documentation.d.ts 3.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805
  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 dirty prepass flag value
  858. */
  859. static readonly MATERIAL_PrePassDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * 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.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * 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.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1058. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1059. */
  1060. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1061. /**
  1062. * Constant used to retrieve the position texture index in the textures array in the prepass
  1063. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1064. */
  1065. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1066. /**
  1067. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1069. */
  1070. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1073. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1074. */
  1075. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1078. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1079. */
  1080. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve albedo index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1091. }
  1092. }
  1093. declare module BABYLON {
  1094. /**
  1095. * This represents the required contract to create a new type of texture loader.
  1096. */
  1097. export interface IInternalTextureLoader {
  1098. /**
  1099. * Defines wether the loader supports cascade loading the different faces.
  1100. */
  1101. supportCascades: boolean;
  1102. /**
  1103. * This returns if the loader support the current file information.
  1104. * @param extension defines the file extension of the file being loaded
  1105. * @param mimeType defines the optional mime type of the file being loaded
  1106. * @returns true if the loader can load the specified file
  1107. */
  1108. canLoad(extension: string, mimeType?: string): boolean;
  1109. /**
  1110. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1111. * @param data contains the texture data
  1112. * @param texture defines the BabylonJS internal texture
  1113. * @param createPolynomials will be true if polynomials have been requested
  1114. * @param onLoad defines the callback to trigger once the texture is ready
  1115. * @param onError defines the callback to trigger in case of error
  1116. */
  1117. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1118. /**
  1119. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1120. * @param data contains the texture data
  1121. * @param texture defines the BabylonJS internal texture
  1122. * @param callback defines the method to call once ready to upload
  1123. */
  1124. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1125. }
  1126. }
  1127. declare module BABYLON {
  1128. /**
  1129. * Class used to store and describe the pipeline context associated with an effect
  1130. */
  1131. export interface IPipelineContext {
  1132. /**
  1133. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1134. */
  1135. isAsync: boolean;
  1136. /**
  1137. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1138. */
  1139. isReady: boolean;
  1140. /** @hidden */
  1141. _getVertexShaderCode(): string | null;
  1142. /** @hidden */
  1143. _getFragmentShaderCode(): string | null;
  1144. /** @hidden */
  1145. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1146. }
  1147. }
  1148. declare module BABYLON {
  1149. /**
  1150. * Class used to store gfx data (like WebGLBuffer)
  1151. */
  1152. export class DataBuffer {
  1153. /**
  1154. * Gets or sets the number of objects referencing this buffer
  1155. */
  1156. references: number;
  1157. /** Gets or sets the size of the underlying buffer */
  1158. capacity: number;
  1159. /**
  1160. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1161. */
  1162. is32Bits: boolean;
  1163. /**
  1164. * Gets the underlying buffer
  1165. */
  1166. get underlyingResource(): any;
  1167. }
  1168. }
  1169. declare module BABYLON {
  1170. /** @hidden */
  1171. export interface IShaderProcessor {
  1172. attributeProcessor?: (attribute: string) => string;
  1173. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1174. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1175. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1176. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1177. lineProcessor?: (line: string, isFragment: boolean) => string;
  1178. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1179. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1180. }
  1181. }
  1182. declare module BABYLON {
  1183. /** @hidden */
  1184. export interface ProcessingOptions {
  1185. defines: string[];
  1186. indexParameters: any;
  1187. isFragment: boolean;
  1188. shouldUseHighPrecisionShader: boolean;
  1189. supportsUniformBuffers: boolean;
  1190. shadersRepository: string;
  1191. includesShadersStore: {
  1192. [key: string]: string;
  1193. };
  1194. processor?: IShaderProcessor;
  1195. version: string;
  1196. platformName: string;
  1197. lookForClosingBracketForUniformBuffer?: boolean;
  1198. }
  1199. }
  1200. declare module BABYLON {
  1201. /** @hidden */
  1202. export class ShaderCodeNode {
  1203. line: string;
  1204. children: ShaderCodeNode[];
  1205. additionalDefineKey?: string;
  1206. additionalDefineValue?: string;
  1207. isValid(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. process(preprocessors: {
  1211. [key: string]: string;
  1212. }, options: ProcessingOptions): string;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderCodeCursor {
  1218. private _lines;
  1219. lineIndex: number;
  1220. get currentLine(): string;
  1221. get canRead(): boolean;
  1222. set lines(value: string[]);
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1228. process(preprocessors: {
  1229. [key: string]: string;
  1230. }, options: ProcessingOptions): string;
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderDefineExpression {
  1236. isTrue(preprocessors: {
  1237. [key: string]: string;
  1238. }): boolean;
  1239. private static _OperatorPriority;
  1240. private static _Stack;
  1241. static postfixToInfix(postfix: string[]): string;
  1242. static infixToPostfix(infix: string): string[];
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /** @hidden */
  1247. export class ShaderCodeTestNode extends ShaderCodeNode {
  1248. testExpression: ShaderDefineExpression;
  1249. isValid(preprocessors: {
  1250. [key: string]: string;
  1251. }): boolean;
  1252. }
  1253. }
  1254. declare module BABYLON {
  1255. /** @hidden */
  1256. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1257. define: string;
  1258. not: boolean;
  1259. constructor(define: string, not?: boolean);
  1260. isTrue(preprocessors: {
  1261. [key: string]: string;
  1262. }): boolean;
  1263. }
  1264. }
  1265. declare module BABYLON {
  1266. /** @hidden */
  1267. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1268. leftOperand: ShaderDefineExpression;
  1269. rightOperand: ShaderDefineExpression;
  1270. isTrue(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module BABYLON {
  1276. /** @hidden */
  1277. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1278. leftOperand: ShaderDefineExpression;
  1279. rightOperand: ShaderDefineExpression;
  1280. isTrue(preprocessors: {
  1281. [key: string]: string;
  1282. }): boolean;
  1283. }
  1284. }
  1285. declare module BABYLON {
  1286. /** @hidden */
  1287. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1288. define: string;
  1289. operand: string;
  1290. testValue: string;
  1291. constructor(define: string, operand: string, testValue: string);
  1292. isTrue(preprocessors: {
  1293. [key: string]: string;
  1294. }): boolean;
  1295. }
  1296. }
  1297. declare module BABYLON {
  1298. /**
  1299. * Class used to enable access to offline support
  1300. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1301. */
  1302. export interface IOfflineProvider {
  1303. /**
  1304. * Gets a boolean indicating if scene must be saved in the database
  1305. */
  1306. enableSceneOffline: boolean;
  1307. /**
  1308. * Gets a boolean indicating if textures must be saved in the database
  1309. */
  1310. enableTexturesOffline: boolean;
  1311. /**
  1312. * Open the offline support and make it available
  1313. * @param successCallback defines the callback to call on success
  1314. * @param errorCallback defines the callback to call on error
  1315. */
  1316. open(successCallback: () => void, errorCallback: () => void): void;
  1317. /**
  1318. * Loads an image from the offline support
  1319. * @param url defines the url to load from
  1320. * @param image defines the target DOM image
  1321. */
  1322. loadImage(url: string, image: HTMLImageElement): void;
  1323. /**
  1324. * Loads a file from offline support
  1325. * @param url defines the URL to load from
  1326. * @param sceneLoaded defines a callback to call on success
  1327. * @param progressCallBack defines a callback to call when progress changed
  1328. * @param errorCallback defines a callback to call on error
  1329. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1330. */
  1331. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1332. }
  1333. }
  1334. declare module BABYLON {
  1335. /**
  1336. * Class used to help managing file picking and drag'n'drop
  1337. * File Storage
  1338. */
  1339. export class FilesInputStore {
  1340. /**
  1341. * List of files ready to be loaded
  1342. */
  1343. static FilesToLoad: {
  1344. [key: string]: File;
  1345. };
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /**
  1350. * Class used to define a retry strategy when error happens while loading assets
  1351. */
  1352. export class RetryStrategy {
  1353. /**
  1354. * Function used to defines an exponential back off strategy
  1355. * @param maxRetries defines the maximum number of retries (3 by default)
  1356. * @param baseInterval defines the interval between retries
  1357. * @returns the strategy function to use
  1358. */
  1359. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1360. }
  1361. }
  1362. declare module BABYLON {
  1363. /**
  1364. * @ignore
  1365. * Application error to support additional information when loading a file
  1366. */
  1367. export abstract class BaseError extends Error {
  1368. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1369. }
  1370. }
  1371. declare module BABYLON {
  1372. /** @ignore */
  1373. export class LoadFileError extends BaseError {
  1374. request?: WebRequest;
  1375. file?: File;
  1376. /**
  1377. * Creates a new LoadFileError
  1378. * @param message defines the message of the error
  1379. * @param request defines the optional web request
  1380. * @param file defines the optional file
  1381. */
  1382. constructor(message: string, object?: WebRequest | File);
  1383. }
  1384. /** @ignore */
  1385. export class RequestFileError extends BaseError {
  1386. request: WebRequest;
  1387. /**
  1388. * Creates a new LoadFileError
  1389. * @param message defines the message of the error
  1390. * @param request defines the optional web request
  1391. */
  1392. constructor(message: string, request: WebRequest);
  1393. }
  1394. /** @ignore */
  1395. export class ReadFileError extends BaseError {
  1396. file: File;
  1397. /**
  1398. * Creates a new ReadFileError
  1399. * @param message defines the message of the error
  1400. * @param file defines the optional file
  1401. */
  1402. constructor(message: string, file: File);
  1403. }
  1404. /**
  1405. * @hidden
  1406. */
  1407. export class FileTools {
  1408. /**
  1409. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1410. */
  1411. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1412. /**
  1413. * Gets or sets the base URL to use to load assets
  1414. */
  1415. static BaseUrl: string;
  1416. /**
  1417. * Default behaviour for cors in the application.
  1418. * It can be a string if the expected behavior is identical in the entire app.
  1419. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1420. */
  1421. static CorsBehavior: string | ((url: string | string[]) => string);
  1422. /**
  1423. * Gets or sets a function used to pre-process url before using them to load assets
  1424. */
  1425. static PreprocessUrl: (url: string) => string;
  1426. /**
  1427. * Removes unwanted characters from an url
  1428. * @param url defines the url to clean
  1429. * @returns the cleaned url
  1430. */
  1431. private static _CleanUrl;
  1432. /**
  1433. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1434. * @param url define the url we are trying
  1435. * @param element define the dom element where to configure the cors policy
  1436. */
  1437. static SetCorsBehavior(url: string | string[], element: {
  1438. crossOrigin: string | null;
  1439. }): void;
  1440. /**
  1441. * Loads an image as an HTMLImageElement.
  1442. * @param input url string, ArrayBuffer, or Blob to load
  1443. * @param onLoad callback called when the image successfully loads
  1444. * @param onError callback called when the image fails to load
  1445. * @param offlineProvider offline provider for caching
  1446. * @param mimeType optional mime type
  1447. * @returns the HTMLImageElement of the loaded image
  1448. */
  1449. 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>;
  1450. /**
  1451. * Reads a file from a File object
  1452. * @param file defines the file to load
  1453. * @param onSuccess defines the callback to call when data is loaded
  1454. * @param onProgress defines the callback to call during loading process
  1455. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1456. * @param onError defines the callback to call when an error occurs
  1457. * @returns a file request object
  1458. */
  1459. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1460. /**
  1461. * Loads a file from a url
  1462. * @param url url to load
  1463. * @param onSuccess callback called when the file successfully loads
  1464. * @param onProgress callback called while file is loading (if the server supports this mode)
  1465. * @param offlineProvider defines the offline provider for caching
  1466. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1467. * @param onError callback called when the file fails to load
  1468. * @returns a file request object
  1469. */
  1470. 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;
  1471. /**
  1472. * Loads a file
  1473. * @param url url to load
  1474. * @param onSuccess callback called when the file successfully loads
  1475. * @param onProgress callback called while file is loading (if the server supports this mode)
  1476. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1477. * @param onError callback called when the file fails to load
  1478. * @param onOpened callback called when the web request is opened
  1479. * @returns a file request object
  1480. */
  1481. 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;
  1482. /**
  1483. * Checks if the loaded document was accessed via `file:`-Protocol.
  1484. * @returns boolean
  1485. */
  1486. static IsFileURL(): boolean;
  1487. }
  1488. }
  1489. declare module BABYLON {
  1490. /** @hidden */
  1491. export class ShaderProcessor {
  1492. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1493. private static _ProcessPrecision;
  1494. private static _ExtractOperation;
  1495. private static _BuildSubExpression;
  1496. private static _BuildExpression;
  1497. private static _MoveCursorWithinIf;
  1498. private static _MoveCursor;
  1499. private static _EvaluatePreProcessors;
  1500. private static _PreparePreProcessors;
  1501. private static _ProcessShaderConversion;
  1502. private static _ProcessIncludes;
  1503. /**
  1504. * Loads a file from a url
  1505. * @param url url to load
  1506. * @param onSuccess callback called when the file successfully loads
  1507. * @param onProgress callback called while file is loading (if the server supports this mode)
  1508. * @param offlineProvider defines the offline provider for caching
  1509. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1510. * @param onError callback called when the file fails to load
  1511. * @returns a file request object
  1512. * @hidden
  1513. */
  1514. 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;
  1515. }
  1516. }
  1517. declare module BABYLON {
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IColor4Like {
  1522. r: float;
  1523. g: float;
  1524. b: float;
  1525. a: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IColor3Like {
  1531. r: float;
  1532. g: float;
  1533. b: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IVector4Like {
  1539. x: float;
  1540. y: float;
  1541. z: float;
  1542. w: float;
  1543. }
  1544. /**
  1545. * @hidden
  1546. */
  1547. export interface IVector3Like {
  1548. x: float;
  1549. y: float;
  1550. z: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector2Like {
  1556. x: float;
  1557. y: float;
  1558. }
  1559. /**
  1560. * @hidden
  1561. */
  1562. export interface IMatrixLike {
  1563. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1564. updateFlag: int;
  1565. }
  1566. /**
  1567. * @hidden
  1568. */
  1569. export interface IViewportLike {
  1570. x: float;
  1571. y: float;
  1572. width: float;
  1573. height: float;
  1574. }
  1575. /**
  1576. * @hidden
  1577. */
  1578. export interface IPlaneLike {
  1579. normal: IVector3Like;
  1580. d: float;
  1581. normalize(): void;
  1582. }
  1583. }
  1584. declare module BABYLON {
  1585. /**
  1586. * Interface used to define common properties for effect fallbacks
  1587. */
  1588. export interface IEffectFallbacks {
  1589. /**
  1590. * Removes the defines that should be removed when falling back.
  1591. * @param currentDefines defines the current define statements for the shader.
  1592. * @param effect defines the current effect we try to compile
  1593. * @returns The resulting defines with defines of the current rank removed.
  1594. */
  1595. reduce(currentDefines: string, effect: Effect): string;
  1596. /**
  1597. * Removes the fallback from the bound mesh.
  1598. */
  1599. unBindMesh(): void;
  1600. /**
  1601. * Checks to see if more fallbacks are still availible.
  1602. */
  1603. hasMoreFallbacks: boolean;
  1604. }
  1605. }
  1606. declare module BABYLON {
  1607. /**
  1608. * Class used to evalaute queries containing `and` and `or` operators
  1609. */
  1610. export class AndOrNotEvaluator {
  1611. /**
  1612. * Evaluate a query
  1613. * @param query defines the query to evaluate
  1614. * @param evaluateCallback defines the callback used to filter result
  1615. * @returns true if the query matches
  1616. */
  1617. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1618. private static _HandleParenthesisContent;
  1619. private static _SimplifyNegation;
  1620. }
  1621. }
  1622. declare module BABYLON {
  1623. /**
  1624. * Class used to store custom tags
  1625. */
  1626. export class Tags {
  1627. /**
  1628. * Adds support for tags on the given object
  1629. * @param obj defines the object to use
  1630. */
  1631. static EnableFor(obj: any): void;
  1632. /**
  1633. * Removes tags support
  1634. * @param obj defines the object to use
  1635. */
  1636. static DisableFor(obj: any): void;
  1637. /**
  1638. * Gets a boolean indicating if the given object has tags
  1639. * @param obj defines the object to use
  1640. * @returns a boolean
  1641. */
  1642. static HasTags(obj: any): boolean;
  1643. /**
  1644. * Gets the tags available on a given object
  1645. * @param obj defines the object to use
  1646. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1647. * @returns the tags
  1648. */
  1649. static GetTags(obj: any, asString?: boolean): any;
  1650. /**
  1651. * Adds tags to an object
  1652. * @param obj defines the object to use
  1653. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1654. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1655. */
  1656. static AddTagsTo(obj: any, tagsString: string): void;
  1657. /**
  1658. * @hidden
  1659. */
  1660. static _AddTagTo(obj: any, tag: string): void;
  1661. /**
  1662. * Removes specific tags from a specific object
  1663. * @param obj defines the object to use
  1664. * @param tagsString defines the tags to remove
  1665. */
  1666. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1667. /**
  1668. * @hidden
  1669. */
  1670. static _RemoveTagFrom(obj: any, tag: string): void;
  1671. /**
  1672. * Defines if tags hosted on an object match a given query
  1673. * @param obj defines the object to use
  1674. * @param tagsQuery defines the tag query
  1675. * @returns a boolean
  1676. */
  1677. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1678. }
  1679. }
  1680. declare module BABYLON {
  1681. /**
  1682. * Scalar computation library
  1683. */
  1684. export class Scalar {
  1685. /**
  1686. * Two pi constants convenient for computation.
  1687. */
  1688. static TwoPi: number;
  1689. /**
  1690. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1691. * @param a number
  1692. * @param b number
  1693. * @param epsilon (default = 1.401298E-45)
  1694. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1695. */
  1696. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1697. /**
  1698. * Returns a string : the upper case translation of the number i to hexadecimal.
  1699. * @param i number
  1700. * @returns the upper case translation of the number i to hexadecimal.
  1701. */
  1702. static ToHex(i: number): string;
  1703. /**
  1704. * Returns -1 if value is negative and +1 is value is positive.
  1705. * @param value the value
  1706. * @returns the value itself if it's equal to zero.
  1707. */
  1708. static Sign(value: number): number;
  1709. /**
  1710. * Returns the value itself if it's between min and max.
  1711. * Returns min if the value is lower than min.
  1712. * Returns max if the value is greater than max.
  1713. * @param value the value to clmap
  1714. * @param min the min value to clamp to (default: 0)
  1715. * @param max the max value to clamp to (default: 1)
  1716. * @returns the clamped value
  1717. */
  1718. static Clamp(value: number, min?: number, max?: number): number;
  1719. /**
  1720. * the log2 of value.
  1721. * @param value the value to compute log2 of
  1722. * @returns the log2 of value.
  1723. */
  1724. static Log2(value: number): number;
  1725. /**
  1726. * Loops the value, so that it is never larger than length and never smaller than 0.
  1727. *
  1728. * This is similar to the modulo operator but it works with floating point numbers.
  1729. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1730. * With t = 5 and length = 2.5, the result would be 0.0.
  1731. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1732. * @param value the value
  1733. * @param length the length
  1734. * @returns the looped value
  1735. */
  1736. static Repeat(value: number, length: number): number;
  1737. /**
  1738. * Normalize the value between 0.0 and 1.0 using min and max values
  1739. * @param value value to normalize
  1740. * @param min max to normalize between
  1741. * @param max min to normalize between
  1742. * @returns the normalized value
  1743. */
  1744. static Normalize(value: number, min: number, max: number): number;
  1745. /**
  1746. * Denormalize the value from 0.0 and 1.0 using min and max values
  1747. * @param normalized value to denormalize
  1748. * @param min max to denormalize between
  1749. * @param max min to denormalize between
  1750. * @returns the denormalized value
  1751. */
  1752. static Denormalize(normalized: number, min: number, max: number): number;
  1753. /**
  1754. * Calculates the shortest difference between two given angles given in degrees.
  1755. * @param current current angle in degrees
  1756. * @param target target angle in degrees
  1757. * @returns the delta
  1758. */
  1759. static DeltaAngle(current: number, target: number): number;
  1760. /**
  1761. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1762. * @param tx value
  1763. * @param length length
  1764. * @returns The returned value will move back and forth between 0 and length
  1765. */
  1766. static PingPong(tx: number, length: number): number;
  1767. /**
  1768. * Interpolates between min and max with smoothing at the limits.
  1769. *
  1770. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1771. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1772. * @param from from
  1773. * @param to to
  1774. * @param tx value
  1775. * @returns the smooth stepped value
  1776. */
  1777. static SmoothStep(from: number, to: number, tx: number): number;
  1778. /**
  1779. * Moves a value current towards target.
  1780. *
  1781. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1782. * Negative values of maxDelta pushes the value away from target.
  1783. * @param current current value
  1784. * @param target target value
  1785. * @param maxDelta max distance to move
  1786. * @returns resulting value
  1787. */
  1788. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1789. /**
  1790. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1791. *
  1792. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1793. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1794. * @param current current value
  1795. * @param target target value
  1796. * @param maxDelta max distance to move
  1797. * @returns resulting angle
  1798. */
  1799. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1800. /**
  1801. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1802. * @param start start value
  1803. * @param end target value
  1804. * @param amount amount to lerp between
  1805. * @returns the lerped value
  1806. */
  1807. static Lerp(start: number, end: number, amount: number): number;
  1808. /**
  1809. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1810. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1811. * @param start start value
  1812. * @param end target value
  1813. * @param amount amount to lerp between
  1814. * @returns the lerped value
  1815. */
  1816. static LerpAngle(start: number, end: number, amount: number): number;
  1817. /**
  1818. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1819. * @param a start value
  1820. * @param b target value
  1821. * @param value value between a and b
  1822. * @returns the inverseLerp value
  1823. */
  1824. static InverseLerp(a: number, b: number, value: number): number;
  1825. /**
  1826. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1827. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1828. * @param value1 spline value
  1829. * @param tangent1 spline value
  1830. * @param value2 spline value
  1831. * @param tangent2 spline value
  1832. * @param amount input value
  1833. * @returns hermite result
  1834. */
  1835. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1836. /**
  1837. * Returns a random float number between and min and max values
  1838. * @param min min value of random
  1839. * @param max max value of random
  1840. * @returns random value
  1841. */
  1842. static RandomRange(min: number, max: number): number;
  1843. /**
  1844. * This function returns percentage of a number in a given range.
  1845. *
  1846. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1847. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1848. * @param number to convert to percentage
  1849. * @param min min range
  1850. * @param max max range
  1851. * @returns the percentage
  1852. */
  1853. static RangeToPercent(number: number, min: number, max: number): number;
  1854. /**
  1855. * This function returns number that corresponds to the percentage in a given range.
  1856. *
  1857. * PercentToRange(0.34,0,100) will return 34.
  1858. * @param percent to convert to number
  1859. * @param min min range
  1860. * @param max max range
  1861. * @returns the number
  1862. */
  1863. static PercentToRange(percent: number, min: number, max: number): number;
  1864. /**
  1865. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1866. * @param angle The angle to normalize in radian.
  1867. * @return The converted angle.
  1868. */
  1869. static NormalizeRadians(angle: number): number;
  1870. }
  1871. }
  1872. declare module BABYLON {
  1873. /**
  1874. * Constant used to convert a value to gamma space
  1875. * @ignorenaming
  1876. */
  1877. export const ToGammaSpace: number;
  1878. /**
  1879. * Constant used to convert a value to linear space
  1880. * @ignorenaming
  1881. */
  1882. export const ToLinearSpace = 2.2;
  1883. /**
  1884. * Constant used to define the minimal number value in Babylon.js
  1885. * @ignorenaming
  1886. */
  1887. let Epsilon: number;
  1888. }
  1889. declare module BABYLON {
  1890. /**
  1891. * Class used to represent a viewport on screen
  1892. */
  1893. export class Viewport {
  1894. /** viewport left coordinate */
  1895. x: number;
  1896. /** viewport top coordinate */
  1897. y: number;
  1898. /**viewport width */
  1899. width: number;
  1900. /** viewport height */
  1901. height: number;
  1902. /**
  1903. * Creates a Viewport object located at (x, y) and sized (width, height)
  1904. * @param x defines viewport left coordinate
  1905. * @param y defines viewport top coordinate
  1906. * @param width defines the viewport width
  1907. * @param height defines the viewport height
  1908. */
  1909. constructor(
  1910. /** viewport left coordinate */
  1911. x: number,
  1912. /** viewport top coordinate */
  1913. y: number,
  1914. /**viewport width */
  1915. width: number,
  1916. /** viewport height */
  1917. height: number);
  1918. /**
  1919. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1920. * @param renderWidth defines the rendering width
  1921. * @param renderHeight defines the rendering height
  1922. * @returns a new Viewport
  1923. */
  1924. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1925. /**
  1926. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @param ref defines the target viewport
  1930. * @returns the current viewport
  1931. */
  1932. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1933. /**
  1934. * Returns a new Viewport copied from the current one
  1935. * @returns a new Viewport
  1936. */
  1937. clone(): Viewport;
  1938. }
  1939. }
  1940. declare module BABYLON {
  1941. /**
  1942. * Class containing a set of static utilities functions for arrays.
  1943. */
  1944. export class ArrayTools {
  1945. /**
  1946. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1947. * @param size the number of element to construct and put in the array
  1948. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1949. * @returns a new array filled with new objects
  1950. */
  1951. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1952. }
  1953. }
  1954. declare module BABYLON {
  1955. /**
  1956. * Represents a plane by the equation ax + by + cz + d = 0
  1957. */
  1958. export class Plane {
  1959. private static _TmpMatrix;
  1960. /**
  1961. * Normal of the plane (a,b,c)
  1962. */
  1963. normal: Vector3;
  1964. /**
  1965. * d component of the plane
  1966. */
  1967. d: number;
  1968. /**
  1969. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1970. * @param a a component of the plane
  1971. * @param b b component of the plane
  1972. * @param c c component of the plane
  1973. * @param d d component of the plane
  1974. */
  1975. constructor(a: number, b: number, c: number, d: number);
  1976. /**
  1977. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1978. */
  1979. asArray(): number[];
  1980. /**
  1981. * @returns a new plane copied from the current Plane.
  1982. */
  1983. clone(): Plane;
  1984. /**
  1985. * @returns the string "Plane".
  1986. */
  1987. getClassName(): string;
  1988. /**
  1989. * @returns the Plane hash code.
  1990. */
  1991. getHashCode(): number;
  1992. /**
  1993. * Normalize the current Plane in place.
  1994. * @returns the updated Plane.
  1995. */
  1996. normalize(): Plane;
  1997. /**
  1998. * Applies a transformation the plane and returns the result
  1999. * @param transformation the transformation matrix to be applied to the plane
  2000. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2001. */
  2002. transform(transformation: DeepImmutable<Matrix>): Plane;
  2003. /**
  2004. * Compute the dot product between the point and the plane normal
  2005. * @param point point to calculate the dot product with
  2006. * @returns the dot product (float) of the point coordinates and the plane normal.
  2007. */
  2008. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2009. /**
  2010. * Updates the current Plane from the plane defined by the three given points.
  2011. * @param point1 one of the points used to contruct the plane
  2012. * @param point2 one of the points used to contruct the plane
  2013. * @param point3 one of the points used to contruct the plane
  2014. * @returns the updated Plane.
  2015. */
  2016. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2017. /**
  2018. * Checks if the plane is facing a given direction
  2019. * @param direction the direction to check if the plane is facing
  2020. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2021. * @returns True is the vector "direction" is the same side than the plane normal.
  2022. */
  2023. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2024. /**
  2025. * Calculates the distance to a point
  2026. * @param point point to calculate distance to
  2027. * @returns the signed distance (float) from the given point to the Plane.
  2028. */
  2029. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2030. /**
  2031. * Creates a plane from an array
  2032. * @param array the array to create a plane from
  2033. * @returns a new Plane from the given array.
  2034. */
  2035. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2036. /**
  2037. * Creates a plane from three points
  2038. * @param point1 point used to create the plane
  2039. * @param point2 point used to create the plane
  2040. * @param point3 point used to create the plane
  2041. * @returns a new Plane defined by the three given points.
  2042. */
  2043. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2044. /**
  2045. * Creates a plane from an origin point and a normal
  2046. * @param origin origin of the plane to be constructed
  2047. * @param normal normal of the plane to be constructed
  2048. * @returns a new Plane the normal vector to this plane at the given origin point.
  2049. * Note : the vector "normal" is updated because normalized.
  2050. */
  2051. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2052. /**
  2053. * Calculates the distance from a plane and a point
  2054. * @param origin origin of the plane to be constructed
  2055. * @param normal normal of the plane to be constructed
  2056. * @param point point to calculate distance to
  2057. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2058. */
  2059. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2060. }
  2061. }
  2062. declare module BABYLON {
  2063. /** @hidden */
  2064. export class PerformanceConfigurator {
  2065. /** @hidden */
  2066. static MatrixUse64Bits: boolean;
  2067. /** @hidden */
  2068. static MatrixTrackPrecisionChange: boolean;
  2069. /** @hidden */
  2070. static MatrixCurrentType: any;
  2071. /** @hidden */
  2072. static MatrixTrackedMatrices: Array<any> | null;
  2073. /** @hidden */
  2074. static SetMatrixPrecision(use64bits: boolean): void;
  2075. }
  2076. }
  2077. declare module BABYLON {
  2078. /**
  2079. * Class representing a vector containing 2 coordinates
  2080. */
  2081. export class Vector2 {
  2082. /** defines the first coordinate */
  2083. x: number;
  2084. /** defines the second coordinate */
  2085. y: number;
  2086. /**
  2087. * Creates a new Vector2 from the given x and y coordinates
  2088. * @param x defines the first coordinate
  2089. * @param y defines the second coordinate
  2090. */
  2091. constructor(
  2092. /** defines the first coordinate */
  2093. x?: number,
  2094. /** defines the second coordinate */
  2095. y?: number);
  2096. /**
  2097. * Gets a string with the Vector2 coordinates
  2098. * @returns a string with the Vector2 coordinates
  2099. */
  2100. toString(): string;
  2101. /**
  2102. * Gets class name
  2103. * @returns the string "Vector2"
  2104. */
  2105. getClassName(): string;
  2106. /**
  2107. * Gets current vector hash code
  2108. * @returns the Vector2 hash code as a number
  2109. */
  2110. getHashCode(): number;
  2111. /**
  2112. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2113. * @param array defines the source array
  2114. * @param index defines the offset in source array
  2115. * @returns the current Vector2
  2116. */
  2117. toArray(array: FloatArray, index?: number): Vector2;
  2118. /**
  2119. * Update the current vector from an array
  2120. * @param array defines the destination array
  2121. * @param index defines the offset in the destination array
  2122. * @returns the current Vector3
  2123. */
  2124. fromArray(array: FloatArray, index?: number): Vector2;
  2125. /**
  2126. * Copy the current vector to an array
  2127. * @returns a new array with 2 elements: the Vector2 coordinates.
  2128. */
  2129. asArray(): number[];
  2130. /**
  2131. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2132. * @param source defines the source Vector2
  2133. * @returns the current updated Vector2
  2134. */
  2135. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2136. /**
  2137. * Sets the Vector2 coordinates with the given floats
  2138. * @param x defines the first coordinate
  2139. * @param y defines the second coordinate
  2140. * @returns the current updated Vector2
  2141. */
  2142. copyFromFloats(x: number, y: number): Vector2;
  2143. /**
  2144. * Sets the Vector2 coordinates with the given floats
  2145. * @param x defines the first coordinate
  2146. * @param y defines the second coordinate
  2147. * @returns the current updated Vector2
  2148. */
  2149. set(x: number, y: number): Vector2;
  2150. /**
  2151. * Add another vector with the current one
  2152. * @param otherVector defines the other vector
  2153. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2154. */
  2155. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2156. /**
  2157. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2158. * @param otherVector defines the other vector
  2159. * @param result defines the target vector
  2160. * @returns the unmodified current Vector2
  2161. */
  2162. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2163. /**
  2164. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2165. * @param otherVector defines the other vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2171. * @param otherVector defines the other vector
  2172. * @returns a new Vector2
  2173. */
  2174. addVector3(otherVector: Vector3): Vector2;
  2175. /**
  2176. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. subtract(otherVector: Vector2): Vector2;
  2181. /**
  2182. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2183. * @param otherVector defines the other vector
  2184. * @param result defines the target vector
  2185. * @returns the unmodified current Vector2
  2186. */
  2187. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2188. /**
  2189. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2190. * @param otherVector defines the other vector
  2191. * @returns the current updated Vector2
  2192. */
  2193. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2194. /**
  2195. * Multiplies in place the current Vector2 coordinates by the given ones
  2196. * @param otherVector defines the other vector
  2197. * @returns the current updated Vector2
  2198. */
  2199. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2202. * @param otherVector defines the other vector
  2203. * @returns a new Vector2
  2204. */
  2205. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2208. * @param otherVector defines the other vector
  2209. * @param result defines the target vector
  2210. * @returns the unmodified current Vector2
  2211. */
  2212. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2213. /**
  2214. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2215. * @param x defines the first coordinate
  2216. * @param y defines the second coordinate
  2217. * @returns a new Vector2
  2218. */
  2219. multiplyByFloats(x: number, y: number): Vector2;
  2220. /**
  2221. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2222. * @param otherVector defines the other vector
  2223. * @returns a new Vector2
  2224. */
  2225. divide(otherVector: Vector2): Vector2;
  2226. /**
  2227. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2228. * @param otherVector defines the other vector
  2229. * @param result defines the target vector
  2230. * @returns the unmodified current Vector2
  2231. */
  2232. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2233. /**
  2234. * Divides the current Vector2 coordinates by the given ones
  2235. * @param otherVector defines the other vector
  2236. * @returns the current updated Vector2
  2237. */
  2238. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2239. /**
  2240. * Gets a new Vector2 with current Vector2 negated coordinates
  2241. * @returns a new Vector2
  2242. */
  2243. negate(): Vector2;
  2244. /**
  2245. * Negate this vector in place
  2246. * @returns this
  2247. */
  2248. negateInPlace(): Vector2;
  2249. /**
  2250. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2251. * @param result defines the Vector3 object where to store the result
  2252. * @returns the current Vector2
  2253. */
  2254. negateToRef(result: Vector2): Vector2;
  2255. /**
  2256. * Multiply the Vector2 coordinates by scale
  2257. * @param scale defines the scaling factor
  2258. * @returns the current updated Vector2
  2259. */
  2260. scaleInPlace(scale: number): Vector2;
  2261. /**
  2262. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2263. * @param scale defines the scaling factor
  2264. * @returns a new Vector2
  2265. */
  2266. scale(scale: number): Vector2;
  2267. /**
  2268. * Scale the current Vector2 values by a factor to a given Vector2
  2269. * @param scale defines the scale factor
  2270. * @param result defines the Vector2 object where to store the result
  2271. * @returns the unmodified current Vector2
  2272. */
  2273. scaleToRef(scale: number, result: Vector2): Vector2;
  2274. /**
  2275. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2276. * @param scale defines the scale factor
  2277. * @param result defines the Vector2 object where to store the result
  2278. * @returns the unmodified current Vector2
  2279. */
  2280. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2281. /**
  2282. * Gets a boolean if two vectors are equals
  2283. * @param otherVector defines the other vector
  2284. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2285. */
  2286. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2287. /**
  2288. * Gets a boolean if two vectors are equals (using an epsilon value)
  2289. * @param otherVector defines the other vector
  2290. * @param epsilon defines the minimal distance to consider equality
  2291. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2292. */
  2293. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2294. /**
  2295. * Gets a new Vector2 from current Vector2 floored values
  2296. * @returns a new Vector2
  2297. */
  2298. floor(): Vector2;
  2299. /**
  2300. * Gets a new Vector2 from current Vector2 floored values
  2301. * @returns a new Vector2
  2302. */
  2303. fract(): Vector2;
  2304. /**
  2305. * Gets the length of the vector
  2306. * @returns the vector length (float)
  2307. */
  2308. length(): number;
  2309. /**
  2310. * Gets the vector squared length
  2311. * @returns the vector squared length (float)
  2312. */
  2313. lengthSquared(): number;
  2314. /**
  2315. * Normalize the vector
  2316. * @returns the current updated Vector2
  2317. */
  2318. normalize(): Vector2;
  2319. /**
  2320. * Gets a new Vector2 copied from the Vector2
  2321. * @returns a new Vector2
  2322. */
  2323. clone(): Vector2;
  2324. /**
  2325. * Gets a new Vector2(0, 0)
  2326. * @returns a new Vector2
  2327. */
  2328. static Zero(): Vector2;
  2329. /**
  2330. * Gets a new Vector2(1, 1)
  2331. * @returns a new Vector2
  2332. */
  2333. static One(): Vector2;
  2334. /**
  2335. * Gets a new Vector2 set from the given index element of the given array
  2336. * @param array defines the data source
  2337. * @param offset defines the offset in the data source
  2338. * @returns a new Vector2
  2339. */
  2340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2341. /**
  2342. * Sets "result" from the given index element of the given array
  2343. * @param array defines the data source
  2344. * @param offset defines the offset in the data source
  2345. * @param result defines the target vector
  2346. */
  2347. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2348. /**
  2349. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2350. * @param value1 defines 1st point of control
  2351. * @param value2 defines 2nd point of control
  2352. * @param value3 defines 3rd point of control
  2353. * @param value4 defines 4th point of control
  2354. * @param amount defines the interpolation factor
  2355. * @returns a new Vector2
  2356. */
  2357. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2358. /**
  2359. * 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".
  2360. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2361. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2362. * @param value defines the value to clamp
  2363. * @param min defines the lower limit
  2364. * @param max defines the upper limit
  2365. * @returns a new Vector2
  2366. */
  2367. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2368. /**
  2369. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2370. * @param value1 defines the 1st control point
  2371. * @param tangent1 defines the outgoing tangent
  2372. * @param value2 defines the 2nd control point
  2373. * @param tangent2 defines the incoming tangent
  2374. * @param amount defines the interpolation factor
  2375. * @returns a new Vector2
  2376. */
  2377. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2378. /**
  2379. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2380. * @param start defines the start vector
  2381. * @param end defines the end vector
  2382. * @param amount defines the interpolation factor
  2383. * @returns a new Vector2
  2384. */
  2385. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2386. /**
  2387. * Gets the dot product of the vector "left" and the vector "right"
  2388. * @param left defines first vector
  2389. * @param right defines second vector
  2390. * @returns the dot product (float)
  2391. */
  2392. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2393. /**
  2394. * Returns a new Vector2 equal to the normalized given vector
  2395. * @param vector defines the vector to normalize
  2396. * @returns a new Vector2
  2397. */
  2398. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2399. /**
  2400. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2401. * @param left defines 1st vector
  2402. * @param right defines 2nd vector
  2403. * @returns a new Vector2
  2404. */
  2405. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2406. /**
  2407. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2408. * @param left defines 1st vector
  2409. * @param right defines 2nd vector
  2410. * @returns a new Vector2
  2411. */
  2412. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2413. /**
  2414. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2415. * @param vector defines the vector to transform
  2416. * @param transformation defines the matrix to apply
  2417. * @returns a new Vector2
  2418. */
  2419. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2420. /**
  2421. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2422. * @param vector defines the vector to transform
  2423. * @param transformation defines the matrix to apply
  2424. * @param result defines the target vector
  2425. */
  2426. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2427. /**
  2428. * Determines if a given vector is included in a triangle
  2429. * @param p defines the vector to test
  2430. * @param p0 defines 1st triangle point
  2431. * @param p1 defines 2nd triangle point
  2432. * @param p2 defines 3rd triangle point
  2433. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2434. */
  2435. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2436. /**
  2437. * Gets the distance between the vectors "value1" and "value2"
  2438. * @param value1 defines first vector
  2439. * @param value2 defines second vector
  2440. * @returns the distance between vectors
  2441. */
  2442. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2443. /**
  2444. * Returns the squared distance between the vectors "value1" and "value2"
  2445. * @param value1 defines first vector
  2446. * @param value2 defines second vector
  2447. * @returns the squared distance between vectors
  2448. */
  2449. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2450. /**
  2451. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2452. * @param value1 defines first vector
  2453. * @param value2 defines second vector
  2454. * @returns a new Vector2
  2455. */
  2456. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2457. /**
  2458. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2459. * @param p defines the middle point
  2460. * @param segA defines one point of the segment
  2461. * @param segB defines the other point of the segment
  2462. * @returns the shortest distance
  2463. */
  2464. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2465. }
  2466. /**
  2467. * Class used to store (x,y,z) vector representation
  2468. * A Vector3 is the main object used in 3D geometry
  2469. * It can represent etiher the coordinates of a point the space, either a direction
  2470. * Reminder: js uses a left handed forward facing system
  2471. */
  2472. export class Vector3 {
  2473. private static _UpReadOnly;
  2474. private static _ZeroReadOnly;
  2475. /** @hidden */
  2476. _x: number;
  2477. /** @hidden */
  2478. _y: number;
  2479. /** @hidden */
  2480. _z: number;
  2481. /** @hidden */
  2482. _isDirty: boolean;
  2483. /** Gets or sets the x coordinate */
  2484. get x(): number;
  2485. set x(value: number);
  2486. /** Gets or sets the y coordinate */
  2487. get y(): number;
  2488. set y(value: number);
  2489. /** Gets or sets the z coordinate */
  2490. get z(): number;
  2491. set z(value: number);
  2492. /**
  2493. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2494. * @param x defines the first coordinates (on X axis)
  2495. * @param y defines the second coordinates (on Y axis)
  2496. * @param z defines the third coordinates (on Z axis)
  2497. */
  2498. constructor(x?: number, y?: number, z?: number);
  2499. /**
  2500. * Creates a string representation of the Vector3
  2501. * @returns a string with the Vector3 coordinates.
  2502. */
  2503. toString(): string;
  2504. /**
  2505. * Gets the class name
  2506. * @returns the string "Vector3"
  2507. */
  2508. getClassName(): string;
  2509. /**
  2510. * Creates the Vector3 hash code
  2511. * @returns a number which tends to be unique between Vector3 instances
  2512. */
  2513. getHashCode(): number;
  2514. /**
  2515. * Creates an array containing three elements : the coordinates of the Vector3
  2516. * @returns a new array of numbers
  2517. */
  2518. asArray(): number[];
  2519. /**
  2520. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2521. * @param array defines the destination array
  2522. * @param index defines the offset in the destination array
  2523. * @returns the current Vector3
  2524. */
  2525. toArray(array: FloatArray, index?: number): Vector3;
  2526. /**
  2527. * Update the current vector from an array
  2528. * @param array defines the destination array
  2529. * @param index defines the offset in the destination array
  2530. * @returns the current Vector3
  2531. */
  2532. fromArray(array: FloatArray, index?: number): Vector3;
  2533. /**
  2534. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2535. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2536. */
  2537. toQuaternion(): Quaternion;
  2538. /**
  2539. * Adds the given vector to the current Vector3
  2540. * @param otherVector defines the second operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2544. /**
  2545. * Adds the given coordinates to the current Vector3
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2554. * @param otherVector defines the second operand
  2555. * @returns the resulting Vector3
  2556. */
  2557. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2558. /**
  2559. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2560. * @param otherVector defines the second operand
  2561. * @param result defines the Vector3 object where to store the result
  2562. * @returns the current Vector3
  2563. */
  2564. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2565. /**
  2566. * Subtract the given vector from the current Vector3
  2567. * @param otherVector defines the second operand
  2568. * @returns the current updated Vector3
  2569. */
  2570. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2573. * @param otherVector defines the second operand
  2574. * @returns the resulting Vector3
  2575. */
  2576. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2577. /**
  2578. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2579. * @param otherVector defines the second operand
  2580. * @param result defines the Vector3 object where to store the result
  2581. * @returns the current Vector3
  2582. */
  2583. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2584. /**
  2585. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2586. * @param x defines the x coordinate of the operand
  2587. * @param y defines the y coordinate of the operand
  2588. * @param z defines the z coordinate of the operand
  2589. * @returns the resulting Vector3
  2590. */
  2591. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2592. /**
  2593. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2594. * @param x defines the x coordinate of the operand
  2595. * @param y defines the y coordinate of the operand
  2596. * @param z defines the z coordinate of the operand
  2597. * @param result defines the Vector3 object where to store the result
  2598. * @returns the current Vector3
  2599. */
  2600. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2601. /**
  2602. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2603. * @returns a new Vector3
  2604. */
  2605. negate(): Vector3;
  2606. /**
  2607. * Negate this vector in place
  2608. * @returns this
  2609. */
  2610. negateInPlace(): Vector3;
  2611. /**
  2612. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2613. * @param result defines the Vector3 object where to store the result
  2614. * @returns the current Vector3
  2615. */
  2616. negateToRef(result: Vector3): Vector3;
  2617. /**
  2618. * Multiplies the Vector3 coordinates by the float "scale"
  2619. * @param scale defines the multiplier factor
  2620. * @returns the current updated Vector3
  2621. */
  2622. scaleInPlace(scale: number): Vector3;
  2623. /**
  2624. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2625. * @param scale defines the multiplier factor
  2626. * @returns a new Vector3
  2627. */
  2628. scale(scale: number): Vector3;
  2629. /**
  2630. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2631. * @param scale defines the multiplier factor
  2632. * @param result defines the Vector3 object where to store the result
  2633. * @returns the current Vector3
  2634. */
  2635. scaleToRef(scale: number, result: Vector3): Vector3;
  2636. /**
  2637. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2638. * @param scale defines the scale factor
  2639. * @param result defines the Vector3 object where to store the result
  2640. * @returns the unmodified current Vector3
  2641. */
  2642. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2643. /**
  2644. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2645. * @param origin defines the origin of the projection ray
  2646. * @param plane defines the plane to project to
  2647. * @returns the projected vector3
  2648. */
  2649. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2650. /**
  2651. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2652. * @param origin defines the origin of the projection ray
  2653. * @param plane defines the plane to project to
  2654. * @param result defines the Vector3 where to store the result
  2655. */
  2656. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2657. /**
  2658. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2659. * @param otherVector defines the second operand
  2660. * @returns true if both vectors are equals
  2661. */
  2662. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2663. /**
  2664. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2665. * @param otherVector defines the second operand
  2666. * @param epsilon defines the minimal distance to define values as equals
  2667. * @returns true if both vectors are distant less than epsilon
  2668. */
  2669. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2670. /**
  2671. * Returns true if the current Vector3 coordinates equals the given floats
  2672. * @param x defines the x coordinate of the operand
  2673. * @param y defines the y coordinate of the operand
  2674. * @param z defines the z coordinate of the operand
  2675. * @returns true if both vectors are equals
  2676. */
  2677. equalsToFloats(x: number, y: number, z: number): boolean;
  2678. /**
  2679. * Multiplies the current Vector3 coordinates by the given ones
  2680. * @param otherVector defines the second operand
  2681. * @returns the current updated Vector3
  2682. */
  2683. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2684. /**
  2685. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2686. * @param otherVector defines the second operand
  2687. * @returns the new Vector3
  2688. */
  2689. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2690. /**
  2691. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2692. * @param otherVector defines the second operand
  2693. * @param result defines the Vector3 object where to store the result
  2694. * @returns the current Vector3
  2695. */
  2696. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2697. /**
  2698. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2699. * @param x defines the x coordinate of the operand
  2700. * @param y defines the y coordinate of the operand
  2701. * @param z defines the z coordinate of the operand
  2702. * @returns the new Vector3
  2703. */
  2704. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2705. /**
  2706. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2707. * @param otherVector defines the second operand
  2708. * @returns the new Vector3
  2709. */
  2710. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2711. /**
  2712. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2713. * @param otherVector defines the second operand
  2714. * @param result defines the Vector3 object where to store the result
  2715. * @returns the current Vector3
  2716. */
  2717. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2718. /**
  2719. * Divides the current Vector3 coordinates by the given ones.
  2720. * @param otherVector defines the second operand
  2721. * @returns the current updated Vector3
  2722. */
  2723. divideInPlace(otherVector: Vector3): Vector3;
  2724. /**
  2725. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2726. * @param other defines the second operand
  2727. * @returns the current updated Vector3
  2728. */
  2729. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2730. /**
  2731. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2732. * @param other defines the second operand
  2733. * @returns the current updated Vector3
  2734. */
  2735. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2736. /**
  2737. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2738. * @param x defines the x coordinate of the operand
  2739. * @param y defines the y coordinate of the operand
  2740. * @param z defines the z coordinate of the operand
  2741. * @returns the current updated Vector3
  2742. */
  2743. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2744. /**
  2745. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2746. * @param x defines the x coordinate of the operand
  2747. * @param y defines the y coordinate of the operand
  2748. * @param z defines the z coordinate of the operand
  2749. * @returns the current updated Vector3
  2750. */
  2751. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2752. /**
  2753. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2754. * Check if is non uniform within a certain amount of decimal places to account for this
  2755. * @param epsilon the amount the values can differ
  2756. * @returns if the the vector is non uniform to a certain number of decimal places
  2757. */
  2758. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2759. /**
  2760. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2761. */
  2762. get isNonUniform(): boolean;
  2763. /**
  2764. * Gets a new Vector3 from current Vector3 floored values
  2765. * @returns a new Vector3
  2766. */
  2767. floor(): Vector3;
  2768. /**
  2769. * Gets a new Vector3 from current Vector3 floored values
  2770. * @returns a new Vector3
  2771. */
  2772. fract(): Vector3;
  2773. /**
  2774. * Gets the length of the Vector3
  2775. * @returns the length of the Vector3
  2776. */
  2777. length(): number;
  2778. /**
  2779. * Gets the squared length of the Vector3
  2780. * @returns squared length of the Vector3
  2781. */
  2782. lengthSquared(): number;
  2783. /**
  2784. * Normalize the current Vector3.
  2785. * Please note that this is an in place operation.
  2786. * @returns the current updated Vector3
  2787. */
  2788. normalize(): Vector3;
  2789. /**
  2790. * Reorders the x y z properties of the vector in place
  2791. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2792. * @returns the current updated vector
  2793. */
  2794. reorderInPlace(order: string): this;
  2795. /**
  2796. * Rotates the vector around 0,0,0 by a quaternion
  2797. * @param quaternion the rotation quaternion
  2798. * @param result vector to store the result
  2799. * @returns the resulting vector
  2800. */
  2801. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2802. /**
  2803. * Rotates a vector around a given point
  2804. * @param quaternion the rotation quaternion
  2805. * @param point the point to rotate around
  2806. * @param result vector to store the result
  2807. * @returns the resulting vector
  2808. */
  2809. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2810. /**
  2811. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2812. * The cross product is then orthogonal to both current and "other"
  2813. * @param other defines the right operand
  2814. * @returns the cross product
  2815. */
  2816. cross(other: Vector3): Vector3;
  2817. /**
  2818. * Normalize the current Vector3 with the given input length.
  2819. * Please note that this is an in place operation.
  2820. * @param len the length of the vector
  2821. * @returns the current updated Vector3
  2822. */
  2823. normalizeFromLength(len: number): Vector3;
  2824. /**
  2825. * Normalize the current Vector3 to a new vector
  2826. * @returns the new Vector3
  2827. */
  2828. normalizeToNew(): Vector3;
  2829. /**
  2830. * Normalize the current Vector3 to the reference
  2831. * @param reference define the Vector3 to update
  2832. * @returns the updated Vector3
  2833. */
  2834. normalizeToRef(reference: Vector3): Vector3;
  2835. /**
  2836. * Creates a new Vector3 copied from the current Vector3
  2837. * @returns the new Vector3
  2838. */
  2839. clone(): Vector3;
  2840. /**
  2841. * Copies the given vector coordinates to the current Vector3 ones
  2842. * @param source defines the source Vector3
  2843. * @returns the current updated Vector3
  2844. */
  2845. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2846. /**
  2847. * Copies the given floats to the current Vector3 coordinates
  2848. * @param x defines the x coordinate of the operand
  2849. * @param y defines the y coordinate of the operand
  2850. * @param z defines the z coordinate of the operand
  2851. * @returns the current updated Vector3
  2852. */
  2853. copyFromFloats(x: number, y: number, z: number): Vector3;
  2854. /**
  2855. * Copies the given floats to the current Vector3 coordinates
  2856. * @param x defines the x coordinate of the operand
  2857. * @param y defines the y coordinate of the operand
  2858. * @param z defines the z coordinate of the operand
  2859. * @returns the current updated Vector3
  2860. */
  2861. set(x: number, y: number, z: number): Vector3;
  2862. /**
  2863. * Copies the given float to the current Vector3 coordinates
  2864. * @param v defines the x, y and z coordinates of the operand
  2865. * @returns the current updated Vector3
  2866. */
  2867. setAll(v: number): Vector3;
  2868. /**
  2869. * Get the clip factor between two vectors
  2870. * @param vector0 defines the first operand
  2871. * @param vector1 defines the second operand
  2872. * @param axis defines the axis to use
  2873. * @param size defines the size along the axis
  2874. * @returns the clip factor
  2875. */
  2876. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2877. /**
  2878. * Get angle between two vectors
  2879. * @param vector0 angle between vector0 and vector1
  2880. * @param vector1 angle between vector0 and vector1
  2881. * @param normal direction of the normal
  2882. * @return the angle between vector0 and vector1
  2883. */
  2884. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2885. /**
  2886. * Returns a new Vector3 set from the index "offset" of the given array
  2887. * @param array defines the source array
  2888. * @param offset defines the offset in the source array
  2889. * @returns the new Vector3
  2890. */
  2891. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2892. /**
  2893. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2894. * @param array defines the source array
  2895. * @param offset defines the offset in the source array
  2896. * @returns the new Vector3
  2897. * @deprecated Please use FromArray instead.
  2898. */
  2899. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2900. /**
  2901. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2902. * @param array defines the source array
  2903. * @param offset defines the offset in the source array
  2904. * @param result defines the Vector3 where to store the result
  2905. */
  2906. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2907. /**
  2908. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2909. * @param array defines the source array
  2910. * @param offset defines the offset in the source array
  2911. * @param result defines the Vector3 where to store the result
  2912. * @deprecated Please use FromArrayToRef instead.
  2913. */
  2914. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2915. /**
  2916. * Sets the given vector "result" with the given floats.
  2917. * @param x defines the x coordinate of the source
  2918. * @param y defines the y coordinate of the source
  2919. * @param z defines the z coordinate of the source
  2920. * @param result defines the Vector3 where to store the result
  2921. */
  2922. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2925. * @returns a new empty Vector3
  2926. */
  2927. static Zero(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2930. * @returns a new unit Vector3
  2931. */
  2932. static One(): Vector3;
  2933. /**
  2934. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2935. * @returns a new up Vector3
  2936. */
  2937. static Up(): Vector3;
  2938. /**
  2939. * Gets a up Vector3 that must not be updated
  2940. */
  2941. static get UpReadOnly(): DeepImmutable<Vector3>;
  2942. /**
  2943. * Gets a zero Vector3 that must not be updated
  2944. */
  2945. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2948. * @returns a new down Vector3
  2949. */
  2950. static Down(): Vector3;
  2951. /**
  2952. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2953. * @param rightHandedSystem is the scene right-handed (negative z)
  2954. * @returns a new forward Vector3
  2955. */
  2956. static Forward(rightHandedSystem?: boolean): Vector3;
  2957. /**
  2958. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2959. * @param rightHandedSystem is the scene right-handed (negative-z)
  2960. * @returns a new forward Vector3
  2961. */
  2962. static Backward(rightHandedSystem?: boolean): Vector3;
  2963. /**
  2964. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2965. * @returns a new right Vector3
  2966. */
  2967. static Right(): Vector3;
  2968. /**
  2969. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2970. * @returns a new left Vector3
  2971. */
  2972. static Left(): Vector3;
  2973. /**
  2974. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2975. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2976. * @param vector defines the Vector3 to transform
  2977. * @param transformation defines the transformation matrix
  2978. * @returns the transformed Vector3
  2979. */
  2980. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2981. /**
  2982. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2983. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2984. * @param vector defines the Vector3 to transform
  2985. * @param transformation defines the transformation matrix
  2986. * @param result defines the Vector3 where to store the result
  2987. */
  2988. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2989. /**
  2990. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2991. * This method computes tranformed coordinates only, not transformed direction vectors
  2992. * @param x define the x coordinate of the source vector
  2993. * @param y define the y coordinate of the source vector
  2994. * @param z define the z coordinate of the source vector
  2995. * @param transformation defines the transformation matrix
  2996. * @param result defines the Vector3 where to store the result
  2997. */
  2998. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2999. /**
  3000. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3001. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3002. * @param vector defines the Vector3 to transform
  3003. * @param transformation defines the transformation matrix
  3004. * @returns the new Vector3
  3005. */
  3006. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3007. /**
  3008. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3009. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3010. * @param vector defines the Vector3 to transform
  3011. * @param transformation defines the transformation matrix
  3012. * @param result defines the Vector3 where to store the result
  3013. */
  3014. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3015. /**
  3016. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3017. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3018. * @param x define the x coordinate of the source vector
  3019. * @param y define the y coordinate of the source vector
  3020. * @param z define the z coordinate of the source vector
  3021. * @param transformation defines the transformation matrix
  3022. * @param result defines the Vector3 where to store the result
  3023. */
  3024. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3025. /**
  3026. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3027. * @param value1 defines the first control point
  3028. * @param value2 defines the second control point
  3029. * @param value3 defines the third control point
  3030. * @param value4 defines the fourth control point
  3031. * @param amount defines the amount on the spline to use
  3032. * @returns the new Vector3
  3033. */
  3034. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3035. /**
  3036. * 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"
  3037. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3038. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3039. * @param value defines the current value
  3040. * @param min defines the lower range value
  3041. * @param max defines the upper range value
  3042. * @returns the new Vector3
  3043. */
  3044. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3045. /**
  3046. * 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"
  3047. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3048. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3049. * @param value defines the current value
  3050. * @param min defines the lower range value
  3051. * @param max defines the upper range value
  3052. * @param result defines the Vector3 where to store the result
  3053. */
  3054. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3055. /**
  3056. * Checks if a given vector is inside a specific range
  3057. * @param v defines the vector to test
  3058. * @param min defines the minimum range
  3059. * @param max defines the maximum range
  3060. */
  3061. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3062. /**
  3063. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3064. * @param value1 defines the first control point
  3065. * @param tangent1 defines the first tangent vector
  3066. * @param value2 defines the second control point
  3067. * @param tangent2 defines the second tangent vector
  3068. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3069. * @returns the new Vector3
  3070. */
  3071. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3072. /**
  3073. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3074. * @param start defines the start value
  3075. * @param end defines the end value
  3076. * @param amount max defines amount between both (between 0 and 1)
  3077. * @returns the new Vector3
  3078. */
  3079. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3082. * @param start defines the start value
  3083. * @param end defines the end value
  3084. * @param amount max defines amount between both (between 0 and 1)
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3088. /**
  3089. * Returns the dot product (float) between the vectors "left" and "right"
  3090. * @param left defines the left operand
  3091. * @param right defines the right operand
  3092. * @returns the dot product
  3093. */
  3094. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3095. /**
  3096. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3097. * The cross product is then orthogonal to both "left" and "right"
  3098. * @param left defines the left operand
  3099. * @param right defines the right operand
  3100. * @returns the cross product
  3101. */
  3102. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3103. /**
  3104. * Sets the given vector "result" with the cross product of "left" and "right"
  3105. * The cross product is then orthogonal to both "left" and "right"
  3106. * @param left defines the left operand
  3107. * @param right defines the right operand
  3108. * @param result defines the Vector3 where to store the result
  3109. */
  3110. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3111. /**
  3112. * Returns a new Vector3 as the normalization of the given vector
  3113. * @param vector defines the Vector3 to normalize
  3114. * @returns the new Vector3
  3115. */
  3116. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3117. /**
  3118. * Sets the given vector "result" with the normalization of the given first vector
  3119. * @param vector defines the Vector3 to normalize
  3120. * @param result defines the Vector3 where to store the result
  3121. */
  3122. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3123. /**
  3124. * Project a Vector3 onto screen space
  3125. * @param vector defines the Vector3 to project
  3126. * @param world defines the world matrix to use
  3127. * @param transform defines the transform (view x projection) matrix to use
  3128. * @param viewport defines the screen viewport to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3132. /** @hidden */
  3133. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3134. /**
  3135. * Unproject from screen space to object space
  3136. * @param source defines the screen space Vector3 to use
  3137. * @param viewportWidth defines the current width of the viewport
  3138. * @param viewportHeight defines the current height of the viewport
  3139. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @returns the new Vector3
  3142. */
  3143. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3144. /**
  3145. * Unproject from screen space to object space
  3146. * @param source defines the screen space Vector3 to use
  3147. * @param viewportWidth defines the current width of the viewport
  3148. * @param viewportHeight defines the current height of the viewport
  3149. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3150. * @param view defines the view matrix to use
  3151. * @param projection defines the projection matrix to use
  3152. * @returns the new Vector3
  3153. */
  3154. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3155. /**
  3156. * Unproject from screen space to object space
  3157. * @param source defines the screen space Vector3 to use
  3158. * @param viewportWidth defines the current width of the viewport
  3159. * @param viewportHeight defines the current height of the viewport
  3160. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3161. * @param view defines the view matrix to use
  3162. * @param projection defines the projection matrix to use
  3163. * @param result defines the Vector3 where to store the result
  3164. */
  3165. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3166. /**
  3167. * Unproject from screen space to object space
  3168. * @param sourceX defines the screen space x coordinate to use
  3169. * @param sourceY defines the screen space y coordinate to use
  3170. * @param sourceZ defines the screen space z coordinate to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Gets the minimal coordinate values between two Vector3
  3181. * @param left defines the first operand
  3182. * @param right defines the second operand
  3183. * @returns the new Vector3
  3184. */
  3185. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3186. /**
  3187. * Gets the maximal coordinate values between two Vector3
  3188. * @param left defines the first operand
  3189. * @param right defines the second operand
  3190. * @returns the new Vector3
  3191. */
  3192. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * Returns the distance between the vectors "value1" and "value2"
  3195. * @param value1 defines the first operand
  3196. * @param value2 defines the second operand
  3197. * @returns the distance
  3198. */
  3199. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3200. /**
  3201. * Returns the squared distance between the vectors "value1" and "value2"
  3202. * @param value1 defines the first operand
  3203. * @param value2 defines the second operand
  3204. * @returns the squared distance
  3205. */
  3206. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3207. /**
  3208. * Returns a new Vector3 located at the center between "value1" and "value2"
  3209. * @param value1 defines the first operand
  3210. * @param value2 defines the second operand
  3211. * @returns the new Vector3
  3212. */
  3213. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3214. /**
  3215. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3216. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3217. * to something in order to rotate it from its local system to the given target system
  3218. * Note: axis1, axis2 and axis3 are normalized during this operation
  3219. * @param axis1 defines the first axis
  3220. * @param axis2 defines the second axis
  3221. * @param axis3 defines the third axis
  3222. * @returns a new Vector3
  3223. */
  3224. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3225. /**
  3226. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3227. * @param axis1 defines the first axis
  3228. * @param axis2 defines the second axis
  3229. * @param axis3 defines the third axis
  3230. * @param ref defines the Vector3 where to store the result
  3231. */
  3232. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3233. }
  3234. /**
  3235. * Vector4 class created for EulerAngle class conversion to Quaternion
  3236. */
  3237. export class Vector4 {
  3238. /** x value of the vector */
  3239. x: number;
  3240. /** y value of the vector */
  3241. y: number;
  3242. /** z value of the vector */
  3243. z: number;
  3244. /** w value of the vector */
  3245. w: number;
  3246. /**
  3247. * Creates a Vector4 object from the given floats.
  3248. * @param x x value of the vector
  3249. * @param y y value of the vector
  3250. * @param z z value of the vector
  3251. * @param w w value of the vector
  3252. */
  3253. constructor(
  3254. /** x value of the vector */
  3255. x: number,
  3256. /** y value of the vector */
  3257. y: number,
  3258. /** z value of the vector */
  3259. z: number,
  3260. /** w value of the vector */
  3261. w: number);
  3262. /**
  3263. * Returns the string with the Vector4 coordinates.
  3264. * @returns a string containing all the vector values
  3265. */
  3266. toString(): string;
  3267. /**
  3268. * Returns the string "Vector4".
  3269. * @returns "Vector4"
  3270. */
  3271. getClassName(): string;
  3272. /**
  3273. * Returns the Vector4 hash code.
  3274. * @returns a unique hash code
  3275. */
  3276. getHashCode(): number;
  3277. /**
  3278. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3279. * @returns the resulting array
  3280. */
  3281. asArray(): number[];
  3282. /**
  3283. * Populates the given array from the given index with the Vector4 coordinates.
  3284. * @param array array to populate
  3285. * @param index index of the array to start at (default: 0)
  3286. * @returns the Vector4.
  3287. */
  3288. toArray(array: FloatArray, index?: number): Vector4;
  3289. /**
  3290. * Update the current vector from an array
  3291. * @param array defines the destination array
  3292. * @param index defines the offset in the destination array
  3293. * @returns the current Vector3
  3294. */
  3295. fromArray(array: FloatArray, index?: number): Vector4;
  3296. /**
  3297. * Adds the given vector to the current Vector4.
  3298. * @param otherVector the vector to add
  3299. * @returns the updated Vector4.
  3300. */
  3301. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3302. /**
  3303. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3304. * @param otherVector the vector to add
  3305. * @returns the resulting vector
  3306. */
  3307. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3308. /**
  3309. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3310. * @param otherVector the vector to add
  3311. * @param result the vector to store the result
  3312. * @returns the current Vector4.
  3313. */
  3314. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3315. /**
  3316. * Subtract in place the given vector from the current Vector4.
  3317. * @param otherVector the vector to subtract
  3318. * @returns the updated Vector4.
  3319. */
  3320. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3323. * @param otherVector the vector to add
  3324. * @returns the new vector with the result
  3325. */
  3326. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3327. /**
  3328. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3329. * @param otherVector the vector to subtract
  3330. * @param result the vector to store the result
  3331. * @returns the current Vector4.
  3332. */
  3333. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3336. */
  3337. /**
  3338. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3339. * @param x value to subtract
  3340. * @param y value to subtract
  3341. * @param z value to subtract
  3342. * @param w value to subtract
  3343. * @returns new vector containing the result
  3344. */
  3345. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3346. /**
  3347. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3348. * @param x value to subtract
  3349. * @param y value to subtract
  3350. * @param z value to subtract
  3351. * @param w value to subtract
  3352. * @param result the vector to store the result in
  3353. * @returns the current Vector4.
  3354. */
  3355. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3356. /**
  3357. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3358. * @returns a new vector with the negated values
  3359. */
  3360. negate(): Vector4;
  3361. /**
  3362. * Negate this vector in place
  3363. * @returns this
  3364. */
  3365. negateInPlace(): Vector4;
  3366. /**
  3367. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3368. * @param result defines the Vector3 object where to store the result
  3369. * @returns the current Vector4
  3370. */
  3371. negateToRef(result: Vector4): Vector4;
  3372. /**
  3373. * Multiplies the current Vector4 coordinates by scale (float).
  3374. * @param scale the number to scale with
  3375. * @returns the updated Vector4.
  3376. */
  3377. scaleInPlace(scale: number): Vector4;
  3378. /**
  3379. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3380. * @param scale the number to scale with
  3381. * @returns a new vector with the result
  3382. */
  3383. scale(scale: number): Vector4;
  3384. /**
  3385. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3386. * @param scale the number to scale with
  3387. * @param result a vector to store the result in
  3388. * @returns the current Vector4.
  3389. */
  3390. scaleToRef(scale: number, result: Vector4): Vector4;
  3391. /**
  3392. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3393. * @param scale defines the scale factor
  3394. * @param result defines the Vector4 object where to store the result
  3395. * @returns the unmodified current Vector4
  3396. */
  3397. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3398. /**
  3399. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3400. * @param otherVector the vector to compare against
  3401. * @returns true if they are equal
  3402. */
  3403. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3404. /**
  3405. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3406. * @param otherVector vector to compare against
  3407. * @param epsilon (Default: very small number)
  3408. * @returns true if they are equal
  3409. */
  3410. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3411. /**
  3412. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3413. * @param x x value to compare against
  3414. * @param y y value to compare against
  3415. * @param z z value to compare against
  3416. * @param w w value to compare against
  3417. * @returns true if equal
  3418. */
  3419. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3420. /**
  3421. * Multiplies in place the current Vector4 by the given one.
  3422. * @param otherVector vector to multiple with
  3423. * @returns the updated Vector4.
  3424. */
  3425. multiplyInPlace(otherVector: Vector4): Vector4;
  3426. /**
  3427. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3428. * @param otherVector vector to multiple with
  3429. * @returns resulting new vector
  3430. */
  3431. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3432. /**
  3433. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3434. * @param otherVector vector to multiple with
  3435. * @param result vector to store the result
  3436. * @returns the current Vector4.
  3437. */
  3438. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3441. * @param x x value multiply with
  3442. * @param y y value multiply with
  3443. * @param z z value multiply with
  3444. * @param w w value multiply with
  3445. * @returns resulting new vector
  3446. */
  3447. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3448. /**
  3449. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3450. * @param otherVector vector to devide with
  3451. * @returns resulting new vector
  3452. */
  3453. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3454. /**
  3455. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3456. * @param otherVector vector to devide with
  3457. * @param result vector to store the result
  3458. * @returns the current Vector4.
  3459. */
  3460. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3461. /**
  3462. * Divides the current Vector3 coordinates by the given ones.
  3463. * @param otherVector vector to devide with
  3464. * @returns the updated Vector3.
  3465. */
  3466. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3469. * @param other defines the second operand
  3470. * @returns the current updated Vector4
  3471. */
  3472. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3473. /**
  3474. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3475. * @param other defines the second operand
  3476. * @returns the current updated Vector4
  3477. */
  3478. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3479. /**
  3480. * Gets a new Vector4 from current Vector4 floored values
  3481. * @returns a new Vector4
  3482. */
  3483. floor(): Vector4;
  3484. /**
  3485. * Gets a new Vector4 from current Vector3 floored values
  3486. * @returns a new Vector4
  3487. */
  3488. fract(): Vector4;
  3489. /**
  3490. * Returns the Vector4 length (float).
  3491. * @returns the length
  3492. */
  3493. length(): number;
  3494. /**
  3495. * Returns the Vector4 squared length (float).
  3496. * @returns the length squared
  3497. */
  3498. lengthSquared(): number;
  3499. /**
  3500. * Normalizes in place the Vector4.
  3501. * @returns the updated Vector4.
  3502. */
  3503. normalize(): Vector4;
  3504. /**
  3505. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3506. * @returns this converted to a new vector3
  3507. */
  3508. toVector3(): Vector3;
  3509. /**
  3510. * Returns a new Vector4 copied from the current one.
  3511. * @returns the new cloned vector
  3512. */
  3513. clone(): Vector4;
  3514. /**
  3515. * Updates the current Vector4 with the given one coordinates.
  3516. * @param source the source vector to copy from
  3517. * @returns the updated Vector4.
  3518. */
  3519. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3520. /**
  3521. * Updates the current Vector4 coordinates with the given floats.
  3522. * @param x float to copy from
  3523. * @param y float to copy from
  3524. * @param z float to copy from
  3525. * @param w float to copy from
  3526. * @returns the updated Vector4.
  3527. */
  3528. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3529. /**
  3530. * Updates the current Vector4 coordinates with the given floats.
  3531. * @param x float to set from
  3532. * @param y float to set from
  3533. * @param z float to set from
  3534. * @param w float to set from
  3535. * @returns the updated Vector4.
  3536. */
  3537. set(x: number, y: number, z: number, w: number): Vector4;
  3538. /**
  3539. * Copies the given float to the current Vector3 coordinates
  3540. * @param v defines the x, y, z and w coordinates of the operand
  3541. * @returns the current updated Vector3
  3542. */
  3543. setAll(v: number): Vector4;
  3544. /**
  3545. * Returns a new Vector4 set from the starting index of the given array.
  3546. * @param array the array to pull values from
  3547. * @param offset the offset into the array to start at
  3548. * @returns the new vector
  3549. */
  3550. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3551. /**
  3552. * Updates the given vector "result" from the starting index of the given array.
  3553. * @param array the array to pull values from
  3554. * @param offset the offset into the array to start at
  3555. * @param result the vector to store the result in
  3556. */
  3557. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3558. /**
  3559. * Updates the given vector "result" from the starting index of the given Float32Array.
  3560. * @param array the array to pull values from
  3561. * @param offset the offset into the array to start at
  3562. * @param result the vector to store the result in
  3563. */
  3564. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3565. /**
  3566. * Updates the given vector "result" coordinates from the given floats.
  3567. * @param x float to set from
  3568. * @param y float to set from
  3569. * @param z float to set from
  3570. * @param w float to set from
  3571. * @param result the vector to the floats in
  3572. */
  3573. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3574. /**
  3575. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3576. * @returns the new vector
  3577. */
  3578. static Zero(): Vector4;
  3579. /**
  3580. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3581. * @returns the new vector
  3582. */
  3583. static One(): Vector4;
  3584. /**
  3585. * Returns a new normalized Vector4 from the given one.
  3586. * @param vector the vector to normalize
  3587. * @returns the vector
  3588. */
  3589. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3590. /**
  3591. * Updates the given vector "result" from the normalization of the given one.
  3592. * @param vector the vector to normalize
  3593. * @param result the vector to store the result in
  3594. */
  3595. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3596. /**
  3597. * Returns a vector with the minimum values from the left and right vectors
  3598. * @param left left vector to minimize
  3599. * @param right right vector to minimize
  3600. * @returns a new vector with the minimum of the left and right vector values
  3601. */
  3602. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Returns a vector with the maximum values from the left and right vectors
  3605. * @param left left vector to maximize
  3606. * @param right right vector to maximize
  3607. * @returns a new vector with the maximum of the left and right vector values
  3608. */
  3609. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3610. /**
  3611. * Returns the distance (float) between the vectors "value1" and "value2".
  3612. * @param value1 value to calulate the distance between
  3613. * @param value2 value to calulate the distance between
  3614. * @return the distance between the two vectors
  3615. */
  3616. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3617. /**
  3618. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3619. * @param value1 value to calulate the distance between
  3620. * @param value2 value to calulate the distance between
  3621. * @return the distance between the two vectors squared
  3622. */
  3623. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3624. /**
  3625. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3626. * @param value1 value to calulate the center between
  3627. * @param value2 value to calulate the center between
  3628. * @return the center between the two vectors
  3629. */
  3630. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3631. /**
  3632. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3633. * This methods computes transformed normalized direction vectors only.
  3634. * @param vector the vector to transform
  3635. * @param transformation the transformation matrix to apply
  3636. * @returns the new vector
  3637. */
  3638. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3639. /**
  3640. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3641. * This methods computes transformed normalized direction vectors only.
  3642. * @param vector the vector to transform
  3643. * @param transformation the transformation matrix to apply
  3644. * @param result the vector to store the result in
  3645. */
  3646. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3647. /**
  3648. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3649. * This methods computes transformed normalized direction vectors only.
  3650. * @param x value to transform
  3651. * @param y value to transform
  3652. * @param z value to transform
  3653. * @param w value to transform
  3654. * @param transformation the transformation matrix to apply
  3655. * @param result the vector to store the results in
  3656. */
  3657. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3658. /**
  3659. * Creates a new Vector4 from a Vector3
  3660. * @param source defines the source data
  3661. * @param w defines the 4th component (default is 0)
  3662. * @returns a new Vector4
  3663. */
  3664. static FromVector3(source: Vector3, w?: number): Vector4;
  3665. }
  3666. /**
  3667. * Class used to store quaternion data
  3668. * @see https://en.wikipedia.org/wiki/Quaternion
  3669. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3670. */
  3671. export class Quaternion {
  3672. /** @hidden */
  3673. _x: number;
  3674. /** @hidden */
  3675. _y: number;
  3676. /** @hidden */
  3677. _z: number;
  3678. /** @hidden */
  3679. _w: number;
  3680. /** @hidden */
  3681. _isDirty: boolean;
  3682. /** Gets or sets the x coordinate */
  3683. get x(): number;
  3684. set x(value: number);
  3685. /** Gets or sets the y coordinate */
  3686. get y(): number;
  3687. set y(value: number);
  3688. /** Gets or sets the z coordinate */
  3689. get z(): number;
  3690. set z(value: number);
  3691. /** Gets or sets the w coordinate */
  3692. get w(): number;
  3693. set w(value: number);
  3694. /**
  3695. * Creates a new Quaternion from the given floats
  3696. * @param x defines the first component (0 by default)
  3697. * @param y defines the second component (0 by default)
  3698. * @param z defines the third component (0 by default)
  3699. * @param w defines the fourth component (1.0 by default)
  3700. */
  3701. constructor(x?: number, y?: number, z?: number, w?: number);
  3702. /**
  3703. * Gets a string representation for the current quaternion
  3704. * @returns a string with the Quaternion coordinates
  3705. */
  3706. toString(): string;
  3707. /**
  3708. * Gets the class name of the quaternion
  3709. * @returns the string "Quaternion"
  3710. */
  3711. getClassName(): string;
  3712. /**
  3713. * Gets a hash code for this quaternion
  3714. * @returns the quaternion hash code
  3715. */
  3716. getHashCode(): number;
  3717. /**
  3718. * Copy the quaternion to an array
  3719. * @returns a new array populated with 4 elements from the quaternion coordinates
  3720. */
  3721. asArray(): number[];
  3722. /**
  3723. * Check if two quaternions are equals
  3724. * @param otherQuaternion defines the second operand
  3725. * @return true if the current quaternion and the given one coordinates are strictly equals
  3726. */
  3727. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3728. /**
  3729. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3730. * @param otherQuaternion defines the other quaternion
  3731. * @param epsilon defines the minimal distance to consider equality
  3732. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3733. */
  3734. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3735. /**
  3736. * Clone the current quaternion
  3737. * @returns a new quaternion copied from the current one
  3738. */
  3739. clone(): Quaternion;
  3740. /**
  3741. * Copy a quaternion to the current one
  3742. * @param other defines the other quaternion
  3743. * @returns the updated current quaternion
  3744. */
  3745. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3746. /**
  3747. * Updates the current quaternion with the given float coordinates
  3748. * @param x defines the x coordinate
  3749. * @param y defines the y coordinate
  3750. * @param z defines the z coordinate
  3751. * @param w defines the w coordinate
  3752. * @returns the updated current quaternion
  3753. */
  3754. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3755. /**
  3756. * Updates the current quaternion from the given float coordinates
  3757. * @param x defines the x coordinate
  3758. * @param y defines the y coordinate
  3759. * @param z defines the z coordinate
  3760. * @param w defines the w coordinate
  3761. * @returns the updated current quaternion
  3762. */
  3763. set(x: number, y: number, z: number, w: number): Quaternion;
  3764. /**
  3765. * Adds two quaternions
  3766. * @param other defines the second operand
  3767. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3768. */
  3769. add(other: DeepImmutable<Quaternion>): Quaternion;
  3770. /**
  3771. * Add a quaternion to the current one
  3772. * @param other defines the quaternion to add
  3773. * @returns the current quaternion
  3774. */
  3775. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3776. /**
  3777. * Subtract two quaternions
  3778. * @param other defines the second operand
  3779. * @returns a new quaternion as the subtraction result of the given one from the current one
  3780. */
  3781. subtract(other: Quaternion): Quaternion;
  3782. /**
  3783. * Multiplies the current quaternion by a scale factor
  3784. * @param value defines the scale factor
  3785. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3786. */
  3787. scale(value: number): Quaternion;
  3788. /**
  3789. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3790. * @param scale defines the scale factor
  3791. * @param result defines the Quaternion object where to store the result
  3792. * @returns the unmodified current quaternion
  3793. */
  3794. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies in place the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns the current modified quaternion
  3799. */
  3800. scaleInPlace(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies two quaternions
  3810. * @param q1 defines the second operand
  3811. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3812. */
  3813. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3814. /**
  3815. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3816. * @param q1 defines the second operand
  3817. * @param result defines the target quaternion
  3818. * @returns the current quaternion
  3819. */
  3820. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3821. /**
  3822. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3823. * @param q1 defines the second operand
  3824. * @returns the currentupdated quaternion
  3825. */
  3826. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3829. * @param ref defines the target quaternion
  3830. * @returns the current quaternion
  3831. */
  3832. conjugateToRef(ref: Quaternion): Quaternion;
  3833. /**
  3834. * Conjugates in place (1-q) the current quaternion
  3835. * @returns the current updated quaternion
  3836. */
  3837. conjugateInPlace(): Quaternion;
  3838. /**
  3839. * Conjugates in place (1-q) the current quaternion
  3840. * @returns a new quaternion
  3841. */
  3842. conjugate(): Quaternion;
  3843. /**
  3844. * Gets length of current quaternion
  3845. * @returns the quaternion length (float)
  3846. */
  3847. length(): number;
  3848. /**
  3849. * Normalize in place the current quaternion
  3850. * @returns the current updated quaternion
  3851. */
  3852. normalize(): Quaternion;
  3853. /**
  3854. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3855. * @param order is a reserved parameter and is ignored for now
  3856. * @returns a new Vector3 containing the Euler angles
  3857. */
  3858. toEulerAngles(order?: string): Vector3;
  3859. /**
  3860. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3861. * @param result defines the vector which will be filled with the Euler angles
  3862. * @returns the current unchanged quaternion
  3863. */
  3864. toEulerAnglesToRef(result: Vector3): Quaternion;
  3865. /**
  3866. * Updates the given rotation matrix with the current quaternion values
  3867. * @param result defines the target matrix
  3868. * @returns the current unchanged quaternion
  3869. */
  3870. toRotationMatrix(result: Matrix): Quaternion;
  3871. /**
  3872. * Updates the current quaternion from the given rotation matrix values
  3873. * @param matrix defines the source matrix
  3874. * @returns the current updated quaternion
  3875. */
  3876. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3877. /**
  3878. * Creates a new quaternion from a rotation matrix
  3879. * @param matrix defines the source matrix
  3880. * @returns a new quaternion created from the given rotation matrix values
  3881. */
  3882. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3883. /**
  3884. * Updates the given quaternion with the given rotation matrix values
  3885. * @param matrix defines the source matrix
  3886. * @param result defines the target quaternion
  3887. */
  3888. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3889. /**
  3890. * Returns the dot product (float) between the quaternions "left" and "right"
  3891. * @param left defines the left operand
  3892. * @param right defines the right operand
  3893. * @returns the dot product
  3894. */
  3895. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3896. /**
  3897. * Checks if the two quaternions are close to each other
  3898. * @param quat0 defines the first quaternion to check
  3899. * @param quat1 defines the second quaternion to check
  3900. * @returns true if the two quaternions are close to each other
  3901. */
  3902. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3903. /**
  3904. * Creates an empty quaternion
  3905. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3906. */
  3907. static Zero(): Quaternion;
  3908. /**
  3909. * Inverse a given quaternion
  3910. * @param q defines the source quaternion
  3911. * @returns a new quaternion as the inverted current quaternion
  3912. */
  3913. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3914. /**
  3915. * Inverse a given quaternion
  3916. * @param q defines the source quaternion
  3917. * @param result the quaternion the result will be stored in
  3918. * @returns the result quaternion
  3919. */
  3920. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3921. /**
  3922. * Creates an identity quaternion
  3923. * @returns the identity quaternion
  3924. */
  3925. static Identity(): Quaternion;
  3926. /**
  3927. * Gets a boolean indicating if the given quaternion is identity
  3928. * @param quaternion defines the quaternion to check
  3929. * @returns true if the quaternion is identity
  3930. */
  3931. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3932. /**
  3933. * Creates a quaternion from a rotation around an axis
  3934. * @param axis defines the axis to use
  3935. * @param angle defines the angle to use
  3936. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3937. */
  3938. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3939. /**
  3940. * Creates a rotation around an axis and stores it into the given quaternion
  3941. * @param axis defines the axis to use
  3942. * @param angle defines the angle to use
  3943. * @param result defines the target quaternion
  3944. * @returns the target quaternion
  3945. */
  3946. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3947. /**
  3948. * Creates a new quaternion from data stored into an array
  3949. * @param array defines the data source
  3950. * @param offset defines the offset in the source array where the data starts
  3951. * @returns a new quaternion
  3952. */
  3953. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3954. /**
  3955. * Updates the given quaternion "result" from the starting index of the given array.
  3956. * @param array the array to pull values from
  3957. * @param offset the offset into the array to start at
  3958. * @param result the quaternion to store the result in
  3959. */
  3960. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3961. /**
  3962. * Create a quaternion from Euler rotation angles
  3963. * @param x Pitch
  3964. * @param y Yaw
  3965. * @param z Roll
  3966. * @returns the new Quaternion
  3967. */
  3968. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3969. /**
  3970. * Updates a quaternion from Euler rotation angles
  3971. * @param x Pitch
  3972. * @param y Yaw
  3973. * @param z Roll
  3974. * @param result the quaternion to store the result
  3975. * @returns the updated quaternion
  3976. */
  3977. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3978. /**
  3979. * Create a quaternion from Euler rotation vector
  3980. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3981. * @returns the new Quaternion
  3982. */
  3983. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3984. /**
  3985. * Updates a quaternion from Euler rotation vector
  3986. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3987. * @param result the quaternion to store the result
  3988. * @returns the updated quaternion
  3989. */
  3990. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3991. /**
  3992. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3993. * @param yaw defines the rotation around Y axis
  3994. * @param pitch defines the rotation around X axis
  3995. * @param roll defines the rotation around Z axis
  3996. * @returns the new quaternion
  3997. */
  3998. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3999. /**
  4000. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4001. * @param yaw defines the rotation around Y axis
  4002. * @param pitch defines the rotation around X axis
  4003. * @param roll defines the rotation around Z axis
  4004. * @param result defines the target quaternion
  4005. */
  4006. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4007. /**
  4008. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4009. * @param alpha defines the rotation around first axis
  4010. * @param beta defines the rotation around second axis
  4011. * @param gamma defines the rotation around third axis
  4012. * @returns the new quaternion
  4013. */
  4014. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4015. /**
  4016. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4017. * @param alpha defines the rotation around first axis
  4018. * @param beta defines the rotation around second axis
  4019. * @param gamma defines the rotation around third axis
  4020. * @param result defines the target quaternion
  4021. */
  4022. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4023. /**
  4024. * 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)
  4025. * @param axis1 defines the first axis
  4026. * @param axis2 defines the second axis
  4027. * @param axis3 defines the third axis
  4028. * @returns the new quaternion
  4029. */
  4030. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4031. /**
  4032. * 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
  4033. * @param axis1 defines the first axis
  4034. * @param axis2 defines the second axis
  4035. * @param axis3 defines the third axis
  4036. * @param ref defines the target quaternion
  4037. */
  4038. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4039. /**
  4040. * Interpolates between two quaternions
  4041. * @param left defines first quaternion
  4042. * @param right defines second quaternion
  4043. * @param amount defines the gradient to use
  4044. * @returns the new interpolated quaternion
  4045. */
  4046. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4047. /**
  4048. * Interpolates between two quaternions and stores it into a target quaternion
  4049. * @param left defines first quaternion
  4050. * @param right defines second quaternion
  4051. * @param amount defines the gradient to use
  4052. * @param result defines the target quaternion
  4053. */
  4054. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4055. /**
  4056. * Interpolate between two quaternions using Hermite interpolation
  4057. * @param value1 defines first quaternion
  4058. * @param tangent1 defines the incoming tangent
  4059. * @param value2 defines second quaternion
  4060. * @param tangent2 defines the outgoing tangent
  4061. * @param amount defines the target quaternion
  4062. * @returns the new interpolated quaternion
  4063. */
  4064. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4065. }
  4066. /**
  4067. * Class used to store matrix data (4x4)
  4068. */
  4069. export class Matrix {
  4070. /**
  4071. * Gets the precision of matrix computations
  4072. */
  4073. static get Use64Bits(): boolean;
  4074. private static _updateFlagSeed;
  4075. private static _identityReadOnly;
  4076. private _isIdentity;
  4077. private _isIdentityDirty;
  4078. private _isIdentity3x2;
  4079. private _isIdentity3x2Dirty;
  4080. /**
  4081. * Gets the update flag of the matrix which is an unique number for the matrix.
  4082. * It will be incremented every time the matrix data change.
  4083. * You can use it to speed the comparison between two versions of the same matrix.
  4084. */
  4085. updateFlag: number;
  4086. private readonly _m;
  4087. /**
  4088. * Gets the internal data of the matrix
  4089. */
  4090. get m(): DeepImmutable<Float32Array | Array<number>>;
  4091. /** @hidden */
  4092. _markAsUpdated(): void;
  4093. /** @hidden */
  4094. private _updateIdentityStatus;
  4095. /**
  4096. * Creates an empty matrix (filled with zeros)
  4097. */
  4098. constructor();
  4099. /**
  4100. * Check if the current matrix is identity
  4101. * @returns true is the matrix is the identity matrix
  4102. */
  4103. isIdentity(): boolean;
  4104. /**
  4105. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4106. * @returns true is the matrix is the identity matrix
  4107. */
  4108. isIdentityAs3x2(): boolean;
  4109. /**
  4110. * Gets the determinant of the matrix
  4111. * @returns the matrix determinant
  4112. */
  4113. determinant(): number;
  4114. /**
  4115. * Returns the matrix as a Float32Array or Array<number>
  4116. * @returns the matrix underlying array
  4117. */
  4118. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4119. /**
  4120. * Returns the matrix as a Float32Array or Array<number>
  4121. * @returns the matrix underlying array.
  4122. */
  4123. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4124. /**
  4125. * Inverts the current matrix in place
  4126. * @returns the current inverted matrix
  4127. */
  4128. invert(): Matrix;
  4129. /**
  4130. * Sets all the matrix elements to zero
  4131. * @returns the current matrix
  4132. */
  4133. reset(): Matrix;
  4134. /**
  4135. * Adds the current matrix with a second one
  4136. * @param other defines the matrix to add
  4137. * @returns a new matrix as the addition of the current matrix and the given one
  4138. */
  4139. add(other: DeepImmutable<Matrix>): Matrix;
  4140. /**
  4141. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4142. * @param other defines the matrix to add
  4143. * @param result defines the target matrix
  4144. * @returns the current matrix
  4145. */
  4146. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4147. /**
  4148. * Adds in place the given matrix to the current matrix
  4149. * @param other defines the second operand
  4150. * @returns the current updated matrix
  4151. */
  4152. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4153. /**
  4154. * Sets the given matrix to the current inverted Matrix
  4155. * @param other defines the target matrix
  4156. * @returns the unmodified current matrix
  4157. */
  4158. invertToRef(other: Matrix): Matrix;
  4159. /**
  4160. * add a value at the specified position in the current Matrix
  4161. * @param index the index of the value within the matrix. between 0 and 15.
  4162. * @param value the value to be added
  4163. * @returns the current updated matrix
  4164. */
  4165. addAtIndex(index: number, value: number): Matrix;
  4166. /**
  4167. * mutiply the specified position in the current Matrix by a value
  4168. * @param index the index of the value within the matrix. between 0 and 15.
  4169. * @param value the value to be added
  4170. * @returns the current updated matrix
  4171. */
  4172. multiplyAtIndex(index: number, value: number): Matrix;
  4173. /**
  4174. * Inserts the translation vector (using 3 floats) in the current matrix
  4175. * @param x defines the 1st component of the translation
  4176. * @param y defines the 2nd component of the translation
  4177. * @param z defines the 3rd component of the translation
  4178. * @returns the current updated matrix
  4179. */
  4180. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4181. /**
  4182. * Adds the translation vector (using 3 floats) in the current matrix
  4183. * @param x defines the 1st component of the translation
  4184. * @param y defines the 2nd component of the translation
  4185. * @param z defines the 3rd component of the translation
  4186. * @returns the current updated matrix
  4187. */
  4188. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4189. /**
  4190. * Inserts the translation vector in the current matrix
  4191. * @param vector3 defines the translation to insert
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4195. /**
  4196. * Gets the translation value of the current matrix
  4197. * @returns a new Vector3 as the extracted translation from the matrix
  4198. */
  4199. getTranslation(): Vector3;
  4200. /**
  4201. * Fill a Vector3 with the extracted translation from the matrix
  4202. * @param result defines the Vector3 where to store the translation
  4203. * @returns the current matrix
  4204. */
  4205. getTranslationToRef(result: Vector3): Matrix;
  4206. /**
  4207. * Remove rotation and scaling part from the matrix
  4208. * @returns the updated matrix
  4209. */
  4210. removeRotationAndScaling(): Matrix;
  4211. /**
  4212. * Multiply two matrices
  4213. * @param other defines the second operand
  4214. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4215. */
  4216. multiply(other: DeepImmutable<Matrix>): Matrix;
  4217. /**
  4218. * Copy the current matrix from the given one
  4219. * @param other defines the source matrix
  4220. * @returns the current updated matrix
  4221. */
  4222. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4223. /**
  4224. * Populates the given array from the starting index with the current matrix values
  4225. * @param array defines the target array
  4226. * @param offset defines the offset in the target array where to start storing values
  4227. * @returns the current matrix
  4228. */
  4229. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4230. /**
  4231. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4232. * @param other defines the second operand
  4233. * @param result defines the matrix where to store the multiplication
  4234. * @returns the current matrix
  4235. */
  4236. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4237. /**
  4238. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4239. * @param other defines the second operand
  4240. * @param result defines the array where to store the multiplication
  4241. * @param offset defines the offset in the target array where to start storing values
  4242. * @returns the current matrix
  4243. */
  4244. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4245. /**
  4246. * Check equality between this matrix and a second one
  4247. * @param value defines the second matrix to compare
  4248. * @returns true is the current matrix and the given one values are strictly equal
  4249. */
  4250. equals(value: DeepImmutable<Matrix>): boolean;
  4251. /**
  4252. * Clone the current matrix
  4253. * @returns a new matrix from the current matrix
  4254. */
  4255. clone(): Matrix;
  4256. /**
  4257. * Returns the name of the current matrix class
  4258. * @returns the string "Matrix"
  4259. */
  4260. getClassName(): string;
  4261. /**
  4262. * Gets the hash code of the current matrix
  4263. * @returns the hash code
  4264. */
  4265. getHashCode(): number;
  4266. /**
  4267. * Decomposes the current Matrix into a translation, rotation and scaling components
  4268. * @param scale defines the scale vector3 given as a reference to update
  4269. * @param rotation defines the rotation quaternion given as a reference to update
  4270. * @param translation defines the translation vector3 given as a reference to update
  4271. * @returns true if operation was successful
  4272. */
  4273. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4274. /**
  4275. * Gets specific row of the matrix
  4276. * @param index defines the number of the row to get
  4277. * @returns the index-th row of the current matrix as a new Vector4
  4278. */
  4279. getRow(index: number): Nullable<Vector4>;
  4280. /**
  4281. * Sets the index-th row of the current matrix to the vector4 values
  4282. * @param index defines the number of the row to set
  4283. * @param row defines the target vector4
  4284. * @returns the updated current matrix
  4285. */
  4286. setRow(index: number, row: Vector4): Matrix;
  4287. /**
  4288. * Compute the transpose of the matrix
  4289. * @returns the new transposed matrix
  4290. */
  4291. transpose(): Matrix;
  4292. /**
  4293. * Compute the transpose of the matrix and store it in a given matrix
  4294. * @param result defines the target matrix
  4295. * @returns the current matrix
  4296. */
  4297. transposeToRef(result: Matrix): Matrix;
  4298. /**
  4299. * Sets the index-th row of the current matrix with the given 4 x float values
  4300. * @param index defines the row index
  4301. * @param x defines the x component to set
  4302. * @param y defines the y component to set
  4303. * @param z defines the z component to set
  4304. * @param w defines the w component to set
  4305. * @returns the updated current matrix
  4306. */
  4307. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4308. /**
  4309. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4310. * @param scale defines the scale factor
  4311. * @returns a new matrix
  4312. */
  4313. scale(scale: number): Matrix;
  4314. /**
  4315. * Scale the current matrix values by a factor to a given result matrix
  4316. * @param scale defines the scale factor
  4317. * @param result defines the matrix to store the result
  4318. * @returns the current matrix
  4319. */
  4320. scaleToRef(scale: number, result: Matrix): Matrix;
  4321. /**
  4322. * Scale the current matrix values by a factor and add the result to a given matrix
  4323. * @param scale defines the scale factor
  4324. * @param result defines the Matrix to store the result
  4325. * @returns the current matrix
  4326. */
  4327. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4328. /**
  4329. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4330. * @param ref matrix to store the result
  4331. */
  4332. toNormalMatrix(ref: Matrix): void;
  4333. /**
  4334. * Gets only rotation part of the current matrix
  4335. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4336. */
  4337. getRotationMatrix(): Matrix;
  4338. /**
  4339. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4340. * @param result defines the target matrix to store data to
  4341. * @returns the current matrix
  4342. */
  4343. getRotationMatrixToRef(result: Matrix): Matrix;
  4344. /**
  4345. * Toggles model matrix from being right handed to left handed in place and vice versa
  4346. */
  4347. toggleModelMatrixHandInPlace(): void;
  4348. /**
  4349. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4350. */
  4351. toggleProjectionMatrixHandInPlace(): void;
  4352. /**
  4353. * Creates a matrix from an array
  4354. * @param array defines the source array
  4355. * @param offset defines an offset in the source array
  4356. * @returns a new Matrix set from the starting index of the given array
  4357. */
  4358. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4359. /**
  4360. * Copy the content of an array into a given matrix
  4361. * @param array defines the source array
  4362. * @param offset defines an offset in the source array
  4363. * @param result defines the target matrix
  4364. */
  4365. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4366. /**
  4367. * Stores an array into a matrix after having multiplied each component by a given factor
  4368. * @param array defines the source array
  4369. * @param offset defines the offset in the source array
  4370. * @param scale defines the scaling factor
  4371. * @param result defines the target matrix
  4372. */
  4373. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4374. /**
  4375. * Gets an identity matrix that must not be updated
  4376. */
  4377. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4378. /**
  4379. * Stores a list of values (16) inside a given matrix
  4380. * @param initialM11 defines 1st value of 1st row
  4381. * @param initialM12 defines 2nd value of 1st row
  4382. * @param initialM13 defines 3rd value of 1st row
  4383. * @param initialM14 defines 4th value of 1st row
  4384. * @param initialM21 defines 1st value of 2nd row
  4385. * @param initialM22 defines 2nd value of 2nd row
  4386. * @param initialM23 defines 3rd value of 2nd row
  4387. * @param initialM24 defines 4th value of 2nd row
  4388. * @param initialM31 defines 1st value of 3rd row
  4389. * @param initialM32 defines 2nd value of 3rd row
  4390. * @param initialM33 defines 3rd value of 3rd row
  4391. * @param initialM34 defines 4th value of 3rd row
  4392. * @param initialM41 defines 1st value of 4th row
  4393. * @param initialM42 defines 2nd value of 4th row
  4394. * @param initialM43 defines 3rd value of 4th row
  4395. * @param initialM44 defines 4th value of 4th row
  4396. * @param result defines the target matrix
  4397. */
  4398. 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;
  4399. /**
  4400. * Creates new matrix from a list of values (16)
  4401. * @param initialM11 defines 1st value of 1st row
  4402. * @param initialM12 defines 2nd value of 1st row
  4403. * @param initialM13 defines 3rd value of 1st row
  4404. * @param initialM14 defines 4th value of 1st row
  4405. * @param initialM21 defines 1st value of 2nd row
  4406. * @param initialM22 defines 2nd value of 2nd row
  4407. * @param initialM23 defines 3rd value of 2nd row
  4408. * @param initialM24 defines 4th value of 2nd row
  4409. * @param initialM31 defines 1st value of 3rd row
  4410. * @param initialM32 defines 2nd value of 3rd row
  4411. * @param initialM33 defines 3rd value of 3rd row
  4412. * @param initialM34 defines 4th value of 3rd row
  4413. * @param initialM41 defines 1st value of 4th row
  4414. * @param initialM42 defines 2nd value of 4th row
  4415. * @param initialM43 defines 3rd value of 4th row
  4416. * @param initialM44 defines 4th value of 4th row
  4417. * @returns the new matrix
  4418. */
  4419. 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;
  4420. /**
  4421. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4422. * @param scale defines the scale vector3
  4423. * @param rotation defines the rotation quaternion
  4424. * @param translation defines the translation vector3
  4425. * @returns a new matrix
  4426. */
  4427. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4428. /**
  4429. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4430. * @param scale defines the scale vector3
  4431. * @param rotation defines the rotation quaternion
  4432. * @param translation defines the translation vector3
  4433. * @param result defines the target matrix
  4434. */
  4435. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4436. /**
  4437. * Creates a new identity matrix
  4438. * @returns a new identity matrix
  4439. */
  4440. static Identity(): Matrix;
  4441. /**
  4442. * Creates a new identity matrix and stores the result in a given matrix
  4443. * @param result defines the target matrix
  4444. */
  4445. static IdentityToRef(result: Matrix): void;
  4446. /**
  4447. * Creates a new zero matrix
  4448. * @returns a new zero matrix
  4449. */
  4450. static Zero(): Matrix;
  4451. /**
  4452. * Creates a new rotation matrix for "angle" radians around the X axis
  4453. * @param angle defines the angle (in radians) to use
  4454. * @return the new matrix
  4455. */
  4456. static RotationX(angle: number): Matrix;
  4457. /**
  4458. * Creates a new matrix as the invert of a given matrix
  4459. * @param source defines the source matrix
  4460. * @returns the new matrix
  4461. */
  4462. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4463. /**
  4464. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4465. * @param angle defines the angle (in radians) to use
  4466. * @param result defines the target matrix
  4467. */
  4468. static RotationXToRef(angle: number, result: Matrix): void;
  4469. /**
  4470. * Creates a new rotation matrix for "angle" radians around the Y axis
  4471. * @param angle defines the angle (in radians) to use
  4472. * @return the new matrix
  4473. */
  4474. static RotationY(angle: number): Matrix;
  4475. /**
  4476. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4477. * @param angle defines the angle (in radians) to use
  4478. * @param result defines the target matrix
  4479. */
  4480. static RotationYToRef(angle: number, result: Matrix): void;
  4481. /**
  4482. * Creates a new rotation matrix for "angle" radians around the Z axis
  4483. * @param angle defines the angle (in radians) to use
  4484. * @return the new matrix
  4485. */
  4486. static RotationZ(angle: number): Matrix;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4489. * @param angle defines the angle (in radians) to use
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationZToRef(angle: number, result: Matrix): void;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the given axis
  4495. * @param axis defines the axis to use
  4496. * @param angle defines the angle (in radians) to use
  4497. * @return the new matrix
  4498. */
  4499. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4500. /**
  4501. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4502. * @param axis defines the axis to use
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4507. /**
  4508. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4509. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4510. * @param from defines the vector to align
  4511. * @param to defines the vector to align to
  4512. * @param result defines the target matrix
  4513. */
  4514. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4515. /**
  4516. * Creates a rotation matrix
  4517. * @param yaw defines the yaw angle in radians (Y axis)
  4518. * @param pitch defines the pitch angle in radians (X axis)
  4519. * @param roll defines the roll angle in radians (Z axis)
  4520. * @returns the new rotation matrix
  4521. */
  4522. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4523. /**
  4524. * Creates a rotation matrix and stores it in a given matrix
  4525. * @param yaw defines the yaw angle in radians (Y axis)
  4526. * @param pitch defines the pitch angle in radians (X axis)
  4527. * @param roll defines the roll angle in radians (Z axis)
  4528. * @param result defines the target matrix
  4529. */
  4530. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4531. /**
  4532. * Creates a scaling matrix
  4533. * @param x defines the scale factor on X axis
  4534. * @param y defines the scale factor on Y axis
  4535. * @param z defines the scale factor on Z axis
  4536. * @returns the new matrix
  4537. */
  4538. static Scaling(x: number, y: number, z: number): Matrix;
  4539. /**
  4540. * Creates a scaling matrix and stores it in a given matrix
  4541. * @param x defines the scale factor on X axis
  4542. * @param y defines the scale factor on Y axis
  4543. * @param z defines the scale factor on Z axis
  4544. * @param result defines the target matrix
  4545. */
  4546. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4547. /**
  4548. * Creates a translation matrix
  4549. * @param x defines the translation on X axis
  4550. * @param y defines the translation on Y axis
  4551. * @param z defines the translationon Z axis
  4552. * @returns the new matrix
  4553. */
  4554. static Translation(x: number, y: number, z: number): Matrix;
  4555. /**
  4556. * Creates a translation matrix and stores it in a given matrix
  4557. * @param x defines the translation on X axis
  4558. * @param y defines the translation on Y axis
  4559. * @param z defines the translationon Z axis
  4560. * @param result defines the target matrix
  4561. */
  4562. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4563. /**
  4564. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4565. * @param startValue defines the start value
  4566. * @param endValue defines the end value
  4567. * @param gradient defines the gradient factor
  4568. * @returns the new matrix
  4569. */
  4570. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4571. /**
  4572. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4573. * @param startValue defines the start value
  4574. * @param endValue defines the end value
  4575. * @param gradient defines the gradient factor
  4576. * @param result defines the Matrix object where to store data
  4577. */
  4578. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * Builds a new matrix whose values are computed by:
  4581. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4582. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4583. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4584. * @param startValue defines the first matrix
  4585. * @param endValue defines the second matrix
  4586. * @param gradient defines the gradient between the two matrices
  4587. * @returns the new matrix
  4588. */
  4589. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4590. /**
  4591. * Update a matrix to values which are computed by:
  4592. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4593. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4594. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4595. * @param startValue defines the first matrix
  4596. * @param endValue defines the second matrix
  4597. * @param gradient defines the gradient between the two matrices
  4598. * @param result defines the target matrix
  4599. */
  4600. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4601. /**
  4602. * 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"
  4603. * This function works in left handed mode
  4604. * @param eye defines the final position of the entity
  4605. * @param target defines where the entity should look at
  4606. * @param up defines the up vector for the entity
  4607. * @returns the new matrix
  4608. */
  4609. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4610. /**
  4611. * 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".
  4612. * This function works in left handed mode
  4613. * @param eye defines the final position of the entity
  4614. * @param target defines where the entity should look at
  4615. * @param up defines the up vector for the entity
  4616. * @param result defines the target matrix
  4617. */
  4618. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4619. /**
  4620. * 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"
  4621. * This function works in right handed mode
  4622. * @param eye defines the final position of the entity
  4623. * @param target defines where the entity should look at
  4624. * @param up defines the up vector for the entity
  4625. * @returns the new matrix
  4626. */
  4627. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4628. /**
  4629. * 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".
  4630. * This function works in right handed mode
  4631. * @param eye defines the final position of the entity
  4632. * @param target defines where the entity should look at
  4633. * @param up defines the up vector for the entity
  4634. * @param result defines the target matrix
  4635. */
  4636. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4637. /**
  4638. * Create a left-handed orthographic projection matrix
  4639. * @param width defines the viewport width
  4640. * @param height defines the viewport height
  4641. * @param znear defines the near clip plane
  4642. * @param zfar defines the far clip plane
  4643. * @returns a new matrix as a left-handed orthographic projection matrix
  4644. */
  4645. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Store a left-handed orthographic projection to a given matrix
  4648. * @param width defines the viewport width
  4649. * @param height defines the viewport height
  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 OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Create a left-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 left-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a left-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 OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a right-handed orthographic projection matrix
  4679. * @param left defines the viewport left coordinate
  4680. * @param right defines the viewport right coordinate
  4681. * @param bottom defines the viewport bottom coordinate
  4682. * @param top defines the viewport top coordinate
  4683. * @param znear defines the near clip plane
  4684. * @param zfar defines the far clip plane
  4685. * @returns a new matrix as a right-handed orthographic projection matrix
  4686. */
  4687. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4688. /**
  4689. * Stores a right-handed orthographic projection into a given matrix
  4690. * @param left defines the viewport left coordinate
  4691. * @param right defines the viewport right coordinate
  4692. * @param bottom defines the viewport bottom coordinate
  4693. * @param top defines the viewport top coordinate
  4694. * @param znear defines the near clip plane
  4695. * @param zfar defines the far clip plane
  4696. * @param result defines the target matrix
  4697. */
  4698. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4699. /**
  4700. * Creates a left-handed perspective projection matrix
  4701. * @param width defines the viewport width
  4702. * @param height defines the viewport height
  4703. * @param znear defines the near clip plane
  4704. * @param zfar defines the far clip plane
  4705. * @returns a new matrix as a left-handed perspective projection matrix
  4706. */
  4707. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4708. /**
  4709. * Creates a left-handed perspective projection matrix
  4710. * @param fov defines the horizontal field of view
  4711. * @param aspect defines the aspect ratio
  4712. * @param znear defines the near clip plane
  4713. * @param zfar defines the far clip plane
  4714. * @returns a new matrix as a left-handed perspective projection matrix
  4715. */
  4716. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4717. /**
  4718. * Stores a left-handed perspective projection into a given matrix
  4719. * @param fov defines the horizontal field of view
  4720. * @param aspect defines the aspect ratio
  4721. * @param znear defines the near clip plane
  4722. * @param zfar defines the far clip plane
  4723. * @param result defines the target matrix
  4724. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4725. */
  4726. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4727. /**
  4728. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4729. * @param fov defines the horizontal field of view
  4730. * @param aspect defines the aspect ratio
  4731. * @param znear defines the near clip plane
  4732. * @param zfar not used as infinity is used as far clip
  4733. * @param result defines the target matrix
  4734. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4735. */
  4736. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4737. /**
  4738. * Creates a right-handed perspective projection matrix
  4739. * @param fov defines the horizontal field of view
  4740. * @param aspect defines the aspect ratio
  4741. * @param znear defines the near clip plane
  4742. * @param zfar defines the far clip plane
  4743. * @returns a new matrix as a right-handed perspective projection matrix
  4744. */
  4745. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4746. /**
  4747. * Stores a right-handed perspective projection into a given matrix
  4748. * @param fov defines the horizontal field of view
  4749. * @param aspect defines the aspect ratio
  4750. * @param znear defines the near clip plane
  4751. * @param zfar defines the far clip plane
  4752. * @param result defines the target matrix
  4753. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4754. */
  4755. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4756. /**
  4757. * Stores a right-handed perspective projection into a given matrix
  4758. * @param fov defines the horizontal field of view
  4759. * @param aspect defines the aspect ratio
  4760. * @param znear defines the near clip plane
  4761. * @param zfar not used as infinity is used as far clip
  4762. * @param result defines the target matrix
  4763. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4764. */
  4765. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4766. /**
  4767. * Stores a perspective projection for WebVR info a given matrix
  4768. * @param fov defines the field of view
  4769. * @param znear defines the near clip plane
  4770. * @param zfar defines the far clip plane
  4771. * @param result defines the target matrix
  4772. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4773. */
  4774. static PerspectiveFovWebVRToRef(fov: {
  4775. upDegrees: number;
  4776. downDegrees: number;
  4777. leftDegrees: number;
  4778. rightDegrees: number;
  4779. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4780. /**
  4781. * Computes a complete transformation matrix
  4782. * @param viewport defines the viewport to use
  4783. * @param world defines the world matrix
  4784. * @param view defines the view matrix
  4785. * @param projection defines the projection matrix
  4786. * @param zmin defines the near clip plane
  4787. * @param zmax defines the far clip plane
  4788. * @returns the transformation matrix
  4789. */
  4790. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4791. /**
  4792. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4793. * @param matrix defines the matrix to use
  4794. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4795. */
  4796. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4797. /**
  4798. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4799. * @param matrix defines the matrix to use
  4800. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4801. */
  4802. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4803. /**
  4804. * Compute the transpose of a given matrix
  4805. * @param matrix defines the matrix to transpose
  4806. * @returns the new matrix
  4807. */
  4808. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4809. /**
  4810. * Compute the transpose of a matrix and store it in a target matrix
  4811. * @param matrix defines the matrix to transpose
  4812. * @param result defines the target matrix
  4813. */
  4814. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4815. /**
  4816. * Computes a reflection matrix from a plane
  4817. * @param plane defines the reflection plane
  4818. * @returns a new matrix
  4819. */
  4820. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4821. /**
  4822. * Computes a reflection matrix from a plane
  4823. * @param plane defines the reflection plane
  4824. * @param result defines the target matrix
  4825. */
  4826. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4827. /**
  4828. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4829. * @param xaxis defines the value of the 1st axis
  4830. * @param yaxis defines the value of the 2nd axis
  4831. * @param zaxis defines the value of the 3rd axis
  4832. * @param result defines the target matrix
  4833. */
  4834. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4835. /**
  4836. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4837. * @param quat defines the quaternion to use
  4838. * @param result defines the target matrix
  4839. */
  4840. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4841. }
  4842. /**
  4843. * @hidden
  4844. */
  4845. export class TmpVectors {
  4846. static Vector2: Vector2[];
  4847. static Vector3: Vector3[];
  4848. static Vector4: Vector4[];
  4849. static Quaternion: Quaternion[];
  4850. static Matrix: Matrix[];
  4851. }
  4852. }
  4853. declare module BABYLON {
  4854. /**
  4855. * Defines potential orientation for back face culling
  4856. */
  4857. export enum Orientation {
  4858. /**
  4859. * Clockwise
  4860. */
  4861. CW = 0,
  4862. /** Counter clockwise */
  4863. CCW = 1
  4864. }
  4865. /** Class used to represent a Bezier curve */
  4866. export class BezierCurve {
  4867. /**
  4868. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4869. * @param t defines the time
  4870. * @param x1 defines the left coordinate on X axis
  4871. * @param y1 defines the left coordinate on Y axis
  4872. * @param x2 defines the right coordinate on X axis
  4873. * @param y2 defines the right coordinate on Y axis
  4874. * @returns the interpolated value
  4875. */
  4876. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4877. }
  4878. /**
  4879. * Defines angle representation
  4880. */
  4881. export class Angle {
  4882. private _radians;
  4883. /**
  4884. * Creates an Angle object of "radians" radians (float).
  4885. * @param radians the angle in radians
  4886. */
  4887. constructor(radians: number);
  4888. /**
  4889. * Get value in degrees
  4890. * @returns the Angle value in degrees (float)
  4891. */
  4892. degrees(): number;
  4893. /**
  4894. * Get value in radians
  4895. * @returns the Angle value in radians (float)
  4896. */
  4897. radians(): number;
  4898. /**
  4899. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4900. * @param a defines first point as the origin
  4901. * @param b defines point
  4902. * @returns a new Angle
  4903. */
  4904. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4905. /**
  4906. * Gets a new Angle object from the given float in radians
  4907. * @param radians defines the angle value in radians
  4908. * @returns a new Angle
  4909. */
  4910. static FromRadians(radians: number): Angle;
  4911. /**
  4912. * Gets a new Angle object from the given float in degrees
  4913. * @param degrees defines the angle value in degrees
  4914. * @returns a new Angle
  4915. */
  4916. static FromDegrees(degrees: number): Angle;
  4917. }
  4918. /**
  4919. * This represents an arc in a 2d space.
  4920. */
  4921. export class Arc2 {
  4922. /** Defines the start point of the arc */
  4923. startPoint: Vector2;
  4924. /** Defines the mid point of the arc */
  4925. midPoint: Vector2;
  4926. /** Defines the end point of the arc */
  4927. endPoint: Vector2;
  4928. /**
  4929. * Defines the center point of the arc.
  4930. */
  4931. centerPoint: Vector2;
  4932. /**
  4933. * Defines the radius of the arc.
  4934. */
  4935. radius: number;
  4936. /**
  4937. * Defines the angle of the arc (from mid point to end point).
  4938. */
  4939. angle: Angle;
  4940. /**
  4941. * Defines the start angle of the arc (from start point to middle point).
  4942. */
  4943. startAngle: Angle;
  4944. /**
  4945. * Defines the orientation of the arc (clock wise/counter clock wise).
  4946. */
  4947. orientation: Orientation;
  4948. /**
  4949. * Creates an Arc object from the three given points : start, middle and end.
  4950. * @param startPoint Defines the start point of the arc
  4951. * @param midPoint Defines the midlle point of the arc
  4952. * @param endPoint Defines the end point of the arc
  4953. */
  4954. constructor(
  4955. /** Defines the start point of the arc */
  4956. startPoint: Vector2,
  4957. /** Defines the mid point of the arc */
  4958. midPoint: Vector2,
  4959. /** Defines the end point of the arc */
  4960. endPoint: Vector2);
  4961. }
  4962. /**
  4963. * Represents a 2D path made up of multiple 2D points
  4964. */
  4965. export class Path2 {
  4966. private _points;
  4967. private _length;
  4968. /**
  4969. * If the path start and end point are the same
  4970. */
  4971. closed: boolean;
  4972. /**
  4973. * Creates a Path2 object from the starting 2D coordinates x and y.
  4974. * @param x the starting points x value
  4975. * @param y the starting points y value
  4976. */
  4977. constructor(x: number, y: number);
  4978. /**
  4979. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4980. * @param x the added points x value
  4981. * @param y the added points y value
  4982. * @returns the updated Path2.
  4983. */
  4984. addLineTo(x: number, y: number): Path2;
  4985. /**
  4986. * 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.
  4987. * @param midX middle point x value
  4988. * @param midY middle point y value
  4989. * @param endX end point x value
  4990. * @param endY end point y value
  4991. * @param numberOfSegments (default: 36)
  4992. * @returns the updated Path2.
  4993. */
  4994. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4995. /**
  4996. * Closes the Path2.
  4997. * @returns the Path2.
  4998. */
  4999. close(): Path2;
  5000. /**
  5001. * Gets the sum of the distance between each sequential point in the path
  5002. * @returns the Path2 total length (float).
  5003. */
  5004. length(): number;
  5005. /**
  5006. * Gets the points which construct the path
  5007. * @returns the Path2 internal array of points.
  5008. */
  5009. getPoints(): Vector2[];
  5010. /**
  5011. * Retreives the point at the distance aways from the starting point
  5012. * @param normalizedLengthPosition the length along the path to retreive the point from
  5013. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5014. */
  5015. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5016. /**
  5017. * Creates a new path starting from an x and y position
  5018. * @param x starting x value
  5019. * @param y starting y value
  5020. * @returns a new Path2 starting at the coordinates (x, y).
  5021. */
  5022. static StartingAt(x: number, y: number): Path2;
  5023. }
  5024. /**
  5025. * Represents a 3D path made up of multiple 3D points
  5026. */
  5027. export class Path3D {
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[];
  5032. private _curve;
  5033. private _distances;
  5034. private _tangents;
  5035. private _normals;
  5036. private _binormals;
  5037. private _raw;
  5038. private _alignTangentsWithPath;
  5039. private readonly _pointAtData;
  5040. /**
  5041. * new Path3D(path, normal, raw)
  5042. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5043. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5044. * @param path an array of Vector3, the curve axis of the Path3D
  5045. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5046. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5047. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5048. */
  5049. constructor(
  5050. /**
  5051. * an array of Vector3, the curve axis of the Path3D
  5052. */
  5053. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5054. /**
  5055. * Returns the Path3D array of successive Vector3 designing its curve.
  5056. * @returns the Path3D array of successive Vector3 designing its curve.
  5057. */
  5058. getCurve(): Vector3[];
  5059. /**
  5060. * Returns the Path3D array of successive Vector3 designing its curve.
  5061. * @returns the Path3D array of successive Vector3 designing its curve.
  5062. */
  5063. getPoints(): Vector3[];
  5064. /**
  5065. * @returns the computed length (float) of the path.
  5066. */
  5067. length(): number;
  5068. /**
  5069. * Returns an array populated with tangent vectors on each Path3D curve point.
  5070. * @returns an array populated with tangent vectors on each Path3D curve point.
  5071. */
  5072. getTangents(): Vector3[];
  5073. /**
  5074. * Returns an array populated with normal vectors on each Path3D curve point.
  5075. * @returns an array populated with normal vectors on each Path3D curve point.
  5076. */
  5077. getNormals(): Vector3[];
  5078. /**
  5079. * Returns an array populated with binormal vectors on each Path3D curve point.
  5080. * @returns an array populated with binormal vectors on each Path3D curve point.
  5081. */
  5082. getBinormals(): Vector3[];
  5083. /**
  5084. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5085. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5086. */
  5087. getDistances(): number[];
  5088. /**
  5089. * Returns an interpolated point along this path
  5090. * @param position the position of the point along this path, from 0.0 to 1.0
  5091. * @returns a new Vector3 as the point
  5092. */
  5093. getPointAt(position: number): Vector3;
  5094. /**
  5095. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5096. * @param position the position of the point along this path, from 0.0 to 1.0
  5097. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5098. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5099. */
  5100. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5101. /**
  5102. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5103. * @param position the position of the point along this path, from 0.0 to 1.0
  5104. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5105. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5106. */
  5107. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5108. /**
  5109. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5110. * @param position the position of the point along this path, from 0.0 to 1.0
  5111. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5112. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5113. */
  5114. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5115. /**
  5116. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5117. * @param position the position of the point along this path, from 0.0 to 1.0
  5118. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5119. */
  5120. getDistanceAt(position: number): number;
  5121. /**
  5122. * Returns the array index of the previous point of an interpolated point along this path
  5123. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5124. * @returns the array index
  5125. */
  5126. getPreviousPointIndexAt(position: number): number;
  5127. /**
  5128. * 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)
  5129. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5130. * @returns the sub position
  5131. */
  5132. getSubPositionAt(position: number): number;
  5133. /**
  5134. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5135. * @param target the vector of which to get the closest position to
  5136. * @returns the position of the closest virtual point on this path to the target vector
  5137. */
  5138. getClosestPositionTo(target: Vector3): number;
  5139. /**
  5140. * Returns a sub path (slice) of this path
  5141. * @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
  5142. * @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
  5143. * @returns a sub path (slice) of this path
  5144. */
  5145. slice(start?: number, end?: number): Path3D;
  5146. /**
  5147. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5148. * @param path path which all values are copied into the curves points
  5149. * @param firstNormal which should be projected onto the curve
  5150. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5151. * @returns the same object updated.
  5152. */
  5153. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5154. private _compute;
  5155. private _getFirstNonNullVector;
  5156. private _getLastNonNullVector;
  5157. private _normalVector;
  5158. /**
  5159. * Updates the point at data for an interpolated point along this curve
  5160. * @param position the position of the point along this curve, from 0.0 to 1.0
  5161. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5162. * @returns the (updated) point at data
  5163. */
  5164. private _updatePointAtData;
  5165. /**
  5166. * Updates the point at data from the specified parameters
  5167. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5168. * @param point the interpolated point
  5169. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5170. */
  5171. private _setPointAtData;
  5172. /**
  5173. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5174. */
  5175. private _updateInterpolationMatrix;
  5176. }
  5177. /**
  5178. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5179. * A Curve3 is designed from a series of successive Vector3.
  5180. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5181. */
  5182. export class Curve3 {
  5183. private _points;
  5184. private _length;
  5185. /**
  5186. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5187. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5188. * @param v1 (Vector3) the control point
  5189. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5190. * @param nbPoints (integer) the wanted number of points in the curve
  5191. * @returns the created Curve3
  5192. */
  5193. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5194. /**
  5195. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5196. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5197. * @param v1 (Vector3) the first control point
  5198. * @param v2 (Vector3) the second control point
  5199. * @param v3 (Vector3) the end point of the Cubic Bezier
  5200. * @param nbPoints (integer) the wanted number of points in the curve
  5201. * @returns the created Curve3
  5202. */
  5203. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5204. /**
  5205. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5206. * @param p1 (Vector3) the origin point of the Hermite Spline
  5207. * @param t1 (Vector3) the tangent vector at the origin point
  5208. * @param p2 (Vector3) the end point of the Hermite Spline
  5209. * @param t2 (Vector3) the tangent vector at the end point
  5210. * @param nbPoints (integer) the wanted number of points in the curve
  5211. * @returns the created Curve3
  5212. */
  5213. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5214. /**
  5215. * Returns a Curve3 object along a CatmullRom Spline curve :
  5216. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5217. * @param nbPoints (integer) the wanted number of points between each curve control points
  5218. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5219. * @returns the created Curve3
  5220. */
  5221. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5222. /**
  5223. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5224. * A Curve3 is designed from a series of successive Vector3.
  5225. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5226. * @param points points which make up the curve
  5227. */
  5228. constructor(points: Vector3[]);
  5229. /**
  5230. * @returns the Curve3 stored array of successive Vector3
  5231. */
  5232. getPoints(): Vector3[];
  5233. /**
  5234. * @returns the computed length (float) of the curve.
  5235. */
  5236. length(): number;
  5237. /**
  5238. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5239. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5240. * curveA and curveB keep unchanged.
  5241. * @param curve the curve to continue from this curve
  5242. * @returns the newly constructed curve
  5243. */
  5244. continue(curve: DeepImmutable<Curve3>): Curve3;
  5245. private _computeLength;
  5246. }
  5247. }
  5248. declare module BABYLON {
  5249. /**
  5250. * This represents the main contract an easing function should follow.
  5251. * Easing functions are used throughout the animation system.
  5252. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5253. */
  5254. export interface IEasingFunction {
  5255. /**
  5256. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5257. * of the easing function.
  5258. * The link below provides some of the most common examples of easing functions.
  5259. * @see https://easings.net/
  5260. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5261. * @returns the corresponding value on the curve defined by the easing function
  5262. */
  5263. ease(gradient: number): number;
  5264. }
  5265. /**
  5266. * Base class used for every default easing function.
  5267. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5268. */
  5269. export class EasingFunction implements IEasingFunction {
  5270. /**
  5271. * Interpolation follows the mathematical formula associated with the easing function.
  5272. */
  5273. static readonly EASINGMODE_EASEIN: number;
  5274. /**
  5275. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5276. */
  5277. static readonly EASINGMODE_EASEOUT: number;
  5278. /**
  5279. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5280. */
  5281. static readonly EASINGMODE_EASEINOUT: number;
  5282. private _easingMode;
  5283. /**
  5284. * Sets the easing mode of the current function.
  5285. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5286. */
  5287. setEasingMode(easingMode: number): void;
  5288. /**
  5289. * Gets the current easing mode.
  5290. * @returns the easing mode
  5291. */
  5292. getEasingMode(): number;
  5293. /**
  5294. * @hidden
  5295. */
  5296. easeInCore(gradient: number): number;
  5297. /**
  5298. * Given an input gradient between 0 and 1, this returns the corresponding value
  5299. * of the easing function.
  5300. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5301. * @returns the corresponding value on the curve defined by the easing function
  5302. */
  5303. ease(gradient: number): number;
  5304. }
  5305. /**
  5306. * Easing function with a circle shape (see link below).
  5307. * @see https://easings.net/#easeInCirc
  5308. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5309. */
  5310. export class CircleEase extends EasingFunction implements IEasingFunction {
  5311. /** @hidden */
  5312. easeInCore(gradient: number): number;
  5313. }
  5314. /**
  5315. * Easing function with a ease back shape (see link below).
  5316. * @see https://easings.net/#easeInBack
  5317. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5318. */
  5319. export class BackEase extends EasingFunction implements IEasingFunction {
  5320. /** Defines the amplitude of the function */
  5321. amplitude: number;
  5322. /**
  5323. * Instantiates a back ease easing
  5324. * @see https://easings.net/#easeInBack
  5325. * @param amplitude Defines the amplitude of the function
  5326. */
  5327. constructor(
  5328. /** Defines the amplitude of the function */
  5329. amplitude?: number);
  5330. /** @hidden */
  5331. easeInCore(gradient: number): number;
  5332. }
  5333. /**
  5334. * Easing function with a bouncing shape (see link below).
  5335. * @see https://easings.net/#easeInBounce
  5336. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5337. */
  5338. export class BounceEase extends EasingFunction implements IEasingFunction {
  5339. /** Defines the number of bounces */
  5340. bounces: number;
  5341. /** Defines the amplitude of the bounce */
  5342. bounciness: number;
  5343. /**
  5344. * Instantiates a bounce easing
  5345. * @see https://easings.net/#easeInBounce
  5346. * @param bounces Defines the number of bounces
  5347. * @param bounciness Defines the amplitude of the bounce
  5348. */
  5349. constructor(
  5350. /** Defines the number of bounces */
  5351. bounces?: number,
  5352. /** Defines the amplitude of the bounce */
  5353. bounciness?: number);
  5354. /** @hidden */
  5355. easeInCore(gradient: number): number;
  5356. }
  5357. /**
  5358. * Easing function with a power of 3 shape (see link below).
  5359. * @see https://easings.net/#easeInCubic
  5360. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5361. */
  5362. export class CubicEase extends EasingFunction implements IEasingFunction {
  5363. /** @hidden */
  5364. easeInCore(gradient: number): number;
  5365. }
  5366. /**
  5367. * Easing function with an elastic shape (see link below).
  5368. * @see https://easings.net/#easeInElastic
  5369. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5370. */
  5371. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5372. /** Defines the number of oscillations*/
  5373. oscillations: number;
  5374. /** Defines the amplitude of the oscillations*/
  5375. springiness: number;
  5376. /**
  5377. * Instantiates an elastic easing function
  5378. * @see https://easings.net/#easeInElastic
  5379. * @param oscillations Defines the number of oscillations
  5380. * @param springiness Defines the amplitude of the oscillations
  5381. */
  5382. constructor(
  5383. /** Defines the number of oscillations*/
  5384. oscillations?: number,
  5385. /** Defines the amplitude of the oscillations*/
  5386. springiness?: number);
  5387. /** @hidden */
  5388. easeInCore(gradient: number): number;
  5389. }
  5390. /**
  5391. * Easing function with an exponential shape (see link below).
  5392. * @see https://easings.net/#easeInExpo
  5393. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5394. */
  5395. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5396. /** Defines the exponent of the function */
  5397. exponent: number;
  5398. /**
  5399. * Instantiates an exponential easing function
  5400. * @see https://easings.net/#easeInExpo
  5401. * @param exponent Defines the exponent of the function
  5402. */
  5403. constructor(
  5404. /** Defines the exponent of the function */
  5405. exponent?: number);
  5406. /** @hidden */
  5407. easeInCore(gradient: number): number;
  5408. }
  5409. /**
  5410. * Easing function with a power shape (see link below).
  5411. * @see https://easings.net/#easeInQuad
  5412. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5413. */
  5414. export class PowerEase extends EasingFunction implements IEasingFunction {
  5415. /** Defines the power of the function */
  5416. power: number;
  5417. /**
  5418. * Instantiates an power base easing function
  5419. * @see https://easings.net/#easeInQuad
  5420. * @param power Defines the power of the function
  5421. */
  5422. constructor(
  5423. /** Defines the power of the function */
  5424. power?: number);
  5425. /** @hidden */
  5426. easeInCore(gradient: number): number;
  5427. }
  5428. /**
  5429. * Easing function with a power of 2 shape (see link below).
  5430. * @see https://easings.net/#easeInQuad
  5431. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5432. */
  5433. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5434. /** @hidden */
  5435. easeInCore(gradient: number): number;
  5436. }
  5437. /**
  5438. * Easing function with a power of 4 shape (see link below).
  5439. * @see https://easings.net/#easeInQuart
  5440. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5441. */
  5442. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5443. /** @hidden */
  5444. easeInCore(gradient: number): number;
  5445. }
  5446. /**
  5447. * Easing function with a power of 5 shape (see link below).
  5448. * @see https://easings.net/#easeInQuint
  5449. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5450. */
  5451. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5452. /** @hidden */
  5453. easeInCore(gradient: number): number;
  5454. }
  5455. /**
  5456. * Easing function with a sin shape (see link below).
  5457. * @see https://easings.net/#easeInSine
  5458. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5459. */
  5460. export class SineEase extends EasingFunction implements IEasingFunction {
  5461. /** @hidden */
  5462. easeInCore(gradient: number): number;
  5463. }
  5464. /**
  5465. * Easing function with a bezier shape (see link below).
  5466. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5467. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5468. */
  5469. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5470. /** Defines the x component of the start tangent in the bezier curve */
  5471. x1: number;
  5472. /** Defines the y component of the start tangent in the bezier curve */
  5473. y1: number;
  5474. /** Defines the x component of the end tangent in the bezier curve */
  5475. x2: number;
  5476. /** Defines the y component of the end tangent in the bezier curve */
  5477. y2: number;
  5478. /**
  5479. * Instantiates a bezier function
  5480. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5481. * @param x1 Defines the x component of the start tangent in the bezier curve
  5482. * @param y1 Defines the y component of the start tangent in the bezier curve
  5483. * @param x2 Defines the x component of the end tangent in the bezier curve
  5484. * @param y2 Defines the y component of the end tangent in the bezier curve
  5485. */
  5486. constructor(
  5487. /** Defines the x component of the start tangent in the bezier curve */
  5488. x1?: number,
  5489. /** Defines the y component of the start tangent in the bezier curve */
  5490. y1?: number,
  5491. /** Defines the x component of the end tangent in the bezier curve */
  5492. x2?: number,
  5493. /** Defines the y component of the end tangent in the bezier curve */
  5494. y2?: number);
  5495. /** @hidden */
  5496. easeInCore(gradient: number): number;
  5497. }
  5498. }
  5499. declare module BABYLON {
  5500. /**
  5501. * Class used to hold a RBG color
  5502. */
  5503. export class Color3 {
  5504. /**
  5505. * Defines the red component (between 0 and 1, default is 0)
  5506. */
  5507. r: number;
  5508. /**
  5509. * Defines the green component (between 0 and 1, default is 0)
  5510. */
  5511. g: number;
  5512. /**
  5513. * Defines the blue component (between 0 and 1, default is 0)
  5514. */
  5515. b: number;
  5516. /**
  5517. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5518. * @param r defines the red component (between 0 and 1, default is 0)
  5519. * @param g defines the green component (between 0 and 1, default is 0)
  5520. * @param b defines the blue component (between 0 and 1, default is 0)
  5521. */
  5522. constructor(
  5523. /**
  5524. * Defines the red component (between 0 and 1, default is 0)
  5525. */
  5526. r?: number,
  5527. /**
  5528. * Defines the green component (between 0 and 1, default is 0)
  5529. */
  5530. g?: number,
  5531. /**
  5532. * Defines the blue component (between 0 and 1, default is 0)
  5533. */
  5534. b?: number);
  5535. /**
  5536. * Creates a string with the Color3 current values
  5537. * @returns the string representation of the Color3 object
  5538. */
  5539. toString(): string;
  5540. /**
  5541. * Returns the string "Color3"
  5542. * @returns "Color3"
  5543. */
  5544. getClassName(): string;
  5545. /**
  5546. * Compute the Color3 hash code
  5547. * @returns an unique number that can be used to hash Color3 objects
  5548. */
  5549. getHashCode(): number;
  5550. /**
  5551. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5552. * @param array defines the array where to store the r,g,b components
  5553. * @param index defines an optional index in the target array to define where to start storing values
  5554. * @returns the current Color3 object
  5555. */
  5556. toArray(array: FloatArray, index?: number): Color3;
  5557. /**
  5558. * Update the current color with values stored in an array from the starting index of the given array
  5559. * @param array defines the source array
  5560. * @param offset defines an offset in the source array
  5561. * @returns the current Color3 object
  5562. */
  5563. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5564. /**
  5565. * Returns a new Color4 object from the current Color3 and the given alpha
  5566. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5567. * @returns a new Color4 object
  5568. */
  5569. toColor4(alpha?: number): Color4;
  5570. /**
  5571. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5572. * @returns the new array
  5573. */
  5574. asArray(): number[];
  5575. /**
  5576. * Returns the luminance value
  5577. * @returns a float value
  5578. */
  5579. toLuminance(): number;
  5580. /**
  5581. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5582. * @param otherColor defines the second operand
  5583. * @returns the new Color3 object
  5584. */
  5585. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5586. /**
  5587. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5588. * @param otherColor defines the second operand
  5589. * @param result defines the Color3 object where to store the result
  5590. * @returns the current Color3
  5591. */
  5592. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5593. /**
  5594. * Determines equality between Color3 objects
  5595. * @param otherColor defines the second operand
  5596. * @returns true if the rgb values are equal to the given ones
  5597. */
  5598. equals(otherColor: DeepImmutable<Color3>): boolean;
  5599. /**
  5600. * Determines equality between the current Color3 object and a set of r,b,g values
  5601. * @param r defines the red component to check
  5602. * @param g defines the green component to check
  5603. * @param b defines the blue component to check
  5604. * @returns true if the rgb values are equal to the given ones
  5605. */
  5606. equalsFloats(r: number, g: number, b: number): boolean;
  5607. /**
  5608. * Multiplies in place each rgb value by scale
  5609. * @param scale defines the scaling factor
  5610. * @returns the updated Color3
  5611. */
  5612. scale(scale: number): Color3;
  5613. /**
  5614. * Multiplies the rgb values by scale and stores the result into "result"
  5615. * @param scale defines the scaling factor
  5616. * @param result defines the Color3 object where to store the result
  5617. * @returns the unmodified current Color3
  5618. */
  5619. scaleToRef(scale: number, result: Color3): Color3;
  5620. /**
  5621. * Scale the current Color3 values by a factor and add the result to a given Color3
  5622. * @param scale defines the scale factor
  5623. * @param result defines color to store the result into
  5624. * @returns the unmodified current Color3
  5625. */
  5626. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5627. /**
  5628. * Clamps the rgb values by the min and max values and stores the result into "result"
  5629. * @param min defines minimum clamping value (default is 0)
  5630. * @param max defines maximum clamping value (default is 1)
  5631. * @param result defines color to store the result into
  5632. * @returns the original Color3
  5633. */
  5634. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5635. /**
  5636. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5637. * @param otherColor defines the second operand
  5638. * @returns the new Color3
  5639. */
  5640. add(otherColor: DeepImmutable<Color3>): Color3;
  5641. /**
  5642. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5643. * @param otherColor defines the second operand
  5644. * @param result defines Color3 object to store the result into
  5645. * @returns the unmodified current Color3
  5646. */
  5647. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5648. /**
  5649. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5650. * @param otherColor defines the second operand
  5651. * @returns the new Color3
  5652. */
  5653. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5654. /**
  5655. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5656. * @param otherColor defines the second operand
  5657. * @param result defines Color3 object to store the result into
  5658. * @returns the unmodified current Color3
  5659. */
  5660. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5661. /**
  5662. * Copy the current object
  5663. * @returns a new Color3 copied the current one
  5664. */
  5665. clone(): Color3;
  5666. /**
  5667. * Copies the rgb values from the source in the current Color3
  5668. * @param source defines the source Color3 object
  5669. * @returns the updated Color3 object
  5670. */
  5671. copyFrom(source: DeepImmutable<Color3>): Color3;
  5672. /**
  5673. * Updates the Color3 rgb values from the given floats
  5674. * @param r defines the red component to read from
  5675. * @param g defines the green component to read from
  5676. * @param b defines the blue component to read from
  5677. * @returns the current Color3 object
  5678. */
  5679. copyFromFloats(r: number, g: number, b: number): Color3;
  5680. /**
  5681. * Updates the Color3 rgb values from the given floats
  5682. * @param r defines the red component to read from
  5683. * @param g defines the green component to read from
  5684. * @param b defines the blue component to read from
  5685. * @returns the current Color3 object
  5686. */
  5687. set(r: number, g: number, b: number): Color3;
  5688. /**
  5689. * Compute the Color3 hexadecimal code as a string
  5690. * @returns a string containing the hexadecimal representation of the Color3 object
  5691. */
  5692. toHexString(): string;
  5693. /**
  5694. * Computes a new Color3 converted from the current one to linear space
  5695. * @returns a new Color3 object
  5696. */
  5697. toLinearSpace(): Color3;
  5698. /**
  5699. * Converts current color in rgb space to HSV values
  5700. * @returns a new color3 representing the HSV values
  5701. */
  5702. toHSV(): Color3;
  5703. /**
  5704. * Converts current color in rgb space to HSV values
  5705. * @param result defines the Color3 where to store the HSV values
  5706. */
  5707. toHSVToRef(result: Color3): void;
  5708. /**
  5709. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5710. * @param convertedColor defines the Color3 object where to store the linear space version
  5711. * @returns the unmodified Color3
  5712. */
  5713. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5714. /**
  5715. * Computes a new Color3 converted from the current one to gamma space
  5716. * @returns a new Color3 object
  5717. */
  5718. toGammaSpace(): Color3;
  5719. /**
  5720. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5721. * @param convertedColor defines the Color3 object where to store the gamma space version
  5722. * @returns the unmodified Color3
  5723. */
  5724. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5725. private static _BlackReadOnly;
  5726. /**
  5727. * Convert Hue, saturation and value to a Color3 (RGB)
  5728. * @param hue defines the hue
  5729. * @param saturation defines the saturation
  5730. * @param value defines the value
  5731. * @param result defines the Color3 where to store the RGB values
  5732. */
  5733. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5734. /**
  5735. * Creates a new Color3 from the string containing valid hexadecimal values
  5736. * @param hex defines a string containing valid hexadecimal values
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromHexString(hex: string): Color3;
  5740. /**
  5741. * Creates a new Color3 from the starting index of the given array
  5742. * @param array defines the source array
  5743. * @param offset defines an offset in the source array
  5744. * @returns a new Color3 object
  5745. */
  5746. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5747. /**
  5748. * Creates a new Color3 from the starting index element of the given array
  5749. * @param array defines the source array to read from
  5750. * @param offset defines the offset in the source array
  5751. * @param result defines the target Color3 object
  5752. */
  5753. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5754. /**
  5755. * Creates a new Color3 from integer values (< 256)
  5756. * @param r defines the red component to read from (value between 0 and 255)
  5757. * @param g defines the green component to read from (value between 0 and 255)
  5758. * @param b defines the blue component to read from (value between 0 and 255)
  5759. * @returns a new Color3 object
  5760. */
  5761. static FromInts(r: number, g: number, b: number): Color3;
  5762. /**
  5763. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5764. * @param start defines the start Color3 value
  5765. * @param end defines the end Color3 value
  5766. * @param amount defines the gradient value between start and end
  5767. * @returns a new Color3 object
  5768. */
  5769. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5770. /**
  5771. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5772. * @param left defines the start value
  5773. * @param right defines the end value
  5774. * @param amount defines the gradient factor
  5775. * @param result defines the Color3 object where to store the result
  5776. */
  5777. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5778. /**
  5779. * Returns a Color3 value containing a red color
  5780. * @returns a new Color3 object
  5781. */
  5782. static Red(): Color3;
  5783. /**
  5784. * Returns a Color3 value containing a green color
  5785. * @returns a new Color3 object
  5786. */
  5787. static Green(): Color3;
  5788. /**
  5789. * Returns a Color3 value containing a blue color
  5790. * @returns a new Color3 object
  5791. */
  5792. static Blue(): Color3;
  5793. /**
  5794. * Returns a Color3 value containing a black color
  5795. * @returns a new Color3 object
  5796. */
  5797. static Black(): Color3;
  5798. /**
  5799. * Gets a Color3 value containing a black color that must not be updated
  5800. */
  5801. static get BlackReadOnly(): DeepImmutable<Color3>;
  5802. /**
  5803. * Returns a Color3 value containing a white color
  5804. * @returns a new Color3 object
  5805. */
  5806. static White(): Color3;
  5807. /**
  5808. * Returns a Color3 value containing a purple color
  5809. * @returns a new Color3 object
  5810. */
  5811. static Purple(): Color3;
  5812. /**
  5813. * Returns a Color3 value containing a magenta color
  5814. * @returns a new Color3 object
  5815. */
  5816. static Magenta(): Color3;
  5817. /**
  5818. * Returns a Color3 value containing a yellow color
  5819. * @returns a new Color3 object
  5820. */
  5821. static Yellow(): Color3;
  5822. /**
  5823. * Returns a Color3 value containing a gray color
  5824. * @returns a new Color3 object
  5825. */
  5826. static Gray(): Color3;
  5827. /**
  5828. * Returns a Color3 value containing a teal color
  5829. * @returns a new Color3 object
  5830. */
  5831. static Teal(): Color3;
  5832. /**
  5833. * Returns a Color3 value containing a random color
  5834. * @returns a new Color3 object
  5835. */
  5836. static Random(): Color3;
  5837. }
  5838. /**
  5839. * Class used to hold a RBGA color
  5840. */
  5841. export class Color4 {
  5842. /**
  5843. * Defines the red component (between 0 and 1, default is 0)
  5844. */
  5845. r: number;
  5846. /**
  5847. * Defines the green component (between 0 and 1, default is 0)
  5848. */
  5849. g: number;
  5850. /**
  5851. * Defines the blue component (between 0 and 1, default is 0)
  5852. */
  5853. b: number;
  5854. /**
  5855. * Defines the alpha component (between 0 and 1, default is 1)
  5856. */
  5857. a: number;
  5858. /**
  5859. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5860. * @param r defines the red component (between 0 and 1, default is 0)
  5861. * @param g defines the green component (between 0 and 1, default is 0)
  5862. * @param b defines the blue component (between 0 and 1, default is 0)
  5863. * @param a defines the alpha component (between 0 and 1, default is 1)
  5864. */
  5865. constructor(
  5866. /**
  5867. * Defines the red component (between 0 and 1, default is 0)
  5868. */
  5869. r?: number,
  5870. /**
  5871. * Defines the green component (between 0 and 1, default is 0)
  5872. */
  5873. g?: number,
  5874. /**
  5875. * Defines the blue component (between 0 and 1, default is 0)
  5876. */
  5877. b?: number,
  5878. /**
  5879. * Defines the alpha component (between 0 and 1, default is 1)
  5880. */
  5881. a?: number);
  5882. /**
  5883. * Adds in place the given Color4 values to the current Color4 object
  5884. * @param right defines the second operand
  5885. * @returns the current updated Color4 object
  5886. */
  5887. addInPlace(right: DeepImmutable<Color4>): Color4;
  5888. /**
  5889. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5890. * @returns the new array
  5891. */
  5892. asArray(): number[];
  5893. /**
  5894. * Stores from the starting index in the given array the Color4 successive values
  5895. * @param array defines the array where to store the r,g,b components
  5896. * @param index defines an optional index in the target array to define where to start storing values
  5897. * @returns the current Color4 object
  5898. */
  5899. toArray(array: number[], index?: number): Color4;
  5900. /**
  5901. * Update the current color with values stored in an array from the starting index of the given array
  5902. * @param array defines the source array
  5903. * @param offset defines an offset in the source array
  5904. * @returns the current Color4 object
  5905. */
  5906. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5907. /**
  5908. * Determines equality between Color4 objects
  5909. * @param otherColor defines the second operand
  5910. * @returns true if the rgba values are equal to the given ones
  5911. */
  5912. equals(otherColor: DeepImmutable<Color4>): boolean;
  5913. /**
  5914. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5915. * @param right defines the second operand
  5916. * @returns a new Color4 object
  5917. */
  5918. add(right: DeepImmutable<Color4>): Color4;
  5919. /**
  5920. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5921. * @param right defines the second operand
  5922. * @returns a new Color4 object
  5923. */
  5924. subtract(right: DeepImmutable<Color4>): Color4;
  5925. /**
  5926. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5927. * @param right defines the second operand
  5928. * @param result defines the Color4 object where to store the result
  5929. * @returns the current Color4 object
  5930. */
  5931. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5932. /**
  5933. * Creates a new Color4 with the current Color4 values multiplied by scale
  5934. * @param scale defines the scaling factor to apply
  5935. * @returns a new Color4 object
  5936. */
  5937. scale(scale: number): Color4;
  5938. /**
  5939. * Multiplies the current Color4 values by scale and stores the result in "result"
  5940. * @param scale defines the scaling factor to apply
  5941. * @param result defines the Color4 object where to store the result
  5942. * @returns the current unmodified Color4
  5943. */
  5944. scaleToRef(scale: number, result: Color4): Color4;
  5945. /**
  5946. * Scale the current Color4 values by a factor and add the result to a given Color4
  5947. * @param scale defines the scale factor
  5948. * @param result defines the Color4 object where to store the result
  5949. * @returns the unmodified current Color4
  5950. */
  5951. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5952. /**
  5953. * Clamps the rgb values by the min and max values and stores the result into "result"
  5954. * @param min defines minimum clamping value (default is 0)
  5955. * @param max defines maximum clamping value (default is 1)
  5956. * @param result defines color to store the result into.
  5957. * @returns the cuurent Color4
  5958. */
  5959. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5960. /**
  5961. * Multipy an Color4 value by another and return a new Color4 object
  5962. * @param color defines the Color4 value to multiply by
  5963. * @returns a new Color4 object
  5964. */
  5965. multiply(color: Color4): Color4;
  5966. /**
  5967. * Multipy a Color4 value by another and push the result in a reference value
  5968. * @param color defines the Color4 value to multiply by
  5969. * @param result defines the Color4 to fill the result in
  5970. * @returns the result Color4
  5971. */
  5972. multiplyToRef(color: Color4, result: Color4): Color4;
  5973. /**
  5974. * Creates a string with the Color4 current values
  5975. * @returns the string representation of the Color4 object
  5976. */
  5977. toString(): string;
  5978. /**
  5979. * Returns the string "Color4"
  5980. * @returns "Color4"
  5981. */
  5982. getClassName(): string;
  5983. /**
  5984. * Compute the Color4 hash code
  5985. * @returns an unique number that can be used to hash Color4 objects
  5986. */
  5987. getHashCode(): number;
  5988. /**
  5989. * Creates a new Color4 copied from the current one
  5990. * @returns a new Color4 object
  5991. */
  5992. clone(): Color4;
  5993. /**
  5994. * Copies the given Color4 values into the current one
  5995. * @param source defines the source Color4 object
  5996. * @returns the current updated Color4 object
  5997. */
  5998. copyFrom(source: Color4): Color4;
  5999. /**
  6000. * Copies the given float values into the current one
  6001. * @param r defines the red component to read from
  6002. * @param g defines the green component to read from
  6003. * @param b defines the blue component to read from
  6004. * @param a defines the alpha component to read from
  6005. * @returns the current updated Color4 object
  6006. */
  6007. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6008. /**
  6009. * Copies the given float values into the current one
  6010. * @param r defines the red component to read from
  6011. * @param g defines the green component to read from
  6012. * @param b defines the blue component to read from
  6013. * @param a defines the alpha component to read from
  6014. * @returns the current updated Color4 object
  6015. */
  6016. set(r: number, g: number, b: number, a: number): Color4;
  6017. /**
  6018. * Compute the Color4 hexadecimal code as a string
  6019. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6020. * @returns a string containing the hexadecimal representation of the Color4 object
  6021. */
  6022. toHexString(returnAsColor3?: boolean): string;
  6023. /**
  6024. * Computes a new Color4 converted from the current one to linear space
  6025. * @returns a new Color4 object
  6026. */
  6027. toLinearSpace(): Color4;
  6028. /**
  6029. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6030. * @param convertedColor defines the Color4 object where to store the linear space version
  6031. * @returns the unmodified Color4
  6032. */
  6033. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6034. /**
  6035. * Computes a new Color4 converted from the current one to gamma space
  6036. * @returns a new Color4 object
  6037. */
  6038. toGammaSpace(): Color4;
  6039. /**
  6040. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6041. * @param convertedColor defines the Color4 object where to store the gamma space version
  6042. * @returns the unmodified Color4
  6043. */
  6044. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6045. /**
  6046. * Creates a new Color4 from the string containing valid hexadecimal values
  6047. * @param hex defines a string containing valid hexadecimal values
  6048. * @returns a new Color4 object
  6049. */
  6050. static FromHexString(hex: string): Color4;
  6051. /**
  6052. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6053. * @param left defines the start value
  6054. * @param right defines the end value
  6055. * @param amount defines the gradient factor
  6056. * @returns a new Color4 object
  6057. */
  6058. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6059. /**
  6060. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6061. * @param left defines the start value
  6062. * @param right defines the end value
  6063. * @param amount defines the gradient factor
  6064. * @param result defines the Color4 object where to store data
  6065. */
  6066. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6067. /**
  6068. * Creates a new Color4 from a Color3 and an alpha value
  6069. * @param color3 defines the source Color3 to read from
  6070. * @param alpha defines the alpha component (1.0 by default)
  6071. * @returns a new Color4 object
  6072. */
  6073. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6074. /**
  6075. * Creates a new Color4 from the starting index element of the given array
  6076. * @param array defines the source array to read from
  6077. * @param offset defines the offset in the source array
  6078. * @returns a new Color4 object
  6079. */
  6080. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6081. /**
  6082. * Creates a new Color4 from the starting index element of the given array
  6083. * @param array defines the source array to read from
  6084. * @param offset defines the offset in the source array
  6085. * @param result defines the target Color4 object
  6086. */
  6087. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6088. /**
  6089. * Creates a new Color3 from integer values (< 256)
  6090. * @param r defines the red component to read from (value between 0 and 255)
  6091. * @param g defines the green component to read from (value between 0 and 255)
  6092. * @param b defines the blue component to read from (value between 0 and 255)
  6093. * @param a defines the alpha component to read from (value between 0 and 255)
  6094. * @returns a new Color3 object
  6095. */
  6096. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6097. /**
  6098. * Check the content of a given array and convert it to an array containing RGBA data
  6099. * If the original array was already containing count * 4 values then it is returned directly
  6100. * @param colors defines the array to check
  6101. * @param count defines the number of RGBA data to expect
  6102. * @returns an array containing count * 4 values (RGBA)
  6103. */
  6104. static CheckColors4(colors: number[], count: number): number[];
  6105. }
  6106. /**
  6107. * @hidden
  6108. */
  6109. export class TmpColors {
  6110. static Color3: Color3[];
  6111. static Color4: Color4[];
  6112. }
  6113. }
  6114. declare module BABYLON {
  6115. /**
  6116. * Defines an interface which represents an animation key frame
  6117. */
  6118. export interface IAnimationKey {
  6119. /**
  6120. * Frame of the key frame
  6121. */
  6122. frame: number;
  6123. /**
  6124. * Value at the specifies key frame
  6125. */
  6126. value: any;
  6127. /**
  6128. * The input tangent for the cubic hermite spline
  6129. */
  6130. inTangent?: any;
  6131. /**
  6132. * The output tangent for the cubic hermite spline
  6133. */
  6134. outTangent?: any;
  6135. /**
  6136. * The animation interpolation type
  6137. */
  6138. interpolation?: AnimationKeyInterpolation;
  6139. }
  6140. /**
  6141. * Enum for the animation key frame interpolation type
  6142. */
  6143. export enum AnimationKeyInterpolation {
  6144. /**
  6145. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6146. */
  6147. STEP = 1
  6148. }
  6149. }
  6150. declare module BABYLON {
  6151. /**
  6152. * Represents the range of an animation
  6153. */
  6154. export class AnimationRange {
  6155. /**The name of the animation range**/
  6156. name: string;
  6157. /**The starting frame of the animation */
  6158. from: number;
  6159. /**The ending frame of the animation*/
  6160. to: number;
  6161. /**
  6162. * Initializes the range of an animation
  6163. * @param name The name of the animation range
  6164. * @param from The starting frame of the animation
  6165. * @param to The ending frame of the animation
  6166. */
  6167. constructor(
  6168. /**The name of the animation range**/
  6169. name: string,
  6170. /**The starting frame of the animation */
  6171. from: number,
  6172. /**The ending frame of the animation*/
  6173. to: number);
  6174. /**
  6175. * Makes a copy of the animation range
  6176. * @returns A copy of the animation range
  6177. */
  6178. clone(): AnimationRange;
  6179. }
  6180. }
  6181. declare module BABYLON {
  6182. /**
  6183. * Composed of a frame, and an action function
  6184. */
  6185. export class AnimationEvent {
  6186. /** The frame for which the event is triggered **/
  6187. frame: number;
  6188. /** The event to perform when triggered **/
  6189. action: (currentFrame: number) => void;
  6190. /** Specifies if the event should be triggered only once**/
  6191. onlyOnce?: boolean | undefined;
  6192. /**
  6193. * Specifies if the animation event is done
  6194. */
  6195. isDone: boolean;
  6196. /**
  6197. * Initializes the animation event
  6198. * @param frame The frame for which the event is triggered
  6199. * @param action The event to perform when triggered
  6200. * @param onlyOnce Specifies if the event should be triggered only once
  6201. */
  6202. constructor(
  6203. /** The frame for which the event is triggered **/
  6204. frame: number,
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void,
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined);
  6209. /** @hidden */
  6210. _clone(): AnimationEvent;
  6211. }
  6212. }
  6213. declare module BABYLON {
  6214. /**
  6215. * Interface used to define a behavior
  6216. */
  6217. export interface Behavior<T> {
  6218. /** gets or sets behavior's name */
  6219. name: string;
  6220. /**
  6221. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6222. */
  6223. init(): void;
  6224. /**
  6225. * Called when the behavior is attached to a target
  6226. * @param target defines the target where the behavior is attached to
  6227. */
  6228. attach(target: T): void;
  6229. /**
  6230. * Called when the behavior is detached from its target
  6231. */
  6232. detach(): void;
  6233. }
  6234. /**
  6235. * Interface implemented by classes supporting behaviors
  6236. */
  6237. export interface IBehaviorAware<T> {
  6238. /**
  6239. * Attach a behavior
  6240. * @param behavior defines the behavior to attach
  6241. * @returns the current host
  6242. */
  6243. addBehavior(behavior: Behavior<T>): T;
  6244. /**
  6245. * Remove a behavior from the current object
  6246. * @param behavior defines the behavior to detach
  6247. * @returns the current host
  6248. */
  6249. removeBehavior(behavior: Behavior<T>): T;
  6250. /**
  6251. * Gets a behavior using its name to search
  6252. * @param name defines the name to search
  6253. * @returns the behavior or null if not found
  6254. */
  6255. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6256. }
  6257. }
  6258. declare module BABYLON {
  6259. /**
  6260. * Defines an array and its length.
  6261. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6262. */
  6263. export interface ISmartArrayLike<T> {
  6264. /**
  6265. * The data of the array.
  6266. */
  6267. data: Array<T>;
  6268. /**
  6269. * The active length of the array.
  6270. */
  6271. length: number;
  6272. }
  6273. /**
  6274. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6275. */
  6276. export class SmartArray<T> implements ISmartArrayLike<T> {
  6277. /**
  6278. * The full set of data from the array.
  6279. */
  6280. data: Array<T>;
  6281. /**
  6282. * The active length of the array.
  6283. */
  6284. length: number;
  6285. protected _id: number;
  6286. /**
  6287. * Instantiates a Smart Array.
  6288. * @param capacity defines the default capacity of the array.
  6289. */
  6290. constructor(capacity: number);
  6291. /**
  6292. * Pushes a value at the end of the active data.
  6293. * @param value defines the object to push in the array.
  6294. */
  6295. push(value: T): void;
  6296. /**
  6297. * Iterates over the active data and apply the lambda to them.
  6298. * @param func defines the action to apply on each value.
  6299. */
  6300. forEach(func: (content: T) => void): void;
  6301. /**
  6302. * Sorts the full sets of data.
  6303. * @param compareFn defines the comparison function to apply.
  6304. */
  6305. sort(compareFn: (a: T, b: T) => number): void;
  6306. /**
  6307. * Resets the active data to an empty array.
  6308. */
  6309. reset(): void;
  6310. /**
  6311. * Releases all the data from the array as well as the array.
  6312. */
  6313. dispose(): void;
  6314. /**
  6315. * Concats the active data with a given array.
  6316. * @param array defines the data to concatenate with.
  6317. */
  6318. concat(array: any): void;
  6319. /**
  6320. * Returns the position of a value in the active data.
  6321. * @param value defines the value to find the index for
  6322. * @returns the index if found in the active data otherwise -1
  6323. */
  6324. indexOf(value: T): number;
  6325. /**
  6326. * Returns whether an element is part of the active data.
  6327. * @param value defines the value to look for
  6328. * @returns true if found in the active data otherwise false
  6329. */
  6330. contains(value: T): boolean;
  6331. private static _GlobalId;
  6332. }
  6333. /**
  6334. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6335. * The data in this array can only be present once
  6336. */
  6337. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6338. private _duplicateId;
  6339. /**
  6340. * Pushes a value at the end of the active data.
  6341. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6342. * @param value defines the object to push in the array.
  6343. */
  6344. push(value: T): void;
  6345. /**
  6346. * Pushes a value at the end of the active data.
  6347. * If the data is already present, it won t be added again
  6348. * @param value defines the object to push in the array.
  6349. * @returns true if added false if it was already present
  6350. */
  6351. pushNoDuplicate(value: T): boolean;
  6352. /**
  6353. * Resets the active data to an empty array.
  6354. */
  6355. reset(): void;
  6356. /**
  6357. * Concats the active data with a given array.
  6358. * This ensures no dupplicate will be present in the result.
  6359. * @param array defines the data to concatenate with.
  6360. */
  6361. concatWithNoDuplicate(array: any): void;
  6362. }
  6363. }
  6364. declare module BABYLON {
  6365. /**
  6366. * @ignore
  6367. * This is a list of all the different input types that are available in the application.
  6368. * Fo instance: ArcRotateCameraGamepadInput...
  6369. */
  6370. export var CameraInputTypes: {};
  6371. /**
  6372. * This is the contract to implement in order to create a new input class.
  6373. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6374. */
  6375. export interface ICameraInput<TCamera extends Camera> {
  6376. /**
  6377. * Defines the camera the input is attached to.
  6378. */
  6379. camera: Nullable<TCamera>;
  6380. /**
  6381. * Gets the class name of the current intput.
  6382. * @returns the class name
  6383. */
  6384. getClassName(): string;
  6385. /**
  6386. * Get the friendly name associated with the input class.
  6387. * @returns the input friendly name
  6388. */
  6389. getSimpleName(): string;
  6390. /**
  6391. * Attach the input controls to a specific dom element to get the input from.
  6392. * @param element Defines the element the controls should be listened from
  6393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6394. */
  6395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6396. /**
  6397. * Detach the current controls from the specified dom element.
  6398. * @param element Defines the element to stop listening the inputs from
  6399. */
  6400. detachControl(element: Nullable<HTMLElement>): void;
  6401. /**
  6402. * Update the current camera state depending on the inputs that have been used this frame.
  6403. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6404. */
  6405. checkInputs?: () => void;
  6406. }
  6407. /**
  6408. * Represents a map of input types to input instance or input index to input instance.
  6409. */
  6410. export interface CameraInputsMap<TCamera extends Camera> {
  6411. /**
  6412. * Accessor to the input by input type.
  6413. */
  6414. [name: string]: ICameraInput<TCamera>;
  6415. /**
  6416. * Accessor to the input by input index.
  6417. */
  6418. [idx: number]: ICameraInput<TCamera>;
  6419. }
  6420. /**
  6421. * This represents the input manager used within a camera.
  6422. * It helps dealing with all the different kind of input attached to a camera.
  6423. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6424. */
  6425. export class CameraInputsManager<TCamera extends Camera> {
  6426. /**
  6427. * Defines the list of inputs attahed to the camera.
  6428. */
  6429. attached: CameraInputsMap<TCamera>;
  6430. /**
  6431. * Defines the dom element the camera is collecting inputs from.
  6432. * This is null if the controls have not been attached.
  6433. */
  6434. attachedElement: Nullable<HTMLElement>;
  6435. /**
  6436. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6437. */
  6438. noPreventDefault: boolean;
  6439. /**
  6440. * Defined the camera the input manager belongs to.
  6441. */
  6442. camera: TCamera;
  6443. /**
  6444. * Update the current camera state depending on the inputs that have been used this frame.
  6445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6446. */
  6447. checkInputs: () => void;
  6448. /**
  6449. * Instantiate a new Camera Input Manager.
  6450. * @param camera Defines the camera the input manager blongs to
  6451. */
  6452. constructor(camera: TCamera);
  6453. /**
  6454. * Add an input method to a camera
  6455. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6456. * @param input camera input method
  6457. */
  6458. add(input: ICameraInput<TCamera>): void;
  6459. /**
  6460. * Remove a specific input method from a camera
  6461. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6462. * @param inputToRemove camera input method
  6463. */
  6464. remove(inputToRemove: ICameraInput<TCamera>): void;
  6465. /**
  6466. * Remove a specific input type from a camera
  6467. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6468. * @param inputType the type of the input to remove
  6469. */
  6470. removeByType(inputType: string): void;
  6471. private _addCheckInputs;
  6472. /**
  6473. * Attach the input controls to the currently attached dom element to listen the events from.
  6474. * @param input Defines the input to attach
  6475. */
  6476. attachInput(input: ICameraInput<TCamera>): void;
  6477. /**
  6478. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6479. * @param element Defines the dom element to collect the events from
  6480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6481. */
  6482. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6483. /**
  6484. * Detach the current manager inputs controls from a specific dom element.
  6485. * @param element Defines the dom element to collect the events from
  6486. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6487. */
  6488. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6489. /**
  6490. * Rebuild the dynamic inputCheck function from the current list of
  6491. * defined inputs in the manager.
  6492. */
  6493. rebuildInputCheck(): void;
  6494. /**
  6495. * Remove all attached input methods from a camera
  6496. */
  6497. clear(): void;
  6498. /**
  6499. * Serialize the current input manager attached to a camera.
  6500. * This ensures than once parsed,
  6501. * the input associated to the camera will be identical to the current ones
  6502. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6503. */
  6504. serialize(serializedCamera: any): void;
  6505. /**
  6506. * Parses an input manager serialized JSON to restore the previous list of inputs
  6507. * and states associated to a camera.
  6508. * @param parsedCamera Defines the JSON to parse
  6509. */
  6510. parse(parsedCamera: any): void;
  6511. }
  6512. }
  6513. declare module BABYLON {
  6514. /**
  6515. * Class used to store data that will be store in GPU memory
  6516. */
  6517. export class Buffer {
  6518. private _engine;
  6519. private _buffer;
  6520. /** @hidden */
  6521. _data: Nullable<DataArray>;
  6522. private _updatable;
  6523. private _instanced;
  6524. private _divisor;
  6525. /**
  6526. * Gets the byte stride.
  6527. */
  6528. readonly byteStride: number;
  6529. /**
  6530. * Constructor
  6531. * @param engine the engine
  6532. * @param data the data to use for this buffer
  6533. * @param updatable whether the data is updatable
  6534. * @param stride the stride (optional)
  6535. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6536. * @param instanced whether the buffer is instanced (optional)
  6537. * @param useBytes set to true if the stride in in bytes (optional)
  6538. * @param divisor sets an optional divisor for instances (1 by default)
  6539. */
  6540. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6541. /**
  6542. * Create a new VertexBuffer based on the current buffer
  6543. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6544. * @param offset defines offset in the buffer (0 by default)
  6545. * @param size defines the size in floats of attributes (position is 3 for instance)
  6546. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6547. * @param instanced defines if the vertex buffer contains indexed data
  6548. * @param useBytes defines if the offset and stride are in bytes *
  6549. * @param divisor sets an optional divisor for instances (1 by default)
  6550. * @returns the new vertex buffer
  6551. */
  6552. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6553. /**
  6554. * Gets a boolean indicating if the Buffer is updatable?
  6555. * @returns true if the buffer is updatable
  6556. */
  6557. isUpdatable(): boolean;
  6558. /**
  6559. * Gets current buffer's data
  6560. * @returns a DataArray or null
  6561. */
  6562. getData(): Nullable<DataArray>;
  6563. /**
  6564. * Gets underlying native buffer
  6565. * @returns underlying native buffer
  6566. */
  6567. getBuffer(): Nullable<DataBuffer>;
  6568. /**
  6569. * Gets the stride in float32 units (i.e. byte stride / 4).
  6570. * May not be an integer if the byte stride is not divisible by 4.
  6571. * @returns the stride in float32 units
  6572. * @deprecated Please use byteStride instead.
  6573. */
  6574. getStrideSize(): number;
  6575. /**
  6576. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6577. * @param data defines the data to store
  6578. */
  6579. create(data?: Nullable<DataArray>): void;
  6580. /** @hidden */
  6581. _rebuild(): void;
  6582. /**
  6583. * Update current buffer data
  6584. * @param data defines the data to store
  6585. */
  6586. update(data: DataArray): void;
  6587. /**
  6588. * Updates the data directly.
  6589. * @param data the new data
  6590. * @param offset the new offset
  6591. * @param vertexCount the vertex count (optional)
  6592. * @param useBytes set to true if the offset is in bytes
  6593. */
  6594. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6595. /**
  6596. * Release all resources
  6597. */
  6598. dispose(): void;
  6599. }
  6600. /**
  6601. * Specialized buffer used to store vertex data
  6602. */
  6603. export class VertexBuffer {
  6604. /** @hidden */
  6605. _buffer: Buffer;
  6606. private _kind;
  6607. private _size;
  6608. private _ownsBuffer;
  6609. private _instanced;
  6610. private _instanceDivisor;
  6611. /**
  6612. * The byte type.
  6613. */
  6614. static readonly BYTE: number;
  6615. /**
  6616. * The unsigned byte type.
  6617. */
  6618. static readonly UNSIGNED_BYTE: number;
  6619. /**
  6620. * The short type.
  6621. */
  6622. static readonly SHORT: number;
  6623. /**
  6624. * The unsigned short type.
  6625. */
  6626. static readonly UNSIGNED_SHORT: number;
  6627. /**
  6628. * The integer type.
  6629. */
  6630. static readonly INT: number;
  6631. /**
  6632. * The unsigned integer type.
  6633. */
  6634. static readonly UNSIGNED_INT: number;
  6635. /**
  6636. * The float type.
  6637. */
  6638. static readonly FLOAT: number;
  6639. /**
  6640. * Gets or sets the instance divisor when in instanced mode
  6641. */
  6642. get instanceDivisor(): number;
  6643. set instanceDivisor(value: number);
  6644. /**
  6645. * Gets the byte stride.
  6646. */
  6647. readonly byteStride: number;
  6648. /**
  6649. * Gets the byte offset.
  6650. */
  6651. readonly byteOffset: number;
  6652. /**
  6653. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6654. */
  6655. readonly normalized: boolean;
  6656. /**
  6657. * Gets the data type of each component in the array.
  6658. */
  6659. readonly type: number;
  6660. /**
  6661. * Constructor
  6662. * @param engine the engine
  6663. * @param data the data to use for this vertex buffer
  6664. * @param kind the vertex buffer kind
  6665. * @param updatable whether the data is updatable
  6666. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6667. * @param stride the stride (optional)
  6668. * @param instanced whether the buffer is instanced (optional)
  6669. * @param offset the offset of the data (optional)
  6670. * @param size the number of components (optional)
  6671. * @param type the type of the component (optional)
  6672. * @param normalized whether the data contains normalized data (optional)
  6673. * @param useBytes set to true if stride and offset are in bytes (optional)
  6674. * @param divisor defines the instance divisor to use (1 by default)
  6675. */
  6676. 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);
  6677. /** @hidden */
  6678. _rebuild(): void;
  6679. /**
  6680. * Returns the kind of the VertexBuffer (string)
  6681. * @returns a string
  6682. */
  6683. getKind(): string;
  6684. /**
  6685. * Gets a boolean indicating if the VertexBuffer is updatable?
  6686. * @returns true if the buffer is updatable
  6687. */
  6688. isUpdatable(): boolean;
  6689. /**
  6690. * Gets current buffer's data
  6691. * @returns a DataArray or null
  6692. */
  6693. getData(): Nullable<DataArray>;
  6694. /**
  6695. * Gets underlying native buffer
  6696. * @returns underlying native buffer
  6697. */
  6698. getBuffer(): Nullable<DataBuffer>;
  6699. /**
  6700. * Gets the stride in float32 units (i.e. byte stride / 4).
  6701. * May not be an integer if the byte stride is not divisible by 4.
  6702. * @returns the stride in float32 units
  6703. * @deprecated Please use byteStride instead.
  6704. */
  6705. getStrideSize(): number;
  6706. /**
  6707. * Returns the offset as a multiple of the type byte length.
  6708. * @returns the offset in bytes
  6709. * @deprecated Please use byteOffset instead.
  6710. */
  6711. getOffset(): number;
  6712. /**
  6713. * Returns the number of components per vertex attribute (integer)
  6714. * @returns the size in float
  6715. */
  6716. getSize(): number;
  6717. /**
  6718. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6719. * @returns true if this buffer is instanced
  6720. */
  6721. getIsInstanced(): boolean;
  6722. /**
  6723. * Returns the instancing divisor, zero for non-instanced (integer).
  6724. * @returns a number
  6725. */
  6726. getInstanceDivisor(): number;
  6727. /**
  6728. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6729. * @param data defines the data to store
  6730. */
  6731. create(data?: DataArray): void;
  6732. /**
  6733. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6734. * This function will create a new buffer if the current one is not updatable
  6735. * @param data defines the data to store
  6736. */
  6737. update(data: DataArray): void;
  6738. /**
  6739. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6740. * Returns the directly updated WebGLBuffer.
  6741. * @param data the new data
  6742. * @param offset the new offset
  6743. * @param useBytes set to true if the offset is in bytes
  6744. */
  6745. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6746. /**
  6747. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6748. */
  6749. dispose(): void;
  6750. /**
  6751. * Enumerates each value of this vertex buffer as numbers.
  6752. * @param count the number of values to enumerate
  6753. * @param callback the callback function called for each value
  6754. */
  6755. forEach(count: number, callback: (value: number, index: number) => void): void;
  6756. /**
  6757. * Positions
  6758. */
  6759. static readonly PositionKind: string;
  6760. /**
  6761. * Normals
  6762. */
  6763. static readonly NormalKind: string;
  6764. /**
  6765. * Tangents
  6766. */
  6767. static readonly TangentKind: string;
  6768. /**
  6769. * Texture coordinates
  6770. */
  6771. static readonly UVKind: string;
  6772. /**
  6773. * Texture coordinates 2
  6774. */
  6775. static readonly UV2Kind: string;
  6776. /**
  6777. * Texture coordinates 3
  6778. */
  6779. static readonly UV3Kind: string;
  6780. /**
  6781. * Texture coordinates 4
  6782. */
  6783. static readonly UV4Kind: string;
  6784. /**
  6785. * Texture coordinates 5
  6786. */
  6787. static readonly UV5Kind: string;
  6788. /**
  6789. * Texture coordinates 6
  6790. */
  6791. static readonly UV6Kind: string;
  6792. /**
  6793. * Colors
  6794. */
  6795. static readonly ColorKind: string;
  6796. /**
  6797. * Matrix indices (for bones)
  6798. */
  6799. static readonly MatricesIndicesKind: string;
  6800. /**
  6801. * Matrix weights (for bones)
  6802. */
  6803. static readonly MatricesWeightsKind: string;
  6804. /**
  6805. * Additional matrix indices (for bones)
  6806. */
  6807. static readonly MatricesIndicesExtraKind: string;
  6808. /**
  6809. * Additional matrix weights (for bones)
  6810. */
  6811. static readonly MatricesWeightsExtraKind: string;
  6812. /**
  6813. * Deduces the stride given a kind.
  6814. * @param kind The kind string to deduce
  6815. * @returns The deduced stride
  6816. */
  6817. static DeduceStride(kind: string): number;
  6818. /**
  6819. * Gets the byte length of the given type.
  6820. * @param type the type
  6821. * @returns the number of bytes
  6822. */
  6823. static GetTypeByteLength(type: number): number;
  6824. /**
  6825. * Enumerates each value of the given parameters as numbers.
  6826. * @param data the data to enumerate
  6827. * @param byteOffset the byte offset of the data
  6828. * @param byteStride the byte stride of the data
  6829. * @param componentCount the number of components per element
  6830. * @param componentType the type of the component
  6831. * @param count the number of values to enumerate
  6832. * @param normalized whether the data is normalized
  6833. * @param callback the callback function called for each value
  6834. */
  6835. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6836. private static _GetFloatValue;
  6837. }
  6838. }
  6839. declare module BABYLON {
  6840. /**
  6841. * The options Interface for creating a Capsule Mesh
  6842. */
  6843. export interface ICreateCapsuleOptions {
  6844. /** The Orientation of the capsule. Default : Vector3.Up() */
  6845. orientation?: Vector3;
  6846. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6847. subdivisions: number;
  6848. /** Number of cylindrical segments on the capsule. */
  6849. tessellation: number;
  6850. /** Height or Length of the capsule. */
  6851. height: number;
  6852. /** Radius of the capsule. */
  6853. radius: number;
  6854. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6855. capSubdivisions: number;
  6856. /** Overwrite for the top radius. */
  6857. radiusTop?: number;
  6858. /** Overwrite for the bottom radius. */
  6859. radiusBottom?: number;
  6860. /** Overwrite for the top capSubdivisions. */
  6861. topCapSubdivisions?: number;
  6862. /** Overwrite for the bottom capSubdivisions. */
  6863. bottomCapSubdivisions?: number;
  6864. }
  6865. /**
  6866. * Class containing static functions to help procedurally build meshes
  6867. */
  6868. export class CapsuleBuilder {
  6869. /**
  6870. * Creates a capsule or a pill mesh
  6871. * @param name defines the name of the mesh
  6872. * @param options The constructors options.
  6873. * @param scene The scene the mesh is scoped to.
  6874. * @returns Capsule Mesh
  6875. */
  6876. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6877. }
  6878. }
  6879. declare module BABYLON {
  6880. /**
  6881. * @hidden
  6882. */
  6883. export class IntersectionInfo {
  6884. bu: Nullable<number>;
  6885. bv: Nullable<number>;
  6886. distance: number;
  6887. faceId: number;
  6888. subMeshId: number;
  6889. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6890. }
  6891. }
  6892. declare module BABYLON {
  6893. /**
  6894. * Class used to store bounding sphere information
  6895. */
  6896. export class BoundingSphere {
  6897. /**
  6898. * Gets the center of the bounding sphere in local space
  6899. */
  6900. readonly center: Vector3;
  6901. /**
  6902. * Radius of the bounding sphere in local space
  6903. */
  6904. radius: number;
  6905. /**
  6906. * Gets the center of the bounding sphere in world space
  6907. */
  6908. readonly centerWorld: Vector3;
  6909. /**
  6910. * Radius of the bounding sphere in world space
  6911. */
  6912. radiusWorld: number;
  6913. /**
  6914. * Gets the minimum vector in local space
  6915. */
  6916. readonly minimum: Vector3;
  6917. /**
  6918. * Gets the maximum vector in local space
  6919. */
  6920. readonly maximum: Vector3;
  6921. private _worldMatrix;
  6922. private static readonly TmpVector3;
  6923. /**
  6924. * Creates a new bounding sphere
  6925. * @param min defines the minimum vector (in local space)
  6926. * @param max defines the maximum vector (in local space)
  6927. * @param worldMatrix defines the new world matrix
  6928. */
  6929. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6930. /**
  6931. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6932. * @param min defines the new minimum vector (in local space)
  6933. * @param max defines the new maximum vector (in local space)
  6934. * @param worldMatrix defines the new world matrix
  6935. */
  6936. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6937. /**
  6938. * Scale the current bounding sphere by applying a scale factor
  6939. * @param factor defines the scale factor to apply
  6940. * @returns the current bounding box
  6941. */
  6942. scale(factor: number): BoundingSphere;
  6943. /**
  6944. * Gets the world matrix of the bounding box
  6945. * @returns a matrix
  6946. */
  6947. getWorldMatrix(): DeepImmutable<Matrix>;
  6948. /** @hidden */
  6949. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6950. /**
  6951. * Tests if the bounding sphere is intersecting the frustum planes
  6952. * @param frustumPlanes defines the frustum planes to test
  6953. * @returns true if there is an intersection
  6954. */
  6955. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6956. /**
  6957. * Tests if the bounding sphere center is in between the frustum planes.
  6958. * Used for optimistic fast inclusion.
  6959. * @param frustumPlanes defines the frustum planes to test
  6960. * @returns true if the sphere center is in between the frustum planes
  6961. */
  6962. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6963. /**
  6964. * Tests if a point is inside the bounding sphere
  6965. * @param point defines the point to test
  6966. * @returns true if the point is inside the bounding sphere
  6967. */
  6968. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6969. /**
  6970. * Checks if two sphere intersct
  6971. * @param sphere0 sphere 0
  6972. * @param sphere1 sphere 1
  6973. * @returns true if the speres intersect
  6974. */
  6975. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6976. }
  6977. }
  6978. declare module BABYLON {
  6979. /**
  6980. * Class used to store bounding box information
  6981. */
  6982. export class BoundingBox implements ICullable {
  6983. /**
  6984. * Gets the 8 vectors representing the bounding box in local space
  6985. */
  6986. readonly vectors: Vector3[];
  6987. /**
  6988. * Gets the center of the bounding box in local space
  6989. */
  6990. readonly center: Vector3;
  6991. /**
  6992. * Gets the center of the bounding box in world space
  6993. */
  6994. readonly centerWorld: Vector3;
  6995. /**
  6996. * Gets the extend size in local space
  6997. */
  6998. readonly extendSize: Vector3;
  6999. /**
  7000. * Gets the extend size in world space
  7001. */
  7002. readonly extendSizeWorld: Vector3;
  7003. /**
  7004. * Gets the OBB (object bounding box) directions
  7005. */
  7006. readonly directions: Vector3[];
  7007. /**
  7008. * Gets the 8 vectors representing the bounding box in world space
  7009. */
  7010. readonly vectorsWorld: Vector3[];
  7011. /**
  7012. * Gets the minimum vector in world space
  7013. */
  7014. readonly minimumWorld: Vector3;
  7015. /**
  7016. * Gets the maximum vector in world space
  7017. */
  7018. readonly maximumWorld: Vector3;
  7019. /**
  7020. * Gets the minimum vector in local space
  7021. */
  7022. readonly minimum: Vector3;
  7023. /**
  7024. * Gets the maximum vector in local space
  7025. */
  7026. readonly maximum: Vector3;
  7027. private _worldMatrix;
  7028. private static readonly TmpVector3;
  7029. /**
  7030. * @hidden
  7031. */
  7032. _tag: number;
  7033. /**
  7034. * Creates a new bounding box
  7035. * @param min defines the minimum vector (in local space)
  7036. * @param max defines the maximum vector (in local space)
  7037. * @param worldMatrix defines the new world matrix
  7038. */
  7039. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7040. /**
  7041. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7042. * @param min defines the new minimum vector (in local space)
  7043. * @param max defines the new maximum vector (in local space)
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7047. /**
  7048. * Scale the current bounding box by applying a scale factor
  7049. * @param factor defines the scale factor to apply
  7050. * @returns the current bounding box
  7051. */
  7052. scale(factor: number): BoundingBox;
  7053. /**
  7054. * Gets the world matrix of the bounding box
  7055. * @returns a matrix
  7056. */
  7057. getWorldMatrix(): DeepImmutable<Matrix>;
  7058. /** @hidden */
  7059. _update(world: DeepImmutable<Matrix>): void;
  7060. /**
  7061. * Tests if the bounding box is intersecting the frustum planes
  7062. * @param frustumPlanes defines the frustum planes to test
  7063. * @returns true if there is an intersection
  7064. */
  7065. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7066. /**
  7067. * Tests if the bounding box is entirely inside the frustum planes
  7068. * @param frustumPlanes defines the frustum planes to test
  7069. * @returns true if there is an inclusion
  7070. */
  7071. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7072. /**
  7073. * Tests if a point is inside the bounding box
  7074. * @param point defines the point to test
  7075. * @returns true if the point is inside the bounding box
  7076. */
  7077. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7078. /**
  7079. * Tests if the bounding box intersects with a bounding sphere
  7080. * @param sphere defines the sphere to test
  7081. * @returns true if there is an intersection
  7082. */
  7083. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7084. /**
  7085. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7086. * @param min defines the min vector to use
  7087. * @param max defines the max vector to use
  7088. * @returns true if there is an intersection
  7089. */
  7090. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7091. /**
  7092. * Tests if two bounding boxes are intersections
  7093. * @param box0 defines the first box to test
  7094. * @param box1 defines the second box to test
  7095. * @returns true if there is an intersection
  7096. */
  7097. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7098. /**
  7099. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7100. * @param minPoint defines the minimum vector of the bounding box
  7101. * @param maxPoint defines the maximum vector of the bounding box
  7102. * @param sphereCenter defines the sphere center
  7103. * @param sphereRadius defines the sphere radius
  7104. * @returns true if there is an intersection
  7105. */
  7106. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7107. /**
  7108. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7109. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7110. * @param frustumPlanes defines the frustum planes to test
  7111. * @return true if there is an inclusion
  7112. */
  7113. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7114. /**
  7115. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7116. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7117. * @param frustumPlanes defines the frustum planes to test
  7118. * @return true if there is an intersection
  7119. */
  7120. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7121. }
  7122. }
  7123. declare module BABYLON {
  7124. /** @hidden */
  7125. export class Collider {
  7126. /** Define if a collision was found */
  7127. collisionFound: boolean;
  7128. /**
  7129. * Define last intersection point in local space
  7130. */
  7131. intersectionPoint: Vector3;
  7132. /**
  7133. * Define last collided mesh
  7134. */
  7135. collidedMesh: Nullable<AbstractMesh>;
  7136. private _collisionPoint;
  7137. private _planeIntersectionPoint;
  7138. private _tempVector;
  7139. private _tempVector2;
  7140. private _tempVector3;
  7141. private _tempVector4;
  7142. private _edge;
  7143. private _baseToVertex;
  7144. private _destinationPoint;
  7145. private _slidePlaneNormal;
  7146. private _displacementVector;
  7147. /** @hidden */
  7148. _radius: Vector3;
  7149. /** @hidden */
  7150. _retry: number;
  7151. private _velocity;
  7152. private _basePoint;
  7153. private _epsilon;
  7154. /** @hidden */
  7155. _velocityWorldLength: number;
  7156. /** @hidden */
  7157. _basePointWorld: Vector3;
  7158. private _velocityWorld;
  7159. private _normalizedVelocity;
  7160. /** @hidden */
  7161. _initialVelocity: Vector3;
  7162. /** @hidden */
  7163. _initialPosition: Vector3;
  7164. private _nearestDistance;
  7165. private _collisionMask;
  7166. get collisionMask(): number;
  7167. set collisionMask(mask: number);
  7168. /**
  7169. * Gets the plane normal used to compute the sliding response (in local space)
  7170. */
  7171. get slidePlaneNormal(): Vector3;
  7172. /** @hidden */
  7173. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7174. /** @hidden */
  7175. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7176. /** @hidden */
  7177. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7178. /** @hidden */
  7179. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7180. /** @hidden */
  7181. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7182. /** @hidden */
  7183. _getResponse(pos: Vector3, vel: Vector3): void;
  7184. }
  7185. }
  7186. declare module BABYLON {
  7187. /**
  7188. * Interface for cullable objects
  7189. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7190. */
  7191. export interface ICullable {
  7192. /**
  7193. * Checks if the object or part of the object is in the frustum
  7194. * @param frustumPlanes Camera near/planes
  7195. * @returns true if the object is in frustum otherwise false
  7196. */
  7197. isInFrustum(frustumPlanes: Plane[]): boolean;
  7198. /**
  7199. * Checks if a cullable object (mesh...) is in the camera frustum
  7200. * Unlike isInFrustum this cheks the full bounding box
  7201. * @param frustumPlanes Camera near/planes
  7202. * @returns true if the object is in frustum otherwise false
  7203. */
  7204. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7205. }
  7206. /**
  7207. * Info for a bounding data of a mesh
  7208. */
  7209. export class BoundingInfo implements ICullable {
  7210. /**
  7211. * Bounding box for the mesh
  7212. */
  7213. readonly boundingBox: BoundingBox;
  7214. /**
  7215. * Bounding sphere for the mesh
  7216. */
  7217. readonly boundingSphere: BoundingSphere;
  7218. private _isLocked;
  7219. private static readonly TmpVector3;
  7220. /**
  7221. * Constructs bounding info
  7222. * @param minimum min vector of the bounding box/sphere
  7223. * @param maximum max vector of the bounding box/sphere
  7224. * @param worldMatrix defines the new world matrix
  7225. */
  7226. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7227. /**
  7228. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7229. * @param min defines the new minimum vector (in local space)
  7230. * @param max defines the new maximum vector (in local space)
  7231. * @param worldMatrix defines the new world matrix
  7232. */
  7233. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7234. /**
  7235. * min vector of the bounding box/sphere
  7236. */
  7237. get minimum(): Vector3;
  7238. /**
  7239. * max vector of the bounding box/sphere
  7240. */
  7241. get maximum(): Vector3;
  7242. /**
  7243. * If the info is locked and won't be updated to avoid perf overhead
  7244. */
  7245. get isLocked(): boolean;
  7246. set isLocked(value: boolean);
  7247. /**
  7248. * Updates the bounding sphere and box
  7249. * @param world world matrix to be used to update
  7250. */
  7251. update(world: DeepImmutable<Matrix>): void;
  7252. /**
  7253. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7254. * @param center New center of the bounding info
  7255. * @param extend New extend of the bounding info
  7256. * @returns the current bounding info
  7257. */
  7258. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7259. /**
  7260. * Scale the current bounding info by applying a scale factor
  7261. * @param factor defines the scale factor to apply
  7262. * @returns the current bounding info
  7263. */
  7264. scale(factor: number): BoundingInfo;
  7265. /**
  7266. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7267. * @param frustumPlanes defines the frustum to test
  7268. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7269. * @returns true if the bounding info is in the frustum planes
  7270. */
  7271. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7272. /**
  7273. * Gets the world distance between the min and max points of the bounding box
  7274. */
  7275. get diagonalLength(): number;
  7276. /**
  7277. * Checks if a cullable object (mesh...) is in the camera frustum
  7278. * Unlike isInFrustum this cheks the full bounding box
  7279. * @param frustumPlanes Camera near/planes
  7280. * @returns true if the object is in frustum otherwise false
  7281. */
  7282. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7283. /** @hidden */
  7284. _checkCollision(collider: Collider): boolean;
  7285. /**
  7286. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7287. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7288. * @param point the point to check intersection with
  7289. * @returns if the point intersects
  7290. */
  7291. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7292. /**
  7293. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7294. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7295. * @param boundingInfo the bounding info to check intersection with
  7296. * @param precise if the intersection should be done using OBB
  7297. * @returns if the bounding info intersects
  7298. */
  7299. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7300. }
  7301. }
  7302. declare module BABYLON {
  7303. /**
  7304. * Extracts minimum and maximum values from a list of indexed positions
  7305. * @param positions defines the positions to use
  7306. * @param indices defines the indices to the positions
  7307. * @param indexStart defines the start index
  7308. * @param indexCount defines the end index
  7309. * @param bias defines bias value to add to the result
  7310. * @return minimum and maximum values
  7311. */
  7312. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7313. minimum: Vector3;
  7314. maximum: Vector3;
  7315. };
  7316. /**
  7317. * Extracts minimum and maximum values from a list of positions
  7318. * @param positions defines the positions to use
  7319. * @param start defines the start index in the positions array
  7320. * @param count defines the number of positions to handle
  7321. * @param bias defines bias value to add to the result
  7322. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7323. * @return minimum and maximum values
  7324. */
  7325. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7326. minimum: Vector3;
  7327. maximum: Vector3;
  7328. };
  7329. }
  7330. declare module BABYLON {
  7331. /** @hidden */
  7332. export class WebGLDataBuffer extends DataBuffer {
  7333. private _buffer;
  7334. constructor(resource: WebGLBuffer);
  7335. get underlyingResource(): any;
  7336. }
  7337. }
  7338. declare module BABYLON {
  7339. /** @hidden */
  7340. export class WebGLPipelineContext implements IPipelineContext {
  7341. engine: ThinEngine;
  7342. program: Nullable<WebGLProgram>;
  7343. context?: WebGLRenderingContext;
  7344. vertexShader?: WebGLShader;
  7345. fragmentShader?: WebGLShader;
  7346. isParallelCompiled: boolean;
  7347. onCompiled?: () => void;
  7348. transformFeedback?: WebGLTransformFeedback | null;
  7349. vertexCompilationError: Nullable<string>;
  7350. fragmentCompilationError: Nullable<string>;
  7351. programLinkError: Nullable<string>;
  7352. programValidationError: Nullable<string>;
  7353. get isAsync(): boolean;
  7354. get isReady(): boolean;
  7355. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7356. _getVertexShaderCode(): string | null;
  7357. _getFragmentShaderCode(): string | null;
  7358. }
  7359. }
  7360. declare module BABYLON {
  7361. interface ThinEngine {
  7362. /**
  7363. * Create an uniform buffer
  7364. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7365. * @param elements defines the content of the uniform buffer
  7366. * @returns the webGL uniform buffer
  7367. */
  7368. createUniformBuffer(elements: FloatArray): DataBuffer;
  7369. /**
  7370. * Create a dynamic uniform buffer
  7371. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7372. * @param elements defines the content of the uniform buffer
  7373. * @returns the webGL uniform buffer
  7374. */
  7375. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7376. /**
  7377. * Update an existing uniform buffer
  7378. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7379. * @param uniformBuffer defines the target uniform buffer
  7380. * @param elements defines the content to update
  7381. * @param offset defines the offset in the uniform buffer where update should start
  7382. * @param count defines the size of the data to update
  7383. */
  7384. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7385. /**
  7386. * Bind an uniform buffer to the current webGL context
  7387. * @param buffer defines the buffer to bind
  7388. */
  7389. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7390. /**
  7391. * Bind a buffer to the current webGL context at a given location
  7392. * @param buffer defines the buffer to bind
  7393. * @param location defines the index where to bind the buffer
  7394. */
  7395. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7396. /**
  7397. * Bind a specific block at a given index in a specific shader program
  7398. * @param pipelineContext defines the pipeline context to use
  7399. * @param blockName defines the block name
  7400. * @param index defines the index where to bind the block
  7401. */
  7402. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7403. }
  7404. }
  7405. declare module BABYLON {
  7406. /**
  7407. * Uniform buffer objects.
  7408. *
  7409. * Handles blocks of uniform on the GPU.
  7410. *
  7411. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7412. *
  7413. * For more information, please refer to :
  7414. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7415. */
  7416. export class UniformBuffer {
  7417. private _engine;
  7418. private _buffer;
  7419. private _data;
  7420. private _bufferData;
  7421. private _dynamic?;
  7422. private _uniformLocations;
  7423. private _uniformSizes;
  7424. private _uniformLocationPointer;
  7425. private _needSync;
  7426. private _noUBO;
  7427. private _currentEffect;
  7428. /** @hidden */
  7429. _alreadyBound: boolean;
  7430. private static _MAX_UNIFORM_SIZE;
  7431. private static _tempBuffer;
  7432. /**
  7433. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7434. * This is dynamic to allow compat with webgl 1 and 2.
  7435. * You will need to pass the name of the uniform as well as the value.
  7436. */
  7437. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7438. /**
  7439. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7440. * This is dynamic to allow compat with webgl 1 and 2.
  7441. * You will need to pass the name of the uniform as well as the value.
  7442. */
  7443. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7444. /**
  7445. * Lambda to Update a single float in a uniform buffer.
  7446. * This is dynamic to allow compat with webgl 1 and 2.
  7447. * You will need to pass the name of the uniform as well as the value.
  7448. */
  7449. updateFloat: (name: string, x: number) => void;
  7450. /**
  7451. * Lambda to Update a vec2 of float in a uniform buffer.
  7452. * This is dynamic to allow compat with webgl 1 and 2.
  7453. * You will need to pass the name of the uniform as well as the value.
  7454. */
  7455. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7456. /**
  7457. * Lambda to Update a vec3 of float in a uniform buffer.
  7458. * This is dynamic to allow compat with webgl 1 and 2.
  7459. * You will need to pass the name of the uniform as well as the value.
  7460. */
  7461. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7462. /**
  7463. * Lambda to Update a vec4 of float in a uniform buffer.
  7464. * This is dynamic to allow compat with webgl 1 and 2.
  7465. * You will need to pass the name of the uniform as well as the value.
  7466. */
  7467. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7468. /**
  7469. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7470. * This is dynamic to allow compat with webgl 1 and 2.
  7471. * You will need to pass the name of the uniform as well as the value.
  7472. */
  7473. updateMatrix: (name: string, mat: Matrix) => void;
  7474. /**
  7475. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7476. * This is dynamic to allow compat with webgl 1 and 2.
  7477. * You will need to pass the name of the uniform as well as the value.
  7478. */
  7479. updateVector3: (name: string, vector: Vector3) => void;
  7480. /**
  7481. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7482. * This is dynamic to allow compat with webgl 1 and 2.
  7483. * You will need to pass the name of the uniform as well as the value.
  7484. */
  7485. updateVector4: (name: string, vector: Vector4) => void;
  7486. /**
  7487. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7488. * This is dynamic to allow compat with webgl 1 and 2.
  7489. * You will need to pass the name of the uniform as well as the value.
  7490. */
  7491. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7492. /**
  7493. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7494. * This is dynamic to allow compat with webgl 1 and 2.
  7495. * You will need to pass the name of the uniform as well as the value.
  7496. */
  7497. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7498. /**
  7499. * Instantiates a new Uniform buffer objects.
  7500. *
  7501. * Handles blocks of uniform on the GPU.
  7502. *
  7503. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7504. *
  7505. * For more information, please refer to :
  7506. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7507. * @param engine Define the engine the buffer is associated with
  7508. * @param data Define the data contained in the buffer
  7509. * @param dynamic Define if the buffer is updatable
  7510. */
  7511. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7512. /**
  7513. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7514. * or just falling back on setUniformXXX calls.
  7515. */
  7516. get useUbo(): boolean;
  7517. /**
  7518. * Indicates if the WebGL underlying uniform buffer is in sync
  7519. * with the javascript cache data.
  7520. */
  7521. get isSync(): boolean;
  7522. /**
  7523. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7524. * Also, a dynamic UniformBuffer will disable cache verification and always
  7525. * update the underlying WebGL uniform buffer to the GPU.
  7526. * @returns if Dynamic, otherwise false
  7527. */
  7528. isDynamic(): boolean;
  7529. /**
  7530. * The data cache on JS side.
  7531. * @returns the underlying data as a float array
  7532. */
  7533. getData(): Float32Array;
  7534. /**
  7535. * The underlying WebGL Uniform buffer.
  7536. * @returns the webgl buffer
  7537. */
  7538. getBuffer(): Nullable<DataBuffer>;
  7539. /**
  7540. * std140 layout specifies how to align data within an UBO structure.
  7541. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7542. * for specs.
  7543. */
  7544. private _fillAlignment;
  7545. /**
  7546. * Adds an uniform in the buffer.
  7547. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7548. * for the layout to be correct !
  7549. * @param name Name of the uniform, as used in the uniform block in the shader.
  7550. * @param size Data size, or data directly.
  7551. */
  7552. addUniform(name: string, size: number | number[]): void;
  7553. /**
  7554. * Adds a Matrix 4x4 to the uniform buffer.
  7555. * @param name Name of the uniform, as used in the uniform block in the shader.
  7556. * @param mat A 4x4 matrix.
  7557. */
  7558. addMatrix(name: string, mat: Matrix): void;
  7559. /**
  7560. * Adds a vec2 to the uniform buffer.
  7561. * @param name Name of the uniform, as used in the uniform block in the shader.
  7562. * @param x Define the x component value of the vec2
  7563. * @param y Define the y component value of the vec2
  7564. */
  7565. addFloat2(name: string, x: number, y: number): void;
  7566. /**
  7567. * Adds a vec3 to the uniform buffer.
  7568. * @param name Name of the uniform, as used in the uniform block in the shader.
  7569. * @param x Define the x component value of the vec3
  7570. * @param y Define the y component value of the vec3
  7571. * @param z Define the z component value of the vec3
  7572. */
  7573. addFloat3(name: string, x: number, y: number, z: number): void;
  7574. /**
  7575. * Adds a vec3 to the uniform buffer.
  7576. * @param name Name of the uniform, as used in the uniform block in the shader.
  7577. * @param color Define the vec3 from a Color
  7578. */
  7579. addColor3(name: string, color: Color3): void;
  7580. /**
  7581. * Adds a vec4 to the uniform buffer.
  7582. * @param name Name of the uniform, as used in the uniform block in the shader.
  7583. * @param color Define the rgb components from a Color
  7584. * @param alpha Define the a component of the vec4
  7585. */
  7586. addColor4(name: string, color: Color3, alpha: number): void;
  7587. /**
  7588. * Adds a vec3 to the uniform buffer.
  7589. * @param name Name of the uniform, as used in the uniform block in the shader.
  7590. * @param vector Define the vec3 components from a Vector
  7591. */
  7592. addVector3(name: string, vector: Vector3): void;
  7593. /**
  7594. * Adds a Matrix 3x3 to the uniform buffer.
  7595. * @param name Name of the uniform, as used in the uniform block in the shader.
  7596. */
  7597. addMatrix3x3(name: string): void;
  7598. /**
  7599. * Adds a Matrix 2x2 to the uniform buffer.
  7600. * @param name Name of the uniform, as used in the uniform block in the shader.
  7601. */
  7602. addMatrix2x2(name: string): void;
  7603. /**
  7604. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7605. */
  7606. create(): void;
  7607. /** @hidden */
  7608. _rebuild(): void;
  7609. /**
  7610. * Updates the WebGL Uniform Buffer on the GPU.
  7611. * If the `dynamic` flag is set to true, no cache comparison is done.
  7612. * Otherwise, the buffer will be updated only if the cache differs.
  7613. */
  7614. update(): void;
  7615. /**
  7616. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7617. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7618. * @param data Define the flattened data
  7619. * @param size Define the size of the data.
  7620. */
  7621. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7622. private _valueCache;
  7623. private _cacheMatrix;
  7624. private _updateMatrix3x3ForUniform;
  7625. private _updateMatrix3x3ForEffect;
  7626. private _updateMatrix2x2ForEffect;
  7627. private _updateMatrix2x2ForUniform;
  7628. private _updateFloatForEffect;
  7629. private _updateFloatForUniform;
  7630. private _updateFloat2ForEffect;
  7631. private _updateFloat2ForUniform;
  7632. private _updateFloat3ForEffect;
  7633. private _updateFloat3ForUniform;
  7634. private _updateFloat4ForEffect;
  7635. private _updateFloat4ForUniform;
  7636. private _updateMatrixForEffect;
  7637. private _updateMatrixForUniform;
  7638. private _updateVector3ForEffect;
  7639. private _updateVector3ForUniform;
  7640. private _updateVector4ForEffect;
  7641. private _updateVector4ForUniform;
  7642. private _updateColor3ForEffect;
  7643. private _updateColor3ForUniform;
  7644. private _updateColor4ForEffect;
  7645. private _updateColor4ForUniform;
  7646. /**
  7647. * Sets a sampler uniform on the effect.
  7648. * @param name Define the name of the sampler.
  7649. * @param texture Define the texture to set in the sampler
  7650. */
  7651. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7652. /**
  7653. * Directly updates the value of the uniform in the cache AND on the GPU.
  7654. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7655. * @param data Define the flattened data
  7656. */
  7657. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7658. /**
  7659. * Binds this uniform buffer to an effect.
  7660. * @param effect Define the effect to bind the buffer to
  7661. * @param name Name of the uniform block in the shader.
  7662. */
  7663. bindToEffect(effect: Effect, name: string): void;
  7664. /**
  7665. * Disposes the uniform buffer.
  7666. */
  7667. dispose(): void;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Enum that determines the text-wrapping mode to use.
  7673. */
  7674. export enum InspectableType {
  7675. /**
  7676. * Checkbox for booleans
  7677. */
  7678. Checkbox = 0,
  7679. /**
  7680. * Sliders for numbers
  7681. */
  7682. Slider = 1,
  7683. /**
  7684. * Vector3
  7685. */
  7686. Vector3 = 2,
  7687. /**
  7688. * Quaternions
  7689. */
  7690. Quaternion = 3,
  7691. /**
  7692. * Color3
  7693. */
  7694. Color3 = 4,
  7695. /**
  7696. * String
  7697. */
  7698. String = 5
  7699. }
  7700. /**
  7701. * Interface used to define custom inspectable properties.
  7702. * This interface is used by the inspector to display custom property grids
  7703. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7704. */
  7705. export interface IInspectable {
  7706. /**
  7707. * Gets the label to display
  7708. */
  7709. label: string;
  7710. /**
  7711. * Gets the name of the property to edit
  7712. */
  7713. propertyName: string;
  7714. /**
  7715. * Gets the type of the editor to use
  7716. */
  7717. type: InspectableType;
  7718. /**
  7719. * Gets the minimum value of the property when using in "slider" mode
  7720. */
  7721. min?: number;
  7722. /**
  7723. * Gets the maximum value of the property when using in "slider" mode
  7724. */
  7725. max?: number;
  7726. /**
  7727. * Gets the setp to use when using in "slider" mode
  7728. */
  7729. step?: number;
  7730. }
  7731. }
  7732. declare module BABYLON {
  7733. /**
  7734. * Class used to provide helper for timing
  7735. */
  7736. export class TimingTools {
  7737. /**
  7738. * Polyfill for setImmediate
  7739. * @param action defines the action to execute after the current execution block
  7740. */
  7741. static SetImmediate(action: () => void): void;
  7742. }
  7743. }
  7744. declare module BABYLON {
  7745. /**
  7746. * Class used to enable instatition of objects by class name
  7747. */
  7748. export class InstantiationTools {
  7749. /**
  7750. * Use this object to register external classes like custom textures or material
  7751. * to allow the laoders to instantiate them
  7752. */
  7753. static RegisteredExternalClasses: {
  7754. [key: string]: Object;
  7755. };
  7756. /**
  7757. * Tries to instantiate a new object from a given class name
  7758. * @param className defines the class name to instantiate
  7759. * @returns the new object or null if the system was not able to do the instantiation
  7760. */
  7761. static Instantiate(className: string): any;
  7762. }
  7763. }
  7764. declare module BABYLON {
  7765. /**
  7766. * Define options used to create a depth texture
  7767. */
  7768. export class DepthTextureCreationOptions {
  7769. /** Specifies whether or not a stencil should be allocated in the texture */
  7770. generateStencil?: boolean;
  7771. /** Specifies whether or not bilinear filtering is enable on the texture */
  7772. bilinearFiltering?: boolean;
  7773. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7774. comparisonFunction?: number;
  7775. /** Specifies if the created texture is a cube texture */
  7776. isCube?: boolean;
  7777. }
  7778. }
  7779. declare module BABYLON {
  7780. interface ThinEngine {
  7781. /**
  7782. * Creates a depth stencil cube texture.
  7783. * This is only available in WebGL 2.
  7784. * @param size The size of face edge in the cube texture.
  7785. * @param options The options defining the cube texture.
  7786. * @returns The cube texture
  7787. */
  7788. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7789. /**
  7790. * Creates a cube texture
  7791. * @param rootUrl defines the url where the files to load is located
  7792. * @param scene defines the current scene
  7793. * @param files defines the list of files to load (1 per face)
  7794. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7795. * @param onLoad defines an optional callback raised when the texture is loaded
  7796. * @param onError defines an optional callback raised if there is an issue to load the texture
  7797. * @param format defines the format of the data
  7798. * @param forcedExtension defines the extension to use to pick the right loader
  7799. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7800. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7801. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7802. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7803. * @returns the cube texture as an InternalTexture
  7804. */
  7805. 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;
  7806. /**
  7807. * Creates a cube texture
  7808. * @param rootUrl defines the url where the files to load is located
  7809. * @param scene defines the current scene
  7810. * @param files defines the list of files to load (1 per face)
  7811. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7812. * @param onLoad defines an optional callback raised when the texture is loaded
  7813. * @param onError defines an optional callback raised if there is an issue to load the texture
  7814. * @param format defines the format of the data
  7815. * @param forcedExtension defines the extension to use to pick the right loader
  7816. * @returns the cube texture as an InternalTexture
  7817. */
  7818. 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;
  7819. /**
  7820. * Creates a cube texture
  7821. * @param rootUrl defines the url where the files to load is located
  7822. * @param scene defines the current scene
  7823. * @param files defines the list of files to load (1 per face)
  7824. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7825. * @param onLoad defines an optional callback raised when the texture is loaded
  7826. * @param onError defines an optional callback raised if there is an issue to load the texture
  7827. * @param format defines the format of the data
  7828. * @param forcedExtension defines the extension to use to pick the right loader
  7829. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7830. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7831. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7832. * @returns the cube texture as an InternalTexture
  7833. */
  7834. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7835. /** @hidden */
  7836. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7837. /** @hidden */
  7838. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7839. /** @hidden */
  7840. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7841. /** @hidden */
  7842. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7843. /**
  7844. * @hidden
  7845. */
  7846. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7847. }
  7848. }
  7849. declare module BABYLON {
  7850. /**
  7851. * Class for creating a cube texture
  7852. */
  7853. export class CubeTexture extends BaseTexture {
  7854. private _delayedOnLoad;
  7855. /**
  7856. * Observable triggered once the texture has been loaded.
  7857. */
  7858. onLoadObservable: Observable<CubeTexture>;
  7859. /**
  7860. * The url of the texture
  7861. */
  7862. url: string;
  7863. /**
  7864. * Gets or sets the center of the bounding box associated with the cube texture.
  7865. * It must define where the camera used to render the texture was set
  7866. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7867. */
  7868. boundingBoxPosition: Vector3;
  7869. private _boundingBoxSize;
  7870. /**
  7871. * Gets or sets the size of the bounding box associated with the cube texture
  7872. * When defined, the cubemap will switch to local mode
  7873. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7874. * @example https://www.babylonjs-playground.com/#RNASML
  7875. */
  7876. set boundingBoxSize(value: Vector3);
  7877. /**
  7878. * Returns the bounding box size
  7879. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7880. */
  7881. get boundingBoxSize(): Vector3;
  7882. protected _rotationY: number;
  7883. /**
  7884. * Sets texture matrix rotation angle around Y axis in radians.
  7885. */
  7886. set rotationY(value: number);
  7887. /**
  7888. * Gets texture matrix rotation angle around Y axis radians.
  7889. */
  7890. get rotationY(): number;
  7891. /**
  7892. * Are mip maps generated for this texture or not.
  7893. */
  7894. get noMipmap(): boolean;
  7895. private _noMipmap;
  7896. private _files;
  7897. protected _forcedExtension: Nullable<string>;
  7898. private _extensions;
  7899. private _textureMatrix;
  7900. private _format;
  7901. private _createPolynomials;
  7902. /**
  7903. * Creates a cube texture from an array of image urls
  7904. * @param files defines an array of image urls
  7905. * @param scene defines the hosting scene
  7906. * @param noMipmap specifies if mip maps are not used
  7907. * @returns a cube texture
  7908. */
  7909. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7910. /**
  7911. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7912. * @param url defines the url of the prefiltered texture
  7913. * @param scene defines the scene the texture is attached to
  7914. * @param forcedExtension defines the extension of the file if different from the url
  7915. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7916. * @return the prefiltered texture
  7917. */
  7918. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7919. /**
  7920. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7921. * as prefiltered data.
  7922. * @param rootUrl defines the url of the texture or the root name of the six images
  7923. * @param null defines the scene or engine the texture is attached to
  7924. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7925. * @param noMipmap defines if mipmaps should be created or not
  7926. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7927. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7928. * @param onError defines a callback triggered in case of error during load
  7929. * @param format defines the internal format to use for the texture once loaded
  7930. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7931. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7932. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7933. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7934. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7935. * @return the cube texture
  7936. */
  7937. 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);
  7938. /**
  7939. * Get the current class name of the texture useful for serialization or dynamic coding.
  7940. * @returns "CubeTexture"
  7941. */
  7942. getClassName(): string;
  7943. /**
  7944. * Update the url (and optional buffer) of this texture if url was null during construction.
  7945. * @param url the url of the texture
  7946. * @param forcedExtension defines the extension to use
  7947. * @param onLoad callback called when the texture is loaded (defaults to null)
  7948. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7949. */
  7950. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7951. /**
  7952. * Delays loading of the cube texture
  7953. * @param forcedExtension defines the extension to use
  7954. */
  7955. delayLoad(forcedExtension?: string): void;
  7956. /**
  7957. * Returns the reflection texture matrix
  7958. * @returns the reflection texture matrix
  7959. */
  7960. getReflectionTextureMatrix(): Matrix;
  7961. /**
  7962. * Sets the reflection texture matrix
  7963. * @param value Reflection texture matrix
  7964. */
  7965. setReflectionTextureMatrix(value: Matrix): void;
  7966. /**
  7967. * Parses text to create a cube texture
  7968. * @param parsedTexture define the serialized text to read from
  7969. * @param scene defines the hosting scene
  7970. * @param rootUrl defines the root url of the cube texture
  7971. * @returns a cube texture
  7972. */
  7973. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7974. /**
  7975. * Makes a clone, or deep copy, of the cube texture
  7976. * @returns a new cube texture
  7977. */
  7978. clone(): CubeTexture;
  7979. }
  7980. }
  7981. declare module BABYLON {
  7982. /**
  7983. * Manages the defines for the Material
  7984. */
  7985. export class MaterialDefines {
  7986. /** @hidden */
  7987. protected _keys: string[];
  7988. private _isDirty;
  7989. /** @hidden */
  7990. _renderId: number;
  7991. /** @hidden */
  7992. _areLightsDirty: boolean;
  7993. /** @hidden */
  7994. _areLightsDisposed: boolean;
  7995. /** @hidden */
  7996. _areAttributesDirty: boolean;
  7997. /** @hidden */
  7998. _areTexturesDirty: boolean;
  7999. /** @hidden */
  8000. _areFresnelDirty: boolean;
  8001. /** @hidden */
  8002. _areMiscDirty: boolean;
  8003. /** @hidden */
  8004. _arePrePassDirty: boolean;
  8005. /** @hidden */
  8006. _areImageProcessingDirty: boolean;
  8007. /** @hidden */
  8008. _normals: boolean;
  8009. /** @hidden */
  8010. _uvs: boolean;
  8011. /** @hidden */
  8012. _needNormals: boolean;
  8013. /** @hidden */
  8014. _needUVs: boolean;
  8015. [id: string]: any;
  8016. /**
  8017. * Specifies if the material needs to be re-calculated
  8018. */
  8019. get isDirty(): boolean;
  8020. /**
  8021. * Marks the material to indicate that it has been re-calculated
  8022. */
  8023. markAsProcessed(): void;
  8024. /**
  8025. * Marks the material to indicate that it needs to be re-calculated
  8026. */
  8027. markAsUnprocessed(): void;
  8028. /**
  8029. * Marks the material to indicate all of its defines need to be re-calculated
  8030. */
  8031. markAllAsDirty(): void;
  8032. /**
  8033. * Marks the material to indicate that image processing needs to be re-calculated
  8034. */
  8035. markAsImageProcessingDirty(): void;
  8036. /**
  8037. * Marks the material to indicate the lights need to be re-calculated
  8038. * @param disposed Defines whether the light is dirty due to dispose or not
  8039. */
  8040. markAsLightDirty(disposed?: boolean): void;
  8041. /**
  8042. * Marks the attribute state as changed
  8043. */
  8044. markAsAttributesDirty(): void;
  8045. /**
  8046. * Marks the texture state as changed
  8047. */
  8048. markAsTexturesDirty(): void;
  8049. /**
  8050. * Marks the fresnel state as changed
  8051. */
  8052. markAsFresnelDirty(): void;
  8053. /**
  8054. * Marks the misc state as changed
  8055. */
  8056. markAsMiscDirty(): void;
  8057. /**
  8058. * Marks the prepass state as changed
  8059. */
  8060. markAsPrePassDirty(): void;
  8061. /**
  8062. * Rebuilds the material defines
  8063. */
  8064. rebuild(): void;
  8065. /**
  8066. * Specifies if two material defines are equal
  8067. * @param other - A material define instance to compare to
  8068. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8069. */
  8070. isEqual(other: MaterialDefines): boolean;
  8071. /**
  8072. * Clones this instance's defines to another instance
  8073. * @param other - material defines to clone values to
  8074. */
  8075. cloneTo(other: MaterialDefines): void;
  8076. /**
  8077. * Resets the material define values
  8078. */
  8079. reset(): void;
  8080. /**
  8081. * Converts the material define values to a string
  8082. * @returns - String of material define information
  8083. */
  8084. toString(): string;
  8085. }
  8086. }
  8087. declare module BABYLON {
  8088. /**
  8089. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8090. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8091. * 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;
  8092. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8093. */
  8094. export class ColorCurves {
  8095. private _dirty;
  8096. private _tempColor;
  8097. private _globalCurve;
  8098. private _highlightsCurve;
  8099. private _midtonesCurve;
  8100. private _shadowsCurve;
  8101. private _positiveCurve;
  8102. private _negativeCurve;
  8103. private _globalHue;
  8104. private _globalDensity;
  8105. private _globalSaturation;
  8106. private _globalExposure;
  8107. /**
  8108. * Gets the global Hue value.
  8109. * 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).
  8110. */
  8111. get globalHue(): number;
  8112. /**
  8113. * Sets the global Hue value.
  8114. * 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).
  8115. */
  8116. set globalHue(value: number);
  8117. /**
  8118. * Gets the global Density value.
  8119. * 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.
  8120. * Values less than zero provide a filter of opposite hue.
  8121. */
  8122. get globalDensity(): number;
  8123. /**
  8124. * Sets the global Density value.
  8125. * 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.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. set globalDensity(value: number);
  8129. /**
  8130. * Gets the global Saturation value.
  8131. * 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.
  8132. */
  8133. get globalSaturation(): number;
  8134. /**
  8135. * Sets the global Saturation value.
  8136. * 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.
  8137. */
  8138. set globalSaturation(value: number);
  8139. /**
  8140. * Gets the global Exposure value.
  8141. * 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.
  8142. */
  8143. get globalExposure(): number;
  8144. /**
  8145. * Sets the global Exposure value.
  8146. * 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.
  8147. */
  8148. set globalExposure(value: number);
  8149. private _highlightsHue;
  8150. private _highlightsDensity;
  8151. private _highlightsSaturation;
  8152. private _highlightsExposure;
  8153. /**
  8154. * Gets the highlights Hue value.
  8155. * 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).
  8156. */
  8157. get highlightsHue(): number;
  8158. /**
  8159. * Sets the highlights Hue value.
  8160. * 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).
  8161. */
  8162. set highlightsHue(value: number);
  8163. /**
  8164. * Gets the highlights Density value.
  8165. * 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.
  8166. * Values less than zero provide a filter of opposite hue.
  8167. */
  8168. get highlightsDensity(): number;
  8169. /**
  8170. * Sets the highlights Density value.
  8171. * 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.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. set highlightsDensity(value: number);
  8175. /**
  8176. * Gets the highlights Saturation value.
  8177. * 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.
  8178. */
  8179. get highlightsSaturation(): number;
  8180. /**
  8181. * Sets the highlights Saturation value.
  8182. * 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.
  8183. */
  8184. set highlightsSaturation(value: number);
  8185. /**
  8186. * Gets the highlights Exposure value.
  8187. * 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.
  8188. */
  8189. get highlightsExposure(): number;
  8190. /**
  8191. * Sets the highlights Exposure value.
  8192. * 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.
  8193. */
  8194. set highlightsExposure(value: number);
  8195. private _midtonesHue;
  8196. private _midtonesDensity;
  8197. private _midtonesSaturation;
  8198. private _midtonesExposure;
  8199. /**
  8200. * Gets the midtones Hue value.
  8201. * 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).
  8202. */
  8203. get midtonesHue(): number;
  8204. /**
  8205. * Sets the midtones Hue value.
  8206. * 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).
  8207. */
  8208. set midtonesHue(value: number);
  8209. /**
  8210. * Gets the midtones Density value.
  8211. * 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.
  8212. * Values less than zero provide a filter of opposite hue.
  8213. */
  8214. get midtonesDensity(): number;
  8215. /**
  8216. * Sets the midtones Density value.
  8217. * 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.
  8218. * Values less than zero provide a filter of opposite hue.
  8219. */
  8220. set midtonesDensity(value: number);
  8221. /**
  8222. * Gets the midtones Saturation value.
  8223. * 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.
  8224. */
  8225. get midtonesSaturation(): number;
  8226. /**
  8227. * Sets the midtones Saturation value.
  8228. * 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.
  8229. */
  8230. set midtonesSaturation(value: number);
  8231. /**
  8232. * Gets the midtones Exposure value.
  8233. * 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.
  8234. */
  8235. get midtonesExposure(): number;
  8236. /**
  8237. * Sets the midtones Exposure value.
  8238. * 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.
  8239. */
  8240. set midtonesExposure(value: number);
  8241. private _shadowsHue;
  8242. private _shadowsDensity;
  8243. private _shadowsSaturation;
  8244. private _shadowsExposure;
  8245. /**
  8246. * Gets the shadows Hue value.
  8247. * 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).
  8248. */
  8249. get shadowsHue(): number;
  8250. /**
  8251. * Sets the shadows Hue value.
  8252. * 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).
  8253. */
  8254. set shadowsHue(value: number);
  8255. /**
  8256. * Gets the shadows Density value.
  8257. * 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.
  8258. * Values less than zero provide a filter of opposite hue.
  8259. */
  8260. get shadowsDensity(): number;
  8261. /**
  8262. * Sets the shadows Density value.
  8263. * 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.
  8264. * Values less than zero provide a filter of opposite hue.
  8265. */
  8266. set shadowsDensity(value: number);
  8267. /**
  8268. * Gets the shadows Saturation value.
  8269. * 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.
  8270. */
  8271. get shadowsSaturation(): number;
  8272. /**
  8273. * Sets the shadows Saturation value.
  8274. * 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.
  8275. */
  8276. set shadowsSaturation(value: number);
  8277. /**
  8278. * Gets the shadows Exposure value.
  8279. * 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.
  8280. */
  8281. get shadowsExposure(): number;
  8282. /**
  8283. * Sets the shadows Exposure value.
  8284. * 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.
  8285. */
  8286. set shadowsExposure(value: number);
  8287. /**
  8288. * Returns the class name
  8289. * @returns The class name
  8290. */
  8291. getClassName(): string;
  8292. /**
  8293. * Binds the color curves to the shader.
  8294. * @param colorCurves The color curve to bind
  8295. * @param effect The effect to bind to
  8296. * @param positiveUniform The positive uniform shader parameter
  8297. * @param neutralUniform The neutral uniform shader parameter
  8298. * @param negativeUniform The negative uniform shader parameter
  8299. */
  8300. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8301. /**
  8302. * Prepare the list of uniforms associated with the ColorCurves effects.
  8303. * @param uniformsList The list of uniforms used in the effect
  8304. */
  8305. static PrepareUniforms(uniformsList: string[]): void;
  8306. /**
  8307. * Returns color grading data based on a hue, density, saturation and exposure value.
  8308. * @param filterHue The hue of the color filter.
  8309. * @param filterDensity The density of the color filter.
  8310. * @param saturation The saturation.
  8311. * @param exposure The exposure.
  8312. * @param result The result data container.
  8313. */
  8314. private getColorGradingDataToRef;
  8315. /**
  8316. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8317. * @param value The input slider value in range [-100,100].
  8318. * @returns Adjusted value.
  8319. */
  8320. private static applyColorGradingSliderNonlinear;
  8321. /**
  8322. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8323. * @param hue The hue (H) input.
  8324. * @param saturation The saturation (S) input.
  8325. * @param brightness The brightness (B) input.
  8326. * @result An RGBA color represented as Vector4.
  8327. */
  8328. private static fromHSBToRef;
  8329. /**
  8330. * Returns a value clamped between min and max
  8331. * @param value The value to clamp
  8332. * @param min The minimum of value
  8333. * @param max The maximum of value
  8334. * @returns The clamped value.
  8335. */
  8336. private static clamp;
  8337. /**
  8338. * Clones the current color curve instance.
  8339. * @return The cloned curves
  8340. */
  8341. clone(): ColorCurves;
  8342. /**
  8343. * Serializes the current color curve instance to a json representation.
  8344. * @return a JSON representation
  8345. */
  8346. serialize(): any;
  8347. /**
  8348. * Parses the color curve from a json representation.
  8349. * @param source the JSON source to parse
  8350. * @return The parsed curves
  8351. */
  8352. static Parse(source: any): ColorCurves;
  8353. }
  8354. }
  8355. declare module BABYLON {
  8356. /**
  8357. * Interface to follow in your material defines to integrate easily the
  8358. * Image proccessing functions.
  8359. * @hidden
  8360. */
  8361. export interface IImageProcessingConfigurationDefines {
  8362. IMAGEPROCESSING: boolean;
  8363. VIGNETTE: boolean;
  8364. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8365. VIGNETTEBLENDMODEOPAQUE: boolean;
  8366. TONEMAPPING: boolean;
  8367. TONEMAPPING_ACES: boolean;
  8368. CONTRAST: boolean;
  8369. EXPOSURE: boolean;
  8370. COLORCURVES: boolean;
  8371. COLORGRADING: boolean;
  8372. COLORGRADING3D: boolean;
  8373. SAMPLER3DGREENDEPTH: boolean;
  8374. SAMPLER3DBGRMAP: boolean;
  8375. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8376. }
  8377. /**
  8378. * @hidden
  8379. */
  8380. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8381. IMAGEPROCESSING: boolean;
  8382. VIGNETTE: boolean;
  8383. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8384. VIGNETTEBLENDMODEOPAQUE: boolean;
  8385. TONEMAPPING: boolean;
  8386. TONEMAPPING_ACES: boolean;
  8387. CONTRAST: boolean;
  8388. COLORCURVES: boolean;
  8389. COLORGRADING: boolean;
  8390. COLORGRADING3D: boolean;
  8391. SAMPLER3DGREENDEPTH: boolean;
  8392. SAMPLER3DBGRMAP: boolean;
  8393. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8394. EXPOSURE: boolean;
  8395. constructor();
  8396. }
  8397. /**
  8398. * This groups together the common properties used for image processing either in direct forward pass
  8399. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8400. * or not.
  8401. */
  8402. export class ImageProcessingConfiguration {
  8403. /**
  8404. * Default tone mapping applied in BabylonJS.
  8405. */
  8406. static readonly TONEMAPPING_STANDARD: number;
  8407. /**
  8408. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8409. * to other engines rendering to increase portability.
  8410. */
  8411. static readonly TONEMAPPING_ACES: number;
  8412. /**
  8413. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8414. */
  8415. colorCurves: Nullable<ColorCurves>;
  8416. private _colorCurvesEnabled;
  8417. /**
  8418. * Gets wether the color curves effect is enabled.
  8419. */
  8420. get colorCurvesEnabled(): boolean;
  8421. /**
  8422. * Sets wether the color curves effect is enabled.
  8423. */
  8424. set colorCurvesEnabled(value: boolean);
  8425. private _colorGradingTexture;
  8426. /**
  8427. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8428. */
  8429. get colorGradingTexture(): Nullable<BaseTexture>;
  8430. /**
  8431. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8432. */
  8433. set colorGradingTexture(value: Nullable<BaseTexture>);
  8434. private _colorGradingEnabled;
  8435. /**
  8436. * Gets wether the color grading effect is enabled.
  8437. */
  8438. get colorGradingEnabled(): boolean;
  8439. /**
  8440. * Sets wether the color grading effect is enabled.
  8441. */
  8442. set colorGradingEnabled(value: boolean);
  8443. private _colorGradingWithGreenDepth;
  8444. /**
  8445. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8446. */
  8447. get colorGradingWithGreenDepth(): boolean;
  8448. /**
  8449. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8450. */
  8451. set colorGradingWithGreenDepth(value: boolean);
  8452. private _colorGradingBGR;
  8453. /**
  8454. * Gets wether the color grading texture contains BGR values.
  8455. */
  8456. get colorGradingBGR(): boolean;
  8457. /**
  8458. * Sets wether the color grading texture contains BGR values.
  8459. */
  8460. set colorGradingBGR(value: boolean);
  8461. /** @hidden */
  8462. _exposure: number;
  8463. /**
  8464. * Gets the Exposure used in the effect.
  8465. */
  8466. get exposure(): number;
  8467. /**
  8468. * Sets the Exposure used in the effect.
  8469. */
  8470. set exposure(value: number);
  8471. private _toneMappingEnabled;
  8472. /**
  8473. * Gets wether the tone mapping effect is enabled.
  8474. */
  8475. get toneMappingEnabled(): boolean;
  8476. /**
  8477. * Sets wether the tone mapping effect is enabled.
  8478. */
  8479. set toneMappingEnabled(value: boolean);
  8480. private _toneMappingType;
  8481. /**
  8482. * Gets the type of tone mapping effect.
  8483. */
  8484. get toneMappingType(): number;
  8485. /**
  8486. * Sets the type of tone mapping effect used in BabylonJS.
  8487. */
  8488. set toneMappingType(value: number);
  8489. protected _contrast: number;
  8490. /**
  8491. * Gets the contrast used in the effect.
  8492. */
  8493. get contrast(): number;
  8494. /**
  8495. * Sets the contrast used in the effect.
  8496. */
  8497. set contrast(value: number);
  8498. /**
  8499. * Vignette stretch size.
  8500. */
  8501. vignetteStretch: number;
  8502. /**
  8503. * Vignette centre X Offset.
  8504. */
  8505. vignetteCentreX: number;
  8506. /**
  8507. * Vignette centre Y Offset.
  8508. */
  8509. vignetteCentreY: number;
  8510. /**
  8511. * Vignette weight or intensity of the vignette effect.
  8512. */
  8513. vignetteWeight: number;
  8514. /**
  8515. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8516. * if vignetteEnabled is set to true.
  8517. */
  8518. vignetteColor: Color4;
  8519. /**
  8520. * Camera field of view used by the Vignette effect.
  8521. */
  8522. vignetteCameraFov: number;
  8523. private _vignetteBlendMode;
  8524. /**
  8525. * Gets the vignette blend mode allowing different kind of effect.
  8526. */
  8527. get vignetteBlendMode(): number;
  8528. /**
  8529. * Sets the vignette blend mode allowing different kind of effect.
  8530. */
  8531. set vignetteBlendMode(value: number);
  8532. private _vignetteEnabled;
  8533. /**
  8534. * Gets wether the vignette effect is enabled.
  8535. */
  8536. get vignetteEnabled(): boolean;
  8537. /**
  8538. * Sets wether the vignette effect is enabled.
  8539. */
  8540. set vignetteEnabled(value: boolean);
  8541. private _applyByPostProcess;
  8542. /**
  8543. * Gets wether the image processing is applied through a post process or not.
  8544. */
  8545. get applyByPostProcess(): boolean;
  8546. /**
  8547. * Sets wether the image processing is applied through a post process or not.
  8548. */
  8549. set applyByPostProcess(value: boolean);
  8550. private _isEnabled;
  8551. /**
  8552. * Gets wether the image processing is enabled or not.
  8553. */
  8554. get isEnabled(): boolean;
  8555. /**
  8556. * Sets wether the image processing is enabled or not.
  8557. */
  8558. set isEnabled(value: boolean);
  8559. /**
  8560. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8561. */
  8562. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8563. /**
  8564. * Method called each time the image processing information changes requires to recompile the effect.
  8565. */
  8566. protected _updateParameters(): void;
  8567. /**
  8568. * Gets the current class name.
  8569. * @return "ImageProcessingConfiguration"
  8570. */
  8571. getClassName(): string;
  8572. /**
  8573. * Prepare the list of uniforms associated with the Image Processing effects.
  8574. * @param uniforms The list of uniforms used in the effect
  8575. * @param defines the list of defines currently in use
  8576. */
  8577. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8578. /**
  8579. * Prepare the list of samplers associated with the Image Processing effects.
  8580. * @param samplersList The list of uniforms used in the effect
  8581. * @param defines the list of defines currently in use
  8582. */
  8583. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8584. /**
  8585. * Prepare the list of defines associated to the shader.
  8586. * @param defines the list of defines to complete
  8587. * @param forPostProcess Define if we are currently in post process mode or not
  8588. */
  8589. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8590. /**
  8591. * Returns true if all the image processing information are ready.
  8592. * @returns True if ready, otherwise, false
  8593. */
  8594. isReady(): boolean;
  8595. /**
  8596. * Binds the image processing to the shader.
  8597. * @param effect The effect to bind to
  8598. * @param overrideAspectRatio Override the aspect ratio of the effect
  8599. */
  8600. bind(effect: Effect, overrideAspectRatio?: number): void;
  8601. /**
  8602. * Clones the current image processing instance.
  8603. * @return The cloned image processing
  8604. */
  8605. clone(): ImageProcessingConfiguration;
  8606. /**
  8607. * Serializes the current image processing instance to a json representation.
  8608. * @return a JSON representation
  8609. */
  8610. serialize(): any;
  8611. /**
  8612. * Parses the image processing from a json representation.
  8613. * @param source the JSON source to parse
  8614. * @return The parsed image processing
  8615. */
  8616. static Parse(source: any): ImageProcessingConfiguration;
  8617. private static _VIGNETTEMODE_MULTIPLY;
  8618. private static _VIGNETTEMODE_OPAQUE;
  8619. /**
  8620. * Used to apply the vignette as a mix with the pixel color.
  8621. */
  8622. static get VIGNETTEMODE_MULTIPLY(): number;
  8623. /**
  8624. * Used to apply the vignette as a replacement of the pixel color.
  8625. */
  8626. static get VIGNETTEMODE_OPAQUE(): number;
  8627. }
  8628. }
  8629. declare module BABYLON {
  8630. /** @hidden */
  8631. export var postprocessVertexShader: {
  8632. name: string;
  8633. shader: string;
  8634. };
  8635. }
  8636. declare module BABYLON {
  8637. /**
  8638. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8639. */
  8640. export type RenderTargetTextureSize = number | {
  8641. width: number;
  8642. height: number;
  8643. layers?: number;
  8644. };
  8645. interface ThinEngine {
  8646. /**
  8647. * Creates a new render target texture
  8648. * @param size defines the size of the texture
  8649. * @param options defines the options used to create the texture
  8650. * @returns a new render target texture stored in an InternalTexture
  8651. */
  8652. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8653. /**
  8654. * Creates a depth stencil texture.
  8655. * This is only available in WebGL 2 or with the depth texture extension available.
  8656. * @param size The size of face edge in the texture.
  8657. * @param options The options defining the texture.
  8658. * @returns The texture
  8659. */
  8660. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8661. /** @hidden */
  8662. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8663. }
  8664. }
  8665. declare module BABYLON {
  8666. /**
  8667. * Defines the kind of connection point for node based material
  8668. */
  8669. export enum NodeMaterialBlockConnectionPointTypes {
  8670. /** Float */
  8671. Float = 1,
  8672. /** Int */
  8673. Int = 2,
  8674. /** Vector2 */
  8675. Vector2 = 4,
  8676. /** Vector3 */
  8677. Vector3 = 8,
  8678. /** Vector4 */
  8679. Vector4 = 16,
  8680. /** Color3 */
  8681. Color3 = 32,
  8682. /** Color4 */
  8683. Color4 = 64,
  8684. /** Matrix */
  8685. Matrix = 128,
  8686. /** Custom object */
  8687. Object = 256,
  8688. /** Detect type based on connection */
  8689. AutoDetect = 1024,
  8690. /** Output type that will be defined by input type */
  8691. BasedOnInput = 2048
  8692. }
  8693. }
  8694. declare module BABYLON {
  8695. /**
  8696. * Enum used to define the target of a block
  8697. */
  8698. export enum NodeMaterialBlockTargets {
  8699. /** Vertex shader */
  8700. Vertex = 1,
  8701. /** Fragment shader */
  8702. Fragment = 2,
  8703. /** Neutral */
  8704. Neutral = 4,
  8705. /** Vertex and Fragment */
  8706. VertexAndFragment = 3
  8707. }
  8708. }
  8709. declare module BABYLON {
  8710. /**
  8711. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8712. */
  8713. export enum NodeMaterialBlockConnectionPointMode {
  8714. /** Value is an uniform */
  8715. Uniform = 0,
  8716. /** Value is a mesh attribute */
  8717. Attribute = 1,
  8718. /** Value is a varying between vertex and fragment shaders */
  8719. Varying = 2,
  8720. /** Mode is undefined */
  8721. Undefined = 3
  8722. }
  8723. }
  8724. declare module BABYLON {
  8725. /**
  8726. * Enum used to define system values e.g. values automatically provided by the system
  8727. */
  8728. export enum NodeMaterialSystemValues {
  8729. /** World */
  8730. World = 1,
  8731. /** View */
  8732. View = 2,
  8733. /** Projection */
  8734. Projection = 3,
  8735. /** ViewProjection */
  8736. ViewProjection = 4,
  8737. /** WorldView */
  8738. WorldView = 5,
  8739. /** WorldViewProjection */
  8740. WorldViewProjection = 6,
  8741. /** CameraPosition */
  8742. CameraPosition = 7,
  8743. /** Fog Color */
  8744. FogColor = 8,
  8745. /** Delta time */
  8746. DeltaTime = 9
  8747. }
  8748. }
  8749. declare module BABYLON {
  8750. /** Defines supported spaces */
  8751. export enum Space {
  8752. /** Local (object) space */
  8753. LOCAL = 0,
  8754. /** World space */
  8755. WORLD = 1,
  8756. /** Bone space */
  8757. BONE = 2
  8758. }
  8759. /** Defines the 3 main axes */
  8760. export class Axis {
  8761. /** X axis */
  8762. static X: Vector3;
  8763. /** Y axis */
  8764. static Y: Vector3;
  8765. /** Z axis */
  8766. static Z: Vector3;
  8767. }
  8768. }
  8769. declare module BABYLON {
  8770. /**
  8771. * Represents a camera frustum
  8772. */
  8773. export class Frustum {
  8774. /**
  8775. * Gets the planes representing the frustum
  8776. * @param transform matrix to be applied to the returned planes
  8777. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8778. */
  8779. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8780. /**
  8781. * Gets the near frustum plane transformed by the transform matrix
  8782. * @param transform transformation matrix to be applied to the resulting frustum plane
  8783. * @param frustumPlane the resuling frustum plane
  8784. */
  8785. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8786. /**
  8787. * Gets the far frustum plane transformed by the transform matrix
  8788. * @param transform transformation matrix to be applied to the resulting frustum plane
  8789. * @param frustumPlane the resuling frustum plane
  8790. */
  8791. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8792. /**
  8793. * Gets the left frustum plane transformed by the transform matrix
  8794. * @param transform transformation matrix to be applied to the resulting frustum plane
  8795. * @param frustumPlane the resuling frustum plane
  8796. */
  8797. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8798. /**
  8799. * Gets the right frustum plane transformed by the transform matrix
  8800. * @param transform transformation matrix to be applied to the resulting frustum plane
  8801. * @param frustumPlane the resuling frustum plane
  8802. */
  8803. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8804. /**
  8805. * Gets the top frustum plane transformed by the transform matrix
  8806. * @param transform transformation matrix to be applied to the resulting frustum plane
  8807. * @param frustumPlane the resuling frustum plane
  8808. */
  8809. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8810. /**
  8811. * Gets the bottom frustum plane transformed by the transform matrix
  8812. * @param transform transformation matrix to be applied to the resulting frustum plane
  8813. * @param frustumPlane the resuling frustum plane
  8814. */
  8815. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8816. /**
  8817. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8818. * @param transform transformation matrix to be applied to the resulting frustum planes
  8819. * @param frustumPlanes the resuling frustum planes
  8820. */
  8821. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8822. }
  8823. }
  8824. declare module BABYLON {
  8825. /**
  8826. * Interface for the size containing width and height
  8827. */
  8828. export interface ISize {
  8829. /**
  8830. * Width
  8831. */
  8832. width: number;
  8833. /**
  8834. * Heighht
  8835. */
  8836. height: number;
  8837. }
  8838. /**
  8839. * Size containing widht and height
  8840. */
  8841. export class Size implements ISize {
  8842. /**
  8843. * Width
  8844. */
  8845. width: number;
  8846. /**
  8847. * Height
  8848. */
  8849. height: number;
  8850. /**
  8851. * Creates a Size object from the given width and height (floats).
  8852. * @param width width of the new size
  8853. * @param height height of the new size
  8854. */
  8855. constructor(width: number, height: number);
  8856. /**
  8857. * Returns a string with the Size width and height
  8858. * @returns a string with the Size width and height
  8859. */
  8860. toString(): string;
  8861. /**
  8862. * "Size"
  8863. * @returns the string "Size"
  8864. */
  8865. getClassName(): string;
  8866. /**
  8867. * Returns the Size hash code.
  8868. * @returns a hash code for a unique width and height
  8869. */
  8870. getHashCode(): number;
  8871. /**
  8872. * Updates the current size from the given one.
  8873. * @param src the given size
  8874. */
  8875. copyFrom(src: Size): void;
  8876. /**
  8877. * Updates in place the current Size from the given floats.
  8878. * @param width width of the new size
  8879. * @param height height of the new size
  8880. * @returns the updated Size.
  8881. */
  8882. copyFromFloats(width: number, height: number): Size;
  8883. /**
  8884. * Updates in place the current Size from the given floats.
  8885. * @param width width to set
  8886. * @param height height to set
  8887. * @returns the updated Size.
  8888. */
  8889. set(width: number, height: number): Size;
  8890. /**
  8891. * Multiplies the width and height by numbers
  8892. * @param w factor to multiple the width by
  8893. * @param h factor to multiple the height by
  8894. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8895. */
  8896. multiplyByFloats(w: number, h: number): Size;
  8897. /**
  8898. * Clones the size
  8899. * @returns a new Size copied from the given one.
  8900. */
  8901. clone(): Size;
  8902. /**
  8903. * True if the current Size and the given one width and height are strictly equal.
  8904. * @param other the other size to compare against
  8905. * @returns True if the current Size and the given one width and height are strictly equal.
  8906. */
  8907. equals(other: Size): boolean;
  8908. /**
  8909. * The surface of the Size : width * height (float).
  8910. */
  8911. get surface(): number;
  8912. /**
  8913. * Create a new size of zero
  8914. * @returns a new Size set to (0.0, 0.0)
  8915. */
  8916. static Zero(): Size;
  8917. /**
  8918. * Sums the width and height of two sizes
  8919. * @param otherSize size to add to this size
  8920. * @returns a new Size set as the addition result of the current Size and the given one.
  8921. */
  8922. add(otherSize: Size): Size;
  8923. /**
  8924. * Subtracts the width and height of two
  8925. * @param otherSize size to subtract to this size
  8926. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8927. */
  8928. subtract(otherSize: Size): Size;
  8929. /**
  8930. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8931. * @param start starting size to lerp between
  8932. * @param end end size to lerp between
  8933. * @param amount amount to lerp between the start and end values
  8934. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8935. */
  8936. static Lerp(start: Size, end: Size, amount: number): Size;
  8937. }
  8938. }
  8939. declare module BABYLON {
  8940. /**
  8941. * Contains position and normal vectors for a vertex
  8942. */
  8943. export class PositionNormalVertex {
  8944. /** the position of the vertex (defaut: 0,0,0) */
  8945. position: Vector3;
  8946. /** the normal of the vertex (defaut: 0,1,0) */
  8947. normal: Vector3;
  8948. /**
  8949. * Creates a PositionNormalVertex
  8950. * @param position the position of the vertex (defaut: 0,0,0)
  8951. * @param normal the normal of the vertex (defaut: 0,1,0)
  8952. */
  8953. constructor(
  8954. /** the position of the vertex (defaut: 0,0,0) */
  8955. position?: Vector3,
  8956. /** the normal of the vertex (defaut: 0,1,0) */
  8957. normal?: Vector3);
  8958. /**
  8959. * Clones the PositionNormalVertex
  8960. * @returns the cloned PositionNormalVertex
  8961. */
  8962. clone(): PositionNormalVertex;
  8963. }
  8964. /**
  8965. * Contains position, normal and uv vectors for a vertex
  8966. */
  8967. export class PositionNormalTextureVertex {
  8968. /** the position of the vertex (defaut: 0,0,0) */
  8969. position: Vector3;
  8970. /** the normal of the vertex (defaut: 0,1,0) */
  8971. normal: Vector3;
  8972. /** the uv of the vertex (default: 0,0) */
  8973. uv: Vector2;
  8974. /**
  8975. * Creates a PositionNormalTextureVertex
  8976. * @param position the position of the vertex (defaut: 0,0,0)
  8977. * @param normal the normal of the vertex (defaut: 0,1,0)
  8978. * @param uv the uv of the vertex (default: 0,0)
  8979. */
  8980. constructor(
  8981. /** the position of the vertex (defaut: 0,0,0) */
  8982. position?: Vector3,
  8983. /** the normal of the vertex (defaut: 0,1,0) */
  8984. normal?: Vector3,
  8985. /** the uv of the vertex (default: 0,0) */
  8986. uv?: Vector2);
  8987. /**
  8988. * Clones the PositionNormalTextureVertex
  8989. * @returns the cloned PositionNormalTextureVertex
  8990. */
  8991. clone(): PositionNormalTextureVertex;
  8992. }
  8993. }
  8994. declare module BABYLON {
  8995. /**
  8996. * Enum defining the type of animations supported by InputBlock
  8997. */
  8998. export enum AnimatedInputBlockTypes {
  8999. /** No animation */
  9000. None = 0,
  9001. /** Time based animation. Will only work for floats */
  9002. Time = 1
  9003. }
  9004. }
  9005. declare module BABYLON {
  9006. /**
  9007. * Interface describing all the common properties and methods a shadow light needs to implement.
  9008. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9009. * as well as binding the different shadow properties to the effects.
  9010. */
  9011. export interface IShadowLight extends Light {
  9012. /**
  9013. * The light id in the scene (used in scene.findLighById for instance)
  9014. */
  9015. id: string;
  9016. /**
  9017. * The position the shdow will be casted from.
  9018. */
  9019. position: Vector3;
  9020. /**
  9021. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9022. */
  9023. direction: Vector3;
  9024. /**
  9025. * The transformed position. Position of the light in world space taking parenting in account.
  9026. */
  9027. transformedPosition: Vector3;
  9028. /**
  9029. * The transformed direction. Direction of the light in world space taking parenting in account.
  9030. */
  9031. transformedDirection: Vector3;
  9032. /**
  9033. * The friendly name of the light in the scene.
  9034. */
  9035. name: string;
  9036. /**
  9037. * Defines the shadow projection clipping minimum z value.
  9038. */
  9039. shadowMinZ: number;
  9040. /**
  9041. * Defines the shadow projection clipping maximum z value.
  9042. */
  9043. shadowMaxZ: number;
  9044. /**
  9045. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9046. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9047. */
  9048. computeTransformedInformation(): boolean;
  9049. /**
  9050. * Gets the scene the light belongs to.
  9051. * @returns The scene
  9052. */
  9053. getScene(): Scene;
  9054. /**
  9055. * Callback defining a custom Projection Matrix Builder.
  9056. * This can be used to override the default projection matrix computation.
  9057. */
  9058. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9059. /**
  9060. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9061. * @param matrix The materix to updated with the projection information
  9062. * @param viewMatrix The transform matrix of the light
  9063. * @param renderList The list of mesh to render in the map
  9064. * @returns The current light
  9065. */
  9066. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9067. /**
  9068. * Gets the current depth scale used in ESM.
  9069. * @returns The scale
  9070. */
  9071. getDepthScale(): number;
  9072. /**
  9073. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9074. * @returns true if a cube texture needs to be use
  9075. */
  9076. needCube(): boolean;
  9077. /**
  9078. * Detects if the projection matrix requires to be recomputed this frame.
  9079. * @returns true if it requires to be recomputed otherwise, false.
  9080. */
  9081. needProjectionMatrixCompute(): boolean;
  9082. /**
  9083. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9084. */
  9085. forceProjectionMatrixCompute(): void;
  9086. /**
  9087. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9088. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9089. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9090. */
  9091. getShadowDirection(faceIndex?: number): Vector3;
  9092. /**
  9093. * Gets the minZ used for shadow according to both the scene and the light.
  9094. * @param activeCamera The camera we are returning the min for
  9095. * @returns the depth min z
  9096. */
  9097. getDepthMinZ(activeCamera: Camera): number;
  9098. /**
  9099. * Gets the maxZ used for shadow according to both the scene and the light.
  9100. * @param activeCamera The camera we are returning the max for
  9101. * @returns the depth max z
  9102. */
  9103. getDepthMaxZ(activeCamera: Camera): number;
  9104. }
  9105. /**
  9106. * Base implementation IShadowLight
  9107. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9108. */
  9109. export abstract class ShadowLight extends Light implements IShadowLight {
  9110. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9111. protected _position: Vector3;
  9112. protected _setPosition(value: Vector3): void;
  9113. /**
  9114. * Sets the position the shadow will be casted from. Also use as the light position for both
  9115. * point and spot lights.
  9116. */
  9117. get position(): Vector3;
  9118. /**
  9119. * Sets the position the shadow will be casted from. Also use as the light position for both
  9120. * point and spot lights.
  9121. */
  9122. set position(value: Vector3);
  9123. protected _direction: Vector3;
  9124. protected _setDirection(value: Vector3): void;
  9125. /**
  9126. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9127. * Also use as the light direction on spot and directional lights.
  9128. */
  9129. get direction(): Vector3;
  9130. /**
  9131. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9132. * Also use as the light direction on spot and directional lights.
  9133. */
  9134. set direction(value: Vector3);
  9135. protected _shadowMinZ: number;
  9136. /**
  9137. * Gets the shadow projection clipping minimum z value.
  9138. */
  9139. get shadowMinZ(): number;
  9140. /**
  9141. * Sets the shadow projection clipping minimum z value.
  9142. */
  9143. set shadowMinZ(value: number);
  9144. protected _shadowMaxZ: number;
  9145. /**
  9146. * Sets the shadow projection clipping maximum z value.
  9147. */
  9148. get shadowMaxZ(): number;
  9149. /**
  9150. * Gets the shadow projection clipping maximum z value.
  9151. */
  9152. set shadowMaxZ(value: number);
  9153. /**
  9154. * Callback defining a custom Projection Matrix Builder.
  9155. * This can be used to override the default projection matrix computation.
  9156. */
  9157. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9158. /**
  9159. * The transformed position. Position of the light in world space taking parenting in account.
  9160. */
  9161. transformedPosition: Vector3;
  9162. /**
  9163. * The transformed direction. Direction of the light in world space taking parenting in account.
  9164. */
  9165. transformedDirection: Vector3;
  9166. private _needProjectionMatrixCompute;
  9167. /**
  9168. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9169. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9170. */
  9171. computeTransformedInformation(): boolean;
  9172. /**
  9173. * Return the depth scale used for the shadow map.
  9174. * @returns the depth scale.
  9175. */
  9176. getDepthScale(): number;
  9177. /**
  9178. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9179. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9180. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9181. */
  9182. getShadowDirection(faceIndex?: number): Vector3;
  9183. /**
  9184. * Returns the ShadowLight absolute position in the World.
  9185. * @returns the position vector in world space
  9186. */
  9187. getAbsolutePosition(): Vector3;
  9188. /**
  9189. * Sets the ShadowLight direction toward the passed target.
  9190. * @param target The point to target in local space
  9191. * @returns the updated ShadowLight direction
  9192. */
  9193. setDirectionToTarget(target: Vector3): Vector3;
  9194. /**
  9195. * Returns the light rotation in euler definition.
  9196. * @returns the x y z rotation in local space.
  9197. */
  9198. getRotation(): Vector3;
  9199. /**
  9200. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9201. * @returns true if a cube texture needs to be use
  9202. */
  9203. needCube(): boolean;
  9204. /**
  9205. * Detects if the projection matrix requires to be recomputed this frame.
  9206. * @returns true if it requires to be recomputed otherwise, false.
  9207. */
  9208. needProjectionMatrixCompute(): boolean;
  9209. /**
  9210. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9211. */
  9212. forceProjectionMatrixCompute(): void;
  9213. /** @hidden */
  9214. _initCache(): void;
  9215. /** @hidden */
  9216. _isSynchronized(): boolean;
  9217. /**
  9218. * Computes the world matrix of the node
  9219. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9220. * @returns the world matrix
  9221. */
  9222. computeWorldMatrix(force?: boolean): Matrix;
  9223. /**
  9224. * Gets the minZ used for shadow according to both the scene and the light.
  9225. * @param activeCamera The camera we are returning the min for
  9226. * @returns the depth min z
  9227. */
  9228. getDepthMinZ(activeCamera: Camera): number;
  9229. /**
  9230. * Gets the maxZ used for shadow according to both the scene and the light.
  9231. * @param activeCamera The camera we are returning the max for
  9232. * @returns the depth max z
  9233. */
  9234. getDepthMaxZ(activeCamera: Camera): number;
  9235. /**
  9236. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9237. * @param matrix The materix to updated with the projection information
  9238. * @param viewMatrix The transform matrix of the light
  9239. * @param renderList The list of mesh to render in the map
  9240. * @returns The current light
  9241. */
  9242. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9243. }
  9244. }
  9245. declare module BABYLON {
  9246. /** @hidden */
  9247. export var packingFunctions: {
  9248. name: string;
  9249. shader: string;
  9250. };
  9251. }
  9252. declare module BABYLON {
  9253. /** @hidden */
  9254. export var bayerDitherFunctions: {
  9255. name: string;
  9256. shader: string;
  9257. };
  9258. }
  9259. declare module BABYLON {
  9260. /** @hidden */
  9261. export var shadowMapFragmentDeclaration: {
  9262. name: string;
  9263. shader: string;
  9264. };
  9265. }
  9266. declare module BABYLON {
  9267. /** @hidden */
  9268. export var clipPlaneFragmentDeclaration: {
  9269. name: string;
  9270. shader: string;
  9271. };
  9272. }
  9273. declare module BABYLON {
  9274. /** @hidden */
  9275. export var clipPlaneFragment: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module BABYLON {
  9281. /** @hidden */
  9282. export var shadowMapFragment: {
  9283. name: string;
  9284. shader: string;
  9285. };
  9286. }
  9287. declare module BABYLON {
  9288. /** @hidden */
  9289. export var shadowMapPixelShader: {
  9290. name: string;
  9291. shader: string;
  9292. };
  9293. }
  9294. declare module BABYLON {
  9295. /** @hidden */
  9296. export var bonesDeclaration: {
  9297. name: string;
  9298. shader: string;
  9299. };
  9300. }
  9301. declare module BABYLON {
  9302. /** @hidden */
  9303. export var morphTargetsVertexGlobalDeclaration: {
  9304. name: string;
  9305. shader: string;
  9306. };
  9307. }
  9308. declare module BABYLON {
  9309. /** @hidden */
  9310. export var morphTargetsVertexDeclaration: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module BABYLON {
  9316. /** @hidden */
  9317. export var instancesDeclaration: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module BABYLON {
  9323. /** @hidden */
  9324. export var helperFunctions: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module BABYLON {
  9330. /** @hidden */
  9331. export var shadowMapVertexDeclaration: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module BABYLON {
  9337. /** @hidden */
  9338. export var clipPlaneVertexDeclaration: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module BABYLON {
  9344. /** @hidden */
  9345. export var morphTargetsVertex: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module BABYLON {
  9351. /** @hidden */
  9352. export var instancesVertex: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module BABYLON {
  9358. /** @hidden */
  9359. export var bonesVertex: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module BABYLON {
  9365. /** @hidden */
  9366. export var shadowMapVertexNormalBias: {
  9367. name: string;
  9368. shader: string;
  9369. };
  9370. }
  9371. declare module BABYLON {
  9372. /** @hidden */
  9373. export var shadowMapVertexMetric: {
  9374. name: string;
  9375. shader: string;
  9376. };
  9377. }
  9378. declare module BABYLON {
  9379. /** @hidden */
  9380. export var clipPlaneVertex: {
  9381. name: string;
  9382. shader: string;
  9383. };
  9384. }
  9385. declare module BABYLON {
  9386. /** @hidden */
  9387. export var shadowMapVertexShader: {
  9388. name: string;
  9389. shader: string;
  9390. };
  9391. }
  9392. declare module BABYLON {
  9393. /** @hidden */
  9394. export var depthBoxBlurPixelShader: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module BABYLON {
  9400. /** @hidden */
  9401. export var shadowMapFragmentSoftTransparentShadow: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module BABYLON {
  9407. /**
  9408. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9409. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9410. */
  9411. export class EffectFallbacks implements IEffectFallbacks {
  9412. private _defines;
  9413. private _currentRank;
  9414. private _maxRank;
  9415. private _mesh;
  9416. /**
  9417. * Removes the fallback from the bound mesh.
  9418. */
  9419. unBindMesh(): void;
  9420. /**
  9421. * Adds a fallback on the specified property.
  9422. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9423. * @param define The name of the define in the shader
  9424. */
  9425. addFallback(rank: number, define: string): void;
  9426. /**
  9427. * Sets the mesh to use CPU skinning when needing to fallback.
  9428. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9429. * @param mesh The mesh to use the fallbacks.
  9430. */
  9431. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9432. /**
  9433. * Checks to see if more fallbacks are still availible.
  9434. */
  9435. get hasMoreFallbacks(): boolean;
  9436. /**
  9437. * Removes the defines that should be removed when falling back.
  9438. * @param currentDefines defines the current define statements for the shader.
  9439. * @param effect defines the current effect we try to compile
  9440. * @returns The resulting defines with defines of the current rank removed.
  9441. */
  9442. reduce(currentDefines: string, effect: Effect): string;
  9443. }
  9444. }
  9445. declare module BABYLON {
  9446. /**
  9447. * Interface used to define Action
  9448. */
  9449. export interface IAction {
  9450. /**
  9451. * Trigger for the action
  9452. */
  9453. trigger: number;
  9454. /** Options of the trigger */
  9455. triggerOptions: any;
  9456. /**
  9457. * Gets the trigger parameters
  9458. * @returns the trigger parameters
  9459. */
  9460. getTriggerParameter(): any;
  9461. /**
  9462. * Internal only - executes current action event
  9463. * @hidden
  9464. */
  9465. _executeCurrent(evt?: ActionEvent): void;
  9466. /**
  9467. * Serialize placeholder for child classes
  9468. * @param parent of child
  9469. * @returns the serialized object
  9470. */
  9471. serialize(parent: any): any;
  9472. /**
  9473. * Internal only
  9474. * @hidden
  9475. */
  9476. _prepare(): void;
  9477. /**
  9478. * Internal only - manager for action
  9479. * @hidden
  9480. */
  9481. _actionManager: Nullable<AbstractActionManager>;
  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: IAction): IAction;
  9489. }
  9490. /**
  9491. * The action to be carried out following a trigger
  9492. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9493. */
  9494. export class Action implements IAction {
  9495. /** the trigger, with or without parameters, for the action */
  9496. triggerOptions: any;
  9497. /**
  9498. * Trigger for the action
  9499. */
  9500. trigger: number;
  9501. /**
  9502. * Internal only - manager for action
  9503. * @hidden
  9504. */
  9505. _actionManager: ActionManager;
  9506. private _nextActiveAction;
  9507. private _child;
  9508. private _condition?;
  9509. private _triggerParameter;
  9510. /**
  9511. * An event triggered prior to action being executed.
  9512. */
  9513. onBeforeExecuteObservable: Observable<Action>;
  9514. /**
  9515. * Creates a new Action
  9516. * @param triggerOptions the trigger, with or without parameters, for the action
  9517. * @param condition an optional determinant of action
  9518. */
  9519. constructor(
  9520. /** the trigger, with or without parameters, for the action */
  9521. triggerOptions: any, condition?: Condition);
  9522. /**
  9523. * Internal only
  9524. * @hidden
  9525. */
  9526. _prepare(): void;
  9527. /**
  9528. * Gets the trigger parameters
  9529. * @returns the trigger parameters
  9530. */
  9531. getTriggerParameter(): any;
  9532. /**
  9533. * Internal only - executes current action event
  9534. * @hidden
  9535. */
  9536. _executeCurrent(evt?: ActionEvent): void;
  9537. /**
  9538. * Execute placeholder for child classes
  9539. * @param evt optional action event
  9540. */
  9541. execute(evt?: ActionEvent): void;
  9542. /**
  9543. * Skips to next active action
  9544. */
  9545. skipToNextActiveAction(): void;
  9546. /**
  9547. * Adds action to chain of actions, may be a DoNothingAction
  9548. * @param action defines the next action to execute
  9549. * @returns The action passed in
  9550. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9551. */
  9552. then(action: Action): Action;
  9553. /**
  9554. * Internal only
  9555. * @hidden
  9556. */
  9557. _getProperty(propertyPath: string): string;
  9558. /**
  9559. * Internal only
  9560. * @hidden
  9561. */
  9562. _getEffectiveTarget(target: any, propertyPath: string): any;
  9563. /**
  9564. * Serialize placeholder for child classes
  9565. * @param parent of child
  9566. * @returns the serialized object
  9567. */
  9568. serialize(parent: any): any;
  9569. /**
  9570. * Internal only called by serialize
  9571. * @hidden
  9572. */
  9573. protected _serialize(serializedAction: any, parent?: any): any;
  9574. /**
  9575. * Internal only
  9576. * @hidden
  9577. */
  9578. static _SerializeValueAsString: (value: any) => string;
  9579. /**
  9580. * Internal only
  9581. * @hidden
  9582. */
  9583. static _GetTargetProperty: (target: Scene | Node) => {
  9584. name: string;
  9585. targetType: string;
  9586. value: string;
  9587. };
  9588. }
  9589. }
  9590. declare module BABYLON {
  9591. /**
  9592. * A Condition applied to an Action
  9593. */
  9594. export class Condition {
  9595. /**
  9596. * Internal only - manager for action
  9597. * @hidden
  9598. */
  9599. _actionManager: ActionManager;
  9600. /**
  9601. * Internal only
  9602. * @hidden
  9603. */
  9604. _evaluationId: number;
  9605. /**
  9606. * Internal only
  9607. * @hidden
  9608. */
  9609. _currentResult: boolean;
  9610. /**
  9611. * Creates a new Condition
  9612. * @param actionManager the manager of the action the condition is applied to
  9613. */
  9614. constructor(actionManager: ActionManager);
  9615. /**
  9616. * Check if the current condition is valid
  9617. * @returns a boolean
  9618. */
  9619. isValid(): boolean;
  9620. /**
  9621. * Internal only
  9622. * @hidden
  9623. */
  9624. _getProperty(propertyPath: string): string;
  9625. /**
  9626. * Internal only
  9627. * @hidden
  9628. */
  9629. _getEffectiveTarget(target: any, propertyPath: string): any;
  9630. /**
  9631. * Serialize placeholder for child classes
  9632. * @returns the serialized object
  9633. */
  9634. serialize(): any;
  9635. /**
  9636. * Internal only
  9637. * @hidden
  9638. */
  9639. protected _serialize(serializedCondition: any): any;
  9640. }
  9641. /**
  9642. * Defines specific conditional operators as extensions of Condition
  9643. */
  9644. export class ValueCondition extends Condition {
  9645. /** path to specify the property of the target the conditional operator uses */
  9646. propertyPath: string;
  9647. /** the value compared by the conditional operator against the current value of the property */
  9648. value: any;
  9649. /** the conditional operator, default ValueCondition.IsEqual */
  9650. operator: number;
  9651. /**
  9652. * Internal only
  9653. * @hidden
  9654. */
  9655. private static _IsEqual;
  9656. /**
  9657. * Internal only
  9658. * @hidden
  9659. */
  9660. private static _IsDifferent;
  9661. /**
  9662. * Internal only
  9663. * @hidden
  9664. */
  9665. private static _IsGreater;
  9666. /**
  9667. * Internal only
  9668. * @hidden
  9669. */
  9670. private static _IsLesser;
  9671. /**
  9672. * returns the number for IsEqual
  9673. */
  9674. static get IsEqual(): number;
  9675. /**
  9676. * Returns the number for IsDifferent
  9677. */
  9678. static get IsDifferent(): number;
  9679. /**
  9680. * Returns the number for IsGreater
  9681. */
  9682. static get IsGreater(): number;
  9683. /**
  9684. * Returns the number for IsLesser
  9685. */
  9686. static get IsLesser(): number;
  9687. /**
  9688. * Internal only The action manager for the condition
  9689. * @hidden
  9690. */
  9691. _actionManager: ActionManager;
  9692. /**
  9693. * Internal only
  9694. * @hidden
  9695. */
  9696. private _target;
  9697. /**
  9698. * Internal only
  9699. * @hidden
  9700. */
  9701. private _effectiveTarget;
  9702. /**
  9703. * Internal only
  9704. * @hidden
  9705. */
  9706. private _property;
  9707. /**
  9708. * Creates a new ValueCondition
  9709. * @param actionManager manager for the action the condition applies to
  9710. * @param target for the action
  9711. * @param propertyPath path to specify the property of the target the conditional operator uses
  9712. * @param value the value compared by the conditional operator against the current value of the property
  9713. * @param operator the conditional operator, default ValueCondition.IsEqual
  9714. */
  9715. constructor(actionManager: ActionManager, target: any,
  9716. /** path to specify the property of the target the conditional operator uses */
  9717. propertyPath: string,
  9718. /** the value compared by the conditional operator against the current value of the property */
  9719. value: any,
  9720. /** the conditional operator, default ValueCondition.IsEqual */
  9721. operator?: number);
  9722. /**
  9723. * Compares the given value with the property value for the specified conditional operator
  9724. * @returns the result of the comparison
  9725. */
  9726. isValid(): boolean;
  9727. /**
  9728. * Serialize the ValueCondition into a JSON compatible object
  9729. * @returns serialization object
  9730. */
  9731. serialize(): any;
  9732. /**
  9733. * Gets the name of the conditional operator for the ValueCondition
  9734. * @param operator the conditional operator
  9735. * @returns the name
  9736. */
  9737. static GetOperatorName(operator: number): string;
  9738. }
  9739. /**
  9740. * Defines a predicate condition as an extension of Condition
  9741. */
  9742. export class PredicateCondition extends Condition {
  9743. /** defines the predicate function used to validate the condition */
  9744. predicate: () => boolean;
  9745. /**
  9746. * Internal only - manager for action
  9747. * @hidden
  9748. */
  9749. _actionManager: ActionManager;
  9750. /**
  9751. * Creates a new PredicateCondition
  9752. * @param actionManager manager for the action the condition applies to
  9753. * @param predicate defines the predicate function used to validate the condition
  9754. */
  9755. constructor(actionManager: ActionManager,
  9756. /** defines the predicate function used to validate the condition */
  9757. predicate: () => boolean);
  9758. /**
  9759. * @returns the validity of the predicate condition
  9760. */
  9761. isValid(): boolean;
  9762. }
  9763. /**
  9764. * Defines a state condition as an extension of Condition
  9765. */
  9766. export class StateCondition extends Condition {
  9767. /** Value to compare with target state */
  9768. value: string;
  9769. /**
  9770. * Internal only - manager for action
  9771. * @hidden
  9772. */
  9773. _actionManager: ActionManager;
  9774. /**
  9775. * Internal only
  9776. * @hidden
  9777. */
  9778. private _target;
  9779. /**
  9780. * Creates a new StateCondition
  9781. * @param actionManager manager for the action the condition applies to
  9782. * @param target of the condition
  9783. * @param value to compare with target state
  9784. */
  9785. constructor(actionManager: ActionManager, target: any,
  9786. /** Value to compare with target state */
  9787. value: string);
  9788. /**
  9789. * Gets a boolean indicating if the current condition is met
  9790. * @returns the validity of the state
  9791. */
  9792. isValid(): boolean;
  9793. /**
  9794. * Serialize the StateCondition into a JSON compatible object
  9795. * @returns serialization object
  9796. */
  9797. serialize(): any;
  9798. }
  9799. }
  9800. declare module BABYLON {
  9801. /**
  9802. * This defines an action responsible to toggle a boolean once triggered.
  9803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9804. */
  9805. export class SwitchBooleanAction extends Action {
  9806. /**
  9807. * The path to the boolean property in the target object
  9808. */
  9809. propertyPath: string;
  9810. private _target;
  9811. private _effectiveTarget;
  9812. private _property;
  9813. /**
  9814. * Instantiate the action
  9815. * @param triggerOptions defines the trigger options
  9816. * @param target defines the object containing the boolean
  9817. * @param propertyPath defines the path to the boolean property in the target object
  9818. * @param condition defines the trigger related conditions
  9819. */
  9820. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9821. /** @hidden */
  9822. _prepare(): void;
  9823. /**
  9824. * Execute the action toggle the boolean value.
  9825. */
  9826. execute(): void;
  9827. /**
  9828. * Serializes the actions and its related information.
  9829. * @param parent defines the object to serialize in
  9830. * @returns the serialized object
  9831. */
  9832. serialize(parent: any): any;
  9833. }
  9834. /**
  9835. * This defines an action responsible to set a the state field of the target
  9836. * to a desired value once triggered.
  9837. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9838. */
  9839. export class SetStateAction extends Action {
  9840. /**
  9841. * The value to store in the state field.
  9842. */
  9843. value: string;
  9844. private _target;
  9845. /**
  9846. * Instantiate the action
  9847. * @param triggerOptions defines the trigger options
  9848. * @param target defines the object containing the state property
  9849. * @param value defines the value to store in the state field
  9850. * @param condition defines the trigger related conditions
  9851. */
  9852. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9853. /**
  9854. * Execute the action and store the value on the target state property.
  9855. */
  9856. execute(): void;
  9857. /**
  9858. * Serializes the actions and its related information.
  9859. * @param parent defines the object to serialize in
  9860. * @returns the serialized object
  9861. */
  9862. serialize(parent: any): any;
  9863. }
  9864. /**
  9865. * This defines an action responsible to set a property of the target
  9866. * to a desired value once triggered.
  9867. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9868. */
  9869. export class SetValueAction extends Action {
  9870. /**
  9871. * The path of the property to set in the target.
  9872. */
  9873. propertyPath: string;
  9874. /**
  9875. * The value to set in the property
  9876. */
  9877. value: any;
  9878. private _target;
  9879. private _effectiveTarget;
  9880. private _property;
  9881. /**
  9882. * Instantiate the action
  9883. * @param triggerOptions defines the trigger options
  9884. * @param target defines the object containing the property
  9885. * @param propertyPath defines the path of the property to set in the target
  9886. * @param value defines the value to set in the property
  9887. * @param condition defines the trigger related conditions
  9888. */
  9889. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9890. /** @hidden */
  9891. _prepare(): void;
  9892. /**
  9893. * Execute the action and set the targetted property to the desired value.
  9894. */
  9895. execute(): void;
  9896. /**
  9897. * Serializes the actions and its related information.
  9898. * @param parent defines the object to serialize in
  9899. * @returns the serialized object
  9900. */
  9901. serialize(parent: any): any;
  9902. }
  9903. /**
  9904. * This defines an action responsible to increment the target value
  9905. * to a desired value once triggered.
  9906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9907. */
  9908. export class IncrementValueAction extends Action {
  9909. /**
  9910. * The path of the property to increment in the target.
  9911. */
  9912. propertyPath: string;
  9913. /**
  9914. * The value we should increment the property by.
  9915. */
  9916. value: any;
  9917. private _target;
  9918. private _effectiveTarget;
  9919. private _property;
  9920. /**
  9921. * Instantiate the action
  9922. * @param triggerOptions defines the trigger options
  9923. * @param target defines the object containing the property
  9924. * @param propertyPath defines the path of the property to increment in the target
  9925. * @param value defines the value value we should increment the property by
  9926. * @param condition defines the trigger related conditions
  9927. */
  9928. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9929. /** @hidden */
  9930. _prepare(): void;
  9931. /**
  9932. * Execute the action and increment the target of the value amount.
  9933. */
  9934. execute(): void;
  9935. /**
  9936. * Serializes the actions and its related information.
  9937. * @param parent defines the object to serialize in
  9938. * @returns the serialized object
  9939. */
  9940. serialize(parent: any): any;
  9941. }
  9942. /**
  9943. * This defines an action responsible to start an animation once triggered.
  9944. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9945. */
  9946. export class PlayAnimationAction extends Action {
  9947. /**
  9948. * Where the animation should start (animation frame)
  9949. */
  9950. from: number;
  9951. /**
  9952. * Where the animation should stop (animation frame)
  9953. */
  9954. to: number;
  9955. /**
  9956. * Define if the animation should loop or stop after the first play.
  9957. */
  9958. loop?: boolean;
  9959. private _target;
  9960. /**
  9961. * Instantiate the action
  9962. * @param triggerOptions defines the trigger options
  9963. * @param target defines the target animation or animation name
  9964. * @param from defines from where the animation should start (animation frame)
  9965. * @param end defines where the animation should stop (animation frame)
  9966. * @param loop defines if the animation should loop or stop after the first play
  9967. * @param condition defines the trigger related conditions
  9968. */
  9969. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9970. /** @hidden */
  9971. _prepare(): void;
  9972. /**
  9973. * Execute the action and play the animation.
  9974. */
  9975. execute(): void;
  9976. /**
  9977. * Serializes the actions and its related information.
  9978. * @param parent defines the object to serialize in
  9979. * @returns the serialized object
  9980. */
  9981. serialize(parent: any): any;
  9982. }
  9983. /**
  9984. * This defines an action responsible to stop an animation once triggered.
  9985. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9986. */
  9987. export class StopAnimationAction extends Action {
  9988. private _target;
  9989. /**
  9990. * Instantiate the action
  9991. * @param triggerOptions defines the trigger options
  9992. * @param target defines the target animation or animation name
  9993. * @param condition defines the trigger related conditions
  9994. */
  9995. constructor(triggerOptions: any, target: any, condition?: Condition);
  9996. /** @hidden */
  9997. _prepare(): void;
  9998. /**
  9999. * Execute the action and stop the animation.
  10000. */
  10001. execute(): void;
  10002. /**
  10003. * Serializes the actions and its related information.
  10004. * @param parent defines the object to serialize in
  10005. * @returns the serialized object
  10006. */
  10007. serialize(parent: any): any;
  10008. }
  10009. /**
  10010. * This defines an action responsible that does nothing once triggered.
  10011. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10012. */
  10013. export class DoNothingAction extends Action {
  10014. /**
  10015. * Instantiate the action
  10016. * @param triggerOptions defines the trigger options
  10017. * @param condition defines the trigger related conditions
  10018. */
  10019. constructor(triggerOptions?: any, condition?: Condition);
  10020. /**
  10021. * Execute the action and do nothing.
  10022. */
  10023. execute(): void;
  10024. /**
  10025. * Serializes the actions and its related information.
  10026. * @param parent defines the object to serialize in
  10027. * @returns the serialized object
  10028. */
  10029. serialize(parent: any): any;
  10030. }
  10031. /**
  10032. * This defines an action responsible to trigger several actions once triggered.
  10033. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10034. */
  10035. export class CombineAction extends Action {
  10036. /**
  10037. * The list of aggregated animations to run.
  10038. */
  10039. children: Action[];
  10040. /**
  10041. * Instantiate the action
  10042. * @param triggerOptions defines the trigger options
  10043. * @param children defines the list of aggregated animations to run
  10044. * @param condition defines the trigger related conditions
  10045. */
  10046. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10047. /** @hidden */
  10048. _prepare(): void;
  10049. /**
  10050. * Execute the action and executes all the aggregated actions.
  10051. */
  10052. execute(evt: ActionEvent): void;
  10053. /**
  10054. * Serializes the actions and its related information.
  10055. * @param parent defines the object to serialize in
  10056. * @returns the serialized object
  10057. */
  10058. serialize(parent: any): any;
  10059. }
  10060. /**
  10061. * This defines an action responsible to run code (external event) once triggered.
  10062. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10063. */
  10064. export class ExecuteCodeAction extends Action {
  10065. /**
  10066. * The callback function to run.
  10067. */
  10068. func: (evt: ActionEvent) => void;
  10069. /**
  10070. * Instantiate the action
  10071. * @param triggerOptions defines the trigger options
  10072. * @param func defines the callback function to run
  10073. * @param condition defines the trigger related conditions
  10074. */
  10075. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10076. /**
  10077. * Execute the action and run the attached code.
  10078. */
  10079. execute(evt: ActionEvent): void;
  10080. }
  10081. /**
  10082. * This defines an action responsible to set the parent property of the target once triggered.
  10083. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10084. */
  10085. export class SetParentAction extends Action {
  10086. private _parent;
  10087. private _target;
  10088. /**
  10089. * Instantiate the action
  10090. * @param triggerOptions defines the trigger options
  10091. * @param target defines the target containing the parent property
  10092. * @param parent defines from where the animation should start (animation frame)
  10093. * @param condition defines the trigger related conditions
  10094. */
  10095. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10096. /** @hidden */
  10097. _prepare(): void;
  10098. /**
  10099. * Execute the action and set the parent property.
  10100. */
  10101. execute(): void;
  10102. /**
  10103. * Serializes the actions and its related information.
  10104. * @param parent defines the object to serialize in
  10105. * @returns the serialized object
  10106. */
  10107. serialize(parent: any): any;
  10108. }
  10109. }
  10110. declare module BABYLON {
  10111. /**
  10112. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10113. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10114. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10115. */
  10116. export class ActionManager extends AbstractActionManager {
  10117. /**
  10118. * Nothing
  10119. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10120. */
  10121. static readonly NothingTrigger: number;
  10122. /**
  10123. * On pick
  10124. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10125. */
  10126. static readonly OnPickTrigger: number;
  10127. /**
  10128. * On left pick
  10129. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10130. */
  10131. static readonly OnLeftPickTrigger: number;
  10132. /**
  10133. * On right pick
  10134. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10135. */
  10136. static readonly OnRightPickTrigger: number;
  10137. /**
  10138. * On center pick
  10139. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10140. */
  10141. static readonly OnCenterPickTrigger: number;
  10142. /**
  10143. * On pick down
  10144. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10145. */
  10146. static readonly OnPickDownTrigger: number;
  10147. /**
  10148. * On double pick
  10149. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10150. */
  10151. static readonly OnDoublePickTrigger: number;
  10152. /**
  10153. * On pick up
  10154. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10155. */
  10156. static readonly OnPickUpTrigger: number;
  10157. /**
  10158. * On pick out.
  10159. * This trigger will only be raised if you also declared a OnPickDown
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnPickOutTrigger: number;
  10163. /**
  10164. * On long press
  10165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10166. */
  10167. static readonly OnLongPressTrigger: number;
  10168. /**
  10169. * On pointer over
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10171. */
  10172. static readonly OnPointerOverTrigger: number;
  10173. /**
  10174. * On pointer out
  10175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10176. */
  10177. static readonly OnPointerOutTrigger: number;
  10178. /**
  10179. * On every frame
  10180. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10181. */
  10182. static readonly OnEveryFrameTrigger: number;
  10183. /**
  10184. * On intersection enter
  10185. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10186. */
  10187. static readonly OnIntersectionEnterTrigger: number;
  10188. /**
  10189. * On intersection exit
  10190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10191. */
  10192. static readonly OnIntersectionExitTrigger: number;
  10193. /**
  10194. * On key down
  10195. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10196. */
  10197. static readonly OnKeyDownTrigger: number;
  10198. /**
  10199. * On key up
  10200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10201. */
  10202. static readonly OnKeyUpTrigger: number;
  10203. private _scene;
  10204. /**
  10205. * Creates a new action manager
  10206. * @param scene defines the hosting scene
  10207. */
  10208. constructor(scene: Scene);
  10209. /**
  10210. * Releases all associated resources
  10211. */
  10212. dispose(): void;
  10213. /**
  10214. * Gets hosting scene
  10215. * @returns the hosting scene
  10216. */
  10217. getScene(): Scene;
  10218. /**
  10219. * Does this action manager handles actions of any of the given triggers
  10220. * @param triggers defines the triggers to be tested
  10221. * @return a boolean indicating whether one (or more) of the triggers is handled
  10222. */
  10223. hasSpecificTriggers(triggers: number[]): boolean;
  10224. /**
  10225. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10226. * speed.
  10227. * @param triggerA defines the trigger to be tested
  10228. * @param triggerB defines the trigger to be tested
  10229. * @return a boolean indicating whether one (or more) of the triggers is handled
  10230. */
  10231. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10232. /**
  10233. * Does this action manager handles actions of a given trigger
  10234. * @param trigger defines the trigger to be tested
  10235. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10236. * @return whether the trigger is handled
  10237. */
  10238. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10239. /**
  10240. * Does this action manager has pointer triggers
  10241. */
  10242. get hasPointerTriggers(): boolean;
  10243. /**
  10244. * Does this action manager has pick triggers
  10245. */
  10246. get hasPickTriggers(): boolean;
  10247. /**
  10248. * Registers an action to this action manager
  10249. * @param action defines the action to be registered
  10250. * @return the action amended (prepared) after registration
  10251. */
  10252. registerAction(action: IAction): Nullable<IAction>;
  10253. /**
  10254. * Unregisters an action to this action manager
  10255. * @param action defines the action to be unregistered
  10256. * @return a boolean indicating whether the action has been unregistered
  10257. */
  10258. unregisterAction(action: IAction): Boolean;
  10259. /**
  10260. * Process a specific trigger
  10261. * @param trigger defines the trigger to process
  10262. * @param evt defines the event details to be processed
  10263. */
  10264. processTrigger(trigger: number, evt?: IActionEvent): void;
  10265. /** @hidden */
  10266. _getEffectiveTarget(target: any, propertyPath: string): any;
  10267. /** @hidden */
  10268. _getProperty(propertyPath: string): string;
  10269. /**
  10270. * Serialize this manager to a JSON object
  10271. * @param name defines the property name to store this manager
  10272. * @returns a JSON representation of this manager
  10273. */
  10274. serialize(name: string): any;
  10275. /**
  10276. * Creates a new ActionManager from a JSON data
  10277. * @param parsedActions defines the JSON data to read from
  10278. * @param object defines the hosting mesh
  10279. * @param scene defines the hosting scene
  10280. */
  10281. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10282. /**
  10283. * Get a trigger name by index
  10284. * @param trigger defines the trigger index
  10285. * @returns a trigger name
  10286. */
  10287. static GetTriggerName(trigger: number): string;
  10288. }
  10289. }
  10290. declare module BABYLON {
  10291. /**
  10292. * Class used to represent a sprite
  10293. * @see https://doc.babylonjs.com/babylon101/sprites
  10294. */
  10295. export class Sprite implements IAnimatable {
  10296. /** defines the name */
  10297. name: string;
  10298. /** Gets or sets the current world position */
  10299. position: Vector3;
  10300. /** Gets or sets the main color */
  10301. color: Color4;
  10302. /** Gets or sets the width */
  10303. width: number;
  10304. /** Gets or sets the height */
  10305. height: number;
  10306. /** Gets or sets rotation angle */
  10307. angle: number;
  10308. /** Gets or sets the cell index in the sprite sheet */
  10309. cellIndex: number;
  10310. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10311. cellRef: string;
  10312. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10313. invertU: boolean;
  10314. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10315. invertV: boolean;
  10316. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10317. disposeWhenFinishedAnimating: boolean;
  10318. /** Gets the list of attached animations */
  10319. animations: Nullable<Array<Animation>>;
  10320. /** Gets or sets a boolean indicating if the sprite can be picked */
  10321. isPickable: boolean;
  10322. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10323. useAlphaForPicking: boolean;
  10324. /** @hidden */
  10325. _xOffset: number;
  10326. /** @hidden */
  10327. _yOffset: number;
  10328. /** @hidden */
  10329. _xSize: number;
  10330. /** @hidden */
  10331. _ySize: number;
  10332. /**
  10333. * Gets or sets the associated action manager
  10334. */
  10335. actionManager: Nullable<ActionManager>;
  10336. /**
  10337. * An event triggered when the control has been disposed
  10338. */
  10339. onDisposeObservable: Observable<Sprite>;
  10340. private _animationStarted;
  10341. private _loopAnimation;
  10342. private _fromIndex;
  10343. private _toIndex;
  10344. private _delay;
  10345. private _direction;
  10346. private _manager;
  10347. private _time;
  10348. private _onAnimationEnd;
  10349. /**
  10350. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10351. */
  10352. isVisible: boolean;
  10353. /**
  10354. * Gets or sets the sprite size
  10355. */
  10356. get size(): number;
  10357. set size(value: number);
  10358. /**
  10359. * Returns a boolean indicating if the animation is started
  10360. */
  10361. get animationStarted(): boolean;
  10362. /**
  10363. * Gets or sets the unique id of the sprite
  10364. */
  10365. uniqueId: number;
  10366. /**
  10367. * Gets the manager of this sprite
  10368. */
  10369. get manager(): ISpriteManager;
  10370. /**
  10371. * Creates a new Sprite
  10372. * @param name defines the name
  10373. * @param manager defines the manager
  10374. */
  10375. constructor(
  10376. /** defines the name */
  10377. name: string, manager: ISpriteManager);
  10378. /**
  10379. * Returns the string "Sprite"
  10380. * @returns "Sprite"
  10381. */
  10382. getClassName(): string;
  10383. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10384. get fromIndex(): number;
  10385. set fromIndex(value: number);
  10386. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10387. get toIndex(): number;
  10388. set toIndex(value: number);
  10389. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10390. get loopAnimation(): boolean;
  10391. set loopAnimation(value: boolean);
  10392. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10393. get delay(): number;
  10394. set delay(value: number);
  10395. /**
  10396. * Starts an animation
  10397. * @param from defines the initial key
  10398. * @param to defines the end key
  10399. * @param loop defines if the animation must loop
  10400. * @param delay defines the start delay (in ms)
  10401. * @param onAnimationEnd defines a callback to call when animation ends
  10402. */
  10403. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10404. /** Stops current animation (if any) */
  10405. stopAnimation(): void;
  10406. /** @hidden */
  10407. _animate(deltaTime: number): void;
  10408. /** Release associated resources */
  10409. dispose(): void;
  10410. /**
  10411. * Serializes the sprite to a JSON object
  10412. * @returns the JSON object
  10413. */
  10414. serialize(): any;
  10415. /**
  10416. * Parses a JSON object to create a new sprite
  10417. * @param parsedSprite The JSON object to parse
  10418. * @param manager defines the hosting manager
  10419. * @returns the new sprite
  10420. */
  10421. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10422. }
  10423. }
  10424. declare module BABYLON {
  10425. /**
  10426. * Information about the result of picking within a scene
  10427. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10428. */
  10429. export class PickingInfo {
  10430. /** @hidden */
  10431. _pickingUnavailable: boolean;
  10432. /**
  10433. * If the pick collided with an object
  10434. */
  10435. hit: boolean;
  10436. /**
  10437. * Distance away where the pick collided
  10438. */
  10439. distance: number;
  10440. /**
  10441. * The location of pick collision
  10442. */
  10443. pickedPoint: Nullable<Vector3>;
  10444. /**
  10445. * The mesh corresponding the the pick collision
  10446. */
  10447. pickedMesh: Nullable<AbstractMesh>;
  10448. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10449. bu: number;
  10450. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10451. bv: number;
  10452. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10453. faceId: number;
  10454. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10455. subMeshFaceId: number;
  10456. /** Id of the the submesh that was picked */
  10457. subMeshId: number;
  10458. /** If a sprite was picked, this will be the sprite the pick collided with */
  10459. pickedSprite: Nullable<Sprite>;
  10460. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10461. thinInstanceIndex: number;
  10462. /**
  10463. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10464. */
  10465. originMesh: Nullable<AbstractMesh>;
  10466. /**
  10467. * The ray that was used to perform the picking.
  10468. */
  10469. ray: Nullable<Ray>;
  10470. /**
  10471. * Gets the normal correspodning to the face the pick collided with
  10472. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10473. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10474. * @returns The normal correspodning to the face the pick collided with
  10475. */
  10476. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10477. /**
  10478. * Gets the texture coordinates of where the pick occured
  10479. * @returns the vector containing the coordnates of the texture
  10480. */
  10481. getTextureCoordinates(): Nullable<Vector2>;
  10482. }
  10483. }
  10484. declare module BABYLON {
  10485. /**
  10486. * Class representing a ray with position and direction
  10487. */
  10488. export class Ray {
  10489. /** origin point */
  10490. origin: Vector3;
  10491. /** direction */
  10492. direction: Vector3;
  10493. /** length of the ray */
  10494. length: number;
  10495. private static readonly _TmpVector3;
  10496. private _tmpRay;
  10497. /**
  10498. * Creates a new ray
  10499. * @param origin origin point
  10500. * @param direction direction
  10501. * @param length length of the ray
  10502. */
  10503. constructor(
  10504. /** origin point */
  10505. origin: Vector3,
  10506. /** direction */
  10507. direction: Vector3,
  10508. /** length of the ray */
  10509. length?: number);
  10510. /**
  10511. * Checks if the ray intersects a box
  10512. * This does not account for the ray lenght by design to improve perfs.
  10513. * @param minimum bound of the box
  10514. * @param maximum bound of the box
  10515. * @param intersectionTreshold extra extend to be added to the box in all direction
  10516. * @returns if the box was hit
  10517. */
  10518. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10519. /**
  10520. * Checks if the ray intersects a box
  10521. * This does not account for the ray lenght by design to improve perfs.
  10522. * @param box the bounding box to check
  10523. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10524. * @returns if the box was hit
  10525. */
  10526. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10527. /**
  10528. * If the ray hits a sphere
  10529. * @param sphere the bounding sphere to check
  10530. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10531. * @returns true if it hits the sphere
  10532. */
  10533. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10534. /**
  10535. * If the ray hits a triange
  10536. * @param vertex0 triangle vertex
  10537. * @param vertex1 triangle vertex
  10538. * @param vertex2 triangle vertex
  10539. * @returns intersection information if hit
  10540. */
  10541. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10542. /**
  10543. * Checks if ray intersects a plane
  10544. * @param plane the plane to check
  10545. * @returns the distance away it was hit
  10546. */
  10547. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10548. /**
  10549. * Calculate the intercept of a ray on a given axis
  10550. * @param axis to check 'x' | 'y' | 'z'
  10551. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10552. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10553. */
  10554. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10555. /**
  10556. * Checks if ray intersects a mesh
  10557. * @param mesh the mesh to check
  10558. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10559. * @returns picking info of the intersecton
  10560. */
  10561. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10562. /**
  10563. * Checks if ray intersects a mesh
  10564. * @param meshes the meshes to check
  10565. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10566. * @param results array to store result in
  10567. * @returns Array of picking infos
  10568. */
  10569. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10570. private _comparePickingInfo;
  10571. private static smallnum;
  10572. private static rayl;
  10573. /**
  10574. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10575. * @param sega the first point of the segment to test the intersection against
  10576. * @param segb the second point of the segment to test the intersection against
  10577. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10578. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10579. */
  10580. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10581. /**
  10582. * Update the ray from viewport position
  10583. * @param x position
  10584. * @param y y position
  10585. * @param viewportWidth viewport width
  10586. * @param viewportHeight viewport height
  10587. * @param world world matrix
  10588. * @param view view matrix
  10589. * @param projection projection matrix
  10590. * @returns this ray updated
  10591. */
  10592. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10593. /**
  10594. * Creates a ray with origin and direction of 0,0,0
  10595. * @returns the new ray
  10596. */
  10597. static Zero(): Ray;
  10598. /**
  10599. * Creates a new ray from screen space and viewport
  10600. * @param x position
  10601. * @param y y position
  10602. * @param viewportWidth viewport width
  10603. * @param viewportHeight viewport height
  10604. * @param world world matrix
  10605. * @param view view matrix
  10606. * @param projection projection matrix
  10607. * @returns new ray
  10608. */
  10609. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10610. /**
  10611. * 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
  10612. * transformed to the given world matrix.
  10613. * @param origin The origin point
  10614. * @param end The end point
  10615. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10616. * @returns the new ray
  10617. */
  10618. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10619. /**
  10620. * Transforms a ray by a matrix
  10621. * @param ray ray to transform
  10622. * @param matrix matrix to apply
  10623. * @returns the resulting new ray
  10624. */
  10625. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10626. /**
  10627. * Transforms a ray by a matrix
  10628. * @param ray ray to transform
  10629. * @param matrix matrix to apply
  10630. * @param result ray to store result in
  10631. */
  10632. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10633. /**
  10634. * Unproject a ray from screen space to object space
  10635. * @param sourceX defines the screen space x coordinate to use
  10636. * @param sourceY defines the screen space y coordinate to use
  10637. * @param viewportWidth defines the current width of the viewport
  10638. * @param viewportHeight defines the current height of the viewport
  10639. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10640. * @param view defines the view matrix to use
  10641. * @param projection defines the projection matrix to use
  10642. */
  10643. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10644. }
  10645. /**
  10646. * Type used to define predicate used to select faces when a mesh intersection is detected
  10647. */
  10648. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10649. interface Scene {
  10650. /** @hidden */
  10651. _tempPickingRay: Nullable<Ray>;
  10652. /** @hidden */
  10653. _cachedRayForTransform: Ray;
  10654. /** @hidden */
  10655. _pickWithRayInverseMatrix: Matrix;
  10656. /** @hidden */
  10657. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10658. /** @hidden */
  10659. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10660. /** @hidden */
  10661. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10662. }
  10663. }
  10664. declare module BABYLON {
  10665. /**
  10666. * Groups all the scene component constants in one place to ease maintenance.
  10667. * @hidden
  10668. */
  10669. export class SceneComponentConstants {
  10670. static readonly NAME_EFFECTLAYER: string;
  10671. static readonly NAME_LAYER: string;
  10672. static readonly NAME_LENSFLARESYSTEM: string;
  10673. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10674. static readonly NAME_PARTICLESYSTEM: string;
  10675. static readonly NAME_GAMEPAD: string;
  10676. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10677. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10678. static readonly NAME_PREPASSRENDERER: string;
  10679. static readonly NAME_DEPTHRENDERER: string;
  10680. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10681. static readonly NAME_SPRITE: string;
  10682. static readonly NAME_SUBSURFACE: string;
  10683. static readonly NAME_OUTLINERENDERER: string;
  10684. static readonly NAME_PROCEDURALTEXTURE: string;
  10685. static readonly NAME_SHADOWGENERATOR: string;
  10686. static readonly NAME_OCTREE: string;
  10687. static readonly NAME_PHYSICSENGINE: string;
  10688. static readonly NAME_AUDIO: string;
  10689. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10690. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10691. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10692. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10693. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10694. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10695. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10696. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10697. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10698. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10699. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10700. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10701. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10702. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10703. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10704. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10705. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10706. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10707. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10708. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10709. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10710. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10711. static readonly STEP_AFTERRENDER_AUDIO: number;
  10712. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10713. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10714. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10715. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10716. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10717. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10718. static readonly STEP_POINTERMOVE_SPRITE: number;
  10719. static readonly STEP_POINTERDOWN_SPRITE: number;
  10720. static readonly STEP_POINTERUP_SPRITE: number;
  10721. }
  10722. /**
  10723. * This represents a scene component.
  10724. *
  10725. * This is used to decouple the dependency the scene is having on the different workloads like
  10726. * layers, post processes...
  10727. */
  10728. export interface ISceneComponent {
  10729. /**
  10730. * The name of the component. Each component must have a unique name.
  10731. */
  10732. name: string;
  10733. /**
  10734. * The scene the component belongs to.
  10735. */
  10736. scene: Scene;
  10737. /**
  10738. * Register the component to one instance of a scene.
  10739. */
  10740. register(): void;
  10741. /**
  10742. * Rebuilds the elements related to this component in case of
  10743. * context lost for instance.
  10744. */
  10745. rebuild(): void;
  10746. /**
  10747. * Disposes the component and the associated ressources.
  10748. */
  10749. dispose(): void;
  10750. }
  10751. /**
  10752. * This represents a SERIALIZABLE scene component.
  10753. *
  10754. * This extends Scene Component to add Serialization methods on top.
  10755. */
  10756. export interface ISceneSerializableComponent extends ISceneComponent {
  10757. /**
  10758. * Adds all the elements from the container to the scene
  10759. * @param container the container holding the elements
  10760. */
  10761. addFromContainer(container: AbstractScene): void;
  10762. /**
  10763. * Removes all the elements in the container from the scene
  10764. * @param container contains the elements to remove
  10765. * @param dispose if the removed element should be disposed (default: false)
  10766. */
  10767. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10768. /**
  10769. * Serializes the component data to the specified json object
  10770. * @param serializationObject The object to serialize to
  10771. */
  10772. serialize(serializationObject: any): void;
  10773. }
  10774. /**
  10775. * Strong typing of a Mesh related stage step action
  10776. */
  10777. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10778. /**
  10779. * Strong typing of a Evaluate Sub Mesh related stage step action
  10780. */
  10781. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10782. /**
  10783. * Strong typing of a Active Mesh related stage step action
  10784. */
  10785. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10786. /**
  10787. * Strong typing of a Camera related stage step action
  10788. */
  10789. export type CameraStageAction = (camera: Camera) => void;
  10790. /**
  10791. * Strong typing of a Camera Frame buffer related stage step action
  10792. */
  10793. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10794. /**
  10795. * Strong typing of a Render Target related stage step action
  10796. */
  10797. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10798. /**
  10799. * Strong typing of a RenderingGroup related stage step action
  10800. */
  10801. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10802. /**
  10803. * Strong typing of a Mesh Render related stage step action
  10804. */
  10805. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10806. /**
  10807. * Strong typing of a simple stage step action
  10808. */
  10809. export type SimpleStageAction = () => void;
  10810. /**
  10811. * Strong typing of a render target action.
  10812. */
  10813. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10814. /**
  10815. * Strong typing of a pointer move action.
  10816. */
  10817. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10818. /**
  10819. * Strong typing of a pointer up/down action.
  10820. */
  10821. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10822. /**
  10823. * Representation of a stage in the scene (Basically a list of ordered steps)
  10824. * @hidden
  10825. */
  10826. export class Stage<T extends Function> extends Array<{
  10827. index: number;
  10828. component: ISceneComponent;
  10829. action: T;
  10830. }> {
  10831. /**
  10832. * Hide ctor from the rest of the world.
  10833. * @param items The items to add.
  10834. */
  10835. private constructor();
  10836. /**
  10837. * Creates a new Stage.
  10838. * @returns A new instance of a Stage
  10839. */
  10840. static Create<T extends Function>(): Stage<T>;
  10841. /**
  10842. * Registers a step in an ordered way in the targeted stage.
  10843. * @param index Defines the position to register the step in
  10844. * @param component Defines the component attached to the step
  10845. * @param action Defines the action to launch during the step
  10846. */
  10847. registerStep(index: number, component: ISceneComponent, action: T): void;
  10848. /**
  10849. * Clears all the steps from the stage.
  10850. */
  10851. clear(): void;
  10852. }
  10853. }
  10854. declare module BABYLON {
  10855. interface Scene {
  10856. /** @hidden */
  10857. _pointerOverSprite: Nullable<Sprite>;
  10858. /** @hidden */
  10859. _pickedDownSprite: Nullable<Sprite>;
  10860. /** @hidden */
  10861. _tempSpritePickingRay: Nullable<Ray>;
  10862. /**
  10863. * All of the sprite managers added to this scene
  10864. * @see https://doc.babylonjs.com/babylon101/sprites
  10865. */
  10866. spriteManagers: Array<ISpriteManager>;
  10867. /**
  10868. * An event triggered when sprites rendering is about to start
  10869. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10870. */
  10871. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10872. /**
  10873. * An event triggered when sprites rendering is done
  10874. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10875. */
  10876. onAfterSpritesRenderingObservable: Observable<Scene>;
  10877. /** @hidden */
  10878. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10879. /** Launch a ray to try to pick a sprite in the scene
  10880. * @param x position on screen
  10881. * @param y position on screen
  10882. * @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
  10883. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10884. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10885. * @returns a PickingInfo
  10886. */
  10887. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10888. /** Use the given ray to pick a sprite in the scene
  10889. * @param ray The ray (in world space) to use to pick meshes
  10890. * @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
  10891. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10892. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10893. * @returns a PickingInfo
  10894. */
  10895. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10896. /** @hidden */
  10897. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10898. /** Launch a ray to try to pick sprites in the scene
  10899. * @param x position on screen
  10900. * @param y position on screen
  10901. * @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
  10902. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10903. * @returns a PickingInfo array
  10904. */
  10905. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10906. /** Use the given ray to pick sprites in the scene
  10907. * @param ray The ray (in world space) to use to pick meshes
  10908. * @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
  10909. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10910. * @returns a PickingInfo array
  10911. */
  10912. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10913. /**
  10914. * Force the sprite under the pointer
  10915. * @param sprite defines the sprite to use
  10916. */
  10917. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10918. /**
  10919. * Gets the sprite under the pointer
  10920. * @returns a Sprite or null if no sprite is under the pointer
  10921. */
  10922. getPointerOverSprite(): Nullable<Sprite>;
  10923. }
  10924. /**
  10925. * Defines the sprite scene component responsible to manage sprites
  10926. * in a given scene.
  10927. */
  10928. export class SpriteSceneComponent implements ISceneComponent {
  10929. /**
  10930. * The component name helpfull to identify the component in the list of scene components.
  10931. */
  10932. readonly name: string;
  10933. /**
  10934. * The scene the component belongs to.
  10935. */
  10936. scene: Scene;
  10937. /** @hidden */
  10938. private _spritePredicate;
  10939. /**
  10940. * Creates a new instance of the component for the given scene
  10941. * @param scene Defines the scene to register the component in
  10942. */
  10943. constructor(scene: Scene);
  10944. /**
  10945. * Registers the component in a given scene
  10946. */
  10947. register(): void;
  10948. /**
  10949. * Rebuilds the elements related to this component in case of
  10950. * context lost for instance.
  10951. */
  10952. rebuild(): void;
  10953. /**
  10954. * Disposes the component and the associated ressources.
  10955. */
  10956. dispose(): void;
  10957. private _pickSpriteButKeepRay;
  10958. private _pointerMove;
  10959. private _pointerDown;
  10960. private _pointerUp;
  10961. }
  10962. }
  10963. declare module BABYLON {
  10964. /** @hidden */
  10965. export var fogFragmentDeclaration: {
  10966. name: string;
  10967. shader: string;
  10968. };
  10969. }
  10970. declare module BABYLON {
  10971. /** @hidden */
  10972. export var fogFragment: {
  10973. name: string;
  10974. shader: string;
  10975. };
  10976. }
  10977. declare module BABYLON {
  10978. /** @hidden */
  10979. export var imageProcessingCompatibility: {
  10980. name: string;
  10981. shader: string;
  10982. };
  10983. }
  10984. declare module BABYLON {
  10985. /** @hidden */
  10986. export var spritesPixelShader: {
  10987. name: string;
  10988. shader: string;
  10989. };
  10990. }
  10991. declare module BABYLON {
  10992. /** @hidden */
  10993. export var fogVertexDeclaration: {
  10994. name: string;
  10995. shader: string;
  10996. };
  10997. }
  10998. declare module BABYLON {
  10999. /** @hidden */
  11000. export var spritesVertexShader: {
  11001. name: string;
  11002. shader: string;
  11003. };
  11004. }
  11005. declare module BABYLON {
  11006. /**
  11007. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11008. */
  11009. export interface ISpriteManager extends IDisposable {
  11010. /**
  11011. * Gets manager's name
  11012. */
  11013. name: string;
  11014. /**
  11015. * Restricts the camera to viewing objects with the same layerMask.
  11016. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11017. */
  11018. layerMask: number;
  11019. /**
  11020. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11021. */
  11022. isPickable: boolean;
  11023. /**
  11024. * Gets the hosting scene
  11025. */
  11026. scene: Scene;
  11027. /**
  11028. * Specifies the rendering group id for this mesh (0 by default)
  11029. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11030. */
  11031. renderingGroupId: number;
  11032. /**
  11033. * Defines the list of sprites managed by the manager.
  11034. */
  11035. sprites: Array<Sprite>;
  11036. /**
  11037. * Gets or sets the spritesheet texture
  11038. */
  11039. texture: Texture;
  11040. /** Defines the default width of a cell in the spritesheet */
  11041. cellWidth: number;
  11042. /** Defines the default height of a cell in the spritesheet */
  11043. cellHeight: number;
  11044. /**
  11045. * Tests the intersection of a sprite with a specific ray.
  11046. * @param ray The ray we are sending to test the collision
  11047. * @param camera The camera space we are sending rays in
  11048. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11049. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11050. * @returns picking info or null.
  11051. */
  11052. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11053. /**
  11054. * Intersects the sprites with a ray
  11055. * @param ray defines the ray to intersect with
  11056. * @param camera defines the current active camera
  11057. * @param predicate defines a predicate used to select candidate sprites
  11058. * @returns null if no hit or a PickingInfo array
  11059. */
  11060. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11061. /**
  11062. * Renders the list of sprites on screen.
  11063. */
  11064. render(): void;
  11065. }
  11066. /**
  11067. * Class used to manage multiple sprites on the same spritesheet
  11068. * @see https://doc.babylonjs.com/babylon101/sprites
  11069. */
  11070. export class SpriteManager implements ISpriteManager {
  11071. /** defines the manager's name */
  11072. name: string;
  11073. /** Define the Url to load snippets */
  11074. static SnippetUrl: string;
  11075. /** Snippet ID if the manager was created from the snippet server */
  11076. snippetId: string;
  11077. /** Gets the list of sprites */
  11078. sprites: Sprite[];
  11079. /** Gets or sets the rendering group id (0 by default) */
  11080. renderingGroupId: number;
  11081. /** Gets or sets camera layer mask */
  11082. layerMask: number;
  11083. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11084. fogEnabled: boolean;
  11085. /** Gets or sets a boolean indicating if the sprites are pickable */
  11086. isPickable: boolean;
  11087. /** Defines the default width of a cell in the spritesheet */
  11088. cellWidth: number;
  11089. /** Defines the default height of a cell in the spritesheet */
  11090. cellHeight: number;
  11091. /** Associative array from JSON sprite data file */
  11092. private _cellData;
  11093. /** Array of sprite names from JSON sprite data file */
  11094. private _spriteMap;
  11095. /** True when packed cell data from JSON file is ready*/
  11096. private _packedAndReady;
  11097. private _textureContent;
  11098. private _useInstancing;
  11099. /**
  11100. * An event triggered when the manager is disposed.
  11101. */
  11102. onDisposeObservable: Observable<SpriteManager>;
  11103. private _onDisposeObserver;
  11104. /**
  11105. * Callback called when the manager is disposed
  11106. */
  11107. set onDispose(callback: () => void);
  11108. private _capacity;
  11109. private _fromPacked;
  11110. private _spriteTexture;
  11111. private _epsilon;
  11112. private _scene;
  11113. private _vertexData;
  11114. private _buffer;
  11115. private _vertexBuffers;
  11116. private _spriteBuffer;
  11117. private _indexBuffer;
  11118. private _effectBase;
  11119. private _effectFog;
  11120. private _vertexBufferSize;
  11121. /**
  11122. * Gets or sets the unique id of the sprite
  11123. */
  11124. uniqueId: number;
  11125. /**
  11126. * Gets the array of sprites
  11127. */
  11128. get children(): Sprite[];
  11129. /**
  11130. * Gets the hosting scene
  11131. */
  11132. get scene(): Scene;
  11133. /**
  11134. * Gets the capacity of the manager
  11135. */
  11136. get capacity(): number;
  11137. /**
  11138. * Gets or sets the spritesheet texture
  11139. */
  11140. get texture(): Texture;
  11141. set texture(value: Texture);
  11142. private _blendMode;
  11143. /**
  11144. * Blend mode use to render the particle, it can be any of
  11145. * the static Constants.ALPHA_x properties provided in this class.
  11146. * Default value is Constants.ALPHA_COMBINE
  11147. */
  11148. get blendMode(): number;
  11149. set blendMode(blendMode: number);
  11150. /** Disables writing to the depth buffer when rendering the sprites.
  11151. * It can be handy to disable depth writing when using textures without alpha channel
  11152. * and setting some specific blend modes.
  11153. */
  11154. disableDepthWrite: boolean;
  11155. /**
  11156. * Creates a new sprite manager
  11157. * @param name defines the manager's name
  11158. * @param imgUrl defines the sprite sheet url
  11159. * @param capacity defines the maximum allowed number of sprites
  11160. * @param cellSize defines the size of a sprite cell
  11161. * @param scene defines the hosting scene
  11162. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11163. * @param samplingMode defines the smapling mode to use with spritesheet
  11164. * @param fromPacked set to false; do not alter
  11165. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11166. */
  11167. constructor(
  11168. /** defines the manager's name */
  11169. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11170. /**
  11171. * Returns the string "SpriteManager"
  11172. * @returns "SpriteManager"
  11173. */
  11174. getClassName(): string;
  11175. private _makePacked;
  11176. private _appendSpriteVertex;
  11177. private _checkTextureAlpha;
  11178. /**
  11179. * Intersects the sprites with a ray
  11180. * @param ray defines the ray to intersect with
  11181. * @param camera defines the current active camera
  11182. * @param predicate defines a predicate used to select candidate sprites
  11183. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11184. * @returns null if no hit or a PickingInfo
  11185. */
  11186. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11187. /**
  11188. * Intersects the sprites with a ray
  11189. * @param ray defines the ray to intersect with
  11190. * @param camera defines the current active camera
  11191. * @param predicate defines a predicate used to select candidate sprites
  11192. * @returns null if no hit or a PickingInfo array
  11193. */
  11194. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11195. /**
  11196. * Render all child sprites
  11197. */
  11198. render(): void;
  11199. /**
  11200. * Release associated resources
  11201. */
  11202. dispose(): void;
  11203. /**
  11204. * Serializes the sprite manager to a JSON object
  11205. * @param serializeTexture defines if the texture must be serialized as well
  11206. * @returns the JSON object
  11207. */
  11208. serialize(serializeTexture?: boolean): any;
  11209. /**
  11210. * Parses a JSON object to create a new sprite manager.
  11211. * @param parsedManager The JSON object to parse
  11212. * @param scene The scene to create the sprite managerin
  11213. * @param rootUrl The root url to use to load external dependencies like texture
  11214. * @returns the new sprite manager
  11215. */
  11216. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11217. /**
  11218. * Creates a sprite manager from a snippet saved in a remote file
  11219. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11220. * @param url defines the url to load from
  11221. * @param scene defines the hosting scene
  11222. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11223. * @returns a promise that will resolve to the new sprite manager
  11224. */
  11225. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11226. /**
  11227. * Creates a sprite manager from a snippet saved by the sprite editor
  11228. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11229. * @param scene defines the hosting scene
  11230. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11231. * @returns a promise that will resolve to the new sprite manager
  11232. */
  11233. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11234. }
  11235. }
  11236. declare module BABYLON {
  11237. /** Interface used by value gradients (color, factor, ...) */
  11238. export interface IValueGradient {
  11239. /**
  11240. * Gets or sets the gradient value (between 0 and 1)
  11241. */
  11242. gradient: number;
  11243. }
  11244. /** Class used to store color4 gradient */
  11245. export class ColorGradient implements IValueGradient {
  11246. /**
  11247. * Gets or sets the gradient value (between 0 and 1)
  11248. */
  11249. gradient: number;
  11250. /**
  11251. * Gets or sets first associated color
  11252. */
  11253. color1: Color4;
  11254. /**
  11255. * Gets or sets second associated color
  11256. */
  11257. color2?: Color4 | undefined;
  11258. /**
  11259. * Creates a new color4 gradient
  11260. * @param gradient gets or sets the gradient value (between 0 and 1)
  11261. * @param color1 gets or sets first associated color
  11262. * @param color2 gets or sets first second color
  11263. */
  11264. constructor(
  11265. /**
  11266. * Gets or sets the gradient value (between 0 and 1)
  11267. */
  11268. gradient: number,
  11269. /**
  11270. * Gets or sets first associated color
  11271. */
  11272. color1: Color4,
  11273. /**
  11274. * Gets or sets second associated color
  11275. */
  11276. color2?: Color4 | undefined);
  11277. /**
  11278. * Will get a color picked randomly between color1 and color2.
  11279. * If color2 is undefined then color1 will be used
  11280. * @param result defines the target Color4 to store the result in
  11281. */
  11282. getColorToRef(result: Color4): void;
  11283. }
  11284. /** Class used to store color 3 gradient */
  11285. export class Color3Gradient implements IValueGradient {
  11286. /**
  11287. * Gets or sets the gradient value (between 0 and 1)
  11288. */
  11289. gradient: number;
  11290. /**
  11291. * Gets or sets the associated color
  11292. */
  11293. color: Color3;
  11294. /**
  11295. * Creates a new color3 gradient
  11296. * @param gradient gets or sets the gradient value (between 0 and 1)
  11297. * @param color gets or sets associated color
  11298. */
  11299. constructor(
  11300. /**
  11301. * Gets or sets the gradient value (between 0 and 1)
  11302. */
  11303. gradient: number,
  11304. /**
  11305. * Gets or sets the associated color
  11306. */
  11307. color: Color3);
  11308. }
  11309. /** Class used to store factor gradient */
  11310. export class FactorGradient implements IValueGradient {
  11311. /**
  11312. * Gets or sets the gradient value (between 0 and 1)
  11313. */
  11314. gradient: number;
  11315. /**
  11316. * Gets or sets first associated factor
  11317. */
  11318. factor1: number;
  11319. /**
  11320. * Gets or sets second associated factor
  11321. */
  11322. factor2?: number | undefined;
  11323. /**
  11324. * Creates a new factor gradient
  11325. * @param gradient gets or sets the gradient value (between 0 and 1)
  11326. * @param factor1 gets or sets first associated factor
  11327. * @param factor2 gets or sets second associated factor
  11328. */
  11329. constructor(
  11330. /**
  11331. * Gets or sets the gradient value (between 0 and 1)
  11332. */
  11333. gradient: number,
  11334. /**
  11335. * Gets or sets first associated factor
  11336. */
  11337. factor1: number,
  11338. /**
  11339. * Gets or sets second associated factor
  11340. */
  11341. factor2?: number | undefined);
  11342. /**
  11343. * Will get a number picked randomly between factor1 and factor2.
  11344. * If factor2 is undefined then factor1 will be used
  11345. * @returns the picked number
  11346. */
  11347. getFactor(): number;
  11348. }
  11349. /**
  11350. * Helper used to simplify some generic gradient tasks
  11351. */
  11352. export class GradientHelper {
  11353. /**
  11354. * Gets the current gradient from an array of IValueGradient
  11355. * @param ratio defines the current ratio to get
  11356. * @param gradients defines the array of IValueGradient
  11357. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11358. */
  11359. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11360. }
  11361. }
  11362. declare module BABYLON {
  11363. interface ThinEngine {
  11364. /**
  11365. * Creates a raw texture
  11366. * @param data defines the data to store in the texture
  11367. * @param width defines the width of the texture
  11368. * @param height defines the height of the texture
  11369. * @param format defines the format of the data
  11370. * @param generateMipMaps defines if the engine should generate the mip levels
  11371. * @param invertY defines if data must be stored with Y axis inverted
  11372. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11373. * @param compression defines the compression used (null by default)
  11374. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11375. * @returns the raw texture inside an InternalTexture
  11376. */
  11377. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11378. /**
  11379. * Update a raw texture
  11380. * @param texture defines the texture to update
  11381. * @param data defines the data to store in the texture
  11382. * @param format defines the format of the data
  11383. * @param invertY defines if data must be stored with Y axis inverted
  11384. */
  11385. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11386. /**
  11387. * Update a raw texture
  11388. * @param texture defines the texture to update
  11389. * @param data defines the data to store in the texture
  11390. * @param format defines the format of the data
  11391. * @param invertY defines if data must be stored with Y axis inverted
  11392. * @param compression defines the compression used (null by default)
  11393. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11394. */
  11395. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11396. /**
  11397. * Creates a new raw cube texture
  11398. * @param data defines the array of data to use to create each face
  11399. * @param size defines the size of the textures
  11400. * @param format defines the format of the data
  11401. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11402. * @param generateMipMaps defines if the engine should generate the mip levels
  11403. * @param invertY defines if data must be stored with Y axis inverted
  11404. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11405. * @param compression defines the compression used (null by default)
  11406. * @returns the cube texture as an InternalTexture
  11407. */
  11408. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11409. /**
  11410. * Update a raw cube texture
  11411. * @param texture defines the texture to udpdate
  11412. * @param data defines the data to store
  11413. * @param format defines the data format
  11414. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11415. * @param invertY defines if data must be stored with Y axis inverted
  11416. */
  11417. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11418. /**
  11419. * Update a raw cube texture
  11420. * @param texture defines the texture to udpdate
  11421. * @param data defines the data to store
  11422. * @param format defines the data format
  11423. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11424. * @param invertY defines if data must be stored with Y axis inverted
  11425. * @param compression defines the compression used (null by default)
  11426. */
  11427. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11428. /**
  11429. * Update a raw cube texture
  11430. * @param texture defines the texture to udpdate
  11431. * @param data defines the data to store
  11432. * @param format defines the data format
  11433. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11434. * @param invertY defines if data must be stored with Y axis inverted
  11435. * @param compression defines the compression used (null by default)
  11436. * @param level defines which level of the texture to update
  11437. */
  11438. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11439. /**
  11440. * Creates a new raw cube texture from a specified url
  11441. * @param url defines the url where the data is located
  11442. * @param scene defines the current scene
  11443. * @param size defines the size of the textures
  11444. * @param format defines the format of the data
  11445. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11446. * @param noMipmap defines if the engine should avoid generating the mip levels
  11447. * @param callback defines a callback used to extract texture data from loaded data
  11448. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11449. * @param onLoad defines a callback called when texture is loaded
  11450. * @param onError defines a callback called if there is an error
  11451. * @returns the cube texture as an InternalTexture
  11452. */
  11453. 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;
  11454. /**
  11455. * Creates a new raw cube texture from a specified url
  11456. * @param url defines the url where the data is located
  11457. * @param scene defines the current scene
  11458. * @param size defines the size of the textures
  11459. * @param format defines the format of the data
  11460. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11461. * @param noMipmap defines if the engine should avoid generating the mip levels
  11462. * @param callback defines a callback used to extract texture data from loaded data
  11463. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11464. * @param onLoad defines a callback called when texture is loaded
  11465. * @param onError defines a callback called if there is an error
  11466. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11467. * @param invertY defines if data must be stored with Y axis inverted
  11468. * @returns the cube texture as an InternalTexture
  11469. */
  11470. 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;
  11471. /**
  11472. * Creates a new raw 3D texture
  11473. * @param data defines the data used to create the texture
  11474. * @param width defines the width of the texture
  11475. * @param height defines the height of the texture
  11476. * @param depth defines the depth of the texture
  11477. * @param format defines the format of the texture
  11478. * @param generateMipMaps defines if the engine must generate mip levels
  11479. * @param invertY defines if data must be stored with Y axis inverted
  11480. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11481. * @param compression defines the compressed used (can be null)
  11482. * @param textureType defines the compressed used (can be null)
  11483. * @returns a new raw 3D texture (stored in an InternalTexture)
  11484. */
  11485. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11486. /**
  11487. * Update a raw 3D texture
  11488. * @param texture defines the texture to update
  11489. * @param data defines the data to store
  11490. * @param format defines the data format
  11491. * @param invertY defines if data must be stored with Y axis inverted
  11492. */
  11493. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11494. /**
  11495. * Update a raw 3D texture
  11496. * @param texture defines the texture to update
  11497. * @param data defines the data to store
  11498. * @param format defines the data format
  11499. * @param invertY defines if data must be stored with Y axis inverted
  11500. * @param compression defines the used compression (can be null)
  11501. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11502. */
  11503. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11504. /**
  11505. * Creates a new raw 2D array texture
  11506. * @param data defines the data used to create the texture
  11507. * @param width defines the width of the texture
  11508. * @param height defines the height of the texture
  11509. * @param depth defines the number of layers of the texture
  11510. * @param format defines the format of the texture
  11511. * @param generateMipMaps defines if the engine must generate mip levels
  11512. * @param invertY defines if data must be stored with Y axis inverted
  11513. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11514. * @param compression defines the compressed used (can be null)
  11515. * @param textureType defines the compressed used (can be null)
  11516. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11517. */
  11518. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11519. /**
  11520. * Update a raw 2D array texture
  11521. * @param texture defines the texture to update
  11522. * @param data defines the data to store
  11523. * @param format defines the data format
  11524. * @param invertY defines if data must be stored with Y axis inverted
  11525. */
  11526. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11527. /**
  11528. * Update a raw 2D array texture
  11529. * @param texture defines the texture to update
  11530. * @param data defines the data to store
  11531. * @param format defines the data format
  11532. * @param invertY defines if data must be stored with Y axis inverted
  11533. * @param compression defines the used compression (can be null)
  11534. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11535. */
  11536. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11537. }
  11538. }
  11539. declare module BABYLON {
  11540. /**
  11541. * Raw texture can help creating a texture directly from an array of data.
  11542. * This can be super useful if you either get the data from an uncompressed source or
  11543. * if you wish to create your texture pixel by pixel.
  11544. */
  11545. export class RawTexture extends Texture {
  11546. /**
  11547. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11548. */
  11549. format: number;
  11550. /**
  11551. * Instantiates a new RawTexture.
  11552. * Raw texture can help creating a texture directly from an array of data.
  11553. * This can be super useful if you either get the data from an uncompressed source or
  11554. * if you wish to create your texture pixel by pixel.
  11555. * @param data define the array of data to use to create the texture
  11556. * @param width define the width of the texture
  11557. * @param height define the height of the texture
  11558. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11559. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11560. * @param generateMipMaps define whether mip maps should be generated or not
  11561. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11562. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11563. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11564. */
  11565. constructor(data: ArrayBufferView, width: number, height: number,
  11566. /**
  11567. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11568. */
  11569. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11570. /**
  11571. * Updates the texture underlying data.
  11572. * @param data Define the new data of the texture
  11573. */
  11574. update(data: ArrayBufferView): void;
  11575. /**
  11576. * Creates a luminance texture from some data.
  11577. * @param data Define the texture data
  11578. * @param width Define the width of the texture
  11579. * @param height Define the height of the texture
  11580. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11584. * @returns the luminance texture
  11585. */
  11586. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11587. /**
  11588. * Creates a luminance alpha texture from some data.
  11589. * @param data Define the texture data
  11590. * @param width Define the width of the texture
  11591. * @param height Define the height of the texture
  11592. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11593. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11594. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11595. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11596. * @returns the luminance alpha texture
  11597. */
  11598. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11599. /**
  11600. * Creates an alpha texture from some data.
  11601. * @param data Define the texture data
  11602. * @param width Define the width of the texture
  11603. * @param height Define the height of the texture
  11604. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11605. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11606. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11607. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11608. * @returns the alpha texture
  11609. */
  11610. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11611. /**
  11612. * Creates a RGB texture from some data.
  11613. * @param data Define the texture data
  11614. * @param width Define the width of the texture
  11615. * @param height Define the height of the texture
  11616. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11617. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11618. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11619. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11620. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11621. * @returns the RGB alpha texture
  11622. */
  11623. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11624. /**
  11625. * Creates a RGBA texture from some data.
  11626. * @param data Define the texture data
  11627. * @param width Define the width of the texture
  11628. * @param height Define the height of the texture
  11629. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11630. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11631. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11632. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11633. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11634. * @returns the RGBA texture
  11635. */
  11636. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11637. /**
  11638. * Creates a R texture from some data.
  11639. * @param data Define the texture data
  11640. * @param width Define the width of the texture
  11641. * @param height Define the height of the texture
  11642. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11643. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11644. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11645. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11646. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11647. * @returns the R texture
  11648. */
  11649. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11650. }
  11651. }
  11652. declare module BABYLON {
  11653. interface ThinEngine {
  11654. /**
  11655. * Update a dynamic index buffer
  11656. * @param indexBuffer defines the target index buffer
  11657. * @param indices defines the data to update
  11658. * @param offset defines the offset in the target index buffer where update should start
  11659. */
  11660. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11661. /**
  11662. * Updates a dynamic vertex buffer.
  11663. * @param vertexBuffer the vertex buffer to update
  11664. * @param data the data used to update the vertex buffer
  11665. * @param byteOffset the byte offset of the data
  11666. * @param byteLength the byte length of the data
  11667. */
  11668. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11669. }
  11670. }
  11671. declare module BABYLON {
  11672. interface AbstractScene {
  11673. /**
  11674. * The list of procedural textures added to the scene
  11675. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11676. */
  11677. proceduralTextures: Array<ProceduralTexture>;
  11678. }
  11679. /**
  11680. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11681. * in a given scene.
  11682. */
  11683. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11684. /**
  11685. * The component name helpfull to identify the component in the list of scene components.
  11686. */
  11687. readonly name: string;
  11688. /**
  11689. * The scene the component belongs to.
  11690. */
  11691. scene: Scene;
  11692. /**
  11693. * Creates a new instance of the component for the given scene
  11694. * @param scene Defines the scene to register the component in
  11695. */
  11696. constructor(scene: Scene);
  11697. /**
  11698. * Registers the component in a given scene
  11699. */
  11700. register(): void;
  11701. /**
  11702. * Rebuilds the elements related to this component in case of
  11703. * context lost for instance.
  11704. */
  11705. rebuild(): void;
  11706. /**
  11707. * Disposes the component and the associated ressources.
  11708. */
  11709. dispose(): void;
  11710. private _beforeClear;
  11711. }
  11712. }
  11713. declare module BABYLON {
  11714. interface ThinEngine {
  11715. /**
  11716. * Creates a new render target cube texture
  11717. * @param size defines the size of the texture
  11718. * @param options defines the options used to create the texture
  11719. * @returns a new render target cube texture stored in an InternalTexture
  11720. */
  11721. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11722. }
  11723. }
  11724. declare module BABYLON {
  11725. /** @hidden */
  11726. export var proceduralVertexShader: {
  11727. name: string;
  11728. shader: string;
  11729. };
  11730. }
  11731. declare module BABYLON {
  11732. /**
  11733. * 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.
  11734. * This is the base class of any Procedural texture and contains most of the shareable code.
  11735. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11736. */
  11737. export class ProceduralTexture extends Texture {
  11738. /**
  11739. * Define if the texture is enabled or not (disabled texture will not render)
  11740. */
  11741. isEnabled: boolean;
  11742. /**
  11743. * Define if the texture must be cleared before rendering (default is true)
  11744. */
  11745. autoClear: boolean;
  11746. /**
  11747. * Callback called when the texture is generated
  11748. */
  11749. onGenerated: () => void;
  11750. /**
  11751. * Event raised when the texture is generated
  11752. */
  11753. onGeneratedObservable: Observable<ProceduralTexture>;
  11754. /**
  11755. * Event raised before the texture is generated
  11756. */
  11757. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11758. /**
  11759. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11760. */
  11761. nodeMaterialSource: Nullable<NodeMaterial>;
  11762. /** @hidden */
  11763. _generateMipMaps: boolean;
  11764. /** @hidden **/
  11765. _effect: Effect;
  11766. /** @hidden */
  11767. _textures: {
  11768. [key: string]: Texture;
  11769. };
  11770. /** @hidden */
  11771. protected _fallbackTexture: Nullable<Texture>;
  11772. private _size;
  11773. private _currentRefreshId;
  11774. private _frameId;
  11775. private _refreshRate;
  11776. private _vertexBuffers;
  11777. private _indexBuffer;
  11778. private _uniforms;
  11779. private _samplers;
  11780. private _fragment;
  11781. private _floats;
  11782. private _ints;
  11783. private _floatsArrays;
  11784. private _colors3;
  11785. private _colors4;
  11786. private _vectors2;
  11787. private _vectors3;
  11788. private _matrices;
  11789. private _fallbackTextureUsed;
  11790. private _fullEngine;
  11791. private _cachedDefines;
  11792. private _contentUpdateId;
  11793. private _contentData;
  11794. /**
  11795. * Instantiates a new procedural texture.
  11796. * 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.
  11797. * This is the base class of any Procedural texture and contains most of the shareable code.
  11798. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11799. * @param name Define the name of the texture
  11800. * @param size Define the size of the texture to create
  11801. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11802. * @param scene Define the scene the texture belongs to
  11803. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11804. * @param generateMipMaps Define if the texture should creates mip maps or not
  11805. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11806. * @param textureType The FBO internal texture type
  11807. */
  11808. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11809. /**
  11810. * The effect that is created when initializing the post process.
  11811. * @returns The created effect corresponding the the postprocess.
  11812. */
  11813. getEffect(): Effect;
  11814. /**
  11815. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11816. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11817. */
  11818. getContent(): Nullable<ArrayBufferView>;
  11819. private _createIndexBuffer;
  11820. /** @hidden */
  11821. _rebuild(): void;
  11822. /**
  11823. * Resets the texture in order to recreate its associated resources.
  11824. * This can be called in case of context loss
  11825. */
  11826. reset(): void;
  11827. protected _getDefines(): string;
  11828. /**
  11829. * Is the texture ready to be used ? (rendered at least once)
  11830. * @returns true if ready, otherwise, false.
  11831. */
  11832. isReady(): boolean;
  11833. /**
  11834. * Resets the refresh counter of the texture and start bak from scratch.
  11835. * Could be useful to regenerate the texture if it is setup to render only once.
  11836. */
  11837. resetRefreshCounter(): void;
  11838. /**
  11839. * Set the fragment shader to use in order to render the texture.
  11840. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11841. */
  11842. setFragment(fragment: any): void;
  11843. /**
  11844. * Define the refresh rate of the texture or the rendering frequency.
  11845. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11846. */
  11847. get refreshRate(): number;
  11848. set refreshRate(value: number);
  11849. /** @hidden */
  11850. _shouldRender(): boolean;
  11851. /**
  11852. * Get the size the texture is rendering at.
  11853. * @returns the size (on cube texture it is always squared)
  11854. */
  11855. getRenderSize(): RenderTargetTextureSize;
  11856. /**
  11857. * Resize the texture to new value.
  11858. * @param size Define the new size the texture should have
  11859. * @param generateMipMaps Define whether the new texture should create mip maps
  11860. */
  11861. resize(size: number, generateMipMaps: boolean): void;
  11862. private _checkUniform;
  11863. /**
  11864. * Set a texture in the shader program used to render.
  11865. * @param name Define the name of the uniform samplers as defined in the shader
  11866. * @param texture Define the texture to bind to this sampler
  11867. * @return the texture itself allowing "fluent" like uniform updates
  11868. */
  11869. setTexture(name: string, texture: Texture): ProceduralTexture;
  11870. /**
  11871. * Set a float in the shader.
  11872. * @param name Define the name of the uniform as defined in the shader
  11873. * @param value Define the value to give to the uniform
  11874. * @return the texture itself allowing "fluent" like uniform updates
  11875. */
  11876. setFloat(name: string, value: number): ProceduralTexture;
  11877. /**
  11878. * Set a int in the shader.
  11879. * @param name Define the name of the uniform as defined in the shader
  11880. * @param value Define the value to give to the uniform
  11881. * @return the texture itself allowing "fluent" like uniform updates
  11882. */
  11883. setInt(name: string, value: number): ProceduralTexture;
  11884. /**
  11885. * Set an array of floats in the shader.
  11886. * @param name Define the name of the uniform as defined in the shader
  11887. * @param value Define the value to give to the uniform
  11888. * @return the texture itself allowing "fluent" like uniform updates
  11889. */
  11890. setFloats(name: string, value: number[]): ProceduralTexture;
  11891. /**
  11892. * Set a vec3 in the shader from a Color3.
  11893. * @param name Define the name of the uniform as defined in the shader
  11894. * @param value Define the value to give to the uniform
  11895. * @return the texture itself allowing "fluent" like uniform updates
  11896. */
  11897. setColor3(name: string, value: Color3): ProceduralTexture;
  11898. /**
  11899. * Set a vec4 in the shader from a Color4.
  11900. * @param name Define the name of the uniform as defined in the shader
  11901. * @param value Define the value to give to the uniform
  11902. * @return the texture itself allowing "fluent" like uniform updates
  11903. */
  11904. setColor4(name: string, value: Color4): ProceduralTexture;
  11905. /**
  11906. * Set a vec2 in the shader from a Vector2.
  11907. * @param name Define the name of the uniform as defined in the shader
  11908. * @param value Define the value to give to the uniform
  11909. * @return the texture itself allowing "fluent" like uniform updates
  11910. */
  11911. setVector2(name: string, value: Vector2): ProceduralTexture;
  11912. /**
  11913. * Set a vec3 in the shader from a Vector3.
  11914. * @param name Define the name of the uniform as defined in the shader
  11915. * @param value Define the value to give to the uniform
  11916. * @return the texture itself allowing "fluent" like uniform updates
  11917. */
  11918. setVector3(name: string, value: Vector3): ProceduralTexture;
  11919. /**
  11920. * Set a mat4 in the shader from a MAtrix.
  11921. * @param name Define the name of the uniform as defined in the shader
  11922. * @param value Define the value to give to the uniform
  11923. * @return the texture itself allowing "fluent" like uniform updates
  11924. */
  11925. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11926. /**
  11927. * Render the texture to its associated render target.
  11928. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11929. */
  11930. render(useCameraPostProcess?: boolean): void;
  11931. /**
  11932. * Clone the texture.
  11933. * @returns the cloned texture
  11934. */
  11935. clone(): ProceduralTexture;
  11936. /**
  11937. * Dispose the texture and release its asoociated resources.
  11938. */
  11939. dispose(): void;
  11940. }
  11941. }
  11942. declare module BABYLON {
  11943. /**
  11944. * This represents the base class for particle system in Babylon.
  11945. * 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.
  11946. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11947. * @example https://doc.babylonjs.com/babylon101/particles
  11948. */
  11949. export class BaseParticleSystem {
  11950. /**
  11951. * Source color is added to the destination color without alpha affecting the result
  11952. */
  11953. static BLENDMODE_ONEONE: number;
  11954. /**
  11955. * Blend current color and particle color using particle’s alpha
  11956. */
  11957. static BLENDMODE_STANDARD: number;
  11958. /**
  11959. * Add current color and particle color multiplied by particle’s alpha
  11960. */
  11961. static BLENDMODE_ADD: number;
  11962. /**
  11963. * Multiply current color with particle color
  11964. */
  11965. static BLENDMODE_MULTIPLY: number;
  11966. /**
  11967. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11968. */
  11969. static BLENDMODE_MULTIPLYADD: number;
  11970. /**
  11971. * List of animations used by the particle system.
  11972. */
  11973. animations: Animation[];
  11974. /**
  11975. * Gets or sets the unique id of the particle system
  11976. */
  11977. uniqueId: number;
  11978. /**
  11979. * The id of the Particle system.
  11980. */
  11981. id: string;
  11982. /**
  11983. * The friendly name of the Particle system.
  11984. */
  11985. name: string;
  11986. /**
  11987. * Snippet ID if the particle system was created from the snippet server
  11988. */
  11989. snippetId: string;
  11990. /**
  11991. * The rendering group used by the Particle system to chose when to render.
  11992. */
  11993. renderingGroupId: number;
  11994. /**
  11995. * The emitter represents the Mesh or position we are attaching the particle system to.
  11996. */
  11997. emitter: Nullable<AbstractMesh | Vector3>;
  11998. /**
  11999. * The maximum number of particles to emit per frame
  12000. */
  12001. emitRate: number;
  12002. /**
  12003. * If you want to launch only a few particles at once, that can be done, as well.
  12004. */
  12005. manualEmitCount: number;
  12006. /**
  12007. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12008. */
  12009. updateSpeed: number;
  12010. /**
  12011. * The amount of time the particle system is running (depends of the overall update speed).
  12012. */
  12013. targetStopDuration: number;
  12014. /**
  12015. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12016. */
  12017. disposeOnStop: boolean;
  12018. /**
  12019. * Minimum power of emitting particles.
  12020. */
  12021. minEmitPower: number;
  12022. /**
  12023. * Maximum power of emitting particles.
  12024. */
  12025. maxEmitPower: number;
  12026. /**
  12027. * Minimum life time of emitting particles.
  12028. */
  12029. minLifeTime: number;
  12030. /**
  12031. * Maximum life time of emitting particles.
  12032. */
  12033. maxLifeTime: number;
  12034. /**
  12035. * Minimum Size of emitting particles.
  12036. */
  12037. minSize: number;
  12038. /**
  12039. * Maximum Size of emitting particles.
  12040. */
  12041. maxSize: number;
  12042. /**
  12043. * Minimum scale of emitting particles on X axis.
  12044. */
  12045. minScaleX: number;
  12046. /**
  12047. * Maximum scale of emitting particles on X axis.
  12048. */
  12049. maxScaleX: number;
  12050. /**
  12051. * Minimum scale of emitting particles on Y axis.
  12052. */
  12053. minScaleY: number;
  12054. /**
  12055. * Maximum scale of emitting particles on Y axis.
  12056. */
  12057. maxScaleY: number;
  12058. /**
  12059. * Gets or sets the minimal initial rotation in radians.
  12060. */
  12061. minInitialRotation: number;
  12062. /**
  12063. * Gets or sets the maximal initial rotation in radians.
  12064. */
  12065. maxInitialRotation: number;
  12066. /**
  12067. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12068. */
  12069. minAngularSpeed: number;
  12070. /**
  12071. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12072. */
  12073. maxAngularSpeed: number;
  12074. /**
  12075. * The texture used to render each particle. (this can be a spritesheet)
  12076. */
  12077. particleTexture: Nullable<BaseTexture>;
  12078. /**
  12079. * The layer mask we are rendering the particles through.
  12080. */
  12081. layerMask: number;
  12082. /**
  12083. * This can help using your own shader to render the particle system.
  12084. * The according effect will be created
  12085. */
  12086. customShader: any;
  12087. /**
  12088. * By default particle system starts as soon as they are created. This prevents the
  12089. * automatic start to happen and let you decide when to start emitting particles.
  12090. */
  12091. preventAutoStart: boolean;
  12092. private _noiseTexture;
  12093. /**
  12094. * Gets or sets a texture used to add random noise to particle positions
  12095. */
  12096. get noiseTexture(): Nullable<ProceduralTexture>;
  12097. set noiseTexture(value: Nullable<ProceduralTexture>);
  12098. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12099. noiseStrength: Vector3;
  12100. /**
  12101. * Callback triggered when the particle animation is ending.
  12102. */
  12103. onAnimationEnd: Nullable<() => void>;
  12104. /**
  12105. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12106. */
  12107. blendMode: number;
  12108. /**
  12109. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12110. * to override the particles.
  12111. */
  12112. forceDepthWrite: boolean;
  12113. /** 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 */
  12114. preWarmCycles: number;
  12115. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12116. preWarmStepOffset: number;
  12117. /**
  12118. * 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)
  12119. */
  12120. spriteCellChangeSpeed: number;
  12121. /**
  12122. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12123. */
  12124. startSpriteCellID: number;
  12125. /**
  12126. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12127. */
  12128. endSpriteCellID: number;
  12129. /**
  12130. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12131. */
  12132. spriteCellWidth: number;
  12133. /**
  12134. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12135. */
  12136. spriteCellHeight: number;
  12137. /**
  12138. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12139. */
  12140. spriteRandomStartCell: boolean;
  12141. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12142. translationPivot: Vector2;
  12143. /** @hidden */
  12144. protected _isAnimationSheetEnabled: boolean;
  12145. /**
  12146. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12147. */
  12148. beginAnimationOnStart: boolean;
  12149. /**
  12150. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12151. */
  12152. beginAnimationFrom: number;
  12153. /**
  12154. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12155. */
  12156. beginAnimationTo: number;
  12157. /**
  12158. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12159. */
  12160. beginAnimationLoop: boolean;
  12161. /**
  12162. * Gets or sets a world offset applied to all particles
  12163. */
  12164. worldOffset: Vector3;
  12165. /**
  12166. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12167. */
  12168. get isAnimationSheetEnabled(): boolean;
  12169. set isAnimationSheetEnabled(value: boolean);
  12170. /**
  12171. * Get hosting scene
  12172. * @returns the scene
  12173. */
  12174. getScene(): Nullable<Scene>;
  12175. /**
  12176. * You can use gravity if you want to give an orientation to your particles.
  12177. */
  12178. gravity: Vector3;
  12179. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12180. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12181. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12182. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12183. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12184. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12185. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12186. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12187. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12188. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12189. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12190. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12191. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12192. /**
  12193. * Defines the delay in milliseconds before starting the system (0 by default)
  12194. */
  12195. startDelay: number;
  12196. /**
  12197. * Gets the current list of drag gradients.
  12198. * You must use addDragGradient and removeDragGradient to udpate this list
  12199. * @returns the list of drag gradients
  12200. */
  12201. getDragGradients(): Nullable<Array<FactorGradient>>;
  12202. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12203. limitVelocityDamping: number;
  12204. /**
  12205. * Gets the current list of limit velocity gradients.
  12206. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12207. * @returns the list of limit velocity gradients
  12208. */
  12209. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12210. /**
  12211. * Gets the current list of color gradients.
  12212. * You must use addColorGradient and removeColorGradient to udpate this list
  12213. * @returns the list of color gradients
  12214. */
  12215. getColorGradients(): Nullable<Array<ColorGradient>>;
  12216. /**
  12217. * Gets the current list of size gradients.
  12218. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12219. * @returns the list of size gradients
  12220. */
  12221. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12222. /**
  12223. * Gets the current list of color remap gradients.
  12224. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12225. * @returns the list of color remap gradients
  12226. */
  12227. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12228. /**
  12229. * Gets the current list of alpha remap gradients.
  12230. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12231. * @returns the list of alpha remap gradients
  12232. */
  12233. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12234. /**
  12235. * Gets the current list of life time gradients.
  12236. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12237. * @returns the list of life time gradients
  12238. */
  12239. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12240. /**
  12241. * Gets the current list of angular speed gradients.
  12242. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12243. * @returns the list of angular speed gradients
  12244. */
  12245. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12246. /**
  12247. * Gets the current list of velocity gradients.
  12248. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12249. * @returns the list of velocity gradients
  12250. */
  12251. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12252. /**
  12253. * Gets the current list of start size gradients.
  12254. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12255. * @returns the list of start size gradients
  12256. */
  12257. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12258. /**
  12259. * Gets the current list of emit rate gradients.
  12260. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12261. * @returns the list of emit rate gradients
  12262. */
  12263. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12264. /**
  12265. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12266. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12267. */
  12268. get direction1(): Vector3;
  12269. set direction1(value: Vector3);
  12270. /**
  12271. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12272. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12273. */
  12274. get direction2(): Vector3;
  12275. set direction2(value: Vector3);
  12276. /**
  12277. * 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.
  12278. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12279. */
  12280. get minEmitBox(): Vector3;
  12281. set minEmitBox(value: Vector3);
  12282. /**
  12283. * 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.
  12284. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12285. */
  12286. get maxEmitBox(): Vector3;
  12287. set maxEmitBox(value: Vector3);
  12288. /**
  12289. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12290. */
  12291. color1: Color4;
  12292. /**
  12293. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12294. */
  12295. color2: Color4;
  12296. /**
  12297. * Color the particle will have at the end of its lifetime
  12298. */
  12299. colorDead: Color4;
  12300. /**
  12301. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12302. */
  12303. textureMask: Color4;
  12304. /**
  12305. * The particle emitter type defines the emitter used by the particle system.
  12306. * It can be for example box, sphere, or cone...
  12307. */
  12308. particleEmitterType: IParticleEmitterType;
  12309. /** @hidden */
  12310. _isSubEmitter: boolean;
  12311. /**
  12312. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12313. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12314. */
  12315. billboardMode: number;
  12316. protected _isBillboardBased: boolean;
  12317. /**
  12318. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12319. */
  12320. get isBillboardBased(): boolean;
  12321. set isBillboardBased(value: boolean);
  12322. /**
  12323. * The scene the particle system belongs to.
  12324. */
  12325. protected _scene: Nullable<Scene>;
  12326. /**
  12327. * The engine the particle system belongs to.
  12328. */
  12329. protected _engine: ThinEngine;
  12330. /**
  12331. * Local cache of defines for image processing.
  12332. */
  12333. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12334. /**
  12335. * Default configuration related to image processing available in the standard Material.
  12336. */
  12337. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12338. /**
  12339. * Gets the image processing configuration used either in this material.
  12340. */
  12341. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12342. /**
  12343. * Sets the Default image processing configuration used either in the this material.
  12344. *
  12345. * If sets to null, the scene one is in use.
  12346. */
  12347. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12348. /**
  12349. * Attaches a new image processing configuration to the Standard Material.
  12350. * @param configuration
  12351. */
  12352. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12353. /** @hidden */
  12354. protected _reset(): void;
  12355. /** @hidden */
  12356. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12357. /**
  12358. * Instantiates a particle system.
  12359. * 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.
  12360. * @param name The name of the particle system
  12361. */
  12362. constructor(name: string);
  12363. /**
  12364. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12365. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12366. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12367. * @returns the emitter
  12368. */
  12369. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12370. /**
  12371. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12372. * @param radius The radius of the hemisphere to emit from
  12373. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12374. * @returns the emitter
  12375. */
  12376. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12377. /**
  12378. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12379. * @param radius The radius of the sphere to emit from
  12380. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12381. * @returns the emitter
  12382. */
  12383. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12384. /**
  12385. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12386. * @param radius The radius of the sphere to emit from
  12387. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12388. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12389. * @returns the emitter
  12390. */
  12391. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12392. /**
  12393. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12394. * @param radius The radius of the emission cylinder
  12395. * @param height The height of the emission cylinder
  12396. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12397. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12398. * @returns the emitter
  12399. */
  12400. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12401. /**
  12402. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12403. * @param radius The radius of the cylinder to emit from
  12404. * @param height The height of the emission cylinder
  12405. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12406. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12407. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12408. * @returns the emitter
  12409. */
  12410. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12411. /**
  12412. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12413. * @param radius The radius of the cone to emit from
  12414. * @param angle The base angle of the cone
  12415. * @returns the emitter
  12416. */
  12417. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12418. /**
  12419. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12420. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12421. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12422. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12423. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12424. * @returns the emitter
  12425. */
  12426. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12427. }
  12428. }
  12429. declare module BABYLON {
  12430. /**
  12431. * Type of sub emitter
  12432. */
  12433. export enum SubEmitterType {
  12434. /**
  12435. * Attached to the particle over it's lifetime
  12436. */
  12437. ATTACHED = 0,
  12438. /**
  12439. * Created when the particle dies
  12440. */
  12441. END = 1
  12442. }
  12443. /**
  12444. * Sub emitter class used to emit particles from an existing particle
  12445. */
  12446. export class SubEmitter {
  12447. /**
  12448. * the particle system to be used by the sub emitter
  12449. */
  12450. particleSystem: ParticleSystem;
  12451. /**
  12452. * Type of the submitter (Default: END)
  12453. */
  12454. type: SubEmitterType;
  12455. /**
  12456. * 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)
  12457. * Note: This only is supported when using an emitter of type Mesh
  12458. */
  12459. inheritDirection: boolean;
  12460. /**
  12461. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12462. */
  12463. inheritedVelocityAmount: number;
  12464. /**
  12465. * Creates a sub emitter
  12466. * @param particleSystem the particle system to be used by the sub emitter
  12467. */
  12468. constructor(
  12469. /**
  12470. * the particle system to be used by the sub emitter
  12471. */
  12472. particleSystem: ParticleSystem);
  12473. /**
  12474. * Clones the sub emitter
  12475. * @returns the cloned sub emitter
  12476. */
  12477. clone(): SubEmitter;
  12478. /**
  12479. * Serialize current object to a JSON object
  12480. * @returns the serialized object
  12481. */
  12482. serialize(): any;
  12483. /** @hidden */
  12484. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12485. /**
  12486. * Creates a new SubEmitter from a serialized JSON version
  12487. * @param serializationObject defines the JSON object to read from
  12488. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12489. * @param rootUrl defines the rootUrl for data loading
  12490. * @returns a new SubEmitter
  12491. */
  12492. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12493. /** Release associated resources */
  12494. dispose(): void;
  12495. }
  12496. }
  12497. declare module BABYLON {
  12498. /** @hidden */
  12499. export var imageProcessingDeclaration: {
  12500. name: string;
  12501. shader: string;
  12502. };
  12503. }
  12504. declare module BABYLON {
  12505. /** @hidden */
  12506. export var imageProcessingFunctions: {
  12507. name: string;
  12508. shader: string;
  12509. };
  12510. }
  12511. declare module BABYLON {
  12512. /** @hidden */
  12513. export var particlesPixelShader: {
  12514. name: string;
  12515. shader: string;
  12516. };
  12517. }
  12518. declare module BABYLON {
  12519. /** @hidden */
  12520. export var particlesVertexShader: {
  12521. name: string;
  12522. shader: string;
  12523. };
  12524. }
  12525. declare module BABYLON {
  12526. /**
  12527. * Interface used to define entities containing multiple clip planes
  12528. */
  12529. export interface IClipPlanesHolder {
  12530. /**
  12531. * Gets or sets the active clipplane 1
  12532. */
  12533. clipPlane: Nullable<Plane>;
  12534. /**
  12535. * Gets or sets the active clipplane 2
  12536. */
  12537. clipPlane2: Nullable<Plane>;
  12538. /**
  12539. * Gets or sets the active clipplane 3
  12540. */
  12541. clipPlane3: Nullable<Plane>;
  12542. /**
  12543. * Gets or sets the active clipplane 4
  12544. */
  12545. clipPlane4: Nullable<Plane>;
  12546. /**
  12547. * Gets or sets the active clipplane 5
  12548. */
  12549. clipPlane5: Nullable<Plane>;
  12550. /**
  12551. * Gets or sets the active clipplane 6
  12552. */
  12553. clipPlane6: Nullable<Plane>;
  12554. }
  12555. }
  12556. declare module BABYLON {
  12557. /**
  12558. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12559. *
  12560. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12561. *
  12562. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12563. */
  12564. export class ThinMaterialHelper {
  12565. /**
  12566. * Binds the clip plane information from the holder to the effect.
  12567. * @param effect The effect we are binding the data to
  12568. * @param holder The entity containing the clip plane information
  12569. */
  12570. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12571. }
  12572. }
  12573. declare module BABYLON {
  12574. interface ThinEngine {
  12575. /**
  12576. * Sets alpha constants used by some alpha blending modes
  12577. * @param r defines the red component
  12578. * @param g defines the green component
  12579. * @param b defines the blue component
  12580. * @param a defines the alpha component
  12581. */
  12582. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12583. /**
  12584. * Sets the current alpha mode
  12585. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12586. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12587. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12588. */
  12589. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12590. /**
  12591. * Gets the current alpha mode
  12592. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12593. * @returns the current alpha mode
  12594. */
  12595. getAlphaMode(): number;
  12596. /**
  12597. * Sets the current alpha equation
  12598. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12599. */
  12600. setAlphaEquation(equation: number): void;
  12601. /**
  12602. * Gets the current alpha equation.
  12603. * @returns the current alpha equation
  12604. */
  12605. getAlphaEquation(): number;
  12606. }
  12607. }
  12608. declare module BABYLON {
  12609. /**
  12610. * This represents a particle system in Babylon.
  12611. * 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.
  12612. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12613. * @example https://doc.babylonjs.com/babylon101/particles
  12614. */
  12615. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12616. /**
  12617. * Billboard mode will only apply to Y axis
  12618. */
  12619. static readonly BILLBOARDMODE_Y: number;
  12620. /**
  12621. * Billboard mode will apply to all axes
  12622. */
  12623. static readonly BILLBOARDMODE_ALL: number;
  12624. /**
  12625. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12626. */
  12627. static readonly BILLBOARDMODE_STRETCHED: number;
  12628. /**
  12629. * This function can be defined to provide custom update for active particles.
  12630. * This function will be called instead of regular update (age, position, color, etc.).
  12631. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12632. */
  12633. updateFunction: (particles: Particle[]) => void;
  12634. private _emitterWorldMatrix;
  12635. /**
  12636. * This function can be defined to specify initial direction for every new particle.
  12637. * It by default use the emitterType defined function
  12638. */
  12639. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12640. /**
  12641. * This function can be defined to specify initial position for every new particle.
  12642. * It by default use the emitterType defined function
  12643. */
  12644. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12645. /**
  12646. * @hidden
  12647. */
  12648. _inheritedVelocityOffset: Vector3;
  12649. /**
  12650. * An event triggered when the system is disposed
  12651. */
  12652. onDisposeObservable: Observable<IParticleSystem>;
  12653. /**
  12654. * An event triggered when the system is stopped
  12655. */
  12656. onStoppedObservable: Observable<IParticleSystem>;
  12657. private _onDisposeObserver;
  12658. /**
  12659. * Sets a callback that will be triggered when the system is disposed
  12660. */
  12661. set onDispose(callback: () => void);
  12662. private _particles;
  12663. private _epsilon;
  12664. private _capacity;
  12665. private _stockParticles;
  12666. private _newPartsExcess;
  12667. private _vertexData;
  12668. private _vertexBuffer;
  12669. private _vertexBuffers;
  12670. private _spriteBuffer;
  12671. private _indexBuffer;
  12672. private _effect;
  12673. private _customEffect;
  12674. private _cachedDefines;
  12675. private _scaledColorStep;
  12676. private _colorDiff;
  12677. private _scaledDirection;
  12678. private _scaledGravity;
  12679. private _currentRenderId;
  12680. private _alive;
  12681. private _useInstancing;
  12682. private _started;
  12683. private _stopped;
  12684. private _actualFrame;
  12685. private _scaledUpdateSpeed;
  12686. private _vertexBufferSize;
  12687. /** @hidden */
  12688. _currentEmitRateGradient: Nullable<FactorGradient>;
  12689. /** @hidden */
  12690. _currentEmitRate1: number;
  12691. /** @hidden */
  12692. _currentEmitRate2: number;
  12693. /** @hidden */
  12694. _currentStartSizeGradient: Nullable<FactorGradient>;
  12695. /** @hidden */
  12696. _currentStartSize1: number;
  12697. /** @hidden */
  12698. _currentStartSize2: number;
  12699. private readonly _rawTextureWidth;
  12700. private _rampGradientsTexture;
  12701. private _useRampGradients;
  12702. /** Gets or sets a matrix to use to compute projection */
  12703. defaultProjectionMatrix: Matrix;
  12704. /** Gets or sets a matrix to use to compute view */
  12705. defaultViewMatrix: Matrix;
  12706. /** Gets or sets a boolean indicating that ramp gradients must be used
  12707. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12708. */
  12709. get useRampGradients(): boolean;
  12710. set useRampGradients(value: boolean);
  12711. /**
  12712. * 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.
  12713. * 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: [])
  12714. */
  12715. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12716. private _subEmitters;
  12717. /**
  12718. * @hidden
  12719. * If the particle systems emitter should be disposed when the particle system is disposed
  12720. */
  12721. _disposeEmitterOnDispose: boolean;
  12722. /**
  12723. * The current active Sub-systems, this property is used by the root particle system only.
  12724. */
  12725. activeSubSystems: Array<ParticleSystem>;
  12726. /**
  12727. * Specifies if the particles are updated in emitter local space or world space
  12728. */
  12729. isLocal: boolean;
  12730. private _rootParticleSystem;
  12731. /**
  12732. * Gets the current list of active particles
  12733. */
  12734. get particles(): Particle[];
  12735. /**
  12736. * Gets the number of particles active at the same time.
  12737. * @returns The number of active particles.
  12738. */
  12739. getActiveCount(): number;
  12740. /**
  12741. * Returns the string "ParticleSystem"
  12742. * @returns a string containing the class name
  12743. */
  12744. getClassName(): string;
  12745. /**
  12746. * Gets a boolean indicating that the system is stopping
  12747. * @returns true if the system is currently stopping
  12748. */
  12749. isStopping(): boolean;
  12750. /**
  12751. * Gets the custom effect used to render the particles
  12752. * @param blendMode Blend mode for which the effect should be retrieved
  12753. * @returns The effect
  12754. */
  12755. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12756. /**
  12757. * Sets the custom effect used to render the particles
  12758. * @param effect The effect to set
  12759. * @param blendMode Blend mode for which the effect should be set
  12760. */
  12761. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12762. /** @hidden */
  12763. private _onBeforeDrawParticlesObservable;
  12764. /**
  12765. * Observable that will be called just before the particles are drawn
  12766. */
  12767. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12768. /**
  12769. * Gets the name of the particle vertex shader
  12770. */
  12771. get vertexShaderName(): string;
  12772. /**
  12773. * Instantiates a particle system.
  12774. * 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.
  12775. * @param name The name of the particle system
  12776. * @param capacity The max number of particles alive at the same time
  12777. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12778. * @param customEffect a custom effect used to change the way particles are rendered by default
  12779. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12780. * @param epsilon Offset used to render the particles
  12781. */
  12782. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12783. private _addFactorGradient;
  12784. private _removeFactorGradient;
  12785. /**
  12786. * Adds a new life time gradient
  12787. * @param gradient defines the gradient to use (between 0 and 1)
  12788. * @param factor defines the life time factor to affect to the specified gradient
  12789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12790. * @returns the current particle system
  12791. */
  12792. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12793. /**
  12794. * Remove a specific life time gradient
  12795. * @param gradient defines the gradient to remove
  12796. * @returns the current particle system
  12797. */
  12798. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12799. /**
  12800. * Adds a new size gradient
  12801. * @param gradient defines the gradient to use (between 0 and 1)
  12802. * @param factor defines the size factor to affect to the specified gradient
  12803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12804. * @returns the current particle system
  12805. */
  12806. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12807. /**
  12808. * Remove a specific size gradient
  12809. * @param gradient defines the gradient to remove
  12810. * @returns the current particle system
  12811. */
  12812. removeSizeGradient(gradient: number): IParticleSystem;
  12813. /**
  12814. * Adds a new color remap gradient
  12815. * @param gradient defines the gradient to use (between 0 and 1)
  12816. * @param min defines the color remap minimal range
  12817. * @param max defines the color remap maximal range
  12818. * @returns the current particle system
  12819. */
  12820. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12821. /**
  12822. * Remove a specific color remap gradient
  12823. * @param gradient defines the gradient to remove
  12824. * @returns the current particle system
  12825. */
  12826. removeColorRemapGradient(gradient: number): IParticleSystem;
  12827. /**
  12828. * Adds a new alpha remap gradient
  12829. * @param gradient defines the gradient to use (between 0 and 1)
  12830. * @param min defines the alpha remap minimal range
  12831. * @param max defines the alpha remap maximal range
  12832. * @returns the current particle system
  12833. */
  12834. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12835. /**
  12836. * Remove a specific alpha remap gradient
  12837. * @param gradient defines the gradient to remove
  12838. * @returns the current particle system
  12839. */
  12840. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12841. /**
  12842. * Adds a new angular speed gradient
  12843. * @param gradient defines the gradient to use (between 0 and 1)
  12844. * @param factor defines the angular speed to affect to the specified gradient
  12845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12846. * @returns the current particle system
  12847. */
  12848. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12849. /**
  12850. * Remove a specific angular speed gradient
  12851. * @param gradient defines the gradient to remove
  12852. * @returns the current particle system
  12853. */
  12854. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12855. /**
  12856. * Adds a new velocity gradient
  12857. * @param gradient defines the gradient to use (between 0 and 1)
  12858. * @param factor defines the velocity to affect to the specified gradient
  12859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12860. * @returns the current particle system
  12861. */
  12862. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12863. /**
  12864. * Remove a specific velocity gradient
  12865. * @param gradient defines the gradient to remove
  12866. * @returns the current particle system
  12867. */
  12868. removeVelocityGradient(gradient: number): IParticleSystem;
  12869. /**
  12870. * Adds a new limit velocity gradient
  12871. * @param gradient defines the gradient to use (between 0 and 1)
  12872. * @param factor defines the limit velocity value to affect to the specified gradient
  12873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12874. * @returns the current particle system
  12875. */
  12876. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12877. /**
  12878. * Remove a specific limit velocity gradient
  12879. * @param gradient defines the gradient to remove
  12880. * @returns the current particle system
  12881. */
  12882. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12883. /**
  12884. * Adds a new drag gradient
  12885. * @param gradient defines the gradient to use (between 0 and 1)
  12886. * @param factor defines the drag value to affect to the specified gradient
  12887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12888. * @returns the current particle system
  12889. */
  12890. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12891. /**
  12892. * Remove a specific drag gradient
  12893. * @param gradient defines the gradient to remove
  12894. * @returns the current particle system
  12895. */
  12896. removeDragGradient(gradient: number): IParticleSystem;
  12897. /**
  12898. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12899. * @param gradient defines the gradient to use (between 0 and 1)
  12900. * @param factor defines the emit rate value to affect to the specified gradient
  12901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12902. * @returns the current particle system
  12903. */
  12904. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12905. /**
  12906. * Remove a specific emit rate gradient
  12907. * @param gradient defines the gradient to remove
  12908. * @returns the current particle system
  12909. */
  12910. removeEmitRateGradient(gradient: number): IParticleSystem;
  12911. /**
  12912. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12913. * @param gradient defines the gradient to use (between 0 and 1)
  12914. * @param factor defines the start size value to affect to the specified gradient
  12915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12916. * @returns the current particle system
  12917. */
  12918. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12919. /**
  12920. * Remove a specific start size gradient
  12921. * @param gradient defines the gradient to remove
  12922. * @returns the current particle system
  12923. */
  12924. removeStartSizeGradient(gradient: number): IParticleSystem;
  12925. private _createRampGradientTexture;
  12926. /**
  12927. * Gets the current list of ramp gradients.
  12928. * You must use addRampGradient and removeRampGradient to udpate this list
  12929. * @returns the list of ramp gradients
  12930. */
  12931. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12932. /** Force the system to rebuild all gradients that need to be resync */
  12933. forceRefreshGradients(): void;
  12934. private _syncRampGradientTexture;
  12935. /**
  12936. * Adds a new ramp gradient used to remap particle colors
  12937. * @param gradient defines the gradient to use (between 0 and 1)
  12938. * @param color defines the color to affect to the specified gradient
  12939. * @returns the current particle system
  12940. */
  12941. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12942. /**
  12943. * Remove a specific ramp gradient
  12944. * @param gradient defines the gradient to remove
  12945. * @returns the current particle system
  12946. */
  12947. removeRampGradient(gradient: number): ParticleSystem;
  12948. /**
  12949. * Adds a new color gradient
  12950. * @param gradient defines the gradient to use (between 0 and 1)
  12951. * @param color1 defines the color to affect to the specified gradient
  12952. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12953. * @returns this particle system
  12954. */
  12955. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12956. /**
  12957. * Remove a specific color gradient
  12958. * @param gradient defines the gradient to remove
  12959. * @returns this particle system
  12960. */
  12961. removeColorGradient(gradient: number): IParticleSystem;
  12962. private _fetchR;
  12963. protected _reset(): void;
  12964. private _resetEffect;
  12965. private _createVertexBuffers;
  12966. private _createIndexBuffer;
  12967. /**
  12968. * Gets the maximum number of particles active at the same time.
  12969. * @returns The max number of active particles.
  12970. */
  12971. getCapacity(): number;
  12972. /**
  12973. * Gets whether there are still active particles in the system.
  12974. * @returns True if it is alive, otherwise false.
  12975. */
  12976. isAlive(): boolean;
  12977. /**
  12978. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12979. * @returns True if it has been started, otherwise false.
  12980. */
  12981. isStarted(): boolean;
  12982. private _prepareSubEmitterInternalArray;
  12983. /**
  12984. * Starts the particle system and begins to emit
  12985. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12986. */
  12987. start(delay?: number): void;
  12988. /**
  12989. * Stops the particle system.
  12990. * @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.
  12991. */
  12992. stop(stopSubEmitters?: boolean): void;
  12993. /**
  12994. * Remove all active particles
  12995. */
  12996. reset(): void;
  12997. /**
  12998. * @hidden (for internal use only)
  12999. */
  13000. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13001. /**
  13002. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13003. * Its lifetime will start back at 0.
  13004. */
  13005. recycleParticle: (particle: Particle) => void;
  13006. private _stopSubEmitters;
  13007. private _createParticle;
  13008. private _removeFromRoot;
  13009. private _emitFromParticle;
  13010. private _update;
  13011. /** @hidden */
  13012. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13013. /** @hidden */
  13014. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13015. /**
  13016. * Fill the defines array according to the current settings of the particle system
  13017. * @param defines Array to be updated
  13018. * @param blendMode blend mode to take into account when updating the array
  13019. */
  13020. fillDefines(defines: Array<string>, blendMode: number): void;
  13021. /**
  13022. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13023. * @param uniforms Uniforms array to fill
  13024. * @param attributes Attributes array to fill
  13025. * @param samplers Samplers array to fill
  13026. */
  13027. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13028. /** @hidden */
  13029. private _getEffect;
  13030. /**
  13031. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13032. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13033. */
  13034. animate(preWarmOnly?: boolean): void;
  13035. private _appendParticleVertices;
  13036. /**
  13037. * Rebuilds the particle system.
  13038. */
  13039. rebuild(): void;
  13040. /**
  13041. * Is this system ready to be used/rendered
  13042. * @return true if the system is ready
  13043. */
  13044. isReady(): boolean;
  13045. private _render;
  13046. /**
  13047. * Renders the particle system in its current state.
  13048. * @returns the current number of particles
  13049. */
  13050. render(): number;
  13051. /**
  13052. * Disposes the particle system and free the associated resources
  13053. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13054. */
  13055. dispose(disposeTexture?: boolean): void;
  13056. /**
  13057. * Clones the particle system.
  13058. * @param name The name of the cloned object
  13059. * @param newEmitter The new emitter to use
  13060. * @returns the cloned particle system
  13061. */
  13062. clone(name: string, newEmitter: any): ParticleSystem;
  13063. /**
  13064. * Serializes the particle system to a JSON object
  13065. * @param serializeTexture defines if the texture must be serialized as well
  13066. * @returns the JSON object
  13067. */
  13068. serialize(serializeTexture?: boolean): any;
  13069. /** @hidden */
  13070. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13071. /** @hidden */
  13072. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13073. /**
  13074. * Parses a JSON object to create a particle system.
  13075. * @param parsedParticleSystem The JSON object to parse
  13076. * @param sceneOrEngine The scene or the engine to create the particle system in
  13077. * @param rootUrl The root url to use to load external dependencies like texture
  13078. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13079. * @returns the Parsed particle system
  13080. */
  13081. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13082. }
  13083. }
  13084. declare module BABYLON {
  13085. /**
  13086. * A particle represents one of the element emitted by a particle system.
  13087. * This is mainly define by its coordinates, direction, velocity and age.
  13088. */
  13089. export class Particle {
  13090. /**
  13091. * The particle system the particle belongs to.
  13092. */
  13093. particleSystem: ParticleSystem;
  13094. private static _Count;
  13095. /**
  13096. * Unique ID of the particle
  13097. */
  13098. id: number;
  13099. /**
  13100. * The world position of the particle in the scene.
  13101. */
  13102. position: Vector3;
  13103. /**
  13104. * The world direction of the particle in the scene.
  13105. */
  13106. direction: Vector3;
  13107. /**
  13108. * The color of the particle.
  13109. */
  13110. color: Color4;
  13111. /**
  13112. * The color change of the particle per step.
  13113. */
  13114. colorStep: Color4;
  13115. /**
  13116. * Defines how long will the life of the particle be.
  13117. */
  13118. lifeTime: number;
  13119. /**
  13120. * The current age of the particle.
  13121. */
  13122. age: number;
  13123. /**
  13124. * The current size of the particle.
  13125. */
  13126. size: number;
  13127. /**
  13128. * The current scale of the particle.
  13129. */
  13130. scale: Vector2;
  13131. /**
  13132. * The current angle of the particle.
  13133. */
  13134. angle: number;
  13135. /**
  13136. * Defines how fast is the angle changing.
  13137. */
  13138. angularSpeed: number;
  13139. /**
  13140. * Defines the cell index used by the particle to be rendered from a sprite.
  13141. */
  13142. cellIndex: number;
  13143. /**
  13144. * The information required to support color remapping
  13145. */
  13146. remapData: Vector4;
  13147. /** @hidden */
  13148. _randomCellOffset?: number;
  13149. /** @hidden */
  13150. _initialDirection: Nullable<Vector3>;
  13151. /** @hidden */
  13152. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13153. /** @hidden */
  13154. _initialStartSpriteCellID: number;
  13155. /** @hidden */
  13156. _initialEndSpriteCellID: number;
  13157. /** @hidden */
  13158. _currentColorGradient: Nullable<ColorGradient>;
  13159. /** @hidden */
  13160. _currentColor1: Color4;
  13161. /** @hidden */
  13162. _currentColor2: Color4;
  13163. /** @hidden */
  13164. _currentSizeGradient: Nullable<FactorGradient>;
  13165. /** @hidden */
  13166. _currentSize1: number;
  13167. /** @hidden */
  13168. _currentSize2: number;
  13169. /** @hidden */
  13170. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13171. /** @hidden */
  13172. _currentAngularSpeed1: number;
  13173. /** @hidden */
  13174. _currentAngularSpeed2: number;
  13175. /** @hidden */
  13176. _currentVelocityGradient: Nullable<FactorGradient>;
  13177. /** @hidden */
  13178. _currentVelocity1: number;
  13179. /** @hidden */
  13180. _currentVelocity2: number;
  13181. /** @hidden */
  13182. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13183. /** @hidden */
  13184. _currentLimitVelocity1: number;
  13185. /** @hidden */
  13186. _currentLimitVelocity2: number;
  13187. /** @hidden */
  13188. _currentDragGradient: Nullable<FactorGradient>;
  13189. /** @hidden */
  13190. _currentDrag1: number;
  13191. /** @hidden */
  13192. _currentDrag2: number;
  13193. /** @hidden */
  13194. _randomNoiseCoordinates1: Vector3;
  13195. /** @hidden */
  13196. _randomNoiseCoordinates2: Vector3;
  13197. /** @hidden */
  13198. _localPosition?: Vector3;
  13199. /**
  13200. * Creates a new instance Particle
  13201. * @param particleSystem the particle system the particle belongs to
  13202. */
  13203. constructor(
  13204. /**
  13205. * The particle system the particle belongs to.
  13206. */
  13207. particleSystem: ParticleSystem);
  13208. private updateCellInfoFromSystem;
  13209. /**
  13210. * Defines how the sprite cell index is updated for the particle
  13211. */
  13212. updateCellIndex(): void;
  13213. /** @hidden */
  13214. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13215. /** @hidden */
  13216. _inheritParticleInfoToSubEmitters(): void;
  13217. /** @hidden */
  13218. _reset(): void;
  13219. /**
  13220. * Copy the properties of particle to another one.
  13221. * @param other the particle to copy the information to.
  13222. */
  13223. copyTo(other: Particle): void;
  13224. }
  13225. }
  13226. declare module BABYLON {
  13227. /**
  13228. * Particle emitter represents a volume emitting particles.
  13229. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13230. */
  13231. export interface IParticleEmitterType {
  13232. /**
  13233. * Called by the particle System when the direction is computed for the created particle.
  13234. * @param worldMatrix is the world matrix of the particle system
  13235. * @param directionToUpdate is the direction vector to update with the result
  13236. * @param particle is the particle we are computed the direction for
  13237. * @param isLocal defines if the direction should be set in local space
  13238. */
  13239. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13240. /**
  13241. * Called by the particle System when the position is computed for the created particle.
  13242. * @param worldMatrix is the world matrix of the particle system
  13243. * @param positionToUpdate is the position vector to update with the result
  13244. * @param particle is the particle we are computed the position for
  13245. * @param isLocal defines if the position should be set in local space
  13246. */
  13247. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13248. /**
  13249. * Clones the current emitter and returns a copy of it
  13250. * @returns the new emitter
  13251. */
  13252. clone(): IParticleEmitterType;
  13253. /**
  13254. * Called by the GPUParticleSystem to setup the update shader
  13255. * @param effect defines the update shader
  13256. */
  13257. applyToShader(effect: Effect): void;
  13258. /**
  13259. * Returns a string to use to update the GPU particles update shader
  13260. * @returns the effect defines string
  13261. */
  13262. getEffectDefines(): string;
  13263. /**
  13264. * Returns a string representing the class name
  13265. * @returns a string containing the class name
  13266. */
  13267. getClassName(): string;
  13268. /**
  13269. * Serializes the particle system to a JSON object.
  13270. * @returns the JSON object
  13271. */
  13272. serialize(): any;
  13273. /**
  13274. * Parse properties from a JSON object
  13275. * @param serializationObject defines the JSON object
  13276. * @param scene defines the hosting scene
  13277. */
  13278. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13279. }
  13280. }
  13281. declare module BABYLON {
  13282. /**
  13283. * Particle emitter emitting particles from the inside of a box.
  13284. * It emits the particles randomly between 2 given directions.
  13285. */
  13286. export class BoxParticleEmitter implements IParticleEmitterType {
  13287. /**
  13288. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13289. */
  13290. direction1: Vector3;
  13291. /**
  13292. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13293. */
  13294. direction2: Vector3;
  13295. /**
  13296. * 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.
  13297. */
  13298. minEmitBox: Vector3;
  13299. /**
  13300. * 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.
  13301. */
  13302. maxEmitBox: Vector3;
  13303. /**
  13304. * Creates a new instance BoxParticleEmitter
  13305. */
  13306. constructor();
  13307. /**
  13308. * Called by the particle System when the direction is computed for the created particle.
  13309. * @param worldMatrix is the world matrix of the particle system
  13310. * @param directionToUpdate is the direction vector to update with the result
  13311. * @param particle is the particle we are computed the direction for
  13312. * @param isLocal defines if the direction should be set in local space
  13313. */
  13314. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13315. /**
  13316. * Called by the particle System when the position is computed for the created particle.
  13317. * @param worldMatrix is the world matrix of the particle system
  13318. * @param positionToUpdate is the position vector to update with the result
  13319. * @param particle is the particle we are computed the position for
  13320. * @param isLocal defines if the position should be set in local space
  13321. */
  13322. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13323. /**
  13324. * Clones the current emitter and returns a copy of it
  13325. * @returns the new emitter
  13326. */
  13327. clone(): BoxParticleEmitter;
  13328. /**
  13329. * Called by the GPUParticleSystem to setup the update shader
  13330. * @param effect defines the update shader
  13331. */
  13332. applyToShader(effect: Effect): void;
  13333. /**
  13334. * Returns a string to use to update the GPU particles update shader
  13335. * @returns a string containng the defines string
  13336. */
  13337. getEffectDefines(): string;
  13338. /**
  13339. * Returns the string "BoxParticleEmitter"
  13340. * @returns a string containing the class name
  13341. */
  13342. getClassName(): string;
  13343. /**
  13344. * Serializes the particle system to a JSON object.
  13345. * @returns the JSON object
  13346. */
  13347. serialize(): any;
  13348. /**
  13349. * Parse properties from a JSON object
  13350. * @param serializationObject defines the JSON object
  13351. */
  13352. parse(serializationObject: any): void;
  13353. }
  13354. }
  13355. declare module BABYLON {
  13356. /**
  13357. * Particle emitter emitting particles from the inside of a cone.
  13358. * It emits the particles alongside the cone volume from the base to the particle.
  13359. * The emission direction might be randomized.
  13360. */
  13361. export class ConeParticleEmitter implements IParticleEmitterType {
  13362. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13363. directionRandomizer: number;
  13364. private _radius;
  13365. private _angle;
  13366. private _height;
  13367. /**
  13368. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13369. */
  13370. radiusRange: number;
  13371. /**
  13372. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13373. */
  13374. heightRange: number;
  13375. /**
  13376. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13377. */
  13378. emitFromSpawnPointOnly: boolean;
  13379. /**
  13380. * Gets or sets the radius of the emission cone
  13381. */
  13382. get radius(): number;
  13383. set radius(value: number);
  13384. /**
  13385. * Gets or sets the angle of the emission cone
  13386. */
  13387. get angle(): number;
  13388. set angle(value: number);
  13389. private _buildHeight;
  13390. /**
  13391. * Creates a new instance ConeParticleEmitter
  13392. * @param radius the radius of the emission cone (1 by default)
  13393. * @param angle the cone base angle (PI by default)
  13394. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13395. */
  13396. constructor(radius?: number, angle?: number,
  13397. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13398. directionRandomizer?: number);
  13399. /**
  13400. * Called by the particle System when the direction is computed for the created particle.
  13401. * @param worldMatrix is the world matrix of the particle system
  13402. * @param directionToUpdate is the direction vector to update with the result
  13403. * @param particle is the particle we are computed the direction for
  13404. * @param isLocal defines if the direction should be set in local space
  13405. */
  13406. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13407. /**
  13408. * Called by the particle System when the position is computed for the created particle.
  13409. * @param worldMatrix is the world matrix of the particle system
  13410. * @param positionToUpdate is the position vector to update with the result
  13411. * @param particle is the particle we are computed the position for
  13412. * @param isLocal defines if the position should be set in local space
  13413. */
  13414. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13415. /**
  13416. * Clones the current emitter and returns a copy of it
  13417. * @returns the new emitter
  13418. */
  13419. clone(): ConeParticleEmitter;
  13420. /**
  13421. * Called by the GPUParticleSystem to setup the update shader
  13422. * @param effect defines the update shader
  13423. */
  13424. applyToShader(effect: Effect): void;
  13425. /**
  13426. * Returns a string to use to update the GPU particles update shader
  13427. * @returns a string containng the defines string
  13428. */
  13429. getEffectDefines(): string;
  13430. /**
  13431. * Returns the string "ConeParticleEmitter"
  13432. * @returns a string containing the class name
  13433. */
  13434. getClassName(): string;
  13435. /**
  13436. * Serializes the particle system to a JSON object.
  13437. * @returns the JSON object
  13438. */
  13439. serialize(): any;
  13440. /**
  13441. * Parse properties from a JSON object
  13442. * @param serializationObject defines the JSON object
  13443. */
  13444. parse(serializationObject: any): void;
  13445. }
  13446. }
  13447. declare module BABYLON {
  13448. /**
  13449. * Particle emitter emitting particles from the inside of a cylinder.
  13450. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13451. */
  13452. export class CylinderParticleEmitter implements IParticleEmitterType {
  13453. /**
  13454. * The radius of the emission cylinder.
  13455. */
  13456. radius: number;
  13457. /**
  13458. * The height of the emission cylinder.
  13459. */
  13460. height: number;
  13461. /**
  13462. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13463. */
  13464. radiusRange: number;
  13465. /**
  13466. * How much to randomize the particle direction [0-1].
  13467. */
  13468. directionRandomizer: number;
  13469. /**
  13470. * Creates a new instance CylinderParticleEmitter
  13471. * @param radius the radius of the emission cylinder (1 by default)
  13472. * @param height the height of the emission cylinder (1 by default)
  13473. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13474. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13475. */
  13476. constructor(
  13477. /**
  13478. * The radius of the emission cylinder.
  13479. */
  13480. radius?: number,
  13481. /**
  13482. * The height of the emission cylinder.
  13483. */
  13484. height?: number,
  13485. /**
  13486. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13487. */
  13488. radiusRange?: number,
  13489. /**
  13490. * How much to randomize the particle direction [0-1].
  13491. */
  13492. directionRandomizer?: number);
  13493. /**
  13494. * Called by the particle System when the direction is computed for the created particle.
  13495. * @param worldMatrix is the world matrix of the particle system
  13496. * @param directionToUpdate is the direction vector to update with the result
  13497. * @param particle is the particle we are computed the direction for
  13498. * @param isLocal defines if the direction should be set in local space
  13499. */
  13500. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13501. /**
  13502. * Called by the particle System when the position is computed for the created particle.
  13503. * @param worldMatrix is the world matrix of the particle system
  13504. * @param positionToUpdate is the position vector to update with the result
  13505. * @param particle is the particle we are computed the position for
  13506. * @param isLocal defines if the position should be set in local space
  13507. */
  13508. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13509. /**
  13510. * Clones the current emitter and returns a copy of it
  13511. * @returns the new emitter
  13512. */
  13513. clone(): CylinderParticleEmitter;
  13514. /**
  13515. * Called by the GPUParticleSystem to setup the update shader
  13516. * @param effect defines the update shader
  13517. */
  13518. applyToShader(effect: Effect): void;
  13519. /**
  13520. * Returns a string to use to update the GPU particles update shader
  13521. * @returns a string containng the defines string
  13522. */
  13523. getEffectDefines(): string;
  13524. /**
  13525. * Returns the string "CylinderParticleEmitter"
  13526. * @returns a string containing the class name
  13527. */
  13528. getClassName(): string;
  13529. /**
  13530. * Serializes the particle system to a JSON object.
  13531. * @returns the JSON object
  13532. */
  13533. serialize(): any;
  13534. /**
  13535. * Parse properties from a JSON object
  13536. * @param serializationObject defines the JSON object
  13537. */
  13538. parse(serializationObject: any): void;
  13539. }
  13540. /**
  13541. * Particle emitter emitting particles from the inside of a cylinder.
  13542. * It emits the particles randomly between two vectors.
  13543. */
  13544. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13545. /**
  13546. * The min limit of the emission direction.
  13547. */
  13548. direction1: Vector3;
  13549. /**
  13550. * The max limit of the emission direction.
  13551. */
  13552. direction2: Vector3;
  13553. /**
  13554. * Creates a new instance CylinderDirectedParticleEmitter
  13555. * @param radius the radius of the emission cylinder (1 by default)
  13556. * @param height the height of the emission cylinder (1 by default)
  13557. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13558. * @param direction1 the min limit of the emission direction (up vector by default)
  13559. * @param direction2 the max limit of the emission direction (up vector by default)
  13560. */
  13561. constructor(radius?: number, height?: number, radiusRange?: number,
  13562. /**
  13563. * The min limit of the emission direction.
  13564. */
  13565. direction1?: Vector3,
  13566. /**
  13567. * The max limit of the emission direction.
  13568. */
  13569. direction2?: Vector3);
  13570. /**
  13571. * Called by the particle System when the direction is computed for the created particle.
  13572. * @param worldMatrix is the world matrix of the particle system
  13573. * @param directionToUpdate is the direction vector to update with the result
  13574. * @param particle is the particle we are computed the direction for
  13575. */
  13576. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13577. /**
  13578. * Clones the current emitter and returns a copy of it
  13579. * @returns the new emitter
  13580. */
  13581. clone(): CylinderDirectedParticleEmitter;
  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 "CylinderDirectedParticleEmitter"
  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 the inside of a hemisphere.
  13612. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13613. */
  13614. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13615. /**
  13616. * The radius of the emission hemisphere.
  13617. */
  13618. radius: number;
  13619. /**
  13620. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13621. */
  13622. radiusRange: number;
  13623. /**
  13624. * How much to randomize the particle direction [0-1].
  13625. */
  13626. directionRandomizer: number;
  13627. /**
  13628. * Creates a new instance HemisphericParticleEmitter
  13629. * @param radius the radius of the emission hemisphere (1 by default)
  13630. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13631. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13632. */
  13633. constructor(
  13634. /**
  13635. * The radius of the emission hemisphere.
  13636. */
  13637. radius?: number,
  13638. /**
  13639. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13640. */
  13641. radiusRange?: number,
  13642. /**
  13643. * How much to randomize the particle direction [0-1].
  13644. */
  13645. directionRandomizer?: number);
  13646. /**
  13647. * Called by the particle System when the direction is computed for the created particle.
  13648. * @param worldMatrix is the world matrix of the particle system
  13649. * @param directionToUpdate is the direction vector to update with the result
  13650. * @param particle is the particle we are computed the direction for
  13651. * @param isLocal defines if the direction should be set in local space
  13652. */
  13653. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13654. /**
  13655. * Called by the particle System when the position is computed for the created particle.
  13656. * @param worldMatrix is the world matrix of the particle system
  13657. * @param positionToUpdate is the position vector to update with the result
  13658. * @param particle is the particle we are computed the position for
  13659. * @param isLocal defines if the position should be set in local space
  13660. */
  13661. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13662. /**
  13663. * Clones the current emitter and returns a copy of it
  13664. * @returns the new emitter
  13665. */
  13666. clone(): HemisphericParticleEmitter;
  13667. /**
  13668. * Called by the GPUParticleSystem to setup the update shader
  13669. * @param effect defines the update shader
  13670. */
  13671. applyToShader(effect: Effect): void;
  13672. /**
  13673. * Returns a string to use to update the GPU particles update shader
  13674. * @returns a string containng the defines string
  13675. */
  13676. getEffectDefines(): string;
  13677. /**
  13678. * Returns the string "HemisphericParticleEmitter"
  13679. * @returns a string containing the class name
  13680. */
  13681. getClassName(): string;
  13682. /**
  13683. * Serializes the particle system to a JSON object.
  13684. * @returns the JSON object
  13685. */
  13686. serialize(): any;
  13687. /**
  13688. * Parse properties from a JSON object
  13689. * @param serializationObject defines the JSON object
  13690. */
  13691. parse(serializationObject: any): void;
  13692. }
  13693. }
  13694. declare module BABYLON {
  13695. /**
  13696. * Particle emitter emitting particles from a point.
  13697. * It emits the particles randomly between 2 given directions.
  13698. */
  13699. export class PointParticleEmitter implements IParticleEmitterType {
  13700. /**
  13701. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13702. */
  13703. direction1: Vector3;
  13704. /**
  13705. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13706. */
  13707. direction2: Vector3;
  13708. /**
  13709. * Creates a new instance PointParticleEmitter
  13710. */
  13711. constructor();
  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(): PointParticleEmitter;
  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 "PointParticleEmitter"
  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. declare module BABYLON {
  13761. /**
  13762. * Particle emitter emitting particles from the inside of a sphere.
  13763. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13764. */
  13765. export class SphereParticleEmitter implements IParticleEmitterType {
  13766. /**
  13767. * The radius of the emission sphere.
  13768. */
  13769. radius: number;
  13770. /**
  13771. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13772. */
  13773. radiusRange: number;
  13774. /**
  13775. * How much to randomize the particle direction [0-1].
  13776. */
  13777. directionRandomizer: number;
  13778. /**
  13779. * Creates a new instance SphereParticleEmitter
  13780. * @param radius the radius of the emission sphere (1 by default)
  13781. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13782. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13783. */
  13784. constructor(
  13785. /**
  13786. * The radius of the emission sphere.
  13787. */
  13788. radius?: number,
  13789. /**
  13790. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13791. */
  13792. radiusRange?: number,
  13793. /**
  13794. * How much to randomize the particle direction [0-1].
  13795. */
  13796. directionRandomizer?: number);
  13797. /**
  13798. * Called by the particle System when the direction is computed for the created particle.
  13799. * @param worldMatrix is the world matrix of the particle system
  13800. * @param directionToUpdate is the direction vector to update with the result
  13801. * @param particle is the particle we are computed the direction for
  13802. * @param isLocal defines if the direction should be set in local space
  13803. */
  13804. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13805. /**
  13806. * Called by the particle System when the position is computed for the created particle.
  13807. * @param worldMatrix is the world matrix of the particle system
  13808. * @param positionToUpdate is the position vector to update with the result
  13809. * @param particle is the particle we are computed the position for
  13810. * @param isLocal defines if the position should be set in local space
  13811. */
  13812. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13813. /**
  13814. * Clones the current emitter and returns a copy of it
  13815. * @returns the new emitter
  13816. */
  13817. clone(): SphereParticleEmitter;
  13818. /**
  13819. * Called by the GPUParticleSystem to setup the update shader
  13820. * @param effect defines the update shader
  13821. */
  13822. applyToShader(effect: Effect): void;
  13823. /**
  13824. * Returns a string to use to update the GPU particles update shader
  13825. * @returns a string containng the defines string
  13826. */
  13827. getEffectDefines(): string;
  13828. /**
  13829. * Returns the string "SphereParticleEmitter"
  13830. * @returns a string containing the class name
  13831. */
  13832. getClassName(): string;
  13833. /**
  13834. * Serializes the particle system to a JSON object.
  13835. * @returns the JSON object
  13836. */
  13837. serialize(): any;
  13838. /**
  13839. * Parse properties from a JSON object
  13840. * @param serializationObject defines the JSON object
  13841. */
  13842. parse(serializationObject: any): void;
  13843. }
  13844. /**
  13845. * Particle emitter emitting particles from the inside of a sphere.
  13846. * It emits the particles randomly between two vectors.
  13847. */
  13848. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13849. /**
  13850. * The min limit of the emission direction.
  13851. */
  13852. direction1: Vector3;
  13853. /**
  13854. * The max limit of the emission direction.
  13855. */
  13856. direction2: Vector3;
  13857. /**
  13858. * Creates a new instance SphereDirectedParticleEmitter
  13859. * @param radius the radius of the emission sphere (1 by default)
  13860. * @param direction1 the min limit of the emission direction (up vector by default)
  13861. * @param direction2 the max limit of the emission direction (up vector by default)
  13862. */
  13863. constructor(radius?: number,
  13864. /**
  13865. * The min limit of the emission direction.
  13866. */
  13867. direction1?: Vector3,
  13868. /**
  13869. * The max limit of the emission direction.
  13870. */
  13871. direction2?: Vector3);
  13872. /**
  13873. * Called by the particle System when the direction is computed for the created particle.
  13874. * @param worldMatrix is the world matrix of the particle system
  13875. * @param directionToUpdate is the direction vector to update with the result
  13876. * @param particle is the particle we are computed the direction for
  13877. */
  13878. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13879. /**
  13880. * Clones the current emitter and returns a copy of it
  13881. * @returns the new emitter
  13882. */
  13883. clone(): SphereDirectedParticleEmitter;
  13884. /**
  13885. * Called by the GPUParticleSystem to setup the update shader
  13886. * @param effect defines the update shader
  13887. */
  13888. applyToShader(effect: Effect): void;
  13889. /**
  13890. * Returns a string to use to update the GPU particles update shader
  13891. * @returns a string containng the defines string
  13892. */
  13893. getEffectDefines(): string;
  13894. /**
  13895. * Returns the string "SphereDirectedParticleEmitter"
  13896. * @returns a string containing the class name
  13897. */
  13898. getClassName(): string;
  13899. /**
  13900. * Serializes the particle system to a JSON object.
  13901. * @returns the JSON object
  13902. */
  13903. serialize(): any;
  13904. /**
  13905. * Parse properties from a JSON object
  13906. * @param serializationObject defines the JSON object
  13907. */
  13908. parse(serializationObject: any): void;
  13909. }
  13910. }
  13911. declare module BABYLON {
  13912. /**
  13913. * Particle emitter emitting particles from a custom list of positions.
  13914. */
  13915. export class CustomParticleEmitter implements IParticleEmitterType {
  13916. /**
  13917. * Gets or sets the position generator that will create the inital position of each particle.
  13918. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13919. */
  13920. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13921. /**
  13922. * Gets or sets the destination generator that will create the final destination of each particle.
  13923. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13924. */
  13925. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13926. /**
  13927. * Creates a new instance CustomParticleEmitter
  13928. */
  13929. constructor();
  13930. /**
  13931. * Called by the particle System when the direction is computed for the created particle.
  13932. * @param worldMatrix is the world matrix of the particle system
  13933. * @param directionToUpdate is the direction vector to update with the result
  13934. * @param particle is the particle we are computed the direction for
  13935. * @param isLocal defines if the direction should be set in local space
  13936. */
  13937. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13938. /**
  13939. * Called by the particle System when the position is computed for the created particle.
  13940. * @param worldMatrix is the world matrix of the particle system
  13941. * @param positionToUpdate is the position vector to update with the result
  13942. * @param particle is the particle we are computed the position for
  13943. * @param isLocal defines if the position should be set in local space
  13944. */
  13945. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13946. /**
  13947. * Clones the current emitter and returns a copy of it
  13948. * @returns the new emitter
  13949. */
  13950. clone(): CustomParticleEmitter;
  13951. /**
  13952. * Called by the GPUParticleSystem to setup the update shader
  13953. * @param effect defines the update shader
  13954. */
  13955. applyToShader(effect: Effect): void;
  13956. /**
  13957. * Returns a string to use to update the GPU particles update shader
  13958. * @returns a string containng the defines string
  13959. */
  13960. getEffectDefines(): string;
  13961. /**
  13962. * Returns the string "PointParticleEmitter"
  13963. * @returns a string containing the class name
  13964. */
  13965. getClassName(): string;
  13966. /**
  13967. * Serializes the particle system to a JSON object.
  13968. * @returns the JSON object
  13969. */
  13970. serialize(): any;
  13971. /**
  13972. * Parse properties from a JSON object
  13973. * @param serializationObject defines the JSON object
  13974. */
  13975. parse(serializationObject: any): void;
  13976. }
  13977. }
  13978. declare module BABYLON {
  13979. /**
  13980. * Particle emitter emitting particles from the inside of a box.
  13981. * It emits the particles randomly between 2 given directions.
  13982. */
  13983. export class MeshParticleEmitter implements IParticleEmitterType {
  13984. private _indices;
  13985. private _positions;
  13986. private _normals;
  13987. private _storedNormal;
  13988. private _mesh;
  13989. /**
  13990. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13991. */
  13992. direction1: Vector3;
  13993. /**
  13994. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13995. */
  13996. direction2: Vector3;
  13997. /**
  13998. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13999. */
  14000. useMeshNormalsForDirection: boolean;
  14001. /** Defines the mesh to use as source */
  14002. get mesh(): Nullable<AbstractMesh>;
  14003. set mesh(value: Nullable<AbstractMesh>);
  14004. /**
  14005. * Creates a new instance MeshParticleEmitter
  14006. * @param mesh defines the mesh to use as source
  14007. */
  14008. constructor(mesh?: Nullable<AbstractMesh>);
  14009. /**
  14010. * Called by the particle System when the direction is computed for the created particle.
  14011. * @param worldMatrix is the world matrix of the particle system
  14012. * @param directionToUpdate is the direction vector to update with the result
  14013. * @param particle is the particle we are computed the direction for
  14014. * @param isLocal defines if the direction should be set in local space
  14015. */
  14016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14017. /**
  14018. * Called by the particle System when the position is computed for the created particle.
  14019. * @param worldMatrix is the world matrix of the particle system
  14020. * @param positionToUpdate is the position vector to update with the result
  14021. * @param particle is the particle we are computed the position for
  14022. * @param isLocal defines if the position should be set in local space
  14023. */
  14024. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14025. /**
  14026. * Clones the current emitter and returns a copy of it
  14027. * @returns the new emitter
  14028. */
  14029. clone(): MeshParticleEmitter;
  14030. /**
  14031. * Called by the GPUParticleSystem to setup the update shader
  14032. * @param effect defines the update shader
  14033. */
  14034. applyToShader(effect: Effect): void;
  14035. /**
  14036. * Returns a string to use to update the GPU particles update shader
  14037. * @returns a string containng the defines string
  14038. */
  14039. getEffectDefines(): string;
  14040. /**
  14041. * Returns the string "BoxParticleEmitter"
  14042. * @returns a string containing the class name
  14043. */
  14044. getClassName(): string;
  14045. /**
  14046. * Serializes the particle system to a JSON object.
  14047. * @returns the JSON object
  14048. */
  14049. serialize(): any;
  14050. /**
  14051. * Parse properties from a JSON object
  14052. * @param serializationObject defines the JSON object
  14053. * @param scene defines the hosting scene
  14054. */
  14055. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14056. }
  14057. }
  14058. declare module BABYLON {
  14059. /**
  14060. * Interface representing a particle system in Babylon.js.
  14061. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14062. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14063. */
  14064. export interface IParticleSystem {
  14065. /**
  14066. * List of animations used by the particle system.
  14067. */
  14068. animations: Animation[];
  14069. /**
  14070. * The id of the Particle system.
  14071. */
  14072. id: string;
  14073. /**
  14074. * The name of the Particle system.
  14075. */
  14076. name: string;
  14077. /**
  14078. * The emitter represents the Mesh or position we are attaching the particle system to.
  14079. */
  14080. emitter: Nullable<AbstractMesh | Vector3>;
  14081. /**
  14082. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14083. */
  14084. isBillboardBased: boolean;
  14085. /**
  14086. * The rendering group used by the Particle system to chose when to render.
  14087. */
  14088. renderingGroupId: number;
  14089. /**
  14090. * The layer mask we are rendering the particles through.
  14091. */
  14092. layerMask: number;
  14093. /**
  14094. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14095. */
  14096. updateSpeed: number;
  14097. /**
  14098. * The amount of time the particle system is running (depends of the overall update speed).
  14099. */
  14100. targetStopDuration: number;
  14101. /**
  14102. * The texture used to render each particle. (this can be a spritesheet)
  14103. */
  14104. particleTexture: Nullable<BaseTexture>;
  14105. /**
  14106. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14107. */
  14108. blendMode: number;
  14109. /**
  14110. * Minimum life time of emitting particles.
  14111. */
  14112. minLifeTime: number;
  14113. /**
  14114. * Maximum life time of emitting particles.
  14115. */
  14116. maxLifeTime: number;
  14117. /**
  14118. * Minimum Size of emitting particles.
  14119. */
  14120. minSize: number;
  14121. /**
  14122. * Maximum Size of emitting particles.
  14123. */
  14124. maxSize: number;
  14125. /**
  14126. * Minimum scale of emitting particles on X axis.
  14127. */
  14128. minScaleX: number;
  14129. /**
  14130. * Maximum scale of emitting particles on X axis.
  14131. */
  14132. maxScaleX: number;
  14133. /**
  14134. * Minimum scale of emitting particles on Y axis.
  14135. */
  14136. minScaleY: number;
  14137. /**
  14138. * Maximum scale of emitting particles on Y axis.
  14139. */
  14140. maxScaleY: number;
  14141. /**
  14142. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14143. */
  14144. color1: Color4;
  14145. /**
  14146. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14147. */
  14148. color2: Color4;
  14149. /**
  14150. * Color the particle will have at the end of its lifetime.
  14151. */
  14152. colorDead: Color4;
  14153. /**
  14154. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14155. */
  14156. emitRate: number;
  14157. /**
  14158. * You can use gravity if you want to give an orientation to your particles.
  14159. */
  14160. gravity: Vector3;
  14161. /**
  14162. * Minimum power of emitting particles.
  14163. */
  14164. minEmitPower: number;
  14165. /**
  14166. * Maximum power of emitting particles.
  14167. */
  14168. maxEmitPower: number;
  14169. /**
  14170. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14171. */
  14172. minAngularSpeed: number;
  14173. /**
  14174. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14175. */
  14176. maxAngularSpeed: number;
  14177. /**
  14178. * Gets or sets the minimal initial rotation in radians.
  14179. */
  14180. minInitialRotation: number;
  14181. /**
  14182. * Gets or sets the maximal initial rotation in radians.
  14183. */
  14184. maxInitialRotation: number;
  14185. /**
  14186. * The particle emitter type defines the emitter used by the particle system.
  14187. * It can be for example box, sphere, or cone...
  14188. */
  14189. particleEmitterType: Nullable<IParticleEmitterType>;
  14190. /**
  14191. * Defines the delay in milliseconds before starting the system (0 by default)
  14192. */
  14193. startDelay: number;
  14194. /**
  14195. * 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
  14196. */
  14197. preWarmCycles: number;
  14198. /**
  14199. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14200. */
  14201. preWarmStepOffset: number;
  14202. /**
  14203. * 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)
  14204. */
  14205. spriteCellChangeSpeed: number;
  14206. /**
  14207. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14208. */
  14209. startSpriteCellID: number;
  14210. /**
  14211. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14212. */
  14213. endSpriteCellID: number;
  14214. /**
  14215. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14216. */
  14217. spriteCellWidth: number;
  14218. /**
  14219. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14220. */
  14221. spriteCellHeight: number;
  14222. /**
  14223. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14224. */
  14225. spriteRandomStartCell: boolean;
  14226. /**
  14227. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14228. */
  14229. isAnimationSheetEnabled: boolean;
  14230. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14231. translationPivot: Vector2;
  14232. /**
  14233. * Gets or sets a texture used to add random noise to particle positions
  14234. */
  14235. noiseTexture: Nullable<BaseTexture>;
  14236. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14237. noiseStrength: Vector3;
  14238. /**
  14239. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14240. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14241. */
  14242. billboardMode: number;
  14243. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14244. limitVelocityDamping: number;
  14245. /**
  14246. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14247. */
  14248. beginAnimationOnStart: boolean;
  14249. /**
  14250. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14251. */
  14252. beginAnimationFrom: number;
  14253. /**
  14254. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14255. */
  14256. beginAnimationTo: number;
  14257. /**
  14258. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14259. */
  14260. beginAnimationLoop: boolean;
  14261. /**
  14262. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14263. */
  14264. disposeOnStop: boolean;
  14265. /**
  14266. * Specifies if the particles are updated in emitter local space or world space
  14267. */
  14268. isLocal: boolean;
  14269. /** Snippet ID if the particle system was created from the snippet server */
  14270. snippetId: string;
  14271. /** Gets or sets a matrix to use to compute projection */
  14272. defaultProjectionMatrix: Matrix;
  14273. /**
  14274. * Gets the maximum number of particles active at the same time.
  14275. * @returns The max number of active particles.
  14276. */
  14277. getCapacity(): number;
  14278. /**
  14279. * Gets the number of particles active at the same time.
  14280. * @returns The number of active particles.
  14281. */
  14282. getActiveCount(): number;
  14283. /**
  14284. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14285. * @returns True if it has been started, otherwise false.
  14286. */
  14287. isStarted(): boolean;
  14288. /**
  14289. * Animates the particle system for this frame.
  14290. */
  14291. animate(): void;
  14292. /**
  14293. * Renders the particle system in its current state.
  14294. * @returns the current number of particles
  14295. */
  14296. render(): number;
  14297. /**
  14298. * Dispose the particle system and frees its associated resources.
  14299. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14300. */
  14301. dispose(disposeTexture?: boolean): void;
  14302. /**
  14303. * An event triggered when the system is disposed
  14304. */
  14305. onDisposeObservable: Observable<IParticleSystem>;
  14306. /**
  14307. * An event triggered when the system is stopped
  14308. */
  14309. onStoppedObservable: Observable<IParticleSystem>;
  14310. /**
  14311. * Clones the particle system.
  14312. * @param name The name of the cloned object
  14313. * @param newEmitter The new emitter to use
  14314. * @returns the cloned particle system
  14315. */
  14316. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14317. /**
  14318. * Serializes the particle system to a JSON object
  14319. * @param serializeTexture defines if the texture must be serialized as well
  14320. * @returns the JSON object
  14321. */
  14322. serialize(serializeTexture: boolean): any;
  14323. /**
  14324. * Rebuild the particle system
  14325. */
  14326. rebuild(): void;
  14327. /** Force the system to rebuild all gradients that need to be resync */
  14328. forceRefreshGradients(): void;
  14329. /**
  14330. * Starts the particle system and begins to emit
  14331. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14332. */
  14333. start(delay?: number): void;
  14334. /**
  14335. * Stops the particle system.
  14336. */
  14337. stop(): void;
  14338. /**
  14339. * Remove all active particles
  14340. */
  14341. reset(): void;
  14342. /**
  14343. * Gets a boolean indicating that the system is stopping
  14344. * @returns true if the system is currently stopping
  14345. */
  14346. isStopping(): boolean;
  14347. /**
  14348. * Is this system ready to be used/rendered
  14349. * @return true if the system is ready
  14350. */
  14351. isReady(): boolean;
  14352. /**
  14353. * Returns the string "ParticleSystem"
  14354. * @returns a string containing the class name
  14355. */
  14356. getClassName(): string;
  14357. /**
  14358. * Gets the custom effect used to render the particles
  14359. * @param blendMode Blend mode for which the effect should be retrieved
  14360. * @returns The effect
  14361. */
  14362. getCustomEffect(blendMode: number): Nullable<Effect>;
  14363. /**
  14364. * Sets the custom effect used to render the particles
  14365. * @param effect The effect to set
  14366. * @param blendMode Blend mode for which the effect should be set
  14367. */
  14368. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14369. /**
  14370. * Fill the defines array according to the current settings of the particle system
  14371. * @param defines Array to be updated
  14372. * @param blendMode blend mode to take into account when updating the array
  14373. */
  14374. fillDefines(defines: Array<string>, blendMode: number): void;
  14375. /**
  14376. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14377. * @param uniforms Uniforms array to fill
  14378. * @param attributes Attributes array to fill
  14379. * @param samplers Samplers array to fill
  14380. */
  14381. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14382. /**
  14383. * Observable that will be called just before the particles are drawn
  14384. */
  14385. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14386. /**
  14387. * Gets the name of the particle vertex shader
  14388. */
  14389. vertexShaderName: string;
  14390. /**
  14391. * Adds a new color gradient
  14392. * @param gradient defines the gradient to use (between 0 and 1)
  14393. * @param color1 defines the color to affect to the specified gradient
  14394. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14395. * @returns the current particle system
  14396. */
  14397. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14398. /**
  14399. * Remove a specific color gradient
  14400. * @param gradient defines the gradient to remove
  14401. * @returns the current particle system
  14402. */
  14403. removeColorGradient(gradient: number): IParticleSystem;
  14404. /**
  14405. * Adds a new size gradient
  14406. * @param gradient defines the gradient to use (between 0 and 1)
  14407. * @param factor defines the size factor to affect to the specified gradient
  14408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14409. * @returns the current particle system
  14410. */
  14411. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14412. /**
  14413. * Remove a specific size gradient
  14414. * @param gradient defines the gradient to remove
  14415. * @returns the current particle system
  14416. */
  14417. removeSizeGradient(gradient: number): IParticleSystem;
  14418. /**
  14419. * Gets the current list of color gradients.
  14420. * You must use addColorGradient and removeColorGradient to udpate this list
  14421. * @returns the list of color gradients
  14422. */
  14423. getColorGradients(): Nullable<Array<ColorGradient>>;
  14424. /**
  14425. * Gets the current list of size gradients.
  14426. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14427. * @returns the list of size gradients
  14428. */
  14429. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14430. /**
  14431. * Gets the current list of angular speed gradients.
  14432. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14433. * @returns the list of angular speed gradients
  14434. */
  14435. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14436. /**
  14437. * Adds a new angular speed gradient
  14438. * @param gradient defines the gradient to use (between 0 and 1)
  14439. * @param factor defines the angular speed to affect to the specified gradient
  14440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14441. * @returns the current particle system
  14442. */
  14443. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14444. /**
  14445. * Remove a specific angular speed gradient
  14446. * @param gradient defines the gradient to remove
  14447. * @returns the current particle system
  14448. */
  14449. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14450. /**
  14451. * Gets the current list of velocity gradients.
  14452. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14453. * @returns the list of velocity gradients
  14454. */
  14455. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14456. /**
  14457. * Adds a new velocity gradient
  14458. * @param gradient defines the gradient to use (between 0 and 1)
  14459. * @param factor defines the velocity to affect to the specified gradient
  14460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14461. * @returns the current particle system
  14462. */
  14463. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14464. /**
  14465. * Remove a specific velocity gradient
  14466. * @param gradient defines the gradient to remove
  14467. * @returns the current particle system
  14468. */
  14469. removeVelocityGradient(gradient: number): IParticleSystem;
  14470. /**
  14471. * Gets the current list of limit velocity gradients.
  14472. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14473. * @returns the list of limit velocity gradients
  14474. */
  14475. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14476. /**
  14477. * Adds a new limit velocity gradient
  14478. * @param gradient defines the gradient to use (between 0 and 1)
  14479. * @param factor defines the limit velocity to affect to the specified gradient
  14480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14481. * @returns the current particle system
  14482. */
  14483. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14484. /**
  14485. * Remove a specific limit velocity gradient
  14486. * @param gradient defines the gradient to remove
  14487. * @returns the current particle system
  14488. */
  14489. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14490. /**
  14491. * Adds a new drag gradient
  14492. * @param gradient defines the gradient to use (between 0 and 1)
  14493. * @param factor defines the drag to affect to the specified gradient
  14494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14495. * @returns the current particle system
  14496. */
  14497. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14498. /**
  14499. * Remove a specific drag gradient
  14500. * @param gradient defines the gradient to remove
  14501. * @returns the current particle system
  14502. */
  14503. removeDragGradient(gradient: number): IParticleSystem;
  14504. /**
  14505. * Gets the current list of drag gradients.
  14506. * You must use addDragGradient and removeDragGradient to udpate this list
  14507. * @returns the list of drag gradients
  14508. */
  14509. getDragGradients(): Nullable<Array<FactorGradient>>;
  14510. /**
  14511. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14512. * @param gradient defines the gradient to use (between 0 and 1)
  14513. * @param factor defines the emit rate to affect to the specified gradient
  14514. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14515. * @returns the current particle system
  14516. */
  14517. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14518. /**
  14519. * Remove a specific emit rate gradient
  14520. * @param gradient defines the gradient to remove
  14521. * @returns the current particle system
  14522. */
  14523. removeEmitRateGradient(gradient: number): IParticleSystem;
  14524. /**
  14525. * Gets the current list of emit rate gradients.
  14526. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14527. * @returns the list of emit rate gradients
  14528. */
  14529. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14530. /**
  14531. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14532. * @param gradient defines the gradient to use (between 0 and 1)
  14533. * @param factor defines the start size to affect to the specified gradient
  14534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14535. * @returns the current particle system
  14536. */
  14537. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14538. /**
  14539. * Remove a specific start size gradient
  14540. * @param gradient defines the gradient to remove
  14541. * @returns the current particle system
  14542. */
  14543. removeStartSizeGradient(gradient: number): IParticleSystem;
  14544. /**
  14545. * Gets the current list of start size gradients.
  14546. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14547. * @returns the list of start size gradients
  14548. */
  14549. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14550. /**
  14551. * Adds a new life time gradient
  14552. * @param gradient defines the gradient to use (between 0 and 1)
  14553. * @param factor defines the life time factor to affect to the specified gradient
  14554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14555. * @returns the current particle system
  14556. */
  14557. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14558. /**
  14559. * Remove a specific life time gradient
  14560. * @param gradient defines the gradient to remove
  14561. * @returns the current particle system
  14562. */
  14563. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14564. /**
  14565. * Gets the current list of life time gradients.
  14566. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14567. * @returns the list of life time gradients
  14568. */
  14569. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14570. /**
  14571. * Gets the current list of color gradients.
  14572. * You must use addColorGradient and removeColorGradient to udpate this list
  14573. * @returns the list of color gradients
  14574. */
  14575. getColorGradients(): Nullable<Array<ColorGradient>>;
  14576. /**
  14577. * Adds a new ramp gradient used to remap particle colors
  14578. * @param gradient defines the gradient to use (between 0 and 1)
  14579. * @param color defines the color to affect to the specified gradient
  14580. * @returns the current particle system
  14581. */
  14582. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14583. /**
  14584. * Gets the current list of ramp gradients.
  14585. * You must use addRampGradient and removeRampGradient to udpate this list
  14586. * @returns the list of ramp gradients
  14587. */
  14588. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14589. /** Gets or sets a boolean indicating that ramp gradients must be used
  14590. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14591. */
  14592. useRampGradients: boolean;
  14593. /**
  14594. * Adds a new color remap gradient
  14595. * @param gradient defines the gradient to use (between 0 and 1)
  14596. * @param min defines the color remap minimal range
  14597. * @param max defines the color remap maximal range
  14598. * @returns the current particle system
  14599. */
  14600. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14601. /**
  14602. * Gets the current list of color remap gradients.
  14603. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14604. * @returns the list of color remap gradients
  14605. */
  14606. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14607. /**
  14608. * Adds a new alpha remap gradient
  14609. * @param gradient defines the gradient to use (between 0 and 1)
  14610. * @param min defines the alpha remap minimal range
  14611. * @param max defines the alpha remap maximal range
  14612. * @returns the current particle system
  14613. */
  14614. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14615. /**
  14616. * Gets the current list of alpha remap gradients.
  14617. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14618. * @returns the list of alpha remap gradients
  14619. */
  14620. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14621. /**
  14622. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14623. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14624. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14625. * @returns the emitter
  14626. */
  14627. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14628. /**
  14629. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14630. * @param radius The radius of the hemisphere to emit from
  14631. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14632. * @returns the emitter
  14633. */
  14634. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14635. /**
  14636. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14637. * @param radius The radius of the sphere to emit from
  14638. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14639. * @returns the emitter
  14640. */
  14641. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14642. /**
  14643. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14644. * @param radius The radius of the sphere to emit from
  14645. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14646. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14647. * @returns the emitter
  14648. */
  14649. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14650. /**
  14651. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14652. * @param radius The radius of the emission cylinder
  14653. * @param height The height of the emission cylinder
  14654. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14655. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14656. * @returns the emitter
  14657. */
  14658. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14659. /**
  14660. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14661. * @param radius The radius of the cylinder to emit from
  14662. * @param height The height of the emission cylinder
  14663. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14664. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14665. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14666. * @returns the emitter
  14667. */
  14668. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14669. /**
  14670. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14671. * @param radius The radius of the cone to emit from
  14672. * @param angle The base angle of the cone
  14673. * @returns the emitter
  14674. */
  14675. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14676. /**
  14677. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14678. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14679. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14680. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14681. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14682. * @returns the emitter
  14683. */
  14684. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14685. /**
  14686. * Get hosting scene
  14687. * @returns the scene
  14688. */
  14689. getScene(): Nullable<Scene>;
  14690. }
  14691. }
  14692. declare module BABYLON {
  14693. /**
  14694. * 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.
  14695. * @see https://doc.babylonjs.com/how_to/transformnode
  14696. */
  14697. export class TransformNode extends Node {
  14698. /**
  14699. * Object will not rotate to face the camera
  14700. */
  14701. static BILLBOARDMODE_NONE: number;
  14702. /**
  14703. * Object will rotate to face the camera but only on the x axis
  14704. */
  14705. static BILLBOARDMODE_X: number;
  14706. /**
  14707. * Object will rotate to face the camera but only on the y axis
  14708. */
  14709. static BILLBOARDMODE_Y: number;
  14710. /**
  14711. * Object will rotate to face the camera but only on the z axis
  14712. */
  14713. static BILLBOARDMODE_Z: number;
  14714. /**
  14715. * Object will rotate to face the camera
  14716. */
  14717. static BILLBOARDMODE_ALL: number;
  14718. /**
  14719. * Object will rotate to face the camera's position instead of orientation
  14720. */
  14721. static BILLBOARDMODE_USE_POSITION: number;
  14722. private static _TmpRotation;
  14723. private static _TmpScaling;
  14724. private static _TmpTranslation;
  14725. private _forward;
  14726. private _forwardInverted;
  14727. private _up;
  14728. private _right;
  14729. private _rightInverted;
  14730. private _position;
  14731. private _rotation;
  14732. private _rotationQuaternion;
  14733. protected _scaling: Vector3;
  14734. protected _isDirty: boolean;
  14735. private _transformToBoneReferal;
  14736. private _isAbsoluteSynced;
  14737. private _billboardMode;
  14738. /**
  14739. * Gets or sets the billboard mode. Default is 0.
  14740. *
  14741. * | Value | Type | Description |
  14742. * | --- | --- | --- |
  14743. * | 0 | BILLBOARDMODE_NONE | |
  14744. * | 1 | BILLBOARDMODE_X | |
  14745. * | 2 | BILLBOARDMODE_Y | |
  14746. * | 4 | BILLBOARDMODE_Z | |
  14747. * | 7 | BILLBOARDMODE_ALL | |
  14748. *
  14749. */
  14750. get billboardMode(): number;
  14751. set billboardMode(value: number);
  14752. private _preserveParentRotationForBillboard;
  14753. /**
  14754. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14755. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14756. */
  14757. get preserveParentRotationForBillboard(): boolean;
  14758. set preserveParentRotationForBillboard(value: boolean);
  14759. /**
  14760. * 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
  14761. */
  14762. scalingDeterminant: number;
  14763. private _infiniteDistance;
  14764. /**
  14765. * Gets or sets the distance of the object to max, often used by skybox
  14766. */
  14767. get infiniteDistance(): boolean;
  14768. set infiniteDistance(value: boolean);
  14769. /**
  14770. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14771. * By default the system will update normals to compensate
  14772. */
  14773. ignoreNonUniformScaling: boolean;
  14774. /**
  14775. * 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
  14776. */
  14777. reIntegrateRotationIntoRotationQuaternion: boolean;
  14778. /** @hidden */
  14779. _poseMatrix: Nullable<Matrix>;
  14780. /** @hidden */
  14781. _localMatrix: Matrix;
  14782. private _usePivotMatrix;
  14783. private _absolutePosition;
  14784. private _absoluteScaling;
  14785. private _absoluteRotationQuaternion;
  14786. private _pivotMatrix;
  14787. private _pivotMatrixInverse;
  14788. /** @hidden */
  14789. _postMultiplyPivotMatrix: boolean;
  14790. protected _isWorldMatrixFrozen: boolean;
  14791. /** @hidden */
  14792. _indexInSceneTransformNodesArray: number;
  14793. /**
  14794. * An event triggered after the world matrix is updated
  14795. */
  14796. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14797. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14798. /**
  14799. * Gets a string identifying the name of the class
  14800. * @returns "TransformNode" string
  14801. */
  14802. getClassName(): string;
  14803. /**
  14804. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14805. */
  14806. get position(): Vector3;
  14807. set position(newPosition: Vector3);
  14808. /**
  14809. * 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)).
  14810. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14811. */
  14812. get rotation(): Vector3;
  14813. set rotation(newRotation: Vector3);
  14814. /**
  14815. * 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)).
  14816. */
  14817. get scaling(): Vector3;
  14818. set scaling(newScaling: Vector3);
  14819. /**
  14820. * 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).
  14821. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14822. */
  14823. get rotationQuaternion(): Nullable<Quaternion>;
  14824. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14825. /**
  14826. * The forward direction of that transform in world space.
  14827. */
  14828. get forward(): Vector3;
  14829. /**
  14830. * The up direction of that transform in world space.
  14831. */
  14832. get up(): Vector3;
  14833. /**
  14834. * The right direction of that transform in world space.
  14835. */
  14836. get right(): Vector3;
  14837. /**
  14838. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14839. * @param matrix the matrix to copy the pose from
  14840. * @returns this TransformNode.
  14841. */
  14842. updatePoseMatrix(matrix: Matrix): TransformNode;
  14843. /**
  14844. * Returns the mesh Pose matrix.
  14845. * @returns the pose matrix
  14846. */
  14847. getPoseMatrix(): Matrix;
  14848. /** @hidden */
  14849. _isSynchronized(): boolean;
  14850. /** @hidden */
  14851. _initCache(): void;
  14852. /**
  14853. * Flag the transform node as dirty (Forcing it to update everything)
  14854. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14855. * @returns this transform node
  14856. */
  14857. markAsDirty(property: string): TransformNode;
  14858. /**
  14859. * Returns the current mesh absolute position.
  14860. * Returns a Vector3.
  14861. */
  14862. get absolutePosition(): Vector3;
  14863. /**
  14864. * Returns the current mesh absolute scaling.
  14865. * Returns a Vector3.
  14866. */
  14867. get absoluteScaling(): Vector3;
  14868. /**
  14869. * Returns the current mesh absolute rotation.
  14870. * Returns a Quaternion.
  14871. */
  14872. get absoluteRotationQuaternion(): Quaternion;
  14873. /**
  14874. * Sets a new matrix to apply before all other transformation
  14875. * @param matrix defines the transform matrix
  14876. * @returns the current TransformNode
  14877. */
  14878. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14879. /**
  14880. * Sets a new pivot matrix to the current node
  14881. * @param matrix defines the new pivot matrix to use
  14882. * @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
  14883. * @returns the current TransformNode
  14884. */
  14885. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14886. /**
  14887. * Returns the mesh pivot matrix.
  14888. * Default : Identity.
  14889. * @returns the matrix
  14890. */
  14891. getPivotMatrix(): Matrix;
  14892. /**
  14893. * Instantiate (when possible) or clone that node with its hierarchy
  14894. * @param newParent defines the new parent to use for the instance (or clone)
  14895. * @param options defines options to configure how copy is done
  14896. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14897. * @returns an instance (or a clone) of the current node with its hiearchy
  14898. */
  14899. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14900. doNotInstantiate: boolean;
  14901. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14902. /**
  14903. * Prevents the World matrix to be computed any longer
  14904. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14905. * @returns the TransformNode.
  14906. */
  14907. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14908. /**
  14909. * Allows back the World matrix computation.
  14910. * @returns the TransformNode.
  14911. */
  14912. unfreezeWorldMatrix(): this;
  14913. /**
  14914. * True if the World matrix has been frozen.
  14915. */
  14916. get isWorldMatrixFrozen(): boolean;
  14917. /**
  14918. * Retuns the mesh absolute position in the World.
  14919. * @returns a Vector3.
  14920. */
  14921. getAbsolutePosition(): Vector3;
  14922. /**
  14923. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14924. * @param absolutePosition the absolute position to set
  14925. * @returns the TransformNode.
  14926. */
  14927. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14928. /**
  14929. * Sets the mesh position in its local space.
  14930. * @param vector3 the position to set in localspace
  14931. * @returns the TransformNode.
  14932. */
  14933. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14934. /**
  14935. * Returns the mesh position in the local space from the current World matrix values.
  14936. * @returns a new Vector3.
  14937. */
  14938. getPositionExpressedInLocalSpace(): Vector3;
  14939. /**
  14940. * Translates the mesh along the passed Vector3 in its local space.
  14941. * @param vector3 the distance to translate in localspace
  14942. * @returns the TransformNode.
  14943. */
  14944. locallyTranslate(vector3: Vector3): TransformNode;
  14945. private static _lookAtVectorCache;
  14946. /**
  14947. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14948. * @param targetPoint the position (must be in same space as current mesh) to look at
  14949. * @param yawCor optional yaw (y-axis) correction in radians
  14950. * @param pitchCor optional pitch (x-axis) correction in radians
  14951. * @param rollCor optional roll (z-axis) correction in radians
  14952. * @param space the choosen space of the target
  14953. * @returns the TransformNode.
  14954. */
  14955. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14956. /**
  14957. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14958. * This Vector3 is expressed in the World space.
  14959. * @param localAxis axis to rotate
  14960. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14961. */
  14962. getDirection(localAxis: Vector3): Vector3;
  14963. /**
  14964. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14965. * localAxis is expressed in the mesh local space.
  14966. * result is computed in the Wordl space from the mesh World matrix.
  14967. * @param localAxis axis to rotate
  14968. * @param result the resulting transformnode
  14969. * @returns this TransformNode.
  14970. */
  14971. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14972. /**
  14973. * Sets this transform node rotation to the given local axis.
  14974. * @param localAxis the axis in local space
  14975. * @param yawCor optional yaw (y-axis) correction in radians
  14976. * @param pitchCor optional pitch (x-axis) correction in radians
  14977. * @param rollCor optional roll (z-axis) correction in radians
  14978. * @returns this TransformNode
  14979. */
  14980. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14981. /**
  14982. * Sets a new pivot point to the current node
  14983. * @param point defines the new pivot point to use
  14984. * @param space defines if the point is in world or local space (local by default)
  14985. * @returns the current TransformNode
  14986. */
  14987. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14988. /**
  14989. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14990. * @returns the pivot point
  14991. */
  14992. getPivotPoint(): Vector3;
  14993. /**
  14994. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14995. * @param result the vector3 to store the result
  14996. * @returns this TransformNode.
  14997. */
  14998. getPivotPointToRef(result: Vector3): TransformNode;
  14999. /**
  15000. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15001. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15002. */
  15003. getAbsolutePivotPoint(): Vector3;
  15004. /**
  15005. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15006. * @param result vector3 to store the result
  15007. * @returns this TransformNode.
  15008. */
  15009. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15010. /**
  15011. * Defines the passed node as the parent of the current node.
  15012. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15013. * @see https://doc.babylonjs.com/how_to/parenting
  15014. * @param node the node ot set as the parent
  15015. * @returns this TransformNode.
  15016. */
  15017. setParent(node: Nullable<Node>): TransformNode;
  15018. private _nonUniformScaling;
  15019. /**
  15020. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15021. */
  15022. get nonUniformScaling(): boolean;
  15023. /** @hidden */
  15024. _updateNonUniformScalingState(value: boolean): boolean;
  15025. /**
  15026. * Attach the current TransformNode to another TransformNode associated with a bone
  15027. * @param bone Bone affecting the TransformNode
  15028. * @param affectedTransformNode TransformNode associated with the bone
  15029. * @returns this object
  15030. */
  15031. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15032. /**
  15033. * Detach the transform node if its associated with a bone
  15034. * @returns this object
  15035. */
  15036. detachFromBone(): TransformNode;
  15037. private static _rotationAxisCache;
  15038. /**
  15039. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15040. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15041. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15042. * The passed axis is also normalized.
  15043. * @param axis the axis to rotate around
  15044. * @param amount the amount to rotate in radians
  15045. * @param space Space to rotate in (Default: local)
  15046. * @returns the TransformNode.
  15047. */
  15048. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15049. /**
  15050. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15051. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15052. * The passed axis is also normalized. .
  15053. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15054. * @param point the point to rotate around
  15055. * @param axis the axis to rotate around
  15056. * @param amount the amount to rotate in radians
  15057. * @returns the TransformNode
  15058. */
  15059. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15060. /**
  15061. * Translates the mesh along the axis vector for the passed distance in the given space.
  15062. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15063. * @param axis the axis to translate in
  15064. * @param distance the distance to translate
  15065. * @param space Space to rotate in (Default: local)
  15066. * @returns the TransformNode.
  15067. */
  15068. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15069. /**
  15070. * Adds a rotation step to the mesh current rotation.
  15071. * x, y, z are Euler angles expressed in radians.
  15072. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15073. * This means this rotation is made in the mesh local space only.
  15074. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15075. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15076. * ```javascript
  15077. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15078. * ```
  15079. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15080. * 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.
  15081. * @param x Rotation to add
  15082. * @param y Rotation to add
  15083. * @param z Rotation to add
  15084. * @returns the TransformNode.
  15085. */
  15086. addRotation(x: number, y: number, z: number): TransformNode;
  15087. /**
  15088. * @hidden
  15089. */
  15090. protected _getEffectiveParent(): Nullable<Node>;
  15091. /**
  15092. * Computes the world matrix of the node
  15093. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15094. * @returns the world matrix
  15095. */
  15096. computeWorldMatrix(force?: boolean): Matrix;
  15097. /**
  15098. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15099. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15100. */
  15101. resetLocalMatrix(independentOfChildren?: boolean): void;
  15102. protected _afterComputeWorldMatrix(): void;
  15103. /**
  15104. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15105. * @param func callback function to add
  15106. *
  15107. * @returns the TransformNode.
  15108. */
  15109. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15110. /**
  15111. * Removes a registered callback function.
  15112. * @param func callback function to remove
  15113. * @returns the TransformNode.
  15114. */
  15115. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15116. /**
  15117. * Gets the position of the current mesh in camera space
  15118. * @param camera defines the camera to use
  15119. * @returns a position
  15120. */
  15121. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15122. /**
  15123. * Returns the distance from the mesh to the active camera
  15124. * @param camera defines the camera to use
  15125. * @returns the distance
  15126. */
  15127. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15128. /**
  15129. * Clone the current transform node
  15130. * @param name Name of the new clone
  15131. * @param newParent New parent for the clone
  15132. * @param doNotCloneChildren Do not clone children hierarchy
  15133. * @returns the new transform node
  15134. */
  15135. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15136. /**
  15137. * Serializes the objects information.
  15138. * @param currentSerializationObject defines the object to serialize in
  15139. * @returns the serialized object
  15140. */
  15141. serialize(currentSerializationObject?: any): any;
  15142. /**
  15143. * Returns a new TransformNode object parsed from the source provided.
  15144. * @param parsedTransformNode is the source.
  15145. * @param scene the scne the object belongs to
  15146. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15147. * @returns a new TransformNode object parsed from the source provided.
  15148. */
  15149. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15150. /**
  15151. * Get all child-transformNodes of this node
  15152. * @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
  15153. * @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
  15154. * @returns an array of TransformNode
  15155. */
  15156. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15157. /**
  15158. * Releases resources associated with this transform node.
  15159. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15160. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15161. */
  15162. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15163. /**
  15164. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15165. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15166. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15167. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15168. * @returns the current mesh
  15169. */
  15170. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15171. private _syncAbsoluteScalingAndRotation;
  15172. }
  15173. }
  15174. declare module BABYLON {
  15175. /**
  15176. * Class used to override all child animations of a given target
  15177. */
  15178. export class AnimationPropertiesOverride {
  15179. /**
  15180. * Gets or sets a value indicating if animation blending must be used
  15181. */
  15182. enableBlending: boolean;
  15183. /**
  15184. * Gets or sets the blending speed to use when enableBlending is true
  15185. */
  15186. blendingSpeed: number;
  15187. /**
  15188. * Gets or sets the default loop mode to use
  15189. */
  15190. loopMode: number;
  15191. }
  15192. }
  15193. declare module BABYLON {
  15194. /**
  15195. * Class used to store bone information
  15196. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15197. */
  15198. export class Bone extends Node {
  15199. /**
  15200. * defines the bone name
  15201. */
  15202. name: string;
  15203. private static _tmpVecs;
  15204. private static _tmpQuat;
  15205. private static _tmpMats;
  15206. /**
  15207. * Gets the list of child bones
  15208. */
  15209. children: Bone[];
  15210. /** Gets the animations associated with this bone */
  15211. animations: Animation[];
  15212. /**
  15213. * Gets or sets bone length
  15214. */
  15215. length: number;
  15216. /**
  15217. * @hidden Internal only
  15218. * Set this value to map this bone to a different index in the transform matrices
  15219. * Set this value to -1 to exclude the bone from the transform matrices
  15220. */
  15221. _index: Nullable<number>;
  15222. private _skeleton;
  15223. private _localMatrix;
  15224. private _restPose;
  15225. private _bindPose;
  15226. private _baseMatrix;
  15227. private _absoluteTransform;
  15228. private _invertedAbsoluteTransform;
  15229. private _parent;
  15230. private _scalingDeterminant;
  15231. private _worldTransform;
  15232. private _localScaling;
  15233. private _localRotation;
  15234. private _localPosition;
  15235. private _needToDecompose;
  15236. private _needToCompose;
  15237. /** @hidden */
  15238. _linkedTransformNode: Nullable<TransformNode>;
  15239. /** @hidden */
  15240. _waitingTransformNodeId: Nullable<string>;
  15241. /** @hidden */
  15242. get _matrix(): Matrix;
  15243. /** @hidden */
  15244. set _matrix(value: Matrix);
  15245. /**
  15246. * Create a new bone
  15247. * @param name defines the bone name
  15248. * @param skeleton defines the parent skeleton
  15249. * @param parentBone defines the parent (can be null if the bone is the root)
  15250. * @param localMatrix defines the local matrix
  15251. * @param restPose defines the rest pose matrix
  15252. * @param baseMatrix defines the base matrix
  15253. * @param index defines index of the bone in the hiearchy
  15254. */
  15255. constructor(
  15256. /**
  15257. * defines the bone name
  15258. */
  15259. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15260. /**
  15261. * Gets the current object class name.
  15262. * @return the class name
  15263. */
  15264. getClassName(): string;
  15265. /**
  15266. * Gets the parent skeleton
  15267. * @returns a skeleton
  15268. */
  15269. getSkeleton(): Skeleton;
  15270. /**
  15271. * Gets parent bone
  15272. * @returns a bone or null if the bone is the root of the bone hierarchy
  15273. */
  15274. getParent(): Nullable<Bone>;
  15275. /**
  15276. * Returns an array containing the root bones
  15277. * @returns an array containing the root bones
  15278. */
  15279. getChildren(): Array<Bone>;
  15280. /**
  15281. * Gets the node index in matrix array generated for rendering
  15282. * @returns the node index
  15283. */
  15284. getIndex(): number;
  15285. /**
  15286. * Sets the parent bone
  15287. * @param parent defines the parent (can be null if the bone is the root)
  15288. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15289. */
  15290. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15291. /**
  15292. * Gets the local matrix
  15293. * @returns a matrix
  15294. */
  15295. getLocalMatrix(): Matrix;
  15296. /**
  15297. * Gets the base matrix (initial matrix which remains unchanged)
  15298. * @returns a matrix
  15299. */
  15300. getBaseMatrix(): Matrix;
  15301. /**
  15302. * Gets the rest pose matrix
  15303. * @returns a matrix
  15304. */
  15305. getRestPose(): Matrix;
  15306. /**
  15307. * Sets the rest pose matrix
  15308. * @param matrix the local-space rest pose to set for this bone
  15309. */
  15310. setRestPose(matrix: Matrix): void;
  15311. /**
  15312. * Gets the bind pose matrix
  15313. * @returns the bind pose matrix
  15314. */
  15315. getBindPose(): Matrix;
  15316. /**
  15317. * Sets the bind pose matrix
  15318. * @param matrix the local-space bind pose to set for this bone
  15319. */
  15320. setBindPose(matrix: Matrix): void;
  15321. /**
  15322. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15323. */
  15324. getWorldMatrix(): Matrix;
  15325. /**
  15326. * Sets the local matrix to rest pose matrix
  15327. */
  15328. returnToRest(): void;
  15329. /**
  15330. * Gets the inverse of the absolute transform matrix.
  15331. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15332. * @returns a matrix
  15333. */
  15334. getInvertedAbsoluteTransform(): Matrix;
  15335. /**
  15336. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15337. * @returns a matrix
  15338. */
  15339. getAbsoluteTransform(): Matrix;
  15340. /**
  15341. * Links with the given transform node.
  15342. * The local matrix of this bone is copied from the transform node every frame.
  15343. * @param transformNode defines the transform node to link to
  15344. */
  15345. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15346. /**
  15347. * Gets the node used to drive the bone's transformation
  15348. * @returns a transform node or null
  15349. */
  15350. getTransformNode(): Nullable<TransformNode>;
  15351. /** Gets or sets current position (in local space) */
  15352. get position(): Vector3;
  15353. set position(newPosition: Vector3);
  15354. /** Gets or sets current rotation (in local space) */
  15355. get rotation(): Vector3;
  15356. set rotation(newRotation: Vector3);
  15357. /** Gets or sets current rotation quaternion (in local space) */
  15358. get rotationQuaternion(): Quaternion;
  15359. set rotationQuaternion(newRotation: Quaternion);
  15360. /** Gets or sets current scaling (in local space) */
  15361. get scaling(): Vector3;
  15362. set scaling(newScaling: Vector3);
  15363. /**
  15364. * Gets the animation properties override
  15365. */
  15366. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15367. private _decompose;
  15368. private _compose;
  15369. /**
  15370. * Update the base and local matrices
  15371. * @param matrix defines the new base or local matrix
  15372. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15373. * @param updateLocalMatrix defines if the local matrix should be updated
  15374. */
  15375. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15376. /** @hidden */
  15377. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15378. /**
  15379. * Flag the bone as dirty (Forcing it to update everything)
  15380. */
  15381. markAsDirty(): void;
  15382. /** @hidden */
  15383. _markAsDirtyAndCompose(): void;
  15384. private _markAsDirtyAndDecompose;
  15385. /**
  15386. * Translate the bone in local or world space
  15387. * @param vec The amount to translate the bone
  15388. * @param space The space that the translation is in
  15389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15390. */
  15391. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15392. /**
  15393. * Set the postion of the bone in local or world space
  15394. * @param position The position to set the bone
  15395. * @param space The space that the position is in
  15396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15397. */
  15398. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15399. /**
  15400. * Set the absolute position of the bone (world space)
  15401. * @param position The position to set the bone
  15402. * @param mesh The mesh that this bone is attached to
  15403. */
  15404. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15405. /**
  15406. * Scale the bone on the x, y and z axes (in local space)
  15407. * @param x The amount to scale the bone on the x axis
  15408. * @param y The amount to scale the bone on the y axis
  15409. * @param z The amount to scale the bone on the z axis
  15410. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15411. */
  15412. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15413. /**
  15414. * Set the bone scaling in local space
  15415. * @param scale defines the scaling vector
  15416. */
  15417. setScale(scale: Vector3): void;
  15418. /**
  15419. * Gets the current scaling in local space
  15420. * @returns the current scaling vector
  15421. */
  15422. getScale(): Vector3;
  15423. /**
  15424. * Gets the current scaling in local space and stores it in a target vector
  15425. * @param result defines the target vector
  15426. */
  15427. getScaleToRef(result: Vector3): void;
  15428. /**
  15429. * Set the yaw, pitch, and roll of the bone in local or world space
  15430. * @param yaw The rotation of the bone on the y axis
  15431. * @param pitch The rotation of the bone on the x axis
  15432. * @param roll The rotation of the bone on the z axis
  15433. * @param space The space that the axes of rotation are in
  15434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15435. */
  15436. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15437. /**
  15438. * Add a rotation to the bone on an axis in local or world space
  15439. * @param axis The axis to rotate the bone on
  15440. * @param amount The amount to rotate the bone
  15441. * @param space The space that the axis is in
  15442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15443. */
  15444. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15445. /**
  15446. * Set the rotation of the bone to a particular axis angle in local or world space
  15447. * @param axis The axis to rotate the bone on
  15448. * @param angle The angle that the bone should be rotated to
  15449. * @param space The space that the axis is in
  15450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15451. */
  15452. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15453. /**
  15454. * Set the euler rotation of the bone in local or world space
  15455. * @param rotation The euler rotation that the bone should be set to
  15456. * @param space The space that the rotation is in
  15457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15458. */
  15459. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15460. /**
  15461. * Set the quaternion rotation of the bone in local or world space
  15462. * @param quat The quaternion rotation that the bone should be set to
  15463. * @param space The space that the rotation is in
  15464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15465. */
  15466. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15467. /**
  15468. * Set the rotation matrix of the bone in local or world space
  15469. * @param rotMat The rotation matrix that the bone should be set to
  15470. * @param space The space that the rotation is in
  15471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15472. */
  15473. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15474. private _rotateWithMatrix;
  15475. private _getNegativeRotationToRef;
  15476. /**
  15477. * Get the position of the bone in local or world space
  15478. * @param space The space that the returned position is in
  15479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15480. * @returns The position of the bone
  15481. */
  15482. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15483. /**
  15484. * Copy the position of the bone to a vector3 in local or world space
  15485. * @param space The space that the returned position is in
  15486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15487. * @param result The vector3 to copy the position to
  15488. */
  15489. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15490. /**
  15491. * Get the absolute position of the bone (world space)
  15492. * @param mesh The mesh that this bone is attached to
  15493. * @returns The absolute position of the bone
  15494. */
  15495. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15496. /**
  15497. * Copy the absolute position of the bone (world space) to the result param
  15498. * @param mesh The mesh that this bone is attached to
  15499. * @param result The vector3 to copy the absolute position to
  15500. */
  15501. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15502. /**
  15503. * Compute the absolute transforms of this bone and its children
  15504. */
  15505. computeAbsoluteTransforms(): void;
  15506. /**
  15507. * Get the world direction from an axis that is in the local space of the bone
  15508. * @param localAxis The local direction that is used to compute the world direction
  15509. * @param mesh The mesh that this bone is attached to
  15510. * @returns The world direction
  15511. */
  15512. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15513. /**
  15514. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15515. * @param localAxis The local direction that is used to compute the world direction
  15516. * @param mesh The mesh that this bone is attached to
  15517. * @param result The vector3 that the world direction will be copied to
  15518. */
  15519. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15520. /**
  15521. * Get the euler rotation of the bone in local or world space
  15522. * @param space The space that the rotation should be in
  15523. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15524. * @returns The euler rotation
  15525. */
  15526. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15527. /**
  15528. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15529. * @param space The space that the rotation should be in
  15530. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15531. * @param result The vector3 that the rotation should be copied to
  15532. */
  15533. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15534. /**
  15535. * Get the quaternion rotation of the bone in either local or world space
  15536. * @param space The space that the rotation should be in
  15537. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15538. * @returns The quaternion rotation
  15539. */
  15540. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15541. /**
  15542. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15543. * @param space The space that the rotation should be in
  15544. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15545. * @param result The quaternion that the rotation should be copied to
  15546. */
  15547. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15548. /**
  15549. * Get the rotation matrix of the bone in local or world space
  15550. * @param space The space that the rotation should be in
  15551. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15552. * @returns The rotation matrix
  15553. */
  15554. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15555. /**
  15556. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15557. * @param space The space that the rotation should be in
  15558. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15559. * @param result The quaternion that the rotation should be copied to
  15560. */
  15561. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15562. /**
  15563. * Get the world position of a point that is in the local space of the bone
  15564. * @param position The local position
  15565. * @param mesh The mesh that this bone is attached to
  15566. * @returns The world position
  15567. */
  15568. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15569. /**
  15570. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15571. * @param position The local position
  15572. * @param mesh The mesh that this bone is attached to
  15573. * @param result The vector3 that the world position should be copied to
  15574. */
  15575. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15576. /**
  15577. * Get the local position of a point that is in world space
  15578. * @param position The world position
  15579. * @param mesh The mesh that this bone is attached to
  15580. * @returns The local position
  15581. */
  15582. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15583. /**
  15584. * Get the local position of a point that is in world space and copy it to the result param
  15585. * @param position The world position
  15586. * @param mesh The mesh that this bone is attached to
  15587. * @param result The vector3 that the local position should be copied to
  15588. */
  15589. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15590. /**
  15591. * Set the current local matrix as the restPose for this bone.
  15592. */
  15593. setCurrentPoseAsRest(): void;
  15594. }
  15595. }
  15596. declare module BABYLON {
  15597. /**
  15598. * Defines a runtime animation
  15599. */
  15600. export class RuntimeAnimation {
  15601. private _events;
  15602. /**
  15603. * The current frame of the runtime animation
  15604. */
  15605. private _currentFrame;
  15606. /**
  15607. * The animation used by the runtime animation
  15608. */
  15609. private _animation;
  15610. /**
  15611. * The target of the runtime animation
  15612. */
  15613. private _target;
  15614. /**
  15615. * The initiating animatable
  15616. */
  15617. private _host;
  15618. /**
  15619. * The original value of the runtime animation
  15620. */
  15621. private _originalValue;
  15622. /**
  15623. * The original blend value of the runtime animation
  15624. */
  15625. private _originalBlendValue;
  15626. /**
  15627. * The offsets cache of the runtime animation
  15628. */
  15629. private _offsetsCache;
  15630. /**
  15631. * The high limits cache of the runtime animation
  15632. */
  15633. private _highLimitsCache;
  15634. /**
  15635. * Specifies if the runtime animation has been stopped
  15636. */
  15637. private _stopped;
  15638. /**
  15639. * The blending factor of the runtime animation
  15640. */
  15641. private _blendingFactor;
  15642. /**
  15643. * The BabylonJS scene
  15644. */
  15645. private _scene;
  15646. /**
  15647. * The current value of the runtime animation
  15648. */
  15649. private _currentValue;
  15650. /** @hidden */
  15651. _animationState: _IAnimationState;
  15652. /**
  15653. * The active target of the runtime animation
  15654. */
  15655. private _activeTargets;
  15656. private _currentActiveTarget;
  15657. private _directTarget;
  15658. /**
  15659. * The target path of the runtime animation
  15660. */
  15661. private _targetPath;
  15662. /**
  15663. * The weight of the runtime animation
  15664. */
  15665. private _weight;
  15666. /**
  15667. * The ratio offset of the runtime animation
  15668. */
  15669. private _ratioOffset;
  15670. /**
  15671. * The previous delay of the runtime animation
  15672. */
  15673. private _previousDelay;
  15674. /**
  15675. * The previous ratio of the runtime animation
  15676. */
  15677. private _previousRatio;
  15678. private _enableBlending;
  15679. private _keys;
  15680. private _minFrame;
  15681. private _maxFrame;
  15682. private _minValue;
  15683. private _maxValue;
  15684. private _targetIsArray;
  15685. /**
  15686. * Gets the current frame of the runtime animation
  15687. */
  15688. get currentFrame(): number;
  15689. /**
  15690. * Gets the weight of the runtime animation
  15691. */
  15692. get weight(): number;
  15693. /**
  15694. * Gets the current value of the runtime animation
  15695. */
  15696. get currentValue(): any;
  15697. /**
  15698. * Gets the target path of the runtime animation
  15699. */
  15700. get targetPath(): string;
  15701. /**
  15702. * Gets the actual target of the runtime animation
  15703. */
  15704. get target(): any;
  15705. /**
  15706. * Gets the additive state of the runtime animation
  15707. */
  15708. get isAdditive(): boolean;
  15709. /** @hidden */
  15710. _onLoop: () => void;
  15711. /**
  15712. * Create a new RuntimeAnimation object
  15713. * @param target defines the target of the animation
  15714. * @param animation defines the source animation object
  15715. * @param scene defines the hosting scene
  15716. * @param host defines the initiating Animatable
  15717. */
  15718. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15719. private _preparePath;
  15720. /**
  15721. * Gets the animation from the runtime animation
  15722. */
  15723. get animation(): Animation;
  15724. /**
  15725. * Resets the runtime animation to the beginning
  15726. * @param restoreOriginal defines whether to restore the target property to the original value
  15727. */
  15728. reset(restoreOriginal?: boolean): void;
  15729. /**
  15730. * Specifies if the runtime animation is stopped
  15731. * @returns Boolean specifying if the runtime animation is stopped
  15732. */
  15733. isStopped(): boolean;
  15734. /**
  15735. * Disposes of the runtime animation
  15736. */
  15737. dispose(): void;
  15738. /**
  15739. * Apply the interpolated value to the target
  15740. * @param currentValue defines the value computed by the animation
  15741. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15742. */
  15743. setValue(currentValue: any, weight: number): void;
  15744. private _getOriginalValues;
  15745. private _setValue;
  15746. /**
  15747. * Gets the loop pmode of the runtime animation
  15748. * @returns Loop Mode
  15749. */
  15750. private _getCorrectLoopMode;
  15751. /**
  15752. * Move the current animation to a given frame
  15753. * @param frame defines the frame to move to
  15754. */
  15755. goToFrame(frame: number): void;
  15756. /**
  15757. * @hidden Internal use only
  15758. */
  15759. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15760. /**
  15761. * Execute the current animation
  15762. * @param delay defines the delay to add to the current frame
  15763. * @param from defines the lower bound of the animation range
  15764. * @param to defines the upper bound of the animation range
  15765. * @param loop defines if the current animation must loop
  15766. * @param speedRatio defines the current speed ratio
  15767. * @param weight defines the weight of the animation (default is -1 so no weight)
  15768. * @param onLoop optional callback called when animation loops
  15769. * @returns a boolean indicating if the animation is running
  15770. */
  15771. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15772. }
  15773. }
  15774. declare module BABYLON {
  15775. /**
  15776. * Class used to store an actual running animation
  15777. */
  15778. export class Animatable {
  15779. /** defines the target object */
  15780. target: any;
  15781. /** defines the starting frame number (default is 0) */
  15782. fromFrame: number;
  15783. /** defines the ending frame number (default is 100) */
  15784. toFrame: number;
  15785. /** defines if the animation must loop (default is false) */
  15786. loopAnimation: boolean;
  15787. /** defines a callback to call when animation ends if it is not looping */
  15788. onAnimationEnd?: (() => void) | null | undefined;
  15789. /** defines a callback to call when animation loops */
  15790. onAnimationLoop?: (() => void) | null | undefined;
  15791. /** defines whether the animation should be evaluated additively */
  15792. isAdditive: boolean;
  15793. private _localDelayOffset;
  15794. private _pausedDelay;
  15795. private _runtimeAnimations;
  15796. private _paused;
  15797. private _scene;
  15798. private _speedRatio;
  15799. private _weight;
  15800. private _syncRoot;
  15801. /**
  15802. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15803. * This will only apply for non looping animation (default is true)
  15804. */
  15805. disposeOnEnd: boolean;
  15806. /**
  15807. * Gets a boolean indicating if the animation has started
  15808. */
  15809. animationStarted: boolean;
  15810. /**
  15811. * Observer raised when the animation ends
  15812. */
  15813. onAnimationEndObservable: Observable<Animatable>;
  15814. /**
  15815. * Observer raised when the animation loops
  15816. */
  15817. onAnimationLoopObservable: Observable<Animatable>;
  15818. /**
  15819. * Gets the root Animatable used to synchronize and normalize animations
  15820. */
  15821. get syncRoot(): Nullable<Animatable>;
  15822. /**
  15823. * Gets the current frame of the first RuntimeAnimation
  15824. * Used to synchronize Animatables
  15825. */
  15826. get masterFrame(): number;
  15827. /**
  15828. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15829. */
  15830. get weight(): number;
  15831. set weight(value: number);
  15832. /**
  15833. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15834. */
  15835. get speedRatio(): number;
  15836. set speedRatio(value: number);
  15837. /**
  15838. * Creates a new Animatable
  15839. * @param scene defines the hosting scene
  15840. * @param target defines the target object
  15841. * @param fromFrame defines the starting frame number (default is 0)
  15842. * @param toFrame defines the ending frame number (default is 100)
  15843. * @param loopAnimation defines if the animation must loop (default is false)
  15844. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15845. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15846. * @param animations defines a group of animation to add to the new Animatable
  15847. * @param onAnimationLoop defines a callback to call when animation loops
  15848. * @param isAdditive defines whether the animation should be evaluated additively
  15849. */
  15850. constructor(scene: Scene,
  15851. /** defines the target object */
  15852. target: any,
  15853. /** defines the starting frame number (default is 0) */
  15854. fromFrame?: number,
  15855. /** defines the ending frame number (default is 100) */
  15856. toFrame?: number,
  15857. /** defines if the animation must loop (default is false) */
  15858. loopAnimation?: boolean, speedRatio?: number,
  15859. /** defines a callback to call when animation ends if it is not looping */
  15860. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15861. /** defines a callback to call when animation loops */
  15862. onAnimationLoop?: (() => void) | null | undefined,
  15863. /** defines whether the animation should be evaluated additively */
  15864. isAdditive?: boolean);
  15865. /**
  15866. * Synchronize and normalize current Animatable with a source Animatable
  15867. * This is useful when using animation weights and when animations are not of the same length
  15868. * @param root defines the root Animatable to synchronize with
  15869. * @returns the current Animatable
  15870. */
  15871. syncWith(root: Animatable): Animatable;
  15872. /**
  15873. * Gets the list of runtime animations
  15874. * @returns an array of RuntimeAnimation
  15875. */
  15876. getAnimations(): RuntimeAnimation[];
  15877. /**
  15878. * Adds more animations to the current animatable
  15879. * @param target defines the target of the animations
  15880. * @param animations defines the new animations to add
  15881. */
  15882. appendAnimations(target: any, animations: Animation[]): void;
  15883. /**
  15884. * Gets the source animation for a specific property
  15885. * @param property defines the propertyu to look for
  15886. * @returns null or the source animation for the given property
  15887. */
  15888. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15889. /**
  15890. * Gets the runtime animation for a specific property
  15891. * @param property defines the propertyu to look for
  15892. * @returns null or the runtime animation for the given property
  15893. */
  15894. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15895. /**
  15896. * Resets the animatable to its original state
  15897. */
  15898. reset(): void;
  15899. /**
  15900. * Allows the animatable to blend with current running animations
  15901. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15902. * @param blendingSpeed defines the blending speed to use
  15903. */
  15904. enableBlending(blendingSpeed: number): void;
  15905. /**
  15906. * Disable animation blending
  15907. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15908. */
  15909. disableBlending(): void;
  15910. /**
  15911. * Jump directly to a given frame
  15912. * @param frame defines the frame to jump to
  15913. */
  15914. goToFrame(frame: number): void;
  15915. /**
  15916. * Pause the animation
  15917. */
  15918. pause(): void;
  15919. /**
  15920. * Restart the animation
  15921. */
  15922. restart(): void;
  15923. private _raiseOnAnimationEnd;
  15924. /**
  15925. * Stop and delete the current animation
  15926. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15927. * @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)
  15928. */
  15929. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15930. /**
  15931. * Wait asynchronously for the animation to end
  15932. * @returns a promise which will be fullfilled when the animation ends
  15933. */
  15934. waitAsync(): Promise<Animatable>;
  15935. /** @hidden */
  15936. _animate(delay: number): boolean;
  15937. }
  15938. interface Scene {
  15939. /** @hidden */
  15940. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15941. /** @hidden */
  15942. _processLateAnimationBindingsForMatrices(holder: {
  15943. totalWeight: number;
  15944. totalAdditiveWeight: number;
  15945. animations: RuntimeAnimation[];
  15946. additiveAnimations: RuntimeAnimation[];
  15947. originalValue: Matrix;
  15948. }): any;
  15949. /** @hidden */
  15950. _processLateAnimationBindingsForQuaternions(holder: {
  15951. totalWeight: number;
  15952. totalAdditiveWeight: number;
  15953. animations: RuntimeAnimation[];
  15954. additiveAnimations: RuntimeAnimation[];
  15955. originalValue: Quaternion;
  15956. }, refQuaternion: Quaternion): Quaternion;
  15957. /** @hidden */
  15958. _processLateAnimationBindings(): void;
  15959. /**
  15960. * Will start the animation sequence of a given target
  15961. * @param target defines the target
  15962. * @param from defines from which frame should animation start
  15963. * @param to defines until which frame should animation run.
  15964. * @param weight defines the weight to apply to the animation (1.0 by default)
  15965. * @param loop defines if the animation loops
  15966. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15967. * @param onAnimationEnd defines the function to be executed when the animation ends
  15968. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15969. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15970. * @param onAnimationLoop defines the callback to call when an animation loops
  15971. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15972. * @returns the animatable object created for this animation
  15973. */
  15974. 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;
  15975. /**
  15976. * Will start the animation sequence of a given target
  15977. * @param target defines the target
  15978. * @param from defines from which frame should animation start
  15979. * @param to defines until which frame should animation run.
  15980. * @param loop defines if the animation loops
  15981. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15982. * @param onAnimationEnd defines the function to be executed when the animation ends
  15983. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15984. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15985. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15986. * @param onAnimationLoop defines the callback to call when an animation loops
  15987. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15988. * @returns the animatable object created for this animation
  15989. */
  15990. 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;
  15991. /**
  15992. * Will start the animation sequence of a given target and its hierarchy
  15993. * @param target defines the target
  15994. * @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.
  15995. * @param from defines from which frame should animation start
  15996. * @param to defines until which frame should animation run.
  15997. * @param loop defines if the animation loops
  15998. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15999. * @param onAnimationEnd defines the function to be executed when the animation ends
  16000. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16001. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16002. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16003. * @param onAnimationLoop defines the callback to call when an animation loops
  16004. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16005. * @returns the list of created animatables
  16006. */
  16007. 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[];
  16008. /**
  16009. * Begin a new animation on a given node
  16010. * @param target defines the target where the animation will take place
  16011. * @param animations defines the list of animations to start
  16012. * @param from defines the initial value
  16013. * @param to defines the final value
  16014. * @param loop defines if you want animation to loop (off by default)
  16015. * @param speedRatio defines the speed ratio to apply to all animations
  16016. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16017. * @param onAnimationLoop defines the callback to call when an animation loops
  16018. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16019. * @returns the list of created animatables
  16020. */
  16021. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16022. /**
  16023. * Begin a new animation on a given node and its hierarchy
  16024. * @param target defines the root node where the animation will take place
  16025. * @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.
  16026. * @param animations defines the list of animations to start
  16027. * @param from defines the initial value
  16028. * @param to defines the final value
  16029. * @param loop defines if you want animation to loop (off by default)
  16030. * @param speedRatio defines the speed ratio to apply to all animations
  16031. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16032. * @param onAnimationLoop defines the callback to call when an animation loops
  16033. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16034. * @returns the list of animatables created for all nodes
  16035. */
  16036. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16037. /**
  16038. * Gets the animatable associated with a specific target
  16039. * @param target defines the target of the animatable
  16040. * @returns the required animatable if found
  16041. */
  16042. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16043. /**
  16044. * Gets all animatables associated with a given target
  16045. * @param target defines the target to look animatables for
  16046. * @returns an array of Animatables
  16047. */
  16048. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16049. /**
  16050. * Stops and removes all animations that have been applied to the scene
  16051. */
  16052. stopAllAnimations(): void;
  16053. /**
  16054. * Gets the current delta time used by animation engine
  16055. */
  16056. deltaTime: number;
  16057. }
  16058. interface Bone {
  16059. /**
  16060. * Copy an animation range from another bone
  16061. * @param source defines the source bone
  16062. * @param rangeName defines the range name to copy
  16063. * @param frameOffset defines the frame offset
  16064. * @param rescaleAsRequired defines if rescaling must be applied if required
  16065. * @param skelDimensionsRatio defines the scaling ratio
  16066. * @returns true if operation was successful
  16067. */
  16068. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16069. }
  16070. }
  16071. declare module BABYLON {
  16072. /**
  16073. * Class used to handle skinning animations
  16074. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16075. */
  16076. export class Skeleton implements IAnimatable {
  16077. /** defines the skeleton name */
  16078. name: string;
  16079. /** defines the skeleton Id */
  16080. id: string;
  16081. /**
  16082. * Defines the list of child bones
  16083. */
  16084. bones: Bone[];
  16085. /**
  16086. * Defines an estimate of the dimension of the skeleton at rest
  16087. */
  16088. dimensionsAtRest: Vector3;
  16089. /**
  16090. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16091. */
  16092. needInitialSkinMatrix: boolean;
  16093. /**
  16094. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16095. */
  16096. overrideMesh: Nullable<AbstractMesh>;
  16097. /**
  16098. * Gets the list of animations attached to this skeleton
  16099. */
  16100. animations: Array<Animation>;
  16101. private _scene;
  16102. private _isDirty;
  16103. private _transformMatrices;
  16104. private _transformMatrixTexture;
  16105. private _meshesWithPoseMatrix;
  16106. private _animatables;
  16107. private _identity;
  16108. private _synchronizedWithMesh;
  16109. private _ranges;
  16110. private _lastAbsoluteTransformsUpdateId;
  16111. private _canUseTextureForBones;
  16112. private _uniqueId;
  16113. /** @hidden */
  16114. _numBonesWithLinkedTransformNode: number;
  16115. /** @hidden */
  16116. _hasWaitingData: Nullable<boolean>;
  16117. /** @hidden */
  16118. _waitingOverrideMeshId: Nullable<string>;
  16119. /**
  16120. * Specifies if the skeleton should be serialized
  16121. */
  16122. doNotSerialize: boolean;
  16123. private _useTextureToStoreBoneMatrices;
  16124. /**
  16125. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16126. * Please note that this option is not available if the hardware does not support it
  16127. */
  16128. get useTextureToStoreBoneMatrices(): boolean;
  16129. set useTextureToStoreBoneMatrices(value: boolean);
  16130. private _animationPropertiesOverride;
  16131. /**
  16132. * Gets or sets the animation properties override
  16133. */
  16134. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16135. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16136. /**
  16137. * List of inspectable custom properties (used by the Inspector)
  16138. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16139. */
  16140. inspectableCustomProperties: IInspectable[];
  16141. /**
  16142. * An observable triggered before computing the skeleton's matrices
  16143. */
  16144. onBeforeComputeObservable: Observable<Skeleton>;
  16145. /**
  16146. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16147. */
  16148. get isUsingTextureForMatrices(): boolean;
  16149. /**
  16150. * Gets the unique ID of this skeleton
  16151. */
  16152. get uniqueId(): number;
  16153. /**
  16154. * Creates a new skeleton
  16155. * @param name defines the skeleton name
  16156. * @param id defines the skeleton Id
  16157. * @param scene defines the hosting scene
  16158. */
  16159. constructor(
  16160. /** defines the skeleton name */
  16161. name: string,
  16162. /** defines the skeleton Id */
  16163. id: string, scene: Scene);
  16164. /**
  16165. * Gets the current object class name.
  16166. * @return the class name
  16167. */
  16168. getClassName(): string;
  16169. /**
  16170. * Returns an array containing the root bones
  16171. * @returns an array containing the root bones
  16172. */
  16173. getChildren(): Array<Bone>;
  16174. /**
  16175. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16176. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16177. * @returns a Float32Array containing matrices data
  16178. */
  16179. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16180. /**
  16181. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16182. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16183. * @returns a raw texture containing the data
  16184. */
  16185. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16186. /**
  16187. * Gets the current hosting scene
  16188. * @returns a scene object
  16189. */
  16190. getScene(): Scene;
  16191. /**
  16192. * Gets a string representing the current skeleton data
  16193. * @param fullDetails defines a boolean indicating if we want a verbose version
  16194. * @returns a string representing the current skeleton data
  16195. */
  16196. toString(fullDetails?: boolean): string;
  16197. /**
  16198. * Get bone's index searching by name
  16199. * @param name defines bone's name to search for
  16200. * @return the indice of the bone. Returns -1 if not found
  16201. */
  16202. getBoneIndexByName(name: string): number;
  16203. /**
  16204. * Creater a new animation range
  16205. * @param name defines the name of the range
  16206. * @param from defines the start key
  16207. * @param to defines the end key
  16208. */
  16209. createAnimationRange(name: string, from: number, to: number): void;
  16210. /**
  16211. * Delete a specific animation range
  16212. * @param name defines the name of the range
  16213. * @param deleteFrames defines if frames must be removed as well
  16214. */
  16215. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16216. /**
  16217. * Gets a specific animation range
  16218. * @param name defines the name of the range to look for
  16219. * @returns the requested animation range or null if not found
  16220. */
  16221. getAnimationRange(name: string): Nullable<AnimationRange>;
  16222. /**
  16223. * Gets the list of all animation ranges defined on this skeleton
  16224. * @returns an array
  16225. */
  16226. getAnimationRanges(): Nullable<AnimationRange>[];
  16227. /**
  16228. * Copy animation range from a source skeleton.
  16229. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16230. * @param source defines the source skeleton
  16231. * @param name defines the name of the range to copy
  16232. * @param rescaleAsRequired defines if rescaling must be applied if required
  16233. * @returns true if operation was successful
  16234. */
  16235. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16236. /**
  16237. * Forces the skeleton to go to rest pose
  16238. */
  16239. returnToRest(): void;
  16240. private _getHighestAnimationFrame;
  16241. /**
  16242. * Begin a specific animation range
  16243. * @param name defines the name of the range to start
  16244. * @param loop defines if looping must be turned on (false by default)
  16245. * @param speedRatio defines the speed ratio to apply (1 by default)
  16246. * @param onAnimationEnd defines a callback which will be called when animation will end
  16247. * @returns a new animatable
  16248. */
  16249. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16250. /**
  16251. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16252. * @param skeleton defines the Skeleton containing the animation range to convert
  16253. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16254. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16255. * @returns the original skeleton
  16256. */
  16257. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16258. /** @hidden */
  16259. _markAsDirty(): void;
  16260. /** @hidden */
  16261. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16262. /** @hidden */
  16263. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16264. private _computeTransformMatrices;
  16265. /**
  16266. * Build all resources required to render a skeleton
  16267. */
  16268. prepare(): void;
  16269. /**
  16270. * Gets the list of animatables currently running for this skeleton
  16271. * @returns an array of animatables
  16272. */
  16273. getAnimatables(): IAnimatable[];
  16274. /**
  16275. * Clone the current skeleton
  16276. * @param name defines the name of the new skeleton
  16277. * @param id defines the id of the new skeleton
  16278. * @returns the new skeleton
  16279. */
  16280. clone(name: string, id?: string): Skeleton;
  16281. /**
  16282. * Enable animation blending for this skeleton
  16283. * @param blendingSpeed defines the blending speed to apply
  16284. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16285. */
  16286. enableBlending(blendingSpeed?: number): void;
  16287. /**
  16288. * Releases all resources associated with the current skeleton
  16289. */
  16290. dispose(): void;
  16291. /**
  16292. * Serialize the skeleton in a JSON object
  16293. * @returns a JSON object
  16294. */
  16295. serialize(): any;
  16296. /**
  16297. * Creates a new skeleton from serialized data
  16298. * @param parsedSkeleton defines the serialized data
  16299. * @param scene defines the hosting scene
  16300. * @returns a new skeleton
  16301. */
  16302. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16303. /**
  16304. * Compute all node absolute transforms
  16305. * @param forceUpdate defines if computation must be done even if cache is up to date
  16306. */
  16307. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16308. /**
  16309. * Gets the root pose matrix
  16310. * @returns a matrix
  16311. */
  16312. getPoseMatrix(): Nullable<Matrix>;
  16313. /**
  16314. * Sorts bones per internal index
  16315. */
  16316. sortBones(): void;
  16317. private _sortBones;
  16318. /**
  16319. * Set the current local matrix as the restPose for all bones in the skeleton.
  16320. */
  16321. setCurrentPoseAsRest(): void;
  16322. }
  16323. }
  16324. declare module BABYLON {
  16325. /**
  16326. * Creates an instance based on a source mesh.
  16327. */
  16328. export class InstancedMesh extends AbstractMesh {
  16329. private _sourceMesh;
  16330. private _currentLOD;
  16331. /** @hidden */
  16332. _indexInSourceMeshInstanceArray: number;
  16333. constructor(name: string, source: Mesh);
  16334. /**
  16335. * Returns the string "InstancedMesh".
  16336. */
  16337. getClassName(): string;
  16338. /** Gets the list of lights affecting that mesh */
  16339. get lightSources(): Light[];
  16340. _resyncLightSources(): void;
  16341. _resyncLightSource(light: Light): void;
  16342. _removeLightSource(light: Light, dispose: boolean): void;
  16343. /**
  16344. * If the source mesh receives shadows
  16345. */
  16346. get receiveShadows(): boolean;
  16347. /**
  16348. * The material of the source mesh
  16349. */
  16350. get material(): Nullable<Material>;
  16351. /**
  16352. * Visibility of the source mesh
  16353. */
  16354. get visibility(): number;
  16355. /**
  16356. * Skeleton of the source mesh
  16357. */
  16358. get skeleton(): Nullable<Skeleton>;
  16359. /**
  16360. * Rendering ground id of the source mesh
  16361. */
  16362. get renderingGroupId(): number;
  16363. set renderingGroupId(value: number);
  16364. /**
  16365. * Returns the total number of vertices (integer).
  16366. */
  16367. getTotalVertices(): number;
  16368. /**
  16369. * Returns a positive integer : the total number of indices in this mesh geometry.
  16370. * @returns the numner of indices or zero if the mesh has no geometry.
  16371. */
  16372. getTotalIndices(): number;
  16373. /**
  16374. * The source mesh of the instance
  16375. */
  16376. get sourceMesh(): Mesh;
  16377. /**
  16378. * Creates a new InstancedMesh object from the mesh model.
  16379. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16380. * @param name defines the name of the new instance
  16381. * @returns a new InstancedMesh
  16382. */
  16383. createInstance(name: string): InstancedMesh;
  16384. /**
  16385. * Is this node ready to be used/rendered
  16386. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16387. * @return {boolean} is it ready
  16388. */
  16389. isReady(completeCheck?: boolean): boolean;
  16390. /**
  16391. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16392. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16393. * @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.
  16394. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16395. */
  16396. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16397. /**
  16398. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16399. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16400. * The `data` are either a numeric array either a Float32Array.
  16401. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16402. * 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).
  16403. * Note that a new underlying VertexBuffer object is created each call.
  16404. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16405. *
  16406. * Possible `kind` values :
  16407. * - VertexBuffer.PositionKind
  16408. * - VertexBuffer.UVKind
  16409. * - VertexBuffer.UV2Kind
  16410. * - VertexBuffer.UV3Kind
  16411. * - VertexBuffer.UV4Kind
  16412. * - VertexBuffer.UV5Kind
  16413. * - VertexBuffer.UV6Kind
  16414. * - VertexBuffer.ColorKind
  16415. * - VertexBuffer.MatricesIndicesKind
  16416. * - VertexBuffer.MatricesIndicesExtraKind
  16417. * - VertexBuffer.MatricesWeightsKind
  16418. * - VertexBuffer.MatricesWeightsExtraKind
  16419. *
  16420. * Returns the Mesh.
  16421. */
  16422. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16423. /**
  16424. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16425. * If the mesh has no geometry, it is simply returned as it is.
  16426. * The `data` are either a numeric array either a Float32Array.
  16427. * No new underlying VertexBuffer object is created.
  16428. * 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.
  16429. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16430. *
  16431. * Possible `kind` values :
  16432. * - VertexBuffer.PositionKind
  16433. * - VertexBuffer.UVKind
  16434. * - VertexBuffer.UV2Kind
  16435. * - VertexBuffer.UV3Kind
  16436. * - VertexBuffer.UV4Kind
  16437. * - VertexBuffer.UV5Kind
  16438. * - VertexBuffer.UV6Kind
  16439. * - VertexBuffer.ColorKind
  16440. * - VertexBuffer.MatricesIndicesKind
  16441. * - VertexBuffer.MatricesIndicesExtraKind
  16442. * - VertexBuffer.MatricesWeightsKind
  16443. * - VertexBuffer.MatricesWeightsExtraKind
  16444. *
  16445. * Returns the Mesh.
  16446. */
  16447. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16448. /**
  16449. * Sets the mesh indices.
  16450. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16451. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16452. * This method creates a new index buffer each call.
  16453. * Returns the Mesh.
  16454. */
  16455. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16456. /**
  16457. * Boolean : True if the mesh owns the requested kind of data.
  16458. */
  16459. isVerticesDataPresent(kind: string): boolean;
  16460. /**
  16461. * Returns an array of indices (IndicesArray).
  16462. */
  16463. getIndices(): Nullable<IndicesArray>;
  16464. get _positions(): Nullable<Vector3[]>;
  16465. /**
  16466. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16467. * This means the mesh underlying bounding box and sphere are recomputed.
  16468. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16469. * @returns the current mesh
  16470. */
  16471. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16472. /** @hidden */
  16473. _preActivate(): InstancedMesh;
  16474. /** @hidden */
  16475. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16476. /** @hidden */
  16477. _postActivate(): void;
  16478. getWorldMatrix(): Matrix;
  16479. get isAnInstance(): boolean;
  16480. /**
  16481. * Returns the current associated LOD AbstractMesh.
  16482. */
  16483. getLOD(camera: Camera): AbstractMesh;
  16484. /** @hidden */
  16485. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16486. /** @hidden */
  16487. _syncSubMeshes(): InstancedMesh;
  16488. /** @hidden */
  16489. _generatePointsArray(): boolean;
  16490. /** @hidden */
  16491. _updateBoundingInfo(): AbstractMesh;
  16492. /**
  16493. * Creates a new InstancedMesh from the current mesh.
  16494. * - name (string) : the cloned mesh name
  16495. * - newParent (optional Node) : the optional Node to parent the clone to.
  16496. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16497. *
  16498. * Returns the clone.
  16499. */
  16500. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16501. /**
  16502. * Disposes the InstancedMesh.
  16503. * Returns nothing.
  16504. */
  16505. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16506. }
  16507. interface Mesh {
  16508. /**
  16509. * Register a custom buffer that will be instanced
  16510. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16511. * @param kind defines the buffer kind
  16512. * @param stride defines the stride in floats
  16513. */
  16514. registerInstancedBuffer(kind: string, stride: number): void;
  16515. /**
  16516. * true to use the edge renderer for all instances of this mesh
  16517. */
  16518. edgesShareWithInstances: boolean;
  16519. /** @hidden */
  16520. _userInstancedBuffersStorage: {
  16521. data: {
  16522. [key: string]: Float32Array;
  16523. };
  16524. sizes: {
  16525. [key: string]: number;
  16526. };
  16527. vertexBuffers: {
  16528. [key: string]: Nullable<VertexBuffer>;
  16529. };
  16530. strides: {
  16531. [key: string]: number;
  16532. };
  16533. };
  16534. }
  16535. interface AbstractMesh {
  16536. /**
  16537. * Object used to store instanced buffers defined by user
  16538. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16539. */
  16540. instancedBuffers: {
  16541. [key: string]: any;
  16542. };
  16543. }
  16544. }
  16545. declare module BABYLON {
  16546. /**
  16547. * Defines the options associated with the creation of a shader material.
  16548. */
  16549. export interface IShaderMaterialOptions {
  16550. /**
  16551. * Does the material work in alpha blend mode
  16552. */
  16553. needAlphaBlending: boolean;
  16554. /**
  16555. * Does the material work in alpha test mode
  16556. */
  16557. needAlphaTesting: boolean;
  16558. /**
  16559. * The list of attribute names used in the shader
  16560. */
  16561. attributes: string[];
  16562. /**
  16563. * The list of unifrom names used in the shader
  16564. */
  16565. uniforms: string[];
  16566. /**
  16567. * The list of UBO names used in the shader
  16568. */
  16569. uniformBuffers: string[];
  16570. /**
  16571. * The list of sampler names used in the shader
  16572. */
  16573. samplers: string[];
  16574. /**
  16575. * The list of defines used in the shader
  16576. */
  16577. defines: string[];
  16578. }
  16579. /**
  16580. * 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.
  16581. *
  16582. * This returned material effects how the mesh will look based on the code in the shaders.
  16583. *
  16584. * @see https://doc.babylonjs.com/how_to/shader_material
  16585. */
  16586. export class ShaderMaterial extends Material {
  16587. private _shaderPath;
  16588. private _options;
  16589. private _textures;
  16590. private _textureArrays;
  16591. private _floats;
  16592. private _ints;
  16593. private _floatsArrays;
  16594. private _colors3;
  16595. private _colors3Arrays;
  16596. private _colors4;
  16597. private _colors4Arrays;
  16598. private _vectors2;
  16599. private _vectors3;
  16600. private _vectors4;
  16601. private _matrices;
  16602. private _matrixArrays;
  16603. private _matrices3x3;
  16604. private _matrices2x2;
  16605. private _vectors2Arrays;
  16606. private _vectors3Arrays;
  16607. private _vectors4Arrays;
  16608. private _cachedWorldViewMatrix;
  16609. private _cachedWorldViewProjectionMatrix;
  16610. private _renderId;
  16611. private _multiview;
  16612. private _cachedDefines;
  16613. /** Define the Url to load snippets */
  16614. static SnippetUrl: string;
  16615. /** Snippet ID if the material was created from the snippet server */
  16616. snippetId: string;
  16617. /**
  16618. * Instantiate a new shader material.
  16619. * 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.
  16620. * This returned material effects how the mesh will look based on the code in the shaders.
  16621. * @see https://doc.babylonjs.com/how_to/shader_material
  16622. * @param name Define the name of the material in the scene
  16623. * @param scene Define the scene the material belongs to
  16624. * @param shaderPath Defines the route to the shader code in one of three ways:
  16625. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16626. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16627. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16628. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16629. * @param options Define the options used to create the shader
  16630. */
  16631. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16632. /**
  16633. * Gets the shader path used to define the shader code
  16634. * It can be modified to trigger a new compilation
  16635. */
  16636. get shaderPath(): any;
  16637. /**
  16638. * Sets the shader path used to define the shader code
  16639. * It can be modified to trigger a new compilation
  16640. */
  16641. set shaderPath(shaderPath: any);
  16642. /**
  16643. * Gets the options used to compile the shader.
  16644. * They can be modified to trigger a new compilation
  16645. */
  16646. get options(): IShaderMaterialOptions;
  16647. /**
  16648. * Gets the current class name of the material e.g. "ShaderMaterial"
  16649. * Mainly use in serialization.
  16650. * @returns the class name
  16651. */
  16652. getClassName(): string;
  16653. /**
  16654. * Specifies if the material will require alpha blending
  16655. * @returns a boolean specifying if alpha blending is needed
  16656. */
  16657. needAlphaBlending(): boolean;
  16658. /**
  16659. * Specifies if this material should be rendered in alpha test mode
  16660. * @returns a boolean specifying if an alpha test is needed.
  16661. */
  16662. needAlphaTesting(): boolean;
  16663. private _checkUniform;
  16664. /**
  16665. * Set a texture in the shader.
  16666. * @param name Define the name of the uniform samplers as defined in the shader
  16667. * @param texture Define the texture to bind to this sampler
  16668. * @return the material itself allowing "fluent" like uniform updates
  16669. */
  16670. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16671. /**
  16672. * Set a texture array in the shader.
  16673. * @param name Define the name of the uniform sampler array as defined in the shader
  16674. * @param textures Define the list of textures to bind to this sampler
  16675. * @return the material itself allowing "fluent" like uniform updates
  16676. */
  16677. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16678. /**
  16679. * Set a float in the shader.
  16680. * @param name Define the name of the uniform as defined in the shader
  16681. * @param value Define the value to give to the uniform
  16682. * @return the material itself allowing "fluent" like uniform updates
  16683. */
  16684. setFloat(name: string, value: number): ShaderMaterial;
  16685. /**
  16686. * Set a int in the shader.
  16687. * @param name Define the name of the uniform as defined in the shader
  16688. * @param value Define the value to give to the uniform
  16689. * @return the material itself allowing "fluent" like uniform updates
  16690. */
  16691. setInt(name: string, value: number): ShaderMaterial;
  16692. /**
  16693. * Set an array of floats in the shader.
  16694. * @param name Define the name of the uniform as defined in the shader
  16695. * @param value Define the value to give to the uniform
  16696. * @return the material itself allowing "fluent" like uniform updates
  16697. */
  16698. setFloats(name: string, value: number[]): ShaderMaterial;
  16699. /**
  16700. * Set a vec3 in the shader from a Color3.
  16701. * @param name Define the name of the uniform as defined in the shader
  16702. * @param value Define the value to give to the uniform
  16703. * @return the material itself allowing "fluent" like uniform updates
  16704. */
  16705. setColor3(name: string, value: Color3): ShaderMaterial;
  16706. /**
  16707. * Set a vec3 array in the shader from a Color3 array.
  16708. * @param name Define the name of the uniform as defined in the shader
  16709. * @param value Define the value to give to the uniform
  16710. * @return the material itself allowing "fluent" like uniform updates
  16711. */
  16712. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16713. /**
  16714. * Set a vec4 in the shader from a Color4.
  16715. * @param name Define the name of the uniform as defined in the shader
  16716. * @param value Define the value to give to the uniform
  16717. * @return the material itself allowing "fluent" like uniform updates
  16718. */
  16719. setColor4(name: string, value: Color4): ShaderMaterial;
  16720. /**
  16721. * Set a vec4 array in the shader from a Color4 array.
  16722. * @param name Define the name of the uniform as defined in the shader
  16723. * @param value Define the value to give to the uniform
  16724. * @return the material itself allowing "fluent" like uniform updates
  16725. */
  16726. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16727. /**
  16728. * Set a vec2 in the shader from a Vector2.
  16729. * @param name Define the name of the uniform as defined in the shader
  16730. * @param value Define the value to give to the uniform
  16731. * @return the material itself allowing "fluent" like uniform updates
  16732. */
  16733. setVector2(name: string, value: Vector2): ShaderMaterial;
  16734. /**
  16735. * Set a vec3 in the shader from a Vector3.
  16736. * @param name Define the name of the uniform as defined in the shader
  16737. * @param value Define the value to give to the uniform
  16738. * @return the material itself allowing "fluent" like uniform updates
  16739. */
  16740. setVector3(name: string, value: Vector3): ShaderMaterial;
  16741. /**
  16742. * Set a vec4 in the shader from a Vector4.
  16743. * @param name Define the name of the uniform as defined in the shader
  16744. * @param value Define the value to give to the uniform
  16745. * @return the material itself allowing "fluent" like uniform updates
  16746. */
  16747. setVector4(name: string, value: Vector4): ShaderMaterial;
  16748. /**
  16749. * Set a mat4 in the shader from a Matrix.
  16750. * @param name Define the name of the uniform as defined in the shader
  16751. * @param value Define the value to give to the uniform
  16752. * @return the material itself allowing "fluent" like uniform updates
  16753. */
  16754. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16755. /**
  16756. * Set a float32Array in the shader from a matrix array.
  16757. * @param name Define the name of the uniform as defined in the shader
  16758. * @param value Define the value to give to the uniform
  16759. * @return the material itself allowing "fluent" like uniform updates
  16760. */
  16761. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16762. /**
  16763. * Set a mat3 in the shader from a Float32Array.
  16764. * @param name Define the name of the uniform as defined in the shader
  16765. * @param value Define the value to give to the uniform
  16766. * @return the material itself allowing "fluent" like uniform updates
  16767. */
  16768. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16769. /**
  16770. * Set a mat2 in the shader from a Float32Array.
  16771. * @param name Define the name of the uniform as defined in the shader
  16772. * @param value Define the value to give to the uniform
  16773. * @return the material itself allowing "fluent" like uniform updates
  16774. */
  16775. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16776. /**
  16777. * Set a vec2 array in the shader from a number array.
  16778. * @param name Define the name of the uniform as defined in the shader
  16779. * @param value Define the value to give to the uniform
  16780. * @return the material itself allowing "fluent" like uniform updates
  16781. */
  16782. setArray2(name: string, value: number[]): ShaderMaterial;
  16783. /**
  16784. * Set a vec3 array in the shader from a number array.
  16785. * @param name Define the name of the uniform as defined in the shader
  16786. * @param value Define the value to give to the uniform
  16787. * @return the material itself allowing "fluent" like uniform updates
  16788. */
  16789. setArray3(name: string, value: number[]): ShaderMaterial;
  16790. /**
  16791. * Set a vec4 array in the shader from a number array.
  16792. * @param name Define the name of the uniform as defined in the shader
  16793. * @param value Define the value to give to the uniform
  16794. * @return the material itself allowing "fluent" like uniform updates
  16795. */
  16796. setArray4(name: string, value: number[]): ShaderMaterial;
  16797. private _checkCache;
  16798. /**
  16799. * Specifies that the submesh is ready to be used
  16800. * @param mesh defines the mesh to check
  16801. * @param subMesh defines which submesh to check
  16802. * @param useInstances specifies that instances should be used
  16803. * @returns a boolean indicating that the submesh is ready or not
  16804. */
  16805. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16806. /**
  16807. * Checks if the material is ready to render the requested mesh
  16808. * @param mesh Define the mesh to render
  16809. * @param useInstances Define whether or not the material is used with instances
  16810. * @returns true if ready, otherwise false
  16811. */
  16812. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16813. /**
  16814. * Binds the world matrix to the material
  16815. * @param world defines the world transformation matrix
  16816. * @param effectOverride - If provided, use this effect instead of internal effect
  16817. */
  16818. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16819. /**
  16820. * Binds the submesh to this material by preparing the effect and shader to draw
  16821. * @param world defines the world transformation matrix
  16822. * @param mesh defines the mesh containing the submesh
  16823. * @param subMesh defines the submesh to bind the material to
  16824. */
  16825. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16826. /**
  16827. * Binds the material to the mesh
  16828. * @param world defines the world transformation matrix
  16829. * @param mesh defines the mesh to bind the material to
  16830. * @param effectOverride - If provided, use this effect instead of internal effect
  16831. */
  16832. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16833. protected _afterBind(mesh?: Mesh): void;
  16834. /**
  16835. * Gets the active textures from the material
  16836. * @returns an array of textures
  16837. */
  16838. getActiveTextures(): BaseTexture[];
  16839. /**
  16840. * Specifies if the material uses a texture
  16841. * @param texture defines the texture to check against the material
  16842. * @returns a boolean specifying if the material uses the texture
  16843. */
  16844. hasTexture(texture: BaseTexture): boolean;
  16845. /**
  16846. * Makes a duplicate of the material, and gives it a new name
  16847. * @param name defines the new name for the duplicated material
  16848. * @returns the cloned material
  16849. */
  16850. clone(name: string): ShaderMaterial;
  16851. /**
  16852. * Disposes the material
  16853. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16854. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16855. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16856. */
  16857. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16858. /**
  16859. * Serializes this material in a JSON representation
  16860. * @returns the serialized material object
  16861. */
  16862. serialize(): any;
  16863. /**
  16864. * Creates a shader material from parsed shader material data
  16865. * @param source defines the JSON represnetation of the material
  16866. * @param scene defines the hosting scene
  16867. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16868. * @returns a new material
  16869. */
  16870. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16871. /**
  16872. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16873. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16874. * @param url defines the url to load from
  16875. * @param scene defines the hosting scene
  16876. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16877. * @returns a promise that will resolve to the new ShaderMaterial
  16878. */
  16879. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16880. /**
  16881. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16882. * @param snippetId defines the snippet to load
  16883. * @param scene defines the hosting scene
  16884. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16885. * @returns a promise that will resolve to the new ShaderMaterial
  16886. */
  16887. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16888. }
  16889. }
  16890. declare module BABYLON {
  16891. /** @hidden */
  16892. export var colorPixelShader: {
  16893. name: string;
  16894. shader: string;
  16895. };
  16896. }
  16897. declare module BABYLON {
  16898. /** @hidden */
  16899. export var colorVertexShader: {
  16900. name: string;
  16901. shader: string;
  16902. };
  16903. }
  16904. declare module BABYLON {
  16905. /**
  16906. * Line mesh
  16907. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16908. */
  16909. export class LinesMesh extends Mesh {
  16910. /**
  16911. * If vertex color should be applied to the mesh
  16912. */
  16913. readonly useVertexColor?: boolean | undefined;
  16914. /**
  16915. * If vertex alpha should be applied to the mesh
  16916. */
  16917. readonly useVertexAlpha?: boolean | undefined;
  16918. /**
  16919. * Color of the line (Default: White)
  16920. */
  16921. color: Color3;
  16922. /**
  16923. * Alpha of the line (Default: 1)
  16924. */
  16925. alpha: number;
  16926. /**
  16927. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16928. * This margin is expressed in world space coordinates, so its value may vary.
  16929. * Default value is 0.1
  16930. */
  16931. intersectionThreshold: number;
  16932. private _colorShader;
  16933. private color4;
  16934. /**
  16935. * Creates a new LinesMesh
  16936. * @param name defines the name
  16937. * @param scene defines the hosting scene
  16938. * @param parent defines the parent mesh if any
  16939. * @param source defines the optional source LinesMesh used to clone data from
  16940. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16941. * When false, achieved by calling a clone(), also passing False.
  16942. * This will make creation of children, recursive.
  16943. * @param useVertexColor defines if this LinesMesh supports vertex color
  16944. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16945. */
  16946. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16947. /**
  16948. * If vertex color should be applied to the mesh
  16949. */
  16950. useVertexColor?: boolean | undefined,
  16951. /**
  16952. * If vertex alpha should be applied to the mesh
  16953. */
  16954. useVertexAlpha?: boolean | undefined);
  16955. private _addClipPlaneDefine;
  16956. private _removeClipPlaneDefine;
  16957. isReady(): boolean;
  16958. /**
  16959. * Returns the string "LineMesh"
  16960. */
  16961. getClassName(): string;
  16962. /**
  16963. * @hidden
  16964. */
  16965. get material(): Material;
  16966. /**
  16967. * @hidden
  16968. */
  16969. set material(value: Material);
  16970. /**
  16971. * @hidden
  16972. */
  16973. get checkCollisions(): boolean;
  16974. /** @hidden */
  16975. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16976. /** @hidden */
  16977. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16978. /**
  16979. * Disposes of the line mesh
  16980. * @param doNotRecurse If children should be disposed
  16981. */
  16982. dispose(doNotRecurse?: boolean): void;
  16983. /**
  16984. * Returns a new LineMesh object cloned from the current one.
  16985. */
  16986. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16987. /**
  16988. * Creates a new InstancedLinesMesh object from the mesh model.
  16989. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16990. * @param name defines the name of the new instance
  16991. * @returns a new InstancedLinesMesh
  16992. */
  16993. createInstance(name: string): InstancedLinesMesh;
  16994. }
  16995. /**
  16996. * Creates an instance based on a source LinesMesh
  16997. */
  16998. export class InstancedLinesMesh extends InstancedMesh {
  16999. /**
  17000. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17001. * This margin is expressed in world space coordinates, so its value may vary.
  17002. * Initilized with the intersectionThreshold value of the source LinesMesh
  17003. */
  17004. intersectionThreshold: number;
  17005. constructor(name: string, source: LinesMesh);
  17006. /**
  17007. * Returns the string "InstancedLinesMesh".
  17008. */
  17009. getClassName(): string;
  17010. }
  17011. }
  17012. declare module BABYLON {
  17013. /** @hidden */
  17014. export var linePixelShader: {
  17015. name: string;
  17016. shader: string;
  17017. };
  17018. }
  17019. declare module BABYLON {
  17020. /** @hidden */
  17021. export var lineVertexShader: {
  17022. name: string;
  17023. shader: string;
  17024. };
  17025. }
  17026. declare module BABYLON {
  17027. interface Scene {
  17028. /** @hidden */
  17029. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17030. }
  17031. interface AbstractMesh {
  17032. /**
  17033. * Gets the edgesRenderer associated with the mesh
  17034. */
  17035. edgesRenderer: Nullable<EdgesRenderer>;
  17036. }
  17037. interface LinesMesh {
  17038. /**
  17039. * Enables the edge rendering mode on the mesh.
  17040. * This mode makes the mesh edges visible
  17041. * @param epsilon defines the maximal distance between two angles to detect a face
  17042. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17043. * @returns the currentAbstractMesh
  17044. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17045. */
  17046. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17047. }
  17048. interface InstancedLinesMesh {
  17049. /**
  17050. * Enables the edge rendering mode on the mesh.
  17051. * This mode makes the mesh edges visible
  17052. * @param epsilon defines the maximal distance between two angles to detect a face
  17053. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17054. * @returns the current InstancedLinesMesh
  17055. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17056. */
  17057. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17058. }
  17059. /**
  17060. * Defines the minimum contract an Edges renderer should follow.
  17061. */
  17062. export interface IEdgesRenderer extends IDisposable {
  17063. /**
  17064. * Gets or sets a boolean indicating if the edgesRenderer is active
  17065. */
  17066. isEnabled: boolean;
  17067. /**
  17068. * Renders the edges of the attached mesh,
  17069. */
  17070. render(): void;
  17071. /**
  17072. * Checks wether or not the edges renderer is ready to render.
  17073. * @return true if ready, otherwise false.
  17074. */
  17075. isReady(): boolean;
  17076. /**
  17077. * List of instances to render in case the source mesh has instances
  17078. */
  17079. customInstances: SmartArray<Matrix>;
  17080. }
  17081. /**
  17082. * Defines the additional options of the edges renderer
  17083. */
  17084. export interface IEdgesRendererOptions {
  17085. /**
  17086. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17087. * If not defined, the default value is true
  17088. */
  17089. useAlternateEdgeFinder?: boolean;
  17090. /**
  17091. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17092. * If not defined, the default value is true.
  17093. * 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)
  17094. * This option is used only if useAlternateEdgeFinder = true
  17095. */
  17096. useFastVertexMerger?: boolean;
  17097. /**
  17098. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17099. * The default value is 1e-6
  17100. * This option is used only if useAlternateEdgeFinder = true
  17101. */
  17102. epsilonVertexMerge?: number;
  17103. /**
  17104. * 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
  17105. * 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.
  17106. * This option is used only if useAlternateEdgeFinder = true
  17107. */
  17108. applyTessellation?: boolean;
  17109. /**
  17110. * 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
  17111. * The default value is 1e-6
  17112. * This option is used only if useAlternateEdgeFinder = true
  17113. */
  17114. epsilonVertexAligned?: number;
  17115. }
  17116. /**
  17117. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17118. */
  17119. export class EdgesRenderer implements IEdgesRenderer {
  17120. /**
  17121. * Define the size of the edges with an orthographic camera
  17122. */
  17123. edgesWidthScalerForOrthographic: number;
  17124. /**
  17125. * Define the size of the edges with a perspective camera
  17126. */
  17127. edgesWidthScalerForPerspective: number;
  17128. protected _source: AbstractMesh;
  17129. protected _linesPositions: number[];
  17130. protected _linesNormals: number[];
  17131. protected _linesIndices: number[];
  17132. protected _epsilon: number;
  17133. protected _indicesCount: number;
  17134. protected _lineShader: ShaderMaterial;
  17135. protected _ib: DataBuffer;
  17136. protected _buffers: {
  17137. [key: string]: Nullable<VertexBuffer>;
  17138. };
  17139. protected _buffersForInstances: {
  17140. [key: string]: Nullable<VertexBuffer>;
  17141. };
  17142. protected _checkVerticesInsteadOfIndices: boolean;
  17143. protected _options: Nullable<IEdgesRendererOptions>;
  17144. private _meshRebuildObserver;
  17145. private _meshDisposeObserver;
  17146. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17147. isEnabled: boolean;
  17148. /**
  17149. * List of instances to render in case the source mesh has instances
  17150. */
  17151. customInstances: SmartArray<Matrix>;
  17152. private static GetShader;
  17153. /**
  17154. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17155. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17156. * @param source Mesh used to create edges
  17157. * @param epsilon sum of angles in adjacency to check for edge
  17158. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17159. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17160. * @param options The options to apply when generating the edges
  17161. */
  17162. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17163. protected _prepareRessources(): void;
  17164. /** @hidden */
  17165. _rebuild(): void;
  17166. /**
  17167. * Releases the required resources for the edges renderer
  17168. */
  17169. dispose(): void;
  17170. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17171. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17172. /**
  17173. * Checks if the pair of p0 and p1 is en edge
  17174. * @param faceIndex
  17175. * @param edge
  17176. * @param faceNormals
  17177. * @param p0
  17178. * @param p1
  17179. * @private
  17180. */
  17181. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17182. /**
  17183. * push line into the position, normal and index buffer
  17184. * @protected
  17185. */
  17186. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17187. /**
  17188. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17189. */
  17190. private _tessellateTriangle;
  17191. private _generateEdgesLinesAlternate;
  17192. /**
  17193. * Generates lines edges from adjacencjes
  17194. * @private
  17195. */
  17196. _generateEdgesLines(): void;
  17197. /**
  17198. * Checks wether or not the edges renderer is ready to render.
  17199. * @return true if ready, otherwise false.
  17200. */
  17201. isReady(): boolean;
  17202. /**
  17203. * Renders the edges of the attached mesh,
  17204. */
  17205. render(): void;
  17206. }
  17207. /**
  17208. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17209. */
  17210. export class LineEdgesRenderer extends EdgesRenderer {
  17211. /**
  17212. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17213. * @param source LineMesh used to generate edges
  17214. * @param epsilon not important (specified angle for edge detection)
  17215. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17216. */
  17217. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17218. /**
  17219. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17220. */
  17221. _generateEdgesLines(): void;
  17222. }
  17223. }
  17224. declare module BABYLON {
  17225. /**
  17226. * This represents the object necessary to create a rendering group.
  17227. * This is exclusively used and created by the rendering manager.
  17228. * To modify the behavior, you use the available helpers in your scene or meshes.
  17229. * @hidden
  17230. */
  17231. export class RenderingGroup {
  17232. index: number;
  17233. private static _zeroVector;
  17234. private _scene;
  17235. private _opaqueSubMeshes;
  17236. private _transparentSubMeshes;
  17237. private _alphaTestSubMeshes;
  17238. private _depthOnlySubMeshes;
  17239. private _particleSystems;
  17240. private _spriteManagers;
  17241. private _opaqueSortCompareFn;
  17242. private _alphaTestSortCompareFn;
  17243. private _transparentSortCompareFn;
  17244. private _renderOpaque;
  17245. private _renderAlphaTest;
  17246. private _renderTransparent;
  17247. /** @hidden */
  17248. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17249. onBeforeTransparentRendering: () => void;
  17250. /**
  17251. * Set the opaque sort comparison function.
  17252. * If null the sub meshes will be render in the order they were created
  17253. */
  17254. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17255. /**
  17256. * Set the alpha test sort comparison function.
  17257. * If null the sub meshes will be render in the order they were created
  17258. */
  17259. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17260. /**
  17261. * Set the transparent sort comparison function.
  17262. * If null the sub meshes will be render in the order they were created
  17263. */
  17264. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17265. /**
  17266. * Creates a new rendering group.
  17267. * @param index The rendering group index
  17268. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17269. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17270. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17271. */
  17272. 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>);
  17273. /**
  17274. * Render all the sub meshes contained in the group.
  17275. * @param customRenderFunction Used to override the default render behaviour of the group.
  17276. * @returns true if rendered some submeshes.
  17277. */
  17278. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17279. /**
  17280. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17281. * @param subMeshes The submeshes to render
  17282. */
  17283. private renderOpaqueSorted;
  17284. /**
  17285. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17286. * @param subMeshes The submeshes to render
  17287. */
  17288. private renderAlphaTestSorted;
  17289. /**
  17290. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17291. * @param subMeshes The submeshes to render
  17292. */
  17293. private renderTransparentSorted;
  17294. /**
  17295. * Renders the submeshes in a specified order.
  17296. * @param subMeshes The submeshes to sort before render
  17297. * @param sortCompareFn The comparison function use to sort
  17298. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17299. * @param transparent Specifies to activate blending if true
  17300. */
  17301. private static renderSorted;
  17302. /**
  17303. * Renders the submeshes in the order they were dispatched (no sort applied).
  17304. * @param subMeshes The submeshes to render
  17305. */
  17306. private static renderUnsorted;
  17307. /**
  17308. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17309. * are rendered back to front if in the same alpha index.
  17310. *
  17311. * @param a The first submesh
  17312. * @param b The second submesh
  17313. * @returns The result of the comparison
  17314. */
  17315. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17316. /**
  17317. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17318. * are rendered back to front.
  17319. *
  17320. * @param a The first submesh
  17321. * @param b The second submesh
  17322. * @returns The result of the comparison
  17323. */
  17324. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17325. /**
  17326. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17327. * are rendered front to back (prevent overdraw).
  17328. *
  17329. * @param a The first submesh
  17330. * @param b The second submesh
  17331. * @returns The result of the comparison
  17332. */
  17333. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17334. /**
  17335. * Resets the different lists of submeshes to prepare a new frame.
  17336. */
  17337. prepare(): void;
  17338. dispose(): void;
  17339. /**
  17340. * Inserts the submesh in its correct queue depending on its material.
  17341. * @param subMesh The submesh to dispatch
  17342. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17343. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17344. */
  17345. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17346. dispatchSprites(spriteManager: ISpriteManager): void;
  17347. dispatchParticles(particleSystem: IParticleSystem): void;
  17348. private _renderParticles;
  17349. private _renderSprites;
  17350. }
  17351. }
  17352. declare module BABYLON {
  17353. /**
  17354. * Interface describing the different options available in the rendering manager
  17355. * regarding Auto Clear between groups.
  17356. */
  17357. export interface IRenderingManagerAutoClearSetup {
  17358. /**
  17359. * Defines whether or not autoclear is enable.
  17360. */
  17361. autoClear: boolean;
  17362. /**
  17363. * Defines whether or not to autoclear the depth buffer.
  17364. */
  17365. depth: boolean;
  17366. /**
  17367. * Defines whether or not to autoclear the stencil buffer.
  17368. */
  17369. stencil: boolean;
  17370. }
  17371. /**
  17372. * This class is used by the onRenderingGroupObservable
  17373. */
  17374. export class RenderingGroupInfo {
  17375. /**
  17376. * The Scene that being rendered
  17377. */
  17378. scene: Scene;
  17379. /**
  17380. * The camera currently used for the rendering pass
  17381. */
  17382. camera: Nullable<Camera>;
  17383. /**
  17384. * The ID of the renderingGroup being processed
  17385. */
  17386. renderingGroupId: number;
  17387. }
  17388. /**
  17389. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17390. * It is enable to manage the different groups as well as the different necessary sort functions.
  17391. * This should not be used directly aside of the few static configurations
  17392. */
  17393. export class RenderingManager {
  17394. /**
  17395. * The max id used for rendering groups (not included)
  17396. */
  17397. static MAX_RENDERINGGROUPS: number;
  17398. /**
  17399. * The min id used for rendering groups (included)
  17400. */
  17401. static MIN_RENDERINGGROUPS: number;
  17402. /**
  17403. * Used to globally prevent autoclearing scenes.
  17404. */
  17405. static AUTOCLEAR: boolean;
  17406. /**
  17407. * @hidden
  17408. */
  17409. _useSceneAutoClearSetup: boolean;
  17410. private _scene;
  17411. private _renderingGroups;
  17412. private _depthStencilBufferAlreadyCleaned;
  17413. private _autoClearDepthStencil;
  17414. private _customOpaqueSortCompareFn;
  17415. private _customAlphaTestSortCompareFn;
  17416. private _customTransparentSortCompareFn;
  17417. private _renderingGroupInfo;
  17418. /**
  17419. * Instantiates a new rendering group for a particular scene
  17420. * @param scene Defines the scene the groups belongs to
  17421. */
  17422. constructor(scene: Scene);
  17423. private _clearDepthStencilBuffer;
  17424. /**
  17425. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17426. * @hidden
  17427. */
  17428. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17429. /**
  17430. * Resets the different information of the group to prepare a new frame
  17431. * @hidden
  17432. */
  17433. reset(): void;
  17434. /**
  17435. * Dispose and release the group and its associated resources.
  17436. * @hidden
  17437. */
  17438. dispose(): void;
  17439. /**
  17440. * Clear the info related to rendering groups preventing retention points during dispose.
  17441. */
  17442. freeRenderingGroups(): void;
  17443. private _prepareRenderingGroup;
  17444. /**
  17445. * Add a sprite manager to the rendering manager in order to render it this frame.
  17446. * @param spriteManager Define the sprite manager to render
  17447. */
  17448. dispatchSprites(spriteManager: ISpriteManager): void;
  17449. /**
  17450. * Add a particle system to the rendering manager in order to render it this frame.
  17451. * @param particleSystem Define the particle system to render
  17452. */
  17453. dispatchParticles(particleSystem: IParticleSystem): void;
  17454. /**
  17455. * Add a submesh to the manager in order to render it this frame
  17456. * @param subMesh The submesh to dispatch
  17457. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17458. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17459. */
  17460. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17461. /**
  17462. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17463. * This allowed control for front to back rendering or reversly depending of the special needs.
  17464. *
  17465. * @param renderingGroupId The rendering group id corresponding to its index
  17466. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17467. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17468. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17469. */
  17470. 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;
  17471. /**
  17472. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17473. *
  17474. * @param renderingGroupId The rendering group id corresponding to its index
  17475. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17476. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17477. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17478. */
  17479. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17480. /**
  17481. * Gets the current auto clear configuration for one rendering group of the rendering
  17482. * manager.
  17483. * @param index the rendering group index to get the information for
  17484. * @returns The auto clear setup for the requested rendering group
  17485. */
  17486. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17487. }
  17488. }
  17489. declare module BABYLON {
  17490. /**
  17491. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17492. */
  17493. export interface ICustomShaderOptions {
  17494. /**
  17495. * Gets or sets the custom shader name to use
  17496. */
  17497. shaderName: string;
  17498. /**
  17499. * The list of attribute names used in the shader
  17500. */
  17501. attributes?: string[];
  17502. /**
  17503. * The list of unifrom names used in the shader
  17504. */
  17505. uniforms?: string[];
  17506. /**
  17507. * The list of sampler names used in the shader
  17508. */
  17509. samplers?: string[];
  17510. /**
  17511. * The list of defines used in the shader
  17512. */
  17513. defines?: string[];
  17514. }
  17515. /**
  17516. * Interface to implement to create a shadow generator compatible with BJS.
  17517. */
  17518. export interface IShadowGenerator {
  17519. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17520. id: string;
  17521. /**
  17522. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17523. * @returns The render target texture if present otherwise, null
  17524. */
  17525. getShadowMap(): Nullable<RenderTargetTexture>;
  17526. /**
  17527. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17528. * @param subMesh The submesh we want to render in the shadow map
  17529. * @param useInstances Defines wether will draw in the map using instances
  17530. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17531. * @returns true if ready otherwise, false
  17532. */
  17533. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17534. /**
  17535. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17536. * @param defines Defines of the material we want to update
  17537. * @param lightIndex Index of the light in the enabled light list of the material
  17538. */
  17539. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17540. /**
  17541. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17542. * defined in the generator but impacting the effect).
  17543. * It implies the unifroms available on the materials are the standard BJS ones.
  17544. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17545. * @param effect The effect we are binfing the information for
  17546. */
  17547. bindShadowLight(lightIndex: string, effect: Effect): void;
  17548. /**
  17549. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17550. * (eq to shadow prjection matrix * light transform matrix)
  17551. * @returns The transform matrix used to create the shadow map
  17552. */
  17553. getTransformMatrix(): Matrix;
  17554. /**
  17555. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17556. * Cube and 2D textures for instance.
  17557. */
  17558. recreateShadowMap(): void;
  17559. /**
  17560. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17561. * @param onCompiled Callback triggered at the and of the effects compilation
  17562. * @param options Sets of optional options forcing the compilation with different modes
  17563. */
  17564. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17565. useInstances: boolean;
  17566. }>): void;
  17567. /**
  17568. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17569. * @param options Sets of optional options forcing the compilation with different modes
  17570. * @returns A promise that resolves when the compilation completes
  17571. */
  17572. forceCompilationAsync(options?: Partial<{
  17573. useInstances: boolean;
  17574. }>): Promise<void>;
  17575. /**
  17576. * Serializes the shadow generator setup to a json object.
  17577. * @returns The serialized JSON object
  17578. */
  17579. serialize(): any;
  17580. /**
  17581. * Disposes the Shadow map and related Textures and effects.
  17582. */
  17583. dispose(): void;
  17584. }
  17585. /**
  17586. * Default implementation IShadowGenerator.
  17587. * This is the main object responsible of generating shadows in the framework.
  17588. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17589. */
  17590. export class ShadowGenerator implements IShadowGenerator {
  17591. /**
  17592. * Name of the shadow generator class
  17593. */
  17594. static CLASSNAME: string;
  17595. /**
  17596. * Shadow generator mode None: no filtering applied.
  17597. */
  17598. static readonly FILTER_NONE: number;
  17599. /**
  17600. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17601. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17602. */
  17603. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17604. /**
  17605. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17606. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17607. */
  17608. static readonly FILTER_POISSONSAMPLING: number;
  17609. /**
  17610. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17611. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17612. */
  17613. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17614. /**
  17615. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17616. * edge artifacts on steep falloff.
  17617. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17618. */
  17619. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17620. /**
  17621. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17622. * edge artifacts on steep falloff.
  17623. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17624. */
  17625. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17626. /**
  17627. * Shadow generator mode PCF: Percentage Closer Filtering
  17628. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17629. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17630. */
  17631. static readonly FILTER_PCF: number;
  17632. /**
  17633. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17634. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17635. * Contact Hardening
  17636. */
  17637. static readonly FILTER_PCSS: number;
  17638. /**
  17639. * Reserved for PCF and PCSS
  17640. * Highest Quality.
  17641. *
  17642. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17643. *
  17644. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17645. */
  17646. static readonly QUALITY_HIGH: number;
  17647. /**
  17648. * Reserved for PCF and PCSS
  17649. * Good tradeoff for quality/perf cross devices
  17650. *
  17651. * Execute PCF on a 3*3 kernel.
  17652. *
  17653. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17654. */
  17655. static readonly QUALITY_MEDIUM: number;
  17656. /**
  17657. * Reserved for PCF and PCSS
  17658. * The lowest quality but the fastest.
  17659. *
  17660. * Execute PCF on a 1*1 kernel.
  17661. *
  17662. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17663. */
  17664. static readonly QUALITY_LOW: number;
  17665. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17666. id: string;
  17667. /** Gets or sets the custom shader name to use */
  17668. customShaderOptions: ICustomShaderOptions;
  17669. /**
  17670. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17671. */
  17672. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17673. /**
  17674. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17675. */
  17676. onAfterShadowMapRenderObservable: Observable<Effect>;
  17677. /**
  17678. * Observable triggered before a mesh is rendered in the shadow map.
  17679. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17680. */
  17681. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17682. /**
  17683. * Observable triggered after a mesh is rendered in the shadow map.
  17684. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17685. */
  17686. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17687. protected _bias: number;
  17688. /**
  17689. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17690. */
  17691. get bias(): number;
  17692. /**
  17693. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17694. */
  17695. set bias(bias: number);
  17696. protected _normalBias: number;
  17697. /**
  17698. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17699. */
  17700. get normalBias(): number;
  17701. /**
  17702. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17703. */
  17704. set normalBias(normalBias: number);
  17705. protected _blurBoxOffset: number;
  17706. /**
  17707. * Gets the blur box offset: offset applied during the blur pass.
  17708. * Only useful if useKernelBlur = false
  17709. */
  17710. get blurBoxOffset(): number;
  17711. /**
  17712. * Sets the blur box offset: offset applied during the blur pass.
  17713. * Only useful if useKernelBlur = false
  17714. */
  17715. set blurBoxOffset(value: number);
  17716. protected _blurScale: number;
  17717. /**
  17718. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17719. * 2 means half of the size.
  17720. */
  17721. get blurScale(): number;
  17722. /**
  17723. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17724. * 2 means half of the size.
  17725. */
  17726. set blurScale(value: number);
  17727. protected _blurKernel: number;
  17728. /**
  17729. * Gets the blur kernel: kernel size of the blur pass.
  17730. * Only useful if useKernelBlur = true
  17731. */
  17732. get blurKernel(): number;
  17733. /**
  17734. * Sets the blur kernel: kernel size of the blur pass.
  17735. * Only useful if useKernelBlur = true
  17736. */
  17737. set blurKernel(value: number);
  17738. protected _useKernelBlur: boolean;
  17739. /**
  17740. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17741. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17742. */
  17743. get useKernelBlur(): boolean;
  17744. /**
  17745. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17746. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17747. */
  17748. set useKernelBlur(value: boolean);
  17749. protected _depthScale: number;
  17750. /**
  17751. * Gets the depth scale used in ESM mode.
  17752. */
  17753. get depthScale(): number;
  17754. /**
  17755. * Sets the depth scale used in ESM mode.
  17756. * This can override the scale stored on the light.
  17757. */
  17758. set depthScale(value: number);
  17759. protected _validateFilter(filter: number): number;
  17760. protected _filter: number;
  17761. /**
  17762. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17763. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17764. */
  17765. get filter(): number;
  17766. /**
  17767. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17768. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17769. */
  17770. set filter(value: number);
  17771. /**
  17772. * Gets if the current filter is set to Poisson Sampling.
  17773. */
  17774. get usePoissonSampling(): boolean;
  17775. /**
  17776. * Sets the current filter to Poisson Sampling.
  17777. */
  17778. set usePoissonSampling(value: boolean);
  17779. /**
  17780. * Gets if the current filter is set to ESM.
  17781. */
  17782. get useExponentialShadowMap(): boolean;
  17783. /**
  17784. * Sets the current filter is to ESM.
  17785. */
  17786. set useExponentialShadowMap(value: boolean);
  17787. /**
  17788. * Gets if the current filter is set to filtered ESM.
  17789. */
  17790. get useBlurExponentialShadowMap(): boolean;
  17791. /**
  17792. * Gets if the current filter is set to filtered ESM.
  17793. */
  17794. set useBlurExponentialShadowMap(value: boolean);
  17795. /**
  17796. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17797. * exponential to prevent steep falloff artifacts).
  17798. */
  17799. get useCloseExponentialShadowMap(): boolean;
  17800. /**
  17801. * Sets the current filter to "close ESM" (using the inverse of the
  17802. * exponential to prevent steep falloff artifacts).
  17803. */
  17804. set useCloseExponentialShadowMap(value: boolean);
  17805. /**
  17806. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17807. * exponential to prevent steep falloff artifacts).
  17808. */
  17809. get useBlurCloseExponentialShadowMap(): boolean;
  17810. /**
  17811. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17812. * exponential to prevent steep falloff artifacts).
  17813. */
  17814. set useBlurCloseExponentialShadowMap(value: boolean);
  17815. /**
  17816. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17817. */
  17818. get usePercentageCloserFiltering(): boolean;
  17819. /**
  17820. * Sets the current filter to "PCF" (percentage closer filtering).
  17821. */
  17822. set usePercentageCloserFiltering(value: boolean);
  17823. protected _filteringQuality: number;
  17824. /**
  17825. * Gets the PCF or PCSS Quality.
  17826. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17827. */
  17828. get filteringQuality(): number;
  17829. /**
  17830. * Sets the PCF or PCSS Quality.
  17831. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17832. */
  17833. set filteringQuality(filteringQuality: number);
  17834. /**
  17835. * Gets if the current filter is set to "PCSS" (contact hardening).
  17836. */
  17837. get useContactHardeningShadow(): boolean;
  17838. /**
  17839. * Sets the current filter to "PCSS" (contact hardening).
  17840. */
  17841. set useContactHardeningShadow(value: boolean);
  17842. protected _contactHardeningLightSizeUVRatio: number;
  17843. /**
  17844. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17845. * Using a ratio helps keeping shape stability independently of the map size.
  17846. *
  17847. * It does not account for the light projection as it was having too much
  17848. * instability during the light setup or during light position changes.
  17849. *
  17850. * Only valid if useContactHardeningShadow is true.
  17851. */
  17852. get contactHardeningLightSizeUVRatio(): number;
  17853. /**
  17854. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17855. * Using a ratio helps keeping shape stability independently of the map size.
  17856. *
  17857. * It does not account for the light projection as it was having too much
  17858. * instability during the light setup or during light position changes.
  17859. *
  17860. * Only valid if useContactHardeningShadow is true.
  17861. */
  17862. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17863. protected _darkness: number;
  17864. /** Gets or sets the actual darkness of a shadow */
  17865. get darkness(): number;
  17866. set darkness(value: number);
  17867. /**
  17868. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17869. * 0 means strongest and 1 would means no shadow.
  17870. * @returns the darkness.
  17871. */
  17872. getDarkness(): number;
  17873. /**
  17874. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17875. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17876. * @returns the shadow generator allowing fluent coding.
  17877. */
  17878. setDarkness(darkness: number): ShadowGenerator;
  17879. protected _transparencyShadow: boolean;
  17880. /** Gets or sets the ability to have transparent shadow */
  17881. get transparencyShadow(): boolean;
  17882. set transparencyShadow(value: boolean);
  17883. /**
  17884. * Sets the ability to have transparent shadow (boolean).
  17885. * @param transparent True if transparent else False
  17886. * @returns the shadow generator allowing fluent coding
  17887. */
  17888. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17889. /**
  17890. * Enables or disables shadows with varying strength based on the transparency
  17891. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17892. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17893. * mesh.visibility * alphaTexture.a
  17894. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17895. */
  17896. enableSoftTransparentShadow: boolean;
  17897. protected _shadowMap: Nullable<RenderTargetTexture>;
  17898. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17899. /**
  17900. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17901. * @returns The render target texture if present otherwise, null
  17902. */
  17903. getShadowMap(): Nullable<RenderTargetTexture>;
  17904. /**
  17905. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17906. * @returns The render target texture if the shadow map is present otherwise, null
  17907. */
  17908. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17909. /**
  17910. * Gets the class name of that object
  17911. * @returns "ShadowGenerator"
  17912. */
  17913. getClassName(): string;
  17914. /**
  17915. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17916. * @param mesh Mesh to add
  17917. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17918. * @returns the Shadow Generator itself
  17919. */
  17920. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17921. /**
  17922. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17923. * @param mesh Mesh to remove
  17924. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17925. * @returns the Shadow Generator itself
  17926. */
  17927. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17928. /**
  17929. * Controls the extent to which the shadows fade out at the edge of the frustum
  17930. */
  17931. frustumEdgeFalloff: number;
  17932. protected _light: IShadowLight;
  17933. /**
  17934. * Returns the associated light object.
  17935. * @returns the light generating the shadow
  17936. */
  17937. getLight(): IShadowLight;
  17938. /**
  17939. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17940. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17941. * It might on the other hand introduce peter panning.
  17942. */
  17943. forceBackFacesOnly: boolean;
  17944. protected _scene: Scene;
  17945. protected _lightDirection: Vector3;
  17946. protected _effect: Effect;
  17947. protected _viewMatrix: Matrix;
  17948. protected _projectionMatrix: Matrix;
  17949. protected _transformMatrix: Matrix;
  17950. protected _cachedPosition: Vector3;
  17951. protected _cachedDirection: Vector3;
  17952. protected _cachedDefines: string;
  17953. protected _currentRenderID: number;
  17954. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17955. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17956. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17957. protected _blurPostProcesses: PostProcess[];
  17958. protected _mapSize: number;
  17959. protected _currentFaceIndex: number;
  17960. protected _currentFaceIndexCache: number;
  17961. protected _textureType: number;
  17962. protected _defaultTextureMatrix: Matrix;
  17963. protected _storedUniqueId: Nullable<number>;
  17964. /** @hidden */
  17965. static _SceneComponentInitialization: (scene: Scene) => void;
  17966. /**
  17967. * Creates a ShadowGenerator object.
  17968. * A ShadowGenerator is the required tool to use the shadows.
  17969. * Each light casting shadows needs to use its own ShadowGenerator.
  17970. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17971. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17972. * @param light The light object generating the shadows.
  17973. * @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.
  17974. */
  17975. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17976. protected _initializeGenerator(): void;
  17977. protected _createTargetRenderTexture(): void;
  17978. protected _initializeShadowMap(): void;
  17979. protected _initializeBlurRTTAndPostProcesses(): void;
  17980. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17981. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17982. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17983. protected _applyFilterValues(): void;
  17984. /**
  17985. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17986. * @param onCompiled Callback triggered at the and of the effects compilation
  17987. * @param options Sets of optional options forcing the compilation with different modes
  17988. */
  17989. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17990. useInstances: boolean;
  17991. }>): void;
  17992. /**
  17993. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17994. * @param options Sets of optional options forcing the compilation with different modes
  17995. * @returns A promise that resolves when the compilation completes
  17996. */
  17997. forceCompilationAsync(options?: Partial<{
  17998. useInstances: boolean;
  17999. }>): Promise<void>;
  18000. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18001. private _prepareShadowDefines;
  18002. /**
  18003. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18004. * @param subMesh The submesh we want to render in the shadow map
  18005. * @param useInstances Defines wether will draw in the map using instances
  18006. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18007. * @returns true if ready otherwise, false
  18008. */
  18009. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18010. /**
  18011. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18012. * @param defines Defines of the material we want to update
  18013. * @param lightIndex Index of the light in the enabled light list of the material
  18014. */
  18015. prepareDefines(defines: any, lightIndex: number): void;
  18016. /**
  18017. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18018. * defined in the generator but impacting the effect).
  18019. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18020. * @param effect The effect we are binfing the information for
  18021. */
  18022. bindShadowLight(lightIndex: string, effect: Effect): void;
  18023. /**
  18024. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18025. * (eq to shadow prjection matrix * light transform matrix)
  18026. * @returns The transform matrix used to create the shadow map
  18027. */
  18028. getTransformMatrix(): Matrix;
  18029. /**
  18030. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18031. * Cube and 2D textures for instance.
  18032. */
  18033. recreateShadowMap(): void;
  18034. protected _disposeBlurPostProcesses(): void;
  18035. protected _disposeRTTandPostProcesses(): void;
  18036. /**
  18037. * Disposes the ShadowGenerator.
  18038. * Returns nothing.
  18039. */
  18040. dispose(): void;
  18041. /**
  18042. * Serializes the shadow generator setup to a json object.
  18043. * @returns The serialized JSON object
  18044. */
  18045. serialize(): any;
  18046. /**
  18047. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18048. * @param parsedShadowGenerator The JSON object to parse
  18049. * @param scene The scene to create the shadow map for
  18050. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18051. * @returns The parsed shadow generator
  18052. */
  18053. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18054. }
  18055. }
  18056. declare module BABYLON {
  18057. /**
  18058. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18059. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18060. * 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.
  18061. */
  18062. export abstract class Light extends Node {
  18063. /**
  18064. * Falloff Default: light is falling off following the material specification:
  18065. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18066. */
  18067. static readonly FALLOFF_DEFAULT: number;
  18068. /**
  18069. * Falloff Physical: light is falling off following the inverse squared distance law.
  18070. */
  18071. static readonly FALLOFF_PHYSICAL: number;
  18072. /**
  18073. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18074. * to enhance interoperability with other engines.
  18075. */
  18076. static readonly FALLOFF_GLTF: number;
  18077. /**
  18078. * Falloff Standard: light is falling off like in the standard material
  18079. * to enhance interoperability with other materials.
  18080. */
  18081. static readonly FALLOFF_STANDARD: number;
  18082. /**
  18083. * If every light affecting the material is in this lightmapMode,
  18084. * material.lightmapTexture adds or multiplies
  18085. * (depends on material.useLightmapAsShadowmap)
  18086. * after every other light calculations.
  18087. */
  18088. static readonly LIGHTMAP_DEFAULT: number;
  18089. /**
  18090. * material.lightmapTexture as only diffuse lighting from this light
  18091. * adds only specular lighting from this light
  18092. * adds dynamic shadows
  18093. */
  18094. static readonly LIGHTMAP_SPECULAR: number;
  18095. /**
  18096. * material.lightmapTexture as only lighting
  18097. * no light calculation from this light
  18098. * only adds dynamic shadows from this light
  18099. */
  18100. static readonly LIGHTMAP_SHADOWSONLY: number;
  18101. /**
  18102. * Each light type uses the default quantity according to its type:
  18103. * point/spot lights use luminous intensity
  18104. * directional lights use illuminance
  18105. */
  18106. static readonly INTENSITYMODE_AUTOMATIC: number;
  18107. /**
  18108. * lumen (lm)
  18109. */
  18110. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18111. /**
  18112. * candela (lm/sr)
  18113. */
  18114. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18115. /**
  18116. * lux (lm/m^2)
  18117. */
  18118. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18119. /**
  18120. * nit (cd/m^2)
  18121. */
  18122. static readonly INTENSITYMODE_LUMINANCE: number;
  18123. /**
  18124. * Light type const id of the point light.
  18125. */
  18126. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18127. /**
  18128. * Light type const id of the directional light.
  18129. */
  18130. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18131. /**
  18132. * Light type const id of the spot light.
  18133. */
  18134. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18135. /**
  18136. * Light type const id of the hemispheric light.
  18137. */
  18138. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18139. /**
  18140. * Diffuse gives the basic color to an object.
  18141. */
  18142. diffuse: Color3;
  18143. /**
  18144. * Specular produces a highlight color on an object.
  18145. * Note: This is note affecting PBR materials.
  18146. */
  18147. specular: Color3;
  18148. /**
  18149. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18150. * falling off base on range or angle.
  18151. * This can be set to any values in Light.FALLOFF_x.
  18152. *
  18153. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18154. * other types of materials.
  18155. */
  18156. falloffType: number;
  18157. /**
  18158. * Strength of the light.
  18159. * Note: By default it is define in the framework own unit.
  18160. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18161. */
  18162. intensity: number;
  18163. private _range;
  18164. protected _inverseSquaredRange: number;
  18165. /**
  18166. * Defines how far from the source the light is impacting in scene units.
  18167. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18168. */
  18169. get range(): number;
  18170. /**
  18171. * Defines how far from the source the light is impacting in scene units.
  18172. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18173. */
  18174. set range(value: number);
  18175. /**
  18176. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18177. * of light.
  18178. */
  18179. private _photometricScale;
  18180. private _intensityMode;
  18181. /**
  18182. * Gets the photometric scale used to interpret the intensity.
  18183. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18184. */
  18185. get intensityMode(): number;
  18186. /**
  18187. * Sets the photometric scale used to interpret the intensity.
  18188. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18189. */
  18190. set intensityMode(value: number);
  18191. private _radius;
  18192. /**
  18193. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18194. */
  18195. get radius(): number;
  18196. /**
  18197. * sets the light radius used by PBR Materials to simulate soft area lights.
  18198. */
  18199. set radius(value: number);
  18200. private _renderPriority;
  18201. /**
  18202. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18203. * exceeding the number allowed of the materials.
  18204. */
  18205. renderPriority: number;
  18206. private _shadowEnabled;
  18207. /**
  18208. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18209. * the current shadow generator.
  18210. */
  18211. get shadowEnabled(): boolean;
  18212. /**
  18213. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18214. * the current shadow generator.
  18215. */
  18216. set shadowEnabled(value: boolean);
  18217. private _includedOnlyMeshes;
  18218. /**
  18219. * Gets the only meshes impacted by this light.
  18220. */
  18221. get includedOnlyMeshes(): AbstractMesh[];
  18222. /**
  18223. * Sets the only meshes impacted by this light.
  18224. */
  18225. set includedOnlyMeshes(value: AbstractMesh[]);
  18226. private _excludedMeshes;
  18227. /**
  18228. * Gets the meshes not impacted by this light.
  18229. */
  18230. get excludedMeshes(): AbstractMesh[];
  18231. /**
  18232. * Sets the meshes not impacted by this light.
  18233. */
  18234. set excludedMeshes(value: AbstractMesh[]);
  18235. private _excludeWithLayerMask;
  18236. /**
  18237. * Gets the layer id use to find what meshes are not impacted by the light.
  18238. * Inactive if 0
  18239. */
  18240. get excludeWithLayerMask(): number;
  18241. /**
  18242. * Sets the layer id use to find what meshes are not impacted by the light.
  18243. * Inactive if 0
  18244. */
  18245. set excludeWithLayerMask(value: number);
  18246. private _includeOnlyWithLayerMask;
  18247. /**
  18248. * Gets the layer id use to find what meshes are impacted by the light.
  18249. * Inactive if 0
  18250. */
  18251. get includeOnlyWithLayerMask(): number;
  18252. /**
  18253. * Sets the layer id use to find what meshes are impacted by the light.
  18254. * Inactive if 0
  18255. */
  18256. set includeOnlyWithLayerMask(value: number);
  18257. private _lightmapMode;
  18258. /**
  18259. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18260. */
  18261. get lightmapMode(): number;
  18262. /**
  18263. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18264. */
  18265. set lightmapMode(value: number);
  18266. /**
  18267. * Shadow generator associted to the light.
  18268. * @hidden Internal use only.
  18269. */
  18270. _shadowGenerator: Nullable<IShadowGenerator>;
  18271. /**
  18272. * @hidden Internal use only.
  18273. */
  18274. _excludedMeshesIds: string[];
  18275. /**
  18276. * @hidden Internal use only.
  18277. */
  18278. _includedOnlyMeshesIds: string[];
  18279. /**
  18280. * The current light unifom buffer.
  18281. * @hidden Internal use only.
  18282. */
  18283. _uniformBuffer: UniformBuffer;
  18284. /** @hidden */
  18285. _renderId: number;
  18286. /**
  18287. * Creates a Light object in the scene.
  18288. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18289. * @param name The firendly name of the light
  18290. * @param scene The scene the light belongs too
  18291. */
  18292. constructor(name: string, scene: Scene);
  18293. protected abstract _buildUniformLayout(): void;
  18294. /**
  18295. * Sets the passed Effect "effect" with the Light information.
  18296. * @param effect The effect to update
  18297. * @param lightIndex The index of the light in the effect to update
  18298. * @returns The light
  18299. */
  18300. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18301. /**
  18302. * Sets the passed Effect "effect" with the Light textures.
  18303. * @param effect The effect to update
  18304. * @param lightIndex The index of the light in the effect to update
  18305. * @returns The light
  18306. */
  18307. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18308. /**
  18309. * Binds the lights information from the scene to the effect for the given mesh.
  18310. * @param lightIndex Light index
  18311. * @param scene The scene where the light belongs to
  18312. * @param effect The effect we are binding the data to
  18313. * @param useSpecular Defines if specular is supported
  18314. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18315. */
  18316. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18317. /**
  18318. * Sets the passed Effect "effect" with the Light information.
  18319. * @param effect The effect to update
  18320. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18321. * @returns The light
  18322. */
  18323. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18324. /**
  18325. * Returns the string "Light".
  18326. * @returns the class name
  18327. */
  18328. getClassName(): string;
  18329. /** @hidden */
  18330. readonly _isLight: boolean;
  18331. /**
  18332. * Converts the light information to a readable string for debug purpose.
  18333. * @param fullDetails Supports for multiple levels of logging within scene loading
  18334. * @returns the human readable light info
  18335. */
  18336. toString(fullDetails?: boolean): string;
  18337. /** @hidden */
  18338. protected _syncParentEnabledState(): void;
  18339. /**
  18340. * Set the enabled state of this node.
  18341. * @param value - the new enabled state
  18342. */
  18343. setEnabled(value: boolean): void;
  18344. /**
  18345. * Returns the Light associated shadow generator if any.
  18346. * @return the associated shadow generator.
  18347. */
  18348. getShadowGenerator(): Nullable<IShadowGenerator>;
  18349. /**
  18350. * Returns a Vector3, the absolute light position in the World.
  18351. * @returns the world space position of the light
  18352. */
  18353. getAbsolutePosition(): Vector3;
  18354. /**
  18355. * Specifies if the light will affect the passed mesh.
  18356. * @param mesh The mesh to test against the light
  18357. * @return true the mesh is affected otherwise, false.
  18358. */
  18359. canAffectMesh(mesh: AbstractMesh): boolean;
  18360. /**
  18361. * Sort function to order lights for rendering.
  18362. * @param a First Light object to compare to second.
  18363. * @param b Second Light object to compare first.
  18364. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18365. */
  18366. static CompareLightsPriority(a: Light, b: Light): number;
  18367. /**
  18368. * Releases resources associated with this node.
  18369. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18370. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18371. */
  18372. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18373. /**
  18374. * Returns the light type ID (integer).
  18375. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18376. */
  18377. getTypeID(): number;
  18378. /**
  18379. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18380. * @returns the scaled intensity in intensity mode unit
  18381. */
  18382. getScaledIntensity(): number;
  18383. /**
  18384. * Returns a new Light object, named "name", from the current one.
  18385. * @param name The name of the cloned light
  18386. * @param newParent The parent of this light, if it has one
  18387. * @returns the new created light
  18388. */
  18389. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18390. /**
  18391. * Serializes the current light into a Serialization object.
  18392. * @returns the serialized object.
  18393. */
  18394. serialize(): any;
  18395. /**
  18396. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18397. * This new light is named "name" and added to the passed scene.
  18398. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18399. * @param name The friendly name of the light
  18400. * @param scene The scene the new light will belong to
  18401. * @returns the constructor function
  18402. */
  18403. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18404. /**
  18405. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18406. * @param parsedLight The JSON representation of the light
  18407. * @param scene The scene to create the parsed light in
  18408. * @returns the created light after parsing
  18409. */
  18410. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18411. private _hookArrayForExcluded;
  18412. private _hookArrayForIncludedOnly;
  18413. private _resyncMeshes;
  18414. /**
  18415. * Forces the meshes to update their light related information in their rendering used effects
  18416. * @hidden Internal Use Only
  18417. */
  18418. _markMeshesAsLightDirty(): void;
  18419. /**
  18420. * Recomputes the cached photometric scale if needed.
  18421. */
  18422. private _computePhotometricScale;
  18423. /**
  18424. * Returns the Photometric Scale according to the light type and intensity mode.
  18425. */
  18426. private _getPhotometricScale;
  18427. /**
  18428. * Reorder the light in the scene according to their defined priority.
  18429. * @hidden Internal Use Only
  18430. */
  18431. _reorderLightsInScene(): void;
  18432. /**
  18433. * Prepares the list of defines specific to the light type.
  18434. * @param defines the list of defines
  18435. * @param lightIndex defines the index of the light for the effect
  18436. */
  18437. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18438. }
  18439. }
  18440. declare module BABYLON {
  18441. /**
  18442. * Configuration needed for prepass-capable materials
  18443. */
  18444. export class PrePassConfiguration {
  18445. /**
  18446. * Previous world matrices of meshes carrying this material
  18447. * Used for computing velocity
  18448. */
  18449. previousWorldMatrices: {
  18450. [index: number]: Matrix;
  18451. };
  18452. /**
  18453. * Previous view project matrix
  18454. * Used for computing velocity
  18455. */
  18456. previousViewProjection: Matrix;
  18457. /**
  18458. * Previous bones of meshes carrying this material
  18459. * Used for computing velocity
  18460. */
  18461. previousBones: {
  18462. [index: number]: Float32Array;
  18463. };
  18464. /**
  18465. * Add the required uniforms to the current list.
  18466. * @param uniforms defines the current uniform list.
  18467. */
  18468. static AddUniforms(uniforms: string[]): void;
  18469. /**
  18470. * Add the required samplers to the current list.
  18471. * @param samplers defines the current sampler list.
  18472. */
  18473. static AddSamplers(samplers: string[]): void;
  18474. /**
  18475. * Binds the material data.
  18476. * @param effect defines the effect to update
  18477. * @param scene defines the scene the material belongs to.
  18478. * @param mesh The mesh
  18479. * @param world World matrix of this mesh
  18480. * @param isFrozen Is the material frozen
  18481. */
  18482. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18483. }
  18484. }
  18485. declare module BABYLON {
  18486. /**
  18487. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18488. * This is the base of the follow, arc rotate cameras and Free camera
  18489. * @see https://doc.babylonjs.com/features/cameras
  18490. */
  18491. export class TargetCamera extends Camera {
  18492. private static _RigCamTransformMatrix;
  18493. private static _TargetTransformMatrix;
  18494. private static _TargetFocalPoint;
  18495. private _tmpUpVector;
  18496. private _tmpTargetVector;
  18497. /**
  18498. * Define the current direction the camera is moving to
  18499. */
  18500. cameraDirection: Vector3;
  18501. /**
  18502. * Define the current rotation the camera is rotating to
  18503. */
  18504. cameraRotation: Vector2;
  18505. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18506. ignoreParentScaling: boolean;
  18507. /**
  18508. * When set, the up vector of the camera will be updated by the rotation of the camera
  18509. */
  18510. updateUpVectorFromRotation: boolean;
  18511. private _tmpQuaternion;
  18512. /**
  18513. * Define the current rotation of the camera
  18514. */
  18515. rotation: Vector3;
  18516. /**
  18517. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18518. */
  18519. rotationQuaternion: Quaternion;
  18520. /**
  18521. * Define the current speed of the camera
  18522. */
  18523. speed: number;
  18524. /**
  18525. * Add constraint to the camera to prevent it to move freely in all directions and
  18526. * around all axis.
  18527. */
  18528. noRotationConstraint: boolean;
  18529. /**
  18530. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18531. * panning
  18532. */
  18533. invertRotation: boolean;
  18534. /**
  18535. * Speed multiplier for inverse camera panning
  18536. */
  18537. inverseRotationSpeed: number;
  18538. /**
  18539. * Define the current target of the camera as an object or a position.
  18540. */
  18541. lockedTarget: any;
  18542. /** @hidden */
  18543. _currentTarget: Vector3;
  18544. /** @hidden */
  18545. _initialFocalDistance: number;
  18546. /** @hidden */
  18547. _viewMatrix: Matrix;
  18548. /** @hidden */
  18549. _camMatrix: Matrix;
  18550. /** @hidden */
  18551. _cameraTransformMatrix: Matrix;
  18552. /** @hidden */
  18553. _cameraRotationMatrix: Matrix;
  18554. /** @hidden */
  18555. _referencePoint: Vector3;
  18556. /** @hidden */
  18557. _transformedReferencePoint: Vector3;
  18558. /** @hidden */
  18559. _reset: () => void;
  18560. private _defaultUp;
  18561. /**
  18562. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18563. * This is the base of the follow, arc rotate cameras and Free camera
  18564. * @see https://doc.babylonjs.com/features/cameras
  18565. * @param name Defines the name of the camera in the scene
  18566. * @param position Defines the start position of the camera in the scene
  18567. * @param scene Defines the scene the camera belongs to
  18568. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18569. */
  18570. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18571. /**
  18572. * Gets the position in front of the camera at a given distance.
  18573. * @param distance The distance from the camera we want the position to be
  18574. * @returns the position
  18575. */
  18576. getFrontPosition(distance: number): Vector3;
  18577. /** @hidden */
  18578. _getLockedTargetPosition(): Nullable<Vector3>;
  18579. private _storedPosition;
  18580. private _storedRotation;
  18581. private _storedRotationQuaternion;
  18582. /**
  18583. * Store current camera state of the camera (fov, position, rotation, etc..)
  18584. * @returns the camera
  18585. */
  18586. storeState(): Camera;
  18587. /**
  18588. * Restored camera state. You must call storeState() first
  18589. * @returns whether it was successful or not
  18590. * @hidden
  18591. */
  18592. _restoreStateValues(): boolean;
  18593. /** @hidden */
  18594. _initCache(): void;
  18595. /** @hidden */
  18596. _updateCache(ignoreParentClass?: boolean): void;
  18597. /** @hidden */
  18598. _isSynchronizedViewMatrix(): boolean;
  18599. /** @hidden */
  18600. _computeLocalCameraSpeed(): number;
  18601. /**
  18602. * Defines the target the camera should look at.
  18603. * @param target Defines the new target as a Vector or a mesh
  18604. */
  18605. setTarget(target: Vector3): void;
  18606. /**
  18607. * Defines the target point of the camera.
  18608. * The camera looks towards it form the radius distance.
  18609. */
  18610. get target(): Vector3;
  18611. set target(value: Vector3);
  18612. /**
  18613. * Return the current target position of the camera. This value is expressed in local space.
  18614. * @returns the target position
  18615. */
  18616. getTarget(): Vector3;
  18617. /** @hidden */
  18618. _decideIfNeedsToMove(): boolean;
  18619. /** @hidden */
  18620. _updatePosition(): void;
  18621. /** @hidden */
  18622. _checkInputs(): void;
  18623. protected _updateCameraRotationMatrix(): void;
  18624. /**
  18625. * 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)
  18626. * @returns the current camera
  18627. */
  18628. private _rotateUpVectorWithCameraRotationMatrix;
  18629. private _cachedRotationZ;
  18630. private _cachedQuaternionRotationZ;
  18631. /** @hidden */
  18632. _getViewMatrix(): Matrix;
  18633. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18634. /**
  18635. * @hidden
  18636. */
  18637. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18638. /**
  18639. * @hidden
  18640. */
  18641. _updateRigCameras(): void;
  18642. private _getRigCamPositionAndTarget;
  18643. /**
  18644. * Gets the current object class name.
  18645. * @return the class name
  18646. */
  18647. getClassName(): string;
  18648. }
  18649. }
  18650. declare module BABYLON {
  18651. /**
  18652. * Gather the list of keyboard event types as constants.
  18653. */
  18654. export class KeyboardEventTypes {
  18655. /**
  18656. * The keydown event is fired when a key becomes active (pressed).
  18657. */
  18658. static readonly KEYDOWN: number;
  18659. /**
  18660. * The keyup event is fired when a key has been released.
  18661. */
  18662. static readonly KEYUP: number;
  18663. }
  18664. /**
  18665. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18666. */
  18667. export class KeyboardInfo {
  18668. /**
  18669. * Defines the type of event (KeyboardEventTypes)
  18670. */
  18671. type: number;
  18672. /**
  18673. * Defines the related dom event
  18674. */
  18675. event: KeyboardEvent;
  18676. /**
  18677. * Instantiates a new keyboard info.
  18678. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18679. * @param type Defines the type of event (KeyboardEventTypes)
  18680. * @param event Defines the related dom event
  18681. */
  18682. constructor(
  18683. /**
  18684. * Defines the type of event (KeyboardEventTypes)
  18685. */
  18686. type: number,
  18687. /**
  18688. * Defines the related dom event
  18689. */
  18690. event: KeyboardEvent);
  18691. }
  18692. /**
  18693. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18694. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18695. */
  18696. export class KeyboardInfoPre extends KeyboardInfo {
  18697. /**
  18698. * Defines the type of event (KeyboardEventTypes)
  18699. */
  18700. type: number;
  18701. /**
  18702. * Defines the related dom event
  18703. */
  18704. event: KeyboardEvent;
  18705. /**
  18706. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18707. */
  18708. skipOnPointerObservable: boolean;
  18709. /**
  18710. * Instantiates a new keyboard pre info.
  18711. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18712. * @param type Defines the type of event (KeyboardEventTypes)
  18713. * @param event Defines the related dom event
  18714. */
  18715. constructor(
  18716. /**
  18717. * Defines the type of event (KeyboardEventTypes)
  18718. */
  18719. type: number,
  18720. /**
  18721. * Defines the related dom event
  18722. */
  18723. event: KeyboardEvent);
  18724. }
  18725. }
  18726. declare module BABYLON {
  18727. /**
  18728. * Manage the keyboard inputs to control the movement of a free camera.
  18729. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18730. */
  18731. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18732. /**
  18733. * Defines the camera the input is attached to.
  18734. */
  18735. camera: FreeCamera;
  18736. /**
  18737. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18738. */
  18739. keysUp: number[];
  18740. /**
  18741. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18742. */
  18743. keysUpward: number[];
  18744. /**
  18745. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18746. */
  18747. keysDown: number[];
  18748. /**
  18749. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18750. */
  18751. keysDownward: number[];
  18752. /**
  18753. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18754. */
  18755. keysLeft: number[];
  18756. /**
  18757. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18758. */
  18759. keysRight: number[];
  18760. private _keys;
  18761. private _onCanvasBlurObserver;
  18762. private _onKeyboardObserver;
  18763. private _engine;
  18764. private _scene;
  18765. /**
  18766. * Attach the input controls to a specific dom element to get the input from.
  18767. * @param element Defines the element the controls should be listened from
  18768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18769. */
  18770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18771. /**
  18772. * Detach the current controls from the specified dom element.
  18773. * @param element Defines the element to stop listening the inputs from
  18774. */
  18775. detachControl(element: Nullable<HTMLElement>): void;
  18776. /**
  18777. * Update the current camera state depending on the inputs that have been used this frame.
  18778. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18779. */
  18780. checkInputs(): void;
  18781. /**
  18782. * Gets the class name of the current intput.
  18783. * @returns the class name
  18784. */
  18785. getClassName(): string;
  18786. /** @hidden */
  18787. _onLostFocus(): void;
  18788. /**
  18789. * Get the friendly name associated with the input class.
  18790. * @returns the input friendly name
  18791. */
  18792. getSimpleName(): string;
  18793. }
  18794. }
  18795. declare module BABYLON {
  18796. /**
  18797. * Gather the list of pointer event types as constants.
  18798. */
  18799. export class PointerEventTypes {
  18800. /**
  18801. * 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.
  18802. */
  18803. static readonly POINTERDOWN: number;
  18804. /**
  18805. * The pointerup event is fired when a pointer is no longer active.
  18806. */
  18807. static readonly POINTERUP: number;
  18808. /**
  18809. * The pointermove event is fired when a pointer changes coordinates.
  18810. */
  18811. static readonly POINTERMOVE: number;
  18812. /**
  18813. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18814. */
  18815. static readonly POINTERWHEEL: number;
  18816. /**
  18817. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18818. */
  18819. static readonly POINTERPICK: number;
  18820. /**
  18821. * The pointertap event is fired when a the object has been touched and released without drag.
  18822. */
  18823. static readonly POINTERTAP: number;
  18824. /**
  18825. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18826. */
  18827. static readonly POINTERDOUBLETAP: number;
  18828. }
  18829. /**
  18830. * Base class of pointer info types.
  18831. */
  18832. export class PointerInfoBase {
  18833. /**
  18834. * Defines the type of event (PointerEventTypes)
  18835. */
  18836. type: number;
  18837. /**
  18838. * Defines the related dom event
  18839. */
  18840. event: PointerEvent | MouseWheelEvent;
  18841. /**
  18842. * Instantiates the base class of pointers info.
  18843. * @param type Defines the type of event (PointerEventTypes)
  18844. * @param event Defines the related dom event
  18845. */
  18846. constructor(
  18847. /**
  18848. * Defines the type of event (PointerEventTypes)
  18849. */
  18850. type: number,
  18851. /**
  18852. * Defines the related dom event
  18853. */
  18854. event: PointerEvent | MouseWheelEvent);
  18855. }
  18856. /**
  18857. * This class is used to store pointer related info for the onPrePointerObservable event.
  18858. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18859. */
  18860. export class PointerInfoPre extends PointerInfoBase {
  18861. /**
  18862. * Ray from a pointer if availible (eg. 6dof controller)
  18863. */
  18864. ray: Nullable<Ray>;
  18865. /**
  18866. * Defines the local position of the pointer on the canvas.
  18867. */
  18868. localPosition: Vector2;
  18869. /**
  18870. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18871. */
  18872. skipOnPointerObservable: boolean;
  18873. /**
  18874. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18875. * @param type Defines the type of event (PointerEventTypes)
  18876. * @param event Defines the related dom event
  18877. * @param localX Defines the local x coordinates of the pointer when the event occured
  18878. * @param localY Defines the local y coordinates of the pointer when the event occured
  18879. */
  18880. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18881. }
  18882. /**
  18883. * This type contains all the data related to a pointer event in Babylon.js.
  18884. * 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.
  18885. */
  18886. export class PointerInfo extends PointerInfoBase {
  18887. /**
  18888. * Defines the picking info associated to the info (if any)\
  18889. */
  18890. pickInfo: Nullable<PickingInfo>;
  18891. /**
  18892. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18893. * @param type Defines the type of event (PointerEventTypes)
  18894. * @param event Defines the related dom event
  18895. * @param pickInfo Defines the picking info associated to the info (if any)\
  18896. */
  18897. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18898. /**
  18899. * Defines the picking info associated to the info (if any)\
  18900. */
  18901. pickInfo: Nullable<PickingInfo>);
  18902. }
  18903. /**
  18904. * Data relating to a touch event on the screen.
  18905. */
  18906. export interface PointerTouch {
  18907. /**
  18908. * X coordinate of touch.
  18909. */
  18910. x: number;
  18911. /**
  18912. * Y coordinate of touch.
  18913. */
  18914. y: number;
  18915. /**
  18916. * Id of touch. Unique for each finger.
  18917. */
  18918. pointerId: number;
  18919. /**
  18920. * Event type passed from DOM.
  18921. */
  18922. type: any;
  18923. }
  18924. }
  18925. declare module BABYLON {
  18926. /**
  18927. * Manage the mouse inputs to control the movement of a free camera.
  18928. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18929. */
  18930. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18931. /**
  18932. * Define if touch is enabled in the mouse input
  18933. */
  18934. touchEnabled: boolean;
  18935. /**
  18936. * Defines the camera the input is attached to.
  18937. */
  18938. camera: FreeCamera;
  18939. /**
  18940. * Defines the buttons associated with the input to handle camera move.
  18941. */
  18942. buttons: number[];
  18943. /**
  18944. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18945. */
  18946. angularSensibility: number;
  18947. private _pointerInput;
  18948. private _onMouseMove;
  18949. private _observer;
  18950. private previousPosition;
  18951. /**
  18952. * Observable for when a pointer move event occurs containing the move offset
  18953. */
  18954. onPointerMovedObservable: Observable<{
  18955. offsetX: number;
  18956. offsetY: number;
  18957. }>;
  18958. /**
  18959. * @hidden
  18960. * If the camera should be rotated automatically based on pointer movement
  18961. */
  18962. _allowCameraRotation: boolean;
  18963. /**
  18964. * Manage the mouse inputs to control the movement of a free camera.
  18965. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18966. * @param touchEnabled Defines if touch is enabled or not
  18967. */
  18968. constructor(
  18969. /**
  18970. * Define if touch is enabled in the mouse input
  18971. */
  18972. touchEnabled?: boolean);
  18973. /**
  18974. * Attach the input controls to a specific dom element to get the input from.
  18975. * @param element Defines the element the controls should be listened from
  18976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18977. */
  18978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18979. /**
  18980. * Called on JS contextmenu event.
  18981. * Override this method to provide functionality.
  18982. */
  18983. protected onContextMenu(evt: PointerEvent): void;
  18984. /**
  18985. * Detach the current controls from the specified dom element.
  18986. * @param element Defines the element to stop listening the inputs from
  18987. */
  18988. detachControl(element: Nullable<HTMLElement>): void;
  18989. /**
  18990. * Gets the class name of the current intput.
  18991. * @returns the class name
  18992. */
  18993. getClassName(): string;
  18994. /**
  18995. * Get the friendly name associated with the input class.
  18996. * @returns the input friendly name
  18997. */
  18998. getSimpleName(): string;
  18999. }
  19000. }
  19001. declare module BABYLON {
  19002. /**
  19003. * Manage the touch inputs to control the movement of a free camera.
  19004. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19005. */
  19006. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19007. /**
  19008. * Define if mouse events can be treated as touch events
  19009. */
  19010. allowMouse: boolean;
  19011. /**
  19012. * Defines the camera the input is attached to.
  19013. */
  19014. camera: FreeCamera;
  19015. /**
  19016. * Defines the touch sensibility for rotation.
  19017. * The higher the faster.
  19018. */
  19019. touchAngularSensibility: number;
  19020. /**
  19021. * Defines the touch sensibility for move.
  19022. * The higher the faster.
  19023. */
  19024. touchMoveSensibility: number;
  19025. private _offsetX;
  19026. private _offsetY;
  19027. private _pointerPressed;
  19028. private _pointerInput;
  19029. private _observer;
  19030. private _onLostFocus;
  19031. /**
  19032. * Manage the touch inputs to control the movement of a free camera.
  19033. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19034. * @param allowMouse Defines if mouse events can be treated as touch events
  19035. */
  19036. constructor(
  19037. /**
  19038. * Define if mouse events can be treated as touch events
  19039. */
  19040. allowMouse?: boolean);
  19041. /**
  19042. * Attach the input controls to a specific dom element to get the input from.
  19043. * @param element Defines the element the controls should be listened from
  19044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19045. */
  19046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19047. /**
  19048. * Detach the current controls from the specified dom element.
  19049. * @param element Defines the element to stop listening the inputs from
  19050. */
  19051. detachControl(element: Nullable<HTMLElement>): void;
  19052. /**
  19053. * Update the current camera state depending on the inputs that have been used this frame.
  19054. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19055. */
  19056. checkInputs(): void;
  19057. /**
  19058. * Gets the class name of the current intput.
  19059. * @returns the class name
  19060. */
  19061. getClassName(): string;
  19062. /**
  19063. * Get the friendly name associated with the input class.
  19064. * @returns the input friendly name
  19065. */
  19066. getSimpleName(): string;
  19067. }
  19068. }
  19069. declare module BABYLON {
  19070. /**
  19071. * Default Inputs manager for the FreeCamera.
  19072. * It groups all the default supported inputs for ease of use.
  19073. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19074. */
  19075. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19076. /**
  19077. * @hidden
  19078. */
  19079. _mouseInput: Nullable<FreeCameraMouseInput>;
  19080. /**
  19081. * Instantiates a new FreeCameraInputsManager.
  19082. * @param camera Defines the camera the inputs belong to
  19083. */
  19084. constructor(camera: FreeCamera);
  19085. /**
  19086. * Add keyboard input support to the input manager.
  19087. * @returns the current input manager
  19088. */
  19089. addKeyboard(): FreeCameraInputsManager;
  19090. /**
  19091. * Add mouse input support to the input manager.
  19092. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19093. * @returns the current input manager
  19094. */
  19095. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19096. /**
  19097. * Removes the mouse input support from the manager
  19098. * @returns the current input manager
  19099. */
  19100. removeMouse(): FreeCameraInputsManager;
  19101. /**
  19102. * Add touch input support to the input manager.
  19103. * @returns the current input manager
  19104. */
  19105. addTouch(): FreeCameraInputsManager;
  19106. /**
  19107. * Remove all attached input methods from a camera
  19108. */
  19109. clear(): void;
  19110. }
  19111. }
  19112. declare module BABYLON {
  19113. /**
  19114. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19115. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19116. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19117. */
  19118. export class FreeCamera extends TargetCamera {
  19119. /**
  19120. * Define the collision ellipsoid of the camera.
  19121. * This is helpful to simulate a camera body like the player body around the camera
  19122. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19123. */
  19124. ellipsoid: Vector3;
  19125. /**
  19126. * Define an offset for the position of the ellipsoid around the camera.
  19127. * This can be helpful to determine the center of the body near the gravity center of the body
  19128. * instead of its head.
  19129. */
  19130. ellipsoidOffset: Vector3;
  19131. /**
  19132. * Enable or disable collisions of the camera with the rest of the scene objects.
  19133. */
  19134. checkCollisions: boolean;
  19135. /**
  19136. * Enable or disable gravity on the camera.
  19137. */
  19138. applyGravity: boolean;
  19139. /**
  19140. * Define the input manager associated to the camera.
  19141. */
  19142. inputs: FreeCameraInputsManager;
  19143. /**
  19144. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19145. * Higher values reduce sensitivity.
  19146. */
  19147. get angularSensibility(): number;
  19148. /**
  19149. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19150. * Higher values reduce sensitivity.
  19151. */
  19152. set angularSensibility(value: number);
  19153. /**
  19154. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19155. */
  19156. get keysUp(): number[];
  19157. set keysUp(value: number[]);
  19158. /**
  19159. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19160. */
  19161. get keysUpward(): number[];
  19162. set keysUpward(value: number[]);
  19163. /**
  19164. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19165. */
  19166. get keysDown(): number[];
  19167. set keysDown(value: number[]);
  19168. /**
  19169. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19170. */
  19171. get keysDownward(): number[];
  19172. set keysDownward(value: number[]);
  19173. /**
  19174. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19175. */
  19176. get keysLeft(): number[];
  19177. set keysLeft(value: number[]);
  19178. /**
  19179. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19180. */
  19181. get keysRight(): number[];
  19182. set keysRight(value: number[]);
  19183. /**
  19184. * Event raised when the camera collide with a mesh in the scene.
  19185. */
  19186. onCollide: (collidedMesh: AbstractMesh) => void;
  19187. private _collider;
  19188. private _needMoveForGravity;
  19189. private _oldPosition;
  19190. private _diffPosition;
  19191. private _newPosition;
  19192. /** @hidden */
  19193. _localDirection: Vector3;
  19194. /** @hidden */
  19195. _transformedDirection: Vector3;
  19196. /**
  19197. * Instantiates a Free Camera.
  19198. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19199. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19200. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19201. * @param name Define the name of the camera in the scene
  19202. * @param position Define the start position of the camera in the scene
  19203. * @param scene Define the scene the camera belongs to
  19204. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19205. */
  19206. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19207. /**
  19208. * Attached controls to the current camera.
  19209. * @param element Defines the element the controls should be listened from
  19210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19211. */
  19212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19213. /**
  19214. * Detach the current controls from the camera.
  19215. * The camera will stop reacting to inputs.
  19216. * @param element Defines the element to stop listening the inputs from
  19217. */
  19218. detachControl(element: HTMLElement): void;
  19219. private _collisionMask;
  19220. /**
  19221. * Define a collision mask to limit the list of object the camera can collide with
  19222. */
  19223. get collisionMask(): number;
  19224. set collisionMask(mask: number);
  19225. /** @hidden */
  19226. _collideWithWorld(displacement: Vector3): void;
  19227. private _onCollisionPositionChange;
  19228. /** @hidden */
  19229. _checkInputs(): void;
  19230. /** @hidden */
  19231. _decideIfNeedsToMove(): boolean;
  19232. /** @hidden */
  19233. _updatePosition(): void;
  19234. /**
  19235. * Destroy the camera and release the current resources hold by it.
  19236. */
  19237. dispose(): void;
  19238. /**
  19239. * Gets the current object class name.
  19240. * @return the class name
  19241. */
  19242. getClassName(): string;
  19243. }
  19244. }
  19245. declare module BABYLON {
  19246. /**
  19247. * Represents a gamepad control stick position
  19248. */
  19249. export class StickValues {
  19250. /**
  19251. * The x component of the control stick
  19252. */
  19253. x: number;
  19254. /**
  19255. * The y component of the control stick
  19256. */
  19257. y: number;
  19258. /**
  19259. * Initializes the gamepad x and y control stick values
  19260. * @param x The x component of the gamepad control stick value
  19261. * @param y The y component of the gamepad control stick value
  19262. */
  19263. constructor(
  19264. /**
  19265. * The x component of the control stick
  19266. */
  19267. x: number,
  19268. /**
  19269. * The y component of the control stick
  19270. */
  19271. y: number);
  19272. }
  19273. /**
  19274. * An interface which manages callbacks for gamepad button changes
  19275. */
  19276. export interface GamepadButtonChanges {
  19277. /**
  19278. * Called when a gamepad has been changed
  19279. */
  19280. changed: boolean;
  19281. /**
  19282. * Called when a gamepad press event has been triggered
  19283. */
  19284. pressChanged: boolean;
  19285. /**
  19286. * Called when a touch event has been triggered
  19287. */
  19288. touchChanged: boolean;
  19289. /**
  19290. * Called when a value has changed
  19291. */
  19292. valueChanged: boolean;
  19293. }
  19294. /**
  19295. * Represents a gamepad
  19296. */
  19297. export class Gamepad {
  19298. /**
  19299. * The id of the gamepad
  19300. */
  19301. id: string;
  19302. /**
  19303. * The index of the gamepad
  19304. */
  19305. index: number;
  19306. /**
  19307. * The browser gamepad
  19308. */
  19309. browserGamepad: any;
  19310. /**
  19311. * Specifies what type of gamepad this represents
  19312. */
  19313. type: number;
  19314. private _leftStick;
  19315. private _rightStick;
  19316. /** @hidden */
  19317. _isConnected: boolean;
  19318. private _leftStickAxisX;
  19319. private _leftStickAxisY;
  19320. private _rightStickAxisX;
  19321. private _rightStickAxisY;
  19322. /**
  19323. * Triggered when the left control stick has been changed
  19324. */
  19325. private _onleftstickchanged;
  19326. /**
  19327. * Triggered when the right control stick has been changed
  19328. */
  19329. private _onrightstickchanged;
  19330. /**
  19331. * Represents a gamepad controller
  19332. */
  19333. static GAMEPAD: number;
  19334. /**
  19335. * Represents a generic controller
  19336. */
  19337. static GENERIC: number;
  19338. /**
  19339. * Represents an XBox controller
  19340. */
  19341. static XBOX: number;
  19342. /**
  19343. * Represents a pose-enabled controller
  19344. */
  19345. static POSE_ENABLED: number;
  19346. /**
  19347. * Represents an Dual Shock controller
  19348. */
  19349. static DUALSHOCK: number;
  19350. /**
  19351. * Specifies whether the left control stick should be Y-inverted
  19352. */
  19353. protected _invertLeftStickY: boolean;
  19354. /**
  19355. * Specifies if the gamepad has been connected
  19356. */
  19357. get isConnected(): boolean;
  19358. /**
  19359. * Initializes the gamepad
  19360. * @param id The id of the gamepad
  19361. * @param index The index of the gamepad
  19362. * @param browserGamepad The browser gamepad
  19363. * @param leftStickX The x component of the left joystick
  19364. * @param leftStickY The y component of the left joystick
  19365. * @param rightStickX The x component of the right joystick
  19366. * @param rightStickY The y component of the right joystick
  19367. */
  19368. constructor(
  19369. /**
  19370. * The id of the gamepad
  19371. */
  19372. id: string,
  19373. /**
  19374. * The index of the gamepad
  19375. */
  19376. index: number,
  19377. /**
  19378. * The browser gamepad
  19379. */
  19380. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19381. /**
  19382. * Callback triggered when the left joystick has changed
  19383. * @param callback
  19384. */
  19385. onleftstickchanged(callback: (values: StickValues) => void): void;
  19386. /**
  19387. * Callback triggered when the right joystick has changed
  19388. * @param callback
  19389. */
  19390. onrightstickchanged(callback: (values: StickValues) => void): void;
  19391. /**
  19392. * Gets the left joystick
  19393. */
  19394. get leftStick(): StickValues;
  19395. /**
  19396. * Sets the left joystick values
  19397. */
  19398. set leftStick(newValues: StickValues);
  19399. /**
  19400. * Gets the right joystick
  19401. */
  19402. get rightStick(): StickValues;
  19403. /**
  19404. * Sets the right joystick value
  19405. */
  19406. set rightStick(newValues: StickValues);
  19407. /**
  19408. * Updates the gamepad joystick positions
  19409. */
  19410. update(): void;
  19411. /**
  19412. * Disposes the gamepad
  19413. */
  19414. dispose(): void;
  19415. }
  19416. /**
  19417. * Represents a generic gamepad
  19418. */
  19419. export class GenericPad extends Gamepad {
  19420. private _buttons;
  19421. private _onbuttondown;
  19422. private _onbuttonup;
  19423. /**
  19424. * Observable triggered when a button has been pressed
  19425. */
  19426. onButtonDownObservable: Observable<number>;
  19427. /**
  19428. * Observable triggered when a button has been released
  19429. */
  19430. onButtonUpObservable: Observable<number>;
  19431. /**
  19432. * Callback triggered when a button has been pressed
  19433. * @param callback Called when a button has been pressed
  19434. */
  19435. onbuttondown(callback: (buttonPressed: number) => void): void;
  19436. /**
  19437. * Callback triggered when a button has been released
  19438. * @param callback Called when a button has been released
  19439. */
  19440. onbuttonup(callback: (buttonReleased: number) => void): void;
  19441. /**
  19442. * Initializes the generic gamepad
  19443. * @param id The id of the generic gamepad
  19444. * @param index The index of the generic gamepad
  19445. * @param browserGamepad The browser gamepad
  19446. */
  19447. constructor(id: string, index: number, browserGamepad: any);
  19448. private _setButtonValue;
  19449. /**
  19450. * Updates the generic gamepad
  19451. */
  19452. update(): void;
  19453. /**
  19454. * Disposes the generic gamepad
  19455. */
  19456. dispose(): void;
  19457. }
  19458. }
  19459. declare module BABYLON {
  19460. /**
  19461. * Defines the types of pose enabled controllers that are supported
  19462. */
  19463. export enum PoseEnabledControllerType {
  19464. /**
  19465. * HTC Vive
  19466. */
  19467. VIVE = 0,
  19468. /**
  19469. * Oculus Rift
  19470. */
  19471. OCULUS = 1,
  19472. /**
  19473. * Windows mixed reality
  19474. */
  19475. WINDOWS = 2,
  19476. /**
  19477. * Samsung gear VR
  19478. */
  19479. GEAR_VR = 3,
  19480. /**
  19481. * Google Daydream
  19482. */
  19483. DAYDREAM = 4,
  19484. /**
  19485. * Generic
  19486. */
  19487. GENERIC = 5
  19488. }
  19489. /**
  19490. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19491. */
  19492. export interface MutableGamepadButton {
  19493. /**
  19494. * Value of the button/trigger
  19495. */
  19496. value: number;
  19497. /**
  19498. * If the button/trigger is currently touched
  19499. */
  19500. touched: boolean;
  19501. /**
  19502. * If the button/trigger is currently pressed
  19503. */
  19504. pressed: boolean;
  19505. }
  19506. /**
  19507. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19508. * @hidden
  19509. */
  19510. export interface ExtendedGamepadButton extends GamepadButton {
  19511. /**
  19512. * If the button/trigger is currently pressed
  19513. */
  19514. readonly pressed: boolean;
  19515. /**
  19516. * If the button/trigger is currently touched
  19517. */
  19518. readonly touched: boolean;
  19519. /**
  19520. * Value of the button/trigger
  19521. */
  19522. readonly value: number;
  19523. }
  19524. /** @hidden */
  19525. export interface _GamePadFactory {
  19526. /**
  19527. * Returns whether or not the current gamepad can be created for this type of controller.
  19528. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19529. * @returns true if it can be created, otherwise false
  19530. */
  19531. canCreate(gamepadInfo: any): boolean;
  19532. /**
  19533. * Creates a new instance of the Gamepad.
  19534. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19535. * @returns the new gamepad instance
  19536. */
  19537. create(gamepadInfo: any): Gamepad;
  19538. }
  19539. /**
  19540. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19541. */
  19542. export class PoseEnabledControllerHelper {
  19543. /** @hidden */
  19544. static _ControllerFactories: _GamePadFactory[];
  19545. /** @hidden */
  19546. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19547. /**
  19548. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19549. * @param vrGamepad the gamepad to initialized
  19550. * @returns a vr controller of the type the gamepad identified as
  19551. */
  19552. static InitiateController(vrGamepad: any): Gamepad;
  19553. }
  19554. /**
  19555. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19556. */
  19557. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19558. /**
  19559. * If the controller is used in a webXR session
  19560. */
  19561. isXR: boolean;
  19562. private _deviceRoomPosition;
  19563. private _deviceRoomRotationQuaternion;
  19564. /**
  19565. * The device position in babylon space
  19566. */
  19567. devicePosition: Vector3;
  19568. /**
  19569. * The device rotation in babylon space
  19570. */
  19571. deviceRotationQuaternion: Quaternion;
  19572. /**
  19573. * The scale factor of the device in babylon space
  19574. */
  19575. deviceScaleFactor: number;
  19576. /**
  19577. * (Likely devicePosition should be used instead) The device position in its room space
  19578. */
  19579. position: Vector3;
  19580. /**
  19581. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19582. */
  19583. rotationQuaternion: Quaternion;
  19584. /**
  19585. * The type of controller (Eg. Windows mixed reality)
  19586. */
  19587. controllerType: PoseEnabledControllerType;
  19588. protected _calculatedPosition: Vector3;
  19589. private _calculatedRotation;
  19590. /**
  19591. * The raw pose from the device
  19592. */
  19593. rawPose: DevicePose;
  19594. private _trackPosition;
  19595. private _maxRotationDistFromHeadset;
  19596. private _draggedRoomRotation;
  19597. /**
  19598. * @hidden
  19599. */
  19600. _disableTrackPosition(fixedPosition: Vector3): void;
  19601. /**
  19602. * Internal, the mesh attached to the controller
  19603. * @hidden
  19604. */
  19605. _mesh: Nullable<AbstractMesh>;
  19606. private _poseControlledCamera;
  19607. private _leftHandSystemQuaternion;
  19608. /**
  19609. * Internal, matrix used to convert room space to babylon space
  19610. * @hidden
  19611. */
  19612. _deviceToWorld: Matrix;
  19613. /**
  19614. * Node to be used when casting a ray from the controller
  19615. * @hidden
  19616. */
  19617. _pointingPoseNode: Nullable<TransformNode>;
  19618. /**
  19619. * Name of the child mesh that can be used to cast a ray from the controller
  19620. */
  19621. static readonly POINTING_POSE: string;
  19622. /**
  19623. * Creates a new PoseEnabledController from a gamepad
  19624. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19625. */
  19626. constructor(browserGamepad: any);
  19627. private _workingMatrix;
  19628. /**
  19629. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19630. */
  19631. update(): void;
  19632. /**
  19633. * Updates only the pose device and mesh without doing any button event checking
  19634. */
  19635. protected _updatePoseAndMesh(): void;
  19636. /**
  19637. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19638. * @param poseData raw pose fromthe device
  19639. */
  19640. updateFromDevice(poseData: DevicePose): void;
  19641. /**
  19642. * @hidden
  19643. */
  19644. _meshAttachedObservable: Observable<AbstractMesh>;
  19645. /**
  19646. * Attaches a mesh to the controller
  19647. * @param mesh the mesh to be attached
  19648. */
  19649. attachToMesh(mesh: AbstractMesh): void;
  19650. /**
  19651. * Attaches the controllers mesh to a camera
  19652. * @param camera the camera the mesh should be attached to
  19653. */
  19654. attachToPoseControlledCamera(camera: TargetCamera): void;
  19655. /**
  19656. * Disposes of the controller
  19657. */
  19658. dispose(): void;
  19659. /**
  19660. * The mesh that is attached to the controller
  19661. */
  19662. get mesh(): Nullable<AbstractMesh>;
  19663. /**
  19664. * Gets the ray of the controller in the direction the controller is pointing
  19665. * @param length the length the resulting ray should be
  19666. * @returns a ray in the direction the controller is pointing
  19667. */
  19668. getForwardRay(length?: number): Ray;
  19669. }
  19670. }
  19671. declare module BABYLON {
  19672. /**
  19673. * Defines the WebVRController object that represents controllers tracked in 3D space
  19674. */
  19675. export abstract class WebVRController extends PoseEnabledController {
  19676. /**
  19677. * Internal, the default controller model for the controller
  19678. */
  19679. protected _defaultModel: Nullable<AbstractMesh>;
  19680. /**
  19681. * Fired when the trigger state has changed
  19682. */
  19683. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19684. /**
  19685. * Fired when the main button state has changed
  19686. */
  19687. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19688. /**
  19689. * Fired when the secondary button state has changed
  19690. */
  19691. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19692. /**
  19693. * Fired when the pad state has changed
  19694. */
  19695. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19696. /**
  19697. * Fired when controllers stick values have changed
  19698. */
  19699. onPadValuesChangedObservable: Observable<StickValues>;
  19700. /**
  19701. * Array of button availible on the controller
  19702. */
  19703. protected _buttons: Array<MutableGamepadButton>;
  19704. private _onButtonStateChange;
  19705. /**
  19706. * Fired when a controller button's state has changed
  19707. * @param callback the callback containing the button that was modified
  19708. */
  19709. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19710. /**
  19711. * X and Y axis corresponding to the controllers joystick
  19712. */
  19713. pad: StickValues;
  19714. /**
  19715. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19716. */
  19717. hand: string;
  19718. /**
  19719. * The default controller model for the controller
  19720. */
  19721. get defaultModel(): Nullable<AbstractMesh>;
  19722. /**
  19723. * Creates a new WebVRController from a gamepad
  19724. * @param vrGamepad the gamepad that the WebVRController should be created from
  19725. */
  19726. constructor(vrGamepad: any);
  19727. /**
  19728. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19729. */
  19730. update(): void;
  19731. /**
  19732. * Function to be called when a button is modified
  19733. */
  19734. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19735. /**
  19736. * Loads a mesh and attaches it to the controller
  19737. * @param scene the scene the mesh should be added to
  19738. * @param meshLoaded callback for when the mesh has been loaded
  19739. */
  19740. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19741. private _setButtonValue;
  19742. private _changes;
  19743. private _checkChanges;
  19744. /**
  19745. * Disposes of th webVRCOntroller
  19746. */
  19747. dispose(): void;
  19748. }
  19749. }
  19750. declare module BABYLON {
  19751. /**
  19752. * The HemisphericLight simulates the ambient environment light,
  19753. * so the passed direction is the light reflection direction, not the incoming direction.
  19754. */
  19755. export class HemisphericLight extends Light {
  19756. /**
  19757. * The groundColor is the light in the opposite direction to the one specified during creation.
  19758. * 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.
  19759. */
  19760. groundColor: Color3;
  19761. /**
  19762. * The light reflection direction, not the incoming direction.
  19763. */
  19764. direction: Vector3;
  19765. /**
  19766. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19767. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19768. * The HemisphericLight can't cast shadows.
  19769. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19770. * @param name The friendly name of the light
  19771. * @param direction The direction of the light reflection
  19772. * @param scene The scene the light belongs to
  19773. */
  19774. constructor(name: string, direction: Vector3, scene: Scene);
  19775. protected _buildUniformLayout(): void;
  19776. /**
  19777. * Returns the string "HemisphericLight".
  19778. * @return The class name
  19779. */
  19780. getClassName(): string;
  19781. /**
  19782. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19783. * Returns the updated direction.
  19784. * @param target The target the direction should point to
  19785. * @return The computed direction
  19786. */
  19787. setDirectionToTarget(target: Vector3): Vector3;
  19788. /**
  19789. * Returns the shadow generator associated to the light.
  19790. * @returns Always null for hemispheric lights because it does not support shadows.
  19791. */
  19792. getShadowGenerator(): Nullable<IShadowGenerator>;
  19793. /**
  19794. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19795. * @param effect The effect to update
  19796. * @param lightIndex The index of the light in the effect to update
  19797. * @returns The hemispheric light
  19798. */
  19799. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19800. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19801. /**
  19802. * Computes the world matrix of the node
  19803. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19804. * @param useWasUpdatedFlag defines a reserved property
  19805. * @returns the world matrix
  19806. */
  19807. computeWorldMatrix(): Matrix;
  19808. /**
  19809. * Returns the integer 3.
  19810. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19811. */
  19812. getTypeID(): number;
  19813. /**
  19814. * Prepares the list of defines specific to the light type.
  19815. * @param defines the list of defines
  19816. * @param lightIndex defines the index of the light for the effect
  19817. */
  19818. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19819. }
  19820. }
  19821. declare module BABYLON {
  19822. /** @hidden */
  19823. export var vrMultiviewToSingleviewPixelShader: {
  19824. name: string;
  19825. shader: string;
  19826. };
  19827. }
  19828. declare module BABYLON {
  19829. /**
  19830. * Renders to multiple views with a single draw call
  19831. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19832. */
  19833. export class MultiviewRenderTarget extends RenderTargetTexture {
  19834. /**
  19835. * Creates a multiview render target
  19836. * @param scene scene used with the render target
  19837. * @param size the size of the render target (used for each view)
  19838. */
  19839. constructor(scene: Scene, size?: number | {
  19840. width: number;
  19841. height: number;
  19842. } | {
  19843. ratio: number;
  19844. });
  19845. /**
  19846. * @hidden
  19847. * @param faceIndex the face index, if its a cube texture
  19848. */
  19849. _bindFrameBuffer(faceIndex?: number): void;
  19850. /**
  19851. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19852. * @returns the view count
  19853. */
  19854. getViewCount(): number;
  19855. }
  19856. }
  19857. declare module BABYLON {
  19858. interface Engine {
  19859. /**
  19860. * Creates a new multiview render target
  19861. * @param width defines the width of the texture
  19862. * @param height defines the height of the texture
  19863. * @returns the created multiview texture
  19864. */
  19865. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19866. /**
  19867. * Binds a multiview framebuffer to be drawn to
  19868. * @param multiviewTexture texture to bind
  19869. */
  19870. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19871. }
  19872. interface Camera {
  19873. /**
  19874. * @hidden
  19875. * 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)
  19876. */
  19877. _useMultiviewToSingleView: boolean;
  19878. /**
  19879. * @hidden
  19880. * 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)
  19881. */
  19882. _multiviewTexture: Nullable<RenderTargetTexture>;
  19883. /**
  19884. * @hidden
  19885. * ensures the multiview texture of the camera exists and has the specified width/height
  19886. * @param width height to set on the multiview texture
  19887. * @param height width to set on the multiview texture
  19888. */
  19889. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19890. }
  19891. interface Scene {
  19892. /** @hidden */
  19893. _transformMatrixR: Matrix;
  19894. /** @hidden */
  19895. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19896. /** @hidden */
  19897. _createMultiviewUbo(): void;
  19898. /** @hidden */
  19899. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19900. /** @hidden */
  19901. _renderMultiviewToSingleView(camera: Camera): void;
  19902. }
  19903. }
  19904. declare module BABYLON {
  19905. /**
  19906. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19907. * This will not be used for webXR as it supports displaying texture arrays directly
  19908. */
  19909. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19910. /**
  19911. * Gets a string identifying the name of the class
  19912. * @returns "VRMultiviewToSingleviewPostProcess" string
  19913. */
  19914. getClassName(): string;
  19915. /**
  19916. * Initializes a VRMultiviewToSingleview
  19917. * @param name name of the post process
  19918. * @param camera camera to be applied to
  19919. * @param scaleFactor scaling factor to the size of the output texture
  19920. */
  19921. constructor(name: string, camera: Camera, scaleFactor: number);
  19922. }
  19923. }
  19924. declare module BABYLON {
  19925. /**
  19926. * Interface used to define additional presentation attributes
  19927. */
  19928. export interface IVRPresentationAttributes {
  19929. /**
  19930. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19931. */
  19932. highRefreshRate: boolean;
  19933. /**
  19934. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19935. */
  19936. foveationLevel: number;
  19937. }
  19938. interface Engine {
  19939. /** @hidden */
  19940. _vrDisplay: any;
  19941. /** @hidden */
  19942. _vrSupported: boolean;
  19943. /** @hidden */
  19944. _oldSize: Size;
  19945. /** @hidden */
  19946. _oldHardwareScaleFactor: number;
  19947. /** @hidden */
  19948. _vrExclusivePointerMode: boolean;
  19949. /** @hidden */
  19950. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19951. /** @hidden */
  19952. _onVRDisplayPointerRestricted: () => void;
  19953. /** @hidden */
  19954. _onVRDisplayPointerUnrestricted: () => void;
  19955. /** @hidden */
  19956. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19957. /** @hidden */
  19958. _onVrDisplayDisconnect: Nullable<() => void>;
  19959. /** @hidden */
  19960. _onVrDisplayPresentChange: Nullable<() => void>;
  19961. /**
  19962. * Observable signaled when VR display mode changes
  19963. */
  19964. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19965. /**
  19966. * Observable signaled when VR request present is complete
  19967. */
  19968. onVRRequestPresentComplete: Observable<boolean>;
  19969. /**
  19970. * Observable signaled when VR request present starts
  19971. */
  19972. onVRRequestPresentStart: Observable<Engine>;
  19973. /**
  19974. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19975. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19976. */
  19977. isInVRExclusivePointerMode: boolean;
  19978. /**
  19979. * Gets a boolean indicating if a webVR device was detected
  19980. * @returns true if a webVR device was detected
  19981. */
  19982. isVRDevicePresent(): boolean;
  19983. /**
  19984. * Gets the current webVR device
  19985. * @returns the current webVR device (or null)
  19986. */
  19987. getVRDevice(): any;
  19988. /**
  19989. * Initializes a webVR display and starts listening to display change events
  19990. * The onVRDisplayChangedObservable will be notified upon these changes
  19991. * @returns A promise containing a VRDisplay and if vr is supported
  19992. */
  19993. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19994. /** @hidden */
  19995. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19996. /**
  19997. * Gets or sets the presentation attributes used to configure VR rendering
  19998. */
  19999. vrPresentationAttributes?: IVRPresentationAttributes;
  20000. /**
  20001. * Call this function to switch to webVR mode
  20002. * Will do nothing if webVR is not supported or if there is no webVR device
  20003. * @param options the webvr options provided to the camera. mainly used for multiview
  20004. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20005. */
  20006. enableVR(options: WebVROptions): void;
  20007. /** @hidden */
  20008. _onVRFullScreenTriggered(): void;
  20009. }
  20010. }
  20011. declare module BABYLON {
  20012. /**
  20013. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20014. * IMPORTANT!! The data is right-hand data.
  20015. * @export
  20016. * @interface DevicePose
  20017. */
  20018. export interface DevicePose {
  20019. /**
  20020. * The position of the device, values in array are [x,y,z].
  20021. */
  20022. readonly position: Nullable<Float32Array>;
  20023. /**
  20024. * The linearVelocity of the device, values in array are [x,y,z].
  20025. */
  20026. readonly linearVelocity: Nullable<Float32Array>;
  20027. /**
  20028. * The linearAcceleration of the device, values in array are [x,y,z].
  20029. */
  20030. readonly linearAcceleration: Nullable<Float32Array>;
  20031. /**
  20032. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20033. */
  20034. readonly orientation: Nullable<Float32Array>;
  20035. /**
  20036. * The angularVelocity of the device, values in array are [x,y,z].
  20037. */
  20038. readonly angularVelocity: Nullable<Float32Array>;
  20039. /**
  20040. * The angularAcceleration of the device, values in array are [x,y,z].
  20041. */
  20042. readonly angularAcceleration: Nullable<Float32Array>;
  20043. }
  20044. /**
  20045. * Interface representing a pose controlled object in Babylon.
  20046. * A pose controlled object has both regular pose values as well as pose values
  20047. * from an external device such as a VR head mounted display
  20048. */
  20049. export interface PoseControlled {
  20050. /**
  20051. * The position of the object in babylon space.
  20052. */
  20053. position: Vector3;
  20054. /**
  20055. * The rotation quaternion of the object in babylon space.
  20056. */
  20057. rotationQuaternion: Quaternion;
  20058. /**
  20059. * The position of the device in babylon space.
  20060. */
  20061. devicePosition?: Vector3;
  20062. /**
  20063. * The rotation quaternion of the device in babylon space.
  20064. */
  20065. deviceRotationQuaternion: Quaternion;
  20066. /**
  20067. * The raw pose coming from the device.
  20068. */
  20069. rawPose: Nullable<DevicePose>;
  20070. /**
  20071. * The scale of the device to be used when translating from device space to babylon space.
  20072. */
  20073. deviceScaleFactor: number;
  20074. /**
  20075. * Updates the poseControlled values based on the input device pose.
  20076. * @param poseData the pose data to update the object with
  20077. */
  20078. updateFromDevice(poseData: DevicePose): void;
  20079. }
  20080. /**
  20081. * Set of options to customize the webVRCamera
  20082. */
  20083. export interface WebVROptions {
  20084. /**
  20085. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20086. */
  20087. trackPosition?: boolean;
  20088. /**
  20089. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20090. */
  20091. positionScale?: number;
  20092. /**
  20093. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20094. */
  20095. displayName?: string;
  20096. /**
  20097. * Should the native controller meshes be initialized. (default: true)
  20098. */
  20099. controllerMeshes?: boolean;
  20100. /**
  20101. * Creating a default HemiLight only on controllers. (default: true)
  20102. */
  20103. defaultLightingOnControllers?: boolean;
  20104. /**
  20105. * If you don't want to use the default VR button of the helper. (default: false)
  20106. */
  20107. useCustomVRButton?: boolean;
  20108. /**
  20109. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20110. */
  20111. customVRButton?: HTMLButtonElement;
  20112. /**
  20113. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20114. */
  20115. rayLength?: number;
  20116. /**
  20117. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20118. */
  20119. defaultHeight?: number;
  20120. /**
  20121. * If multiview should be used if availible (default: false)
  20122. */
  20123. useMultiview?: boolean;
  20124. }
  20125. /**
  20126. * This represents a WebVR camera.
  20127. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20128. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20129. */
  20130. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20131. private webVROptions;
  20132. /**
  20133. * @hidden
  20134. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20135. */
  20136. _vrDevice: any;
  20137. /**
  20138. * The rawPose of the vrDevice.
  20139. */
  20140. rawPose: Nullable<DevicePose>;
  20141. private _onVREnabled;
  20142. private _specsVersion;
  20143. private _attached;
  20144. private _frameData;
  20145. protected _descendants: Array<Node>;
  20146. private _deviceRoomPosition;
  20147. /** @hidden */
  20148. _deviceRoomRotationQuaternion: Quaternion;
  20149. private _standingMatrix;
  20150. /**
  20151. * Represents device position in babylon space.
  20152. */
  20153. devicePosition: Vector3;
  20154. /**
  20155. * Represents device rotation in babylon space.
  20156. */
  20157. deviceRotationQuaternion: Quaternion;
  20158. /**
  20159. * The scale of the device to be used when translating from device space to babylon space.
  20160. */
  20161. deviceScaleFactor: number;
  20162. private _deviceToWorld;
  20163. private _worldToDevice;
  20164. /**
  20165. * References to the webVR controllers for the vrDevice.
  20166. */
  20167. controllers: Array<WebVRController>;
  20168. /**
  20169. * Emits an event when a controller is attached.
  20170. */
  20171. onControllersAttachedObservable: Observable<WebVRController[]>;
  20172. /**
  20173. * Emits an event when a controller's mesh has been loaded;
  20174. */
  20175. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20176. /**
  20177. * Emits an event when the HMD's pose has been updated.
  20178. */
  20179. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20180. private _poseSet;
  20181. /**
  20182. * If the rig cameras be used as parent instead of this camera.
  20183. */
  20184. rigParenting: boolean;
  20185. private _lightOnControllers;
  20186. private _defaultHeight?;
  20187. /**
  20188. * Instantiates a WebVRFreeCamera.
  20189. * @param name The name of the WebVRFreeCamera
  20190. * @param position The starting anchor position for the camera
  20191. * @param scene The scene the camera belongs to
  20192. * @param webVROptions a set of customizable options for the webVRCamera
  20193. */
  20194. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20195. /**
  20196. * Gets the device distance from the ground in meters.
  20197. * @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.
  20198. */
  20199. deviceDistanceToRoomGround(): number;
  20200. /**
  20201. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20202. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20203. */
  20204. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20205. /**
  20206. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20207. * @returns A promise with a boolean set to if the standing matrix is supported.
  20208. */
  20209. useStandingMatrixAsync(): Promise<boolean>;
  20210. /**
  20211. * Disposes the camera
  20212. */
  20213. dispose(): void;
  20214. /**
  20215. * Gets a vrController by name.
  20216. * @param name The name of the controller to retreive
  20217. * @returns the controller matching the name specified or null if not found
  20218. */
  20219. getControllerByName(name: string): Nullable<WebVRController>;
  20220. private _leftController;
  20221. /**
  20222. * The controller corresponding to the users left hand.
  20223. */
  20224. get leftController(): Nullable<WebVRController>;
  20225. private _rightController;
  20226. /**
  20227. * The controller corresponding to the users right hand.
  20228. */
  20229. get rightController(): Nullable<WebVRController>;
  20230. /**
  20231. * Casts a ray forward from the vrCamera's gaze.
  20232. * @param length Length of the ray (default: 100)
  20233. * @returns the ray corresponding to the gaze
  20234. */
  20235. getForwardRay(length?: number): Ray;
  20236. /**
  20237. * @hidden
  20238. * Updates the camera based on device's frame data
  20239. */
  20240. _checkInputs(): void;
  20241. /**
  20242. * Updates the poseControlled values based on the input device pose.
  20243. * @param poseData Pose coming from the device
  20244. */
  20245. updateFromDevice(poseData: DevicePose): void;
  20246. private _htmlElementAttached;
  20247. private _detachIfAttached;
  20248. /**
  20249. * WebVR's attach control will start broadcasting frames to the device.
  20250. * Note that in certain browsers (chrome for example) this function must be called
  20251. * within a user-interaction callback. Example:
  20252. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20253. *
  20254. * @param element html element to attach the vrDevice to
  20255. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20256. */
  20257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20258. /**
  20259. * Detaches the camera from the html element and disables VR
  20260. *
  20261. * @param element html element to detach from
  20262. */
  20263. detachControl(element: HTMLElement): void;
  20264. /**
  20265. * @returns the name of this class
  20266. */
  20267. getClassName(): string;
  20268. /**
  20269. * Calls resetPose on the vrDisplay
  20270. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20271. */
  20272. resetToCurrentRotation(): void;
  20273. /**
  20274. * @hidden
  20275. * Updates the rig cameras (left and right eye)
  20276. */
  20277. _updateRigCameras(): void;
  20278. private _workingVector;
  20279. private _oneVector;
  20280. private _workingMatrix;
  20281. private updateCacheCalled;
  20282. private _correctPositionIfNotTrackPosition;
  20283. /**
  20284. * @hidden
  20285. * Updates the cached values of the camera
  20286. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20287. */
  20288. _updateCache(ignoreParentClass?: boolean): void;
  20289. /**
  20290. * @hidden
  20291. * Get current device position in babylon world
  20292. */
  20293. _computeDevicePosition(): void;
  20294. /**
  20295. * Updates the current device position and rotation in the babylon world
  20296. */
  20297. update(): void;
  20298. /**
  20299. * @hidden
  20300. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20301. * @returns an identity matrix
  20302. */
  20303. _getViewMatrix(): Matrix;
  20304. private _tmpMatrix;
  20305. /**
  20306. * This function is called by the two RIG cameras.
  20307. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20308. * @hidden
  20309. */
  20310. _getWebVRViewMatrix(): Matrix;
  20311. /** @hidden */
  20312. _getWebVRProjectionMatrix(): Matrix;
  20313. private _onGamepadConnectedObserver;
  20314. private _onGamepadDisconnectedObserver;
  20315. private _updateCacheWhenTrackingDisabledObserver;
  20316. /**
  20317. * Initializes the controllers and their meshes
  20318. */
  20319. initControllers(): void;
  20320. }
  20321. }
  20322. declare module BABYLON {
  20323. /**
  20324. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20325. *
  20326. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20327. *
  20328. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20329. */
  20330. export class MaterialHelper {
  20331. /**
  20332. * Bind the current view position to an effect.
  20333. * @param effect The effect to be bound
  20334. * @param scene The scene the eyes position is used from
  20335. * @param variableName name of the shader variable that will hold the eye position
  20336. */
  20337. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20338. /**
  20339. * Helps preparing the defines values about the UVs in used in the effect.
  20340. * UVs are shared as much as we can accross channels in the shaders.
  20341. * @param texture The texture we are preparing the UVs for
  20342. * @param defines The defines to update
  20343. * @param key The channel key "diffuse", "specular"... used in the shader
  20344. */
  20345. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20346. /**
  20347. * Binds a texture matrix value to its corrsponding uniform
  20348. * @param texture The texture to bind the matrix for
  20349. * @param uniformBuffer The uniform buffer receivin the data
  20350. * @param key The channel key "diffuse", "specular"... used in the shader
  20351. */
  20352. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20353. /**
  20354. * Gets the current status of the fog (should it be enabled?)
  20355. * @param mesh defines the mesh to evaluate for fog support
  20356. * @param scene defines the hosting scene
  20357. * @returns true if fog must be enabled
  20358. */
  20359. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20360. /**
  20361. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20362. * @param mesh defines the current mesh
  20363. * @param scene defines the current scene
  20364. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20365. * @param pointsCloud defines if point cloud rendering has to be turned on
  20366. * @param fogEnabled defines if fog has to be turned on
  20367. * @param alphaTest defines if alpha testing has to be turned on
  20368. * @param defines defines the current list of defines
  20369. */
  20370. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20371. /**
  20372. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20373. * @param scene defines the current scene
  20374. * @param engine defines the current engine
  20375. * @param defines specifies the list of active defines
  20376. * @param useInstances defines if instances have to be turned on
  20377. * @param useClipPlane defines if clip plane have to be turned on
  20378. * @param useInstances defines if instances have to be turned on
  20379. * @param useThinInstances defines if thin instances have to be turned on
  20380. */
  20381. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20382. /**
  20383. * Prepares the defines for bones
  20384. * @param mesh The mesh containing the geometry data we will draw
  20385. * @param defines The defines to update
  20386. */
  20387. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20388. /**
  20389. * Prepares the defines for morph targets
  20390. * @param mesh The mesh containing the geometry data we will draw
  20391. * @param defines The defines to update
  20392. */
  20393. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20394. /**
  20395. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20396. * @param mesh The mesh containing the geometry data we will draw
  20397. * @param defines The defines to update
  20398. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20399. * @param useBones Precise whether bones should be used or not (override mesh info)
  20400. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20401. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20402. * @returns false if defines are considered not dirty and have not been checked
  20403. */
  20404. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20405. /**
  20406. * Prepares the defines related to multiview
  20407. * @param scene The scene we are intending to draw
  20408. * @param defines The defines to update
  20409. */
  20410. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20411. /**
  20412. * Prepares the defines related to the prepass
  20413. * @param scene The scene we are intending to draw
  20414. * @param defines The defines to update
  20415. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20416. */
  20417. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20418. /**
  20419. * Prepares the defines related to the light information passed in parameter
  20420. * @param scene The scene we are intending to draw
  20421. * @param mesh The mesh the effect is compiling for
  20422. * @param light The light the effect is compiling for
  20423. * @param lightIndex The index of the light
  20424. * @param defines The defines to update
  20425. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20426. * @param state Defines the current state regarding what is needed (normals, etc...)
  20427. */
  20428. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20429. needNormals: boolean;
  20430. needRebuild: boolean;
  20431. shadowEnabled: boolean;
  20432. specularEnabled: boolean;
  20433. lightmapMode: boolean;
  20434. }): void;
  20435. /**
  20436. * Prepares the defines related to the light information passed in parameter
  20437. * @param scene The scene we are intending to draw
  20438. * @param mesh The mesh the effect is compiling for
  20439. * @param defines The defines to update
  20440. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20441. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20442. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20443. * @returns true if normals will be required for the rest of the effect
  20444. */
  20445. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20446. /**
  20447. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20448. * @param lightIndex defines the light index
  20449. * @param uniformsList The uniform list
  20450. * @param samplersList The sampler list
  20451. * @param projectedLightTexture defines if projected texture must be used
  20452. * @param uniformBuffersList defines an optional list of uniform buffers
  20453. */
  20454. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20455. /**
  20456. * Prepares the uniforms and samplers list to be used in the effect
  20457. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20458. * @param samplersList The sampler list
  20459. * @param defines The defines helping in the list generation
  20460. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20461. */
  20462. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20463. /**
  20464. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20465. * @param defines The defines to update while falling back
  20466. * @param fallbacks The authorized effect fallbacks
  20467. * @param maxSimultaneousLights The maximum number of lights allowed
  20468. * @param rank the current rank of the Effect
  20469. * @returns The newly affected rank
  20470. */
  20471. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20472. private static _TmpMorphInfluencers;
  20473. /**
  20474. * Prepares the list of attributes required for morph targets according to the effect defines.
  20475. * @param attribs The current list of supported attribs
  20476. * @param mesh The mesh to prepare the morph targets attributes for
  20477. * @param influencers The number of influencers
  20478. */
  20479. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20480. /**
  20481. * Prepares the list of attributes required for morph targets according to the effect defines.
  20482. * @param attribs The current list of supported attribs
  20483. * @param mesh The mesh to prepare the morph targets attributes for
  20484. * @param defines The current Defines of the effect
  20485. */
  20486. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20487. /**
  20488. * Prepares the list of attributes required for bones according to the effect defines.
  20489. * @param attribs The current list of supported attribs
  20490. * @param mesh The mesh to prepare the bones attributes for
  20491. * @param defines The current Defines of the effect
  20492. * @param fallbacks The current efffect fallback strategy
  20493. */
  20494. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20495. /**
  20496. * Check and prepare the list of attributes required for instances according to the effect defines.
  20497. * @param attribs The current list of supported attribs
  20498. * @param defines The current MaterialDefines of the effect
  20499. */
  20500. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20501. /**
  20502. * Add the list of attributes required for instances to the attribs array.
  20503. * @param attribs The current list of supported attribs
  20504. */
  20505. static PushAttributesForInstances(attribs: string[]): void;
  20506. /**
  20507. * Binds the light information to the effect.
  20508. * @param light The light containing the generator
  20509. * @param effect The effect we are binding the data to
  20510. * @param lightIndex The light index in the effect used to render
  20511. */
  20512. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20513. /**
  20514. * Binds the lights information from the scene to the effect for the given mesh.
  20515. * @param light Light to bind
  20516. * @param lightIndex Light index
  20517. * @param scene The scene where the light belongs to
  20518. * @param effect The effect we are binding the data to
  20519. * @param useSpecular Defines if specular is supported
  20520. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20521. */
  20522. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20523. /**
  20524. * Binds the lights information from the scene to the effect for the given mesh.
  20525. * @param scene The scene the lights belongs to
  20526. * @param mesh The mesh we are binding the information to render
  20527. * @param effect The effect we are binding the data to
  20528. * @param defines The generated defines for the effect
  20529. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20530. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20531. */
  20532. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20533. private static _tempFogColor;
  20534. /**
  20535. * Binds the fog information from the scene to the effect for the given mesh.
  20536. * @param scene The scene the lights belongs to
  20537. * @param mesh The mesh we are binding the information to render
  20538. * @param effect The effect we are binding the data to
  20539. * @param linearSpace Defines if the fog effect is applied in linear space
  20540. */
  20541. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20542. /**
  20543. * Binds the bones information from the mesh to the effect.
  20544. * @param mesh The mesh we are binding the information to render
  20545. * @param effect The effect we are binding the data to
  20546. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20547. */
  20548. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20549. private static _CopyBonesTransformationMatrices;
  20550. /**
  20551. * Binds the morph targets information from the mesh to the effect.
  20552. * @param abstractMesh The mesh we are binding the information to render
  20553. * @param effect The effect we are binding the data to
  20554. */
  20555. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20556. /**
  20557. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20558. * @param defines The generated defines used in the effect
  20559. * @param effect The effect we are binding the data to
  20560. * @param scene The scene we are willing to render with logarithmic scale for
  20561. */
  20562. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20563. /**
  20564. * Binds the clip plane information from the scene to the effect.
  20565. * @param scene The scene the clip plane information are extracted from
  20566. * @param effect The effect we are binding the data to
  20567. */
  20568. static BindClipPlane(effect: Effect, scene: Scene): void;
  20569. }
  20570. }
  20571. declare module BABYLON {
  20572. /**
  20573. * Block used to expose an input value
  20574. */
  20575. export class InputBlock extends NodeMaterialBlock {
  20576. private _mode;
  20577. private _associatedVariableName;
  20578. private _storedValue;
  20579. private _valueCallback;
  20580. private _type;
  20581. private _animationType;
  20582. /** Gets or set a value used to limit the range of float values */
  20583. min: number;
  20584. /** Gets or set a value used to limit the range of float values */
  20585. max: number;
  20586. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20587. isBoolean: boolean;
  20588. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20589. matrixMode: number;
  20590. /** @hidden */
  20591. _systemValue: Nullable<NodeMaterialSystemValues>;
  20592. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20593. isConstant: boolean;
  20594. /** Gets or sets the group to use to display this block in the Inspector */
  20595. groupInInspector: string;
  20596. /** Gets an observable raised when the value is changed */
  20597. onValueChangedObservable: Observable<InputBlock>;
  20598. /**
  20599. * Gets or sets the connection point type (default is float)
  20600. */
  20601. get type(): NodeMaterialBlockConnectionPointTypes;
  20602. /**
  20603. * Creates a new InputBlock
  20604. * @param name defines the block name
  20605. * @param target defines the target of that block (Vertex by default)
  20606. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20607. */
  20608. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20609. /**
  20610. * Validates if a name is a reserve word.
  20611. * @param newName the new name to be given to the node.
  20612. * @returns false if the name is a reserve word, else true.
  20613. */
  20614. validateBlockName(newName: string): boolean;
  20615. /**
  20616. * Gets the output component
  20617. */
  20618. get output(): NodeMaterialConnectionPoint;
  20619. /**
  20620. * Set the source of this connection point to a vertex attribute
  20621. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20622. * @returns the current connection point
  20623. */
  20624. setAsAttribute(attributeName?: string): InputBlock;
  20625. /**
  20626. * Set the source of this connection point to a system value
  20627. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20628. * @returns the current connection point
  20629. */
  20630. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20631. /**
  20632. * Gets or sets the value of that point.
  20633. * Please note that this value will be ignored if valueCallback is defined
  20634. */
  20635. get value(): any;
  20636. set value(value: any);
  20637. /**
  20638. * Gets or sets a callback used to get the value of that point.
  20639. * Please note that setting this value will force the connection point to ignore the value property
  20640. */
  20641. get valueCallback(): () => any;
  20642. set valueCallback(value: () => any);
  20643. /**
  20644. * Gets or sets the associated variable name in the shader
  20645. */
  20646. get associatedVariableName(): string;
  20647. set associatedVariableName(value: string);
  20648. /** Gets or sets the type of animation applied to the input */
  20649. get animationType(): AnimatedInputBlockTypes;
  20650. set animationType(value: AnimatedInputBlockTypes);
  20651. /**
  20652. * Gets a boolean indicating that this connection point not defined yet
  20653. */
  20654. get isUndefined(): boolean;
  20655. /**
  20656. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20657. * In this case the connection point name must be the name of the uniform to use.
  20658. * Can only be set on inputs
  20659. */
  20660. get isUniform(): boolean;
  20661. set isUniform(value: boolean);
  20662. /**
  20663. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20664. * In this case the connection point name must be the name of the attribute to use
  20665. * Can only be set on inputs
  20666. */
  20667. get isAttribute(): boolean;
  20668. set isAttribute(value: boolean);
  20669. /**
  20670. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20671. * Can only be set on exit points
  20672. */
  20673. get isVarying(): boolean;
  20674. set isVarying(value: boolean);
  20675. /**
  20676. * Gets a boolean indicating that the current connection point is a system value
  20677. */
  20678. get isSystemValue(): boolean;
  20679. /**
  20680. * Gets or sets the current well known value or null if not defined as a system value
  20681. */
  20682. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20683. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20684. /**
  20685. * Gets the current class name
  20686. * @returns the class name
  20687. */
  20688. getClassName(): string;
  20689. /**
  20690. * Animate the input if animationType !== None
  20691. * @param scene defines the rendering scene
  20692. */
  20693. animate(scene: Scene): void;
  20694. private _emitDefine;
  20695. initialize(state: NodeMaterialBuildState): void;
  20696. /**
  20697. * Set the input block to its default value (based on its type)
  20698. */
  20699. setDefaultValue(): void;
  20700. private _emitConstant;
  20701. /** @hidden */
  20702. get _noContextSwitch(): boolean;
  20703. private _emit;
  20704. /** @hidden */
  20705. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20706. /** @hidden */
  20707. _transmit(effect: Effect, scene: Scene): void;
  20708. protected _buildBlock(state: NodeMaterialBuildState): void;
  20709. protected _dumpPropertiesCode(): string;
  20710. dispose(): void;
  20711. serialize(): any;
  20712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20713. }
  20714. }
  20715. declare module BABYLON {
  20716. /**
  20717. * Enum used to define the compatibility state between two connection points
  20718. */
  20719. export enum NodeMaterialConnectionPointCompatibilityStates {
  20720. /** Points are compatibles */
  20721. Compatible = 0,
  20722. /** Points are incompatible because of their types */
  20723. TypeIncompatible = 1,
  20724. /** Points are incompatible because of their targets (vertex vs fragment) */
  20725. TargetIncompatible = 2
  20726. }
  20727. /**
  20728. * Defines the direction of a connection point
  20729. */
  20730. export enum NodeMaterialConnectionPointDirection {
  20731. /** Input */
  20732. Input = 0,
  20733. /** Output */
  20734. Output = 1
  20735. }
  20736. /**
  20737. * Defines a connection point for a block
  20738. */
  20739. export class NodeMaterialConnectionPoint {
  20740. /** @hidden */
  20741. _ownerBlock: NodeMaterialBlock;
  20742. /** @hidden */
  20743. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20744. private _endpoints;
  20745. private _associatedVariableName;
  20746. private _direction;
  20747. /** @hidden */
  20748. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20749. /** @hidden */
  20750. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20751. private _type;
  20752. /** @hidden */
  20753. _enforceAssociatedVariableName: boolean;
  20754. /** Gets the direction of the point */
  20755. get direction(): NodeMaterialConnectionPointDirection;
  20756. /** Indicates that this connection point needs dual validation before being connected to another point */
  20757. needDualDirectionValidation: boolean;
  20758. /**
  20759. * Gets or sets the additional types supported by this connection point
  20760. */
  20761. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20762. /**
  20763. * Gets or sets the additional types excluded by this connection point
  20764. */
  20765. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20766. /**
  20767. * Observable triggered when this point is connected
  20768. */
  20769. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20770. /**
  20771. * Gets or sets the associated variable name in the shader
  20772. */
  20773. get associatedVariableName(): string;
  20774. set associatedVariableName(value: string);
  20775. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20776. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20777. /**
  20778. * Gets or sets the connection point type (default is float)
  20779. */
  20780. get type(): NodeMaterialBlockConnectionPointTypes;
  20781. set type(value: NodeMaterialBlockConnectionPointTypes);
  20782. /**
  20783. * Gets or sets the connection point name
  20784. */
  20785. name: string;
  20786. /**
  20787. * Gets or sets the connection point name
  20788. */
  20789. displayName: string;
  20790. /**
  20791. * Gets or sets a boolean indicating that this connection point can be omitted
  20792. */
  20793. isOptional: boolean;
  20794. /**
  20795. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20796. */
  20797. isExposedOnFrame: boolean;
  20798. /**
  20799. * Gets or sets number indicating the position that the port is exposed to on a frame
  20800. */
  20801. exposedPortPosition: number;
  20802. /**
  20803. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20804. */
  20805. define: string;
  20806. /** @hidden */
  20807. _prioritizeVertex: boolean;
  20808. private _target;
  20809. /** Gets or sets the target of that connection point */
  20810. get target(): NodeMaterialBlockTargets;
  20811. set target(value: NodeMaterialBlockTargets);
  20812. /**
  20813. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20814. */
  20815. get isConnected(): boolean;
  20816. /**
  20817. * Gets a boolean indicating that the current point is connected to an input block
  20818. */
  20819. get isConnectedToInputBlock(): boolean;
  20820. /**
  20821. * Gets a the connected input block (if any)
  20822. */
  20823. get connectInputBlock(): Nullable<InputBlock>;
  20824. /** Get the other side of the connection (if any) */
  20825. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20826. /** Get the block that owns this connection point */
  20827. get ownerBlock(): NodeMaterialBlock;
  20828. /** Get the block connected on the other side of this connection (if any) */
  20829. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20830. /** Get the block connected on the endpoints of this connection (if any) */
  20831. get connectedBlocks(): Array<NodeMaterialBlock>;
  20832. /** Gets the list of connected endpoints */
  20833. get endpoints(): NodeMaterialConnectionPoint[];
  20834. /** Gets a boolean indicating if that output point is connected to at least one input */
  20835. get hasEndpoints(): boolean;
  20836. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20837. get isConnectedInVertexShader(): boolean;
  20838. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20839. get isConnectedInFragmentShader(): boolean;
  20840. /**
  20841. * Creates a block suitable to be used as an input for this input point.
  20842. * If null is returned, a block based on the point type will be created.
  20843. * @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
  20844. */
  20845. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20846. /**
  20847. * Creates a new connection point
  20848. * @param name defines the connection point name
  20849. * @param ownerBlock defines the block hosting this connection point
  20850. * @param direction defines the direction of the connection point
  20851. */
  20852. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20853. /**
  20854. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20855. * @returns the class name
  20856. */
  20857. getClassName(): string;
  20858. /**
  20859. * Gets a boolean indicating if the current point can be connected to another point
  20860. * @param connectionPoint defines the other connection point
  20861. * @returns a boolean
  20862. */
  20863. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20864. /**
  20865. * Gets a number indicating if the current point can be connected to another point
  20866. * @param connectionPoint defines the other connection point
  20867. * @returns a number defining the compatibility state
  20868. */
  20869. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20870. /**
  20871. * Connect this point to another connection point
  20872. * @param connectionPoint defines the other connection point
  20873. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20874. * @returns the current connection point
  20875. */
  20876. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20877. /**
  20878. * Disconnect this point from one of his endpoint
  20879. * @param endpoint defines the other connection point
  20880. * @returns the current connection point
  20881. */
  20882. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20883. /**
  20884. * Serializes this point in a JSON representation
  20885. * @param isInput defines if the connection point is an input (default is true)
  20886. * @returns the serialized point object
  20887. */
  20888. serialize(isInput?: boolean): any;
  20889. /**
  20890. * Release resources
  20891. */
  20892. dispose(): void;
  20893. }
  20894. }
  20895. declare module BABYLON {
  20896. /**
  20897. * Enum used to define the material modes
  20898. */
  20899. export enum NodeMaterialModes {
  20900. /** Regular material */
  20901. Material = 0,
  20902. /** For post process */
  20903. PostProcess = 1,
  20904. /** For particle system */
  20905. Particle = 2,
  20906. /** For procedural texture */
  20907. ProceduralTexture = 3
  20908. }
  20909. }
  20910. declare module BABYLON {
  20911. /**
  20912. * Block used to read a texture from a sampler
  20913. */
  20914. export class TextureBlock extends NodeMaterialBlock {
  20915. private _defineName;
  20916. private _linearDefineName;
  20917. private _gammaDefineName;
  20918. private _tempTextureRead;
  20919. private _samplerName;
  20920. private _transformedUVName;
  20921. private _textureTransformName;
  20922. private _textureInfoName;
  20923. private _mainUVName;
  20924. private _mainUVDefineName;
  20925. private _fragmentOnly;
  20926. /**
  20927. * Gets or sets the texture associated with the node
  20928. */
  20929. texture: Nullable<Texture>;
  20930. /**
  20931. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20932. */
  20933. convertToGammaSpace: boolean;
  20934. /**
  20935. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20936. */
  20937. convertToLinearSpace: boolean;
  20938. /**
  20939. * Create a new TextureBlock
  20940. * @param name defines the block name
  20941. */
  20942. constructor(name: string, fragmentOnly?: boolean);
  20943. /**
  20944. * Gets the current class name
  20945. * @returns the class name
  20946. */
  20947. getClassName(): string;
  20948. /**
  20949. * Gets the uv input component
  20950. */
  20951. get uv(): NodeMaterialConnectionPoint;
  20952. /**
  20953. * Gets the rgba output component
  20954. */
  20955. get rgba(): NodeMaterialConnectionPoint;
  20956. /**
  20957. * Gets the rgb output component
  20958. */
  20959. get rgb(): NodeMaterialConnectionPoint;
  20960. /**
  20961. * Gets the r output component
  20962. */
  20963. get r(): NodeMaterialConnectionPoint;
  20964. /**
  20965. * Gets the g output component
  20966. */
  20967. get g(): NodeMaterialConnectionPoint;
  20968. /**
  20969. * Gets the b output component
  20970. */
  20971. get b(): NodeMaterialConnectionPoint;
  20972. /**
  20973. * Gets the a output component
  20974. */
  20975. get a(): NodeMaterialConnectionPoint;
  20976. get target(): NodeMaterialBlockTargets;
  20977. autoConfigure(material: NodeMaterial): void;
  20978. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20980. isReady(): boolean;
  20981. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20982. private get _isMixed();
  20983. private _injectVertexCode;
  20984. private _writeTextureRead;
  20985. private _writeOutput;
  20986. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20987. protected _dumpPropertiesCode(): string;
  20988. serialize(): any;
  20989. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20990. }
  20991. }
  20992. declare module BABYLON {
  20993. /** @hidden */
  20994. export var reflectionFunction: {
  20995. name: string;
  20996. shader: string;
  20997. };
  20998. }
  20999. declare module BABYLON {
  21000. /**
  21001. * Base block used to read a reflection texture from a sampler
  21002. */
  21003. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21004. /** @hidden */
  21005. _define3DName: string;
  21006. /** @hidden */
  21007. _defineCubicName: string;
  21008. /** @hidden */
  21009. _defineExplicitName: string;
  21010. /** @hidden */
  21011. _defineProjectionName: string;
  21012. /** @hidden */
  21013. _defineLocalCubicName: string;
  21014. /** @hidden */
  21015. _defineSphericalName: string;
  21016. /** @hidden */
  21017. _definePlanarName: string;
  21018. /** @hidden */
  21019. _defineEquirectangularName: string;
  21020. /** @hidden */
  21021. _defineMirroredEquirectangularFixedName: string;
  21022. /** @hidden */
  21023. _defineEquirectangularFixedName: string;
  21024. /** @hidden */
  21025. _defineSkyboxName: string;
  21026. /** @hidden */
  21027. _defineOppositeZ: string;
  21028. /** @hidden */
  21029. _cubeSamplerName: string;
  21030. /** @hidden */
  21031. _2DSamplerName: string;
  21032. protected _positionUVWName: string;
  21033. protected _directionWName: string;
  21034. protected _reflectionVectorName: string;
  21035. /** @hidden */
  21036. _reflectionCoordsName: string;
  21037. /** @hidden */
  21038. _reflectionMatrixName: string;
  21039. protected _reflectionColorName: string;
  21040. /**
  21041. * Gets or sets the texture associated with the node
  21042. */
  21043. texture: Nullable<BaseTexture>;
  21044. /**
  21045. * Create a new ReflectionTextureBaseBlock
  21046. * @param name defines the block name
  21047. */
  21048. constructor(name: string);
  21049. /**
  21050. * Gets the current class name
  21051. * @returns the class name
  21052. */
  21053. getClassName(): string;
  21054. /**
  21055. * Gets the world position input component
  21056. */
  21057. abstract get position(): NodeMaterialConnectionPoint;
  21058. /**
  21059. * Gets the world position input component
  21060. */
  21061. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21062. /**
  21063. * Gets the world normal input component
  21064. */
  21065. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21066. /**
  21067. * Gets the world input component
  21068. */
  21069. abstract get world(): NodeMaterialConnectionPoint;
  21070. /**
  21071. * Gets the camera (or eye) position component
  21072. */
  21073. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21074. /**
  21075. * Gets the view input component
  21076. */
  21077. abstract get view(): NodeMaterialConnectionPoint;
  21078. protected _getTexture(): Nullable<BaseTexture>;
  21079. autoConfigure(material: NodeMaterial): void;
  21080. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21081. isReady(): boolean;
  21082. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21083. /**
  21084. * Gets the code to inject in the vertex shader
  21085. * @param state current state of the node material building
  21086. * @returns the shader code
  21087. */
  21088. handleVertexSide(state: NodeMaterialBuildState): string;
  21089. /**
  21090. * Handles the inits for the fragment code path
  21091. * @param state node material build state
  21092. */
  21093. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21094. /**
  21095. * Generates the reflection coords code for the fragment code path
  21096. * @param worldNormalVarName name of the world normal variable
  21097. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21098. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21099. * @returns the shader code
  21100. */
  21101. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21102. /**
  21103. * Generates the reflection color code for the fragment code path
  21104. * @param lodVarName name of the lod variable
  21105. * @param swizzleLookupTexture swizzle to use for the final color variable
  21106. * @returns the shader code
  21107. */
  21108. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21109. /**
  21110. * Generates the code corresponding to the connected output points
  21111. * @param state node material build state
  21112. * @param varName name of the variable to output
  21113. * @returns the shader code
  21114. */
  21115. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21116. protected _buildBlock(state: NodeMaterialBuildState): this;
  21117. protected _dumpPropertiesCode(): string;
  21118. serialize(): any;
  21119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21120. }
  21121. }
  21122. declare module BABYLON {
  21123. /**
  21124. * Defines a connection point to be used for points with a custom object type
  21125. */
  21126. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21127. private _blockType;
  21128. private _blockName;
  21129. private _nameForCheking?;
  21130. /**
  21131. * Creates a new connection point
  21132. * @param name defines the connection point name
  21133. * @param ownerBlock defines the block hosting this connection point
  21134. * @param direction defines the direction of the connection point
  21135. */
  21136. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21137. /**
  21138. * Gets a number indicating if the current point can be connected to another point
  21139. * @param connectionPoint defines the other connection point
  21140. * @returns a number defining the compatibility state
  21141. */
  21142. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21143. /**
  21144. * Creates a block suitable to be used as an input for this input point.
  21145. * If null is returned, a block based on the point type will be created.
  21146. * @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
  21147. */
  21148. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21149. }
  21150. }
  21151. declare module BABYLON {
  21152. /**
  21153. * Enum defining the type of properties that can be edited in the property pages in the NME
  21154. */
  21155. export enum PropertyTypeForEdition {
  21156. /** property is a boolean */
  21157. Boolean = 0,
  21158. /** property is a float */
  21159. Float = 1,
  21160. /** property is a Vector2 */
  21161. Vector2 = 2,
  21162. /** property is a list of values */
  21163. List = 3
  21164. }
  21165. /**
  21166. * Interface that defines an option in a variable of type list
  21167. */
  21168. export interface IEditablePropertyListOption {
  21169. /** label of the option */
  21170. "label": string;
  21171. /** value of the option */
  21172. "value": number;
  21173. }
  21174. /**
  21175. * Interface that defines the options available for an editable property
  21176. */
  21177. export interface IEditablePropertyOption {
  21178. /** min value */
  21179. "min"?: number;
  21180. /** max value */
  21181. "max"?: number;
  21182. /** notifiers: indicates which actions to take when the property is changed */
  21183. "notifiers"?: {
  21184. /** the material should be rebuilt */
  21185. "rebuild"?: boolean;
  21186. /** the preview should be updated */
  21187. "update"?: boolean;
  21188. };
  21189. /** list of the options for a variable of type list */
  21190. "options"?: IEditablePropertyListOption[];
  21191. }
  21192. /**
  21193. * Interface that describes an editable property
  21194. */
  21195. export interface IPropertyDescriptionForEdition {
  21196. /** name of the property */
  21197. "propertyName": string;
  21198. /** display name of the property */
  21199. "displayName": string;
  21200. /** type of the property */
  21201. "type": PropertyTypeForEdition;
  21202. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21203. "groupName": string;
  21204. /** options for the property */
  21205. "options": IEditablePropertyOption;
  21206. }
  21207. /**
  21208. * Decorator that flags a property in a node material block as being editable
  21209. */
  21210. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21211. }
  21212. declare module BABYLON {
  21213. /**
  21214. * Block used to implement the refraction part of the sub surface module of the PBR material
  21215. */
  21216. export class RefractionBlock extends NodeMaterialBlock {
  21217. /** @hidden */
  21218. _define3DName: string;
  21219. /** @hidden */
  21220. _refractionMatrixName: string;
  21221. /** @hidden */
  21222. _defineLODRefractionAlpha: string;
  21223. /** @hidden */
  21224. _defineLinearSpecularRefraction: string;
  21225. /** @hidden */
  21226. _defineOppositeZ: string;
  21227. /** @hidden */
  21228. _cubeSamplerName: string;
  21229. /** @hidden */
  21230. _2DSamplerName: string;
  21231. /** @hidden */
  21232. _vRefractionMicrosurfaceInfosName: string;
  21233. /** @hidden */
  21234. _vRefractionInfosName: string;
  21235. private _scene;
  21236. /**
  21237. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21238. * Materials half opaque for instance using refraction could benefit from this control.
  21239. */
  21240. linkRefractionWithTransparency: boolean;
  21241. /**
  21242. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21243. */
  21244. invertRefractionY: boolean;
  21245. /**
  21246. * Gets or sets the texture associated with the node
  21247. */
  21248. texture: Nullable<BaseTexture>;
  21249. /**
  21250. * Create a new RefractionBlock
  21251. * @param name defines the block name
  21252. */
  21253. constructor(name: string);
  21254. /**
  21255. * Gets the current class name
  21256. * @returns the class name
  21257. */
  21258. getClassName(): string;
  21259. /**
  21260. * Gets the intensity input component
  21261. */
  21262. get intensity(): NodeMaterialConnectionPoint;
  21263. /**
  21264. * Gets the index of refraction input component
  21265. */
  21266. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21267. /**
  21268. * Gets the tint at distance input component
  21269. */
  21270. get tintAtDistance(): NodeMaterialConnectionPoint;
  21271. /**
  21272. * Gets the view input component
  21273. */
  21274. get view(): NodeMaterialConnectionPoint;
  21275. /**
  21276. * Gets the refraction object output component
  21277. */
  21278. get refraction(): NodeMaterialConnectionPoint;
  21279. /**
  21280. * Returns true if the block has a texture
  21281. */
  21282. get hasTexture(): boolean;
  21283. protected _getTexture(): Nullable<BaseTexture>;
  21284. autoConfigure(material: NodeMaterial): void;
  21285. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21286. isReady(): boolean;
  21287. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21288. /**
  21289. * Gets the main code of the block (fragment side)
  21290. * @param state current state of the node material building
  21291. * @returns the shader code
  21292. */
  21293. getCode(state: NodeMaterialBuildState): string;
  21294. protected _buildBlock(state: NodeMaterialBuildState): this;
  21295. protected _dumpPropertiesCode(): string;
  21296. serialize(): any;
  21297. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21298. }
  21299. }
  21300. declare module BABYLON {
  21301. /**
  21302. * Base block used as input for post process
  21303. */
  21304. export class CurrentScreenBlock extends NodeMaterialBlock {
  21305. private _samplerName;
  21306. private _linearDefineName;
  21307. private _gammaDefineName;
  21308. private _mainUVName;
  21309. private _tempTextureRead;
  21310. /**
  21311. * Gets or sets the texture associated with the node
  21312. */
  21313. texture: Nullable<BaseTexture>;
  21314. /**
  21315. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21316. */
  21317. convertToGammaSpace: boolean;
  21318. /**
  21319. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21320. */
  21321. convertToLinearSpace: boolean;
  21322. /**
  21323. * Create a new CurrentScreenBlock
  21324. * @param name defines the block name
  21325. */
  21326. constructor(name: string);
  21327. /**
  21328. * Gets the current class name
  21329. * @returns the class name
  21330. */
  21331. getClassName(): string;
  21332. /**
  21333. * Gets the uv input component
  21334. */
  21335. get uv(): NodeMaterialConnectionPoint;
  21336. /**
  21337. * Gets the rgba output component
  21338. */
  21339. get rgba(): NodeMaterialConnectionPoint;
  21340. /**
  21341. * Gets the rgb output component
  21342. */
  21343. get rgb(): NodeMaterialConnectionPoint;
  21344. /**
  21345. * Gets the r output component
  21346. */
  21347. get r(): NodeMaterialConnectionPoint;
  21348. /**
  21349. * Gets the g output component
  21350. */
  21351. get g(): NodeMaterialConnectionPoint;
  21352. /**
  21353. * Gets the b output component
  21354. */
  21355. get b(): NodeMaterialConnectionPoint;
  21356. /**
  21357. * Gets the a output component
  21358. */
  21359. get a(): NodeMaterialConnectionPoint;
  21360. /**
  21361. * Initialize the block and prepare the context for build
  21362. * @param state defines the state that will be used for the build
  21363. */
  21364. initialize(state: NodeMaterialBuildState): void;
  21365. get target(): NodeMaterialBlockTargets;
  21366. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21367. isReady(): boolean;
  21368. private _injectVertexCode;
  21369. private _writeTextureRead;
  21370. private _writeOutput;
  21371. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21372. serialize(): any;
  21373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21374. }
  21375. }
  21376. declare module BABYLON {
  21377. /**
  21378. * Base block used for the particle texture
  21379. */
  21380. export class ParticleTextureBlock extends NodeMaterialBlock {
  21381. private _samplerName;
  21382. private _linearDefineName;
  21383. private _gammaDefineName;
  21384. private _tempTextureRead;
  21385. /**
  21386. * Gets or sets the texture associated with the node
  21387. */
  21388. texture: Nullable<BaseTexture>;
  21389. /**
  21390. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21391. */
  21392. convertToGammaSpace: boolean;
  21393. /**
  21394. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21395. */
  21396. convertToLinearSpace: boolean;
  21397. /**
  21398. * Create a new ParticleTextureBlock
  21399. * @param name defines the block name
  21400. */
  21401. constructor(name: string);
  21402. /**
  21403. * Gets the current class name
  21404. * @returns the class name
  21405. */
  21406. getClassName(): string;
  21407. /**
  21408. * Gets the uv input component
  21409. */
  21410. get uv(): NodeMaterialConnectionPoint;
  21411. /**
  21412. * Gets the rgba output component
  21413. */
  21414. get rgba(): NodeMaterialConnectionPoint;
  21415. /**
  21416. * Gets the rgb output component
  21417. */
  21418. get rgb(): NodeMaterialConnectionPoint;
  21419. /**
  21420. * Gets the r output component
  21421. */
  21422. get r(): NodeMaterialConnectionPoint;
  21423. /**
  21424. * Gets the g output component
  21425. */
  21426. get g(): NodeMaterialConnectionPoint;
  21427. /**
  21428. * Gets the b output component
  21429. */
  21430. get b(): NodeMaterialConnectionPoint;
  21431. /**
  21432. * Gets the a output component
  21433. */
  21434. get a(): NodeMaterialConnectionPoint;
  21435. /**
  21436. * Initialize the block and prepare the context for build
  21437. * @param state defines the state that will be used for the build
  21438. */
  21439. initialize(state: NodeMaterialBuildState): void;
  21440. autoConfigure(material: NodeMaterial): void;
  21441. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21442. isReady(): boolean;
  21443. private _writeOutput;
  21444. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21445. serialize(): any;
  21446. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21447. }
  21448. }
  21449. declare module BABYLON {
  21450. /**
  21451. * Class used to store shared data between 2 NodeMaterialBuildState
  21452. */
  21453. export class NodeMaterialBuildStateSharedData {
  21454. /**
  21455. * Gets the list of emitted varyings
  21456. */
  21457. temps: string[];
  21458. /**
  21459. * Gets the list of emitted varyings
  21460. */
  21461. varyings: string[];
  21462. /**
  21463. * Gets the varying declaration string
  21464. */
  21465. varyingDeclaration: string;
  21466. /**
  21467. * Input blocks
  21468. */
  21469. inputBlocks: InputBlock[];
  21470. /**
  21471. * Input blocks
  21472. */
  21473. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21474. /**
  21475. * Bindable blocks (Blocks that need to set data to the effect)
  21476. */
  21477. bindableBlocks: NodeMaterialBlock[];
  21478. /**
  21479. * List of blocks that can provide a compilation fallback
  21480. */
  21481. blocksWithFallbacks: NodeMaterialBlock[];
  21482. /**
  21483. * List of blocks that can provide a define update
  21484. */
  21485. blocksWithDefines: NodeMaterialBlock[];
  21486. /**
  21487. * List of blocks that can provide a repeatable content
  21488. */
  21489. repeatableContentBlocks: NodeMaterialBlock[];
  21490. /**
  21491. * List of blocks that can provide a dynamic list of uniforms
  21492. */
  21493. dynamicUniformBlocks: NodeMaterialBlock[];
  21494. /**
  21495. * List of blocks that can block the isReady function for the material
  21496. */
  21497. blockingBlocks: NodeMaterialBlock[];
  21498. /**
  21499. * Gets the list of animated inputs
  21500. */
  21501. animatedInputs: InputBlock[];
  21502. /**
  21503. * Build Id used to avoid multiple recompilations
  21504. */
  21505. buildId: number;
  21506. /** List of emitted variables */
  21507. variableNames: {
  21508. [key: string]: number;
  21509. };
  21510. /** List of emitted defines */
  21511. defineNames: {
  21512. [key: string]: number;
  21513. };
  21514. /** Should emit comments? */
  21515. emitComments: boolean;
  21516. /** Emit build activity */
  21517. verbose: boolean;
  21518. /** Gets or sets the hosting scene */
  21519. scene: Scene;
  21520. /**
  21521. * Gets the compilation hints emitted at compilation time
  21522. */
  21523. hints: {
  21524. needWorldViewMatrix: boolean;
  21525. needWorldViewProjectionMatrix: boolean;
  21526. needAlphaBlending: boolean;
  21527. needAlphaTesting: boolean;
  21528. };
  21529. /**
  21530. * List of compilation checks
  21531. */
  21532. checks: {
  21533. emitVertex: boolean;
  21534. emitFragment: boolean;
  21535. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21536. };
  21537. /**
  21538. * Is vertex program allowed to be empty?
  21539. */
  21540. allowEmptyVertexProgram: boolean;
  21541. /** Creates a new shared data */
  21542. constructor();
  21543. /**
  21544. * Emits console errors and exceptions if there is a failing check
  21545. */
  21546. emitErrors(): void;
  21547. }
  21548. }
  21549. declare module BABYLON {
  21550. /**
  21551. * Class used to store node based material build state
  21552. */
  21553. export class NodeMaterialBuildState {
  21554. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21555. supportUniformBuffers: boolean;
  21556. /**
  21557. * Gets the list of emitted attributes
  21558. */
  21559. attributes: string[];
  21560. /**
  21561. * Gets the list of emitted uniforms
  21562. */
  21563. uniforms: string[];
  21564. /**
  21565. * Gets the list of emitted constants
  21566. */
  21567. constants: string[];
  21568. /**
  21569. * Gets the list of emitted samplers
  21570. */
  21571. samplers: string[];
  21572. /**
  21573. * Gets the list of emitted functions
  21574. */
  21575. functions: {
  21576. [key: string]: string;
  21577. };
  21578. /**
  21579. * Gets the list of emitted extensions
  21580. */
  21581. extensions: {
  21582. [key: string]: string;
  21583. };
  21584. /**
  21585. * Gets the target of the compilation state
  21586. */
  21587. target: NodeMaterialBlockTargets;
  21588. /**
  21589. * Gets the list of emitted counters
  21590. */
  21591. counters: {
  21592. [key: string]: number;
  21593. };
  21594. /**
  21595. * Shared data between multiple NodeMaterialBuildState instances
  21596. */
  21597. sharedData: NodeMaterialBuildStateSharedData;
  21598. /** @hidden */
  21599. _vertexState: NodeMaterialBuildState;
  21600. /** @hidden */
  21601. _attributeDeclaration: string;
  21602. /** @hidden */
  21603. _uniformDeclaration: string;
  21604. /** @hidden */
  21605. _constantDeclaration: string;
  21606. /** @hidden */
  21607. _samplerDeclaration: string;
  21608. /** @hidden */
  21609. _varyingTransfer: string;
  21610. /** @hidden */
  21611. _injectAtEnd: string;
  21612. private _repeatableContentAnchorIndex;
  21613. /** @hidden */
  21614. _builtCompilationString: string;
  21615. /**
  21616. * Gets the emitted compilation strings
  21617. */
  21618. compilationString: string;
  21619. /**
  21620. * Finalize the compilation strings
  21621. * @param state defines the current compilation state
  21622. */
  21623. finalize(state: NodeMaterialBuildState): void;
  21624. /** @hidden */
  21625. get _repeatableContentAnchor(): string;
  21626. /** @hidden */
  21627. _getFreeVariableName(prefix: string): string;
  21628. /** @hidden */
  21629. _getFreeDefineName(prefix: string): string;
  21630. /** @hidden */
  21631. _excludeVariableName(name: string): void;
  21632. /** @hidden */
  21633. _emit2DSampler(name: string): void;
  21634. /** @hidden */
  21635. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21636. /** @hidden */
  21637. _emitExtension(name: string, extension: string, define?: string): void;
  21638. /** @hidden */
  21639. _emitFunction(name: string, code: string, comments: string): void;
  21640. /** @hidden */
  21641. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21642. replaceStrings?: {
  21643. search: RegExp;
  21644. replace: string;
  21645. }[];
  21646. repeatKey?: string;
  21647. }): string;
  21648. /** @hidden */
  21649. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21650. repeatKey?: string;
  21651. removeAttributes?: boolean;
  21652. removeUniforms?: boolean;
  21653. removeVaryings?: boolean;
  21654. removeIfDef?: boolean;
  21655. replaceStrings?: {
  21656. search: RegExp;
  21657. replace: string;
  21658. }[];
  21659. }, storeKey?: string): void;
  21660. /** @hidden */
  21661. _registerTempVariable(name: string): boolean;
  21662. /** @hidden */
  21663. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21664. /** @hidden */
  21665. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21666. /** @hidden */
  21667. _emitFloat(value: number): string;
  21668. }
  21669. }
  21670. declare module BABYLON {
  21671. /**
  21672. * Helper class used to generate session unique ID
  21673. */
  21674. export class UniqueIdGenerator {
  21675. private static _UniqueIdCounter;
  21676. /**
  21677. * Gets an unique (relatively to the current scene) Id
  21678. */
  21679. static get UniqueId(): number;
  21680. }
  21681. }
  21682. declare module BABYLON {
  21683. /**
  21684. * Defines a block that can be used inside a node based material
  21685. */
  21686. export class NodeMaterialBlock {
  21687. private _buildId;
  21688. private _buildTarget;
  21689. private _target;
  21690. private _isFinalMerger;
  21691. private _isInput;
  21692. private _name;
  21693. protected _isUnique: boolean;
  21694. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21695. inputsAreExclusive: boolean;
  21696. /** @hidden */
  21697. _codeVariableName: string;
  21698. /** @hidden */
  21699. _inputs: NodeMaterialConnectionPoint[];
  21700. /** @hidden */
  21701. _outputs: NodeMaterialConnectionPoint[];
  21702. /** @hidden */
  21703. _preparationId: number;
  21704. /**
  21705. * Gets the name of the block
  21706. */
  21707. get name(): string;
  21708. /**
  21709. * Sets the name of the block. Will check if the name is valid.
  21710. */
  21711. set name(newName: string);
  21712. /**
  21713. * Gets or sets the unique id of the node
  21714. */
  21715. uniqueId: number;
  21716. /**
  21717. * Gets or sets the comments associated with this block
  21718. */
  21719. comments: string;
  21720. /**
  21721. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21722. */
  21723. get isUnique(): boolean;
  21724. /**
  21725. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21726. */
  21727. get isFinalMerger(): boolean;
  21728. /**
  21729. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21730. */
  21731. get isInput(): boolean;
  21732. /**
  21733. * Gets or sets the build Id
  21734. */
  21735. get buildId(): number;
  21736. set buildId(value: number);
  21737. /**
  21738. * Gets or sets the target of the block
  21739. */
  21740. get target(): NodeMaterialBlockTargets;
  21741. set target(value: NodeMaterialBlockTargets);
  21742. /**
  21743. * Gets the list of input points
  21744. */
  21745. get inputs(): NodeMaterialConnectionPoint[];
  21746. /** Gets the list of output points */
  21747. get outputs(): NodeMaterialConnectionPoint[];
  21748. /**
  21749. * Find an input by its name
  21750. * @param name defines the name of the input to look for
  21751. * @returns the input or null if not found
  21752. */
  21753. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21754. /**
  21755. * Find an output by its name
  21756. * @param name defines the name of the outputto look for
  21757. * @returns the output or null if not found
  21758. */
  21759. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21760. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21761. visibleInInspector: boolean;
  21762. /**
  21763. * Creates a new NodeMaterialBlock
  21764. * @param name defines the block name
  21765. * @param target defines the target of that block (Vertex by default)
  21766. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21767. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21768. */
  21769. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21770. /**
  21771. * Initialize the block and prepare the context for build
  21772. * @param state defines the state that will be used for the build
  21773. */
  21774. initialize(state: NodeMaterialBuildState): void;
  21775. /**
  21776. * Bind data to effect. Will only be called for blocks with isBindable === true
  21777. * @param effect defines the effect to bind data to
  21778. * @param nodeMaterial defines the hosting NodeMaterial
  21779. * @param mesh defines the mesh that will be rendered
  21780. * @param subMesh defines the submesh that will be rendered
  21781. */
  21782. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21783. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21784. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21785. protected _writeFloat(value: number): string;
  21786. /**
  21787. * Gets the current class name e.g. "NodeMaterialBlock"
  21788. * @returns the class name
  21789. */
  21790. getClassName(): string;
  21791. /**
  21792. * Register a new input. Must be called inside a block constructor
  21793. * @param name defines the connection point name
  21794. * @param type defines the connection point type
  21795. * @param isOptional defines a boolean indicating that this input can be omitted
  21796. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21797. * @param point an already created connection point. If not provided, create a new one
  21798. * @returns the current block
  21799. */
  21800. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21801. /**
  21802. * Register a new output. Must be called inside a block constructor
  21803. * @param name defines the connection point name
  21804. * @param type defines the connection point type
  21805. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21806. * @param point an already created connection point. If not provided, create a new one
  21807. * @returns the current block
  21808. */
  21809. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21810. /**
  21811. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21812. * @param forOutput defines an optional connection point to check compatibility with
  21813. * @returns the first available input or null
  21814. */
  21815. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21816. /**
  21817. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21818. * @param forBlock defines an optional block to check compatibility with
  21819. * @returns the first available input or null
  21820. */
  21821. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21822. /**
  21823. * Gets the sibling of the given output
  21824. * @param current defines the current output
  21825. * @returns the next output in the list or null
  21826. */
  21827. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21828. /**
  21829. * Connect current block with another block
  21830. * @param other defines the block to connect with
  21831. * @param options define the various options to help pick the right connections
  21832. * @returns the current block
  21833. */
  21834. connectTo(other: NodeMaterialBlock, options?: {
  21835. input?: string;
  21836. output?: string;
  21837. outputSwizzle?: string;
  21838. }): this | undefined;
  21839. protected _buildBlock(state: NodeMaterialBuildState): void;
  21840. /**
  21841. * Add uniforms, samplers and uniform buffers at compilation time
  21842. * @param state defines the state to update
  21843. * @param nodeMaterial defines the node material requesting the update
  21844. * @param defines defines the material defines to update
  21845. * @param uniformBuffers defines the list of uniform buffer names
  21846. */
  21847. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21848. /**
  21849. * Add potential fallbacks if shader compilation fails
  21850. * @param mesh defines the mesh to be rendered
  21851. * @param fallbacks defines the current prioritized list of fallbacks
  21852. */
  21853. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21854. /**
  21855. * Initialize defines for shader compilation
  21856. * @param mesh defines the mesh to be rendered
  21857. * @param nodeMaterial defines the node material requesting the update
  21858. * @param defines defines the material defines to update
  21859. * @param useInstances specifies that instances should be used
  21860. */
  21861. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21862. /**
  21863. * Update defines for shader compilation
  21864. * @param mesh defines the mesh to be rendered
  21865. * @param nodeMaterial defines the node material requesting the update
  21866. * @param defines defines the material defines to update
  21867. * @param useInstances specifies that instances should be used
  21868. * @param subMesh defines which submesh to render
  21869. */
  21870. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21871. /**
  21872. * Lets the block try to connect some inputs automatically
  21873. * @param material defines the hosting NodeMaterial
  21874. */
  21875. autoConfigure(material: NodeMaterial): void;
  21876. /**
  21877. * Function called when a block is declared as repeatable content generator
  21878. * @param vertexShaderState defines the current compilation state for the vertex shader
  21879. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21880. * @param mesh defines the mesh to be rendered
  21881. * @param defines defines the material defines to update
  21882. */
  21883. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21884. /**
  21885. * Checks if the block is ready
  21886. * @param mesh defines the mesh to be rendered
  21887. * @param nodeMaterial defines the node material requesting the update
  21888. * @param defines defines the material defines to update
  21889. * @param useInstances specifies that instances should be used
  21890. * @returns true if the block is ready
  21891. */
  21892. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21893. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21894. private _processBuild;
  21895. /**
  21896. * Validates the new name for the block node.
  21897. * @param newName the new name to be given to the node.
  21898. * @returns false if the name is a reserve word, else true.
  21899. */
  21900. validateBlockName(newName: string): boolean;
  21901. /**
  21902. * Compile the current node and generate the shader code
  21903. * @param state defines the current compilation state (uniforms, samplers, current string)
  21904. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21905. * @returns true if already built
  21906. */
  21907. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21908. protected _inputRename(name: string): string;
  21909. protected _outputRename(name: string): string;
  21910. protected _dumpPropertiesCode(): string;
  21911. /** @hidden */
  21912. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21913. /** @hidden */
  21914. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21915. /**
  21916. * Clone the current block to a new identical block
  21917. * @param scene defines the hosting scene
  21918. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21919. * @returns a copy of the current block
  21920. */
  21921. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21922. /**
  21923. * Serializes this block in a JSON representation
  21924. * @returns the serialized block object
  21925. */
  21926. serialize(): any;
  21927. /** @hidden */
  21928. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21929. private _deserializePortDisplayNamesAndExposedOnFrame;
  21930. /**
  21931. * Release resources
  21932. */
  21933. dispose(): void;
  21934. }
  21935. }
  21936. declare module BABYLON {
  21937. /**
  21938. * Base class of materials working in push mode in babylon JS
  21939. * @hidden
  21940. */
  21941. export class PushMaterial extends Material {
  21942. protected _activeEffect: Effect;
  21943. protected _normalMatrix: Matrix;
  21944. constructor(name: string, scene: Scene);
  21945. getEffect(): Effect;
  21946. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21947. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21948. /**
  21949. * Binds the given world matrix to the active effect
  21950. *
  21951. * @param world the matrix to bind
  21952. */
  21953. bindOnlyWorldMatrix(world: Matrix): void;
  21954. /**
  21955. * Binds the given normal matrix to the active effect
  21956. *
  21957. * @param normalMatrix the matrix to bind
  21958. */
  21959. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21960. bind(world: Matrix, mesh?: Mesh): void;
  21961. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21962. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21963. }
  21964. }
  21965. declare module BABYLON {
  21966. /**
  21967. * Root class for all node material optimizers
  21968. */
  21969. export class NodeMaterialOptimizer {
  21970. /**
  21971. * Function used to optimize a NodeMaterial graph
  21972. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21973. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21974. */
  21975. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21976. }
  21977. }
  21978. declare module BABYLON {
  21979. /**
  21980. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21981. */
  21982. export class TransformBlock extends NodeMaterialBlock {
  21983. /**
  21984. * Defines the value to use to complement W value to transform it to a Vector4
  21985. */
  21986. complementW: number;
  21987. /**
  21988. * Defines the value to use to complement z value to transform it to a Vector4
  21989. */
  21990. complementZ: number;
  21991. /**
  21992. * Creates a new TransformBlock
  21993. * @param name defines the block name
  21994. */
  21995. constructor(name: string);
  21996. /**
  21997. * Gets the current class name
  21998. * @returns the class name
  21999. */
  22000. getClassName(): string;
  22001. /**
  22002. * Gets the vector input
  22003. */
  22004. get vector(): NodeMaterialConnectionPoint;
  22005. /**
  22006. * Gets the output component
  22007. */
  22008. get output(): NodeMaterialConnectionPoint;
  22009. /**
  22010. * Gets the xyz output component
  22011. */
  22012. get xyz(): NodeMaterialConnectionPoint;
  22013. /**
  22014. * Gets the matrix transform input
  22015. */
  22016. get transform(): NodeMaterialConnectionPoint;
  22017. protected _buildBlock(state: NodeMaterialBuildState): this;
  22018. /**
  22019. * Update defines for shader compilation
  22020. * @param mesh defines the mesh to be rendered
  22021. * @param nodeMaterial defines the node material requesting the update
  22022. * @param defines defines the material defines to update
  22023. * @param useInstances specifies that instances should be used
  22024. * @param subMesh defines which submesh to render
  22025. */
  22026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22027. serialize(): any;
  22028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22029. protected _dumpPropertiesCode(): string;
  22030. }
  22031. }
  22032. declare module BABYLON {
  22033. /**
  22034. * Block used to output the vertex position
  22035. */
  22036. export class VertexOutputBlock extends NodeMaterialBlock {
  22037. /**
  22038. * Creates a new VertexOutputBlock
  22039. * @param name defines the block name
  22040. */
  22041. constructor(name: string);
  22042. /**
  22043. * Gets the current class name
  22044. * @returns the class name
  22045. */
  22046. getClassName(): string;
  22047. /**
  22048. * Gets the vector input component
  22049. */
  22050. get vector(): NodeMaterialConnectionPoint;
  22051. protected _buildBlock(state: NodeMaterialBuildState): this;
  22052. }
  22053. }
  22054. declare module BABYLON {
  22055. /**
  22056. * Block used to output the final color
  22057. */
  22058. export class FragmentOutputBlock extends NodeMaterialBlock {
  22059. /**
  22060. * Create a new FragmentOutputBlock
  22061. * @param name defines the block name
  22062. */
  22063. constructor(name: string);
  22064. /**
  22065. * Gets the current class name
  22066. * @returns the class name
  22067. */
  22068. getClassName(): string;
  22069. /**
  22070. * Gets the rgba input component
  22071. */
  22072. get rgba(): NodeMaterialConnectionPoint;
  22073. /**
  22074. * Gets the rgb input component
  22075. */
  22076. get rgb(): NodeMaterialConnectionPoint;
  22077. /**
  22078. * Gets the a input component
  22079. */
  22080. get a(): NodeMaterialConnectionPoint;
  22081. protected _buildBlock(state: NodeMaterialBuildState): this;
  22082. }
  22083. }
  22084. declare module BABYLON {
  22085. /**
  22086. * Block used for the particle ramp gradient section
  22087. */
  22088. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22089. /**
  22090. * Create a new ParticleRampGradientBlock
  22091. * @param name defines the block name
  22092. */
  22093. constructor(name: string);
  22094. /**
  22095. * Gets the current class name
  22096. * @returns the class name
  22097. */
  22098. getClassName(): string;
  22099. /**
  22100. * Gets the color input component
  22101. */
  22102. get color(): NodeMaterialConnectionPoint;
  22103. /**
  22104. * Gets the rampColor output component
  22105. */
  22106. get rampColor(): NodeMaterialConnectionPoint;
  22107. /**
  22108. * Initialize the block and prepare the context for build
  22109. * @param state defines the state that will be used for the build
  22110. */
  22111. initialize(state: NodeMaterialBuildState): void;
  22112. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22113. }
  22114. }
  22115. declare module BABYLON {
  22116. /**
  22117. * Block used for the particle blend multiply section
  22118. */
  22119. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22120. /**
  22121. * Create a new ParticleBlendMultiplyBlock
  22122. * @param name defines the block name
  22123. */
  22124. constructor(name: string);
  22125. /**
  22126. * Gets the current class name
  22127. * @returns the class name
  22128. */
  22129. getClassName(): string;
  22130. /**
  22131. * Gets the color input component
  22132. */
  22133. get color(): NodeMaterialConnectionPoint;
  22134. /**
  22135. * Gets the alphaTexture input component
  22136. */
  22137. get alphaTexture(): NodeMaterialConnectionPoint;
  22138. /**
  22139. * Gets the alphaColor input component
  22140. */
  22141. get alphaColor(): NodeMaterialConnectionPoint;
  22142. /**
  22143. * Gets the blendColor output component
  22144. */
  22145. get blendColor(): NodeMaterialConnectionPoint;
  22146. /**
  22147. * Initialize the block and prepare the context for build
  22148. * @param state defines the state that will be used for the build
  22149. */
  22150. initialize(state: NodeMaterialBuildState): void;
  22151. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22152. }
  22153. }
  22154. declare module BABYLON {
  22155. /**
  22156. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22157. */
  22158. export class VectorMergerBlock extends NodeMaterialBlock {
  22159. /**
  22160. * Create a new VectorMergerBlock
  22161. * @param name defines the block name
  22162. */
  22163. constructor(name: string);
  22164. /**
  22165. * Gets the current class name
  22166. * @returns the class name
  22167. */
  22168. getClassName(): string;
  22169. /**
  22170. * Gets the xyz component (input)
  22171. */
  22172. get xyzIn(): NodeMaterialConnectionPoint;
  22173. /**
  22174. * Gets the xy component (input)
  22175. */
  22176. get xyIn(): NodeMaterialConnectionPoint;
  22177. /**
  22178. * Gets the x component (input)
  22179. */
  22180. get x(): NodeMaterialConnectionPoint;
  22181. /**
  22182. * Gets the y component (input)
  22183. */
  22184. get y(): NodeMaterialConnectionPoint;
  22185. /**
  22186. * Gets the z component (input)
  22187. */
  22188. get z(): NodeMaterialConnectionPoint;
  22189. /**
  22190. * Gets the w component (input)
  22191. */
  22192. get w(): NodeMaterialConnectionPoint;
  22193. /**
  22194. * Gets the xyzw component (output)
  22195. */
  22196. get xyzw(): NodeMaterialConnectionPoint;
  22197. /**
  22198. * Gets the xyz component (output)
  22199. */
  22200. get xyzOut(): NodeMaterialConnectionPoint;
  22201. /**
  22202. * Gets the xy component (output)
  22203. */
  22204. get xyOut(): NodeMaterialConnectionPoint;
  22205. /**
  22206. * Gets the xy component (output)
  22207. * @deprecated Please use xyOut instead.
  22208. */
  22209. get xy(): NodeMaterialConnectionPoint;
  22210. /**
  22211. * Gets the xyz component (output)
  22212. * @deprecated Please use xyzOut instead.
  22213. */
  22214. get xyz(): NodeMaterialConnectionPoint;
  22215. protected _buildBlock(state: NodeMaterialBuildState): this;
  22216. }
  22217. }
  22218. declare module BABYLON {
  22219. /**
  22220. * Block used to remap a float from a range to a new one
  22221. */
  22222. export class RemapBlock extends NodeMaterialBlock {
  22223. /**
  22224. * Gets or sets the source range
  22225. */
  22226. sourceRange: Vector2;
  22227. /**
  22228. * Gets or sets the target range
  22229. */
  22230. targetRange: Vector2;
  22231. /**
  22232. * Creates a new RemapBlock
  22233. * @param name defines the block name
  22234. */
  22235. constructor(name: string);
  22236. /**
  22237. * Gets the current class name
  22238. * @returns the class name
  22239. */
  22240. getClassName(): string;
  22241. /**
  22242. * Gets the input component
  22243. */
  22244. get input(): NodeMaterialConnectionPoint;
  22245. /**
  22246. * Gets the source min input component
  22247. */
  22248. get sourceMin(): NodeMaterialConnectionPoint;
  22249. /**
  22250. * Gets the source max input component
  22251. */
  22252. get sourceMax(): NodeMaterialConnectionPoint;
  22253. /**
  22254. * Gets the target min input component
  22255. */
  22256. get targetMin(): NodeMaterialConnectionPoint;
  22257. /**
  22258. * Gets the target max input component
  22259. */
  22260. get targetMax(): NodeMaterialConnectionPoint;
  22261. /**
  22262. * Gets the output component
  22263. */
  22264. get output(): NodeMaterialConnectionPoint;
  22265. protected _buildBlock(state: NodeMaterialBuildState): this;
  22266. protected _dumpPropertiesCode(): string;
  22267. serialize(): any;
  22268. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22269. }
  22270. }
  22271. declare module BABYLON {
  22272. /**
  22273. * Block used to multiply 2 values
  22274. */
  22275. export class MultiplyBlock extends NodeMaterialBlock {
  22276. /**
  22277. * Creates a new MultiplyBlock
  22278. * @param name defines the block name
  22279. */
  22280. constructor(name: string);
  22281. /**
  22282. * Gets the current class name
  22283. * @returns the class name
  22284. */
  22285. getClassName(): string;
  22286. /**
  22287. * Gets the left operand input component
  22288. */
  22289. get left(): NodeMaterialConnectionPoint;
  22290. /**
  22291. * Gets the right operand input component
  22292. */
  22293. get right(): NodeMaterialConnectionPoint;
  22294. /**
  22295. * Gets the output component
  22296. */
  22297. get output(): NodeMaterialConnectionPoint;
  22298. protected _buildBlock(state: NodeMaterialBuildState): this;
  22299. }
  22300. }
  22301. declare module BABYLON {
  22302. /**
  22303. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22304. */
  22305. export class ColorSplitterBlock extends NodeMaterialBlock {
  22306. /**
  22307. * Create a new ColorSplitterBlock
  22308. * @param name defines the block name
  22309. */
  22310. constructor(name: string);
  22311. /**
  22312. * Gets the current class name
  22313. * @returns the class name
  22314. */
  22315. getClassName(): string;
  22316. /**
  22317. * Gets the rgba component (input)
  22318. */
  22319. get rgba(): NodeMaterialConnectionPoint;
  22320. /**
  22321. * Gets the rgb component (input)
  22322. */
  22323. get rgbIn(): NodeMaterialConnectionPoint;
  22324. /**
  22325. * Gets the rgb component (output)
  22326. */
  22327. get rgbOut(): NodeMaterialConnectionPoint;
  22328. /**
  22329. * Gets the r component (output)
  22330. */
  22331. get r(): NodeMaterialConnectionPoint;
  22332. /**
  22333. * Gets the g component (output)
  22334. */
  22335. get g(): NodeMaterialConnectionPoint;
  22336. /**
  22337. * Gets the b component (output)
  22338. */
  22339. get b(): NodeMaterialConnectionPoint;
  22340. /**
  22341. * Gets the a component (output)
  22342. */
  22343. get a(): NodeMaterialConnectionPoint;
  22344. protected _inputRename(name: string): string;
  22345. protected _outputRename(name: string): string;
  22346. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22347. }
  22348. }
  22349. declare module BABYLON {
  22350. /**
  22351. * Operations supported by the Trigonometry block
  22352. */
  22353. export enum TrigonometryBlockOperations {
  22354. /** Cos */
  22355. Cos = 0,
  22356. /** Sin */
  22357. Sin = 1,
  22358. /** Abs */
  22359. Abs = 2,
  22360. /** Exp */
  22361. Exp = 3,
  22362. /** Exp2 */
  22363. Exp2 = 4,
  22364. /** Round */
  22365. Round = 5,
  22366. /** Floor */
  22367. Floor = 6,
  22368. /** Ceiling */
  22369. Ceiling = 7,
  22370. /** Square root */
  22371. Sqrt = 8,
  22372. /** Log */
  22373. Log = 9,
  22374. /** Tangent */
  22375. Tan = 10,
  22376. /** Arc tangent */
  22377. ArcTan = 11,
  22378. /** Arc cosinus */
  22379. ArcCos = 12,
  22380. /** Arc sinus */
  22381. ArcSin = 13,
  22382. /** Fraction */
  22383. Fract = 14,
  22384. /** Sign */
  22385. Sign = 15,
  22386. /** To radians (from degrees) */
  22387. Radians = 16,
  22388. /** To degrees (from radians) */
  22389. Degrees = 17
  22390. }
  22391. /**
  22392. * Block used to apply trigonometry operation to floats
  22393. */
  22394. export class TrigonometryBlock extends NodeMaterialBlock {
  22395. /**
  22396. * Gets or sets the operation applied by the block
  22397. */
  22398. operation: TrigonometryBlockOperations;
  22399. /**
  22400. * Creates a new TrigonometryBlock
  22401. * @param name defines the block name
  22402. */
  22403. constructor(name: string);
  22404. /**
  22405. * Gets the current class name
  22406. * @returns the class name
  22407. */
  22408. getClassName(): string;
  22409. /**
  22410. * Gets the input component
  22411. */
  22412. get input(): NodeMaterialConnectionPoint;
  22413. /**
  22414. * Gets the output component
  22415. */
  22416. get output(): NodeMaterialConnectionPoint;
  22417. protected _buildBlock(state: NodeMaterialBuildState): this;
  22418. serialize(): any;
  22419. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22420. protected _dumpPropertiesCode(): string;
  22421. }
  22422. }
  22423. declare module BABYLON {
  22424. /**
  22425. * Interface used to configure the node material editor
  22426. */
  22427. export interface INodeMaterialEditorOptions {
  22428. /** Define the URl to load node editor script */
  22429. editorURL?: string;
  22430. }
  22431. /** @hidden */
  22432. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22433. NORMAL: boolean;
  22434. TANGENT: boolean;
  22435. UV1: boolean;
  22436. /** BONES */
  22437. NUM_BONE_INFLUENCERS: number;
  22438. BonesPerMesh: number;
  22439. BONETEXTURE: boolean;
  22440. /** MORPH TARGETS */
  22441. MORPHTARGETS: boolean;
  22442. MORPHTARGETS_NORMAL: boolean;
  22443. MORPHTARGETS_TANGENT: boolean;
  22444. MORPHTARGETS_UV: boolean;
  22445. NUM_MORPH_INFLUENCERS: number;
  22446. /** IMAGE PROCESSING */
  22447. IMAGEPROCESSING: boolean;
  22448. VIGNETTE: boolean;
  22449. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22450. VIGNETTEBLENDMODEOPAQUE: boolean;
  22451. TONEMAPPING: boolean;
  22452. TONEMAPPING_ACES: boolean;
  22453. CONTRAST: boolean;
  22454. EXPOSURE: boolean;
  22455. COLORCURVES: boolean;
  22456. COLORGRADING: boolean;
  22457. COLORGRADING3D: boolean;
  22458. SAMPLER3DGREENDEPTH: boolean;
  22459. SAMPLER3DBGRMAP: boolean;
  22460. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22461. /** MISC. */
  22462. BUMPDIRECTUV: number;
  22463. constructor();
  22464. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22465. }
  22466. /**
  22467. * Class used to configure NodeMaterial
  22468. */
  22469. export interface INodeMaterialOptions {
  22470. /**
  22471. * Defines if blocks should emit comments
  22472. */
  22473. emitComments: boolean;
  22474. }
  22475. /**
  22476. * Class used to create a node based material built by assembling shader blocks
  22477. */
  22478. export class NodeMaterial extends PushMaterial {
  22479. private static _BuildIdGenerator;
  22480. private _options;
  22481. private _vertexCompilationState;
  22482. private _fragmentCompilationState;
  22483. private _sharedData;
  22484. private _buildId;
  22485. private _buildWasSuccessful;
  22486. private _cachedWorldViewMatrix;
  22487. private _cachedWorldViewProjectionMatrix;
  22488. private _optimizers;
  22489. private _animationFrame;
  22490. /** Define the Url to load node editor script */
  22491. static EditorURL: string;
  22492. /** Define the Url to load snippets */
  22493. static SnippetUrl: string;
  22494. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22495. static IgnoreTexturesAtLoadTime: boolean;
  22496. private BJSNODEMATERIALEDITOR;
  22497. /** Get the inspector from bundle or global */
  22498. private _getGlobalNodeMaterialEditor;
  22499. /**
  22500. * Snippet ID if the material was created from the snippet server
  22501. */
  22502. snippetId: string;
  22503. /**
  22504. * Gets or sets data used by visual editor
  22505. * @see https://nme.babylonjs.com
  22506. */
  22507. editorData: any;
  22508. /**
  22509. * 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)
  22510. */
  22511. ignoreAlpha: boolean;
  22512. /**
  22513. * Defines the maximum number of lights that can be used in the material
  22514. */
  22515. maxSimultaneousLights: number;
  22516. /**
  22517. * Observable raised when the material is built
  22518. */
  22519. onBuildObservable: Observable<NodeMaterial>;
  22520. /**
  22521. * Gets or sets the root nodes of the material vertex shader
  22522. */
  22523. _vertexOutputNodes: NodeMaterialBlock[];
  22524. /**
  22525. * Gets or sets the root nodes of the material fragment (pixel) shader
  22526. */
  22527. _fragmentOutputNodes: NodeMaterialBlock[];
  22528. /** Gets or sets options to control the node material overall behavior */
  22529. get options(): INodeMaterialOptions;
  22530. set options(options: INodeMaterialOptions);
  22531. /**
  22532. * Default configuration related to image processing available in the standard Material.
  22533. */
  22534. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22535. /**
  22536. * Gets the image processing configuration used either in this material.
  22537. */
  22538. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22539. /**
  22540. * Sets the Default image processing configuration used either in the this material.
  22541. *
  22542. * If sets to null, the scene one is in use.
  22543. */
  22544. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22545. /**
  22546. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22547. */
  22548. attachedBlocks: NodeMaterialBlock[];
  22549. /**
  22550. * Specifies the mode of the node material
  22551. * @hidden
  22552. */
  22553. _mode: NodeMaterialModes;
  22554. /**
  22555. * Gets the mode property
  22556. */
  22557. get mode(): NodeMaterialModes;
  22558. /**
  22559. * Create a new node based material
  22560. * @param name defines the material name
  22561. * @param scene defines the hosting scene
  22562. * @param options defines creation option
  22563. */
  22564. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22565. /**
  22566. * Gets the current class name of the material e.g. "NodeMaterial"
  22567. * @returns the class name
  22568. */
  22569. getClassName(): string;
  22570. /**
  22571. * Keep track of the image processing observer to allow dispose and replace.
  22572. */
  22573. private _imageProcessingObserver;
  22574. /**
  22575. * Attaches a new image processing configuration to the Standard Material.
  22576. * @param configuration
  22577. */
  22578. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22579. /**
  22580. * Get a block by its name
  22581. * @param name defines the name of the block to retrieve
  22582. * @returns the required block or null if not found
  22583. */
  22584. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22585. /**
  22586. * Get a block by its name
  22587. * @param predicate defines the predicate used to find the good candidate
  22588. * @returns the required block or null if not found
  22589. */
  22590. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22591. /**
  22592. * Get an input block by its name
  22593. * @param predicate defines the predicate used to find the good candidate
  22594. * @returns the required input block or null if not found
  22595. */
  22596. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22597. /**
  22598. * Gets the list of input blocks attached to this material
  22599. * @returns an array of InputBlocks
  22600. */
  22601. getInputBlocks(): InputBlock[];
  22602. /**
  22603. * Adds a new optimizer to the list of optimizers
  22604. * @param optimizer defines the optimizers to add
  22605. * @returns the current material
  22606. */
  22607. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22608. /**
  22609. * Remove an optimizer from the list of optimizers
  22610. * @param optimizer defines the optimizers to remove
  22611. * @returns the current material
  22612. */
  22613. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22614. /**
  22615. * Add a new block to the list of output nodes
  22616. * @param node defines the node to add
  22617. * @returns the current material
  22618. */
  22619. addOutputNode(node: NodeMaterialBlock): this;
  22620. /**
  22621. * Remove a block from the list of root nodes
  22622. * @param node defines the node to remove
  22623. * @returns the current material
  22624. */
  22625. removeOutputNode(node: NodeMaterialBlock): this;
  22626. private _addVertexOutputNode;
  22627. private _removeVertexOutputNode;
  22628. private _addFragmentOutputNode;
  22629. private _removeFragmentOutputNode;
  22630. /**
  22631. * Specifies if the material will require alpha blending
  22632. * @returns a boolean specifying if alpha blending is needed
  22633. */
  22634. needAlphaBlending(): boolean;
  22635. /**
  22636. * Specifies if this material should be rendered in alpha test mode
  22637. * @returns a boolean specifying if an alpha test is needed.
  22638. */
  22639. needAlphaTesting(): boolean;
  22640. private _initializeBlock;
  22641. private _resetDualBlocks;
  22642. /**
  22643. * Remove a block from the current node material
  22644. * @param block defines the block to remove
  22645. */
  22646. removeBlock(block: NodeMaterialBlock): void;
  22647. /**
  22648. * Build the material and generates the inner effect
  22649. * @param verbose defines if the build should log activity
  22650. */
  22651. build(verbose?: boolean): void;
  22652. /**
  22653. * Runs an otpimization phase to try to improve the shader code
  22654. */
  22655. optimize(): void;
  22656. private _prepareDefinesForAttributes;
  22657. /**
  22658. * Create a post process from the material
  22659. * @param camera The camera to apply the render pass to.
  22660. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22662. * @param engine The engine which the post process will be applied. (default: current engine)
  22663. * @param reusable If the post process can be reused on the same frame. (default: false)
  22664. * @param textureType Type of textures used when performing the post process. (default: 0)
  22665. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22666. * @returns the post process created
  22667. */
  22668. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22669. /**
  22670. * Create the post process effect from the material
  22671. * @param postProcess The post process to create the effect for
  22672. */
  22673. createEffectForPostProcess(postProcess: PostProcess): void;
  22674. private _createEffectForPostProcess;
  22675. /**
  22676. * Create a new procedural texture based on this node material
  22677. * @param size defines the size of the texture
  22678. * @param scene defines the hosting scene
  22679. * @returns the new procedural texture attached to this node material
  22680. */
  22681. createProceduralTexture(size: number | {
  22682. width: number;
  22683. height: number;
  22684. layers?: number;
  22685. }, scene: Scene): Nullable<ProceduralTexture>;
  22686. private _createEffectForParticles;
  22687. private _checkInternals;
  22688. /**
  22689. * Create the effect to be used as the custom effect for a particle system
  22690. * @param particleSystem Particle system to create the effect for
  22691. * @param onCompiled defines a function to call when the effect creation is successful
  22692. * @param onError defines a function to call when the effect creation has failed
  22693. */
  22694. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22695. private _processDefines;
  22696. /**
  22697. * Get if the submesh is ready to be used and all its information available.
  22698. * Child classes can use it to update shaders
  22699. * @param mesh defines the mesh to check
  22700. * @param subMesh defines which submesh to check
  22701. * @param useInstances specifies that instances should be used
  22702. * @returns a boolean indicating that the submesh is ready or not
  22703. */
  22704. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22705. /**
  22706. * Get a string representing the shaders built by the current node graph
  22707. */
  22708. get compiledShaders(): string;
  22709. /**
  22710. * Binds the world matrix to the material
  22711. * @param world defines the world transformation matrix
  22712. */
  22713. bindOnlyWorldMatrix(world: Matrix): void;
  22714. /**
  22715. * Binds the submesh to this material by preparing the effect and shader to draw
  22716. * @param world defines the world transformation matrix
  22717. * @param mesh defines the mesh containing the submesh
  22718. * @param subMesh defines the submesh to bind the material to
  22719. */
  22720. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22721. /**
  22722. * Gets the active textures from the material
  22723. * @returns an array of textures
  22724. */
  22725. getActiveTextures(): BaseTexture[];
  22726. /**
  22727. * Gets the list of texture blocks
  22728. * @returns an array of texture blocks
  22729. */
  22730. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22731. /**
  22732. * Specifies if the material uses a texture
  22733. * @param texture defines the texture to check against the material
  22734. * @returns a boolean specifying if the material uses the texture
  22735. */
  22736. hasTexture(texture: BaseTexture): boolean;
  22737. /**
  22738. * Disposes the material
  22739. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22740. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22741. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22742. */
  22743. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22744. /** Creates the node editor window. */
  22745. private _createNodeEditor;
  22746. /**
  22747. * Launch the node material editor
  22748. * @param config Define the configuration of the editor
  22749. * @return a promise fulfilled when the node editor is visible
  22750. */
  22751. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22752. /**
  22753. * Clear the current material
  22754. */
  22755. clear(): void;
  22756. /**
  22757. * Clear the current material and set it to a default state
  22758. */
  22759. setToDefault(): void;
  22760. /**
  22761. * Clear the current material and set it to a default state for post process
  22762. */
  22763. setToDefaultPostProcess(): void;
  22764. /**
  22765. * Clear the current material and set it to a default state for procedural texture
  22766. */
  22767. setToDefaultProceduralTexture(): void;
  22768. /**
  22769. * Clear the current material and set it to a default state for particle
  22770. */
  22771. setToDefaultParticle(): void;
  22772. /**
  22773. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22774. * @param url defines the url to load from
  22775. * @returns a promise that will fullfil when the material is fully loaded
  22776. */
  22777. loadAsync(url: string): Promise<void>;
  22778. private _gatherBlocks;
  22779. /**
  22780. * Generate a string containing the code declaration required to create an equivalent of this material
  22781. * @returns a string
  22782. */
  22783. generateCode(): string;
  22784. /**
  22785. * Serializes this material in a JSON representation
  22786. * @returns the serialized material object
  22787. */
  22788. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22789. private _restoreConnections;
  22790. /**
  22791. * Clear the current graph and load a new one from a serialization object
  22792. * @param source defines the JSON representation of the material
  22793. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22794. * @param merge defines whether or not the source must be merged or replace the current content
  22795. */
  22796. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22797. /**
  22798. * Makes a duplicate of the current material.
  22799. * @param name - name to use for the new material.
  22800. */
  22801. clone(name: string): NodeMaterial;
  22802. /**
  22803. * Creates a node material from parsed material data
  22804. * @param source defines the JSON representation of the material
  22805. * @param scene defines the hosting scene
  22806. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22807. * @returns a new node material
  22808. */
  22809. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22810. /**
  22811. * Creates a node material from a snippet saved in a remote file
  22812. * @param name defines the name of the material to create
  22813. * @param url defines the url to load from
  22814. * @param scene defines the hosting scene
  22815. * @returns a promise that will resolve to the new node material
  22816. */
  22817. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22818. /**
  22819. * Creates a node material from a snippet saved by the node material editor
  22820. * @param snippetId defines the snippet to load
  22821. * @param scene defines the hosting scene
  22822. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22823. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22824. * @returns a promise that will resolve to the new node material
  22825. */
  22826. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22827. /**
  22828. * Creates a new node material set to default basic configuration
  22829. * @param name defines the name of the material
  22830. * @param scene defines the hosting scene
  22831. * @returns a new NodeMaterial
  22832. */
  22833. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22834. }
  22835. }
  22836. declare module BABYLON {
  22837. interface ThinEngine {
  22838. /**
  22839. * Unbind a list of render target textures from the webGL context
  22840. * This is used only when drawBuffer extension or webGL2 are active
  22841. * @param textures defines the render target textures to unbind
  22842. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  22843. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  22844. */
  22845. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  22846. /**
  22847. * Create a multi render target texture
  22848. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  22849. * @param size defines the size of the texture
  22850. * @param options defines the creation options
  22851. * @returns the cube texture as an InternalTexture
  22852. */
  22853. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  22854. /**
  22855. * Update the sample count for a given multiple render target texture
  22856. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  22857. * @param textures defines the textures to update
  22858. * @param samples defines the sample count to set
  22859. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  22860. */
  22861. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  22862. /**
  22863. * Select a subsets of attachments to draw to.
  22864. * @param attachments gl attachments
  22865. */
  22866. bindAttachments(attachments: number[]): void;
  22867. /**
  22868. * Creates a layout object to draw/clear on specific textures in a MRT
  22869. * @param textureStatus textureStatus[i] indicates if the i-th is active
  22870. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  22871. */
  22872. buildTextureLayout(textureStatus: boolean[]): number[];
  22873. /**
  22874. * Restores the webgl state to only draw on the main color attachment
  22875. */
  22876. restoreSingleAttachment(): void;
  22877. }
  22878. }
  22879. declare module BABYLON {
  22880. /**
  22881. * Creation options of the multi render target texture.
  22882. */
  22883. export interface IMultiRenderTargetOptions {
  22884. /**
  22885. * Define if the texture needs to create mip maps after render.
  22886. */
  22887. generateMipMaps?: boolean;
  22888. /**
  22889. * Define the types of all the draw buffers we want to create
  22890. */
  22891. types?: number[];
  22892. /**
  22893. * Define the sampling modes of all the draw buffers we want to create
  22894. */
  22895. samplingModes?: number[];
  22896. /**
  22897. * Define if a depth buffer is required
  22898. */
  22899. generateDepthBuffer?: boolean;
  22900. /**
  22901. * Define if a stencil buffer is required
  22902. */
  22903. generateStencilBuffer?: boolean;
  22904. /**
  22905. * Define if a depth texture is required instead of a depth buffer
  22906. */
  22907. generateDepthTexture?: boolean;
  22908. /**
  22909. * Define the number of desired draw buffers
  22910. */
  22911. textureCount?: number;
  22912. /**
  22913. * Define if aspect ratio should be adapted to the texture or stay the scene one
  22914. */
  22915. doNotChangeAspectRatio?: boolean;
  22916. /**
  22917. * Define the default type of the buffers we are creating
  22918. */
  22919. defaultType?: number;
  22920. }
  22921. /**
  22922. * A multi render target, like a render target provides the ability to render to a texture.
  22923. * Unlike the render target, it can render to several draw buffers in one draw.
  22924. * This is specially interesting in deferred rendering or for any effects requiring more than
  22925. * just one color from a single pass.
  22926. */
  22927. export class MultiRenderTarget extends RenderTargetTexture {
  22928. private _internalTextures;
  22929. private _textures;
  22930. private _multiRenderTargetOptions;
  22931. private _count;
  22932. /**
  22933. * Get if draw buffers are currently supported by the used hardware and browser.
  22934. */
  22935. get isSupported(): boolean;
  22936. /**
  22937. * Get the list of textures generated by the multi render target.
  22938. */
  22939. get textures(): Texture[];
  22940. /**
  22941. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  22942. */
  22943. get count(): number;
  22944. /**
  22945. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  22946. */
  22947. get depthTexture(): Texture;
  22948. /**
  22949. * Set the wrapping mode on U of all the textures we are rendering to.
  22950. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22951. */
  22952. set wrapU(wrap: number);
  22953. /**
  22954. * Set the wrapping mode on V of all the textures we are rendering to.
  22955. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22956. */
  22957. set wrapV(wrap: number);
  22958. /**
  22959. * Instantiate a new multi render target texture.
  22960. * A multi render target, like a render target provides the ability to render to a texture.
  22961. * Unlike the render target, it can render to several draw buffers in one draw.
  22962. * This is specially interesting in deferred rendering or for any effects requiring more than
  22963. * just one color from a single pass.
  22964. * @param name Define the name of the texture
  22965. * @param size Define the size of the buffers to render to
  22966. * @param count Define the number of target we are rendering into
  22967. * @param scene Define the scene the texture belongs to
  22968. * @param options Define the options used to create the multi render target
  22969. */
  22970. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  22971. private _initTypes;
  22972. /** @hidden */
  22973. _rebuild(forceFullRebuild?: boolean): void;
  22974. private _createInternalTextures;
  22975. private _createTextures;
  22976. /**
  22977. * Replaces a texture within the MRT.
  22978. * @param texture The new texture to insert in the MRT
  22979. * @param index The index of the texture to replace
  22980. */
  22981. replaceTexture(texture: Texture, index: number): void;
  22982. /**
  22983. * Define the number of samples used if MSAA is enabled.
  22984. */
  22985. get samples(): number;
  22986. set samples(value: number);
  22987. /**
  22988. * Resize all the textures in the multi render target.
  22989. * Be careful as it will recreate all the data in the new texture.
  22990. * @param size Define the new size
  22991. */
  22992. resize(size: any): void;
  22993. /**
  22994. * Changes the number of render targets in this MRT
  22995. * Be careful as it will recreate all the data in the new texture.
  22996. * @param count new texture count
  22997. * @param options Specifies texture types and sampling modes for new textures
  22998. */
  22999. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23000. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23001. /**
  23002. * Dispose the render targets and their associated resources
  23003. */
  23004. dispose(): void;
  23005. /**
  23006. * Release all the underlying texture used as draw buffers.
  23007. */
  23008. releaseInternalTextures(): void;
  23009. }
  23010. }
  23011. declare module BABYLON {
  23012. /** @hidden */
  23013. export var imageProcessingPixelShader: {
  23014. name: string;
  23015. shader: string;
  23016. };
  23017. }
  23018. declare module BABYLON {
  23019. /**
  23020. * ImageProcessingPostProcess
  23021. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23022. */
  23023. export class ImageProcessingPostProcess extends PostProcess {
  23024. /**
  23025. * Default configuration related to image processing available in the PBR Material.
  23026. */
  23027. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23028. /**
  23029. * Gets the image processing configuration used either in this material.
  23030. */
  23031. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23032. /**
  23033. * Sets the Default image processing configuration used either in the this material.
  23034. *
  23035. * If sets to null, the scene one is in use.
  23036. */
  23037. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23038. /**
  23039. * Keep track of the image processing observer to allow dispose and replace.
  23040. */
  23041. private _imageProcessingObserver;
  23042. /**
  23043. * Attaches a new image processing configuration to the PBR Material.
  23044. * @param configuration
  23045. */
  23046. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23047. /**
  23048. * If the post process is supported.
  23049. */
  23050. get isSupported(): boolean;
  23051. /**
  23052. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23053. */
  23054. get colorCurves(): Nullable<ColorCurves>;
  23055. /**
  23056. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23057. */
  23058. set colorCurves(value: Nullable<ColorCurves>);
  23059. /**
  23060. * Gets wether the color curves effect is enabled.
  23061. */
  23062. get colorCurvesEnabled(): boolean;
  23063. /**
  23064. * Sets wether the color curves effect is enabled.
  23065. */
  23066. set colorCurvesEnabled(value: boolean);
  23067. /**
  23068. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23069. */
  23070. get colorGradingTexture(): Nullable<BaseTexture>;
  23071. /**
  23072. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23073. */
  23074. set colorGradingTexture(value: Nullable<BaseTexture>);
  23075. /**
  23076. * Gets wether the color grading effect is enabled.
  23077. */
  23078. get colorGradingEnabled(): boolean;
  23079. /**
  23080. * Gets wether the color grading effect is enabled.
  23081. */
  23082. set colorGradingEnabled(value: boolean);
  23083. /**
  23084. * Gets exposure used in the effect.
  23085. */
  23086. get exposure(): number;
  23087. /**
  23088. * Sets exposure used in the effect.
  23089. */
  23090. set exposure(value: number);
  23091. /**
  23092. * Gets wether tonemapping is enabled or not.
  23093. */
  23094. get toneMappingEnabled(): boolean;
  23095. /**
  23096. * Sets wether tonemapping is enabled or not
  23097. */
  23098. set toneMappingEnabled(value: boolean);
  23099. /**
  23100. * Gets the type of tone mapping effect.
  23101. */
  23102. get toneMappingType(): number;
  23103. /**
  23104. * Sets the type of tone mapping effect.
  23105. */
  23106. set toneMappingType(value: number);
  23107. /**
  23108. * Gets contrast used in the effect.
  23109. */
  23110. get contrast(): number;
  23111. /**
  23112. * Sets contrast used in the effect.
  23113. */
  23114. set contrast(value: number);
  23115. /**
  23116. * Gets Vignette stretch size.
  23117. */
  23118. get vignetteStretch(): number;
  23119. /**
  23120. * Sets Vignette stretch size.
  23121. */
  23122. set vignetteStretch(value: number);
  23123. /**
  23124. * Gets Vignette centre X Offset.
  23125. */
  23126. get vignetteCentreX(): number;
  23127. /**
  23128. * Sets Vignette centre X Offset.
  23129. */
  23130. set vignetteCentreX(value: number);
  23131. /**
  23132. * Gets Vignette centre Y Offset.
  23133. */
  23134. get vignetteCentreY(): number;
  23135. /**
  23136. * Sets Vignette centre Y Offset.
  23137. */
  23138. set vignetteCentreY(value: number);
  23139. /**
  23140. * Gets Vignette weight or intensity of the vignette effect.
  23141. */
  23142. get vignetteWeight(): number;
  23143. /**
  23144. * Sets Vignette weight or intensity of the vignette effect.
  23145. */
  23146. set vignetteWeight(value: number);
  23147. /**
  23148. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23149. * if vignetteEnabled is set to true.
  23150. */
  23151. get vignetteColor(): Color4;
  23152. /**
  23153. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23154. * if vignetteEnabled is set to true.
  23155. */
  23156. set vignetteColor(value: Color4);
  23157. /**
  23158. * Gets Camera field of view used by the Vignette effect.
  23159. */
  23160. get vignetteCameraFov(): number;
  23161. /**
  23162. * Sets Camera field of view used by the Vignette effect.
  23163. */
  23164. set vignetteCameraFov(value: number);
  23165. /**
  23166. * Gets the vignette blend mode allowing different kind of effect.
  23167. */
  23168. get vignetteBlendMode(): number;
  23169. /**
  23170. * Sets the vignette blend mode allowing different kind of effect.
  23171. */
  23172. set vignetteBlendMode(value: number);
  23173. /**
  23174. * Gets wether the vignette effect is enabled.
  23175. */
  23176. get vignetteEnabled(): boolean;
  23177. /**
  23178. * Sets wether the vignette effect is enabled.
  23179. */
  23180. set vignetteEnabled(value: boolean);
  23181. private _fromLinearSpace;
  23182. /**
  23183. * Gets wether the input of the processing is in Gamma or Linear Space.
  23184. */
  23185. get fromLinearSpace(): boolean;
  23186. /**
  23187. * Sets wether the input of the processing is in Gamma or Linear Space.
  23188. */
  23189. set fromLinearSpace(value: boolean);
  23190. /**
  23191. * Defines cache preventing GC.
  23192. */
  23193. private _defines;
  23194. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23195. /**
  23196. * "ImageProcessingPostProcess"
  23197. * @returns "ImageProcessingPostProcess"
  23198. */
  23199. getClassName(): string;
  23200. /**
  23201. * @hidden
  23202. */
  23203. _updateParameters(): void;
  23204. dispose(camera?: Camera): void;
  23205. }
  23206. }
  23207. declare module BABYLON {
  23208. /**
  23209. * Interface for defining prepass effects in the prepass post-process pipeline
  23210. */
  23211. export interface PrePassEffectConfiguration {
  23212. /**
  23213. * Name of the effect
  23214. */
  23215. name: string;
  23216. /**
  23217. * Post process to attach for this effect
  23218. */
  23219. postProcess?: PostProcess;
  23220. /**
  23221. * Textures required in the MRT
  23222. */
  23223. texturesRequired: number[];
  23224. /**
  23225. * Is the effect enabled
  23226. */
  23227. enabled: boolean;
  23228. /**
  23229. * Disposes the effect configuration
  23230. */
  23231. dispose?: () => void;
  23232. /**
  23233. * Creates the associated post process
  23234. */
  23235. createPostProcess?: () => PostProcess;
  23236. }
  23237. }
  23238. declare module BABYLON {
  23239. /**
  23240. * Options to be used when creating a FresnelParameters.
  23241. */
  23242. export type IFresnelParametersCreationOptions = {
  23243. /**
  23244. * Define the color used on edges (grazing angle)
  23245. */
  23246. leftColor?: Color3;
  23247. /**
  23248. * Define the color used on center
  23249. */
  23250. rightColor?: Color3;
  23251. /**
  23252. * Define bias applied to computed fresnel term
  23253. */
  23254. bias?: number;
  23255. /**
  23256. * Defined the power exponent applied to fresnel term
  23257. */
  23258. power?: number;
  23259. /**
  23260. * Define if the fresnel effect is enable or not.
  23261. */
  23262. isEnabled?: boolean;
  23263. };
  23264. /**
  23265. * Serialized format for FresnelParameters.
  23266. */
  23267. export type IFresnelParametersSerialized = {
  23268. /**
  23269. * Define the color used on edges (grazing angle) [as an array]
  23270. */
  23271. leftColor: number[];
  23272. /**
  23273. * Define the color used on center [as an array]
  23274. */
  23275. rightColor: number[];
  23276. /**
  23277. * Define bias applied to computed fresnel term
  23278. */
  23279. bias: number;
  23280. /**
  23281. * Defined the power exponent applied to fresnel term
  23282. */
  23283. power?: number;
  23284. /**
  23285. * Define if the fresnel effect is enable or not.
  23286. */
  23287. isEnabled: boolean;
  23288. };
  23289. /**
  23290. * This represents all the required information to add a fresnel effect on a material:
  23291. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23292. */
  23293. export class FresnelParameters {
  23294. private _isEnabled;
  23295. /**
  23296. * Define if the fresnel effect is enable or not.
  23297. */
  23298. get isEnabled(): boolean;
  23299. set isEnabled(value: boolean);
  23300. /**
  23301. * Define the color used on edges (grazing angle)
  23302. */
  23303. leftColor: Color3;
  23304. /**
  23305. * Define the color used on center
  23306. */
  23307. rightColor: Color3;
  23308. /**
  23309. * Define bias applied to computed fresnel term
  23310. */
  23311. bias: number;
  23312. /**
  23313. * Defined the power exponent applied to fresnel term
  23314. */
  23315. power: number;
  23316. /**
  23317. * Creates a new FresnelParameters object.
  23318. *
  23319. * @param options provide your own settings to optionally to override defaults
  23320. */
  23321. constructor(options?: IFresnelParametersCreationOptions);
  23322. /**
  23323. * Clones the current fresnel and its valuues
  23324. * @returns a clone fresnel configuration
  23325. */
  23326. clone(): FresnelParameters;
  23327. /**
  23328. * Determines equality between FresnelParameters objects
  23329. * @param otherFresnelParameters defines the second operand
  23330. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23331. */
  23332. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23333. /**
  23334. * Serializes the current fresnel parameters to a JSON representation.
  23335. * @return the JSON serialization
  23336. */
  23337. serialize(): IFresnelParametersSerialized;
  23338. /**
  23339. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23340. * @param parsedFresnelParameters Define the JSON representation
  23341. * @returns the parsed parameters
  23342. */
  23343. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23344. }
  23345. }
  23346. declare module BABYLON {
  23347. /**
  23348. * This groups all the flags used to control the materials channel.
  23349. */
  23350. export class MaterialFlags {
  23351. private static _DiffuseTextureEnabled;
  23352. /**
  23353. * Are diffuse textures enabled in the application.
  23354. */
  23355. static get DiffuseTextureEnabled(): boolean;
  23356. static set DiffuseTextureEnabled(value: boolean);
  23357. private static _DetailTextureEnabled;
  23358. /**
  23359. * Are detail textures enabled in the application.
  23360. */
  23361. static get DetailTextureEnabled(): boolean;
  23362. static set DetailTextureEnabled(value: boolean);
  23363. private static _AmbientTextureEnabled;
  23364. /**
  23365. * Are ambient textures enabled in the application.
  23366. */
  23367. static get AmbientTextureEnabled(): boolean;
  23368. static set AmbientTextureEnabled(value: boolean);
  23369. private static _OpacityTextureEnabled;
  23370. /**
  23371. * Are opacity textures enabled in the application.
  23372. */
  23373. static get OpacityTextureEnabled(): boolean;
  23374. static set OpacityTextureEnabled(value: boolean);
  23375. private static _ReflectionTextureEnabled;
  23376. /**
  23377. * Are reflection textures enabled in the application.
  23378. */
  23379. static get ReflectionTextureEnabled(): boolean;
  23380. static set ReflectionTextureEnabled(value: boolean);
  23381. private static _EmissiveTextureEnabled;
  23382. /**
  23383. * Are emissive textures enabled in the application.
  23384. */
  23385. static get EmissiveTextureEnabled(): boolean;
  23386. static set EmissiveTextureEnabled(value: boolean);
  23387. private static _SpecularTextureEnabled;
  23388. /**
  23389. * Are specular textures enabled in the application.
  23390. */
  23391. static get SpecularTextureEnabled(): boolean;
  23392. static set SpecularTextureEnabled(value: boolean);
  23393. private static _BumpTextureEnabled;
  23394. /**
  23395. * Are bump textures enabled in the application.
  23396. */
  23397. static get BumpTextureEnabled(): boolean;
  23398. static set BumpTextureEnabled(value: boolean);
  23399. private static _LightmapTextureEnabled;
  23400. /**
  23401. * Are lightmap textures enabled in the application.
  23402. */
  23403. static get LightmapTextureEnabled(): boolean;
  23404. static set LightmapTextureEnabled(value: boolean);
  23405. private static _RefractionTextureEnabled;
  23406. /**
  23407. * Are refraction textures enabled in the application.
  23408. */
  23409. static get RefractionTextureEnabled(): boolean;
  23410. static set RefractionTextureEnabled(value: boolean);
  23411. private static _ColorGradingTextureEnabled;
  23412. /**
  23413. * Are color grading textures enabled in the application.
  23414. */
  23415. static get ColorGradingTextureEnabled(): boolean;
  23416. static set ColorGradingTextureEnabled(value: boolean);
  23417. private static _FresnelEnabled;
  23418. /**
  23419. * Are fresnels enabled in the application.
  23420. */
  23421. static get FresnelEnabled(): boolean;
  23422. static set FresnelEnabled(value: boolean);
  23423. private static _ClearCoatTextureEnabled;
  23424. /**
  23425. * Are clear coat textures enabled in the application.
  23426. */
  23427. static get ClearCoatTextureEnabled(): boolean;
  23428. static set ClearCoatTextureEnabled(value: boolean);
  23429. private static _ClearCoatBumpTextureEnabled;
  23430. /**
  23431. * Are clear coat bump textures enabled in the application.
  23432. */
  23433. static get ClearCoatBumpTextureEnabled(): boolean;
  23434. static set ClearCoatBumpTextureEnabled(value: boolean);
  23435. private static _ClearCoatTintTextureEnabled;
  23436. /**
  23437. * Are clear coat tint textures enabled in the application.
  23438. */
  23439. static get ClearCoatTintTextureEnabled(): boolean;
  23440. static set ClearCoatTintTextureEnabled(value: boolean);
  23441. private static _SheenTextureEnabled;
  23442. /**
  23443. * Are sheen textures enabled in the application.
  23444. */
  23445. static get SheenTextureEnabled(): boolean;
  23446. static set SheenTextureEnabled(value: boolean);
  23447. private static _AnisotropicTextureEnabled;
  23448. /**
  23449. * Are anisotropic textures enabled in the application.
  23450. */
  23451. static get AnisotropicTextureEnabled(): boolean;
  23452. static set AnisotropicTextureEnabled(value: boolean);
  23453. private static _ThicknessTextureEnabled;
  23454. /**
  23455. * Are thickness textures enabled in the application.
  23456. */
  23457. static get ThicknessTextureEnabled(): boolean;
  23458. static set ThicknessTextureEnabled(value: boolean);
  23459. }
  23460. }
  23461. declare module BABYLON {
  23462. /** @hidden */
  23463. export var defaultFragmentDeclaration: {
  23464. name: string;
  23465. shader: string;
  23466. };
  23467. }
  23468. declare module BABYLON {
  23469. /** @hidden */
  23470. export var defaultUboDeclaration: {
  23471. name: string;
  23472. shader: string;
  23473. };
  23474. }
  23475. declare module BABYLON {
  23476. /** @hidden */
  23477. export var prePassDeclaration: {
  23478. name: string;
  23479. shader: string;
  23480. };
  23481. }
  23482. declare module BABYLON {
  23483. /** @hidden */
  23484. export var lightFragmentDeclaration: {
  23485. name: string;
  23486. shader: string;
  23487. };
  23488. }
  23489. declare module BABYLON {
  23490. /** @hidden */
  23491. export var lightUboDeclaration: {
  23492. name: string;
  23493. shader: string;
  23494. };
  23495. }
  23496. declare module BABYLON {
  23497. /** @hidden */
  23498. export var lightsFragmentFunctions: {
  23499. name: string;
  23500. shader: string;
  23501. };
  23502. }
  23503. declare module BABYLON {
  23504. /** @hidden */
  23505. export var shadowsFragmentFunctions: {
  23506. name: string;
  23507. shader: string;
  23508. };
  23509. }
  23510. declare module BABYLON {
  23511. /** @hidden */
  23512. export var fresnelFunction: {
  23513. name: string;
  23514. shader: string;
  23515. };
  23516. }
  23517. declare module BABYLON {
  23518. /** @hidden */
  23519. export var bumpFragmentMainFunctions: {
  23520. name: string;
  23521. shader: string;
  23522. };
  23523. }
  23524. declare module BABYLON {
  23525. /** @hidden */
  23526. export var bumpFragmentFunctions: {
  23527. name: string;
  23528. shader: string;
  23529. };
  23530. }
  23531. declare module BABYLON {
  23532. /** @hidden */
  23533. export var logDepthDeclaration: {
  23534. name: string;
  23535. shader: string;
  23536. };
  23537. }
  23538. declare module BABYLON {
  23539. /** @hidden */
  23540. export var bumpFragment: {
  23541. name: string;
  23542. shader: string;
  23543. };
  23544. }
  23545. declare module BABYLON {
  23546. /** @hidden */
  23547. export var depthPrePass: {
  23548. name: string;
  23549. shader: string;
  23550. };
  23551. }
  23552. declare module BABYLON {
  23553. /** @hidden */
  23554. export var lightFragment: {
  23555. name: string;
  23556. shader: string;
  23557. };
  23558. }
  23559. declare module BABYLON {
  23560. /** @hidden */
  23561. export var logDepthFragment: {
  23562. name: string;
  23563. shader: string;
  23564. };
  23565. }
  23566. declare module BABYLON {
  23567. /** @hidden */
  23568. export var defaultPixelShader: {
  23569. name: string;
  23570. shader: string;
  23571. };
  23572. }
  23573. declare module BABYLON {
  23574. /** @hidden */
  23575. export var defaultVertexDeclaration: {
  23576. name: string;
  23577. shader: string;
  23578. };
  23579. }
  23580. declare module BABYLON {
  23581. /** @hidden */
  23582. export var prePassVertexDeclaration: {
  23583. name: string;
  23584. shader: string;
  23585. };
  23586. }
  23587. declare module BABYLON {
  23588. /** @hidden */
  23589. export var bumpVertexDeclaration: {
  23590. name: string;
  23591. shader: string;
  23592. };
  23593. }
  23594. declare module BABYLON {
  23595. /** @hidden */
  23596. export var prePassVertex: {
  23597. name: string;
  23598. shader: string;
  23599. };
  23600. }
  23601. declare module BABYLON {
  23602. /** @hidden */
  23603. export var bumpVertex: {
  23604. name: string;
  23605. shader: string;
  23606. };
  23607. }
  23608. declare module BABYLON {
  23609. /** @hidden */
  23610. export var fogVertex: {
  23611. name: string;
  23612. shader: string;
  23613. };
  23614. }
  23615. declare module BABYLON {
  23616. /** @hidden */
  23617. export var shadowsVertex: {
  23618. name: string;
  23619. shader: string;
  23620. };
  23621. }
  23622. declare module BABYLON {
  23623. /** @hidden */
  23624. export var pointCloudVertex: {
  23625. name: string;
  23626. shader: string;
  23627. };
  23628. }
  23629. declare module BABYLON {
  23630. /** @hidden */
  23631. export var logDepthVertex: {
  23632. name: string;
  23633. shader: string;
  23634. };
  23635. }
  23636. declare module BABYLON {
  23637. /** @hidden */
  23638. export var defaultVertexShader: {
  23639. name: string;
  23640. shader: string;
  23641. };
  23642. }
  23643. declare module BABYLON {
  23644. /**
  23645. * @hidden
  23646. */
  23647. export interface IMaterialDetailMapDefines {
  23648. DETAIL: boolean;
  23649. DETAILDIRECTUV: number;
  23650. DETAIL_NORMALBLENDMETHOD: number;
  23651. /** @hidden */
  23652. _areTexturesDirty: boolean;
  23653. }
  23654. /**
  23655. * Define the code related to the detail map parameters of a material
  23656. *
  23657. * Inspired from:
  23658. * 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
  23659. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23660. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23661. */
  23662. export class DetailMapConfiguration {
  23663. private _texture;
  23664. /**
  23665. * The detail texture of the material.
  23666. */
  23667. texture: Nullable<BaseTexture>;
  23668. /**
  23669. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23670. * Bigger values mean stronger blending
  23671. */
  23672. diffuseBlendLevel: number;
  23673. /**
  23674. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23675. * Bigger values mean stronger blending. Only used with PBR materials
  23676. */
  23677. roughnessBlendLevel: number;
  23678. /**
  23679. * Defines how strong the bump effect from the detail map is
  23680. * Bigger values mean stronger effect
  23681. */
  23682. bumpLevel: number;
  23683. private _normalBlendMethod;
  23684. /**
  23685. * The method used to blend the bump and detail normals together
  23686. */
  23687. normalBlendMethod: number;
  23688. private _isEnabled;
  23689. /**
  23690. * Enable or disable the detail map on this material
  23691. */
  23692. isEnabled: boolean;
  23693. /** @hidden */
  23694. private _internalMarkAllSubMeshesAsTexturesDirty;
  23695. /** @hidden */
  23696. _markAllSubMeshesAsTexturesDirty(): void;
  23697. /**
  23698. * Instantiate a new detail map
  23699. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  23700. */
  23701. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  23702. /**
  23703. * Gets whether the submesh is ready to be used or not.
  23704. * @param defines the list of "defines" to update.
  23705. * @param scene defines the scene the material belongs to.
  23706. * @returns - boolean indicating that the submesh is ready or not.
  23707. */
  23708. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  23709. /**
  23710. * Update the defines for detail map usage
  23711. * @param defines the list of "defines" to update.
  23712. * @param scene defines the scene the material belongs to.
  23713. */
  23714. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  23715. /**
  23716. * Binds the material data.
  23717. * @param uniformBuffer defines the Uniform buffer to fill in.
  23718. * @param scene defines the scene the material belongs to.
  23719. * @param isFrozen defines whether the material is frozen or not.
  23720. */
  23721. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  23722. /**
  23723. * Checks to see if a texture is used in the material.
  23724. * @param texture - Base texture to use.
  23725. * @returns - Boolean specifying if a texture is used in the material.
  23726. */
  23727. hasTexture(texture: BaseTexture): boolean;
  23728. /**
  23729. * Returns an array of the actively used textures.
  23730. * @param activeTextures Array of BaseTextures
  23731. */
  23732. getActiveTextures(activeTextures: BaseTexture[]): void;
  23733. /**
  23734. * Returns the animatable textures.
  23735. * @param animatables Array of animatable textures.
  23736. */
  23737. getAnimatables(animatables: IAnimatable[]): void;
  23738. /**
  23739. * Disposes the resources of the material.
  23740. * @param forceDisposeTextures - Forces the disposal of all textures.
  23741. */
  23742. dispose(forceDisposeTextures?: boolean): void;
  23743. /**
  23744. * Get the current class name useful for serialization or dynamic coding.
  23745. * @returns "DetailMap"
  23746. */
  23747. getClassName(): string;
  23748. /**
  23749. * Add the required uniforms to the current list.
  23750. * @param uniforms defines the current uniform list.
  23751. */
  23752. static AddUniforms(uniforms: string[]): void;
  23753. /**
  23754. * Add the required samplers to the current list.
  23755. * @param samplers defines the current sampler list.
  23756. */
  23757. static AddSamplers(samplers: string[]): void;
  23758. /**
  23759. * Add the required uniforms to the current buffer.
  23760. * @param uniformBuffer defines the current uniform buffer.
  23761. */
  23762. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  23763. /**
  23764. * Makes a duplicate of the current instance into another one.
  23765. * @param detailMap define the instance where to copy the info
  23766. */
  23767. copyTo(detailMap: DetailMapConfiguration): void;
  23768. /**
  23769. * Serializes this detail map instance
  23770. * @returns - An object with the serialized instance.
  23771. */
  23772. serialize(): any;
  23773. /**
  23774. * Parses a detail map setting from a serialized object.
  23775. * @param source - Serialized object.
  23776. * @param scene Defines the scene we are parsing for
  23777. * @param rootUrl Defines the rootUrl to load from
  23778. */
  23779. parse(source: any, scene: Scene, rootUrl: string): void;
  23780. }
  23781. }
  23782. declare module BABYLON {
  23783. /** @hidden */
  23784. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  23785. MAINUV1: boolean;
  23786. MAINUV2: boolean;
  23787. DIFFUSE: boolean;
  23788. DIFFUSEDIRECTUV: number;
  23789. DETAIL: boolean;
  23790. DETAILDIRECTUV: number;
  23791. DETAIL_NORMALBLENDMETHOD: number;
  23792. AMBIENT: boolean;
  23793. AMBIENTDIRECTUV: number;
  23794. OPACITY: boolean;
  23795. OPACITYDIRECTUV: number;
  23796. OPACITYRGB: boolean;
  23797. REFLECTION: boolean;
  23798. EMISSIVE: boolean;
  23799. EMISSIVEDIRECTUV: number;
  23800. SPECULAR: boolean;
  23801. SPECULARDIRECTUV: number;
  23802. BUMP: boolean;
  23803. BUMPDIRECTUV: number;
  23804. PARALLAX: boolean;
  23805. PARALLAXOCCLUSION: boolean;
  23806. SPECULAROVERALPHA: boolean;
  23807. CLIPPLANE: boolean;
  23808. CLIPPLANE2: boolean;
  23809. CLIPPLANE3: boolean;
  23810. CLIPPLANE4: boolean;
  23811. CLIPPLANE5: boolean;
  23812. CLIPPLANE6: boolean;
  23813. ALPHATEST: boolean;
  23814. DEPTHPREPASS: boolean;
  23815. ALPHAFROMDIFFUSE: boolean;
  23816. POINTSIZE: boolean;
  23817. FOG: boolean;
  23818. SPECULARTERM: boolean;
  23819. DIFFUSEFRESNEL: boolean;
  23820. OPACITYFRESNEL: boolean;
  23821. REFLECTIONFRESNEL: boolean;
  23822. REFRACTIONFRESNEL: boolean;
  23823. EMISSIVEFRESNEL: boolean;
  23824. FRESNEL: boolean;
  23825. NORMAL: boolean;
  23826. UV1: boolean;
  23827. UV2: boolean;
  23828. VERTEXCOLOR: boolean;
  23829. VERTEXALPHA: boolean;
  23830. NUM_BONE_INFLUENCERS: number;
  23831. BonesPerMesh: number;
  23832. BONETEXTURE: boolean;
  23833. BONES_VELOCITY_ENABLED: boolean;
  23834. INSTANCES: boolean;
  23835. THIN_INSTANCES: boolean;
  23836. GLOSSINESS: boolean;
  23837. ROUGHNESS: boolean;
  23838. EMISSIVEASILLUMINATION: boolean;
  23839. LINKEMISSIVEWITHDIFFUSE: boolean;
  23840. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23841. LIGHTMAP: boolean;
  23842. LIGHTMAPDIRECTUV: number;
  23843. OBJECTSPACE_NORMALMAP: boolean;
  23844. USELIGHTMAPASSHADOWMAP: boolean;
  23845. REFLECTIONMAP_3D: boolean;
  23846. REFLECTIONMAP_SPHERICAL: boolean;
  23847. REFLECTIONMAP_PLANAR: boolean;
  23848. REFLECTIONMAP_CUBIC: boolean;
  23849. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23850. REFLECTIONMAP_PROJECTION: boolean;
  23851. REFLECTIONMAP_SKYBOX: boolean;
  23852. REFLECTIONMAP_EXPLICIT: boolean;
  23853. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23854. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23855. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23856. INVERTCUBICMAP: boolean;
  23857. LOGARITHMICDEPTH: boolean;
  23858. REFRACTION: boolean;
  23859. REFRACTIONMAP_3D: boolean;
  23860. REFLECTIONOVERALPHA: boolean;
  23861. TWOSIDEDLIGHTING: boolean;
  23862. SHADOWFLOAT: boolean;
  23863. MORPHTARGETS: boolean;
  23864. MORPHTARGETS_NORMAL: boolean;
  23865. MORPHTARGETS_TANGENT: boolean;
  23866. MORPHTARGETS_UV: boolean;
  23867. NUM_MORPH_INFLUENCERS: number;
  23868. NONUNIFORMSCALING: boolean;
  23869. PREMULTIPLYALPHA: boolean;
  23870. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  23871. ALPHABLEND: boolean;
  23872. PREPASS: boolean;
  23873. PREPASS_IRRADIANCE: boolean;
  23874. PREPASS_IRRADIANCE_INDEX: number;
  23875. PREPASS_ALBEDO: boolean;
  23876. PREPASS_ALBEDO_INDEX: number;
  23877. PREPASS_DEPTHNORMAL: boolean;
  23878. PREPASS_DEPTHNORMAL_INDEX: number;
  23879. PREPASS_POSITION: boolean;
  23880. PREPASS_POSITION_INDEX: number;
  23881. PREPASS_VELOCITY: boolean;
  23882. PREPASS_VELOCITY_INDEX: number;
  23883. PREPASS_REFLECTIVITY: boolean;
  23884. PREPASS_REFLECTIVITY_INDEX: number;
  23885. SCENE_MRT_COUNT: number;
  23886. RGBDLIGHTMAP: boolean;
  23887. RGBDREFLECTION: boolean;
  23888. RGBDREFRACTION: boolean;
  23889. IMAGEPROCESSING: boolean;
  23890. VIGNETTE: boolean;
  23891. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23892. VIGNETTEBLENDMODEOPAQUE: boolean;
  23893. TONEMAPPING: boolean;
  23894. TONEMAPPING_ACES: boolean;
  23895. CONTRAST: boolean;
  23896. COLORCURVES: boolean;
  23897. COLORGRADING: boolean;
  23898. COLORGRADING3D: boolean;
  23899. SAMPLER3DGREENDEPTH: boolean;
  23900. SAMPLER3DBGRMAP: boolean;
  23901. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23902. MULTIVIEW: boolean;
  23903. /**
  23904. * If the reflection texture on this material is in linear color space
  23905. * @hidden
  23906. */
  23907. IS_REFLECTION_LINEAR: boolean;
  23908. /**
  23909. * If the refraction texture on this material is in linear color space
  23910. * @hidden
  23911. */
  23912. IS_REFRACTION_LINEAR: boolean;
  23913. EXPOSURE: boolean;
  23914. constructor();
  23915. setReflectionMode(modeToEnable: string): void;
  23916. }
  23917. /**
  23918. * This is the default material used in Babylon. It is the best trade off between quality
  23919. * and performances.
  23920. * @see https://doc.babylonjs.com/babylon101/materials
  23921. */
  23922. export class StandardMaterial extends PushMaterial {
  23923. private _diffuseTexture;
  23924. /**
  23925. * The basic texture of the material as viewed under a light.
  23926. */
  23927. diffuseTexture: Nullable<BaseTexture>;
  23928. private _ambientTexture;
  23929. /**
  23930. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23931. */
  23932. ambientTexture: Nullable<BaseTexture>;
  23933. private _opacityTexture;
  23934. /**
  23935. * Define the transparency of the material from a texture.
  23936. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23937. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23938. */
  23939. opacityTexture: Nullable<BaseTexture>;
  23940. private _reflectionTexture;
  23941. /**
  23942. * Define the texture used to display the reflection.
  23943. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23944. */
  23945. reflectionTexture: Nullable<BaseTexture>;
  23946. private _emissiveTexture;
  23947. /**
  23948. * Define texture of the material as if self lit.
  23949. * This will be mixed in the final result even in the absence of light.
  23950. */
  23951. emissiveTexture: Nullable<BaseTexture>;
  23952. private _specularTexture;
  23953. /**
  23954. * Define how the color and intensity of the highlight given by the light in the material.
  23955. */
  23956. specularTexture: Nullable<BaseTexture>;
  23957. private _bumpTexture;
  23958. /**
  23959. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23960. * 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.
  23961. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  23962. */
  23963. bumpTexture: Nullable<BaseTexture>;
  23964. private _lightmapTexture;
  23965. /**
  23966. * Complex lighting can be computationally expensive to compute at runtime.
  23967. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23968. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  23969. */
  23970. lightmapTexture: Nullable<BaseTexture>;
  23971. private _refractionTexture;
  23972. /**
  23973. * Define the texture used to display the refraction.
  23974. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23975. */
  23976. refractionTexture: Nullable<BaseTexture>;
  23977. /**
  23978. * The color of the material lit by the environmental background lighting.
  23979. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  23980. */
  23981. ambientColor: Color3;
  23982. /**
  23983. * The basic color of the material as viewed under a light.
  23984. */
  23985. diffuseColor: Color3;
  23986. /**
  23987. * Define how the color and intensity of the highlight given by the light in the material.
  23988. */
  23989. specularColor: Color3;
  23990. /**
  23991. * Define the color of the material as if self lit.
  23992. * This will be mixed in the final result even in the absence of light.
  23993. */
  23994. emissiveColor: Color3;
  23995. /**
  23996. * Defines how sharp are the highlights in the material.
  23997. * The bigger the value the sharper giving a more glossy feeling to the result.
  23998. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  23999. */
  24000. specularPower: number;
  24001. private _useAlphaFromDiffuseTexture;
  24002. /**
  24003. * Does the transparency come from the diffuse texture alpha channel.
  24004. */
  24005. useAlphaFromDiffuseTexture: boolean;
  24006. private _useEmissiveAsIllumination;
  24007. /**
  24008. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24009. */
  24010. useEmissiveAsIllumination: boolean;
  24011. private _linkEmissiveWithDiffuse;
  24012. /**
  24013. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24014. * the emissive level when the final color is close to one.
  24015. */
  24016. linkEmissiveWithDiffuse: boolean;
  24017. private _useSpecularOverAlpha;
  24018. /**
  24019. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24020. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24021. */
  24022. useSpecularOverAlpha: boolean;
  24023. private _useReflectionOverAlpha;
  24024. /**
  24025. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24026. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24027. */
  24028. useReflectionOverAlpha: boolean;
  24029. private _disableLighting;
  24030. /**
  24031. * Does lights from the scene impacts this material.
  24032. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24033. */
  24034. disableLighting: boolean;
  24035. private _useObjectSpaceNormalMap;
  24036. /**
  24037. * Allows using an object space normal map (instead of tangent space).
  24038. */
  24039. useObjectSpaceNormalMap: boolean;
  24040. private _useParallax;
  24041. /**
  24042. * Is parallax enabled or not.
  24043. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24044. */
  24045. useParallax: boolean;
  24046. private _useParallaxOcclusion;
  24047. /**
  24048. * Is parallax occlusion enabled or not.
  24049. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24050. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24051. */
  24052. useParallaxOcclusion: boolean;
  24053. /**
  24054. * 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.
  24055. */
  24056. parallaxScaleBias: number;
  24057. private _roughness;
  24058. /**
  24059. * Helps to define how blurry the reflections should appears in the material.
  24060. */
  24061. roughness: number;
  24062. /**
  24063. * In case of refraction, define the value of the index of refraction.
  24064. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24065. */
  24066. indexOfRefraction: number;
  24067. /**
  24068. * Invert the refraction texture alongside the y axis.
  24069. * It can be useful with procedural textures or probe for instance.
  24070. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24071. */
  24072. invertRefractionY: boolean;
  24073. /**
  24074. * Defines the alpha limits in alpha test mode.
  24075. */
  24076. alphaCutOff: number;
  24077. private _useLightmapAsShadowmap;
  24078. /**
  24079. * In case of light mapping, define whether the map contains light or shadow informations.
  24080. */
  24081. useLightmapAsShadowmap: boolean;
  24082. private _diffuseFresnelParameters;
  24083. /**
  24084. * Define the diffuse fresnel parameters of the material.
  24085. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24086. */
  24087. diffuseFresnelParameters: FresnelParameters;
  24088. private _opacityFresnelParameters;
  24089. /**
  24090. * Define the opacity fresnel parameters of the material.
  24091. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24092. */
  24093. opacityFresnelParameters: FresnelParameters;
  24094. private _reflectionFresnelParameters;
  24095. /**
  24096. * Define the reflection fresnel parameters of the material.
  24097. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24098. */
  24099. reflectionFresnelParameters: FresnelParameters;
  24100. private _refractionFresnelParameters;
  24101. /**
  24102. * Define the refraction fresnel parameters of the material.
  24103. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24104. */
  24105. refractionFresnelParameters: FresnelParameters;
  24106. private _emissiveFresnelParameters;
  24107. /**
  24108. * Define the emissive fresnel parameters of the material.
  24109. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24110. */
  24111. emissiveFresnelParameters: FresnelParameters;
  24112. private _useReflectionFresnelFromSpecular;
  24113. /**
  24114. * If true automatically deducts the fresnels values from the material specularity.
  24115. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24116. */
  24117. useReflectionFresnelFromSpecular: boolean;
  24118. private _useGlossinessFromSpecularMapAlpha;
  24119. /**
  24120. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24121. */
  24122. useGlossinessFromSpecularMapAlpha: boolean;
  24123. private _maxSimultaneousLights;
  24124. /**
  24125. * Defines the maximum number of lights that can be used in the material
  24126. */
  24127. maxSimultaneousLights: number;
  24128. private _invertNormalMapX;
  24129. /**
  24130. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24131. */
  24132. invertNormalMapX: boolean;
  24133. private _invertNormalMapY;
  24134. /**
  24135. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24136. */
  24137. invertNormalMapY: boolean;
  24138. private _twoSidedLighting;
  24139. /**
  24140. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24141. */
  24142. twoSidedLighting: boolean;
  24143. /**
  24144. * Default configuration related to image processing available in the standard Material.
  24145. */
  24146. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24147. /**
  24148. * Gets the image processing configuration used either in this material.
  24149. */
  24150. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24151. /**
  24152. * Sets the Default image processing configuration used either in the this material.
  24153. *
  24154. * If sets to null, the scene one is in use.
  24155. */
  24156. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24157. /**
  24158. * Keep track of the image processing observer to allow dispose and replace.
  24159. */
  24160. private _imageProcessingObserver;
  24161. /**
  24162. * Attaches a new image processing configuration to the Standard Material.
  24163. * @param configuration
  24164. */
  24165. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24166. /**
  24167. * Defines additionnal PrePass parameters for the material.
  24168. */
  24169. readonly prePassConfiguration: PrePassConfiguration;
  24170. /**
  24171. * Gets wether the color curves effect is enabled.
  24172. */
  24173. get cameraColorCurvesEnabled(): boolean;
  24174. /**
  24175. * Sets wether the color curves effect is enabled.
  24176. */
  24177. set cameraColorCurvesEnabled(value: boolean);
  24178. /**
  24179. * Gets wether the color grading effect is enabled.
  24180. */
  24181. get cameraColorGradingEnabled(): boolean;
  24182. /**
  24183. * Gets wether the color grading effect is enabled.
  24184. */
  24185. set cameraColorGradingEnabled(value: boolean);
  24186. /**
  24187. * Gets wether tonemapping is enabled or not.
  24188. */
  24189. get cameraToneMappingEnabled(): boolean;
  24190. /**
  24191. * Sets wether tonemapping is enabled or not
  24192. */
  24193. set cameraToneMappingEnabled(value: boolean);
  24194. /**
  24195. * The camera exposure used on this material.
  24196. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24197. * This corresponds to a photographic exposure.
  24198. */
  24199. get cameraExposure(): number;
  24200. /**
  24201. * The camera exposure used on this material.
  24202. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24203. * This corresponds to a photographic exposure.
  24204. */
  24205. set cameraExposure(value: number);
  24206. /**
  24207. * Gets The camera contrast used on this material.
  24208. */
  24209. get cameraContrast(): number;
  24210. /**
  24211. * Sets The camera contrast used on this material.
  24212. */
  24213. set cameraContrast(value: number);
  24214. /**
  24215. * Gets the Color Grading 2D Lookup Texture.
  24216. */
  24217. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24218. /**
  24219. * Sets the Color Grading 2D Lookup Texture.
  24220. */
  24221. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24222. /**
  24223. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24224. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24225. * 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;
  24226. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24227. */
  24228. get cameraColorCurves(): Nullable<ColorCurves>;
  24229. /**
  24230. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24231. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24232. * 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;
  24233. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24234. */
  24235. set cameraColorCurves(value: Nullable<ColorCurves>);
  24236. /**
  24237. * Can this material render to several textures at once
  24238. */
  24239. get canRenderToMRT(): boolean;
  24240. /**
  24241. * Defines the detail map parameters for the material.
  24242. */
  24243. readonly detailMap: DetailMapConfiguration;
  24244. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24245. protected _worldViewProjectionMatrix: Matrix;
  24246. protected _globalAmbientColor: Color3;
  24247. protected _useLogarithmicDepth: boolean;
  24248. protected _rebuildInParallel: boolean;
  24249. /**
  24250. * Instantiates a new standard material.
  24251. * This is the default material used in Babylon. It is the best trade off between quality
  24252. * and performances.
  24253. * @see https://doc.babylonjs.com/babylon101/materials
  24254. * @param name Define the name of the material in the scene
  24255. * @param scene Define the scene the material belong to
  24256. */
  24257. constructor(name: string, scene: Scene);
  24258. /**
  24259. * Gets a boolean indicating that current material needs to register RTT
  24260. */
  24261. get hasRenderTargetTextures(): boolean;
  24262. /**
  24263. * Gets the current class name of the material e.g. "StandardMaterial"
  24264. * Mainly use in serialization.
  24265. * @returns the class name
  24266. */
  24267. getClassName(): string;
  24268. /**
  24269. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24270. * You can try switching to logarithmic depth.
  24271. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24272. */
  24273. get useLogarithmicDepth(): boolean;
  24274. set useLogarithmicDepth(value: boolean);
  24275. /**
  24276. * Specifies if the material will require alpha blending
  24277. * @returns a boolean specifying if alpha blending is needed
  24278. */
  24279. needAlphaBlending(): boolean;
  24280. /**
  24281. * Specifies if this material should be rendered in alpha test mode
  24282. * @returns a boolean specifying if an alpha test is needed.
  24283. */
  24284. needAlphaTesting(): boolean;
  24285. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24286. /**
  24287. * Get the texture used for alpha test purpose.
  24288. * @returns the diffuse texture in case of the standard material.
  24289. */
  24290. getAlphaTestTexture(): Nullable<BaseTexture>;
  24291. /**
  24292. * Get if the submesh is ready to be used and all its information available.
  24293. * Child classes can use it to update shaders
  24294. * @param mesh defines the mesh to check
  24295. * @param subMesh defines which submesh to check
  24296. * @param useInstances specifies that instances should be used
  24297. * @returns a boolean indicating that the submesh is ready or not
  24298. */
  24299. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24300. /**
  24301. * Builds the material UBO layouts.
  24302. * Used internally during the effect preparation.
  24303. */
  24304. buildUniformLayout(): void;
  24305. /**
  24306. * Unbinds the material from the mesh
  24307. */
  24308. unbind(): void;
  24309. /**
  24310. * Binds the submesh to this material by preparing the effect and shader to draw
  24311. * @param world defines the world transformation matrix
  24312. * @param mesh defines the mesh containing the submesh
  24313. * @param subMesh defines the submesh to bind the material to
  24314. */
  24315. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24316. /**
  24317. * Get the list of animatables in the material.
  24318. * @returns the list of animatables object used in the material
  24319. */
  24320. getAnimatables(): IAnimatable[];
  24321. /**
  24322. * Gets the active textures from the material
  24323. * @returns an array of textures
  24324. */
  24325. getActiveTextures(): BaseTexture[];
  24326. /**
  24327. * Specifies if the material uses a texture
  24328. * @param texture defines the texture to check against the material
  24329. * @returns a boolean specifying if the material uses the texture
  24330. */
  24331. hasTexture(texture: BaseTexture): boolean;
  24332. /**
  24333. * Disposes the material
  24334. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24335. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24336. */
  24337. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24338. /**
  24339. * Makes a duplicate of the material, and gives it a new name
  24340. * @param name defines the new name for the duplicated material
  24341. * @returns the cloned material
  24342. */
  24343. clone(name: string): StandardMaterial;
  24344. /**
  24345. * Serializes this material in a JSON representation
  24346. * @returns the serialized material object
  24347. */
  24348. serialize(): any;
  24349. /**
  24350. * Creates a standard material from parsed material data
  24351. * @param source defines the JSON representation of the material
  24352. * @param scene defines the hosting scene
  24353. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24354. * @returns a new standard material
  24355. */
  24356. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24357. /**
  24358. * Are diffuse textures enabled in the application.
  24359. */
  24360. static get DiffuseTextureEnabled(): boolean;
  24361. static set DiffuseTextureEnabled(value: boolean);
  24362. /**
  24363. * Are detail textures enabled in the application.
  24364. */
  24365. static get DetailTextureEnabled(): boolean;
  24366. static set DetailTextureEnabled(value: boolean);
  24367. /**
  24368. * Are ambient textures enabled in the application.
  24369. */
  24370. static get AmbientTextureEnabled(): boolean;
  24371. static set AmbientTextureEnabled(value: boolean);
  24372. /**
  24373. * Are opacity textures enabled in the application.
  24374. */
  24375. static get OpacityTextureEnabled(): boolean;
  24376. static set OpacityTextureEnabled(value: boolean);
  24377. /**
  24378. * Are reflection textures enabled in the application.
  24379. */
  24380. static get ReflectionTextureEnabled(): boolean;
  24381. static set ReflectionTextureEnabled(value: boolean);
  24382. /**
  24383. * Are emissive textures enabled in the application.
  24384. */
  24385. static get EmissiveTextureEnabled(): boolean;
  24386. static set EmissiveTextureEnabled(value: boolean);
  24387. /**
  24388. * Are specular textures enabled in the application.
  24389. */
  24390. static get SpecularTextureEnabled(): boolean;
  24391. static set SpecularTextureEnabled(value: boolean);
  24392. /**
  24393. * Are bump textures enabled in the application.
  24394. */
  24395. static get BumpTextureEnabled(): boolean;
  24396. static set BumpTextureEnabled(value: boolean);
  24397. /**
  24398. * Are lightmap textures enabled in the application.
  24399. */
  24400. static get LightmapTextureEnabled(): boolean;
  24401. static set LightmapTextureEnabled(value: boolean);
  24402. /**
  24403. * Are refraction textures enabled in the application.
  24404. */
  24405. static get RefractionTextureEnabled(): boolean;
  24406. static set RefractionTextureEnabled(value: boolean);
  24407. /**
  24408. * Are color grading textures enabled in the application.
  24409. */
  24410. static get ColorGradingTextureEnabled(): boolean;
  24411. static set ColorGradingTextureEnabled(value: boolean);
  24412. /**
  24413. * Are fresnels enabled in the application.
  24414. */
  24415. static get FresnelEnabled(): boolean;
  24416. static set FresnelEnabled(value: boolean);
  24417. }
  24418. }
  24419. declare module BABYLON {
  24420. /** @hidden */
  24421. export var rgbdDecodePixelShader: {
  24422. name: string;
  24423. shader: string;
  24424. };
  24425. }
  24426. declare module BABYLON {
  24427. /**
  24428. * Class used to host RGBD texture specific utilities
  24429. */
  24430. export class RGBDTextureTools {
  24431. /**
  24432. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24433. * @param texture the texture to expand.
  24434. */
  24435. static ExpandRGBDTexture(texture: Texture): void;
  24436. }
  24437. }
  24438. declare module BABYLON {
  24439. /**
  24440. * Class used to host texture specific utilities
  24441. */
  24442. export class BRDFTextureTools {
  24443. /**
  24444. * Prevents texture cache collision
  24445. */
  24446. private static _instanceNumber;
  24447. /**
  24448. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24449. * @param scene defines the hosting scene
  24450. * @returns the environment BRDF texture
  24451. */
  24452. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24453. private static _environmentBRDFBase64Texture;
  24454. }
  24455. }
  24456. declare module BABYLON {
  24457. /**
  24458. * @hidden
  24459. */
  24460. export interface IMaterialClearCoatDefines {
  24461. CLEARCOAT: boolean;
  24462. CLEARCOAT_DEFAULTIOR: boolean;
  24463. CLEARCOAT_TEXTURE: boolean;
  24464. CLEARCOAT_TEXTUREDIRECTUV: number;
  24465. CLEARCOAT_BUMP: boolean;
  24466. CLEARCOAT_BUMPDIRECTUV: number;
  24467. CLEARCOAT_REMAP_F0: boolean;
  24468. CLEARCOAT_TINT: boolean;
  24469. CLEARCOAT_TINT_TEXTURE: boolean;
  24470. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24471. /** @hidden */
  24472. _areTexturesDirty: boolean;
  24473. }
  24474. /**
  24475. * Define the code related to the clear coat parameters of the pbr material.
  24476. */
  24477. export class PBRClearCoatConfiguration {
  24478. /**
  24479. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24480. * The default fits with a polyurethane material.
  24481. */
  24482. private static readonly _DefaultIndexOfRefraction;
  24483. private _isEnabled;
  24484. /**
  24485. * Defines if the clear coat is enabled in the material.
  24486. */
  24487. isEnabled: boolean;
  24488. /**
  24489. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24490. */
  24491. intensity: number;
  24492. /**
  24493. * Defines the clear coat layer roughness.
  24494. */
  24495. roughness: number;
  24496. private _indexOfRefraction;
  24497. /**
  24498. * Defines the index of refraction of the clear coat.
  24499. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24500. * The default fits with a polyurethane material.
  24501. * Changing the default value is more performance intensive.
  24502. */
  24503. indexOfRefraction: number;
  24504. private _texture;
  24505. /**
  24506. * Stores the clear coat values in a texture.
  24507. */
  24508. texture: Nullable<BaseTexture>;
  24509. private _remapF0OnInterfaceChange;
  24510. /**
  24511. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24512. */
  24513. remapF0OnInterfaceChange: boolean;
  24514. private _bumpTexture;
  24515. /**
  24516. * Define the clear coat specific bump texture.
  24517. */
  24518. bumpTexture: Nullable<BaseTexture>;
  24519. private _isTintEnabled;
  24520. /**
  24521. * Defines if the clear coat tint is enabled in the material.
  24522. */
  24523. isTintEnabled: boolean;
  24524. /**
  24525. * Defines the clear coat tint of the material.
  24526. * This is only use if tint is enabled
  24527. */
  24528. tintColor: Color3;
  24529. /**
  24530. * Defines the distance at which the tint color should be found in the
  24531. * clear coat media.
  24532. * This is only use if tint is enabled
  24533. */
  24534. tintColorAtDistance: number;
  24535. /**
  24536. * Defines the clear coat layer thickness.
  24537. * This is only use if tint is enabled
  24538. */
  24539. tintThickness: number;
  24540. private _tintTexture;
  24541. /**
  24542. * Stores the clear tint values in a texture.
  24543. * rgb is tint
  24544. * a is a thickness factor
  24545. */
  24546. tintTexture: Nullable<BaseTexture>;
  24547. /** @hidden */
  24548. private _internalMarkAllSubMeshesAsTexturesDirty;
  24549. /** @hidden */
  24550. _markAllSubMeshesAsTexturesDirty(): void;
  24551. /**
  24552. * Instantiate a new istance of clear coat configuration.
  24553. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24554. */
  24555. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24556. /**
  24557. * Gets wehter the submesh is ready to be used or not.
  24558. * @param defines the list of "defines" to update.
  24559. * @param scene defines the scene the material belongs to.
  24560. * @param engine defines the engine the material belongs to.
  24561. * @param disableBumpMap defines wether the material disables bump or not.
  24562. * @returns - boolean indicating that the submesh is ready or not.
  24563. */
  24564. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24565. /**
  24566. * Checks to see if a texture is used in the material.
  24567. * @param defines the list of "defines" to update.
  24568. * @param scene defines the scene to the material belongs to.
  24569. */
  24570. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24571. /**
  24572. * Binds the material data.
  24573. * @param uniformBuffer defines the Uniform buffer to fill in.
  24574. * @param scene defines the scene the material belongs to.
  24575. * @param engine defines the engine the material belongs to.
  24576. * @param disableBumpMap defines wether the material disables bump or not.
  24577. * @param isFrozen defines wether the material is frozen or not.
  24578. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24579. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24580. */
  24581. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  24582. /**
  24583. * Checks to see if a texture is used in the material.
  24584. * @param texture - Base texture to use.
  24585. * @returns - Boolean specifying if a texture is used in the material.
  24586. */
  24587. hasTexture(texture: BaseTexture): boolean;
  24588. /**
  24589. * Returns an array of the actively used textures.
  24590. * @param activeTextures Array of BaseTextures
  24591. */
  24592. getActiveTextures(activeTextures: BaseTexture[]): void;
  24593. /**
  24594. * Returns the animatable textures.
  24595. * @param animatables Array of animatable textures.
  24596. */
  24597. getAnimatables(animatables: IAnimatable[]): void;
  24598. /**
  24599. * Disposes the resources of the material.
  24600. * @param forceDisposeTextures - Forces the disposal of all textures.
  24601. */
  24602. dispose(forceDisposeTextures?: boolean): void;
  24603. /**
  24604. * Get the current class name of the texture useful for serialization or dynamic coding.
  24605. * @returns "PBRClearCoatConfiguration"
  24606. */
  24607. getClassName(): string;
  24608. /**
  24609. * Add fallbacks to the effect fallbacks list.
  24610. * @param defines defines the Base texture to use.
  24611. * @param fallbacks defines the current fallback list.
  24612. * @param currentRank defines the current fallback rank.
  24613. * @returns the new fallback rank.
  24614. */
  24615. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24616. /**
  24617. * Add the required uniforms to the current list.
  24618. * @param uniforms defines the current uniform list.
  24619. */
  24620. static AddUniforms(uniforms: string[]): void;
  24621. /**
  24622. * Add the required samplers to the current list.
  24623. * @param samplers defines the current sampler list.
  24624. */
  24625. static AddSamplers(samplers: string[]): void;
  24626. /**
  24627. * Add the required uniforms to the current buffer.
  24628. * @param uniformBuffer defines the current uniform buffer.
  24629. */
  24630. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24631. /**
  24632. * Makes a duplicate of the current configuration into another one.
  24633. * @param clearCoatConfiguration define the config where to copy the info
  24634. */
  24635. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24636. /**
  24637. * Serializes this clear coat configuration.
  24638. * @returns - An object with the serialized config.
  24639. */
  24640. serialize(): any;
  24641. /**
  24642. * Parses a anisotropy Configuration from a serialized object.
  24643. * @param source - Serialized object.
  24644. * @param scene Defines the scene we are parsing for
  24645. * @param rootUrl Defines the rootUrl to load from
  24646. */
  24647. parse(source: any, scene: Scene, rootUrl: string): void;
  24648. }
  24649. }
  24650. declare module BABYLON {
  24651. /**
  24652. * @hidden
  24653. */
  24654. export interface IMaterialAnisotropicDefines {
  24655. ANISOTROPIC: boolean;
  24656. ANISOTROPIC_TEXTURE: boolean;
  24657. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24658. MAINUV1: boolean;
  24659. _areTexturesDirty: boolean;
  24660. _needUVs: boolean;
  24661. }
  24662. /**
  24663. * Define the code related to the anisotropic parameters of the pbr material.
  24664. */
  24665. export class PBRAnisotropicConfiguration {
  24666. private _isEnabled;
  24667. /**
  24668. * Defines if the anisotropy is enabled in the material.
  24669. */
  24670. isEnabled: boolean;
  24671. /**
  24672. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  24673. */
  24674. intensity: number;
  24675. /**
  24676. * Defines if the effect is along the tangents, bitangents or in between.
  24677. * By default, the effect is "strectching" the highlights along the tangents.
  24678. */
  24679. direction: Vector2;
  24680. private _texture;
  24681. /**
  24682. * Stores the anisotropy values in a texture.
  24683. * rg is direction (like normal from -1 to 1)
  24684. * b is a intensity
  24685. */
  24686. texture: Nullable<BaseTexture>;
  24687. /** @hidden */
  24688. private _internalMarkAllSubMeshesAsTexturesDirty;
  24689. /** @hidden */
  24690. _markAllSubMeshesAsTexturesDirty(): void;
  24691. /**
  24692. * Instantiate a new istance of anisotropy configuration.
  24693. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24694. */
  24695. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24696. /**
  24697. * Specifies that the submesh is ready to be used.
  24698. * @param defines the list of "defines" to update.
  24699. * @param scene defines the scene the material belongs to.
  24700. * @returns - boolean indicating that the submesh is ready or not.
  24701. */
  24702. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  24703. /**
  24704. * Checks to see if a texture is used in the material.
  24705. * @param defines the list of "defines" to update.
  24706. * @param mesh the mesh we are preparing the defines for.
  24707. * @param scene defines the scene the material belongs to.
  24708. */
  24709. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  24710. /**
  24711. * Binds the material data.
  24712. * @param uniformBuffer defines the Uniform buffer to fill in.
  24713. * @param scene defines the scene the material belongs to.
  24714. * @param isFrozen defines wether the material is frozen or not.
  24715. */
  24716. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24717. /**
  24718. * Checks to see if a texture is used in the material.
  24719. * @param texture - Base texture to use.
  24720. * @returns - Boolean specifying if a texture is used in the material.
  24721. */
  24722. hasTexture(texture: BaseTexture): boolean;
  24723. /**
  24724. * Returns an array of the actively used textures.
  24725. * @param activeTextures Array of BaseTextures
  24726. */
  24727. getActiveTextures(activeTextures: BaseTexture[]): void;
  24728. /**
  24729. * Returns the animatable textures.
  24730. * @param animatables Array of animatable textures.
  24731. */
  24732. getAnimatables(animatables: IAnimatable[]): void;
  24733. /**
  24734. * Disposes the resources of the material.
  24735. * @param forceDisposeTextures - Forces the disposal of all textures.
  24736. */
  24737. dispose(forceDisposeTextures?: boolean): void;
  24738. /**
  24739. * Get the current class name of the texture useful for serialization or dynamic coding.
  24740. * @returns "PBRAnisotropicConfiguration"
  24741. */
  24742. getClassName(): string;
  24743. /**
  24744. * Add fallbacks to the effect fallbacks list.
  24745. * @param defines defines the Base texture to use.
  24746. * @param fallbacks defines the current fallback list.
  24747. * @param currentRank defines the current fallback rank.
  24748. * @returns the new fallback rank.
  24749. */
  24750. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24751. /**
  24752. * Add the required uniforms to the current list.
  24753. * @param uniforms defines the current uniform list.
  24754. */
  24755. static AddUniforms(uniforms: string[]): void;
  24756. /**
  24757. * Add the required uniforms to the current buffer.
  24758. * @param uniformBuffer defines the current uniform buffer.
  24759. */
  24760. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24761. /**
  24762. * Add the required samplers to the current list.
  24763. * @param samplers defines the current sampler list.
  24764. */
  24765. static AddSamplers(samplers: string[]): void;
  24766. /**
  24767. * Makes a duplicate of the current configuration into another one.
  24768. * @param anisotropicConfiguration define the config where to copy the info
  24769. */
  24770. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  24771. /**
  24772. * Serializes this anisotropy configuration.
  24773. * @returns - An object with the serialized config.
  24774. */
  24775. serialize(): any;
  24776. /**
  24777. * Parses a anisotropy Configuration from a serialized object.
  24778. * @param source - Serialized object.
  24779. * @param scene Defines the scene we are parsing for
  24780. * @param rootUrl Defines the rootUrl to load from
  24781. */
  24782. parse(source: any, scene: Scene, rootUrl: string): void;
  24783. }
  24784. }
  24785. declare module BABYLON {
  24786. /**
  24787. * @hidden
  24788. */
  24789. export interface IMaterialBRDFDefines {
  24790. BRDF_V_HEIGHT_CORRELATED: boolean;
  24791. MS_BRDF_ENERGY_CONSERVATION: boolean;
  24792. SPHERICAL_HARMONICS: boolean;
  24793. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  24794. /** @hidden */
  24795. _areMiscDirty: boolean;
  24796. }
  24797. /**
  24798. * Define the code related to the BRDF parameters of the pbr material.
  24799. */
  24800. export class PBRBRDFConfiguration {
  24801. /**
  24802. * Default value used for the energy conservation.
  24803. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24804. */
  24805. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  24806. /**
  24807. * Default value used for the Smith Visibility Height Correlated mode.
  24808. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24809. */
  24810. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  24811. /**
  24812. * Default value used for the IBL diffuse part.
  24813. * This can help switching back to the polynomials mode globally which is a tiny bit
  24814. * less GPU intensive at the drawback of a lower quality.
  24815. */
  24816. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  24817. /**
  24818. * Default value used for activating energy conservation for the specular workflow.
  24819. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24820. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24821. */
  24822. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  24823. private _useEnergyConservation;
  24824. /**
  24825. * Defines if the material uses energy conservation.
  24826. */
  24827. useEnergyConservation: boolean;
  24828. private _useSmithVisibilityHeightCorrelated;
  24829. /**
  24830. * LEGACY Mode set to false
  24831. * Defines if the material uses height smith correlated visibility term.
  24832. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  24833. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  24834. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  24835. * Not relying on height correlated will also disable energy conservation.
  24836. */
  24837. useSmithVisibilityHeightCorrelated: boolean;
  24838. private _useSphericalHarmonics;
  24839. /**
  24840. * LEGACY Mode set to false
  24841. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  24842. * diffuse part of the IBL.
  24843. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  24844. * to the ground truth.
  24845. */
  24846. useSphericalHarmonics: boolean;
  24847. private _useSpecularGlossinessInputEnergyConservation;
  24848. /**
  24849. * Defines if the material uses energy conservation, when the specular workflow is active.
  24850. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24851. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24852. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  24853. */
  24854. useSpecularGlossinessInputEnergyConservation: boolean;
  24855. /** @hidden */
  24856. private _internalMarkAllSubMeshesAsMiscDirty;
  24857. /** @hidden */
  24858. _markAllSubMeshesAsMiscDirty(): void;
  24859. /**
  24860. * Instantiate a new istance of clear coat configuration.
  24861. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  24862. */
  24863. constructor(markAllSubMeshesAsMiscDirty: () => void);
  24864. /**
  24865. * Checks to see if a texture is used in the material.
  24866. * @param defines the list of "defines" to update.
  24867. */
  24868. prepareDefines(defines: IMaterialBRDFDefines): void;
  24869. /**
  24870. * Get the current class name of the texture useful for serialization or dynamic coding.
  24871. * @returns "PBRClearCoatConfiguration"
  24872. */
  24873. getClassName(): string;
  24874. /**
  24875. * Makes a duplicate of the current configuration into another one.
  24876. * @param brdfConfiguration define the config where to copy the info
  24877. */
  24878. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  24879. /**
  24880. * Serializes this BRDF configuration.
  24881. * @returns - An object with the serialized config.
  24882. */
  24883. serialize(): any;
  24884. /**
  24885. * Parses a anisotropy Configuration from a serialized object.
  24886. * @param source - Serialized object.
  24887. * @param scene Defines the scene we are parsing for
  24888. * @param rootUrl Defines the rootUrl to load from
  24889. */
  24890. parse(source: any, scene: Scene, rootUrl: string): void;
  24891. }
  24892. }
  24893. declare module BABYLON {
  24894. /**
  24895. * @hidden
  24896. */
  24897. export interface IMaterialSheenDefines {
  24898. SHEEN: boolean;
  24899. SHEEN_TEXTURE: boolean;
  24900. SHEEN_TEXTUREDIRECTUV: number;
  24901. SHEEN_LINKWITHALBEDO: boolean;
  24902. SHEEN_ROUGHNESS: boolean;
  24903. SHEEN_ALBEDOSCALING: boolean;
  24904. /** @hidden */
  24905. _areTexturesDirty: boolean;
  24906. }
  24907. /**
  24908. * Define the code related to the Sheen parameters of the pbr material.
  24909. */
  24910. export class PBRSheenConfiguration {
  24911. private _isEnabled;
  24912. /**
  24913. * Defines if the material uses sheen.
  24914. */
  24915. isEnabled: boolean;
  24916. private _linkSheenWithAlbedo;
  24917. /**
  24918. * Defines if the sheen is linked to the sheen color.
  24919. */
  24920. linkSheenWithAlbedo: boolean;
  24921. /**
  24922. * Defines the sheen intensity.
  24923. */
  24924. intensity: number;
  24925. /**
  24926. * Defines the sheen color.
  24927. */
  24928. color: Color3;
  24929. private _texture;
  24930. /**
  24931. * Stores the sheen tint values in a texture.
  24932. * rgb is tint
  24933. * a is a intensity or roughness if roughness has been defined
  24934. */
  24935. texture: Nullable<BaseTexture>;
  24936. private _roughness;
  24937. /**
  24938. * Defines the sheen roughness.
  24939. * It is not taken into account if linkSheenWithAlbedo is true.
  24940. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  24941. */
  24942. roughness: Nullable<number>;
  24943. private _albedoScaling;
  24944. /**
  24945. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  24946. * It allows the strength of the sheen effect to not depend on the base color of the material,
  24947. * making it easier to setup and tweak the effect
  24948. */
  24949. albedoScaling: boolean;
  24950. /** @hidden */
  24951. private _internalMarkAllSubMeshesAsTexturesDirty;
  24952. /** @hidden */
  24953. _markAllSubMeshesAsTexturesDirty(): void;
  24954. /**
  24955. * Instantiate a new istance of clear coat configuration.
  24956. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24957. */
  24958. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24959. /**
  24960. * Specifies that the submesh is ready to be used.
  24961. * @param defines the list of "defines" to update.
  24962. * @param scene defines the scene the material belongs to.
  24963. * @returns - boolean indicating that the submesh is ready or not.
  24964. */
  24965. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  24966. /**
  24967. * Checks to see if a texture is used in the material.
  24968. * @param defines the list of "defines" to update.
  24969. * @param scene defines the scene the material belongs to.
  24970. */
  24971. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  24972. /**
  24973. * Binds the material data.
  24974. * @param uniformBuffer defines the Uniform buffer to fill in.
  24975. * @param scene defines the scene the material belongs to.
  24976. * @param isFrozen defines wether the material is frozen or not.
  24977. */
  24978. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24979. /**
  24980. * Checks to see if a texture is used in the material.
  24981. * @param texture - Base texture to use.
  24982. * @returns - Boolean specifying if a texture is used in the material.
  24983. */
  24984. hasTexture(texture: BaseTexture): boolean;
  24985. /**
  24986. * Returns an array of the actively used textures.
  24987. * @param activeTextures Array of BaseTextures
  24988. */
  24989. getActiveTextures(activeTextures: BaseTexture[]): void;
  24990. /**
  24991. * Returns the animatable textures.
  24992. * @param animatables Array of animatable textures.
  24993. */
  24994. getAnimatables(animatables: IAnimatable[]): void;
  24995. /**
  24996. * Disposes the resources of the material.
  24997. * @param forceDisposeTextures - Forces the disposal of all textures.
  24998. */
  24999. dispose(forceDisposeTextures?: boolean): void;
  25000. /**
  25001. * Get the current class name of the texture useful for serialization or dynamic coding.
  25002. * @returns "PBRSheenConfiguration"
  25003. */
  25004. getClassName(): string;
  25005. /**
  25006. * Add fallbacks to the effect fallbacks list.
  25007. * @param defines defines the Base texture to use.
  25008. * @param fallbacks defines the current fallback list.
  25009. * @param currentRank defines the current fallback rank.
  25010. * @returns the new fallback rank.
  25011. */
  25012. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25013. /**
  25014. * Add the required uniforms to the current list.
  25015. * @param uniforms defines the current uniform list.
  25016. */
  25017. static AddUniforms(uniforms: string[]): void;
  25018. /**
  25019. * Add the required uniforms to the current buffer.
  25020. * @param uniformBuffer defines the current uniform buffer.
  25021. */
  25022. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25023. /**
  25024. * Add the required samplers to the current list.
  25025. * @param samplers defines the current sampler list.
  25026. */
  25027. static AddSamplers(samplers: string[]): void;
  25028. /**
  25029. * Makes a duplicate of the current configuration into another one.
  25030. * @param sheenConfiguration define the config where to copy the info
  25031. */
  25032. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25033. /**
  25034. * Serializes this BRDF configuration.
  25035. * @returns - An object with the serialized config.
  25036. */
  25037. serialize(): any;
  25038. /**
  25039. * Parses a anisotropy Configuration from a serialized object.
  25040. * @param source - Serialized object.
  25041. * @param scene Defines the scene we are parsing for
  25042. * @param rootUrl Defines the rootUrl to load from
  25043. */
  25044. parse(source: any, scene: Scene, rootUrl: string): void;
  25045. }
  25046. }
  25047. declare module BABYLON {
  25048. /**
  25049. * @hidden
  25050. */
  25051. export interface IMaterialSubSurfaceDefines {
  25052. SUBSURFACE: boolean;
  25053. SS_REFRACTION: boolean;
  25054. SS_TRANSLUCENCY: boolean;
  25055. SS_SCATTERING: boolean;
  25056. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25057. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25058. SS_REFRACTIONMAP_3D: boolean;
  25059. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25060. SS_LODINREFRACTIONALPHA: boolean;
  25061. SS_GAMMAREFRACTION: boolean;
  25062. SS_RGBDREFRACTION: boolean;
  25063. SS_LINEARSPECULARREFRACTION: boolean;
  25064. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25065. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25066. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25067. /** @hidden */
  25068. _areTexturesDirty: boolean;
  25069. }
  25070. /**
  25071. * Define the code related to the sub surface parameters of the pbr material.
  25072. */
  25073. export class PBRSubSurfaceConfiguration {
  25074. private _isRefractionEnabled;
  25075. /**
  25076. * Defines if the refraction is enabled in the material.
  25077. */
  25078. isRefractionEnabled: boolean;
  25079. private _isTranslucencyEnabled;
  25080. /**
  25081. * Defines if the translucency is enabled in the material.
  25082. */
  25083. isTranslucencyEnabled: boolean;
  25084. private _isScatteringEnabled;
  25085. /**
  25086. * Defines if the sub surface scattering is enabled in the material.
  25087. */
  25088. isScatteringEnabled: boolean;
  25089. private _scatteringDiffusionProfileIndex;
  25090. /**
  25091. * Diffusion profile for subsurface scattering.
  25092. * Useful for better scattering in the skins or foliages.
  25093. */
  25094. get scatteringDiffusionProfile(): Nullable<Color3>;
  25095. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25096. /**
  25097. * Defines the refraction intensity of the material.
  25098. * The refraction when enabled replaces the Diffuse part of the material.
  25099. * The intensity helps transitionning between diffuse and refraction.
  25100. */
  25101. refractionIntensity: number;
  25102. /**
  25103. * Defines the translucency intensity of the material.
  25104. * When translucency has been enabled, this defines how much of the "translucency"
  25105. * is addded to the diffuse part of the material.
  25106. */
  25107. translucencyIntensity: number;
  25108. /**
  25109. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25110. */
  25111. useAlbedoToTintRefraction: boolean;
  25112. private _thicknessTexture;
  25113. /**
  25114. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25115. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25116. * 0 would mean minimumThickness
  25117. * 1 would mean maximumThickness
  25118. * The other channels might be use as a mask to vary the different effects intensity.
  25119. */
  25120. thicknessTexture: Nullable<BaseTexture>;
  25121. private _refractionTexture;
  25122. /**
  25123. * Defines the texture to use for refraction.
  25124. */
  25125. refractionTexture: Nullable<BaseTexture>;
  25126. private _indexOfRefraction;
  25127. /**
  25128. * Index of refraction of the material base layer.
  25129. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25130. *
  25131. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25132. *
  25133. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25134. */
  25135. indexOfRefraction: number;
  25136. private _volumeIndexOfRefraction;
  25137. /**
  25138. * Index of refraction of the material's volume.
  25139. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25140. *
  25141. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25142. * the volume will use the same IOR as the surface.
  25143. */
  25144. get volumeIndexOfRefraction(): number;
  25145. set volumeIndexOfRefraction(value: number);
  25146. private _invertRefractionY;
  25147. /**
  25148. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25149. */
  25150. invertRefractionY: boolean;
  25151. private _linkRefractionWithTransparency;
  25152. /**
  25153. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25154. * Materials half opaque for instance using refraction could benefit from this control.
  25155. */
  25156. linkRefractionWithTransparency: boolean;
  25157. /**
  25158. * Defines the minimum thickness stored in the thickness map.
  25159. * If no thickness map is defined, this value will be used to simulate thickness.
  25160. */
  25161. minimumThickness: number;
  25162. /**
  25163. * Defines the maximum thickness stored in the thickness map.
  25164. */
  25165. maximumThickness: number;
  25166. /**
  25167. * Defines the volume tint of the material.
  25168. * This is used for both translucency and scattering.
  25169. */
  25170. tintColor: Color3;
  25171. /**
  25172. * Defines the distance at which the tint color should be found in the media.
  25173. * This is used for refraction only.
  25174. */
  25175. tintColorAtDistance: number;
  25176. /**
  25177. * Defines how far each channel transmit through the media.
  25178. * It is defined as a color to simplify it selection.
  25179. */
  25180. diffusionDistance: Color3;
  25181. private _useMaskFromThicknessTexture;
  25182. /**
  25183. * Stores the intensity of the different subsurface effects in the thickness texture.
  25184. * * the green channel is the translucency intensity.
  25185. * * the blue channel is the scattering intensity.
  25186. * * the alpha channel is the refraction intensity.
  25187. */
  25188. useMaskFromThicknessTexture: boolean;
  25189. private _scene;
  25190. /** @hidden */
  25191. private _internalMarkAllSubMeshesAsTexturesDirty;
  25192. private _internalMarkScenePrePassDirty;
  25193. /** @hidden */
  25194. _markAllSubMeshesAsTexturesDirty(): void;
  25195. /** @hidden */
  25196. _markScenePrePassDirty(): void;
  25197. /**
  25198. * Instantiate a new istance of sub surface configuration.
  25199. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25200. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25201. * @param scene The scene
  25202. */
  25203. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25204. /**
  25205. * Gets wehter the submesh is ready to be used or not.
  25206. * @param defines the list of "defines" to update.
  25207. * @param scene defines the scene the material belongs to.
  25208. * @returns - boolean indicating that the submesh is ready or not.
  25209. */
  25210. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25211. /**
  25212. * Checks to see if a texture is used in the material.
  25213. * @param defines the list of "defines" to update.
  25214. * @param scene defines the scene to the material belongs to.
  25215. */
  25216. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25217. /**
  25218. * Binds the material data.
  25219. * @param uniformBuffer defines the Uniform buffer to fill in.
  25220. * @param scene defines the scene the material belongs to.
  25221. * @param engine defines the engine the material belongs to.
  25222. * @param isFrozen defines whether the material is frozen or not.
  25223. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25224. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25225. */
  25226. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25227. /**
  25228. * Unbinds the material from the mesh.
  25229. * @param activeEffect defines the effect that should be unbound from.
  25230. * @returns true if unbound, otherwise false
  25231. */
  25232. unbind(activeEffect: Effect): boolean;
  25233. /**
  25234. * Returns the texture used for refraction or null if none is used.
  25235. * @param scene defines the scene the material belongs to.
  25236. * @returns - Refraction texture if present. If no refraction texture and refraction
  25237. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25238. */
  25239. private _getRefractionTexture;
  25240. /**
  25241. * Returns true if alpha blending should be disabled.
  25242. */
  25243. get disableAlphaBlending(): boolean;
  25244. /**
  25245. * Fills the list of render target textures.
  25246. * @param renderTargets the list of render targets to update
  25247. */
  25248. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25249. /**
  25250. * Checks to see if a texture is used in the material.
  25251. * @param texture - Base texture to use.
  25252. * @returns - Boolean specifying if a texture is used in the material.
  25253. */
  25254. hasTexture(texture: BaseTexture): boolean;
  25255. /**
  25256. * Gets a boolean indicating that current material needs to register RTT
  25257. * @returns true if this uses a render target otherwise false.
  25258. */
  25259. hasRenderTargetTextures(): boolean;
  25260. /**
  25261. * Returns an array of the actively used textures.
  25262. * @param activeTextures Array of BaseTextures
  25263. */
  25264. getActiveTextures(activeTextures: BaseTexture[]): void;
  25265. /**
  25266. * Returns the animatable textures.
  25267. * @param animatables Array of animatable textures.
  25268. */
  25269. getAnimatables(animatables: IAnimatable[]): void;
  25270. /**
  25271. * Disposes the resources of the material.
  25272. * @param forceDisposeTextures - Forces the disposal of all textures.
  25273. */
  25274. dispose(forceDisposeTextures?: boolean): void;
  25275. /**
  25276. * Get the current class name of the texture useful for serialization or dynamic coding.
  25277. * @returns "PBRSubSurfaceConfiguration"
  25278. */
  25279. getClassName(): string;
  25280. /**
  25281. * Add fallbacks to the effect fallbacks list.
  25282. * @param defines defines the Base texture to use.
  25283. * @param fallbacks defines the current fallback list.
  25284. * @param currentRank defines the current fallback rank.
  25285. * @returns the new fallback rank.
  25286. */
  25287. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25288. /**
  25289. * Add the required uniforms to the current list.
  25290. * @param uniforms defines the current uniform list.
  25291. */
  25292. static AddUniforms(uniforms: string[]): void;
  25293. /**
  25294. * Add the required samplers to the current list.
  25295. * @param samplers defines the current sampler list.
  25296. */
  25297. static AddSamplers(samplers: string[]): void;
  25298. /**
  25299. * Add the required uniforms to the current buffer.
  25300. * @param uniformBuffer defines the current uniform buffer.
  25301. */
  25302. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25303. /**
  25304. * Makes a duplicate of the current configuration into another one.
  25305. * @param configuration define the config where to copy the info
  25306. */
  25307. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25308. /**
  25309. * Serializes this Sub Surface configuration.
  25310. * @returns - An object with the serialized config.
  25311. */
  25312. serialize(): any;
  25313. /**
  25314. * Parses a anisotropy Configuration from a serialized object.
  25315. * @param source - Serialized object.
  25316. * @param scene Defines the scene we are parsing for
  25317. * @param rootUrl Defines the rootUrl to load from
  25318. */
  25319. parse(source: any, scene: Scene, rootUrl: string): void;
  25320. }
  25321. }
  25322. declare module BABYLON {
  25323. /**
  25324. * Class representing spherical harmonics coefficients to the 3rd degree
  25325. */
  25326. export class SphericalHarmonics {
  25327. /**
  25328. * Defines whether or not the harmonics have been prescaled for rendering.
  25329. */
  25330. preScaled: boolean;
  25331. /**
  25332. * The l0,0 coefficients of the spherical harmonics
  25333. */
  25334. l00: Vector3;
  25335. /**
  25336. * The l1,-1 coefficients of the spherical harmonics
  25337. */
  25338. l1_1: Vector3;
  25339. /**
  25340. * The l1,0 coefficients of the spherical harmonics
  25341. */
  25342. l10: Vector3;
  25343. /**
  25344. * The l1,1 coefficients of the spherical harmonics
  25345. */
  25346. l11: Vector3;
  25347. /**
  25348. * The l2,-2 coefficients of the spherical harmonics
  25349. */
  25350. l2_2: Vector3;
  25351. /**
  25352. * The l2,-1 coefficients of the spherical harmonics
  25353. */
  25354. l2_1: Vector3;
  25355. /**
  25356. * The l2,0 coefficients of the spherical harmonics
  25357. */
  25358. l20: Vector3;
  25359. /**
  25360. * The l2,1 coefficients of the spherical harmonics
  25361. */
  25362. l21: Vector3;
  25363. /**
  25364. * The l2,2 coefficients of the spherical harmonics
  25365. */
  25366. l22: Vector3;
  25367. /**
  25368. * Adds a light to the spherical harmonics
  25369. * @param direction the direction of the light
  25370. * @param color the color of the light
  25371. * @param deltaSolidAngle the delta solid angle of the light
  25372. */
  25373. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25374. /**
  25375. * Scales the spherical harmonics by the given amount
  25376. * @param scale the amount to scale
  25377. */
  25378. scaleInPlace(scale: number): void;
  25379. /**
  25380. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25381. *
  25382. * ```
  25383. * E_lm = A_l * L_lm
  25384. * ```
  25385. *
  25386. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25387. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25388. * the scaling factors are given in equation 9.
  25389. */
  25390. convertIncidentRadianceToIrradiance(): void;
  25391. /**
  25392. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25393. *
  25394. * ```
  25395. * L = (1/pi) * E * rho
  25396. * ```
  25397. *
  25398. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25399. */
  25400. convertIrradianceToLambertianRadiance(): void;
  25401. /**
  25402. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25403. * required operations at run time.
  25404. *
  25405. * This is simply done by scaling back the SH with Ylm constants parameter.
  25406. * The trigonometric part being applied by the shader at run time.
  25407. */
  25408. preScaleForRendering(): void;
  25409. /**
  25410. * Constructs a spherical harmonics from an array.
  25411. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25412. * @returns the spherical harmonics
  25413. */
  25414. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25415. /**
  25416. * Gets the spherical harmonics from polynomial
  25417. * @param polynomial the spherical polynomial
  25418. * @returns the spherical harmonics
  25419. */
  25420. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25421. }
  25422. /**
  25423. * Class representing spherical polynomial coefficients to the 3rd degree
  25424. */
  25425. export class SphericalPolynomial {
  25426. private _harmonics;
  25427. /**
  25428. * The spherical harmonics used to create the polynomials.
  25429. */
  25430. get preScaledHarmonics(): SphericalHarmonics;
  25431. /**
  25432. * The x coefficients of the spherical polynomial
  25433. */
  25434. x: Vector3;
  25435. /**
  25436. * The y coefficients of the spherical polynomial
  25437. */
  25438. y: Vector3;
  25439. /**
  25440. * The z coefficients of the spherical polynomial
  25441. */
  25442. z: Vector3;
  25443. /**
  25444. * The xx coefficients of the spherical polynomial
  25445. */
  25446. xx: Vector3;
  25447. /**
  25448. * The yy coefficients of the spherical polynomial
  25449. */
  25450. yy: Vector3;
  25451. /**
  25452. * The zz coefficients of the spherical polynomial
  25453. */
  25454. zz: Vector3;
  25455. /**
  25456. * The xy coefficients of the spherical polynomial
  25457. */
  25458. xy: Vector3;
  25459. /**
  25460. * The yz coefficients of the spherical polynomial
  25461. */
  25462. yz: Vector3;
  25463. /**
  25464. * The zx coefficients of the spherical polynomial
  25465. */
  25466. zx: Vector3;
  25467. /**
  25468. * Adds an ambient color to the spherical polynomial
  25469. * @param color the color to add
  25470. */
  25471. addAmbient(color: Color3): void;
  25472. /**
  25473. * Scales the spherical polynomial by the given amount
  25474. * @param scale the amount to scale
  25475. */
  25476. scaleInPlace(scale: number): void;
  25477. /**
  25478. * Gets the spherical polynomial from harmonics
  25479. * @param harmonics the spherical harmonics
  25480. * @returns the spherical polynomial
  25481. */
  25482. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25483. /**
  25484. * Constructs a spherical polynomial from an array.
  25485. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25486. * @returns the spherical polynomial
  25487. */
  25488. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25489. }
  25490. }
  25491. declare module BABYLON {
  25492. /**
  25493. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25494. */
  25495. export interface CubeMapInfo {
  25496. /**
  25497. * The pixel array for the front face.
  25498. * This is stored in format, left to right, up to down format.
  25499. */
  25500. front: Nullable<ArrayBufferView>;
  25501. /**
  25502. * The pixel array for the back face.
  25503. * This is stored in format, left to right, up to down format.
  25504. */
  25505. back: Nullable<ArrayBufferView>;
  25506. /**
  25507. * The pixel array for the left face.
  25508. * This is stored in format, left to right, up to down format.
  25509. */
  25510. left: Nullable<ArrayBufferView>;
  25511. /**
  25512. * The pixel array for the right face.
  25513. * This is stored in format, left to right, up to down format.
  25514. */
  25515. right: Nullable<ArrayBufferView>;
  25516. /**
  25517. * The pixel array for the up face.
  25518. * This is stored in format, left to right, up to down format.
  25519. */
  25520. up: Nullable<ArrayBufferView>;
  25521. /**
  25522. * The pixel array for the down face.
  25523. * This is stored in format, left to right, up to down format.
  25524. */
  25525. down: Nullable<ArrayBufferView>;
  25526. /**
  25527. * The size of the cubemap stored.
  25528. *
  25529. * Each faces will be size * size pixels.
  25530. */
  25531. size: number;
  25532. /**
  25533. * The format of the texture.
  25534. *
  25535. * RGBA, RGB.
  25536. */
  25537. format: number;
  25538. /**
  25539. * The type of the texture data.
  25540. *
  25541. * UNSIGNED_INT, FLOAT.
  25542. */
  25543. type: number;
  25544. /**
  25545. * Specifies whether the texture is in gamma space.
  25546. */
  25547. gammaSpace: boolean;
  25548. }
  25549. /**
  25550. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25551. */
  25552. export class PanoramaToCubeMapTools {
  25553. private static FACE_LEFT;
  25554. private static FACE_RIGHT;
  25555. private static FACE_FRONT;
  25556. private static FACE_BACK;
  25557. private static FACE_DOWN;
  25558. private static FACE_UP;
  25559. /**
  25560. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25561. *
  25562. * @param float32Array The source data.
  25563. * @param inputWidth The width of the input panorama.
  25564. * @param inputHeight The height of the input panorama.
  25565. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25566. * @return The cubemap data
  25567. */
  25568. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25569. private static CreateCubemapTexture;
  25570. private static CalcProjectionSpherical;
  25571. }
  25572. }
  25573. declare module BABYLON {
  25574. /**
  25575. * Helper class dealing with the extraction of spherical polynomial dataArray
  25576. * from a cube map.
  25577. */
  25578. export class CubeMapToSphericalPolynomialTools {
  25579. private static FileFaces;
  25580. /**
  25581. * Converts a texture to the according Spherical Polynomial data.
  25582. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25583. *
  25584. * @param texture The texture to extract the information from.
  25585. * @return The Spherical Polynomial data.
  25586. */
  25587. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25588. /**
  25589. * Converts a cubemap to the according Spherical Polynomial data.
  25590. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25591. *
  25592. * @param cubeInfo The Cube map to extract the information from.
  25593. * @return The Spherical Polynomial data.
  25594. */
  25595. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25596. }
  25597. }
  25598. declare module BABYLON {
  25599. interface BaseTexture {
  25600. /**
  25601. * Get the polynomial representation of the texture data.
  25602. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25603. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25604. */
  25605. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25606. }
  25607. }
  25608. declare module BABYLON {
  25609. /** @hidden */
  25610. export var pbrFragmentDeclaration: {
  25611. name: string;
  25612. shader: string;
  25613. };
  25614. }
  25615. declare module BABYLON {
  25616. /** @hidden */
  25617. export var pbrUboDeclaration: {
  25618. name: string;
  25619. shader: string;
  25620. };
  25621. }
  25622. declare module BABYLON {
  25623. /** @hidden */
  25624. export var pbrFragmentExtraDeclaration: {
  25625. name: string;
  25626. shader: string;
  25627. };
  25628. }
  25629. declare module BABYLON {
  25630. /** @hidden */
  25631. export var pbrFragmentSamplersDeclaration: {
  25632. name: string;
  25633. shader: string;
  25634. };
  25635. }
  25636. declare module BABYLON {
  25637. /** @hidden */
  25638. export var subSurfaceScatteringFunctions: {
  25639. name: string;
  25640. shader: string;
  25641. };
  25642. }
  25643. declare module BABYLON {
  25644. /** @hidden */
  25645. export var importanceSampling: {
  25646. name: string;
  25647. shader: string;
  25648. };
  25649. }
  25650. declare module BABYLON {
  25651. /** @hidden */
  25652. export var pbrHelperFunctions: {
  25653. name: string;
  25654. shader: string;
  25655. };
  25656. }
  25657. declare module BABYLON {
  25658. /** @hidden */
  25659. export var harmonicsFunctions: {
  25660. name: string;
  25661. shader: string;
  25662. };
  25663. }
  25664. declare module BABYLON {
  25665. /** @hidden */
  25666. export var pbrDirectLightingSetupFunctions: {
  25667. name: string;
  25668. shader: string;
  25669. };
  25670. }
  25671. declare module BABYLON {
  25672. /** @hidden */
  25673. export var pbrDirectLightingFalloffFunctions: {
  25674. name: string;
  25675. shader: string;
  25676. };
  25677. }
  25678. declare module BABYLON {
  25679. /** @hidden */
  25680. export var pbrBRDFFunctions: {
  25681. name: string;
  25682. shader: string;
  25683. };
  25684. }
  25685. declare module BABYLON {
  25686. /** @hidden */
  25687. export var hdrFilteringFunctions: {
  25688. name: string;
  25689. shader: string;
  25690. };
  25691. }
  25692. declare module BABYLON {
  25693. /** @hidden */
  25694. export var pbrDirectLightingFunctions: {
  25695. name: string;
  25696. shader: string;
  25697. };
  25698. }
  25699. declare module BABYLON {
  25700. /** @hidden */
  25701. export var pbrIBLFunctions: {
  25702. name: string;
  25703. shader: string;
  25704. };
  25705. }
  25706. declare module BABYLON {
  25707. /** @hidden */
  25708. export var pbrBlockAlbedoOpacity: {
  25709. name: string;
  25710. shader: string;
  25711. };
  25712. }
  25713. declare module BABYLON {
  25714. /** @hidden */
  25715. export var pbrBlockReflectivity: {
  25716. name: string;
  25717. shader: string;
  25718. };
  25719. }
  25720. declare module BABYLON {
  25721. /** @hidden */
  25722. export var pbrBlockAmbientOcclusion: {
  25723. name: string;
  25724. shader: string;
  25725. };
  25726. }
  25727. declare module BABYLON {
  25728. /** @hidden */
  25729. export var pbrBlockAlphaFresnel: {
  25730. name: string;
  25731. shader: string;
  25732. };
  25733. }
  25734. declare module BABYLON {
  25735. /** @hidden */
  25736. export var pbrBlockAnisotropic: {
  25737. name: string;
  25738. shader: string;
  25739. };
  25740. }
  25741. declare module BABYLON {
  25742. /** @hidden */
  25743. export var pbrBlockReflection: {
  25744. name: string;
  25745. shader: string;
  25746. };
  25747. }
  25748. declare module BABYLON {
  25749. /** @hidden */
  25750. export var pbrBlockSheen: {
  25751. name: string;
  25752. shader: string;
  25753. };
  25754. }
  25755. declare module BABYLON {
  25756. /** @hidden */
  25757. export var pbrBlockClearcoat: {
  25758. name: string;
  25759. shader: string;
  25760. };
  25761. }
  25762. declare module BABYLON {
  25763. /** @hidden */
  25764. export var pbrBlockSubSurface: {
  25765. name: string;
  25766. shader: string;
  25767. };
  25768. }
  25769. declare module BABYLON {
  25770. /** @hidden */
  25771. export var pbrBlockNormalGeometric: {
  25772. name: string;
  25773. shader: string;
  25774. };
  25775. }
  25776. declare module BABYLON {
  25777. /** @hidden */
  25778. export var pbrBlockNormalFinal: {
  25779. name: string;
  25780. shader: string;
  25781. };
  25782. }
  25783. declare module BABYLON {
  25784. /** @hidden */
  25785. export var pbrBlockLightmapInit: {
  25786. name: string;
  25787. shader: string;
  25788. };
  25789. }
  25790. declare module BABYLON {
  25791. /** @hidden */
  25792. export var pbrBlockGeometryInfo: {
  25793. name: string;
  25794. shader: string;
  25795. };
  25796. }
  25797. declare module BABYLON {
  25798. /** @hidden */
  25799. export var pbrBlockReflectance0: {
  25800. name: string;
  25801. shader: string;
  25802. };
  25803. }
  25804. declare module BABYLON {
  25805. /** @hidden */
  25806. export var pbrBlockReflectance: {
  25807. name: string;
  25808. shader: string;
  25809. };
  25810. }
  25811. declare module BABYLON {
  25812. /** @hidden */
  25813. export var pbrBlockDirectLighting: {
  25814. name: string;
  25815. shader: string;
  25816. };
  25817. }
  25818. declare module BABYLON {
  25819. /** @hidden */
  25820. export var pbrBlockFinalLitComponents: {
  25821. name: string;
  25822. shader: string;
  25823. };
  25824. }
  25825. declare module BABYLON {
  25826. /** @hidden */
  25827. export var pbrBlockFinalUnlitComponents: {
  25828. name: string;
  25829. shader: string;
  25830. };
  25831. }
  25832. declare module BABYLON {
  25833. /** @hidden */
  25834. export var pbrBlockFinalColorComposition: {
  25835. name: string;
  25836. shader: string;
  25837. };
  25838. }
  25839. declare module BABYLON {
  25840. /** @hidden */
  25841. export var pbrBlockImageProcessing: {
  25842. name: string;
  25843. shader: string;
  25844. };
  25845. }
  25846. declare module BABYLON {
  25847. /** @hidden */
  25848. export var pbrDebug: {
  25849. name: string;
  25850. shader: string;
  25851. };
  25852. }
  25853. declare module BABYLON {
  25854. /** @hidden */
  25855. export var pbrPixelShader: {
  25856. name: string;
  25857. shader: string;
  25858. };
  25859. }
  25860. declare module BABYLON {
  25861. /** @hidden */
  25862. export var pbrVertexDeclaration: {
  25863. name: string;
  25864. shader: string;
  25865. };
  25866. }
  25867. declare module BABYLON {
  25868. /** @hidden */
  25869. export var pbrVertexShader: {
  25870. name: string;
  25871. shader: string;
  25872. };
  25873. }
  25874. declare module BABYLON {
  25875. /**
  25876. * Manages the defines for the PBR Material.
  25877. * @hidden
  25878. */
  25879. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  25880. PBR: boolean;
  25881. NUM_SAMPLES: string;
  25882. REALTIME_FILTERING: boolean;
  25883. MAINUV1: boolean;
  25884. MAINUV2: boolean;
  25885. UV1: boolean;
  25886. UV2: boolean;
  25887. ALBEDO: boolean;
  25888. GAMMAALBEDO: boolean;
  25889. ALBEDODIRECTUV: number;
  25890. VERTEXCOLOR: boolean;
  25891. DETAIL: boolean;
  25892. DETAILDIRECTUV: number;
  25893. DETAIL_NORMALBLENDMETHOD: number;
  25894. AMBIENT: boolean;
  25895. AMBIENTDIRECTUV: number;
  25896. AMBIENTINGRAYSCALE: boolean;
  25897. OPACITY: boolean;
  25898. VERTEXALPHA: boolean;
  25899. OPACITYDIRECTUV: number;
  25900. OPACITYRGB: boolean;
  25901. ALPHATEST: boolean;
  25902. DEPTHPREPASS: boolean;
  25903. ALPHABLEND: boolean;
  25904. ALPHAFROMALBEDO: boolean;
  25905. ALPHATESTVALUE: string;
  25906. SPECULAROVERALPHA: boolean;
  25907. RADIANCEOVERALPHA: boolean;
  25908. ALPHAFRESNEL: boolean;
  25909. LINEARALPHAFRESNEL: boolean;
  25910. PREMULTIPLYALPHA: boolean;
  25911. EMISSIVE: boolean;
  25912. EMISSIVEDIRECTUV: number;
  25913. REFLECTIVITY: boolean;
  25914. REFLECTIVITYDIRECTUV: number;
  25915. SPECULARTERM: boolean;
  25916. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  25917. MICROSURFACEAUTOMATIC: boolean;
  25918. LODBASEDMICROSFURACE: boolean;
  25919. MICROSURFACEMAP: boolean;
  25920. MICROSURFACEMAPDIRECTUV: number;
  25921. METALLICWORKFLOW: boolean;
  25922. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  25923. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  25924. METALLNESSSTOREINMETALMAPBLUE: boolean;
  25925. AOSTOREINMETALMAPRED: boolean;
  25926. METALLIC_REFLECTANCE: boolean;
  25927. METALLIC_REFLECTANCEDIRECTUV: number;
  25928. ENVIRONMENTBRDF: boolean;
  25929. ENVIRONMENTBRDF_RGBD: boolean;
  25930. NORMAL: boolean;
  25931. TANGENT: boolean;
  25932. BUMP: boolean;
  25933. BUMPDIRECTUV: number;
  25934. OBJECTSPACE_NORMALMAP: boolean;
  25935. PARALLAX: boolean;
  25936. PARALLAXOCCLUSION: boolean;
  25937. NORMALXYSCALE: boolean;
  25938. LIGHTMAP: boolean;
  25939. LIGHTMAPDIRECTUV: number;
  25940. USELIGHTMAPASSHADOWMAP: boolean;
  25941. GAMMALIGHTMAP: boolean;
  25942. RGBDLIGHTMAP: boolean;
  25943. REFLECTION: boolean;
  25944. REFLECTIONMAP_3D: boolean;
  25945. REFLECTIONMAP_SPHERICAL: boolean;
  25946. REFLECTIONMAP_PLANAR: boolean;
  25947. REFLECTIONMAP_CUBIC: boolean;
  25948. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25949. REFLECTIONMAP_PROJECTION: boolean;
  25950. REFLECTIONMAP_SKYBOX: boolean;
  25951. REFLECTIONMAP_EXPLICIT: boolean;
  25952. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  25953. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  25954. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  25955. INVERTCUBICMAP: boolean;
  25956. USESPHERICALFROMREFLECTIONMAP: boolean;
  25957. USEIRRADIANCEMAP: boolean;
  25958. SPHERICAL_HARMONICS: boolean;
  25959. USESPHERICALINVERTEX: boolean;
  25960. REFLECTIONMAP_OPPOSITEZ: boolean;
  25961. LODINREFLECTIONALPHA: boolean;
  25962. GAMMAREFLECTION: boolean;
  25963. RGBDREFLECTION: boolean;
  25964. LINEARSPECULARREFLECTION: boolean;
  25965. RADIANCEOCCLUSION: boolean;
  25966. HORIZONOCCLUSION: boolean;
  25967. INSTANCES: boolean;
  25968. THIN_INSTANCES: boolean;
  25969. PREPASS: boolean;
  25970. PREPASS_IRRADIANCE: boolean;
  25971. PREPASS_IRRADIANCE_INDEX: number;
  25972. PREPASS_ALBEDO: boolean;
  25973. PREPASS_ALBEDO_INDEX: number;
  25974. PREPASS_DEPTHNORMAL: boolean;
  25975. PREPASS_DEPTHNORMAL_INDEX: number;
  25976. PREPASS_POSITION: boolean;
  25977. PREPASS_POSITION_INDEX: number;
  25978. PREPASS_VELOCITY: boolean;
  25979. PREPASS_VELOCITY_INDEX: number;
  25980. PREPASS_REFLECTIVITY: boolean;
  25981. PREPASS_REFLECTIVITY_INDEX: number;
  25982. SCENE_MRT_COUNT: number;
  25983. NUM_BONE_INFLUENCERS: number;
  25984. BonesPerMesh: number;
  25985. BONETEXTURE: boolean;
  25986. BONES_VELOCITY_ENABLED: boolean;
  25987. NONUNIFORMSCALING: boolean;
  25988. MORPHTARGETS: boolean;
  25989. MORPHTARGETS_NORMAL: boolean;
  25990. MORPHTARGETS_TANGENT: boolean;
  25991. MORPHTARGETS_UV: boolean;
  25992. NUM_MORPH_INFLUENCERS: number;
  25993. IMAGEPROCESSING: boolean;
  25994. VIGNETTE: boolean;
  25995. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25996. VIGNETTEBLENDMODEOPAQUE: boolean;
  25997. TONEMAPPING: boolean;
  25998. TONEMAPPING_ACES: boolean;
  25999. CONTRAST: boolean;
  26000. COLORCURVES: boolean;
  26001. COLORGRADING: boolean;
  26002. COLORGRADING3D: boolean;
  26003. SAMPLER3DGREENDEPTH: boolean;
  26004. SAMPLER3DBGRMAP: boolean;
  26005. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26006. EXPOSURE: boolean;
  26007. MULTIVIEW: boolean;
  26008. USEPHYSICALLIGHTFALLOFF: boolean;
  26009. USEGLTFLIGHTFALLOFF: boolean;
  26010. TWOSIDEDLIGHTING: boolean;
  26011. SHADOWFLOAT: boolean;
  26012. CLIPPLANE: boolean;
  26013. CLIPPLANE2: boolean;
  26014. CLIPPLANE3: boolean;
  26015. CLIPPLANE4: boolean;
  26016. CLIPPLANE5: boolean;
  26017. CLIPPLANE6: boolean;
  26018. POINTSIZE: boolean;
  26019. FOG: boolean;
  26020. LOGARITHMICDEPTH: boolean;
  26021. FORCENORMALFORWARD: boolean;
  26022. SPECULARAA: boolean;
  26023. CLEARCOAT: boolean;
  26024. CLEARCOAT_DEFAULTIOR: boolean;
  26025. CLEARCOAT_TEXTURE: boolean;
  26026. CLEARCOAT_TEXTUREDIRECTUV: number;
  26027. CLEARCOAT_BUMP: boolean;
  26028. CLEARCOAT_BUMPDIRECTUV: number;
  26029. CLEARCOAT_REMAP_F0: boolean;
  26030. CLEARCOAT_TINT: boolean;
  26031. CLEARCOAT_TINT_TEXTURE: boolean;
  26032. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26033. ANISOTROPIC: boolean;
  26034. ANISOTROPIC_TEXTURE: boolean;
  26035. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26036. BRDF_V_HEIGHT_CORRELATED: boolean;
  26037. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26038. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26039. SHEEN: boolean;
  26040. SHEEN_TEXTURE: boolean;
  26041. SHEEN_TEXTUREDIRECTUV: number;
  26042. SHEEN_LINKWITHALBEDO: boolean;
  26043. SHEEN_ROUGHNESS: boolean;
  26044. SHEEN_ALBEDOSCALING: boolean;
  26045. SUBSURFACE: boolean;
  26046. SS_REFRACTION: boolean;
  26047. SS_TRANSLUCENCY: boolean;
  26048. SS_SCATTERING: boolean;
  26049. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26050. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26051. SS_REFRACTIONMAP_3D: boolean;
  26052. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26053. SS_LODINREFRACTIONALPHA: boolean;
  26054. SS_GAMMAREFRACTION: boolean;
  26055. SS_RGBDREFRACTION: boolean;
  26056. SS_LINEARSPECULARREFRACTION: boolean;
  26057. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26058. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26059. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26060. UNLIT: boolean;
  26061. DEBUGMODE: number;
  26062. /**
  26063. * Initializes the PBR Material defines.
  26064. */
  26065. constructor();
  26066. /**
  26067. * Resets the PBR Material defines.
  26068. */
  26069. reset(): void;
  26070. }
  26071. /**
  26072. * The Physically based material base class of BJS.
  26073. *
  26074. * This offers the main features of a standard PBR material.
  26075. * For more information, please refer to the documentation :
  26076. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26077. */
  26078. export abstract class PBRBaseMaterial extends PushMaterial {
  26079. /**
  26080. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26081. */
  26082. static readonly PBRMATERIAL_OPAQUE: number;
  26083. /**
  26084. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26085. */
  26086. static readonly PBRMATERIAL_ALPHATEST: number;
  26087. /**
  26088. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26089. */
  26090. static readonly PBRMATERIAL_ALPHABLEND: number;
  26091. /**
  26092. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26093. * They are also discarded below the alpha cutoff threshold to improve performances.
  26094. */
  26095. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26096. /**
  26097. * Defines the default value of how much AO map is occluding the analytical lights
  26098. * (point spot...).
  26099. */
  26100. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26101. /**
  26102. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26103. */
  26104. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26105. /**
  26106. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26107. * to enhance interoperability with other engines.
  26108. */
  26109. static readonly LIGHTFALLOFF_GLTF: number;
  26110. /**
  26111. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26112. * to enhance interoperability with other materials.
  26113. */
  26114. static readonly LIGHTFALLOFF_STANDARD: number;
  26115. /**
  26116. * Intensity of the direct lights e.g. the four lights available in your scene.
  26117. * This impacts both the direct diffuse and specular highlights.
  26118. */
  26119. protected _directIntensity: number;
  26120. /**
  26121. * Intensity of the emissive part of the material.
  26122. * This helps controlling the emissive effect without modifying the emissive color.
  26123. */
  26124. protected _emissiveIntensity: number;
  26125. /**
  26126. * Intensity of the environment e.g. how much the environment will light the object
  26127. * either through harmonics for rough material or through the refelction for shiny ones.
  26128. */
  26129. protected _environmentIntensity: number;
  26130. /**
  26131. * This is a special control allowing the reduction of the specular highlights coming from the
  26132. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26133. */
  26134. protected _specularIntensity: number;
  26135. /**
  26136. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26137. */
  26138. private _lightingInfos;
  26139. /**
  26140. * Debug Control allowing disabling the bump map on this material.
  26141. */
  26142. protected _disableBumpMap: boolean;
  26143. /**
  26144. * AKA Diffuse Texture in standard nomenclature.
  26145. */
  26146. protected _albedoTexture: Nullable<BaseTexture>;
  26147. /**
  26148. * AKA Occlusion Texture in other nomenclature.
  26149. */
  26150. protected _ambientTexture: Nullable<BaseTexture>;
  26151. /**
  26152. * AKA Occlusion Texture Intensity in other nomenclature.
  26153. */
  26154. protected _ambientTextureStrength: number;
  26155. /**
  26156. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26157. * 1 means it completely occludes it
  26158. * 0 mean it has no impact
  26159. */
  26160. protected _ambientTextureImpactOnAnalyticalLights: number;
  26161. /**
  26162. * Stores the alpha values in a texture.
  26163. */
  26164. protected _opacityTexture: Nullable<BaseTexture>;
  26165. /**
  26166. * Stores the reflection values in a texture.
  26167. */
  26168. protected _reflectionTexture: Nullable<BaseTexture>;
  26169. /**
  26170. * Stores the emissive values in a texture.
  26171. */
  26172. protected _emissiveTexture: Nullable<BaseTexture>;
  26173. /**
  26174. * AKA Specular texture in other nomenclature.
  26175. */
  26176. protected _reflectivityTexture: Nullable<BaseTexture>;
  26177. /**
  26178. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26179. */
  26180. protected _metallicTexture: Nullable<BaseTexture>;
  26181. /**
  26182. * Specifies the metallic scalar of the metallic/roughness workflow.
  26183. * Can also be used to scale the metalness values of the metallic texture.
  26184. */
  26185. protected _metallic: Nullable<number>;
  26186. /**
  26187. * Specifies the roughness scalar of the metallic/roughness workflow.
  26188. * Can also be used to scale the roughness values of the metallic texture.
  26189. */
  26190. protected _roughness: Nullable<number>;
  26191. /**
  26192. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26193. * By default the indexOfrefraction is used to compute F0;
  26194. *
  26195. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26196. *
  26197. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26198. * F90 = metallicReflectanceColor;
  26199. */
  26200. protected _metallicF0Factor: number;
  26201. /**
  26202. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26203. * By default the F90 is always 1;
  26204. *
  26205. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26206. *
  26207. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26208. * F90 = metallicReflectanceColor;
  26209. */
  26210. protected _metallicReflectanceColor: Color3;
  26211. /**
  26212. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26213. * This is multiply against the scalar values defined in the material.
  26214. */
  26215. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26216. /**
  26217. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26218. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26219. */
  26220. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26221. /**
  26222. * Stores surface normal data used to displace a mesh in a texture.
  26223. */
  26224. protected _bumpTexture: Nullable<BaseTexture>;
  26225. /**
  26226. * Stores the pre-calculated light information of a mesh in a texture.
  26227. */
  26228. protected _lightmapTexture: Nullable<BaseTexture>;
  26229. /**
  26230. * The color of a material in ambient lighting.
  26231. */
  26232. protected _ambientColor: Color3;
  26233. /**
  26234. * AKA Diffuse Color in other nomenclature.
  26235. */
  26236. protected _albedoColor: Color3;
  26237. /**
  26238. * AKA Specular Color in other nomenclature.
  26239. */
  26240. protected _reflectivityColor: Color3;
  26241. /**
  26242. * The color applied when light is reflected from a material.
  26243. */
  26244. protected _reflectionColor: Color3;
  26245. /**
  26246. * The color applied when light is emitted from a material.
  26247. */
  26248. protected _emissiveColor: Color3;
  26249. /**
  26250. * AKA Glossiness in other nomenclature.
  26251. */
  26252. protected _microSurface: number;
  26253. /**
  26254. * Specifies that the material will use the light map as a show map.
  26255. */
  26256. protected _useLightmapAsShadowmap: boolean;
  26257. /**
  26258. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26259. * makes the reflect vector face the model (under horizon).
  26260. */
  26261. protected _useHorizonOcclusion: boolean;
  26262. /**
  26263. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26264. * too much the area relying on ambient texture to define their ambient occlusion.
  26265. */
  26266. protected _useRadianceOcclusion: boolean;
  26267. /**
  26268. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26269. */
  26270. protected _useAlphaFromAlbedoTexture: boolean;
  26271. /**
  26272. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26273. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26274. */
  26275. protected _useSpecularOverAlpha: boolean;
  26276. /**
  26277. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26278. */
  26279. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26280. /**
  26281. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26282. */
  26283. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26284. /**
  26285. * Specifies if the metallic texture contains the roughness information in its green channel.
  26286. */
  26287. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26288. /**
  26289. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26290. */
  26291. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26292. /**
  26293. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26294. */
  26295. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26296. /**
  26297. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26298. */
  26299. protected _useAmbientInGrayScale: boolean;
  26300. /**
  26301. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26302. * The material will try to infer what glossiness each pixel should be.
  26303. */
  26304. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26305. /**
  26306. * Defines the falloff type used in this material.
  26307. * It by default is Physical.
  26308. */
  26309. protected _lightFalloff: number;
  26310. /**
  26311. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26312. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26313. */
  26314. protected _useRadianceOverAlpha: boolean;
  26315. /**
  26316. * Allows using an object space normal map (instead of tangent space).
  26317. */
  26318. protected _useObjectSpaceNormalMap: boolean;
  26319. /**
  26320. * Allows using the bump map in parallax mode.
  26321. */
  26322. protected _useParallax: boolean;
  26323. /**
  26324. * Allows using the bump map in parallax occlusion mode.
  26325. */
  26326. protected _useParallaxOcclusion: boolean;
  26327. /**
  26328. * Controls the scale bias of the parallax mode.
  26329. */
  26330. protected _parallaxScaleBias: number;
  26331. /**
  26332. * If sets to true, disables all the lights affecting the material.
  26333. */
  26334. protected _disableLighting: boolean;
  26335. /**
  26336. * Number of Simultaneous lights allowed on the material.
  26337. */
  26338. protected _maxSimultaneousLights: number;
  26339. /**
  26340. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26341. */
  26342. protected _invertNormalMapX: boolean;
  26343. /**
  26344. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26345. */
  26346. protected _invertNormalMapY: boolean;
  26347. /**
  26348. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26349. */
  26350. protected _twoSidedLighting: boolean;
  26351. /**
  26352. * Defines the alpha limits in alpha test mode.
  26353. */
  26354. protected _alphaCutOff: number;
  26355. /**
  26356. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26357. */
  26358. protected _forceAlphaTest: boolean;
  26359. /**
  26360. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26361. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26362. */
  26363. protected _useAlphaFresnel: boolean;
  26364. /**
  26365. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26366. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26367. */
  26368. protected _useLinearAlphaFresnel: boolean;
  26369. /**
  26370. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26371. * from cos thetav and roughness:
  26372. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26373. */
  26374. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26375. /**
  26376. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26377. */
  26378. protected _forceIrradianceInFragment: boolean;
  26379. private _realTimeFiltering;
  26380. /**
  26381. * Enables realtime filtering on the texture.
  26382. */
  26383. get realTimeFiltering(): boolean;
  26384. set realTimeFiltering(b: boolean);
  26385. private _realTimeFilteringQuality;
  26386. /**
  26387. * Quality switch for realtime filtering
  26388. */
  26389. get realTimeFilteringQuality(): number;
  26390. set realTimeFilteringQuality(n: number);
  26391. /**
  26392. * Can this material render to several textures at once
  26393. */
  26394. get canRenderToMRT(): boolean;
  26395. /**
  26396. * Force normal to face away from face.
  26397. */
  26398. protected _forceNormalForward: boolean;
  26399. /**
  26400. * Enables specular anti aliasing in the PBR shader.
  26401. * It will both interacts on the Geometry for analytical and IBL lighting.
  26402. * It also prefilter the roughness map based on the bump values.
  26403. */
  26404. protected _enableSpecularAntiAliasing: boolean;
  26405. /**
  26406. * Default configuration related to image processing available in the PBR Material.
  26407. */
  26408. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26409. /**
  26410. * Keep track of the image processing observer to allow dispose and replace.
  26411. */
  26412. private _imageProcessingObserver;
  26413. /**
  26414. * Attaches a new image processing configuration to the PBR Material.
  26415. * @param configuration
  26416. */
  26417. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26418. /**
  26419. * Stores the available render targets.
  26420. */
  26421. private _renderTargets;
  26422. /**
  26423. * Sets the global ambient color for the material used in lighting calculations.
  26424. */
  26425. private _globalAmbientColor;
  26426. /**
  26427. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26428. */
  26429. private _useLogarithmicDepth;
  26430. /**
  26431. * If set to true, no lighting calculations will be applied.
  26432. */
  26433. private _unlit;
  26434. private _debugMode;
  26435. /**
  26436. * @hidden
  26437. * This is reserved for the inspector.
  26438. * Defines the material debug mode.
  26439. * It helps seeing only some components of the material while troubleshooting.
  26440. */
  26441. debugMode: number;
  26442. /**
  26443. * @hidden
  26444. * This is reserved for the inspector.
  26445. * Specify from where on screen the debug mode should start.
  26446. * The value goes from -1 (full screen) to 1 (not visible)
  26447. * It helps with side by side comparison against the final render
  26448. * This defaults to -1
  26449. */
  26450. private debugLimit;
  26451. /**
  26452. * @hidden
  26453. * This is reserved for the inspector.
  26454. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26455. * You can use the factor to better multiply the final value.
  26456. */
  26457. private debugFactor;
  26458. /**
  26459. * Defines the clear coat layer parameters for the material.
  26460. */
  26461. readonly clearCoat: PBRClearCoatConfiguration;
  26462. /**
  26463. * Defines the anisotropic parameters for the material.
  26464. */
  26465. readonly anisotropy: PBRAnisotropicConfiguration;
  26466. /**
  26467. * Defines the BRDF parameters for the material.
  26468. */
  26469. readonly brdf: PBRBRDFConfiguration;
  26470. /**
  26471. * Defines the Sheen parameters for the material.
  26472. */
  26473. readonly sheen: PBRSheenConfiguration;
  26474. /**
  26475. * Defines the SubSurface parameters for the material.
  26476. */
  26477. readonly subSurface: PBRSubSurfaceConfiguration;
  26478. /**
  26479. * Defines additionnal PrePass parameters for the material.
  26480. */
  26481. readonly prePassConfiguration: PrePassConfiguration;
  26482. /**
  26483. * Defines the detail map parameters for the material.
  26484. */
  26485. readonly detailMap: DetailMapConfiguration;
  26486. protected _rebuildInParallel: boolean;
  26487. /**
  26488. * Instantiates a new PBRMaterial instance.
  26489. *
  26490. * @param name The material name
  26491. * @param scene The scene the material will be use in.
  26492. */
  26493. constructor(name: string, scene: Scene);
  26494. /**
  26495. * Gets a boolean indicating that current material needs to register RTT
  26496. */
  26497. get hasRenderTargetTextures(): boolean;
  26498. /**
  26499. * Gets the name of the material class.
  26500. */
  26501. getClassName(): string;
  26502. /**
  26503. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26504. */
  26505. get useLogarithmicDepth(): boolean;
  26506. /**
  26507. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26508. */
  26509. set useLogarithmicDepth(value: boolean);
  26510. /**
  26511. * Returns true if alpha blending should be disabled.
  26512. */
  26513. protected get _disableAlphaBlending(): boolean;
  26514. /**
  26515. * Specifies whether or not this material should be rendered in alpha blend mode.
  26516. */
  26517. needAlphaBlending(): boolean;
  26518. /**
  26519. * Specifies whether or not this material should be rendered in alpha test mode.
  26520. */
  26521. needAlphaTesting(): boolean;
  26522. /**
  26523. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26524. */
  26525. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26526. /**
  26527. * Gets the texture used for the alpha test.
  26528. */
  26529. getAlphaTestTexture(): Nullable<BaseTexture>;
  26530. /**
  26531. * Specifies that the submesh is ready to be used.
  26532. * @param mesh - BJS mesh.
  26533. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26534. * @param useInstances - Specifies that instances should be used.
  26535. * @returns - boolean indicating that the submesh is ready or not.
  26536. */
  26537. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26538. /**
  26539. * Specifies if the material uses metallic roughness workflow.
  26540. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26541. */
  26542. isMetallicWorkflow(): boolean;
  26543. private _prepareEffect;
  26544. private _prepareDefines;
  26545. /**
  26546. * Force shader compilation
  26547. */
  26548. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26549. /**
  26550. * Initializes the uniform buffer layout for the shader.
  26551. */
  26552. buildUniformLayout(): void;
  26553. /**
  26554. * Unbinds the material from the mesh
  26555. */
  26556. unbind(): void;
  26557. /**
  26558. * Binds the submesh data.
  26559. * @param world - The world matrix.
  26560. * @param mesh - The BJS mesh.
  26561. * @param subMesh - A submesh of the BJS mesh.
  26562. */
  26563. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26564. /**
  26565. * Returns the animatable textures.
  26566. * @returns - Array of animatable textures.
  26567. */
  26568. getAnimatables(): IAnimatable[];
  26569. /**
  26570. * Returns the texture used for reflections.
  26571. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26572. */
  26573. private _getReflectionTexture;
  26574. /**
  26575. * Returns an array of the actively used textures.
  26576. * @returns - Array of BaseTextures
  26577. */
  26578. getActiveTextures(): BaseTexture[];
  26579. /**
  26580. * Checks to see if a texture is used in the material.
  26581. * @param texture - Base texture to use.
  26582. * @returns - Boolean specifying if a texture is used in the material.
  26583. */
  26584. hasTexture(texture: BaseTexture): boolean;
  26585. /**
  26586. * Sets the required values to the prepass renderer.
  26587. * @param prePassRenderer defines the prepass renderer to setup
  26588. */
  26589. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26590. /**
  26591. * Disposes the resources of the material.
  26592. * @param forceDisposeEffect - Forces the disposal of effects.
  26593. * @param forceDisposeTextures - Forces the disposal of all textures.
  26594. */
  26595. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26596. }
  26597. }
  26598. declare module BABYLON {
  26599. /**
  26600. * The Physically based material of BJS.
  26601. *
  26602. * This offers the main features of a standard PBR material.
  26603. * For more information, please refer to the documentation :
  26604. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26605. */
  26606. export class PBRMaterial extends PBRBaseMaterial {
  26607. /**
  26608. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26609. */
  26610. static readonly PBRMATERIAL_OPAQUE: number;
  26611. /**
  26612. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26613. */
  26614. static readonly PBRMATERIAL_ALPHATEST: number;
  26615. /**
  26616. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26617. */
  26618. static readonly PBRMATERIAL_ALPHABLEND: number;
  26619. /**
  26620. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26621. * They are also discarded below the alpha cutoff threshold to improve performances.
  26622. */
  26623. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26624. /**
  26625. * Defines the default value of how much AO map is occluding the analytical lights
  26626. * (point spot...).
  26627. */
  26628. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26629. /**
  26630. * Intensity of the direct lights e.g. the four lights available in your scene.
  26631. * This impacts both the direct diffuse and specular highlights.
  26632. */
  26633. directIntensity: number;
  26634. /**
  26635. * Intensity of the emissive part of the material.
  26636. * This helps controlling the emissive effect without modifying the emissive color.
  26637. */
  26638. emissiveIntensity: number;
  26639. /**
  26640. * Intensity of the environment e.g. how much the environment will light the object
  26641. * either through harmonics for rough material or through the refelction for shiny ones.
  26642. */
  26643. environmentIntensity: number;
  26644. /**
  26645. * This is a special control allowing the reduction of the specular highlights coming from the
  26646. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26647. */
  26648. specularIntensity: number;
  26649. /**
  26650. * Debug Control allowing disabling the bump map on this material.
  26651. */
  26652. disableBumpMap: boolean;
  26653. /**
  26654. * AKA Diffuse Texture in standard nomenclature.
  26655. */
  26656. albedoTexture: BaseTexture;
  26657. /**
  26658. * AKA Occlusion Texture in other nomenclature.
  26659. */
  26660. ambientTexture: BaseTexture;
  26661. /**
  26662. * AKA Occlusion Texture Intensity in other nomenclature.
  26663. */
  26664. ambientTextureStrength: number;
  26665. /**
  26666. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26667. * 1 means it completely occludes it
  26668. * 0 mean it has no impact
  26669. */
  26670. ambientTextureImpactOnAnalyticalLights: number;
  26671. /**
  26672. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  26673. */
  26674. opacityTexture: BaseTexture;
  26675. /**
  26676. * Stores the reflection values in a texture.
  26677. */
  26678. reflectionTexture: Nullable<BaseTexture>;
  26679. /**
  26680. * Stores the emissive values in a texture.
  26681. */
  26682. emissiveTexture: BaseTexture;
  26683. /**
  26684. * AKA Specular texture in other nomenclature.
  26685. */
  26686. reflectivityTexture: BaseTexture;
  26687. /**
  26688. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26689. */
  26690. metallicTexture: BaseTexture;
  26691. /**
  26692. * Specifies the metallic scalar of the metallic/roughness workflow.
  26693. * Can also be used to scale the metalness values of the metallic texture.
  26694. */
  26695. metallic: Nullable<number>;
  26696. /**
  26697. * Specifies the roughness scalar of the metallic/roughness workflow.
  26698. * Can also be used to scale the roughness values of the metallic texture.
  26699. */
  26700. roughness: Nullable<number>;
  26701. /**
  26702. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26703. * By default the indexOfrefraction is used to compute F0;
  26704. *
  26705. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26706. *
  26707. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26708. * F90 = metallicReflectanceColor;
  26709. */
  26710. metallicF0Factor: number;
  26711. /**
  26712. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26713. * By default the F90 is always 1;
  26714. *
  26715. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26716. *
  26717. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26718. * F90 = metallicReflectanceColor;
  26719. */
  26720. metallicReflectanceColor: Color3;
  26721. /**
  26722. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26723. * This is multiply against the scalar values defined in the material.
  26724. */
  26725. metallicReflectanceTexture: Nullable<BaseTexture>;
  26726. /**
  26727. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26728. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26729. */
  26730. microSurfaceTexture: BaseTexture;
  26731. /**
  26732. * Stores surface normal data used to displace a mesh in a texture.
  26733. */
  26734. bumpTexture: BaseTexture;
  26735. /**
  26736. * Stores the pre-calculated light information of a mesh in a texture.
  26737. */
  26738. lightmapTexture: BaseTexture;
  26739. /**
  26740. * Stores the refracted light information in a texture.
  26741. */
  26742. get refractionTexture(): Nullable<BaseTexture>;
  26743. set refractionTexture(value: Nullable<BaseTexture>);
  26744. /**
  26745. * The color of a material in ambient lighting.
  26746. */
  26747. ambientColor: Color3;
  26748. /**
  26749. * AKA Diffuse Color in other nomenclature.
  26750. */
  26751. albedoColor: Color3;
  26752. /**
  26753. * AKA Specular Color in other nomenclature.
  26754. */
  26755. reflectivityColor: Color3;
  26756. /**
  26757. * The color reflected from the material.
  26758. */
  26759. reflectionColor: Color3;
  26760. /**
  26761. * The color emitted from the material.
  26762. */
  26763. emissiveColor: Color3;
  26764. /**
  26765. * AKA Glossiness in other nomenclature.
  26766. */
  26767. microSurface: number;
  26768. /**
  26769. * Index of refraction of the material base layer.
  26770. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26771. *
  26772. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26773. *
  26774. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26775. */
  26776. get indexOfRefraction(): number;
  26777. set indexOfRefraction(value: number);
  26778. /**
  26779. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26780. */
  26781. get invertRefractionY(): boolean;
  26782. set invertRefractionY(value: boolean);
  26783. /**
  26784. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26785. * Materials half opaque for instance using refraction could benefit from this control.
  26786. */
  26787. get linkRefractionWithTransparency(): boolean;
  26788. set linkRefractionWithTransparency(value: boolean);
  26789. /**
  26790. * If true, the light map contains occlusion information instead of lighting info.
  26791. */
  26792. useLightmapAsShadowmap: boolean;
  26793. /**
  26794. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26795. */
  26796. useAlphaFromAlbedoTexture: boolean;
  26797. /**
  26798. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26799. */
  26800. forceAlphaTest: boolean;
  26801. /**
  26802. * Defines the alpha limits in alpha test mode.
  26803. */
  26804. alphaCutOff: number;
  26805. /**
  26806. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26807. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26808. */
  26809. useSpecularOverAlpha: boolean;
  26810. /**
  26811. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26812. */
  26813. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26814. /**
  26815. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26816. */
  26817. useRoughnessFromMetallicTextureAlpha: boolean;
  26818. /**
  26819. * Specifies if the metallic texture contains the roughness information in its green channel.
  26820. */
  26821. useRoughnessFromMetallicTextureGreen: boolean;
  26822. /**
  26823. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26824. */
  26825. useMetallnessFromMetallicTextureBlue: boolean;
  26826. /**
  26827. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26828. */
  26829. useAmbientOcclusionFromMetallicTextureRed: boolean;
  26830. /**
  26831. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26832. */
  26833. useAmbientInGrayScale: boolean;
  26834. /**
  26835. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26836. * The material will try to infer what glossiness each pixel should be.
  26837. */
  26838. useAutoMicroSurfaceFromReflectivityMap: boolean;
  26839. /**
  26840. * BJS is using an harcoded light falloff based on a manually sets up range.
  26841. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26842. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26843. */
  26844. get usePhysicalLightFalloff(): boolean;
  26845. /**
  26846. * BJS is using an harcoded light falloff based on a manually sets up range.
  26847. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26848. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26849. */
  26850. set usePhysicalLightFalloff(value: boolean);
  26851. /**
  26852. * In order to support the falloff compatibility with gltf, a special mode has been added
  26853. * to reproduce the gltf light falloff.
  26854. */
  26855. get useGLTFLightFalloff(): boolean;
  26856. /**
  26857. * In order to support the falloff compatibility with gltf, a special mode has been added
  26858. * to reproduce the gltf light falloff.
  26859. */
  26860. set useGLTFLightFalloff(value: boolean);
  26861. /**
  26862. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26863. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26864. */
  26865. useRadianceOverAlpha: boolean;
  26866. /**
  26867. * Allows using an object space normal map (instead of tangent space).
  26868. */
  26869. useObjectSpaceNormalMap: boolean;
  26870. /**
  26871. * Allows using the bump map in parallax mode.
  26872. */
  26873. useParallax: boolean;
  26874. /**
  26875. * Allows using the bump map in parallax occlusion mode.
  26876. */
  26877. useParallaxOcclusion: boolean;
  26878. /**
  26879. * Controls the scale bias of the parallax mode.
  26880. */
  26881. parallaxScaleBias: number;
  26882. /**
  26883. * If sets to true, disables all the lights affecting the material.
  26884. */
  26885. disableLighting: boolean;
  26886. /**
  26887. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26888. */
  26889. forceIrradianceInFragment: boolean;
  26890. /**
  26891. * Number of Simultaneous lights allowed on the material.
  26892. */
  26893. maxSimultaneousLights: number;
  26894. /**
  26895. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26896. */
  26897. invertNormalMapX: boolean;
  26898. /**
  26899. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26900. */
  26901. invertNormalMapY: boolean;
  26902. /**
  26903. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26904. */
  26905. twoSidedLighting: boolean;
  26906. /**
  26907. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26908. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26909. */
  26910. useAlphaFresnel: boolean;
  26911. /**
  26912. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26913. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26914. */
  26915. useLinearAlphaFresnel: boolean;
  26916. /**
  26917. * Let user defines the brdf lookup texture used for IBL.
  26918. * A default 8bit version is embedded but you could point at :
  26919. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  26920. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  26921. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  26922. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  26923. */
  26924. environmentBRDFTexture: Nullable<BaseTexture>;
  26925. /**
  26926. * Force normal to face away from face.
  26927. */
  26928. forceNormalForward: boolean;
  26929. /**
  26930. * Enables specular anti aliasing in the PBR shader.
  26931. * It will both interacts on the Geometry for analytical and IBL lighting.
  26932. * It also prefilter the roughness map based on the bump values.
  26933. */
  26934. enableSpecularAntiAliasing: boolean;
  26935. /**
  26936. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26937. * makes the reflect vector face the model (under horizon).
  26938. */
  26939. useHorizonOcclusion: boolean;
  26940. /**
  26941. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26942. * too much the area relying on ambient texture to define their ambient occlusion.
  26943. */
  26944. useRadianceOcclusion: boolean;
  26945. /**
  26946. * If set to true, no lighting calculations will be applied.
  26947. */
  26948. unlit: boolean;
  26949. /**
  26950. * Gets the image processing configuration used either in this material.
  26951. */
  26952. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26953. /**
  26954. * Sets the Default image processing configuration used either in the this material.
  26955. *
  26956. * If sets to null, the scene one is in use.
  26957. */
  26958. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26959. /**
  26960. * Gets wether the color curves effect is enabled.
  26961. */
  26962. get cameraColorCurvesEnabled(): boolean;
  26963. /**
  26964. * Sets wether the color curves effect is enabled.
  26965. */
  26966. set cameraColorCurvesEnabled(value: boolean);
  26967. /**
  26968. * Gets wether the color grading effect is enabled.
  26969. */
  26970. get cameraColorGradingEnabled(): boolean;
  26971. /**
  26972. * Gets wether the color grading effect is enabled.
  26973. */
  26974. set cameraColorGradingEnabled(value: boolean);
  26975. /**
  26976. * Gets wether tonemapping is enabled or not.
  26977. */
  26978. get cameraToneMappingEnabled(): boolean;
  26979. /**
  26980. * Sets wether tonemapping is enabled or not
  26981. */
  26982. set cameraToneMappingEnabled(value: boolean);
  26983. /**
  26984. * The camera exposure used on this material.
  26985. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26986. * This corresponds to a photographic exposure.
  26987. */
  26988. get cameraExposure(): number;
  26989. /**
  26990. * The camera exposure used on this material.
  26991. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26992. * This corresponds to a photographic exposure.
  26993. */
  26994. set cameraExposure(value: number);
  26995. /**
  26996. * Gets The camera contrast used on this material.
  26997. */
  26998. get cameraContrast(): number;
  26999. /**
  27000. * Sets The camera contrast used on this material.
  27001. */
  27002. set cameraContrast(value: number);
  27003. /**
  27004. * Gets the Color Grading 2D Lookup Texture.
  27005. */
  27006. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27007. /**
  27008. * Sets the Color Grading 2D Lookup Texture.
  27009. */
  27010. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27011. /**
  27012. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27013. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27014. * 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;
  27015. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27016. */
  27017. get cameraColorCurves(): Nullable<ColorCurves>;
  27018. /**
  27019. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27020. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27021. * 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;
  27022. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27023. */
  27024. set cameraColorCurves(value: Nullable<ColorCurves>);
  27025. /**
  27026. * Instantiates a new PBRMaterial instance.
  27027. *
  27028. * @param name The material name
  27029. * @param scene The scene the material will be use in.
  27030. */
  27031. constructor(name: string, scene: Scene);
  27032. /**
  27033. * Returns the name of this material class.
  27034. */
  27035. getClassName(): string;
  27036. /**
  27037. * Makes a duplicate of the current material.
  27038. * @param name - name to use for the new material.
  27039. */
  27040. clone(name: string): PBRMaterial;
  27041. /**
  27042. * Serializes this PBR Material.
  27043. * @returns - An object with the serialized material.
  27044. */
  27045. serialize(): any;
  27046. /**
  27047. * Parses a PBR Material from a serialized object.
  27048. * @param source - Serialized object.
  27049. * @param scene - BJS scene instance.
  27050. * @param rootUrl - url for the scene object
  27051. * @returns - PBRMaterial
  27052. */
  27053. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27054. }
  27055. }
  27056. declare module BABYLON {
  27057. /** @hidden */
  27058. export var mrtFragmentDeclaration: {
  27059. name: string;
  27060. shader: string;
  27061. };
  27062. }
  27063. declare module BABYLON {
  27064. /** @hidden */
  27065. export var geometryPixelShader: {
  27066. name: string;
  27067. shader: string;
  27068. };
  27069. }
  27070. declare module BABYLON {
  27071. /** @hidden */
  27072. export var geometryVertexShader: {
  27073. name: string;
  27074. shader: string;
  27075. };
  27076. }
  27077. declare module BABYLON {
  27078. /** @hidden */
  27079. interface ISavedTransformationMatrix {
  27080. world: Matrix;
  27081. viewProjection: Matrix;
  27082. }
  27083. /**
  27084. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27085. */
  27086. export class GeometryBufferRenderer {
  27087. /**
  27088. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27089. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27090. */
  27091. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27092. /**
  27093. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27094. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27095. */
  27096. static readonly POSITION_TEXTURE_TYPE: number;
  27097. /**
  27098. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27099. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27100. */
  27101. static readonly VELOCITY_TEXTURE_TYPE: number;
  27102. /**
  27103. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27104. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27105. */
  27106. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27107. /**
  27108. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27109. * in order to compute objects velocities when enableVelocity is set to "true"
  27110. * @hidden
  27111. */
  27112. _previousTransformationMatrices: {
  27113. [index: number]: ISavedTransformationMatrix;
  27114. };
  27115. /**
  27116. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27117. * in order to compute objects velocities when enableVelocity is set to "true"
  27118. * @hidden
  27119. */
  27120. _previousBonesTransformationMatrices: {
  27121. [index: number]: Float32Array;
  27122. };
  27123. /**
  27124. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27125. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27126. */
  27127. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27128. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27129. renderTransparentMeshes: boolean;
  27130. private _scene;
  27131. private _resizeObserver;
  27132. private _multiRenderTarget;
  27133. private _ratio;
  27134. private _enablePosition;
  27135. private _enableVelocity;
  27136. private _enableReflectivity;
  27137. private _positionIndex;
  27138. private _velocityIndex;
  27139. private _reflectivityIndex;
  27140. private _depthNormalIndex;
  27141. private _linkedWithPrePass;
  27142. private _prePassRenderer;
  27143. private _attachments;
  27144. protected _effect: Effect;
  27145. protected _cachedDefines: string;
  27146. /**
  27147. * @hidden
  27148. * Sets up internal structures to share outputs with PrePassRenderer
  27149. * This method should only be called by the PrePassRenderer itself
  27150. */
  27151. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27152. /**
  27153. * @hidden
  27154. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27155. * This method should only be called by the PrePassRenderer itself
  27156. */
  27157. _unlinkPrePassRenderer(): void;
  27158. /**
  27159. * @hidden
  27160. * Resets the geometry buffer layout
  27161. */
  27162. _resetLayout(): void;
  27163. /**
  27164. * @hidden
  27165. * Replaces a texture in the geometry buffer renderer
  27166. * Useful when linking textures of the prepass renderer
  27167. */
  27168. _forceTextureType(geometryBufferType: number, index: number): void;
  27169. /**
  27170. * @hidden
  27171. * Sets texture attachments
  27172. * Useful when linking textures of the prepass renderer
  27173. */
  27174. _setAttachments(attachments: number[]): void;
  27175. /**
  27176. * @hidden
  27177. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27178. * Useful when linking textures of the prepass renderer
  27179. */
  27180. _linkInternalTexture(internalTexture: InternalTexture): void;
  27181. /**
  27182. * Gets the render list (meshes to be rendered) used in the G buffer.
  27183. */
  27184. get renderList(): Nullable<AbstractMesh[]>;
  27185. /**
  27186. * Set the render list (meshes to be rendered) used in the G buffer.
  27187. */
  27188. set renderList(meshes: Nullable<AbstractMesh[]>);
  27189. /**
  27190. * Gets wether or not G buffer are supported by the running hardware.
  27191. * This requires draw buffer supports
  27192. */
  27193. get isSupported(): boolean;
  27194. /**
  27195. * Returns the index of the given texture type in the G-Buffer textures array
  27196. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27197. * @returns the index of the given texture type in the G-Buffer textures array
  27198. */
  27199. getTextureIndex(textureType: number): number;
  27200. /**
  27201. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27202. */
  27203. get enablePosition(): boolean;
  27204. /**
  27205. * Sets whether or not objects positions are enabled for the G buffer.
  27206. */
  27207. set enablePosition(enable: boolean);
  27208. /**
  27209. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27210. */
  27211. get enableVelocity(): boolean;
  27212. /**
  27213. * Sets wether or not objects velocities are enabled for the G buffer.
  27214. */
  27215. set enableVelocity(enable: boolean);
  27216. /**
  27217. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27218. */
  27219. get enableReflectivity(): boolean;
  27220. /**
  27221. * Sets wether or not objects roughness are enabled for the G buffer.
  27222. */
  27223. set enableReflectivity(enable: boolean);
  27224. /**
  27225. * Gets the scene associated with the buffer.
  27226. */
  27227. get scene(): Scene;
  27228. /**
  27229. * Gets the ratio used by the buffer during its creation.
  27230. * How big is the buffer related to the main canvas.
  27231. */
  27232. get ratio(): number;
  27233. /** @hidden */
  27234. static _SceneComponentInitialization: (scene: Scene) => void;
  27235. /**
  27236. * Creates a new G Buffer for the scene
  27237. * @param scene The scene the buffer belongs to
  27238. * @param ratio How big is the buffer related to the main canvas.
  27239. */
  27240. constructor(scene: Scene, ratio?: number);
  27241. /**
  27242. * Checks wether everything is ready to render a submesh to the G buffer.
  27243. * @param subMesh the submesh to check readiness for
  27244. * @param useInstances is the mesh drawn using instance or not
  27245. * @returns true if ready otherwise false
  27246. */
  27247. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27248. /**
  27249. * Gets the current underlying G Buffer.
  27250. * @returns the buffer
  27251. */
  27252. getGBuffer(): MultiRenderTarget;
  27253. /**
  27254. * Gets the number of samples used to render the buffer (anti aliasing).
  27255. */
  27256. get samples(): number;
  27257. /**
  27258. * Sets the number of samples used to render the buffer (anti aliasing).
  27259. */
  27260. set samples(value: number);
  27261. /**
  27262. * Disposes the renderer and frees up associated resources.
  27263. */
  27264. dispose(): void;
  27265. private _assignRenderTargetIndices;
  27266. protected _createRenderTargets(): void;
  27267. private _copyBonesTransformationMatrices;
  27268. }
  27269. }
  27270. declare module BABYLON {
  27271. /**
  27272. * Renders a pre pass of the scene
  27273. * This means every mesh in the scene will be rendered to a render target texture
  27274. * And then this texture will be composited to the rendering canvas with post processes
  27275. * It is necessary for effects like subsurface scattering or deferred shading
  27276. */
  27277. export class PrePassRenderer {
  27278. /** @hidden */
  27279. static _SceneComponentInitialization: (scene: Scene) => void;
  27280. private _textureFormats;
  27281. /**
  27282. * To save performance, we can excluded skinned meshes from the prepass
  27283. */
  27284. excludedSkinnedMesh: AbstractMesh[];
  27285. /**
  27286. * Force material to be excluded from the prepass
  27287. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27288. * and you don't want a material to show in the effect.
  27289. */
  27290. excludedMaterials: Material[];
  27291. private _textureIndices;
  27292. private _scene;
  27293. private _engine;
  27294. private _isDirty;
  27295. /**
  27296. * Number of textures in the multi render target texture where the scene is directly rendered
  27297. */
  27298. mrtCount: number;
  27299. /**
  27300. * The render target where the scene is directly rendered
  27301. */
  27302. prePassRT: MultiRenderTarget;
  27303. private _multiRenderAttachments;
  27304. private _defaultAttachments;
  27305. private _clearAttachments;
  27306. private _postProcesses;
  27307. private readonly _clearColor;
  27308. /**
  27309. * Image processing post process for composition
  27310. */
  27311. imageProcessingPostProcess: ImageProcessingPostProcess;
  27312. /**
  27313. * Configuration for prepass effects
  27314. */
  27315. private _effectConfigurations;
  27316. private _mrtFormats;
  27317. private _mrtLayout;
  27318. private _enabled;
  27319. /**
  27320. * Indicates if the prepass is enabled
  27321. */
  27322. get enabled(): boolean;
  27323. /**
  27324. * How many samples are used for MSAA of the scene render target
  27325. */
  27326. get samples(): number;
  27327. set samples(n: number);
  27328. private _geometryBuffer;
  27329. private _useGeometryBufferFallback;
  27330. /**
  27331. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27332. */
  27333. get useGeometryBufferFallback(): boolean;
  27334. set useGeometryBufferFallback(value: boolean);
  27335. /**
  27336. * Instanciates a prepass renderer
  27337. * @param scene The scene
  27338. */
  27339. constructor(scene: Scene);
  27340. private _initializeAttachments;
  27341. private _createCompositionEffect;
  27342. /**
  27343. * Indicates if rendering a prepass is supported
  27344. */
  27345. get isSupported(): boolean;
  27346. /**
  27347. * Sets the proper output textures to draw in the engine.
  27348. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27349. * @param subMesh Submesh on which the effect is applied
  27350. */
  27351. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27352. /**
  27353. * @hidden
  27354. */
  27355. _beforeCameraDraw(): void;
  27356. /**
  27357. * @hidden
  27358. */
  27359. _afterCameraDraw(): void;
  27360. private _checkRTSize;
  27361. private _bindFrameBuffer;
  27362. /**
  27363. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27364. */
  27365. clear(): void;
  27366. private _setState;
  27367. private _updateGeometryBufferLayout;
  27368. /**
  27369. * Adds an effect configuration to the prepass.
  27370. * If an effect has already been added, it won't add it twice and will return the configuration
  27371. * already present.
  27372. * @param cfg the effect configuration
  27373. * @return the effect configuration now used by the prepass
  27374. */
  27375. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27376. /**
  27377. * Returns the index of a texture in the multi render target texture array.
  27378. * @param type Texture type
  27379. * @return The index
  27380. */
  27381. getIndex(type: number): number;
  27382. private _enable;
  27383. private _disable;
  27384. private _resetLayout;
  27385. private _resetPostProcessChain;
  27386. private _bindPostProcessChain;
  27387. /**
  27388. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27389. */
  27390. markAsDirty(): void;
  27391. /**
  27392. * Enables a texture on the MultiRenderTarget for prepass
  27393. */
  27394. private _enableTextures;
  27395. private _update;
  27396. private _markAllMaterialsAsPrePassDirty;
  27397. /**
  27398. * Disposes the prepass renderer.
  27399. */
  27400. dispose(): void;
  27401. }
  27402. }
  27403. declare module BABYLON {
  27404. /**
  27405. * Size options for a post process
  27406. */
  27407. export type PostProcessOptions = {
  27408. width: number;
  27409. height: number;
  27410. };
  27411. /**
  27412. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27413. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27414. */
  27415. export class PostProcess {
  27416. /**
  27417. * Gets or sets the unique id of the post process
  27418. */
  27419. uniqueId: number;
  27420. /** Name of the PostProcess. */
  27421. name: string;
  27422. /**
  27423. * Width of the texture to apply the post process on
  27424. */
  27425. width: number;
  27426. /**
  27427. * Height of the texture to apply the post process on
  27428. */
  27429. height: number;
  27430. /**
  27431. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27432. */
  27433. nodeMaterialSource: Nullable<NodeMaterial>;
  27434. /**
  27435. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27436. * @hidden
  27437. */
  27438. _outputTexture: Nullable<InternalTexture>;
  27439. /**
  27440. * Sampling mode used by the shader
  27441. * See https://doc.babylonjs.com/classes/3.1/texture
  27442. */
  27443. renderTargetSamplingMode: number;
  27444. /**
  27445. * Clear color to use when screen clearing
  27446. */
  27447. clearColor: Color4;
  27448. /**
  27449. * If the buffer needs to be cleared before applying the post process. (default: true)
  27450. * Should be set to false if shader will overwrite all previous pixels.
  27451. */
  27452. autoClear: boolean;
  27453. /**
  27454. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27455. */
  27456. alphaMode: number;
  27457. /**
  27458. * Sets the setAlphaBlendConstants of the babylon engine
  27459. */
  27460. alphaConstants: Color4;
  27461. /**
  27462. * Animations to be used for the post processing
  27463. */
  27464. animations: Animation[];
  27465. /**
  27466. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27467. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27468. */
  27469. enablePixelPerfectMode: boolean;
  27470. /**
  27471. * Force the postprocess to be applied without taking in account viewport
  27472. */
  27473. forceFullscreenViewport: boolean;
  27474. /**
  27475. * List of inspectable custom properties (used by the Inspector)
  27476. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27477. */
  27478. inspectableCustomProperties: IInspectable[];
  27479. /**
  27480. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27481. *
  27482. * | Value | Type | Description |
  27483. * | ----- | ----------------------------------- | ----------- |
  27484. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27485. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27486. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27487. *
  27488. */
  27489. scaleMode: number;
  27490. /**
  27491. * Force textures to be a power of two (default: false)
  27492. */
  27493. alwaysForcePOT: boolean;
  27494. private _samples;
  27495. /**
  27496. * Number of sample textures (default: 1)
  27497. */
  27498. get samples(): number;
  27499. set samples(n: number);
  27500. /**
  27501. * Modify the scale of the post process to be the same as the viewport (default: false)
  27502. */
  27503. adaptScaleToCurrentViewport: boolean;
  27504. private _camera;
  27505. protected _scene: Scene;
  27506. private _engine;
  27507. private _options;
  27508. private _reusable;
  27509. private _textureType;
  27510. private _textureFormat;
  27511. /**
  27512. * Smart array of input and output textures for the post process.
  27513. * @hidden
  27514. */
  27515. _textures: SmartArray<InternalTexture>;
  27516. /**
  27517. * The index in _textures that corresponds to the output texture.
  27518. * @hidden
  27519. */
  27520. _currentRenderTextureInd: number;
  27521. private _effect;
  27522. private _samplers;
  27523. private _fragmentUrl;
  27524. private _vertexUrl;
  27525. private _parameters;
  27526. private _scaleRatio;
  27527. protected _indexParameters: any;
  27528. private _shareOutputWithPostProcess;
  27529. private _texelSize;
  27530. private _forcedOutputTexture;
  27531. /**
  27532. * Prepass configuration in case this post process needs a texture from prepass
  27533. * @hidden
  27534. */
  27535. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27536. /**
  27537. * Returns the fragment url or shader name used in the post process.
  27538. * @returns the fragment url or name in the shader store.
  27539. */
  27540. getEffectName(): string;
  27541. /**
  27542. * An event triggered when the postprocess is activated.
  27543. */
  27544. onActivateObservable: Observable<Camera>;
  27545. private _onActivateObserver;
  27546. /**
  27547. * A function that is added to the onActivateObservable
  27548. */
  27549. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27550. /**
  27551. * An event triggered when the postprocess changes its size.
  27552. */
  27553. onSizeChangedObservable: Observable<PostProcess>;
  27554. private _onSizeChangedObserver;
  27555. /**
  27556. * A function that is added to the onSizeChangedObservable
  27557. */
  27558. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27559. /**
  27560. * An event triggered when the postprocess applies its effect.
  27561. */
  27562. onApplyObservable: Observable<Effect>;
  27563. private _onApplyObserver;
  27564. /**
  27565. * A function that is added to the onApplyObservable
  27566. */
  27567. set onApply(callback: (effect: Effect) => void);
  27568. /**
  27569. * An event triggered before rendering the postprocess
  27570. */
  27571. onBeforeRenderObservable: Observable<Effect>;
  27572. private _onBeforeRenderObserver;
  27573. /**
  27574. * A function that is added to the onBeforeRenderObservable
  27575. */
  27576. set onBeforeRender(callback: (effect: Effect) => void);
  27577. /**
  27578. * An event triggered after rendering the postprocess
  27579. */
  27580. onAfterRenderObservable: Observable<Effect>;
  27581. private _onAfterRenderObserver;
  27582. /**
  27583. * A function that is added to the onAfterRenderObservable
  27584. */
  27585. set onAfterRender(callback: (efect: Effect) => void);
  27586. /**
  27587. * 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
  27588. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27589. */
  27590. get inputTexture(): InternalTexture;
  27591. set inputTexture(value: InternalTexture);
  27592. /**
  27593. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27594. * the only way to unset it is to use this function to restore its internal state
  27595. */
  27596. restoreDefaultInputTexture(): void;
  27597. /**
  27598. * Gets the camera which post process is applied to.
  27599. * @returns The camera the post process is applied to.
  27600. */
  27601. getCamera(): Camera;
  27602. /**
  27603. * Gets the texel size of the postprocess.
  27604. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27605. */
  27606. get texelSize(): Vector2;
  27607. /**
  27608. * Creates a new instance PostProcess
  27609. * @param name The name of the PostProcess.
  27610. * @param fragmentUrl The url of the fragment shader to be used.
  27611. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27612. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27613. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27614. * @param camera The camera to apply the render pass to.
  27615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27616. * @param engine The engine which the post process will be applied. (default: current engine)
  27617. * @param reusable If the post process can be reused on the same frame. (default: false)
  27618. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27619. * @param textureType Type of textures used when performing the post process. (default: 0)
  27620. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27621. * @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
  27622. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27623. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27624. */
  27625. 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);
  27626. /**
  27627. * Gets a string identifying the name of the class
  27628. * @returns "PostProcess" string
  27629. */
  27630. getClassName(): string;
  27631. /**
  27632. * Gets the engine which this post process belongs to.
  27633. * @returns The engine the post process was enabled with.
  27634. */
  27635. getEngine(): Engine;
  27636. /**
  27637. * The effect that is created when initializing the post process.
  27638. * @returns The created effect corresponding the the postprocess.
  27639. */
  27640. getEffect(): Effect;
  27641. /**
  27642. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27643. * @param postProcess The post process to share the output with.
  27644. * @returns This post process.
  27645. */
  27646. shareOutputWith(postProcess: PostProcess): PostProcess;
  27647. /**
  27648. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27649. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27650. */
  27651. useOwnOutput(): void;
  27652. /**
  27653. * Updates the effect with the current post process compile time values and recompiles the shader.
  27654. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27655. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27656. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27657. * @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
  27658. * @param onCompiled Called when the shader has been compiled.
  27659. * @param onError Called if there is an error when compiling a shader.
  27660. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  27661. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  27662. */
  27663. 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;
  27664. /**
  27665. * The post process is reusable if it can be used multiple times within one frame.
  27666. * @returns If the post process is reusable
  27667. */
  27668. isReusable(): boolean;
  27669. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27670. markTextureDirty(): void;
  27671. /**
  27672. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27673. * 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.
  27674. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27675. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27676. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27677. * @returns The target texture that was bound to be written to.
  27678. */
  27679. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27680. /**
  27681. * If the post process is supported.
  27682. */
  27683. get isSupported(): boolean;
  27684. /**
  27685. * The aspect ratio of the output texture.
  27686. */
  27687. get aspectRatio(): number;
  27688. /**
  27689. * Get a value indicating if the post-process is ready to be used
  27690. * @returns true if the post-process is ready (shader is compiled)
  27691. */
  27692. isReady(): boolean;
  27693. /**
  27694. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27695. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  27696. */
  27697. apply(): Nullable<Effect>;
  27698. private _disposeTextures;
  27699. /**
  27700. * Sets the required values to the prepass renderer.
  27701. * @param prePassRenderer defines the prepass renderer to setup.
  27702. * @returns true if the pre pass is needed.
  27703. */
  27704. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27705. /**
  27706. * Disposes the post process.
  27707. * @param camera The camera to dispose the post process on.
  27708. */
  27709. dispose(camera?: Camera): void;
  27710. /**
  27711. * Serializes the particle system to a JSON object
  27712. * @returns the JSON object
  27713. */
  27714. serialize(): any;
  27715. /**
  27716. * Creates a material from parsed material data
  27717. * @param parsedPostProcess defines parsed post process data
  27718. * @param scene defines the hosting scene
  27719. * @param rootUrl defines the root URL to use to load textures
  27720. * @returns a new post process
  27721. */
  27722. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  27723. }
  27724. }
  27725. declare module BABYLON {
  27726. /** @hidden */
  27727. export var kernelBlurVaryingDeclaration: {
  27728. name: string;
  27729. shader: string;
  27730. };
  27731. }
  27732. declare module BABYLON {
  27733. /** @hidden */
  27734. export var kernelBlurFragment: {
  27735. name: string;
  27736. shader: string;
  27737. };
  27738. }
  27739. declare module BABYLON {
  27740. /** @hidden */
  27741. export var kernelBlurFragment2: {
  27742. name: string;
  27743. shader: string;
  27744. };
  27745. }
  27746. declare module BABYLON {
  27747. /** @hidden */
  27748. export var kernelBlurPixelShader: {
  27749. name: string;
  27750. shader: string;
  27751. };
  27752. }
  27753. declare module BABYLON {
  27754. /** @hidden */
  27755. export var kernelBlurVertex: {
  27756. name: string;
  27757. shader: string;
  27758. };
  27759. }
  27760. declare module BABYLON {
  27761. /** @hidden */
  27762. export var kernelBlurVertexShader: {
  27763. name: string;
  27764. shader: string;
  27765. };
  27766. }
  27767. declare module BABYLON {
  27768. /**
  27769. * The Blur Post Process which blurs an image based on a kernel and direction.
  27770. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27771. */
  27772. export class BlurPostProcess extends PostProcess {
  27773. private blockCompilation;
  27774. protected _kernel: number;
  27775. protected _idealKernel: number;
  27776. protected _packedFloat: boolean;
  27777. private _staticDefines;
  27778. /** The direction in which to blur the image. */
  27779. direction: Vector2;
  27780. /**
  27781. * Sets the length in pixels of the blur sample region
  27782. */
  27783. set kernel(v: number);
  27784. /**
  27785. * Gets the length in pixels of the blur sample region
  27786. */
  27787. get kernel(): number;
  27788. /**
  27789. * Sets wether or not the blur needs to unpack/repack floats
  27790. */
  27791. set packedFloat(v: boolean);
  27792. /**
  27793. * Gets wether or not the blur is unpacking/repacking floats
  27794. */
  27795. get packedFloat(): boolean;
  27796. /**
  27797. * Gets a string identifying the name of the class
  27798. * @returns "BlurPostProcess" string
  27799. */
  27800. getClassName(): string;
  27801. /**
  27802. * Creates a new instance BlurPostProcess
  27803. * @param name The name of the effect.
  27804. * @param direction The direction in which to blur the image.
  27805. * @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.
  27806. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27807. * @param camera The camera to apply the render pass to.
  27808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27809. * @param engine The engine which the post process will be applied. (default: current engine)
  27810. * @param reusable If the post process can be reused on the same frame. (default: false)
  27811. * @param textureType Type of textures used when performing the post process. (default: 0)
  27812. * @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)
  27813. */
  27814. 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);
  27815. /**
  27816. * Updates the effect with the current post process compile time values and recompiles the shader.
  27817. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27818. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27819. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27820. * @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
  27821. * @param onCompiled Called when the shader has been compiled.
  27822. * @param onError Called if there is an error when compiling a shader.
  27823. */
  27824. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27825. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27826. /**
  27827. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27828. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27829. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27830. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27831. * The gaps between physical kernels are compensated for in the weighting of the samples
  27832. * @param idealKernel Ideal blur kernel.
  27833. * @return Nearest best kernel.
  27834. */
  27835. protected _nearestBestKernel(idealKernel: number): number;
  27836. /**
  27837. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27838. * @param x The point on the Gaussian distribution to sample.
  27839. * @return the value of the Gaussian function at x.
  27840. */
  27841. protected _gaussianWeight(x: number): number;
  27842. /**
  27843. * Generates a string that can be used as a floating point number in GLSL.
  27844. * @param x Value to print.
  27845. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27846. * @return GLSL float string.
  27847. */
  27848. protected _glslFloat(x: number, decimalFigures?: number): string;
  27849. /** @hidden */
  27850. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  27851. }
  27852. }
  27853. declare module BABYLON {
  27854. /**
  27855. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27856. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27857. * You can then easily use it as a reflectionTexture on a flat surface.
  27858. * In case the surface is not a plane, please consider relying on reflection probes.
  27859. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27860. */
  27861. export class MirrorTexture extends RenderTargetTexture {
  27862. private scene;
  27863. /**
  27864. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  27865. * 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.
  27866. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27867. */
  27868. mirrorPlane: Plane;
  27869. /**
  27870. * Define the blur ratio used to blur the reflection if needed.
  27871. */
  27872. set blurRatio(value: number);
  27873. get blurRatio(): number;
  27874. /**
  27875. * Define the adaptive blur kernel used to blur the reflection if needed.
  27876. * This will autocompute the closest best match for the `blurKernel`
  27877. */
  27878. set adaptiveBlurKernel(value: number);
  27879. /**
  27880. * Define the blur kernel used to blur the reflection if needed.
  27881. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27882. */
  27883. set blurKernel(value: number);
  27884. /**
  27885. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  27886. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27887. */
  27888. set blurKernelX(value: number);
  27889. get blurKernelX(): number;
  27890. /**
  27891. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  27892. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27893. */
  27894. set blurKernelY(value: number);
  27895. get blurKernelY(): number;
  27896. private _autoComputeBlurKernel;
  27897. protected _onRatioRescale(): void;
  27898. private _updateGammaSpace;
  27899. private _imageProcessingConfigChangeObserver;
  27900. private _transformMatrix;
  27901. private _mirrorMatrix;
  27902. private _savedViewMatrix;
  27903. private _blurX;
  27904. private _blurY;
  27905. private _adaptiveBlurKernel;
  27906. private _blurKernelX;
  27907. private _blurKernelY;
  27908. private _blurRatio;
  27909. /**
  27910. * Instantiates a Mirror Texture.
  27911. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27912. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27913. * You can then easily use it as a reflectionTexture on a flat surface.
  27914. * In case the surface is not a plane, please consider relying on reflection probes.
  27915. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27916. * @param name
  27917. * @param size
  27918. * @param scene
  27919. * @param generateMipMaps
  27920. * @param type
  27921. * @param samplingMode
  27922. * @param generateDepthBuffer
  27923. */
  27924. constructor(name: string, size: number | {
  27925. width: number;
  27926. height: number;
  27927. } | {
  27928. ratio: number;
  27929. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  27930. private _preparePostProcesses;
  27931. /**
  27932. * Clone the mirror texture.
  27933. * @returns the cloned texture
  27934. */
  27935. clone(): MirrorTexture;
  27936. /**
  27937. * Serialize the texture to a JSON representation you could use in Parse later on
  27938. * @returns the serialized JSON representation
  27939. */
  27940. serialize(): any;
  27941. /**
  27942. * Dispose the texture and release its associated resources.
  27943. */
  27944. dispose(): void;
  27945. }
  27946. }
  27947. declare module BABYLON {
  27948. /**
  27949. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  27950. * @see https://doc.babylonjs.com/babylon101/materials#texture
  27951. */
  27952. export class Texture extends BaseTexture {
  27953. /**
  27954. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  27955. */
  27956. static SerializeBuffers: boolean;
  27957. /** @hidden */
  27958. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  27959. /** @hidden */
  27960. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  27961. /** @hidden */
  27962. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  27963. /** nearest is mag = nearest and min = nearest and mip = linear */
  27964. static readonly NEAREST_SAMPLINGMODE: number;
  27965. /** nearest is mag = nearest and min = nearest and mip = linear */
  27966. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  27967. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27968. static readonly BILINEAR_SAMPLINGMODE: number;
  27969. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27970. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  27971. /** Trilinear is mag = linear and min = linear and mip = linear */
  27972. static readonly TRILINEAR_SAMPLINGMODE: number;
  27973. /** Trilinear is mag = linear and min = linear and mip = linear */
  27974. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  27975. /** mag = nearest and min = nearest and mip = nearest */
  27976. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  27977. /** mag = nearest and min = linear and mip = nearest */
  27978. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  27979. /** mag = nearest and min = linear and mip = linear */
  27980. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  27981. /** mag = nearest and min = linear and mip = none */
  27982. static readonly NEAREST_LINEAR: number;
  27983. /** mag = nearest and min = nearest and mip = none */
  27984. static readonly NEAREST_NEAREST: number;
  27985. /** mag = linear and min = nearest and mip = nearest */
  27986. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  27987. /** mag = linear and min = nearest and mip = linear */
  27988. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  27989. /** mag = linear and min = linear and mip = none */
  27990. static readonly LINEAR_LINEAR: number;
  27991. /** mag = linear and min = nearest and mip = none */
  27992. static readonly LINEAR_NEAREST: number;
  27993. /** Explicit coordinates mode */
  27994. static readonly EXPLICIT_MODE: number;
  27995. /** Spherical coordinates mode */
  27996. static readonly SPHERICAL_MODE: number;
  27997. /** Planar coordinates mode */
  27998. static readonly PLANAR_MODE: number;
  27999. /** Cubic coordinates mode */
  28000. static readonly CUBIC_MODE: number;
  28001. /** Projection coordinates mode */
  28002. static readonly PROJECTION_MODE: number;
  28003. /** Inverse Cubic coordinates mode */
  28004. static readonly SKYBOX_MODE: number;
  28005. /** Inverse Cubic coordinates mode */
  28006. static readonly INVCUBIC_MODE: number;
  28007. /** Equirectangular coordinates mode */
  28008. static readonly EQUIRECTANGULAR_MODE: number;
  28009. /** Equirectangular Fixed coordinates mode */
  28010. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28011. /** Equirectangular Fixed Mirrored coordinates mode */
  28012. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28013. /** Texture is not repeating outside of 0..1 UVs */
  28014. static readonly CLAMP_ADDRESSMODE: number;
  28015. /** Texture is repeating outside of 0..1 UVs */
  28016. static readonly WRAP_ADDRESSMODE: number;
  28017. /** Texture is repeating and mirrored */
  28018. static readonly MIRROR_ADDRESSMODE: number;
  28019. /**
  28020. * 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
  28021. */
  28022. static UseSerializedUrlIfAny: boolean;
  28023. /**
  28024. * Define the url of the texture.
  28025. */
  28026. url: Nullable<string>;
  28027. /**
  28028. * Define an offset on the texture to offset the u coordinates of the UVs
  28029. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28030. */
  28031. uOffset: number;
  28032. /**
  28033. * Define an offset on the texture to offset the v coordinates of the UVs
  28034. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28035. */
  28036. vOffset: number;
  28037. /**
  28038. * Define an offset on the texture to scale the u coordinates of the UVs
  28039. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28040. */
  28041. uScale: number;
  28042. /**
  28043. * Define an offset on the texture to scale the v coordinates of the UVs
  28044. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28045. */
  28046. vScale: number;
  28047. /**
  28048. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28049. * @see https://doc.babylonjs.com/how_to/more_materials
  28050. */
  28051. uAng: number;
  28052. /**
  28053. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28054. * @see https://doc.babylonjs.com/how_to/more_materials
  28055. */
  28056. vAng: number;
  28057. /**
  28058. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28059. * @see https://doc.babylonjs.com/how_to/more_materials
  28060. */
  28061. wAng: number;
  28062. /**
  28063. * Defines the center of rotation (U)
  28064. */
  28065. uRotationCenter: number;
  28066. /**
  28067. * Defines the center of rotation (V)
  28068. */
  28069. vRotationCenter: number;
  28070. /**
  28071. * Defines the center of rotation (W)
  28072. */
  28073. wRotationCenter: number;
  28074. /**
  28075. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28076. */
  28077. homogeneousRotationInUVTransform: boolean;
  28078. /**
  28079. * Are mip maps generated for this texture or not.
  28080. */
  28081. get noMipmap(): boolean;
  28082. /**
  28083. * List of inspectable custom properties (used by the Inspector)
  28084. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28085. */
  28086. inspectableCustomProperties: Nullable<IInspectable[]>;
  28087. private _noMipmap;
  28088. /** @hidden */
  28089. _invertY: boolean;
  28090. private _rowGenerationMatrix;
  28091. private _cachedTextureMatrix;
  28092. private _projectionModeMatrix;
  28093. private _t0;
  28094. private _t1;
  28095. private _t2;
  28096. private _cachedUOffset;
  28097. private _cachedVOffset;
  28098. private _cachedUScale;
  28099. private _cachedVScale;
  28100. private _cachedUAng;
  28101. private _cachedVAng;
  28102. private _cachedWAng;
  28103. private _cachedProjectionMatrixId;
  28104. private _cachedURotationCenter;
  28105. private _cachedVRotationCenter;
  28106. private _cachedWRotationCenter;
  28107. private _cachedHomogeneousRotationInUVTransform;
  28108. private _cachedCoordinatesMode;
  28109. /** @hidden */
  28110. protected _initialSamplingMode: number;
  28111. /** @hidden */
  28112. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28113. private _deleteBuffer;
  28114. protected _format: Nullable<number>;
  28115. private _delayedOnLoad;
  28116. private _delayedOnError;
  28117. private _mimeType?;
  28118. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28119. get mimeType(): string | undefined;
  28120. /**
  28121. * Observable triggered once the texture has been loaded.
  28122. */
  28123. onLoadObservable: Observable<Texture>;
  28124. protected _isBlocking: boolean;
  28125. /**
  28126. * Is the texture preventing material to render while loading.
  28127. * If false, a default texture will be used instead of the loading one during the preparation step.
  28128. */
  28129. set isBlocking(value: boolean);
  28130. get isBlocking(): boolean;
  28131. /**
  28132. * Get the current sampling mode associated with the texture.
  28133. */
  28134. get samplingMode(): number;
  28135. /**
  28136. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28137. */
  28138. get invertY(): boolean;
  28139. /**
  28140. * Instantiates a new texture.
  28141. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28142. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28143. * @param url defines the url of the picture to load as a texture
  28144. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28145. * @param noMipmap defines if the texture will require mip maps or not
  28146. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28147. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28148. * @param onLoad defines a callback triggered when the texture has been loaded
  28149. * @param onError defines a callback triggered when an error occurred during the loading session
  28150. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28151. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28152. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28153. * @param mimeType defines an optional mime type information
  28154. */
  28155. 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);
  28156. /**
  28157. * Update the url (and optional buffer) of this texture if url was null during construction.
  28158. * @param url the url of the texture
  28159. * @param buffer the buffer of the texture (defaults to null)
  28160. * @param onLoad callback called when the texture is loaded (defaults to null)
  28161. */
  28162. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28163. /**
  28164. * Finish the loading sequence of a texture flagged as delayed load.
  28165. * @hidden
  28166. */
  28167. delayLoad(): void;
  28168. private _prepareRowForTextureGeneration;
  28169. /**
  28170. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28171. * @returns the transform matrix of the texture.
  28172. */
  28173. getTextureMatrix(uBase?: number): Matrix;
  28174. /**
  28175. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28176. * @returns The reflection texture transform
  28177. */
  28178. getReflectionTextureMatrix(): Matrix;
  28179. /**
  28180. * Clones the texture.
  28181. * @returns the cloned texture
  28182. */
  28183. clone(): Texture;
  28184. /**
  28185. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28186. * @returns The JSON representation of the texture
  28187. */
  28188. serialize(): any;
  28189. /**
  28190. * Get the current class name of the texture useful for serialization or dynamic coding.
  28191. * @returns "Texture"
  28192. */
  28193. getClassName(): string;
  28194. /**
  28195. * Dispose the texture and release its associated resources.
  28196. */
  28197. dispose(): void;
  28198. /**
  28199. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28200. * @param parsedTexture Define the JSON representation of the texture
  28201. * @param scene Define the scene the parsed texture should be instantiated in
  28202. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28203. * @returns The parsed texture if successful
  28204. */
  28205. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28206. /**
  28207. * Creates a texture from its base 64 representation.
  28208. * @param data Define the base64 payload without the data: prefix
  28209. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28210. * @param scene Define the scene the texture should belong to
  28211. * @param noMipmap Forces the texture to not create mip map information if true
  28212. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28213. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28214. * @param onLoad define a callback triggered when the texture has been loaded
  28215. * @param onError define a callback triggered when an error occurred during the loading session
  28216. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28217. * @returns the created texture
  28218. */
  28219. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28220. /**
  28221. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28222. * @param data Define the base64 payload without the data: prefix
  28223. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28224. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28225. * @param scene Define the scene the texture should belong to
  28226. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28227. * @param noMipmap Forces the texture to not create mip map information if true
  28228. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28229. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28230. * @param onLoad define a callback triggered when the texture has been loaded
  28231. * @param onError define a callback triggered when an error occurred during the loading session
  28232. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28233. * @returns the created texture
  28234. */
  28235. 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;
  28236. }
  28237. }
  28238. declare module BABYLON {
  28239. /**
  28240. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28241. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28242. */
  28243. export class PostProcessManager {
  28244. private _scene;
  28245. private _indexBuffer;
  28246. private _vertexBuffers;
  28247. /**
  28248. * Creates a new instance PostProcess
  28249. * @param scene The scene that the post process is associated with.
  28250. */
  28251. constructor(scene: Scene);
  28252. private _prepareBuffers;
  28253. private _buildIndexBuffer;
  28254. /**
  28255. * Rebuilds the vertex buffers of the manager.
  28256. * @hidden
  28257. */
  28258. _rebuild(): void;
  28259. /**
  28260. * Prepares a frame to be run through a post process.
  28261. * @param sourceTexture The input texture to the post procesess. (default: null)
  28262. * @param postProcesses An array of post processes to be run. (default: null)
  28263. * @returns True if the post processes were able to be run.
  28264. * @hidden
  28265. */
  28266. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28267. /**
  28268. * Manually render a set of post processes to a texture.
  28269. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28270. * @param postProcesses An array of post processes to be run.
  28271. * @param targetTexture The target texture to render to.
  28272. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28273. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28274. * @param lodLevel defines which lod of the texture to render to
  28275. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28276. */
  28277. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28278. /**
  28279. * Finalize the result of the output of the postprocesses.
  28280. * @param doNotPresent If true the result will not be displayed to the screen.
  28281. * @param targetTexture The target texture to render to.
  28282. * @param faceIndex The index of the face to bind the target texture to.
  28283. * @param postProcesses The array of post processes to render.
  28284. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28285. * @hidden
  28286. */
  28287. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28288. /**
  28289. * Disposes of the post process manager.
  28290. */
  28291. dispose(): void;
  28292. }
  28293. }
  28294. declare module BABYLON {
  28295. /**
  28296. * This Helps creating a texture that will be created from a camera in your scene.
  28297. * It is basically a dynamic texture that could be used to create special effects for instance.
  28298. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28299. */
  28300. export class RenderTargetTexture extends Texture {
  28301. /**
  28302. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28303. */
  28304. static readonly REFRESHRATE_RENDER_ONCE: number;
  28305. /**
  28306. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28307. */
  28308. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28309. /**
  28310. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28311. * the central point of your effect and can save a lot of performances.
  28312. */
  28313. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28314. /**
  28315. * Use this predicate to dynamically define the list of mesh you want to render.
  28316. * If set, the renderList property will be overwritten.
  28317. */
  28318. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28319. private _renderList;
  28320. /**
  28321. * Use this list to define the list of mesh you want to render.
  28322. */
  28323. get renderList(): Nullable<Array<AbstractMesh>>;
  28324. set renderList(value: Nullable<Array<AbstractMesh>>);
  28325. /**
  28326. * Use this function to overload the renderList array at rendering time.
  28327. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28328. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28329. * the cube (if the RTT is a cube, else layerOrFace=0).
  28330. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28331. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28332. * hold dummy elements!
  28333. */
  28334. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28335. private _hookArray;
  28336. /**
  28337. * Define if particles should be rendered in your texture.
  28338. */
  28339. renderParticles: boolean;
  28340. /**
  28341. * Define if sprites should be rendered in your texture.
  28342. */
  28343. renderSprites: boolean;
  28344. /**
  28345. * Define the camera used to render the texture.
  28346. */
  28347. activeCamera: Nullable<Camera>;
  28348. /**
  28349. * Override the mesh isReady function with your own one.
  28350. */
  28351. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28352. /**
  28353. * Override the render function of the texture with your own one.
  28354. */
  28355. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28356. /**
  28357. * Define if camera post processes should be use while rendering the texture.
  28358. */
  28359. useCameraPostProcesses: boolean;
  28360. /**
  28361. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28362. */
  28363. ignoreCameraViewport: boolean;
  28364. private _postProcessManager;
  28365. private _postProcesses;
  28366. private _resizeObserver;
  28367. /**
  28368. * An event triggered when the texture is unbind.
  28369. */
  28370. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28371. /**
  28372. * An event triggered when the texture is unbind.
  28373. */
  28374. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28375. private _onAfterUnbindObserver;
  28376. /**
  28377. * Set a after unbind callback in the texture.
  28378. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28379. */
  28380. set onAfterUnbind(callback: () => void);
  28381. /**
  28382. * An event triggered before rendering the texture
  28383. */
  28384. onBeforeRenderObservable: Observable<number>;
  28385. private _onBeforeRenderObserver;
  28386. /**
  28387. * Set a before render callback in the texture.
  28388. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28389. */
  28390. set onBeforeRender(callback: (faceIndex: number) => void);
  28391. /**
  28392. * An event triggered after rendering the texture
  28393. */
  28394. onAfterRenderObservable: Observable<number>;
  28395. private _onAfterRenderObserver;
  28396. /**
  28397. * Set a after render callback in the texture.
  28398. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28399. */
  28400. set onAfterRender(callback: (faceIndex: number) => void);
  28401. /**
  28402. * An event triggered after the texture clear
  28403. */
  28404. onClearObservable: Observable<Engine>;
  28405. private _onClearObserver;
  28406. /**
  28407. * Set a clear callback in the texture.
  28408. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28409. */
  28410. set onClear(callback: (Engine: Engine) => void);
  28411. /**
  28412. * An event triggered when the texture is resized.
  28413. */
  28414. onResizeObservable: Observable<RenderTargetTexture>;
  28415. /**
  28416. * Define the clear color of the Render Target if it should be different from the scene.
  28417. */
  28418. clearColor: Color4;
  28419. protected _size: number | {
  28420. width: number;
  28421. height: number;
  28422. layers?: number;
  28423. };
  28424. protected _initialSizeParameter: number | {
  28425. width: number;
  28426. height: number;
  28427. } | {
  28428. ratio: number;
  28429. };
  28430. protected _sizeRatio: Nullable<number>;
  28431. /** @hidden */
  28432. _generateMipMaps: boolean;
  28433. protected _renderingManager: RenderingManager;
  28434. /** @hidden */
  28435. _waitingRenderList?: string[];
  28436. protected _doNotChangeAspectRatio: boolean;
  28437. protected _currentRefreshId: number;
  28438. protected _refreshRate: number;
  28439. protected _textureMatrix: Matrix;
  28440. protected _samples: number;
  28441. protected _renderTargetOptions: RenderTargetCreationOptions;
  28442. /**
  28443. * Gets render target creation options that were used.
  28444. */
  28445. get renderTargetOptions(): RenderTargetCreationOptions;
  28446. protected _onRatioRescale(): void;
  28447. /**
  28448. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28449. * It must define where the camera used to render the texture is set
  28450. */
  28451. boundingBoxPosition: Vector3;
  28452. private _boundingBoxSize;
  28453. /**
  28454. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28455. * When defined, the cubemap will switch to local mode
  28456. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28457. * @example https://www.babylonjs-playground.com/#RNASML
  28458. */
  28459. set boundingBoxSize(value: Vector3);
  28460. get boundingBoxSize(): Vector3;
  28461. /**
  28462. * In case the RTT has been created with a depth texture, get the associated
  28463. * depth texture.
  28464. * Otherwise, return null.
  28465. */
  28466. get depthStencilTexture(): Nullable<InternalTexture>;
  28467. /**
  28468. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28469. * or used a shadow, depth texture...
  28470. * @param name The friendly name of the texture
  28471. * @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)
  28472. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28473. * @param generateMipMaps True if mip maps need to be generated after render.
  28474. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28475. * @param type The type of the buffer in the RTT (int, half float, float...)
  28476. * @param isCube True if a cube texture needs to be created
  28477. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28478. * @param generateDepthBuffer True to generate a depth buffer
  28479. * @param generateStencilBuffer True to generate a stencil buffer
  28480. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28481. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28482. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28483. */
  28484. constructor(name: string, size: number | {
  28485. width: number;
  28486. height: number;
  28487. layers?: number;
  28488. } | {
  28489. ratio: number;
  28490. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28491. /**
  28492. * Creates a depth stencil texture.
  28493. * This is only available in WebGL 2 or with the depth texture extension available.
  28494. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28495. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28496. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28497. */
  28498. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28499. private _processSizeParameter;
  28500. /**
  28501. * Define the number of samples to use in case of MSAA.
  28502. * It defaults to one meaning no MSAA has been enabled.
  28503. */
  28504. get samples(): number;
  28505. set samples(value: number);
  28506. /**
  28507. * Resets the refresh counter of the texture and start bak from scratch.
  28508. * Could be useful to regenerate the texture if it is setup to render only once.
  28509. */
  28510. resetRefreshCounter(): void;
  28511. /**
  28512. * Define the refresh rate of the texture or the rendering frequency.
  28513. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28514. */
  28515. get refreshRate(): number;
  28516. set refreshRate(value: number);
  28517. /**
  28518. * Adds a post process to the render target rendering passes.
  28519. * @param postProcess define the post process to add
  28520. */
  28521. addPostProcess(postProcess: PostProcess): void;
  28522. /**
  28523. * Clear all the post processes attached to the render target
  28524. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28525. */
  28526. clearPostProcesses(dispose?: boolean): void;
  28527. /**
  28528. * Remove one of the post process from the list of attached post processes to the texture
  28529. * @param postProcess define the post process to remove from the list
  28530. */
  28531. removePostProcess(postProcess: PostProcess): void;
  28532. /** @hidden */
  28533. _shouldRender(): boolean;
  28534. /**
  28535. * Gets the actual render size of the texture.
  28536. * @returns the width of the render size
  28537. */
  28538. getRenderSize(): number;
  28539. /**
  28540. * Gets the actual render width of the texture.
  28541. * @returns the width of the render size
  28542. */
  28543. getRenderWidth(): number;
  28544. /**
  28545. * Gets the actual render height of the texture.
  28546. * @returns the height of the render size
  28547. */
  28548. getRenderHeight(): number;
  28549. /**
  28550. * Gets the actual number of layers of the texture.
  28551. * @returns the number of layers
  28552. */
  28553. getRenderLayers(): number;
  28554. /**
  28555. * Get if the texture can be rescaled or not.
  28556. */
  28557. get canRescale(): boolean;
  28558. /**
  28559. * Resize the texture using a ratio.
  28560. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28561. */
  28562. scale(ratio: number): void;
  28563. /**
  28564. * Get the texture reflection matrix used to rotate/transform the reflection.
  28565. * @returns the reflection matrix
  28566. */
  28567. getReflectionTextureMatrix(): Matrix;
  28568. /**
  28569. * Resize the texture to a new desired size.
  28570. * Be carrefull as it will recreate all the data in the new texture.
  28571. * @param size Define the new size. It can be:
  28572. * - a number for squared texture,
  28573. * - an object containing { width: number, height: number }
  28574. * - or an object containing a ratio { ratio: number }
  28575. */
  28576. resize(size: number | {
  28577. width: number;
  28578. height: number;
  28579. } | {
  28580. ratio: number;
  28581. }): void;
  28582. private _defaultRenderListPrepared;
  28583. /**
  28584. * Renders all the objects from the render list into the texture.
  28585. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28586. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28587. */
  28588. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28589. private _bestReflectionRenderTargetDimension;
  28590. private _prepareRenderingManager;
  28591. /**
  28592. * @hidden
  28593. * @param faceIndex face index to bind to if this is a cubetexture
  28594. * @param layer defines the index of the texture to bind in the array
  28595. */
  28596. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28597. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28598. private renderToTarget;
  28599. /**
  28600. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28601. * This allowed control for front to back rendering or reversly depending of the special needs.
  28602. *
  28603. * @param renderingGroupId The rendering group id corresponding to its index
  28604. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28605. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28606. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28607. */
  28608. 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;
  28609. /**
  28610. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28611. *
  28612. * @param renderingGroupId The rendering group id corresponding to its index
  28613. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28614. */
  28615. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28616. /**
  28617. * Clones the texture.
  28618. * @returns the cloned texture
  28619. */
  28620. clone(): RenderTargetTexture;
  28621. /**
  28622. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28623. * @returns The JSON representation of the texture
  28624. */
  28625. serialize(): any;
  28626. /**
  28627. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  28628. */
  28629. disposeFramebufferObjects(): void;
  28630. /**
  28631. * Dispose the texture and release its associated resources.
  28632. */
  28633. dispose(): void;
  28634. /** @hidden */
  28635. _rebuild(): void;
  28636. /**
  28637. * Clear the info related to rendering groups preventing retention point in material dispose.
  28638. */
  28639. freeRenderingGroups(): void;
  28640. /**
  28641. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28642. * @returns the view count
  28643. */
  28644. getViewCount(): number;
  28645. }
  28646. }
  28647. declare module BABYLON {
  28648. /**
  28649. * Class used to manipulate GUIDs
  28650. */
  28651. export class GUID {
  28652. /**
  28653. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28654. * Be aware Math.random() could cause collisions, but:
  28655. * "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"
  28656. * @returns a pseudo random id
  28657. */
  28658. static RandomId(): string;
  28659. }
  28660. }
  28661. declare module BABYLON {
  28662. /**
  28663. * Options to be used when creating a shadow depth material
  28664. */
  28665. export interface IIOptionShadowDepthMaterial {
  28666. /** Variables in the vertex shader code that need to have their names remapped.
  28667. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  28668. * "var_name" should be either: worldPos or vNormalW
  28669. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  28670. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  28671. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  28672. */
  28673. remappedVariables?: string[];
  28674. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  28675. standalone?: boolean;
  28676. }
  28677. /**
  28678. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  28679. */
  28680. export class ShadowDepthWrapper {
  28681. private _scene;
  28682. private _options?;
  28683. private _baseMaterial;
  28684. private _onEffectCreatedObserver;
  28685. private _subMeshToEffect;
  28686. private _subMeshToDepthEffect;
  28687. private _meshes;
  28688. /** @hidden */
  28689. _matriceNames: any;
  28690. /** Gets the standalone status of the wrapper */
  28691. get standalone(): boolean;
  28692. /** Gets the base material the wrapper is built upon */
  28693. get baseMaterial(): Material;
  28694. /**
  28695. * Instantiate a new shadow depth wrapper.
  28696. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  28697. * generate the shadow depth map. For more information, please refer to the documentation:
  28698. * https://doc.babylonjs.com/babylon101/shadows
  28699. * @param baseMaterial Material to wrap
  28700. * @param scene Define the scene the material belongs to
  28701. * @param options Options used to create the wrapper
  28702. */
  28703. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  28704. /**
  28705. * Gets the effect to use to generate the depth map
  28706. * @param subMesh subMesh to get the effect for
  28707. * @param shadowGenerator shadow generator to get the effect for
  28708. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  28709. */
  28710. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  28711. /**
  28712. * Specifies that the submesh is ready to be used for depth rendering
  28713. * @param subMesh submesh to check
  28714. * @param defines the list of defines to take into account when checking the effect
  28715. * @param shadowGenerator combined with subMesh, it defines the effect to check
  28716. * @param useInstances specifies that instances should be used
  28717. * @returns a boolean indicating that the submesh is ready or not
  28718. */
  28719. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  28720. /**
  28721. * Disposes the resources
  28722. */
  28723. dispose(): void;
  28724. private _makeEffect;
  28725. }
  28726. }
  28727. declare module BABYLON {
  28728. /**
  28729. * Options for compiling materials.
  28730. */
  28731. export interface IMaterialCompilationOptions {
  28732. /**
  28733. * Defines whether clip planes are enabled.
  28734. */
  28735. clipPlane: boolean;
  28736. /**
  28737. * Defines whether instances are enabled.
  28738. */
  28739. useInstances: boolean;
  28740. }
  28741. /**
  28742. * Options passed when calling customShaderNameResolve
  28743. */
  28744. export interface ICustomShaderNameResolveOptions {
  28745. /**
  28746. * 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
  28747. */
  28748. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  28749. }
  28750. /**
  28751. * Base class for the main features of a material in Babylon.js
  28752. */
  28753. export class Material implements IAnimatable {
  28754. /**
  28755. * Returns the triangle fill mode
  28756. */
  28757. static readonly TriangleFillMode: number;
  28758. /**
  28759. * Returns the wireframe mode
  28760. */
  28761. static readonly WireFrameFillMode: number;
  28762. /**
  28763. * Returns the point fill mode
  28764. */
  28765. static readonly PointFillMode: number;
  28766. /**
  28767. * Returns the point list draw mode
  28768. */
  28769. static readonly PointListDrawMode: number;
  28770. /**
  28771. * Returns the line list draw mode
  28772. */
  28773. static readonly LineListDrawMode: number;
  28774. /**
  28775. * Returns the line loop draw mode
  28776. */
  28777. static readonly LineLoopDrawMode: number;
  28778. /**
  28779. * Returns the line strip draw mode
  28780. */
  28781. static readonly LineStripDrawMode: number;
  28782. /**
  28783. * Returns the triangle strip draw mode
  28784. */
  28785. static readonly TriangleStripDrawMode: number;
  28786. /**
  28787. * Returns the triangle fan draw mode
  28788. */
  28789. static readonly TriangleFanDrawMode: number;
  28790. /**
  28791. * Stores the clock-wise side orientation
  28792. */
  28793. static readonly ClockWiseSideOrientation: number;
  28794. /**
  28795. * Stores the counter clock-wise side orientation
  28796. */
  28797. static readonly CounterClockWiseSideOrientation: number;
  28798. /**
  28799. * The dirty texture flag value
  28800. */
  28801. static readonly TextureDirtyFlag: number;
  28802. /**
  28803. * The dirty light flag value
  28804. */
  28805. static readonly LightDirtyFlag: number;
  28806. /**
  28807. * The dirty fresnel flag value
  28808. */
  28809. static readonly FresnelDirtyFlag: number;
  28810. /**
  28811. * The dirty attribute flag value
  28812. */
  28813. static readonly AttributesDirtyFlag: number;
  28814. /**
  28815. * The dirty misc flag value
  28816. */
  28817. static readonly MiscDirtyFlag: number;
  28818. /**
  28819. * The dirty prepass flag value
  28820. */
  28821. static readonly PrePassDirtyFlag: number;
  28822. /**
  28823. * The all dirty flag value
  28824. */
  28825. static readonly AllDirtyFlag: number;
  28826. /**
  28827. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  28828. */
  28829. static readonly MATERIAL_OPAQUE: number;
  28830. /**
  28831. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  28832. */
  28833. static readonly MATERIAL_ALPHATEST: number;
  28834. /**
  28835. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28836. */
  28837. static readonly MATERIAL_ALPHABLEND: number;
  28838. /**
  28839. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28840. * They are also discarded below the alpha cutoff threshold to improve performances.
  28841. */
  28842. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  28843. /**
  28844. * The Whiteout method is used to blend normals.
  28845. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28846. */
  28847. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  28848. /**
  28849. * The Reoriented Normal Mapping method is used to blend normals.
  28850. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28851. */
  28852. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  28853. /**
  28854. * Custom callback helping to override the default shader used in the material.
  28855. */
  28856. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  28857. /**
  28858. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  28859. */
  28860. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  28861. /**
  28862. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  28863. * This means that the material can keep using a previous shader while a new one is being compiled.
  28864. * This is mostly used when shader parallel compilation is supported (true by default)
  28865. */
  28866. allowShaderHotSwapping: boolean;
  28867. /**
  28868. * The ID of the material
  28869. */
  28870. id: string;
  28871. /**
  28872. * Gets or sets the unique id of the material
  28873. */
  28874. uniqueId: number;
  28875. /**
  28876. * The name of the material
  28877. */
  28878. name: string;
  28879. /**
  28880. * Gets or sets user defined metadata
  28881. */
  28882. metadata: any;
  28883. /**
  28884. * For internal use only. Please do not use.
  28885. */
  28886. reservedDataStore: any;
  28887. /**
  28888. * Specifies if the ready state should be checked on each call
  28889. */
  28890. checkReadyOnEveryCall: boolean;
  28891. /**
  28892. * Specifies if the ready state should be checked once
  28893. */
  28894. checkReadyOnlyOnce: boolean;
  28895. /**
  28896. * The state of the material
  28897. */
  28898. state: string;
  28899. /**
  28900. * If the material can be rendered to several textures with MRT extension
  28901. */
  28902. get canRenderToMRT(): boolean;
  28903. /**
  28904. * The alpha value of the material
  28905. */
  28906. protected _alpha: number;
  28907. /**
  28908. * List of inspectable custom properties (used by the Inspector)
  28909. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28910. */
  28911. inspectableCustomProperties: IInspectable[];
  28912. /**
  28913. * Sets the alpha value of the material
  28914. */
  28915. set alpha(value: number);
  28916. /**
  28917. * Gets the alpha value of the material
  28918. */
  28919. get alpha(): number;
  28920. /**
  28921. * Specifies if back face culling is enabled
  28922. */
  28923. protected _backFaceCulling: boolean;
  28924. /**
  28925. * Sets the back-face culling state
  28926. */
  28927. set backFaceCulling(value: boolean);
  28928. /**
  28929. * Gets the back-face culling state
  28930. */
  28931. get backFaceCulling(): boolean;
  28932. /**
  28933. * Stores the value for side orientation
  28934. */
  28935. sideOrientation: number;
  28936. /**
  28937. * Callback triggered when the material is compiled
  28938. */
  28939. onCompiled: Nullable<(effect: Effect) => void>;
  28940. /**
  28941. * Callback triggered when an error occurs
  28942. */
  28943. onError: Nullable<(effect: Effect, errors: string) => void>;
  28944. /**
  28945. * Callback triggered to get the render target textures
  28946. */
  28947. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  28948. /**
  28949. * Gets a boolean indicating that current material needs to register RTT
  28950. */
  28951. get hasRenderTargetTextures(): boolean;
  28952. /**
  28953. * Specifies if the material should be serialized
  28954. */
  28955. doNotSerialize: boolean;
  28956. /**
  28957. * @hidden
  28958. */
  28959. _storeEffectOnSubMeshes: boolean;
  28960. /**
  28961. * Stores the animations for the material
  28962. */
  28963. animations: Nullable<Array<Animation>>;
  28964. /**
  28965. * An event triggered when the material is disposed
  28966. */
  28967. onDisposeObservable: Observable<Material>;
  28968. /**
  28969. * An observer which watches for dispose events
  28970. */
  28971. private _onDisposeObserver;
  28972. private _onUnBindObservable;
  28973. /**
  28974. * Called during a dispose event
  28975. */
  28976. set onDispose(callback: () => void);
  28977. private _onBindObservable;
  28978. /**
  28979. * An event triggered when the material is bound
  28980. */
  28981. get onBindObservable(): Observable<AbstractMesh>;
  28982. /**
  28983. * An observer which watches for bind events
  28984. */
  28985. private _onBindObserver;
  28986. /**
  28987. * Called during a bind event
  28988. */
  28989. set onBind(callback: (Mesh: AbstractMesh) => void);
  28990. /**
  28991. * An event triggered when the material is unbound
  28992. */
  28993. get onUnBindObservable(): Observable<Material>;
  28994. protected _onEffectCreatedObservable: Nullable<Observable<{
  28995. effect: Effect;
  28996. subMesh: Nullable<SubMesh>;
  28997. }>>;
  28998. /**
  28999. * An event triggered when the effect is (re)created
  29000. */
  29001. get onEffectCreatedObservable(): Observable<{
  29002. effect: Effect;
  29003. subMesh: Nullable<SubMesh>;
  29004. }>;
  29005. /**
  29006. * Stores the value of the alpha mode
  29007. */
  29008. private _alphaMode;
  29009. /**
  29010. * Sets the value of the alpha mode.
  29011. *
  29012. * | Value | Type | Description |
  29013. * | --- | --- | --- |
  29014. * | 0 | ALPHA_DISABLE | |
  29015. * | 1 | ALPHA_ADD | |
  29016. * | 2 | ALPHA_COMBINE | |
  29017. * | 3 | ALPHA_SUBTRACT | |
  29018. * | 4 | ALPHA_MULTIPLY | |
  29019. * | 5 | ALPHA_MAXIMIZED | |
  29020. * | 6 | ALPHA_ONEONE | |
  29021. * | 7 | ALPHA_PREMULTIPLIED | |
  29022. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29023. * | 9 | ALPHA_INTERPOLATE | |
  29024. * | 10 | ALPHA_SCREENMODE | |
  29025. *
  29026. */
  29027. set alphaMode(value: number);
  29028. /**
  29029. * Gets the value of the alpha mode
  29030. */
  29031. get alphaMode(): number;
  29032. /**
  29033. * Stores the state of the need depth pre-pass value
  29034. */
  29035. private _needDepthPrePass;
  29036. /**
  29037. * Sets the need depth pre-pass value
  29038. */
  29039. set needDepthPrePass(value: boolean);
  29040. /**
  29041. * Gets the depth pre-pass value
  29042. */
  29043. get needDepthPrePass(): boolean;
  29044. /**
  29045. * Specifies if depth writing should be disabled
  29046. */
  29047. disableDepthWrite: boolean;
  29048. /**
  29049. * Specifies if color writing should be disabled
  29050. */
  29051. disableColorWrite: boolean;
  29052. /**
  29053. * Specifies if depth writing should be forced
  29054. */
  29055. forceDepthWrite: boolean;
  29056. /**
  29057. * Specifies the depth function that should be used. 0 means the default engine function
  29058. */
  29059. depthFunction: number;
  29060. /**
  29061. * Specifies if there should be a separate pass for culling
  29062. */
  29063. separateCullingPass: boolean;
  29064. /**
  29065. * Stores the state specifing if fog should be enabled
  29066. */
  29067. private _fogEnabled;
  29068. /**
  29069. * Sets the state for enabling fog
  29070. */
  29071. set fogEnabled(value: boolean);
  29072. /**
  29073. * Gets the value of the fog enabled state
  29074. */
  29075. get fogEnabled(): boolean;
  29076. /**
  29077. * Stores the size of points
  29078. */
  29079. pointSize: number;
  29080. /**
  29081. * Stores the z offset value
  29082. */
  29083. zOffset: number;
  29084. get wireframe(): boolean;
  29085. /**
  29086. * Sets the state of wireframe mode
  29087. */
  29088. set wireframe(value: boolean);
  29089. /**
  29090. * Gets the value specifying if point clouds are enabled
  29091. */
  29092. get pointsCloud(): boolean;
  29093. /**
  29094. * Sets the state of point cloud mode
  29095. */
  29096. set pointsCloud(value: boolean);
  29097. /**
  29098. * Gets the material fill mode
  29099. */
  29100. get fillMode(): number;
  29101. /**
  29102. * Sets the material fill mode
  29103. */
  29104. set fillMode(value: number);
  29105. /**
  29106. * @hidden
  29107. * Stores the effects for the material
  29108. */
  29109. _effect: Nullable<Effect>;
  29110. /**
  29111. * Specifies if uniform buffers should be used
  29112. */
  29113. private _useUBO;
  29114. /**
  29115. * Stores a reference to the scene
  29116. */
  29117. private _scene;
  29118. /**
  29119. * Stores the fill mode state
  29120. */
  29121. private _fillMode;
  29122. /**
  29123. * Specifies if the depth write state should be cached
  29124. */
  29125. private _cachedDepthWriteState;
  29126. /**
  29127. * Specifies if the color write state should be cached
  29128. */
  29129. private _cachedColorWriteState;
  29130. /**
  29131. * Specifies if the depth function state should be cached
  29132. */
  29133. private _cachedDepthFunctionState;
  29134. /**
  29135. * Stores the uniform buffer
  29136. */
  29137. protected _uniformBuffer: UniformBuffer;
  29138. /** @hidden */
  29139. _indexInSceneMaterialArray: number;
  29140. /** @hidden */
  29141. meshMap: Nullable<{
  29142. [id: string]: AbstractMesh | undefined;
  29143. }>;
  29144. /**
  29145. * Creates a material instance
  29146. * @param name defines the name of the material
  29147. * @param scene defines the scene to reference
  29148. * @param doNotAdd specifies if the material should be added to the scene
  29149. */
  29150. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29151. /**
  29152. * Returns a string representation of the current material
  29153. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29154. * @returns a string with material information
  29155. */
  29156. toString(fullDetails?: boolean): string;
  29157. /**
  29158. * Gets the class name of the material
  29159. * @returns a string with the class name of the material
  29160. */
  29161. getClassName(): string;
  29162. /**
  29163. * Specifies if updates for the material been locked
  29164. */
  29165. get isFrozen(): boolean;
  29166. /**
  29167. * Locks updates for the material
  29168. */
  29169. freeze(): void;
  29170. /**
  29171. * Unlocks updates for the material
  29172. */
  29173. unfreeze(): void;
  29174. /**
  29175. * Specifies if the material is ready to be used
  29176. * @param mesh defines the mesh to check
  29177. * @param useInstances specifies if instances should be used
  29178. * @returns a boolean indicating if the material is ready to be used
  29179. */
  29180. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29181. /**
  29182. * Specifies that the submesh is ready to be used
  29183. * @param mesh defines the mesh to check
  29184. * @param subMesh defines which submesh to check
  29185. * @param useInstances specifies that instances should be used
  29186. * @returns a boolean indicating that the submesh is ready or not
  29187. */
  29188. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29189. /**
  29190. * Returns the material effect
  29191. * @returns the effect associated with the material
  29192. */
  29193. getEffect(): Nullable<Effect>;
  29194. /**
  29195. * Returns the current scene
  29196. * @returns a Scene
  29197. */
  29198. getScene(): Scene;
  29199. /**
  29200. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29201. */
  29202. protected _forceAlphaTest: boolean;
  29203. /**
  29204. * The transparency mode of the material.
  29205. */
  29206. protected _transparencyMode: Nullable<number>;
  29207. /**
  29208. * Gets the current transparency mode.
  29209. */
  29210. get transparencyMode(): Nullable<number>;
  29211. /**
  29212. * Sets the transparency mode of the material.
  29213. *
  29214. * | Value | Type | Description |
  29215. * | ----- | ----------------------------------- | ----------- |
  29216. * | 0 | OPAQUE | |
  29217. * | 1 | ALPHATEST | |
  29218. * | 2 | ALPHABLEND | |
  29219. * | 3 | ALPHATESTANDBLEND | |
  29220. *
  29221. */
  29222. set transparencyMode(value: Nullable<number>);
  29223. /**
  29224. * Returns true if alpha blending should be disabled.
  29225. */
  29226. protected get _disableAlphaBlending(): boolean;
  29227. /**
  29228. * Specifies whether or not this material should be rendered in alpha blend mode.
  29229. * @returns a boolean specifying if alpha blending is needed
  29230. */
  29231. needAlphaBlending(): boolean;
  29232. /**
  29233. * Specifies if the mesh will require alpha blending
  29234. * @param mesh defines the mesh to check
  29235. * @returns a boolean specifying if alpha blending is needed for the mesh
  29236. */
  29237. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29238. /**
  29239. * Specifies whether or not this material should be rendered in alpha test mode.
  29240. * @returns a boolean specifying if an alpha test is needed.
  29241. */
  29242. needAlphaTesting(): boolean;
  29243. /**
  29244. * Specifies if material alpha testing should be turned on for the mesh
  29245. * @param mesh defines the mesh to check
  29246. */
  29247. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29248. /**
  29249. * Gets the texture used for the alpha test
  29250. * @returns the texture to use for alpha testing
  29251. */
  29252. getAlphaTestTexture(): Nullable<BaseTexture>;
  29253. /**
  29254. * Marks the material to indicate that it needs to be re-calculated
  29255. */
  29256. markDirty(): void;
  29257. /** @hidden */
  29258. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29259. /**
  29260. * Binds the material to the mesh
  29261. * @param world defines the world transformation matrix
  29262. * @param mesh defines the mesh to bind the material to
  29263. */
  29264. bind(world: Matrix, mesh?: Mesh): void;
  29265. /**
  29266. * Binds the submesh to the material
  29267. * @param world defines the world transformation matrix
  29268. * @param mesh defines the mesh containing the submesh
  29269. * @param subMesh defines the submesh to bind the material to
  29270. */
  29271. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29272. /**
  29273. * Binds the world matrix to the material
  29274. * @param world defines the world transformation matrix
  29275. */
  29276. bindOnlyWorldMatrix(world: Matrix): void;
  29277. /**
  29278. * Binds the scene's uniform buffer to the effect.
  29279. * @param effect defines the effect to bind to the scene uniform buffer
  29280. * @param sceneUbo defines the uniform buffer storing scene data
  29281. */
  29282. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29283. /**
  29284. * Binds the view matrix to the effect
  29285. * @param effect defines the effect to bind the view matrix to
  29286. */
  29287. bindView(effect: Effect): void;
  29288. /**
  29289. * Binds the view projection matrix to the effect
  29290. * @param effect defines the effect to bind the view projection matrix to
  29291. */
  29292. bindViewProjection(effect: Effect): void;
  29293. /**
  29294. * Processes to execute after binding the material to a mesh
  29295. * @param mesh defines the rendered mesh
  29296. */
  29297. protected _afterBind(mesh?: Mesh): void;
  29298. /**
  29299. * Unbinds the material from the mesh
  29300. */
  29301. unbind(): void;
  29302. /**
  29303. * Gets the active textures from the material
  29304. * @returns an array of textures
  29305. */
  29306. getActiveTextures(): BaseTexture[];
  29307. /**
  29308. * Specifies if the material uses a texture
  29309. * @param texture defines the texture to check against the material
  29310. * @returns a boolean specifying if the material uses the texture
  29311. */
  29312. hasTexture(texture: BaseTexture): boolean;
  29313. /**
  29314. * Makes a duplicate of the material, and gives it a new name
  29315. * @param name defines the new name for the duplicated material
  29316. * @returns the cloned material
  29317. */
  29318. clone(name: string): Nullable<Material>;
  29319. /**
  29320. * Gets the meshes bound to the material
  29321. * @returns an array of meshes bound to the material
  29322. */
  29323. getBindedMeshes(): AbstractMesh[];
  29324. /**
  29325. * Force shader compilation
  29326. * @param mesh defines the mesh associated with this material
  29327. * @param onCompiled defines a function to execute once the material is compiled
  29328. * @param options defines the options to configure the compilation
  29329. * @param onError defines a function to execute if the material fails compiling
  29330. */
  29331. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29332. /**
  29333. * Force shader compilation
  29334. * @param mesh defines the mesh that will use this material
  29335. * @param options defines additional options for compiling the shaders
  29336. * @returns a promise that resolves when the compilation completes
  29337. */
  29338. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29339. private static readonly _AllDirtyCallBack;
  29340. private static readonly _ImageProcessingDirtyCallBack;
  29341. private static readonly _TextureDirtyCallBack;
  29342. private static readonly _FresnelDirtyCallBack;
  29343. private static readonly _MiscDirtyCallBack;
  29344. private static readonly _PrePassDirtyCallBack;
  29345. private static readonly _LightsDirtyCallBack;
  29346. private static readonly _AttributeDirtyCallBack;
  29347. private static _FresnelAndMiscDirtyCallBack;
  29348. private static _TextureAndMiscDirtyCallBack;
  29349. private static readonly _DirtyCallbackArray;
  29350. private static readonly _RunDirtyCallBacks;
  29351. /**
  29352. * Marks a define in the material to indicate that it needs to be re-computed
  29353. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29354. */
  29355. markAsDirty(flag: number): void;
  29356. /**
  29357. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29358. * @param func defines a function which checks material defines against the submeshes
  29359. */
  29360. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29361. /**
  29362. * Indicates that the scene should check if the rendering now needs a prepass
  29363. */
  29364. protected _markScenePrePassDirty(): void;
  29365. /**
  29366. * Indicates that we need to re-calculated for all submeshes
  29367. */
  29368. protected _markAllSubMeshesAsAllDirty(): void;
  29369. /**
  29370. * Indicates that image processing needs to be re-calculated for all submeshes
  29371. */
  29372. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29373. /**
  29374. * Indicates that textures need to be re-calculated for all submeshes
  29375. */
  29376. protected _markAllSubMeshesAsTexturesDirty(): void;
  29377. /**
  29378. * Indicates that fresnel needs to be re-calculated for all submeshes
  29379. */
  29380. protected _markAllSubMeshesAsFresnelDirty(): void;
  29381. /**
  29382. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29383. */
  29384. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29385. /**
  29386. * Indicates that lights need to be re-calculated for all submeshes
  29387. */
  29388. protected _markAllSubMeshesAsLightsDirty(): void;
  29389. /**
  29390. * Indicates that attributes need to be re-calculated for all submeshes
  29391. */
  29392. protected _markAllSubMeshesAsAttributesDirty(): void;
  29393. /**
  29394. * Indicates that misc needs to be re-calculated for all submeshes
  29395. */
  29396. protected _markAllSubMeshesAsMiscDirty(): void;
  29397. /**
  29398. * Indicates that prepass needs to be re-calculated for all submeshes
  29399. */
  29400. protected _markAllSubMeshesAsPrePassDirty(): void;
  29401. /**
  29402. * Indicates that textures and misc need to be re-calculated for all submeshes
  29403. */
  29404. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29405. /**
  29406. * Sets the required values to the prepass renderer.
  29407. * @param prePassRenderer defines the prepass renderer to setup.
  29408. * @returns true if the pre pass is needed.
  29409. */
  29410. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29411. /**
  29412. * Disposes the material
  29413. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29414. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29415. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29416. */
  29417. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29418. /** @hidden */
  29419. private releaseVertexArrayObject;
  29420. /**
  29421. * Serializes this material
  29422. * @returns the serialized material object
  29423. */
  29424. serialize(): any;
  29425. /**
  29426. * Creates a material from parsed material data
  29427. * @param parsedMaterial defines parsed material data
  29428. * @param scene defines the hosting scene
  29429. * @param rootUrl defines the root URL to use to load textures
  29430. * @returns a new material
  29431. */
  29432. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29433. }
  29434. }
  29435. declare module BABYLON {
  29436. /**
  29437. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29438. * separate meshes. This can be use to improve performances.
  29439. * @see https://doc.babylonjs.com/how_to/multi_materials
  29440. */
  29441. export class MultiMaterial extends Material {
  29442. private _subMaterials;
  29443. /**
  29444. * Gets or Sets the list of Materials used within the multi material.
  29445. * They need to be ordered according to the submeshes order in the associated mesh
  29446. */
  29447. get subMaterials(): Nullable<Material>[];
  29448. set subMaterials(value: Nullable<Material>[]);
  29449. /**
  29450. * Function used to align with Node.getChildren()
  29451. * @returns the list of Materials used within the multi material
  29452. */
  29453. getChildren(): Nullable<Material>[];
  29454. /**
  29455. * Instantiates a new Multi Material
  29456. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29457. * separate meshes. This can be use to improve performances.
  29458. * @see https://doc.babylonjs.com/how_to/multi_materials
  29459. * @param name Define the name in the scene
  29460. * @param scene Define the scene the material belongs to
  29461. */
  29462. constructor(name: string, scene: Scene);
  29463. private _hookArray;
  29464. /**
  29465. * Get one of the submaterial by its index in the submaterials array
  29466. * @param index The index to look the sub material at
  29467. * @returns The Material if the index has been defined
  29468. */
  29469. getSubMaterial(index: number): Nullable<Material>;
  29470. /**
  29471. * Get the list of active textures for the whole sub materials list.
  29472. * @returns All the textures that will be used during the rendering
  29473. */
  29474. getActiveTextures(): BaseTexture[];
  29475. /**
  29476. * Gets the current class name of the material e.g. "MultiMaterial"
  29477. * Mainly use in serialization.
  29478. * @returns the class name
  29479. */
  29480. getClassName(): string;
  29481. /**
  29482. * Checks if the material is ready to render the requested sub mesh
  29483. * @param mesh Define the mesh the submesh belongs to
  29484. * @param subMesh Define the sub mesh to look readyness for
  29485. * @param useInstances Define whether or not the material is used with instances
  29486. * @returns true if ready, otherwise false
  29487. */
  29488. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29489. /**
  29490. * Clones the current material and its related sub materials
  29491. * @param name Define the name of the newly cloned material
  29492. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29493. * @returns the cloned material
  29494. */
  29495. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29496. /**
  29497. * Serializes the materials into a JSON representation.
  29498. * @returns the JSON representation
  29499. */
  29500. serialize(): any;
  29501. /**
  29502. * Dispose the material and release its associated resources
  29503. * @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)
  29504. * @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)
  29505. * @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)
  29506. */
  29507. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29508. /**
  29509. * Creates a MultiMaterial from parsed MultiMaterial data.
  29510. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29511. * @param scene defines the hosting scene
  29512. * @returns a new MultiMaterial
  29513. */
  29514. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29515. }
  29516. }
  29517. declare module BABYLON {
  29518. /**
  29519. * Defines a subdivision inside a mesh
  29520. */
  29521. export class SubMesh implements ICullable {
  29522. /** the material index to use */
  29523. materialIndex: number;
  29524. /** vertex index start */
  29525. verticesStart: number;
  29526. /** vertices count */
  29527. verticesCount: number;
  29528. /** index start */
  29529. indexStart: number;
  29530. /** indices count */
  29531. indexCount: number;
  29532. /** @hidden */
  29533. _materialDefines: Nullable<MaterialDefines>;
  29534. /** @hidden */
  29535. _materialEffect: Nullable<Effect>;
  29536. /** @hidden */
  29537. _effectOverride: Nullable<Effect>;
  29538. /**
  29539. * Gets material defines used by the effect associated to the sub mesh
  29540. */
  29541. get materialDefines(): Nullable<MaterialDefines>;
  29542. /**
  29543. * Sets material defines used by the effect associated to the sub mesh
  29544. */
  29545. set materialDefines(defines: Nullable<MaterialDefines>);
  29546. /**
  29547. * Gets associated effect
  29548. */
  29549. get effect(): Nullable<Effect>;
  29550. /**
  29551. * Sets associated effect (effect used to render this submesh)
  29552. * @param effect defines the effect to associate with
  29553. * @param defines defines the set of defines used to compile this effect
  29554. */
  29555. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29556. /** @hidden */
  29557. _linesIndexCount: number;
  29558. private _mesh;
  29559. private _renderingMesh;
  29560. private _boundingInfo;
  29561. private _linesIndexBuffer;
  29562. /** @hidden */
  29563. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29564. /** @hidden */
  29565. _trianglePlanes: Plane[];
  29566. /** @hidden */
  29567. _lastColliderTransformMatrix: Nullable<Matrix>;
  29568. /** @hidden */
  29569. _renderId: number;
  29570. /** @hidden */
  29571. _alphaIndex: number;
  29572. /** @hidden */
  29573. _distanceToCamera: number;
  29574. /** @hidden */
  29575. _id: number;
  29576. private _currentMaterial;
  29577. /**
  29578. * Add a new submesh to a mesh
  29579. * @param materialIndex defines the material index to use
  29580. * @param verticesStart defines vertex index start
  29581. * @param verticesCount defines vertices count
  29582. * @param indexStart defines index start
  29583. * @param indexCount defines indices count
  29584. * @param mesh defines the parent mesh
  29585. * @param renderingMesh defines an optional rendering mesh
  29586. * @param createBoundingBox defines if bounding box should be created for this submesh
  29587. * @returns the new submesh
  29588. */
  29589. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29590. /**
  29591. * Creates a new submesh
  29592. * @param materialIndex defines the material index to use
  29593. * @param verticesStart defines vertex index start
  29594. * @param verticesCount defines vertices count
  29595. * @param indexStart defines index start
  29596. * @param indexCount defines indices count
  29597. * @param mesh defines the parent mesh
  29598. * @param renderingMesh defines an optional rendering mesh
  29599. * @param createBoundingBox defines if bounding box should be created for this submesh
  29600. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29601. */
  29602. constructor(
  29603. /** the material index to use */
  29604. materialIndex: number,
  29605. /** vertex index start */
  29606. verticesStart: number,
  29607. /** vertices count */
  29608. verticesCount: number,
  29609. /** index start */
  29610. indexStart: number,
  29611. /** indices count */
  29612. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29613. /**
  29614. * Returns true if this submesh covers the entire parent mesh
  29615. * @ignorenaming
  29616. */
  29617. get IsGlobal(): boolean;
  29618. /**
  29619. * Returns the submesh BoudingInfo object
  29620. * @returns current bounding info (or mesh's one if the submesh is global)
  29621. */
  29622. getBoundingInfo(): BoundingInfo;
  29623. /**
  29624. * Sets the submesh BoundingInfo
  29625. * @param boundingInfo defines the new bounding info to use
  29626. * @returns the SubMesh
  29627. */
  29628. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29629. /**
  29630. * Returns the mesh of the current submesh
  29631. * @return the parent mesh
  29632. */
  29633. getMesh(): AbstractMesh;
  29634. /**
  29635. * Returns the rendering mesh of the submesh
  29636. * @returns the rendering mesh (could be different from parent mesh)
  29637. */
  29638. getRenderingMesh(): Mesh;
  29639. /**
  29640. * Returns the replacement mesh of the submesh
  29641. * @returns the replacement mesh (could be different from parent mesh)
  29642. */
  29643. getReplacementMesh(): Nullable<AbstractMesh>;
  29644. /**
  29645. * Returns the effective mesh of the submesh
  29646. * @returns the effective mesh (could be different from parent mesh)
  29647. */
  29648. getEffectiveMesh(): AbstractMesh;
  29649. /**
  29650. * Returns the submesh material
  29651. * @returns null or the current material
  29652. */
  29653. getMaterial(): Nullable<Material>;
  29654. private _IsMultiMaterial;
  29655. /**
  29656. * Sets a new updated BoundingInfo object to the submesh
  29657. * @param data defines an optional position array to use to determine the bounding info
  29658. * @returns the SubMesh
  29659. */
  29660. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  29661. /** @hidden */
  29662. _checkCollision(collider: Collider): boolean;
  29663. /**
  29664. * Updates the submesh BoundingInfo
  29665. * @param world defines the world matrix to use to update the bounding info
  29666. * @returns the submesh
  29667. */
  29668. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29669. /**
  29670. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29671. * @param frustumPlanes defines the frustum planes
  29672. * @returns true if the submesh is intersecting with the frustum
  29673. */
  29674. isInFrustum(frustumPlanes: Plane[]): boolean;
  29675. /**
  29676. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29677. * @param frustumPlanes defines the frustum planes
  29678. * @returns true if the submesh is inside the frustum
  29679. */
  29680. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29681. /**
  29682. * Renders the submesh
  29683. * @param enableAlphaMode defines if alpha needs to be used
  29684. * @returns the submesh
  29685. */
  29686. render(enableAlphaMode: boolean): SubMesh;
  29687. /**
  29688. * @hidden
  29689. */
  29690. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  29691. /**
  29692. * Checks if the submesh intersects with a ray
  29693. * @param ray defines the ray to test
  29694. * @returns true is the passed ray intersects the submesh bounding box
  29695. */
  29696. canIntersects(ray: Ray): boolean;
  29697. /**
  29698. * Intersects current submesh with a ray
  29699. * @param ray defines the ray to test
  29700. * @param positions defines mesh's positions array
  29701. * @param indices defines mesh's indices array
  29702. * @param fastCheck defines if the first intersection will be used (and not the closest)
  29703. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29704. * @returns intersection info or null if no intersection
  29705. */
  29706. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  29707. /** @hidden */
  29708. private _intersectLines;
  29709. /** @hidden */
  29710. private _intersectUnIndexedLines;
  29711. /** @hidden */
  29712. private _intersectTriangles;
  29713. /** @hidden */
  29714. private _intersectUnIndexedTriangles;
  29715. /** @hidden */
  29716. _rebuild(): void;
  29717. /**
  29718. * Creates a new submesh from the passed mesh
  29719. * @param newMesh defines the new hosting mesh
  29720. * @param newRenderingMesh defines an optional rendering mesh
  29721. * @returns the new submesh
  29722. */
  29723. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29724. /**
  29725. * Release associated resources
  29726. */
  29727. dispose(): void;
  29728. /**
  29729. * Gets the class name
  29730. * @returns the string "SubMesh".
  29731. */
  29732. getClassName(): string;
  29733. /**
  29734. * Creates a new submesh from indices data
  29735. * @param materialIndex the index of the main mesh material
  29736. * @param startIndex the index where to start the copy in the mesh indices array
  29737. * @param indexCount the number of indices to copy then from the startIndex
  29738. * @param mesh the main mesh to create the submesh from
  29739. * @param renderingMesh the optional rendering mesh
  29740. * @returns a new submesh
  29741. */
  29742. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29743. }
  29744. }
  29745. declare module BABYLON {
  29746. /**
  29747. * Class used to represent data loading progression
  29748. */
  29749. export class SceneLoaderFlags {
  29750. private static _ForceFullSceneLoadingForIncremental;
  29751. private static _ShowLoadingScreen;
  29752. private static _CleanBoneMatrixWeights;
  29753. private static _loggingLevel;
  29754. /**
  29755. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  29756. */
  29757. static get ForceFullSceneLoadingForIncremental(): boolean;
  29758. static set ForceFullSceneLoadingForIncremental(value: boolean);
  29759. /**
  29760. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  29761. */
  29762. static get ShowLoadingScreen(): boolean;
  29763. static set ShowLoadingScreen(value: boolean);
  29764. /**
  29765. * Defines the current logging level (while loading the scene)
  29766. * @ignorenaming
  29767. */
  29768. static get loggingLevel(): number;
  29769. static set loggingLevel(value: number);
  29770. /**
  29771. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  29772. */
  29773. static get CleanBoneMatrixWeights(): boolean;
  29774. static set CleanBoneMatrixWeights(value: boolean);
  29775. }
  29776. }
  29777. declare module BABYLON {
  29778. /**
  29779. * Class used to store geometry data (vertex buffers + index buffer)
  29780. */
  29781. export class Geometry implements IGetSetVerticesData {
  29782. /**
  29783. * Gets or sets the ID of the geometry
  29784. */
  29785. id: string;
  29786. /**
  29787. * Gets or sets the unique ID of the geometry
  29788. */
  29789. uniqueId: number;
  29790. /**
  29791. * Gets the delay loading state of the geometry (none by default which means not delayed)
  29792. */
  29793. delayLoadState: number;
  29794. /**
  29795. * Gets the file containing the data to load when running in delay load state
  29796. */
  29797. delayLoadingFile: Nullable<string>;
  29798. /**
  29799. * Callback called when the geometry is updated
  29800. */
  29801. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  29802. private _scene;
  29803. private _engine;
  29804. private _meshes;
  29805. private _totalVertices;
  29806. /** @hidden */
  29807. _indices: IndicesArray;
  29808. /** @hidden */
  29809. _vertexBuffers: {
  29810. [key: string]: VertexBuffer;
  29811. };
  29812. private _isDisposed;
  29813. private _extend;
  29814. private _boundingBias;
  29815. /** @hidden */
  29816. _delayInfo: Array<string>;
  29817. private _indexBuffer;
  29818. private _indexBufferIsUpdatable;
  29819. /** @hidden */
  29820. _boundingInfo: Nullable<BoundingInfo>;
  29821. /** @hidden */
  29822. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  29823. /** @hidden */
  29824. _softwareSkinningFrameId: number;
  29825. private _vertexArrayObjects;
  29826. private _updatable;
  29827. /** @hidden */
  29828. _positions: Nullable<Vector3[]>;
  29829. /**
  29830. * 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
  29831. */
  29832. get boundingBias(): Vector2;
  29833. /**
  29834. * 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
  29835. */
  29836. set boundingBias(value: Vector2);
  29837. /**
  29838. * Static function used to attach a new empty geometry to a mesh
  29839. * @param mesh defines the mesh to attach the geometry to
  29840. * @returns the new Geometry
  29841. */
  29842. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  29843. /** Get the list of meshes using this geometry */
  29844. get meshes(): Mesh[];
  29845. /**
  29846. * 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
  29847. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  29848. */
  29849. useBoundingInfoFromGeometry: boolean;
  29850. /**
  29851. * Creates a new geometry
  29852. * @param id defines the unique ID
  29853. * @param scene defines the hosting scene
  29854. * @param vertexData defines the VertexData used to get geometry data
  29855. * @param updatable defines if geometry must be updatable (false by default)
  29856. * @param mesh defines the mesh that will be associated with the geometry
  29857. */
  29858. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  29859. /**
  29860. * Gets the current extend of the geometry
  29861. */
  29862. get extend(): {
  29863. minimum: Vector3;
  29864. maximum: Vector3;
  29865. };
  29866. /**
  29867. * Gets the hosting scene
  29868. * @returns the hosting Scene
  29869. */
  29870. getScene(): Scene;
  29871. /**
  29872. * Gets the hosting engine
  29873. * @returns the hosting Engine
  29874. */
  29875. getEngine(): Engine;
  29876. /**
  29877. * Defines if the geometry is ready to use
  29878. * @returns true if the geometry is ready to be used
  29879. */
  29880. isReady(): boolean;
  29881. /**
  29882. * Gets a value indicating that the geometry should not be serialized
  29883. */
  29884. get doNotSerialize(): boolean;
  29885. /** @hidden */
  29886. _rebuild(): void;
  29887. /**
  29888. * Affects all geometry data in one call
  29889. * @param vertexData defines the geometry data
  29890. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  29891. */
  29892. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  29893. /**
  29894. * Set specific vertex data
  29895. * @param kind defines the data kind (Position, normal, etc...)
  29896. * @param data defines the vertex data to use
  29897. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  29898. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  29899. */
  29900. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  29901. /**
  29902. * Removes a specific vertex data
  29903. * @param kind defines the data kind (Position, normal, etc...)
  29904. */
  29905. removeVerticesData(kind: string): void;
  29906. /**
  29907. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  29908. * @param buffer defines the vertex buffer to use
  29909. * @param totalVertices defines the total number of vertices for position kind (could be null)
  29910. */
  29911. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  29912. /**
  29913. * Update a specific vertex buffer
  29914. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  29915. * It will do nothing if the buffer is not updatable
  29916. * @param kind defines the data kind (Position, normal, etc...)
  29917. * @param data defines the data to use
  29918. * @param offset defines the offset in the target buffer where to store the data
  29919. * @param useBytes set to true if the offset is in bytes
  29920. */
  29921. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  29922. /**
  29923. * Update a specific vertex buffer
  29924. * This function will create a new buffer if the current one is not updatable
  29925. * @param kind defines the data kind (Position, normal, etc...)
  29926. * @param data defines the data to use
  29927. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  29928. */
  29929. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  29930. private _updateBoundingInfo;
  29931. /** @hidden */
  29932. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  29933. /**
  29934. * Gets total number of vertices
  29935. * @returns the total number of vertices
  29936. */
  29937. getTotalVertices(): number;
  29938. /**
  29939. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  29940. * @param kind defines the data kind (Position, normal, etc...)
  29941. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  29942. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29943. * @returns a float array containing vertex data
  29944. */
  29945. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29946. /**
  29947. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  29948. * @param kind defines the data kind (Position, normal, etc...)
  29949. * @returns true if the vertex buffer with the specified kind is updatable
  29950. */
  29951. isVertexBufferUpdatable(kind: string): boolean;
  29952. /**
  29953. * Gets a specific vertex buffer
  29954. * @param kind defines the data kind (Position, normal, etc...)
  29955. * @returns a VertexBuffer
  29956. */
  29957. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29958. /**
  29959. * Returns all vertex buffers
  29960. * @return an object holding all vertex buffers indexed by kind
  29961. */
  29962. getVertexBuffers(): Nullable<{
  29963. [key: string]: VertexBuffer;
  29964. }>;
  29965. /**
  29966. * Gets a boolean indicating if specific vertex buffer is present
  29967. * @param kind defines the data kind (Position, normal, etc...)
  29968. * @returns true if data is present
  29969. */
  29970. isVerticesDataPresent(kind: string): boolean;
  29971. /**
  29972. * Gets a list of all attached data kinds (Position, normal, etc...)
  29973. * @returns a list of string containing all kinds
  29974. */
  29975. getVerticesDataKinds(): string[];
  29976. /**
  29977. * Update index buffer
  29978. * @param indices defines the indices to store in the index buffer
  29979. * @param offset defines the offset in the target buffer where to store the data
  29980. * @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)
  29981. */
  29982. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  29983. /**
  29984. * Creates a new index buffer
  29985. * @param indices defines the indices to store in the index buffer
  29986. * @param totalVertices defines the total number of vertices (could be null)
  29987. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  29988. */
  29989. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  29990. /**
  29991. * Return the total number of indices
  29992. * @returns the total number of indices
  29993. */
  29994. getTotalIndices(): number;
  29995. /**
  29996. * Gets the index buffer array
  29997. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  29998. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29999. * @returns the index buffer array
  30000. */
  30001. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30002. /**
  30003. * Gets the index buffer
  30004. * @return the index buffer
  30005. */
  30006. getIndexBuffer(): Nullable<DataBuffer>;
  30007. /** @hidden */
  30008. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30009. /**
  30010. * Release the associated resources for a specific mesh
  30011. * @param mesh defines the source mesh
  30012. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30013. */
  30014. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30015. /**
  30016. * Apply current geometry to a given mesh
  30017. * @param mesh defines the mesh to apply geometry to
  30018. */
  30019. applyToMesh(mesh: Mesh): void;
  30020. private _updateExtend;
  30021. private _applyToMesh;
  30022. private notifyUpdate;
  30023. /**
  30024. * Load the geometry if it was flagged as delay loaded
  30025. * @param scene defines the hosting scene
  30026. * @param onLoaded defines a callback called when the geometry is loaded
  30027. */
  30028. load(scene: Scene, onLoaded?: () => void): void;
  30029. private _queueLoad;
  30030. /**
  30031. * Invert the geometry to move from a right handed system to a left handed one.
  30032. */
  30033. toLeftHanded(): void;
  30034. /** @hidden */
  30035. _resetPointsArrayCache(): void;
  30036. /** @hidden */
  30037. _generatePointsArray(): boolean;
  30038. /**
  30039. * Gets a value indicating if the geometry is disposed
  30040. * @returns true if the geometry was disposed
  30041. */
  30042. isDisposed(): boolean;
  30043. private _disposeVertexArrayObjects;
  30044. /**
  30045. * Free all associated resources
  30046. */
  30047. dispose(): void;
  30048. /**
  30049. * Clone the current geometry into a new geometry
  30050. * @param id defines the unique ID of the new geometry
  30051. * @returns a new geometry object
  30052. */
  30053. copy(id: string): Geometry;
  30054. /**
  30055. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30056. * @return a JSON representation of the current geometry data (without the vertices data)
  30057. */
  30058. serialize(): any;
  30059. private toNumberArray;
  30060. /**
  30061. * Serialize all vertices data into a JSON oject
  30062. * @returns a JSON representation of the current geometry data
  30063. */
  30064. serializeVerticeData(): any;
  30065. /**
  30066. * Extracts a clone of a mesh geometry
  30067. * @param mesh defines the source mesh
  30068. * @param id defines the unique ID of the new geometry object
  30069. * @returns the new geometry object
  30070. */
  30071. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30072. /**
  30073. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30074. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30075. * Be aware Math.random() could cause collisions, but:
  30076. * "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"
  30077. * @returns a string containing a new GUID
  30078. */
  30079. static RandomId(): string;
  30080. /** @hidden */
  30081. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30082. private static _CleanMatricesWeights;
  30083. /**
  30084. * Create a new geometry from persisted data (Using .babylon file format)
  30085. * @param parsedVertexData defines the persisted data
  30086. * @param scene defines the hosting scene
  30087. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30088. * @returns the new geometry object
  30089. */
  30090. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30091. }
  30092. }
  30093. declare module BABYLON {
  30094. /**
  30095. * Define an interface for all classes that will get and set the data on vertices
  30096. */
  30097. export interface IGetSetVerticesData {
  30098. /**
  30099. * Gets a boolean indicating if specific vertex data is present
  30100. * @param kind defines the vertex data kind to use
  30101. * @returns true is data kind is present
  30102. */
  30103. isVerticesDataPresent(kind: string): boolean;
  30104. /**
  30105. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30106. * @param kind defines the data kind (Position, normal, etc...)
  30107. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30108. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30109. * @returns a float array containing vertex data
  30110. */
  30111. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30112. /**
  30113. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30114. * @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.
  30115. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30116. * @returns the indices array or an empty array if the mesh has no geometry
  30117. */
  30118. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30119. /**
  30120. * Set specific vertex data
  30121. * @param kind defines the data kind (Position, normal, etc...)
  30122. * @param data defines the vertex data to use
  30123. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30124. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30125. */
  30126. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30127. /**
  30128. * Update a specific associated vertex buffer
  30129. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30130. * - VertexBuffer.PositionKind
  30131. * - VertexBuffer.UVKind
  30132. * - VertexBuffer.UV2Kind
  30133. * - VertexBuffer.UV3Kind
  30134. * - VertexBuffer.UV4Kind
  30135. * - VertexBuffer.UV5Kind
  30136. * - VertexBuffer.UV6Kind
  30137. * - VertexBuffer.ColorKind
  30138. * - VertexBuffer.MatricesIndicesKind
  30139. * - VertexBuffer.MatricesIndicesExtraKind
  30140. * - VertexBuffer.MatricesWeightsKind
  30141. * - VertexBuffer.MatricesWeightsExtraKind
  30142. * @param data defines the data source
  30143. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30144. * @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)
  30145. */
  30146. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30147. /**
  30148. * Creates a new index buffer
  30149. * @param indices defines the indices to store in the index buffer
  30150. * @param totalVertices defines the total number of vertices (could be null)
  30151. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30152. */
  30153. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30154. }
  30155. /**
  30156. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30157. */
  30158. export class VertexData {
  30159. /**
  30160. * Mesh side orientation : usually the external or front surface
  30161. */
  30162. static readonly FRONTSIDE: number;
  30163. /**
  30164. * Mesh side orientation : usually the internal or back surface
  30165. */
  30166. static readonly BACKSIDE: number;
  30167. /**
  30168. * Mesh side orientation : both internal and external or front and back surfaces
  30169. */
  30170. static readonly DOUBLESIDE: number;
  30171. /**
  30172. * Mesh side orientation : by default, `FRONTSIDE`
  30173. */
  30174. static readonly DEFAULTSIDE: number;
  30175. /**
  30176. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30177. */
  30178. positions: Nullable<FloatArray>;
  30179. /**
  30180. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30181. */
  30182. normals: Nullable<FloatArray>;
  30183. /**
  30184. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30185. */
  30186. tangents: Nullable<FloatArray>;
  30187. /**
  30188. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30189. */
  30190. uvs: Nullable<FloatArray>;
  30191. /**
  30192. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30193. */
  30194. uvs2: Nullable<FloatArray>;
  30195. /**
  30196. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30197. */
  30198. uvs3: Nullable<FloatArray>;
  30199. /**
  30200. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30201. */
  30202. uvs4: Nullable<FloatArray>;
  30203. /**
  30204. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30205. */
  30206. uvs5: Nullable<FloatArray>;
  30207. /**
  30208. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30209. */
  30210. uvs6: Nullable<FloatArray>;
  30211. /**
  30212. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30213. */
  30214. colors: Nullable<FloatArray>;
  30215. /**
  30216. * 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).
  30217. */
  30218. matricesIndices: Nullable<FloatArray>;
  30219. /**
  30220. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30221. */
  30222. matricesWeights: Nullable<FloatArray>;
  30223. /**
  30224. * An array extending the number of possible indices
  30225. */
  30226. matricesIndicesExtra: Nullable<FloatArray>;
  30227. /**
  30228. * An array extending the number of possible weights when the number of indices is extended
  30229. */
  30230. matricesWeightsExtra: Nullable<FloatArray>;
  30231. /**
  30232. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30233. */
  30234. indices: Nullable<IndicesArray>;
  30235. /**
  30236. * Uses the passed data array to set the set the values for the specified kind of data
  30237. * @param data a linear array of floating numbers
  30238. * @param kind the type of data that is being set, eg positions, colors etc
  30239. */
  30240. set(data: FloatArray, kind: string): void;
  30241. /**
  30242. * Associates the vertexData to the passed Mesh.
  30243. * Sets it as updatable or not (default `false`)
  30244. * @param mesh the mesh the vertexData is applied to
  30245. * @param updatable when used and having the value true allows new data to update the vertexData
  30246. * @returns the VertexData
  30247. */
  30248. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30249. /**
  30250. * Associates the vertexData to the passed Geometry.
  30251. * Sets it as updatable or not (default `false`)
  30252. * @param geometry the geometry the vertexData is applied to
  30253. * @param updatable when used and having the value true allows new data to update the vertexData
  30254. * @returns VertexData
  30255. */
  30256. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30257. /**
  30258. * Updates the associated mesh
  30259. * @param mesh the mesh to be updated
  30260. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30261. * @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
  30262. * @returns VertexData
  30263. */
  30264. updateMesh(mesh: Mesh): VertexData;
  30265. /**
  30266. * Updates the associated geometry
  30267. * @param geometry the geometry to be updated
  30268. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30269. * @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
  30270. * @returns VertexData.
  30271. */
  30272. updateGeometry(geometry: Geometry): VertexData;
  30273. private _applyTo;
  30274. private _update;
  30275. /**
  30276. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30277. * @param matrix the transforming matrix
  30278. * @returns the VertexData
  30279. */
  30280. transform(matrix: Matrix): VertexData;
  30281. /**
  30282. * Merges the passed VertexData into the current one
  30283. * @param other the VertexData to be merged into the current one
  30284. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30285. * @returns the modified VertexData
  30286. */
  30287. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30288. private _mergeElement;
  30289. private _validate;
  30290. /**
  30291. * Serializes the VertexData
  30292. * @returns a serialized object
  30293. */
  30294. serialize(): any;
  30295. /**
  30296. * Extracts the vertexData from a mesh
  30297. * @param mesh the mesh from which to extract the VertexData
  30298. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30299. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30300. * @returns the object VertexData associated to the passed mesh
  30301. */
  30302. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30303. /**
  30304. * Extracts the vertexData from the geometry
  30305. * @param geometry the geometry from which to extract the VertexData
  30306. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30307. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30308. * @returns the object VertexData associated to the passed mesh
  30309. */
  30310. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30311. private static _ExtractFrom;
  30312. /**
  30313. * Creates the VertexData for a Ribbon
  30314. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30315. * * pathArray array of paths, each of which an array of successive Vector3
  30316. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30317. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30318. * * 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
  30319. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30320. * * 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)
  30321. * * 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)
  30322. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30323. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30324. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30325. * @returns the VertexData of the ribbon
  30326. */
  30327. static CreateRibbon(options: {
  30328. pathArray: Vector3[][];
  30329. closeArray?: boolean;
  30330. closePath?: boolean;
  30331. offset?: number;
  30332. sideOrientation?: number;
  30333. frontUVs?: Vector4;
  30334. backUVs?: Vector4;
  30335. invertUV?: boolean;
  30336. uvs?: Vector2[];
  30337. colors?: Color4[];
  30338. }): VertexData;
  30339. /**
  30340. * Creates the VertexData for a box
  30341. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30342. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30343. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30344. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30345. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30346. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30347. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30349. * * 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)
  30350. * * 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)
  30351. * @returns the VertexData of the box
  30352. */
  30353. static CreateBox(options: {
  30354. size?: number;
  30355. width?: number;
  30356. height?: number;
  30357. depth?: number;
  30358. faceUV?: Vector4[];
  30359. faceColors?: Color4[];
  30360. sideOrientation?: number;
  30361. frontUVs?: Vector4;
  30362. backUVs?: Vector4;
  30363. }): VertexData;
  30364. /**
  30365. * Creates the VertexData for a tiled box
  30366. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30367. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30368. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30369. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30371. * @returns the VertexData of the box
  30372. */
  30373. static CreateTiledBox(options: {
  30374. pattern?: number;
  30375. width?: number;
  30376. height?: number;
  30377. depth?: number;
  30378. tileSize?: number;
  30379. tileWidth?: number;
  30380. tileHeight?: number;
  30381. alignHorizontal?: number;
  30382. alignVertical?: number;
  30383. faceUV?: Vector4[];
  30384. faceColors?: Color4[];
  30385. sideOrientation?: number;
  30386. }): VertexData;
  30387. /**
  30388. * Creates the VertexData for a tiled plane
  30389. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30390. * * pattern a limited pattern arrangement depending on the number
  30391. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30392. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30393. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30394. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30395. * * 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)
  30396. * * 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)
  30397. * @returns the VertexData of the tiled plane
  30398. */
  30399. static CreateTiledPlane(options: {
  30400. pattern?: number;
  30401. tileSize?: number;
  30402. tileWidth?: number;
  30403. tileHeight?: number;
  30404. size?: number;
  30405. width?: number;
  30406. height?: number;
  30407. alignHorizontal?: number;
  30408. alignVertical?: number;
  30409. sideOrientation?: number;
  30410. frontUVs?: Vector4;
  30411. backUVs?: Vector4;
  30412. }): VertexData;
  30413. /**
  30414. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30415. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30416. * * segments sets the number of horizontal strips optional, default 32
  30417. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30418. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30419. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30420. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30421. * * 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
  30422. * * 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
  30423. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30424. * * 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)
  30425. * * 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)
  30426. * @returns the VertexData of the ellipsoid
  30427. */
  30428. static CreateSphere(options: {
  30429. segments?: number;
  30430. diameter?: number;
  30431. diameterX?: number;
  30432. diameterY?: number;
  30433. diameterZ?: number;
  30434. arc?: number;
  30435. slice?: number;
  30436. sideOrientation?: number;
  30437. frontUVs?: Vector4;
  30438. backUVs?: Vector4;
  30439. }): VertexData;
  30440. /**
  30441. * Creates the VertexData for a cylinder, cone or prism
  30442. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30443. * * height sets the height (y direction) of the cylinder, optional, default 2
  30444. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30445. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30446. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30447. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30448. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30449. * * 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
  30450. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30451. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30452. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30453. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30455. * * 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)
  30456. * * 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)
  30457. * @returns the VertexData of the cylinder, cone or prism
  30458. */
  30459. static CreateCylinder(options: {
  30460. height?: number;
  30461. diameterTop?: number;
  30462. diameterBottom?: number;
  30463. diameter?: number;
  30464. tessellation?: number;
  30465. subdivisions?: number;
  30466. arc?: number;
  30467. faceColors?: Color4[];
  30468. faceUV?: Vector4[];
  30469. hasRings?: boolean;
  30470. enclose?: boolean;
  30471. sideOrientation?: number;
  30472. frontUVs?: Vector4;
  30473. backUVs?: Vector4;
  30474. }): VertexData;
  30475. /**
  30476. * Creates the VertexData for a torus
  30477. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30478. * * diameter the diameter of the torus, optional default 1
  30479. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30480. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30482. * * 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)
  30483. * * 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)
  30484. * @returns the VertexData of the torus
  30485. */
  30486. static CreateTorus(options: {
  30487. diameter?: number;
  30488. thickness?: number;
  30489. tessellation?: number;
  30490. sideOrientation?: number;
  30491. frontUVs?: Vector4;
  30492. backUVs?: Vector4;
  30493. }): VertexData;
  30494. /**
  30495. * Creates the VertexData of the LineSystem
  30496. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30497. * - lines an array of lines, each line being an array of successive Vector3
  30498. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30499. * @returns the VertexData of the LineSystem
  30500. */
  30501. static CreateLineSystem(options: {
  30502. lines: Vector3[][];
  30503. colors?: Nullable<Color4[][]>;
  30504. }): VertexData;
  30505. /**
  30506. * Create the VertexData for a DashedLines
  30507. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30508. * - points an array successive Vector3
  30509. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30510. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30511. * - dashNb the intended total number of dashes, optional, default 200
  30512. * @returns the VertexData for the DashedLines
  30513. */
  30514. static CreateDashedLines(options: {
  30515. points: Vector3[];
  30516. dashSize?: number;
  30517. gapSize?: number;
  30518. dashNb?: number;
  30519. }): VertexData;
  30520. /**
  30521. * Creates the VertexData for a Ground
  30522. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30523. * - width the width (x direction) of the ground, optional, default 1
  30524. * - height the height (z direction) of the ground, optional, default 1
  30525. * - subdivisions the number of subdivisions per side, optional, default 1
  30526. * @returns the VertexData of the Ground
  30527. */
  30528. static CreateGround(options: {
  30529. width?: number;
  30530. height?: number;
  30531. subdivisions?: number;
  30532. subdivisionsX?: number;
  30533. subdivisionsY?: number;
  30534. }): VertexData;
  30535. /**
  30536. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30537. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30538. * * xmin the ground minimum X coordinate, optional, default -1
  30539. * * zmin the ground minimum Z coordinate, optional, default -1
  30540. * * xmax the ground maximum X coordinate, optional, default 1
  30541. * * zmax the ground maximum Z coordinate, optional, default 1
  30542. * * 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}
  30543. * * 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}
  30544. * @returns the VertexData of the TiledGround
  30545. */
  30546. static CreateTiledGround(options: {
  30547. xmin: number;
  30548. zmin: number;
  30549. xmax: number;
  30550. zmax: number;
  30551. subdivisions?: {
  30552. w: number;
  30553. h: number;
  30554. };
  30555. precision?: {
  30556. w: number;
  30557. h: number;
  30558. };
  30559. }): VertexData;
  30560. /**
  30561. * Creates the VertexData of the Ground designed from a heightmap
  30562. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30563. * * width the width (x direction) of the ground
  30564. * * height the height (z direction) of the ground
  30565. * * subdivisions the number of subdivisions per side
  30566. * * minHeight the minimum altitude on the ground, optional, default 0
  30567. * * maxHeight the maximum altitude on the ground, optional default 1
  30568. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30569. * * buffer the array holding the image color data
  30570. * * bufferWidth the width of image
  30571. * * bufferHeight the height of image
  30572. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30573. * @returns the VertexData of the Ground designed from a heightmap
  30574. */
  30575. static CreateGroundFromHeightMap(options: {
  30576. width: number;
  30577. height: number;
  30578. subdivisions: number;
  30579. minHeight: number;
  30580. maxHeight: number;
  30581. colorFilter: Color3;
  30582. buffer: Uint8Array;
  30583. bufferWidth: number;
  30584. bufferHeight: number;
  30585. alphaFilter: number;
  30586. }): VertexData;
  30587. /**
  30588. * Creates the VertexData for a Plane
  30589. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30590. * * size sets the width and height of the plane to the value of size, optional default 1
  30591. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30592. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30593. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30594. * * 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)
  30595. * * 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)
  30596. * @returns the VertexData of the box
  30597. */
  30598. static CreatePlane(options: {
  30599. size?: number;
  30600. width?: number;
  30601. height?: number;
  30602. sideOrientation?: number;
  30603. frontUVs?: Vector4;
  30604. backUVs?: Vector4;
  30605. }): VertexData;
  30606. /**
  30607. * Creates the VertexData of the Disc or regular Polygon
  30608. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30609. * * radius the radius of the disc, optional default 0.5
  30610. * * tessellation the number of polygon sides, optional, default 64
  30611. * * 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
  30612. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30613. * * 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)
  30614. * * 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)
  30615. * @returns the VertexData of the box
  30616. */
  30617. static CreateDisc(options: {
  30618. radius?: number;
  30619. tessellation?: number;
  30620. arc?: number;
  30621. sideOrientation?: number;
  30622. frontUVs?: Vector4;
  30623. backUVs?: Vector4;
  30624. }): VertexData;
  30625. /**
  30626. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  30627. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  30628. * @param polygon a mesh built from polygonTriangulation.build()
  30629. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30630. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30631. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30632. * @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)
  30633. * @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)
  30634. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  30635. * @returns the VertexData of the Polygon
  30636. */
  30637. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  30638. /**
  30639. * Creates the VertexData of the IcoSphere
  30640. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  30641. * * radius the radius of the IcoSphere, optional default 1
  30642. * * radiusX allows stretching in the x direction, optional, default radius
  30643. * * radiusY allows stretching in the y direction, optional, default radius
  30644. * * radiusZ allows stretching in the z direction, optional, default radius
  30645. * * flat when true creates a flat shaded mesh, optional, default true
  30646. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30647. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30648. * * 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)
  30649. * * 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)
  30650. * @returns the VertexData of the IcoSphere
  30651. */
  30652. static CreateIcoSphere(options: {
  30653. radius?: number;
  30654. radiusX?: number;
  30655. radiusY?: number;
  30656. radiusZ?: number;
  30657. flat?: boolean;
  30658. subdivisions?: number;
  30659. sideOrientation?: number;
  30660. frontUVs?: Vector4;
  30661. backUVs?: Vector4;
  30662. }): VertexData;
  30663. /**
  30664. * Creates the VertexData for a Polyhedron
  30665. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  30666. * * type provided types are:
  30667. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  30668. * * 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)
  30669. * * size the size of the IcoSphere, optional default 1
  30670. * * sizeX allows stretching in the x direction, optional, default size
  30671. * * sizeY allows stretching in the y direction, optional, default size
  30672. * * sizeZ allows stretching in the z direction, optional, default size
  30673. * * 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
  30674. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30675. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30676. * * flat when true creates a flat shaded mesh, optional, default true
  30677. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30679. * * 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)
  30680. * * 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)
  30681. * @returns the VertexData of the Polyhedron
  30682. */
  30683. static CreatePolyhedron(options: {
  30684. type?: number;
  30685. size?: number;
  30686. sizeX?: number;
  30687. sizeY?: number;
  30688. sizeZ?: number;
  30689. custom?: any;
  30690. faceUV?: Vector4[];
  30691. faceColors?: Color4[];
  30692. flat?: boolean;
  30693. sideOrientation?: number;
  30694. frontUVs?: Vector4;
  30695. backUVs?: Vector4;
  30696. }): VertexData;
  30697. /**
  30698. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  30699. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  30700. * @returns the VertexData of the Capsule
  30701. */
  30702. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  30703. /**
  30704. * Creates the VertexData for a TorusKnot
  30705. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  30706. * * radius the radius of the torus knot, optional, default 2
  30707. * * tube the thickness of the tube, optional, default 0.5
  30708. * * radialSegments the number of sides on each tube segments, optional, default 32
  30709. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  30710. * * p the number of windings around the z axis, optional, default 2
  30711. * * q the number of windings around the x axis, optional, default 3
  30712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30713. * * 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)
  30714. * * 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)
  30715. * @returns the VertexData of the Torus Knot
  30716. */
  30717. static CreateTorusKnot(options: {
  30718. radius?: number;
  30719. tube?: number;
  30720. radialSegments?: number;
  30721. tubularSegments?: number;
  30722. p?: number;
  30723. q?: number;
  30724. sideOrientation?: number;
  30725. frontUVs?: Vector4;
  30726. backUVs?: Vector4;
  30727. }): VertexData;
  30728. /**
  30729. * Compute normals for given positions and indices
  30730. * @param positions an array of vertex positions, [...., x, y, z, ......]
  30731. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  30732. * @param normals an array of vertex normals, [...., x, y, z, ......]
  30733. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  30734. * * facetNormals : optional array of facet normals (vector3)
  30735. * * facetPositions : optional array of facet positions (vector3)
  30736. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  30737. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  30738. * * bInfo : optional bounding info, required for facetPartitioning computation
  30739. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  30740. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  30741. * * useRightHandedSystem: optional boolean to for right handed system computation
  30742. * * depthSort : optional boolean to enable the facet depth sort computation
  30743. * * distanceTo : optional Vector3 to compute the facet depth from this location
  30744. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  30745. */
  30746. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  30747. facetNormals?: any;
  30748. facetPositions?: any;
  30749. facetPartitioning?: any;
  30750. ratio?: number;
  30751. bInfo?: any;
  30752. bbSize?: Vector3;
  30753. subDiv?: any;
  30754. useRightHandedSystem?: boolean;
  30755. depthSort?: boolean;
  30756. distanceTo?: Vector3;
  30757. depthSortedFacets?: any;
  30758. }): void;
  30759. /** @hidden */
  30760. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  30761. /**
  30762. * Applies VertexData created from the imported parameters to the geometry
  30763. * @param parsedVertexData the parsed data from an imported file
  30764. * @param geometry the geometry to apply the VertexData to
  30765. */
  30766. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  30767. }
  30768. }
  30769. declare module BABYLON {
  30770. /**
  30771. * Defines a target to use with MorphTargetManager
  30772. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30773. */
  30774. export class MorphTarget implements IAnimatable {
  30775. /** defines the name of the target */
  30776. name: string;
  30777. /**
  30778. * Gets or sets the list of animations
  30779. */
  30780. animations: Animation[];
  30781. private _scene;
  30782. private _positions;
  30783. private _normals;
  30784. private _tangents;
  30785. private _uvs;
  30786. private _influence;
  30787. private _uniqueId;
  30788. /**
  30789. * Observable raised when the influence changes
  30790. */
  30791. onInfluenceChanged: Observable<boolean>;
  30792. /** @hidden */
  30793. _onDataLayoutChanged: Observable<void>;
  30794. /**
  30795. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30796. */
  30797. get influence(): number;
  30798. set influence(influence: number);
  30799. /**
  30800. * Gets or sets the id of the morph Target
  30801. */
  30802. id: string;
  30803. private _animationPropertiesOverride;
  30804. /**
  30805. * Gets or sets the animation properties override
  30806. */
  30807. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30808. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30809. /**
  30810. * Creates a new MorphTarget
  30811. * @param name defines the name of the target
  30812. * @param influence defines the influence to use
  30813. * @param scene defines the scene the morphtarget belongs to
  30814. */
  30815. constructor(
  30816. /** defines the name of the target */
  30817. name: string, influence?: number, scene?: Nullable<Scene>);
  30818. /**
  30819. * Gets the unique ID of this manager
  30820. */
  30821. get uniqueId(): number;
  30822. /**
  30823. * Gets a boolean defining if the target contains position data
  30824. */
  30825. get hasPositions(): boolean;
  30826. /**
  30827. * Gets a boolean defining if the target contains normal data
  30828. */
  30829. get hasNormals(): boolean;
  30830. /**
  30831. * Gets a boolean defining if the target contains tangent data
  30832. */
  30833. get hasTangents(): boolean;
  30834. /**
  30835. * Gets a boolean defining if the target contains texture coordinates data
  30836. */
  30837. get hasUVs(): boolean;
  30838. /**
  30839. * Affects position data to this target
  30840. * @param data defines the position data to use
  30841. */
  30842. setPositions(data: Nullable<FloatArray>): void;
  30843. /**
  30844. * Gets the position data stored in this target
  30845. * @returns a FloatArray containing the position data (or null if not present)
  30846. */
  30847. getPositions(): Nullable<FloatArray>;
  30848. /**
  30849. * Affects normal data to this target
  30850. * @param data defines the normal data to use
  30851. */
  30852. setNormals(data: Nullable<FloatArray>): void;
  30853. /**
  30854. * Gets the normal data stored in this target
  30855. * @returns a FloatArray containing the normal data (or null if not present)
  30856. */
  30857. getNormals(): Nullable<FloatArray>;
  30858. /**
  30859. * Affects tangent data to this target
  30860. * @param data defines the tangent data to use
  30861. */
  30862. setTangents(data: Nullable<FloatArray>): void;
  30863. /**
  30864. * Gets the tangent data stored in this target
  30865. * @returns a FloatArray containing the tangent data (or null if not present)
  30866. */
  30867. getTangents(): Nullable<FloatArray>;
  30868. /**
  30869. * Affects texture coordinates data to this target
  30870. * @param data defines the texture coordinates data to use
  30871. */
  30872. setUVs(data: Nullable<FloatArray>): void;
  30873. /**
  30874. * Gets the texture coordinates data stored in this target
  30875. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30876. */
  30877. getUVs(): Nullable<FloatArray>;
  30878. /**
  30879. * Clone the current target
  30880. * @returns a new MorphTarget
  30881. */
  30882. clone(): MorphTarget;
  30883. /**
  30884. * Serializes the current target into a Serialization object
  30885. * @returns the serialized object
  30886. */
  30887. serialize(): any;
  30888. /**
  30889. * Returns the string "MorphTarget"
  30890. * @returns "MorphTarget"
  30891. */
  30892. getClassName(): string;
  30893. /**
  30894. * Creates a new target from serialized data
  30895. * @param serializationObject defines the serialized data to use
  30896. * @returns a new MorphTarget
  30897. */
  30898. static Parse(serializationObject: any): MorphTarget;
  30899. /**
  30900. * Creates a MorphTarget from mesh data
  30901. * @param mesh defines the source mesh
  30902. * @param name defines the name to use for the new target
  30903. * @param influence defines the influence to attach to the target
  30904. * @returns a new MorphTarget
  30905. */
  30906. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30907. }
  30908. }
  30909. declare module BABYLON {
  30910. /**
  30911. * This class is used to deform meshes using morphing between different targets
  30912. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30913. */
  30914. export class MorphTargetManager {
  30915. private _targets;
  30916. private _targetInfluenceChangedObservers;
  30917. private _targetDataLayoutChangedObservers;
  30918. private _activeTargets;
  30919. private _scene;
  30920. private _influences;
  30921. private _supportsNormals;
  30922. private _supportsTangents;
  30923. private _supportsUVs;
  30924. private _vertexCount;
  30925. private _uniqueId;
  30926. private _tempInfluences;
  30927. /**
  30928. * Gets or sets a boolean indicating if normals must be morphed
  30929. */
  30930. enableNormalMorphing: boolean;
  30931. /**
  30932. * Gets or sets a boolean indicating if tangents must be morphed
  30933. */
  30934. enableTangentMorphing: boolean;
  30935. /**
  30936. * Gets or sets a boolean indicating if UV must be morphed
  30937. */
  30938. enableUVMorphing: boolean;
  30939. /**
  30940. * Creates a new MorphTargetManager
  30941. * @param scene defines the current scene
  30942. */
  30943. constructor(scene?: Nullable<Scene>);
  30944. /**
  30945. * Gets the unique ID of this manager
  30946. */
  30947. get uniqueId(): number;
  30948. /**
  30949. * Gets the number of vertices handled by this manager
  30950. */
  30951. get vertexCount(): number;
  30952. /**
  30953. * Gets a boolean indicating if this manager supports morphing of normals
  30954. */
  30955. get supportsNormals(): boolean;
  30956. /**
  30957. * Gets a boolean indicating if this manager supports morphing of tangents
  30958. */
  30959. get supportsTangents(): boolean;
  30960. /**
  30961. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30962. */
  30963. get supportsUVs(): boolean;
  30964. /**
  30965. * Gets the number of targets stored in this manager
  30966. */
  30967. get numTargets(): number;
  30968. /**
  30969. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30970. */
  30971. get numInfluencers(): number;
  30972. /**
  30973. * Gets the list of influences (one per target)
  30974. */
  30975. get influences(): Float32Array;
  30976. /**
  30977. * Gets the active target at specified index. An active target is a target with an influence > 0
  30978. * @param index defines the index to check
  30979. * @returns the requested target
  30980. */
  30981. getActiveTarget(index: number): MorphTarget;
  30982. /**
  30983. * Gets the target at specified index
  30984. * @param index defines the index to check
  30985. * @returns the requested target
  30986. */
  30987. getTarget(index: number): MorphTarget;
  30988. /**
  30989. * Add a new target to this manager
  30990. * @param target defines the target to add
  30991. */
  30992. addTarget(target: MorphTarget): void;
  30993. /**
  30994. * Removes a target from the manager
  30995. * @param target defines the target to remove
  30996. */
  30997. removeTarget(target: MorphTarget): void;
  30998. /**
  30999. * Clone the current manager
  31000. * @returns a new MorphTargetManager
  31001. */
  31002. clone(): MorphTargetManager;
  31003. /**
  31004. * Serializes the current manager into a Serialization object
  31005. * @returns the serialized object
  31006. */
  31007. serialize(): any;
  31008. private _syncActiveTargets;
  31009. /**
  31010. * Syncrhonize the targets with all the meshes using this morph target manager
  31011. */
  31012. synchronize(): void;
  31013. /**
  31014. * Creates a new MorphTargetManager from serialized data
  31015. * @param serializationObject defines the serialized data
  31016. * @param scene defines the hosting scene
  31017. * @returns the new MorphTargetManager
  31018. */
  31019. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31020. }
  31021. }
  31022. declare module BABYLON {
  31023. /**
  31024. * Class used to represent a specific level of detail of a mesh
  31025. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31026. */
  31027. export class MeshLODLevel {
  31028. /** Defines the distance where this level should start being displayed */
  31029. distance: number;
  31030. /** Defines the mesh to use to render this level */
  31031. mesh: Nullable<Mesh>;
  31032. /**
  31033. * Creates a new LOD level
  31034. * @param distance defines the distance where this level should star being displayed
  31035. * @param mesh defines the mesh to use to render this level
  31036. */
  31037. constructor(
  31038. /** Defines the distance where this level should start being displayed */
  31039. distance: number,
  31040. /** Defines the mesh to use to render this level */
  31041. mesh: Nullable<Mesh>);
  31042. }
  31043. }
  31044. declare module BABYLON {
  31045. /**
  31046. * Helper class used to generate a canvas to manipulate images
  31047. */
  31048. export class CanvasGenerator {
  31049. /**
  31050. * Create a new canvas (or offscreen canvas depending on the context)
  31051. * @param width defines the expected width
  31052. * @param height defines the expected height
  31053. * @return a new canvas or offscreen canvas
  31054. */
  31055. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31056. }
  31057. }
  31058. declare module BABYLON {
  31059. /**
  31060. * Mesh representing the gorund
  31061. */
  31062. export class GroundMesh extends Mesh {
  31063. /** If octree should be generated */
  31064. generateOctree: boolean;
  31065. private _heightQuads;
  31066. /** @hidden */
  31067. _subdivisionsX: number;
  31068. /** @hidden */
  31069. _subdivisionsY: number;
  31070. /** @hidden */
  31071. _width: number;
  31072. /** @hidden */
  31073. _height: number;
  31074. /** @hidden */
  31075. _minX: number;
  31076. /** @hidden */
  31077. _maxX: number;
  31078. /** @hidden */
  31079. _minZ: number;
  31080. /** @hidden */
  31081. _maxZ: number;
  31082. constructor(name: string, scene: Scene);
  31083. /**
  31084. * "GroundMesh"
  31085. * @returns "GroundMesh"
  31086. */
  31087. getClassName(): string;
  31088. /**
  31089. * The minimum of x and y subdivisions
  31090. */
  31091. get subdivisions(): number;
  31092. /**
  31093. * X subdivisions
  31094. */
  31095. get subdivisionsX(): number;
  31096. /**
  31097. * Y subdivisions
  31098. */
  31099. get subdivisionsY(): number;
  31100. /**
  31101. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31102. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31103. * @param chunksCount the number of subdivisions for x and y
  31104. * @param octreeBlocksSize (Default: 32)
  31105. */
  31106. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31107. /**
  31108. * Returns a height (y) value in the Worl system :
  31109. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31110. * @param x x coordinate
  31111. * @param z z coordinate
  31112. * @returns the ground y position if (x, z) are outside the ground surface.
  31113. */
  31114. getHeightAtCoordinates(x: number, z: number): number;
  31115. /**
  31116. * Returns a normalized vector (Vector3) orthogonal to the ground
  31117. * at the ground coordinates (x, z) expressed in the World system.
  31118. * @param x x coordinate
  31119. * @param z z coordinate
  31120. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31121. */
  31122. getNormalAtCoordinates(x: number, z: number): Vector3;
  31123. /**
  31124. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31125. * at the ground coordinates (x, z) expressed in the World system.
  31126. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31127. * @param x x coordinate
  31128. * @param z z coordinate
  31129. * @param ref vector to store the result
  31130. * @returns the GroundMesh.
  31131. */
  31132. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31133. /**
  31134. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31135. * if the ground has been updated.
  31136. * This can be used in the render loop.
  31137. * @returns the GroundMesh.
  31138. */
  31139. updateCoordinateHeights(): GroundMesh;
  31140. private _getFacetAt;
  31141. private _initHeightQuads;
  31142. private _computeHeightQuads;
  31143. /**
  31144. * Serializes this ground mesh
  31145. * @param serializationObject object to write serialization to
  31146. */
  31147. serialize(serializationObject: any): void;
  31148. /**
  31149. * Parses a serialized ground mesh
  31150. * @param parsedMesh the serialized mesh
  31151. * @param scene the scene to create the ground mesh in
  31152. * @returns the created ground mesh
  31153. */
  31154. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31155. }
  31156. }
  31157. declare module BABYLON {
  31158. /**
  31159. * Interface for Physics-Joint data
  31160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31161. */
  31162. export interface PhysicsJointData {
  31163. /**
  31164. * The main pivot of the joint
  31165. */
  31166. mainPivot?: Vector3;
  31167. /**
  31168. * The connected pivot of the joint
  31169. */
  31170. connectedPivot?: Vector3;
  31171. /**
  31172. * The main axis of the joint
  31173. */
  31174. mainAxis?: Vector3;
  31175. /**
  31176. * The connected axis of the joint
  31177. */
  31178. connectedAxis?: Vector3;
  31179. /**
  31180. * The collision of the joint
  31181. */
  31182. collision?: boolean;
  31183. /**
  31184. * Native Oimo/Cannon/Energy data
  31185. */
  31186. nativeParams?: any;
  31187. }
  31188. /**
  31189. * This is a holder class for the physics joint created by the physics plugin
  31190. * It holds a set of functions to control the underlying joint
  31191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31192. */
  31193. export class PhysicsJoint {
  31194. /**
  31195. * The type of the physics joint
  31196. */
  31197. type: number;
  31198. /**
  31199. * The data for the physics joint
  31200. */
  31201. jointData: PhysicsJointData;
  31202. private _physicsJoint;
  31203. protected _physicsPlugin: IPhysicsEnginePlugin;
  31204. /**
  31205. * Initializes the physics joint
  31206. * @param type The type of the physics joint
  31207. * @param jointData The data for the physics joint
  31208. */
  31209. constructor(
  31210. /**
  31211. * The type of the physics joint
  31212. */
  31213. type: number,
  31214. /**
  31215. * The data for the physics joint
  31216. */
  31217. jointData: PhysicsJointData);
  31218. /**
  31219. * Gets the physics joint
  31220. */
  31221. get physicsJoint(): any;
  31222. /**
  31223. * Sets the physics joint
  31224. */
  31225. set physicsJoint(newJoint: any);
  31226. /**
  31227. * Sets the physics plugin
  31228. */
  31229. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31230. /**
  31231. * Execute a function that is physics-plugin specific.
  31232. * @param {Function} func the function that will be executed.
  31233. * It accepts two parameters: the physics world and the physics joint
  31234. */
  31235. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31236. /**
  31237. * Distance-Joint type
  31238. */
  31239. static DistanceJoint: number;
  31240. /**
  31241. * Hinge-Joint type
  31242. */
  31243. static HingeJoint: number;
  31244. /**
  31245. * Ball-and-Socket joint type
  31246. */
  31247. static BallAndSocketJoint: number;
  31248. /**
  31249. * Wheel-Joint type
  31250. */
  31251. static WheelJoint: number;
  31252. /**
  31253. * Slider-Joint type
  31254. */
  31255. static SliderJoint: number;
  31256. /**
  31257. * Prismatic-Joint type
  31258. */
  31259. static PrismaticJoint: number;
  31260. /**
  31261. * Universal-Joint type
  31262. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31263. */
  31264. static UniversalJoint: number;
  31265. /**
  31266. * Hinge-Joint 2 type
  31267. */
  31268. static Hinge2Joint: number;
  31269. /**
  31270. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31271. */
  31272. static PointToPointJoint: number;
  31273. /**
  31274. * Spring-Joint type
  31275. */
  31276. static SpringJoint: number;
  31277. /**
  31278. * Lock-Joint type
  31279. */
  31280. static LockJoint: number;
  31281. }
  31282. /**
  31283. * A class representing a physics distance joint
  31284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31285. */
  31286. export class DistanceJoint extends PhysicsJoint {
  31287. /**
  31288. *
  31289. * @param jointData The data for the Distance-Joint
  31290. */
  31291. constructor(jointData: DistanceJointData);
  31292. /**
  31293. * Update the predefined distance.
  31294. * @param maxDistance The maximum preferred distance
  31295. * @param minDistance The minimum preferred distance
  31296. */
  31297. updateDistance(maxDistance: number, minDistance?: number): void;
  31298. }
  31299. /**
  31300. * Represents a Motor-Enabled Joint
  31301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31302. */
  31303. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31304. /**
  31305. * Initializes the Motor-Enabled Joint
  31306. * @param type The type of the joint
  31307. * @param jointData The physica joint data for the joint
  31308. */
  31309. constructor(type: number, jointData: PhysicsJointData);
  31310. /**
  31311. * Set the motor values.
  31312. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31313. * @param force the force to apply
  31314. * @param maxForce max force for this motor.
  31315. */
  31316. setMotor(force?: number, maxForce?: number): void;
  31317. /**
  31318. * Set the motor's limits.
  31319. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31320. * @param upperLimit The upper limit of the motor
  31321. * @param lowerLimit The lower limit of the motor
  31322. */
  31323. setLimit(upperLimit: number, lowerLimit?: number): void;
  31324. }
  31325. /**
  31326. * This class represents a single physics Hinge-Joint
  31327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31328. */
  31329. export class HingeJoint extends MotorEnabledJoint {
  31330. /**
  31331. * Initializes the Hinge-Joint
  31332. * @param jointData The joint data for the Hinge-Joint
  31333. */
  31334. constructor(jointData: PhysicsJointData);
  31335. /**
  31336. * Set the motor values.
  31337. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31338. * @param {number} force the force to apply
  31339. * @param {number} maxForce max force for this motor.
  31340. */
  31341. setMotor(force?: number, maxForce?: number): void;
  31342. /**
  31343. * Set the motor's limits.
  31344. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31345. * @param upperLimit The upper limit of the motor
  31346. * @param lowerLimit The lower limit of the motor
  31347. */
  31348. setLimit(upperLimit: number, lowerLimit?: number): void;
  31349. }
  31350. /**
  31351. * This class represents a dual hinge physics joint (same as wheel joint)
  31352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31353. */
  31354. export class Hinge2Joint extends MotorEnabledJoint {
  31355. /**
  31356. * Initializes the Hinge2-Joint
  31357. * @param jointData The joint data for the Hinge2-Joint
  31358. */
  31359. constructor(jointData: PhysicsJointData);
  31360. /**
  31361. * Set the motor values.
  31362. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31363. * @param {number} targetSpeed the speed the motor is to reach
  31364. * @param {number} maxForce max force for this motor.
  31365. * @param {motorIndex} the motor's index, 0 or 1.
  31366. */
  31367. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31368. /**
  31369. * Set the motor limits.
  31370. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31371. * @param {number} upperLimit the upper limit
  31372. * @param {number} lowerLimit lower limit
  31373. * @param {motorIndex} the motor's index, 0 or 1.
  31374. */
  31375. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31376. }
  31377. /**
  31378. * Interface for a motor enabled joint
  31379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31380. */
  31381. export interface IMotorEnabledJoint {
  31382. /**
  31383. * Physics joint
  31384. */
  31385. physicsJoint: any;
  31386. /**
  31387. * Sets the motor of the motor-enabled joint
  31388. * @param force The force of the motor
  31389. * @param maxForce The maximum force of the motor
  31390. * @param motorIndex The index of the motor
  31391. */
  31392. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31393. /**
  31394. * Sets the limit of the motor
  31395. * @param upperLimit The upper limit of the motor
  31396. * @param lowerLimit The lower limit of the motor
  31397. * @param motorIndex The index of the motor
  31398. */
  31399. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31400. }
  31401. /**
  31402. * Joint data for a Distance-Joint
  31403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31404. */
  31405. export interface DistanceJointData extends PhysicsJointData {
  31406. /**
  31407. * Max distance the 2 joint objects can be apart
  31408. */
  31409. maxDistance: number;
  31410. }
  31411. /**
  31412. * Joint data from a spring joint
  31413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31414. */
  31415. export interface SpringJointData extends PhysicsJointData {
  31416. /**
  31417. * Length of the spring
  31418. */
  31419. length: number;
  31420. /**
  31421. * Stiffness of the spring
  31422. */
  31423. stiffness: number;
  31424. /**
  31425. * Damping of the spring
  31426. */
  31427. damping: number;
  31428. /** this callback will be called when applying the force to the impostors. */
  31429. forceApplicationCallback: () => void;
  31430. }
  31431. }
  31432. declare module BABYLON {
  31433. /**
  31434. * Holds the data for the raycast result
  31435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31436. */
  31437. export class PhysicsRaycastResult {
  31438. private _hasHit;
  31439. private _hitDistance;
  31440. private _hitNormalWorld;
  31441. private _hitPointWorld;
  31442. private _rayFromWorld;
  31443. private _rayToWorld;
  31444. /**
  31445. * Gets if there was a hit
  31446. */
  31447. get hasHit(): boolean;
  31448. /**
  31449. * Gets the distance from the hit
  31450. */
  31451. get hitDistance(): number;
  31452. /**
  31453. * Gets the hit normal/direction in the world
  31454. */
  31455. get hitNormalWorld(): Vector3;
  31456. /**
  31457. * Gets the hit point in the world
  31458. */
  31459. get hitPointWorld(): Vector3;
  31460. /**
  31461. * Gets the ray "start point" of the ray in the world
  31462. */
  31463. get rayFromWorld(): Vector3;
  31464. /**
  31465. * Gets the ray "end point" of the ray in the world
  31466. */
  31467. get rayToWorld(): Vector3;
  31468. /**
  31469. * Sets the hit data (normal & point in world space)
  31470. * @param hitNormalWorld defines the normal in world space
  31471. * @param hitPointWorld defines the point in world space
  31472. */
  31473. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31474. /**
  31475. * Sets the distance from the start point to the hit point
  31476. * @param distance
  31477. */
  31478. setHitDistance(distance: number): void;
  31479. /**
  31480. * Calculates the distance manually
  31481. */
  31482. calculateHitDistance(): void;
  31483. /**
  31484. * Resets all the values to default
  31485. * @param from The from point on world space
  31486. * @param to The to point on world space
  31487. */
  31488. reset(from?: Vector3, to?: Vector3): void;
  31489. }
  31490. /**
  31491. * Interface for the size containing width and height
  31492. */
  31493. interface IXYZ {
  31494. /**
  31495. * X
  31496. */
  31497. x: number;
  31498. /**
  31499. * Y
  31500. */
  31501. y: number;
  31502. /**
  31503. * Z
  31504. */
  31505. z: number;
  31506. }
  31507. }
  31508. declare module BABYLON {
  31509. /**
  31510. * Interface used to describe a physics joint
  31511. */
  31512. export interface PhysicsImpostorJoint {
  31513. /** Defines the main impostor to which the joint is linked */
  31514. mainImpostor: PhysicsImpostor;
  31515. /** Defines the impostor that is connected to the main impostor using this joint */
  31516. connectedImpostor: PhysicsImpostor;
  31517. /** Defines the joint itself */
  31518. joint: PhysicsJoint;
  31519. }
  31520. /** @hidden */
  31521. export interface IPhysicsEnginePlugin {
  31522. world: any;
  31523. name: string;
  31524. setGravity(gravity: Vector3): void;
  31525. setTimeStep(timeStep: number): void;
  31526. getTimeStep(): number;
  31527. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31528. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31529. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31530. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31531. removePhysicsBody(impostor: PhysicsImpostor): void;
  31532. generateJoint(joint: PhysicsImpostorJoint): void;
  31533. removeJoint(joint: PhysicsImpostorJoint): void;
  31534. isSupported(): boolean;
  31535. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31536. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31537. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31538. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31539. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31540. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31541. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31542. getBodyMass(impostor: PhysicsImpostor): number;
  31543. getBodyFriction(impostor: PhysicsImpostor): number;
  31544. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31545. getBodyRestitution(impostor: PhysicsImpostor): number;
  31546. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31547. getBodyPressure?(impostor: PhysicsImpostor): number;
  31548. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31549. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31550. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31551. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31552. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31553. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31554. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31555. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31556. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31557. sleepBody(impostor: PhysicsImpostor): void;
  31558. wakeUpBody(impostor: PhysicsImpostor): void;
  31559. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31560. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31561. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31562. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31563. getRadius(impostor: PhysicsImpostor): number;
  31564. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31565. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31566. dispose(): void;
  31567. }
  31568. /**
  31569. * Interface used to define a physics engine
  31570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31571. */
  31572. export interface IPhysicsEngine {
  31573. /**
  31574. * Gets the gravity vector used by the simulation
  31575. */
  31576. gravity: Vector3;
  31577. /**
  31578. * Sets the gravity vector used by the simulation
  31579. * @param gravity defines the gravity vector to use
  31580. */
  31581. setGravity(gravity: Vector3): void;
  31582. /**
  31583. * Set the time step of the physics engine.
  31584. * Default is 1/60.
  31585. * To slow it down, enter 1/600 for example.
  31586. * To speed it up, 1/30
  31587. * @param newTimeStep the new timestep to apply to this world.
  31588. */
  31589. setTimeStep(newTimeStep: number): void;
  31590. /**
  31591. * Get the time step of the physics engine.
  31592. * @returns the current time step
  31593. */
  31594. getTimeStep(): number;
  31595. /**
  31596. * Set the sub time step of the physics engine.
  31597. * Default is 0 meaning there is no sub steps
  31598. * To increase physics resolution precision, set a small value (like 1 ms)
  31599. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31600. */
  31601. setSubTimeStep(subTimeStep: number): void;
  31602. /**
  31603. * Get the sub time step of the physics engine.
  31604. * @returns the current sub time step
  31605. */
  31606. getSubTimeStep(): number;
  31607. /**
  31608. * Release all resources
  31609. */
  31610. dispose(): void;
  31611. /**
  31612. * Gets the name of the current physics plugin
  31613. * @returns the name of the plugin
  31614. */
  31615. getPhysicsPluginName(): string;
  31616. /**
  31617. * Adding a new impostor for the impostor tracking.
  31618. * This will be done by the impostor itself.
  31619. * @param impostor the impostor to add
  31620. */
  31621. addImpostor(impostor: PhysicsImpostor): void;
  31622. /**
  31623. * Remove an impostor from the engine.
  31624. * This impostor and its mesh will not longer be updated by the physics engine.
  31625. * @param impostor the impostor to remove
  31626. */
  31627. removeImpostor(impostor: PhysicsImpostor): void;
  31628. /**
  31629. * Add a joint to the physics engine
  31630. * @param mainImpostor defines the main impostor to which the joint is added.
  31631. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31632. * @param joint defines the joint that will connect both impostors.
  31633. */
  31634. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31635. /**
  31636. * Removes a joint from the simulation
  31637. * @param mainImpostor defines the impostor used with the joint
  31638. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31639. * @param joint defines the joint to remove
  31640. */
  31641. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31642. /**
  31643. * Gets the current plugin used to run the simulation
  31644. * @returns current plugin
  31645. */
  31646. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31647. /**
  31648. * Gets the list of physic impostors
  31649. * @returns an array of PhysicsImpostor
  31650. */
  31651. getImpostors(): Array<PhysicsImpostor>;
  31652. /**
  31653. * Gets the impostor for a physics enabled object
  31654. * @param object defines the object impersonated by the impostor
  31655. * @returns the PhysicsImpostor or null if not found
  31656. */
  31657. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31658. /**
  31659. * Gets the impostor for a physics body object
  31660. * @param body defines physics body used by the impostor
  31661. * @returns the PhysicsImpostor or null if not found
  31662. */
  31663. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31664. /**
  31665. * Does a raycast in the physics world
  31666. * @param from when should the ray start?
  31667. * @param to when should the ray end?
  31668. * @returns PhysicsRaycastResult
  31669. */
  31670. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31671. /**
  31672. * Called by the scene. No need to call it.
  31673. * @param delta defines the timespam between frames
  31674. */
  31675. _step(delta: number): void;
  31676. }
  31677. }
  31678. declare module BABYLON {
  31679. /**
  31680. * The interface for the physics imposter parameters
  31681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31682. */
  31683. export interface PhysicsImpostorParameters {
  31684. /**
  31685. * The mass of the physics imposter
  31686. */
  31687. mass: number;
  31688. /**
  31689. * The friction of the physics imposter
  31690. */
  31691. friction?: number;
  31692. /**
  31693. * The coefficient of restitution of the physics imposter
  31694. */
  31695. restitution?: number;
  31696. /**
  31697. * The native options of the physics imposter
  31698. */
  31699. nativeOptions?: any;
  31700. /**
  31701. * Specifies if the parent should be ignored
  31702. */
  31703. ignoreParent?: boolean;
  31704. /**
  31705. * Specifies if bi-directional transformations should be disabled
  31706. */
  31707. disableBidirectionalTransformation?: boolean;
  31708. /**
  31709. * The pressure inside the physics imposter, soft object only
  31710. */
  31711. pressure?: number;
  31712. /**
  31713. * The stiffness the physics imposter, soft object only
  31714. */
  31715. stiffness?: number;
  31716. /**
  31717. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31718. */
  31719. velocityIterations?: number;
  31720. /**
  31721. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31722. */
  31723. positionIterations?: number;
  31724. /**
  31725. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31726. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31727. * Add to fix multiple points
  31728. */
  31729. fixedPoints?: number;
  31730. /**
  31731. * The collision margin around a soft object
  31732. */
  31733. margin?: number;
  31734. /**
  31735. * The collision margin around a soft object
  31736. */
  31737. damping?: number;
  31738. /**
  31739. * The path for a rope based on an extrusion
  31740. */
  31741. path?: any;
  31742. /**
  31743. * The shape of an extrusion used for a rope based on an extrusion
  31744. */
  31745. shape?: any;
  31746. }
  31747. /**
  31748. * Interface for a physics-enabled object
  31749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31750. */
  31751. export interface IPhysicsEnabledObject {
  31752. /**
  31753. * The position of the physics-enabled object
  31754. */
  31755. position: Vector3;
  31756. /**
  31757. * The rotation of the physics-enabled object
  31758. */
  31759. rotationQuaternion: Nullable<Quaternion>;
  31760. /**
  31761. * The scale of the physics-enabled object
  31762. */
  31763. scaling: Vector3;
  31764. /**
  31765. * The rotation of the physics-enabled object
  31766. */
  31767. rotation?: Vector3;
  31768. /**
  31769. * The parent of the physics-enabled object
  31770. */
  31771. parent?: any;
  31772. /**
  31773. * The bounding info of the physics-enabled object
  31774. * @returns The bounding info of the physics-enabled object
  31775. */
  31776. getBoundingInfo(): BoundingInfo;
  31777. /**
  31778. * Computes the world matrix
  31779. * @param force Specifies if the world matrix should be computed by force
  31780. * @returns A world matrix
  31781. */
  31782. computeWorldMatrix(force: boolean): Matrix;
  31783. /**
  31784. * Gets the world matrix
  31785. * @returns A world matrix
  31786. */
  31787. getWorldMatrix?(): Matrix;
  31788. /**
  31789. * Gets the child meshes
  31790. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31791. * @returns An array of abstract meshes
  31792. */
  31793. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31794. /**
  31795. * Gets the vertex data
  31796. * @param kind The type of vertex data
  31797. * @returns A nullable array of numbers, or a float32 array
  31798. */
  31799. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31800. /**
  31801. * Gets the indices from the mesh
  31802. * @returns A nullable array of index arrays
  31803. */
  31804. getIndices?(): Nullable<IndicesArray>;
  31805. /**
  31806. * Gets the scene from the mesh
  31807. * @returns the indices array or null
  31808. */
  31809. getScene?(): Scene;
  31810. /**
  31811. * Gets the absolute position from the mesh
  31812. * @returns the absolute position
  31813. */
  31814. getAbsolutePosition(): Vector3;
  31815. /**
  31816. * Gets the absolute pivot point from the mesh
  31817. * @returns the absolute pivot point
  31818. */
  31819. getAbsolutePivotPoint(): Vector3;
  31820. /**
  31821. * Rotates the mesh
  31822. * @param axis The axis of rotation
  31823. * @param amount The amount of rotation
  31824. * @param space The space of the rotation
  31825. * @returns The rotation transform node
  31826. */
  31827. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31828. /**
  31829. * Translates the mesh
  31830. * @param axis The axis of translation
  31831. * @param distance The distance of translation
  31832. * @param space The space of the translation
  31833. * @returns The transform node
  31834. */
  31835. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31836. /**
  31837. * Sets the absolute position of the mesh
  31838. * @param absolutePosition The absolute position of the mesh
  31839. * @returns The transform node
  31840. */
  31841. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31842. /**
  31843. * Gets the class name of the mesh
  31844. * @returns The class name
  31845. */
  31846. getClassName(): string;
  31847. }
  31848. /**
  31849. * Represents a physics imposter
  31850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31851. */
  31852. export class PhysicsImpostor {
  31853. /**
  31854. * The physics-enabled object used as the physics imposter
  31855. */
  31856. object: IPhysicsEnabledObject;
  31857. /**
  31858. * The type of the physics imposter
  31859. */
  31860. type: number;
  31861. private _options;
  31862. private _scene?;
  31863. /**
  31864. * The default object size of the imposter
  31865. */
  31866. static DEFAULT_OBJECT_SIZE: Vector3;
  31867. /**
  31868. * The identity quaternion of the imposter
  31869. */
  31870. static IDENTITY_QUATERNION: Quaternion;
  31871. /** @hidden */
  31872. _pluginData: any;
  31873. private _physicsEngine;
  31874. private _physicsBody;
  31875. private _bodyUpdateRequired;
  31876. private _onBeforePhysicsStepCallbacks;
  31877. private _onAfterPhysicsStepCallbacks;
  31878. /** @hidden */
  31879. _onPhysicsCollideCallbacks: Array<{
  31880. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  31881. otherImpostors: Array<PhysicsImpostor>;
  31882. }>;
  31883. private _deltaPosition;
  31884. private _deltaRotation;
  31885. private _deltaRotationConjugated;
  31886. /** @hidden */
  31887. _isFromLine: boolean;
  31888. private _parent;
  31889. private _isDisposed;
  31890. private static _tmpVecs;
  31891. private static _tmpQuat;
  31892. /**
  31893. * Specifies if the physics imposter is disposed
  31894. */
  31895. get isDisposed(): boolean;
  31896. /**
  31897. * Gets the mass of the physics imposter
  31898. */
  31899. get mass(): number;
  31900. set mass(value: number);
  31901. /**
  31902. * Gets the coefficient of friction
  31903. */
  31904. get friction(): number;
  31905. /**
  31906. * Sets the coefficient of friction
  31907. */
  31908. set friction(value: number);
  31909. /**
  31910. * Gets the coefficient of restitution
  31911. */
  31912. get restitution(): number;
  31913. /**
  31914. * Sets the coefficient of restitution
  31915. */
  31916. set restitution(value: number);
  31917. /**
  31918. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31919. */
  31920. get pressure(): number;
  31921. /**
  31922. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31923. */
  31924. set pressure(value: number);
  31925. /**
  31926. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31927. */
  31928. get stiffness(): number;
  31929. /**
  31930. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31931. */
  31932. set stiffness(value: number);
  31933. /**
  31934. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31935. */
  31936. get velocityIterations(): number;
  31937. /**
  31938. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31939. */
  31940. set velocityIterations(value: number);
  31941. /**
  31942. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31943. */
  31944. get positionIterations(): number;
  31945. /**
  31946. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31947. */
  31948. set positionIterations(value: number);
  31949. /**
  31950. * The unique id of the physics imposter
  31951. * set by the physics engine when adding this impostor to the array
  31952. */
  31953. uniqueId: number;
  31954. /**
  31955. * @hidden
  31956. */
  31957. soft: boolean;
  31958. /**
  31959. * @hidden
  31960. */
  31961. segments: number;
  31962. private _joints;
  31963. /**
  31964. * Initializes the physics imposter
  31965. * @param object The physics-enabled object used as the physics imposter
  31966. * @param type The type of the physics imposter
  31967. * @param _options The options for the physics imposter
  31968. * @param _scene The Babylon scene
  31969. */
  31970. constructor(
  31971. /**
  31972. * The physics-enabled object used as the physics imposter
  31973. */
  31974. object: IPhysicsEnabledObject,
  31975. /**
  31976. * The type of the physics imposter
  31977. */
  31978. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31979. /**
  31980. * This function will completly initialize this impostor.
  31981. * It will create a new body - but only if this mesh has no parent.
  31982. * If it has, this impostor will not be used other than to define the impostor
  31983. * of the child mesh.
  31984. * @hidden
  31985. */
  31986. _init(): void;
  31987. private _getPhysicsParent;
  31988. /**
  31989. * Should a new body be generated.
  31990. * @returns boolean specifying if body initialization is required
  31991. */
  31992. isBodyInitRequired(): boolean;
  31993. /**
  31994. * Sets the updated scaling
  31995. * @param updated Specifies if the scaling is updated
  31996. */
  31997. setScalingUpdated(): void;
  31998. /**
  31999. * Force a regeneration of this or the parent's impostor's body.
  32000. * Use under cautious - This will remove all joints already implemented.
  32001. */
  32002. forceUpdate(): void;
  32003. /**
  32004. * Gets the body that holds this impostor. Either its own, or its parent.
  32005. */
  32006. get physicsBody(): any;
  32007. /**
  32008. * Get the parent of the physics imposter
  32009. * @returns Physics imposter or null
  32010. */
  32011. get parent(): Nullable<PhysicsImpostor>;
  32012. /**
  32013. * Sets the parent of the physics imposter
  32014. */
  32015. set parent(value: Nullable<PhysicsImpostor>);
  32016. /**
  32017. * Set the physics body. Used mainly by the physics engine/plugin
  32018. */
  32019. set physicsBody(physicsBody: any);
  32020. /**
  32021. * Resets the update flags
  32022. */
  32023. resetUpdateFlags(): void;
  32024. /**
  32025. * Gets the object extend size
  32026. * @returns the object extend size
  32027. */
  32028. getObjectExtendSize(): Vector3;
  32029. /**
  32030. * Gets the object center
  32031. * @returns The object center
  32032. */
  32033. getObjectCenter(): Vector3;
  32034. /**
  32035. * Get a specific parameter from the options parameters
  32036. * @param paramName The object parameter name
  32037. * @returns The object parameter
  32038. */
  32039. getParam(paramName: string): any;
  32040. /**
  32041. * Sets a specific parameter in the options given to the physics plugin
  32042. * @param paramName The parameter name
  32043. * @param value The value of the parameter
  32044. */
  32045. setParam(paramName: string, value: number): void;
  32046. /**
  32047. * Specifically change the body's mass option. Won't recreate the physics body object
  32048. * @param mass The mass of the physics imposter
  32049. */
  32050. setMass(mass: number): void;
  32051. /**
  32052. * Gets the linear velocity
  32053. * @returns linear velocity or null
  32054. */
  32055. getLinearVelocity(): Nullable<Vector3>;
  32056. /**
  32057. * Sets the linear velocity
  32058. * @param velocity linear velocity or null
  32059. */
  32060. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32061. /**
  32062. * Gets the angular velocity
  32063. * @returns angular velocity or null
  32064. */
  32065. getAngularVelocity(): Nullable<Vector3>;
  32066. /**
  32067. * Sets the angular velocity
  32068. * @param velocity The velocity or null
  32069. */
  32070. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32071. /**
  32072. * Execute a function with the physics plugin native code
  32073. * Provide a function the will have two variables - the world object and the physics body object
  32074. * @param func The function to execute with the physics plugin native code
  32075. */
  32076. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32077. /**
  32078. * Register a function that will be executed before the physics world is stepping forward
  32079. * @param func The function to execute before the physics world is stepped forward
  32080. */
  32081. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32082. /**
  32083. * Unregister a function that will be executed before the physics world is stepping forward
  32084. * @param func The function to execute before the physics world is stepped forward
  32085. */
  32086. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32087. /**
  32088. * Register a function that will be executed after the physics step
  32089. * @param func The function to execute after physics step
  32090. */
  32091. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32092. /**
  32093. * Unregisters a function that will be executed after the physics step
  32094. * @param func The function to execute after physics step
  32095. */
  32096. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32097. /**
  32098. * register a function that will be executed when this impostor collides against a different body
  32099. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32100. * @param func Callback that is executed on collision
  32101. */
  32102. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32103. /**
  32104. * Unregisters the physics imposter on contact
  32105. * @param collideAgainst The physics object to collide against
  32106. * @param func Callback to execute on collision
  32107. */
  32108. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32109. private _tmpQuat;
  32110. private _tmpQuat2;
  32111. /**
  32112. * Get the parent rotation
  32113. * @returns The parent rotation
  32114. */
  32115. getParentsRotation(): Quaternion;
  32116. /**
  32117. * this function is executed by the physics engine.
  32118. */
  32119. beforeStep: () => void;
  32120. /**
  32121. * this function is executed by the physics engine
  32122. */
  32123. afterStep: () => void;
  32124. /**
  32125. * Legacy collision detection event support
  32126. */
  32127. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32128. /**
  32129. * event and body object due to cannon's event-based architecture.
  32130. */
  32131. onCollide: (e: {
  32132. body: any;
  32133. }) => void;
  32134. /**
  32135. * Apply a force
  32136. * @param force The force to apply
  32137. * @param contactPoint The contact point for the force
  32138. * @returns The physics imposter
  32139. */
  32140. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32141. /**
  32142. * Apply an impulse
  32143. * @param force The impulse force
  32144. * @param contactPoint The contact point for the impulse force
  32145. * @returns The physics imposter
  32146. */
  32147. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32148. /**
  32149. * A help function to create a joint
  32150. * @param otherImpostor A physics imposter used to create a joint
  32151. * @param jointType The type of joint
  32152. * @param jointData The data for the joint
  32153. * @returns The physics imposter
  32154. */
  32155. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32156. /**
  32157. * Add a joint to this impostor with a different impostor
  32158. * @param otherImpostor A physics imposter used to add a joint
  32159. * @param joint The joint to add
  32160. * @returns The physics imposter
  32161. */
  32162. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32163. /**
  32164. * Add an anchor to a cloth impostor
  32165. * @param otherImpostor rigid impostor to anchor to
  32166. * @param width ratio across width from 0 to 1
  32167. * @param height ratio up height from 0 to 1
  32168. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32169. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32170. * @returns impostor the soft imposter
  32171. */
  32172. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32173. /**
  32174. * Add a hook to a rope impostor
  32175. * @param otherImpostor rigid impostor to anchor to
  32176. * @param length ratio across rope from 0 to 1
  32177. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32178. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32179. * @returns impostor the rope imposter
  32180. */
  32181. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32182. /**
  32183. * Will keep this body still, in a sleep mode.
  32184. * @returns the physics imposter
  32185. */
  32186. sleep(): PhysicsImpostor;
  32187. /**
  32188. * Wake the body up.
  32189. * @returns The physics imposter
  32190. */
  32191. wakeUp(): PhysicsImpostor;
  32192. /**
  32193. * Clones the physics imposter
  32194. * @param newObject The physics imposter clones to this physics-enabled object
  32195. * @returns A nullable physics imposter
  32196. */
  32197. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32198. /**
  32199. * Disposes the physics imposter
  32200. */
  32201. dispose(): void;
  32202. /**
  32203. * Sets the delta position
  32204. * @param position The delta position amount
  32205. */
  32206. setDeltaPosition(position: Vector3): void;
  32207. /**
  32208. * Sets the delta rotation
  32209. * @param rotation The delta rotation amount
  32210. */
  32211. setDeltaRotation(rotation: Quaternion): void;
  32212. /**
  32213. * Gets the box size of the physics imposter and stores the result in the input parameter
  32214. * @param result Stores the box size
  32215. * @returns The physics imposter
  32216. */
  32217. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32218. /**
  32219. * Gets the radius of the physics imposter
  32220. * @returns Radius of the physics imposter
  32221. */
  32222. getRadius(): number;
  32223. /**
  32224. * Sync a bone with this impostor
  32225. * @param bone The bone to sync to the impostor.
  32226. * @param boneMesh The mesh that the bone is influencing.
  32227. * @param jointPivot The pivot of the joint / bone in local space.
  32228. * @param distToJoint Optional distance from the impostor to the joint.
  32229. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32230. */
  32231. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32232. /**
  32233. * Sync impostor to a bone
  32234. * @param bone The bone that the impostor will be synced to.
  32235. * @param boneMesh The mesh that the bone is influencing.
  32236. * @param jointPivot The pivot of the joint / bone in local space.
  32237. * @param distToJoint Optional distance from the impostor to the joint.
  32238. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32239. * @param boneAxis Optional vector3 axis the bone is aligned with
  32240. */
  32241. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32242. /**
  32243. * No-Imposter type
  32244. */
  32245. static NoImpostor: number;
  32246. /**
  32247. * Sphere-Imposter type
  32248. */
  32249. static SphereImpostor: number;
  32250. /**
  32251. * Box-Imposter type
  32252. */
  32253. static BoxImpostor: number;
  32254. /**
  32255. * Plane-Imposter type
  32256. */
  32257. static PlaneImpostor: number;
  32258. /**
  32259. * Mesh-imposter type
  32260. */
  32261. static MeshImpostor: number;
  32262. /**
  32263. * Capsule-Impostor type (Ammo.js plugin only)
  32264. */
  32265. static CapsuleImpostor: number;
  32266. /**
  32267. * Cylinder-Imposter type
  32268. */
  32269. static CylinderImpostor: number;
  32270. /**
  32271. * Particle-Imposter type
  32272. */
  32273. static ParticleImpostor: number;
  32274. /**
  32275. * Heightmap-Imposter type
  32276. */
  32277. static HeightmapImpostor: number;
  32278. /**
  32279. * ConvexHull-Impostor type (Ammo.js plugin only)
  32280. */
  32281. static ConvexHullImpostor: number;
  32282. /**
  32283. * Custom-Imposter type (Ammo.js plugin only)
  32284. */
  32285. static CustomImpostor: number;
  32286. /**
  32287. * Rope-Imposter type
  32288. */
  32289. static RopeImpostor: number;
  32290. /**
  32291. * Cloth-Imposter type
  32292. */
  32293. static ClothImpostor: number;
  32294. /**
  32295. * Softbody-Imposter type
  32296. */
  32297. static SoftbodyImpostor: number;
  32298. }
  32299. }
  32300. declare module BABYLON {
  32301. /**
  32302. * @hidden
  32303. **/
  32304. export class _CreationDataStorage {
  32305. closePath?: boolean;
  32306. closeArray?: boolean;
  32307. idx: number[];
  32308. dashSize: number;
  32309. gapSize: number;
  32310. path3D: Path3D;
  32311. pathArray: Vector3[][];
  32312. arc: number;
  32313. radius: number;
  32314. cap: number;
  32315. tessellation: number;
  32316. }
  32317. /**
  32318. * @hidden
  32319. **/
  32320. class _InstanceDataStorage {
  32321. visibleInstances: any;
  32322. batchCache: _InstancesBatch;
  32323. instancesBufferSize: number;
  32324. instancesBuffer: Nullable<Buffer>;
  32325. instancesData: Float32Array;
  32326. overridenInstanceCount: number;
  32327. isFrozen: boolean;
  32328. previousBatch: Nullable<_InstancesBatch>;
  32329. hardwareInstancedRendering: boolean;
  32330. sideOrientation: number;
  32331. manualUpdate: boolean;
  32332. previousRenderId: number;
  32333. }
  32334. /**
  32335. * @hidden
  32336. **/
  32337. export class _InstancesBatch {
  32338. mustReturn: boolean;
  32339. visibleInstances: Nullable<InstancedMesh[]>[];
  32340. renderSelf: boolean[];
  32341. hardwareInstancedRendering: boolean[];
  32342. }
  32343. /**
  32344. * @hidden
  32345. **/
  32346. class _ThinInstanceDataStorage {
  32347. instancesCount: number;
  32348. matrixBuffer: Nullable<Buffer>;
  32349. matrixBufferSize: number;
  32350. matrixData: Nullable<Float32Array>;
  32351. boundingVectors: Array<Vector3>;
  32352. worldMatrices: Nullable<Matrix[]>;
  32353. }
  32354. /**
  32355. * Class used to represent renderable models
  32356. */
  32357. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32358. /**
  32359. * Mesh side orientation : usually the external or front surface
  32360. */
  32361. static readonly FRONTSIDE: number;
  32362. /**
  32363. * Mesh side orientation : usually the internal or back surface
  32364. */
  32365. static readonly BACKSIDE: number;
  32366. /**
  32367. * Mesh side orientation : both internal and external or front and back surfaces
  32368. */
  32369. static readonly DOUBLESIDE: number;
  32370. /**
  32371. * Mesh side orientation : by default, `FRONTSIDE`
  32372. */
  32373. static readonly DEFAULTSIDE: number;
  32374. /**
  32375. * Mesh cap setting : no cap
  32376. */
  32377. static readonly NO_CAP: number;
  32378. /**
  32379. * Mesh cap setting : one cap at the beginning of the mesh
  32380. */
  32381. static readonly CAP_START: number;
  32382. /**
  32383. * Mesh cap setting : one cap at the end of the mesh
  32384. */
  32385. static readonly CAP_END: number;
  32386. /**
  32387. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32388. */
  32389. static readonly CAP_ALL: number;
  32390. /**
  32391. * Mesh pattern setting : no flip or rotate
  32392. */
  32393. static readonly NO_FLIP: number;
  32394. /**
  32395. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32396. */
  32397. static readonly FLIP_TILE: number;
  32398. /**
  32399. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32400. */
  32401. static readonly ROTATE_TILE: number;
  32402. /**
  32403. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32404. */
  32405. static readonly FLIP_ROW: number;
  32406. /**
  32407. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32408. */
  32409. static readonly ROTATE_ROW: number;
  32410. /**
  32411. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32412. */
  32413. static readonly FLIP_N_ROTATE_TILE: number;
  32414. /**
  32415. * Mesh pattern setting : rotate pattern and rotate
  32416. */
  32417. static readonly FLIP_N_ROTATE_ROW: number;
  32418. /**
  32419. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32420. */
  32421. static readonly CENTER: number;
  32422. /**
  32423. * Mesh tile positioning : part tiles on left
  32424. */
  32425. static readonly LEFT: number;
  32426. /**
  32427. * Mesh tile positioning : part tiles on right
  32428. */
  32429. static readonly RIGHT: number;
  32430. /**
  32431. * Mesh tile positioning : part tiles on top
  32432. */
  32433. static readonly TOP: number;
  32434. /**
  32435. * Mesh tile positioning : part tiles on bottom
  32436. */
  32437. static readonly BOTTOM: number;
  32438. /**
  32439. * Gets the default side orientation.
  32440. * @param orientation the orientation to value to attempt to get
  32441. * @returns the default orientation
  32442. * @hidden
  32443. */
  32444. static _GetDefaultSideOrientation(orientation?: number): number;
  32445. private _internalMeshDataInfo;
  32446. get computeBonesUsingShaders(): boolean;
  32447. set computeBonesUsingShaders(value: boolean);
  32448. /**
  32449. * An event triggered before rendering the mesh
  32450. */
  32451. get onBeforeRenderObservable(): Observable<Mesh>;
  32452. /**
  32453. * An event triggered before binding the mesh
  32454. */
  32455. get onBeforeBindObservable(): Observable<Mesh>;
  32456. /**
  32457. * An event triggered after rendering the mesh
  32458. */
  32459. get onAfterRenderObservable(): Observable<Mesh>;
  32460. /**
  32461. * An event triggered before drawing the mesh
  32462. */
  32463. get onBeforeDrawObservable(): Observable<Mesh>;
  32464. private _onBeforeDrawObserver;
  32465. /**
  32466. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32467. */
  32468. set onBeforeDraw(callback: () => void);
  32469. get hasInstances(): boolean;
  32470. get hasThinInstances(): boolean;
  32471. /**
  32472. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32473. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32474. */
  32475. delayLoadState: number;
  32476. /**
  32477. * Gets the list of instances created from this mesh
  32478. * it is not supposed to be modified manually.
  32479. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32480. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32481. */
  32482. instances: InstancedMesh[];
  32483. /**
  32484. * Gets the file containing delay loading data for this mesh
  32485. */
  32486. delayLoadingFile: string;
  32487. /** @hidden */
  32488. _binaryInfo: any;
  32489. /**
  32490. * User defined function used to change how LOD level selection is done
  32491. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32492. */
  32493. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32494. /**
  32495. * Gets or sets the morph target manager
  32496. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32497. */
  32498. get morphTargetManager(): Nullable<MorphTargetManager>;
  32499. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32500. /** @hidden */
  32501. _creationDataStorage: Nullable<_CreationDataStorage>;
  32502. /** @hidden */
  32503. _geometry: Nullable<Geometry>;
  32504. /** @hidden */
  32505. _delayInfo: Array<string>;
  32506. /** @hidden */
  32507. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32508. /** @hidden */
  32509. _instanceDataStorage: _InstanceDataStorage;
  32510. /** @hidden */
  32511. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32512. private _effectiveMaterial;
  32513. /** @hidden */
  32514. _shouldGenerateFlatShading: boolean;
  32515. /** @hidden */
  32516. _originalBuilderSideOrientation: number;
  32517. /**
  32518. * Use this property to change the original side orientation defined at construction time
  32519. */
  32520. overrideMaterialSideOrientation: Nullable<number>;
  32521. /**
  32522. * Gets the source mesh (the one used to clone this one from)
  32523. */
  32524. get source(): Nullable<Mesh>;
  32525. /**
  32526. * Gets the list of clones of this mesh
  32527. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32528. * Note that useClonedMeshMap=true is the default setting
  32529. */
  32530. get cloneMeshMap(): Nullable<{
  32531. [id: string]: Mesh | undefined;
  32532. }>;
  32533. /**
  32534. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32535. */
  32536. get isUnIndexed(): boolean;
  32537. set isUnIndexed(value: boolean);
  32538. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32539. get worldMatrixInstancedBuffer(): Float32Array;
  32540. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32541. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32542. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32543. /**
  32544. * @constructor
  32545. * @param name The value used by scene.getMeshByName() to do a lookup.
  32546. * @param scene The scene to add this mesh to.
  32547. * @param parent The parent of this mesh, if it has one
  32548. * @param source An optional Mesh from which geometry is shared, cloned.
  32549. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32550. * When false, achieved by calling a clone(), also passing False.
  32551. * This will make creation of children, recursive.
  32552. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32553. */
  32554. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32555. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32556. doNotInstantiate: boolean;
  32557. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32558. /**
  32559. * Gets the class name
  32560. * @returns the string "Mesh".
  32561. */
  32562. getClassName(): string;
  32563. /** @hidden */
  32564. get _isMesh(): boolean;
  32565. /**
  32566. * Returns a description of this mesh
  32567. * @param fullDetails define if full details about this mesh must be used
  32568. * @returns a descriptive string representing this mesh
  32569. */
  32570. toString(fullDetails?: boolean): string;
  32571. /** @hidden */
  32572. _unBindEffect(): void;
  32573. /**
  32574. * Gets a boolean indicating if this mesh has LOD
  32575. */
  32576. get hasLODLevels(): boolean;
  32577. /**
  32578. * Gets the list of MeshLODLevel associated with the current mesh
  32579. * @returns an array of MeshLODLevel
  32580. */
  32581. getLODLevels(): MeshLODLevel[];
  32582. private _sortLODLevels;
  32583. /**
  32584. * Add a mesh as LOD level triggered at the given distance.
  32585. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32586. * @param distance The distance from the center of the object to show this level
  32587. * @param mesh The mesh to be added as LOD level (can be null)
  32588. * @return This mesh (for chaining)
  32589. */
  32590. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32591. /**
  32592. * Returns the LOD level mesh at the passed distance or null if not found.
  32593. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32594. * @param distance The distance from the center of the object to show this level
  32595. * @returns a Mesh or `null`
  32596. */
  32597. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32598. /**
  32599. * Remove a mesh from the LOD array
  32600. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32601. * @param mesh defines the mesh to be removed
  32602. * @return This mesh (for chaining)
  32603. */
  32604. removeLODLevel(mesh: Mesh): Mesh;
  32605. /**
  32606. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32607. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32608. * @param camera defines the camera to use to compute distance
  32609. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32610. * @return This mesh (for chaining)
  32611. */
  32612. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32613. /**
  32614. * Gets the mesh internal Geometry object
  32615. */
  32616. get geometry(): Nullable<Geometry>;
  32617. /**
  32618. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32619. * @returns the total number of vertices
  32620. */
  32621. getTotalVertices(): number;
  32622. /**
  32623. * Returns the content of an associated vertex buffer
  32624. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32625. * - VertexBuffer.PositionKind
  32626. * - VertexBuffer.UVKind
  32627. * - VertexBuffer.UV2Kind
  32628. * - VertexBuffer.UV3Kind
  32629. * - VertexBuffer.UV4Kind
  32630. * - VertexBuffer.UV5Kind
  32631. * - VertexBuffer.UV6Kind
  32632. * - VertexBuffer.ColorKind
  32633. * - VertexBuffer.MatricesIndicesKind
  32634. * - VertexBuffer.MatricesIndicesExtraKind
  32635. * - VertexBuffer.MatricesWeightsKind
  32636. * - VertexBuffer.MatricesWeightsExtraKind
  32637. * @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
  32638. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32639. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32640. */
  32641. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32642. /**
  32643. * Returns the mesh VertexBuffer object from the requested `kind`
  32644. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32645. * - VertexBuffer.PositionKind
  32646. * - VertexBuffer.NormalKind
  32647. * - VertexBuffer.UVKind
  32648. * - VertexBuffer.UV2Kind
  32649. * - VertexBuffer.UV3Kind
  32650. * - VertexBuffer.UV4Kind
  32651. * - VertexBuffer.UV5Kind
  32652. * - VertexBuffer.UV6Kind
  32653. * - VertexBuffer.ColorKind
  32654. * - VertexBuffer.MatricesIndicesKind
  32655. * - VertexBuffer.MatricesIndicesExtraKind
  32656. * - VertexBuffer.MatricesWeightsKind
  32657. * - VertexBuffer.MatricesWeightsExtraKind
  32658. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32659. */
  32660. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32661. /**
  32662. * Tests if a specific vertex buffer is associated with this mesh
  32663. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32664. * - VertexBuffer.PositionKind
  32665. * - VertexBuffer.NormalKind
  32666. * - VertexBuffer.UVKind
  32667. * - VertexBuffer.UV2Kind
  32668. * - VertexBuffer.UV3Kind
  32669. * - VertexBuffer.UV4Kind
  32670. * - VertexBuffer.UV5Kind
  32671. * - VertexBuffer.UV6Kind
  32672. * - VertexBuffer.ColorKind
  32673. * - VertexBuffer.MatricesIndicesKind
  32674. * - VertexBuffer.MatricesIndicesExtraKind
  32675. * - VertexBuffer.MatricesWeightsKind
  32676. * - VertexBuffer.MatricesWeightsExtraKind
  32677. * @returns a boolean
  32678. */
  32679. isVerticesDataPresent(kind: string): boolean;
  32680. /**
  32681. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32682. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32683. * - VertexBuffer.PositionKind
  32684. * - VertexBuffer.UVKind
  32685. * - VertexBuffer.UV2Kind
  32686. * - VertexBuffer.UV3Kind
  32687. * - VertexBuffer.UV4Kind
  32688. * - VertexBuffer.UV5Kind
  32689. * - VertexBuffer.UV6Kind
  32690. * - VertexBuffer.ColorKind
  32691. * - VertexBuffer.MatricesIndicesKind
  32692. * - VertexBuffer.MatricesIndicesExtraKind
  32693. * - VertexBuffer.MatricesWeightsKind
  32694. * - VertexBuffer.MatricesWeightsExtraKind
  32695. * @returns a boolean
  32696. */
  32697. isVertexBufferUpdatable(kind: string): boolean;
  32698. /**
  32699. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32700. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32701. * - VertexBuffer.PositionKind
  32702. * - VertexBuffer.NormalKind
  32703. * - VertexBuffer.UVKind
  32704. * - VertexBuffer.UV2Kind
  32705. * - VertexBuffer.UV3Kind
  32706. * - VertexBuffer.UV4Kind
  32707. * - VertexBuffer.UV5Kind
  32708. * - VertexBuffer.UV6Kind
  32709. * - VertexBuffer.ColorKind
  32710. * - VertexBuffer.MatricesIndicesKind
  32711. * - VertexBuffer.MatricesIndicesExtraKind
  32712. * - VertexBuffer.MatricesWeightsKind
  32713. * - VertexBuffer.MatricesWeightsExtraKind
  32714. * @returns an array of strings
  32715. */
  32716. getVerticesDataKinds(): string[];
  32717. /**
  32718. * Returns a positive integer : the total number of indices in this mesh geometry.
  32719. * @returns the numner of indices or zero if the mesh has no geometry.
  32720. */
  32721. getTotalIndices(): number;
  32722. /**
  32723. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32724. * @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.
  32725. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32726. * @returns the indices array or an empty array if the mesh has no geometry
  32727. */
  32728. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32729. get isBlocked(): boolean;
  32730. /**
  32731. * Determine if the current mesh is ready to be rendered
  32732. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32733. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32734. * @returns true if all associated assets are ready (material, textures, shaders)
  32735. */
  32736. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32737. /**
  32738. * 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.
  32739. */
  32740. get areNormalsFrozen(): boolean;
  32741. /**
  32742. * 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.
  32743. * @returns the current mesh
  32744. */
  32745. freezeNormals(): Mesh;
  32746. /**
  32747. * 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
  32748. * @returns the current mesh
  32749. */
  32750. unfreezeNormals(): Mesh;
  32751. /**
  32752. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32753. */
  32754. set overridenInstanceCount(count: number);
  32755. /** @hidden */
  32756. _preActivate(): Mesh;
  32757. /** @hidden */
  32758. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32759. /** @hidden */
  32760. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32761. protected _afterComputeWorldMatrix(): void;
  32762. /** @hidden */
  32763. _postActivate(): void;
  32764. /**
  32765. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32766. * This means the mesh underlying bounding box and sphere are recomputed.
  32767. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32768. * @returns the current mesh
  32769. */
  32770. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32771. /** @hidden */
  32772. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32773. /**
  32774. * This function will subdivide the mesh into multiple submeshes
  32775. * @param count defines the expected number of submeshes
  32776. */
  32777. subdivide(count: number): void;
  32778. /**
  32779. * Copy a FloatArray into a specific associated vertex buffer
  32780. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32781. * - VertexBuffer.PositionKind
  32782. * - VertexBuffer.UVKind
  32783. * - VertexBuffer.UV2Kind
  32784. * - VertexBuffer.UV3Kind
  32785. * - VertexBuffer.UV4Kind
  32786. * - VertexBuffer.UV5Kind
  32787. * - VertexBuffer.UV6Kind
  32788. * - VertexBuffer.ColorKind
  32789. * - VertexBuffer.MatricesIndicesKind
  32790. * - VertexBuffer.MatricesIndicesExtraKind
  32791. * - VertexBuffer.MatricesWeightsKind
  32792. * - VertexBuffer.MatricesWeightsExtraKind
  32793. * @param data defines the data source
  32794. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32795. * @param stride defines the data stride size (can be null)
  32796. * @returns the current mesh
  32797. */
  32798. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32799. /**
  32800. * Delete a vertex buffer associated with this mesh
  32801. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32802. * - VertexBuffer.PositionKind
  32803. * - VertexBuffer.UVKind
  32804. * - VertexBuffer.UV2Kind
  32805. * - VertexBuffer.UV3Kind
  32806. * - VertexBuffer.UV4Kind
  32807. * - VertexBuffer.UV5Kind
  32808. * - VertexBuffer.UV6Kind
  32809. * - VertexBuffer.ColorKind
  32810. * - VertexBuffer.MatricesIndicesKind
  32811. * - VertexBuffer.MatricesIndicesExtraKind
  32812. * - VertexBuffer.MatricesWeightsKind
  32813. * - VertexBuffer.MatricesWeightsExtraKind
  32814. */
  32815. removeVerticesData(kind: string): void;
  32816. /**
  32817. * Flags an associated vertex buffer as updatable
  32818. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32819. * - VertexBuffer.PositionKind
  32820. * - VertexBuffer.UVKind
  32821. * - VertexBuffer.UV2Kind
  32822. * - VertexBuffer.UV3Kind
  32823. * - VertexBuffer.UV4Kind
  32824. * - VertexBuffer.UV5Kind
  32825. * - VertexBuffer.UV6Kind
  32826. * - VertexBuffer.ColorKind
  32827. * - VertexBuffer.MatricesIndicesKind
  32828. * - VertexBuffer.MatricesIndicesExtraKind
  32829. * - VertexBuffer.MatricesWeightsKind
  32830. * - VertexBuffer.MatricesWeightsExtraKind
  32831. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32832. */
  32833. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32834. /**
  32835. * Sets the mesh global Vertex Buffer
  32836. * @param buffer defines the buffer to use
  32837. * @returns the current mesh
  32838. */
  32839. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32840. /**
  32841. * Update a specific associated vertex buffer
  32842. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32843. * - VertexBuffer.PositionKind
  32844. * - VertexBuffer.UVKind
  32845. * - VertexBuffer.UV2Kind
  32846. * - VertexBuffer.UV3Kind
  32847. * - VertexBuffer.UV4Kind
  32848. * - VertexBuffer.UV5Kind
  32849. * - VertexBuffer.UV6Kind
  32850. * - VertexBuffer.ColorKind
  32851. * - VertexBuffer.MatricesIndicesKind
  32852. * - VertexBuffer.MatricesIndicesExtraKind
  32853. * - VertexBuffer.MatricesWeightsKind
  32854. * - VertexBuffer.MatricesWeightsExtraKind
  32855. * @param data defines the data source
  32856. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32857. * @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)
  32858. * @returns the current mesh
  32859. */
  32860. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32861. /**
  32862. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32863. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32864. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32865. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32866. * @returns the current mesh
  32867. */
  32868. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32869. /**
  32870. * Creates a un-shared specific occurence of the geometry for the mesh.
  32871. * @returns the current mesh
  32872. */
  32873. makeGeometryUnique(): Mesh;
  32874. /**
  32875. * Set the index buffer of this mesh
  32876. * @param indices defines the source data
  32877. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32878. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32879. * @returns the current mesh
  32880. */
  32881. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32882. /**
  32883. * Update the current index buffer
  32884. * @param indices defines the source data
  32885. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32886. * @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)
  32887. * @returns the current mesh
  32888. */
  32889. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32890. /**
  32891. * Invert the geometry to move from a right handed system to a left handed one.
  32892. * @returns the current mesh
  32893. */
  32894. toLeftHanded(): Mesh;
  32895. /** @hidden */
  32896. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32897. /** @hidden */
  32898. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32899. /**
  32900. * Registers for this mesh a javascript function called just before the rendering process
  32901. * @param func defines the function to call before rendering this mesh
  32902. * @returns the current mesh
  32903. */
  32904. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32905. /**
  32906. * Disposes a previously registered javascript function called before the rendering
  32907. * @param func defines the function to remove
  32908. * @returns the current mesh
  32909. */
  32910. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32911. /**
  32912. * Registers for this mesh a javascript function called just after the rendering is complete
  32913. * @param func defines the function to call after rendering this mesh
  32914. * @returns the current mesh
  32915. */
  32916. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32917. /**
  32918. * Disposes a previously registered javascript function called after the rendering.
  32919. * @param func defines the function to remove
  32920. * @returns the current mesh
  32921. */
  32922. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32923. /** @hidden */
  32924. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32925. /** @hidden */
  32926. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32927. /** @hidden */
  32928. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32929. /** @hidden */
  32930. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32931. /** @hidden */
  32932. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32933. /** @hidden */
  32934. _rebuild(): void;
  32935. /** @hidden */
  32936. _freeze(): void;
  32937. /** @hidden */
  32938. _unFreeze(): void;
  32939. /**
  32940. * 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
  32941. * @param subMesh defines the subMesh to render
  32942. * @param enableAlphaMode defines if alpha mode can be changed
  32943. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32944. * @returns the current mesh
  32945. */
  32946. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32947. private _onBeforeDraw;
  32948. /**
  32949. * Renormalize the mesh and patch it up if there are no weights
  32950. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32951. * However in the case of zero weights then we set just a single influence to 1.
  32952. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32953. */
  32954. cleanMatrixWeights(): void;
  32955. private normalizeSkinFourWeights;
  32956. private normalizeSkinWeightsAndExtra;
  32957. /**
  32958. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32959. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32960. * the user know there was an issue with importing the mesh
  32961. * @returns a validation object with skinned, valid and report string
  32962. */
  32963. validateSkinning(): {
  32964. skinned: boolean;
  32965. valid: boolean;
  32966. report: string;
  32967. };
  32968. /** @hidden */
  32969. _checkDelayState(): Mesh;
  32970. private _queueLoad;
  32971. /**
  32972. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32973. * A mesh is in the frustum if its bounding box intersects the frustum
  32974. * @param frustumPlanes defines the frustum to test
  32975. * @returns true if the mesh is in the frustum planes
  32976. */
  32977. isInFrustum(frustumPlanes: Plane[]): boolean;
  32978. /**
  32979. * Sets the mesh material by the material or multiMaterial `id` property
  32980. * @param id is a string identifying the material or the multiMaterial
  32981. * @returns the current mesh
  32982. */
  32983. setMaterialByID(id: string): Mesh;
  32984. /**
  32985. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32986. * @returns an array of IAnimatable
  32987. */
  32988. getAnimatables(): IAnimatable[];
  32989. /**
  32990. * Modifies the mesh geometry according to the passed transformation matrix.
  32991. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  32992. * The mesh normals are modified using the same transformation.
  32993. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32994. * @param transform defines the transform matrix to use
  32995. * @see https://doc.babylonjs.com/resources/baking_transformations
  32996. * @returns the current mesh
  32997. */
  32998. bakeTransformIntoVertices(transform: Matrix): Mesh;
  32999. /**
  33000. * Modifies the mesh geometry according to its own current World Matrix.
  33001. * The mesh World Matrix is then reset.
  33002. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33003. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33004. * @see https://doc.babylonjs.com/resources/baking_transformations
  33005. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33006. * @returns the current mesh
  33007. */
  33008. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33009. /** @hidden */
  33010. get _positions(): Nullable<Vector3[]>;
  33011. /** @hidden */
  33012. _resetPointsArrayCache(): Mesh;
  33013. /** @hidden */
  33014. _generatePointsArray(): boolean;
  33015. /**
  33016. * Returns a new Mesh object generated from the current mesh properties.
  33017. * This method must not get confused with createInstance()
  33018. * @param name is a string, the name given to the new mesh
  33019. * @param newParent can be any Node object (default `null`)
  33020. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33021. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33022. * @returns a new mesh
  33023. */
  33024. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33025. /**
  33026. * Releases resources associated with this mesh.
  33027. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33028. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33029. */
  33030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33031. /** @hidden */
  33032. _disposeInstanceSpecificData(): void;
  33033. /** @hidden */
  33034. _disposeThinInstanceSpecificData(): void;
  33035. /**
  33036. * Modifies the mesh geometry according to a displacement map.
  33037. * 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.
  33038. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33039. * @param url is a string, the URL from the image file is to be downloaded.
  33040. * @param minHeight is the lower limit of the displacement.
  33041. * @param maxHeight is the upper limit of the displacement.
  33042. * @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.
  33043. * @param uvOffset is an optional vector2 used to offset UV.
  33044. * @param uvScale is an optional vector2 used to scale UV.
  33045. * @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.
  33046. * @returns the Mesh.
  33047. */
  33048. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33049. /**
  33050. * Modifies the mesh geometry according to a displacementMap buffer.
  33051. * 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.
  33052. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33053. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33054. * @param heightMapWidth is the width of the buffer image.
  33055. * @param heightMapHeight is the height of the buffer image.
  33056. * @param minHeight is the lower limit of the displacement.
  33057. * @param maxHeight is the upper limit of the displacement.
  33058. * @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.
  33059. * @param uvOffset is an optional vector2 used to offset UV.
  33060. * @param uvScale is an optional vector2 used to scale UV.
  33061. * @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.
  33062. * @returns the Mesh.
  33063. */
  33064. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33065. /**
  33066. * Modify the mesh to get a flat shading rendering.
  33067. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33068. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33069. * @returns current mesh
  33070. */
  33071. convertToFlatShadedMesh(): Mesh;
  33072. /**
  33073. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33074. * In other words, more vertices, no more indices and a single bigger VBO.
  33075. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33076. * @returns current mesh
  33077. */
  33078. convertToUnIndexedMesh(): Mesh;
  33079. /**
  33080. * Inverses facet orientations.
  33081. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33082. * @param flipNormals will also inverts the normals
  33083. * @returns current mesh
  33084. */
  33085. flipFaces(flipNormals?: boolean): Mesh;
  33086. /**
  33087. * Increase the number of facets and hence vertices in a mesh
  33088. * Vertex normals are interpolated from existing vertex normals
  33089. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33090. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33091. */
  33092. increaseVertices(numberPerEdge: number): void;
  33093. /**
  33094. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33095. * This will undo any application of covertToFlatShadedMesh
  33096. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33097. */
  33098. forceSharedVertices(): void;
  33099. /** @hidden */
  33100. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33101. /** @hidden */
  33102. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33103. /**
  33104. * Creates a new InstancedMesh object from the mesh model.
  33105. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33106. * @param name defines the name of the new instance
  33107. * @returns a new InstancedMesh
  33108. */
  33109. createInstance(name: string): InstancedMesh;
  33110. /**
  33111. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33112. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33113. * @returns the current mesh
  33114. */
  33115. synchronizeInstances(): Mesh;
  33116. /**
  33117. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33118. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33119. * This should be used together with the simplification to avoid disappearing triangles.
  33120. * @param successCallback an optional success callback to be called after the optimization finished.
  33121. * @returns the current mesh
  33122. */
  33123. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33124. /**
  33125. * Serialize current mesh
  33126. * @param serializationObject defines the object which will receive the serialization data
  33127. */
  33128. serialize(serializationObject: any): void;
  33129. /** @hidden */
  33130. _syncGeometryWithMorphTargetManager(): void;
  33131. /** @hidden */
  33132. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33133. /**
  33134. * Returns a new Mesh object parsed from the source provided.
  33135. * @param parsedMesh is the source
  33136. * @param scene defines the hosting scene
  33137. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33138. * @returns a new Mesh
  33139. */
  33140. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33141. /**
  33142. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33143. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33144. * @param name defines the name of the mesh to create
  33145. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33146. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33147. * @param closePath creates a seam between the first and the last points of each path of the path array
  33148. * @param offset is taken in account only if the `pathArray` is containing a single path
  33149. * @param scene defines the hosting scene
  33150. * @param updatable defines if the mesh must be flagged as updatable
  33151. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33152. * @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)
  33153. * @returns a new Mesh
  33154. */
  33155. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33156. /**
  33157. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33158. * @param name defines the name of the mesh to create
  33159. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33160. * @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
  33161. * @param scene defines the hosting scene
  33162. * @param updatable defines if the mesh must be flagged as updatable
  33163. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33164. * @returns a new Mesh
  33165. */
  33166. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33167. /**
  33168. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33169. * @param name defines the name of the mesh to create
  33170. * @param size sets the size (float) of each box side (default 1)
  33171. * @param scene defines the hosting scene
  33172. * @param updatable defines if the mesh must be flagged as updatable
  33173. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33174. * @returns a new Mesh
  33175. */
  33176. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33177. /**
  33178. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33179. * @param name defines the name of the mesh to create
  33180. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33181. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33182. * @param scene defines the hosting scene
  33183. * @param updatable defines if the mesh must be flagged as updatable
  33184. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33185. * @returns a new Mesh
  33186. */
  33187. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33188. /**
  33189. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33190. * @param name defines the name of the mesh to create
  33191. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33192. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33193. * @param scene defines the hosting scene
  33194. * @returns a new Mesh
  33195. */
  33196. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33197. /**
  33198. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33199. * @param name defines the name of the mesh to create
  33200. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33201. * @param diameterTop set the top cap diameter (floats, default 1)
  33202. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33203. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33204. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33205. * @param scene defines the hosting scene
  33206. * @param updatable defines if the mesh must be flagged as updatable
  33207. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33208. * @returns a new Mesh
  33209. */
  33210. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33211. /**
  33212. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33213. * @param name defines the name of the mesh to create
  33214. * @param diameter sets the diameter size (float) of the torus (default 1)
  33215. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33216. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33217. * @param scene defines the hosting scene
  33218. * @param updatable defines if the mesh must be flagged as updatable
  33219. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33220. * @returns a new Mesh
  33221. */
  33222. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33223. /**
  33224. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33225. * @param name defines the name of the mesh to create
  33226. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33227. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33228. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33229. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33230. * @param p the number of windings on X axis (positive integers, default 2)
  33231. * @param q the number of windings on Y axis (positive integers, default 3)
  33232. * @param scene defines the hosting scene
  33233. * @param updatable defines if the mesh must be flagged as updatable
  33234. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33235. * @returns a new Mesh
  33236. */
  33237. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33238. /**
  33239. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33240. * @param name defines the name of the mesh to create
  33241. * @param points is an array successive Vector3
  33242. * @param scene defines the hosting scene
  33243. * @param updatable defines if the mesh must be flagged as updatable
  33244. * @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).
  33245. * @returns a new Mesh
  33246. */
  33247. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33248. /**
  33249. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33250. * @param name defines the name of the mesh to create
  33251. * @param points is an array successive Vector3
  33252. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33253. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33254. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33255. * @param scene defines the hosting scene
  33256. * @param updatable defines if the mesh must be flagged as updatable
  33257. * @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)
  33258. * @returns a new Mesh
  33259. */
  33260. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33261. /**
  33262. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33263. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33264. * 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.
  33265. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33266. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33267. * Remember you can only change the shape positions, not their number when updating a polygon.
  33268. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33269. * @param name defines the name of the mesh to create
  33270. * @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
  33271. * @param scene defines the hosting scene
  33272. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33273. * @param updatable defines if the mesh must be flagged as updatable
  33274. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33275. * @param earcutInjection can be used to inject your own earcut reference
  33276. * @returns a new Mesh
  33277. */
  33278. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33279. /**
  33280. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33281. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33282. * @param name defines the name of the mesh to create
  33283. * @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
  33284. * @param depth defines the height of extrusion
  33285. * @param scene defines the hosting scene
  33286. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33287. * @param updatable defines if the mesh must be flagged as updatable
  33288. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33289. * @param earcutInjection can be used to inject your own earcut reference
  33290. * @returns a new Mesh
  33291. */
  33292. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33293. /**
  33294. * Creates an extruded shape mesh.
  33295. * 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
  33296. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33297. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33298. * @param name defines the name of the mesh to create
  33299. * @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
  33300. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33301. * @param scale is the value to scale the shape
  33302. * @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
  33303. * @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
  33304. * @param scene defines the hosting scene
  33305. * @param updatable defines if the mesh must be flagged as updatable
  33306. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33307. * @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)
  33308. * @returns a new Mesh
  33309. */
  33310. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33311. /**
  33312. * Creates an custom extruded shape mesh.
  33313. * The custom extrusion is a parametric shape.
  33314. * It has no predefined shape. Its final shape will depend on the input parameters.
  33315. * Please consider using the same method from the MeshBuilder class instead
  33316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33317. * @param name defines the name of the mesh to create
  33318. * @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
  33319. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33320. * @param scaleFunction is a custom Javascript function called on each path point
  33321. * @param rotationFunction is a custom Javascript function called on each path point
  33322. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33323. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33324. * @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
  33325. * @param scene defines the hosting scene
  33326. * @param updatable defines if the mesh must be flagged as updatable
  33327. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33328. * @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)
  33329. * @returns a new Mesh
  33330. */
  33331. 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;
  33332. /**
  33333. * Creates lathe mesh.
  33334. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33335. * Please consider using the same method from the MeshBuilder class instead
  33336. * @param name defines the name of the mesh to create
  33337. * @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
  33338. * @param radius is the radius value of the lathe
  33339. * @param tessellation is the side number of the lathe.
  33340. * @param scene defines the hosting scene
  33341. * @param updatable defines if the mesh must be flagged as updatable
  33342. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33343. * @returns a new Mesh
  33344. */
  33345. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33346. /**
  33347. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33348. * @param name defines the name of the mesh to create
  33349. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33350. * @param scene defines the hosting scene
  33351. * @param updatable defines if the mesh must be flagged as updatable
  33352. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33353. * @returns a new Mesh
  33354. */
  33355. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33356. /**
  33357. * Creates a ground mesh.
  33358. * Please consider using the same method from the MeshBuilder class instead
  33359. * @param name defines the name of the mesh to create
  33360. * @param width set the width of the ground
  33361. * @param height set the height of the ground
  33362. * @param subdivisions sets the number of subdivisions per side
  33363. * @param scene defines the hosting scene
  33364. * @param updatable defines if the mesh must be flagged as updatable
  33365. * @returns a new Mesh
  33366. */
  33367. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33368. /**
  33369. * Creates a tiled ground mesh.
  33370. * Please consider using the same method from the MeshBuilder class instead
  33371. * @param name defines the name of the mesh to create
  33372. * @param xmin set the ground minimum X coordinate
  33373. * @param zmin set the ground minimum Y coordinate
  33374. * @param xmax set the ground maximum X coordinate
  33375. * @param zmax set the ground maximum Z coordinate
  33376. * @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
  33377. * @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
  33378. * @param scene defines the hosting scene
  33379. * @param updatable defines if the mesh must be flagged as updatable
  33380. * @returns a new Mesh
  33381. */
  33382. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33383. w: number;
  33384. h: number;
  33385. }, precision: {
  33386. w: number;
  33387. h: number;
  33388. }, scene: Scene, updatable?: boolean): Mesh;
  33389. /**
  33390. * Creates a ground mesh from a height map.
  33391. * Please consider using the same method from the MeshBuilder class instead
  33392. * @see https://doc.babylonjs.com/babylon101/height_map
  33393. * @param name defines the name of the mesh to create
  33394. * @param url sets the URL of the height map image resource
  33395. * @param width set the ground width size
  33396. * @param height set the ground height size
  33397. * @param subdivisions sets the number of subdivision per side
  33398. * @param minHeight is the minimum altitude on the ground
  33399. * @param maxHeight is the maximum altitude on the ground
  33400. * @param scene defines the hosting scene
  33401. * @param updatable defines if the mesh must be flagged as updatable
  33402. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33403. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33404. * @returns a new Mesh
  33405. */
  33406. 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;
  33407. /**
  33408. * Creates a tube mesh.
  33409. * The tube is a parametric shape.
  33410. * It has no predefined shape. Its final shape will depend on the input parameters.
  33411. * Please consider using the same method from the MeshBuilder class instead
  33412. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33413. * @param name defines the name of the mesh to create
  33414. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33415. * @param radius sets the tube radius size
  33416. * @param tessellation is the number of sides on the tubular surface
  33417. * @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
  33418. * @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
  33419. * @param scene defines the hosting scene
  33420. * @param updatable defines if the mesh must be flagged as updatable
  33421. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33422. * @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)
  33423. * @returns a new Mesh
  33424. */
  33425. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33426. (i: number, distance: number): number;
  33427. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33428. /**
  33429. * Creates a polyhedron mesh.
  33430. * Please consider using the same method from the MeshBuilder class instead.
  33431. * * 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
  33432. * * The parameter `size` (positive float, default 1) sets the polygon size
  33433. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33434. * * 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`
  33435. * * 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
  33436. * * 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)`)
  33437. * * 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
  33438. * * 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
  33439. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33440. * * 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
  33441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33442. * @param name defines the name of the mesh to create
  33443. * @param options defines the options used to create the mesh
  33444. * @param scene defines the hosting scene
  33445. * @returns a new Mesh
  33446. */
  33447. static CreatePolyhedron(name: string, options: {
  33448. type?: number;
  33449. size?: number;
  33450. sizeX?: number;
  33451. sizeY?: number;
  33452. sizeZ?: number;
  33453. custom?: any;
  33454. faceUV?: Vector4[];
  33455. faceColors?: Color4[];
  33456. updatable?: boolean;
  33457. sideOrientation?: number;
  33458. }, scene: Scene): Mesh;
  33459. /**
  33460. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33461. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33462. * * 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`)
  33463. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33464. * * 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
  33465. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33466. * * 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
  33467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33468. * @param name defines the name of the mesh
  33469. * @param options defines the options used to create the mesh
  33470. * @param scene defines the hosting scene
  33471. * @returns a new Mesh
  33472. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33473. */
  33474. static CreateIcoSphere(name: string, options: {
  33475. radius?: number;
  33476. flat?: boolean;
  33477. subdivisions?: number;
  33478. sideOrientation?: number;
  33479. updatable?: boolean;
  33480. }, scene: Scene): Mesh;
  33481. /**
  33482. * Creates a decal mesh.
  33483. * Please consider using the same method from the MeshBuilder class instead.
  33484. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33485. * @param name defines the name of the mesh
  33486. * @param sourceMesh defines the mesh receiving the decal
  33487. * @param position sets the position of the decal in world coordinates
  33488. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33489. * @param size sets the decal scaling
  33490. * @param angle sets the angle to rotate the decal
  33491. * @returns a new Mesh
  33492. */
  33493. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33494. /** Creates a Capsule Mesh
  33495. * @param name defines the name of the mesh.
  33496. * @param options the constructors options used to shape the mesh.
  33497. * @param scene defines the scene the mesh is scoped to.
  33498. * @returns the capsule mesh
  33499. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33500. */
  33501. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33502. /**
  33503. * Prepare internal position array for software CPU skinning
  33504. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33505. */
  33506. setPositionsForCPUSkinning(): Float32Array;
  33507. /**
  33508. * Prepare internal normal array for software CPU skinning
  33509. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33510. */
  33511. setNormalsForCPUSkinning(): Float32Array;
  33512. /**
  33513. * Updates the vertex buffer by applying transformation from the bones
  33514. * @param skeleton defines the skeleton to apply to current mesh
  33515. * @returns the current mesh
  33516. */
  33517. applySkeleton(skeleton: Skeleton): Mesh;
  33518. /**
  33519. * 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
  33520. * @param meshes defines the list of meshes to scan
  33521. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33522. */
  33523. static MinMax(meshes: AbstractMesh[]): {
  33524. min: Vector3;
  33525. max: Vector3;
  33526. };
  33527. /**
  33528. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33529. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33530. * @returns a vector3
  33531. */
  33532. static Center(meshesOrMinMaxVector: {
  33533. min: Vector3;
  33534. max: Vector3;
  33535. } | AbstractMesh[]): Vector3;
  33536. /**
  33537. * Merge the array of meshes into a single mesh for performance reasons.
  33538. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33539. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33540. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33541. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33542. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33543. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33544. * @returns a new mesh
  33545. */
  33546. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33547. /** @hidden */
  33548. addInstance(instance: InstancedMesh): void;
  33549. /** @hidden */
  33550. removeInstance(instance: InstancedMesh): void;
  33551. }
  33552. }
  33553. declare module BABYLON {
  33554. /**
  33555. * This is the base class of all the camera used in the application.
  33556. * @see https://doc.babylonjs.com/features/cameras
  33557. */
  33558. export class Camera extends Node {
  33559. /** @hidden */
  33560. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33561. /**
  33562. * This is the default projection mode used by the cameras.
  33563. * It helps recreating a feeling of perspective and better appreciate depth.
  33564. * This is the best way to simulate real life cameras.
  33565. */
  33566. static readonly PERSPECTIVE_CAMERA: number;
  33567. /**
  33568. * This helps creating camera with an orthographic mode.
  33569. * 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.
  33570. */
  33571. static readonly ORTHOGRAPHIC_CAMERA: number;
  33572. /**
  33573. * This is the default FOV mode for perspective cameras.
  33574. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33575. */
  33576. static readonly FOVMODE_VERTICAL_FIXED: number;
  33577. /**
  33578. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33579. */
  33580. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33581. /**
  33582. * This specifies ther is no need for a camera rig.
  33583. * Basically only one eye is rendered corresponding to the camera.
  33584. */
  33585. static readonly RIG_MODE_NONE: number;
  33586. /**
  33587. * Simulates a camera Rig with one blue eye and one red eye.
  33588. * This can be use with 3d blue and red glasses.
  33589. */
  33590. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33591. /**
  33592. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33593. */
  33594. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33595. /**
  33596. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33597. */
  33598. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33599. /**
  33600. * Defines that both eyes of the camera will be rendered over under each other.
  33601. */
  33602. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33603. /**
  33604. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33605. */
  33606. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33607. /**
  33608. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33609. */
  33610. static readonly RIG_MODE_VR: number;
  33611. /**
  33612. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33613. */
  33614. static readonly RIG_MODE_WEBVR: number;
  33615. /**
  33616. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33617. */
  33618. static readonly RIG_MODE_CUSTOM: number;
  33619. /**
  33620. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33621. */
  33622. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33623. /**
  33624. * Define the input manager associated with the camera.
  33625. */
  33626. inputs: CameraInputsManager<Camera>;
  33627. /** @hidden */
  33628. _position: Vector3;
  33629. /**
  33630. * Define the current local position of the camera in the scene
  33631. */
  33632. get position(): Vector3;
  33633. set position(newPosition: Vector3);
  33634. protected _upVector: Vector3;
  33635. /**
  33636. * The vector the camera should consider as up.
  33637. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  33638. */
  33639. set upVector(vec: Vector3);
  33640. get upVector(): Vector3;
  33641. /**
  33642. * Define the current limit on the left side for an orthographic camera
  33643. * In scene unit
  33644. */
  33645. orthoLeft: Nullable<number>;
  33646. /**
  33647. * Define the current limit on the right side for an orthographic camera
  33648. * In scene unit
  33649. */
  33650. orthoRight: Nullable<number>;
  33651. /**
  33652. * Define the current limit on the bottom side for an orthographic camera
  33653. * In scene unit
  33654. */
  33655. orthoBottom: Nullable<number>;
  33656. /**
  33657. * Define the current limit on the top side for an orthographic camera
  33658. * In scene unit
  33659. */
  33660. orthoTop: Nullable<number>;
  33661. /**
  33662. * Field Of View is set in Radians. (default is 0.8)
  33663. */
  33664. fov: number;
  33665. /**
  33666. * Define the minimum distance the camera can see from.
  33667. * This is important to note that the depth buffer are not infinite and the closer it starts
  33668. * the more your scene might encounter depth fighting issue.
  33669. */
  33670. minZ: number;
  33671. /**
  33672. * Define the maximum distance the camera can see to.
  33673. * This is important to note that the depth buffer are not infinite and the further it end
  33674. * the more your scene might encounter depth fighting issue.
  33675. */
  33676. maxZ: number;
  33677. /**
  33678. * Define the default inertia of the camera.
  33679. * This helps giving a smooth feeling to the camera movement.
  33680. */
  33681. inertia: number;
  33682. /**
  33683. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  33684. */
  33685. mode: number;
  33686. /**
  33687. * Define whether the camera is intermediate.
  33688. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  33689. */
  33690. isIntermediate: boolean;
  33691. /**
  33692. * Define the viewport of the camera.
  33693. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  33694. */
  33695. viewport: Viewport;
  33696. /**
  33697. * Restricts the camera to viewing objects with the same layerMask.
  33698. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  33699. */
  33700. layerMask: number;
  33701. /**
  33702. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  33703. */
  33704. fovMode: number;
  33705. /**
  33706. * Rig mode of the camera.
  33707. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  33708. * This is normally controlled byt the camera themselves as internal use.
  33709. */
  33710. cameraRigMode: number;
  33711. /**
  33712. * Defines the distance between both "eyes" in case of a RIG
  33713. */
  33714. interaxialDistance: number;
  33715. /**
  33716. * Defines if stereoscopic rendering is done side by side or over under.
  33717. */
  33718. isStereoscopicSideBySide: boolean;
  33719. /**
  33720. * 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
  33721. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  33722. * else in the scene. (Eg. security camera)
  33723. *
  33724. * 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)
  33725. */
  33726. customRenderTargets: RenderTargetTexture[];
  33727. /**
  33728. * When set, the camera will render to this render target instead of the default canvas
  33729. *
  33730. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  33731. */
  33732. outputRenderTarget: Nullable<RenderTargetTexture>;
  33733. /**
  33734. * Observable triggered when the camera view matrix has changed.
  33735. */
  33736. onViewMatrixChangedObservable: Observable<Camera>;
  33737. /**
  33738. * Observable triggered when the camera Projection matrix has changed.
  33739. */
  33740. onProjectionMatrixChangedObservable: Observable<Camera>;
  33741. /**
  33742. * Observable triggered when the inputs have been processed.
  33743. */
  33744. onAfterCheckInputsObservable: Observable<Camera>;
  33745. /**
  33746. * Observable triggered when reset has been called and applied to the camera.
  33747. */
  33748. onRestoreStateObservable: Observable<Camera>;
  33749. /**
  33750. * Is this camera a part of a rig system?
  33751. */
  33752. isRigCamera: boolean;
  33753. /**
  33754. * If isRigCamera set to true this will be set with the parent camera.
  33755. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  33756. */
  33757. rigParent?: Camera;
  33758. /** @hidden */
  33759. _cameraRigParams: any;
  33760. /** @hidden */
  33761. _rigCameras: Camera[];
  33762. /** @hidden */
  33763. _rigPostProcess: Nullable<PostProcess>;
  33764. protected _webvrViewMatrix: Matrix;
  33765. /** @hidden */
  33766. _skipRendering: boolean;
  33767. /** @hidden */
  33768. _projectionMatrix: Matrix;
  33769. /** @hidden */
  33770. _postProcesses: Nullable<PostProcess>[];
  33771. /** @hidden */
  33772. _activeMeshes: SmartArray<AbstractMesh>;
  33773. protected _globalPosition: Vector3;
  33774. /** @hidden */
  33775. _computedViewMatrix: Matrix;
  33776. private _doNotComputeProjectionMatrix;
  33777. private _transformMatrix;
  33778. private _frustumPlanes;
  33779. private _refreshFrustumPlanes;
  33780. private _storedFov;
  33781. private _stateStored;
  33782. /**
  33783. * Instantiates a new camera object.
  33784. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  33785. * @see https://doc.babylonjs.com/features/cameras
  33786. * @param name Defines the name of the camera in the scene
  33787. * @param position Defines the position of the camera
  33788. * @param scene Defines the scene the camera belongs too
  33789. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  33790. */
  33791. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  33792. /**
  33793. * Store current camera state (fov, position, etc..)
  33794. * @returns the camera
  33795. */
  33796. storeState(): Camera;
  33797. /**
  33798. * Restores the camera state values if it has been stored. You must call storeState() first
  33799. */
  33800. protected _restoreStateValues(): boolean;
  33801. /**
  33802. * Restored camera state. You must call storeState() first.
  33803. * @returns true if restored and false otherwise
  33804. */
  33805. restoreState(): boolean;
  33806. /**
  33807. * Gets the class name of the camera.
  33808. * @returns the class name
  33809. */
  33810. getClassName(): string;
  33811. /** @hidden */
  33812. readonly _isCamera: boolean;
  33813. /**
  33814. * Gets a string representation of the camera useful for debug purpose.
  33815. * @param fullDetails Defines that a more verboe level of logging is required
  33816. * @returns the string representation
  33817. */
  33818. toString(fullDetails?: boolean): string;
  33819. /**
  33820. * Gets the current world space position of the camera.
  33821. */
  33822. get globalPosition(): Vector3;
  33823. /**
  33824. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  33825. * @returns the active meshe list
  33826. */
  33827. getActiveMeshes(): SmartArray<AbstractMesh>;
  33828. /**
  33829. * Check whether a mesh is part of the current active mesh list of the camera
  33830. * @param mesh Defines the mesh to check
  33831. * @returns true if active, false otherwise
  33832. */
  33833. isActiveMesh(mesh: Mesh): boolean;
  33834. /**
  33835. * Is this camera ready to be used/rendered
  33836. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  33837. * @return true if the camera is ready
  33838. */
  33839. isReady(completeCheck?: boolean): boolean;
  33840. /** @hidden */
  33841. _initCache(): void;
  33842. /** @hidden */
  33843. _updateCache(ignoreParentClass?: boolean): void;
  33844. /** @hidden */
  33845. _isSynchronized(): boolean;
  33846. /** @hidden */
  33847. _isSynchronizedViewMatrix(): boolean;
  33848. /** @hidden */
  33849. _isSynchronizedProjectionMatrix(): boolean;
  33850. /**
  33851. * Attach the input controls to a specific dom element to get the input from.
  33852. * @param element Defines the element the controls should be listened from
  33853. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33854. */
  33855. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33856. /**
  33857. * Detach the current controls from the specified dom element.
  33858. * @param element Defines the element to stop listening the inputs from
  33859. */
  33860. detachControl(element: HTMLElement): void;
  33861. /**
  33862. * Update the camera state according to the different inputs gathered during the frame.
  33863. */
  33864. update(): void;
  33865. /** @hidden */
  33866. _checkInputs(): void;
  33867. /** @hidden */
  33868. get rigCameras(): Camera[];
  33869. /**
  33870. * Gets the post process used by the rig cameras
  33871. */
  33872. get rigPostProcess(): Nullable<PostProcess>;
  33873. /**
  33874. * Internal, gets the first post proces.
  33875. * @returns the first post process to be run on this camera.
  33876. */
  33877. _getFirstPostProcess(): Nullable<PostProcess>;
  33878. private _cascadePostProcessesToRigCams;
  33879. /**
  33880. * Attach a post process to the camera.
  33881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33882. * @param postProcess The post process to attach to the camera
  33883. * @param insertAt The position of the post process in case several of them are in use in the scene
  33884. * @returns the position the post process has been inserted at
  33885. */
  33886. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  33887. /**
  33888. * Detach a post process to the camera.
  33889. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33890. * @param postProcess The post process to detach from the camera
  33891. */
  33892. detachPostProcess(postProcess: PostProcess): void;
  33893. /**
  33894. * Gets the current world matrix of the camera
  33895. */
  33896. getWorldMatrix(): Matrix;
  33897. /** @hidden */
  33898. _getViewMatrix(): Matrix;
  33899. /**
  33900. * Gets the current view matrix of the camera.
  33901. * @param force forces the camera to recompute the matrix without looking at the cached state
  33902. * @returns the view matrix
  33903. */
  33904. getViewMatrix(force?: boolean): Matrix;
  33905. /**
  33906. * Freeze the projection matrix.
  33907. * It will prevent the cache check of the camera projection compute and can speed up perf
  33908. * if no parameter of the camera are meant to change
  33909. * @param projection Defines manually a projection if necessary
  33910. */
  33911. freezeProjectionMatrix(projection?: Matrix): void;
  33912. /**
  33913. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  33914. */
  33915. unfreezeProjectionMatrix(): void;
  33916. /**
  33917. * Gets the current projection matrix of the camera.
  33918. * @param force forces the camera to recompute the matrix without looking at the cached state
  33919. * @returns the projection matrix
  33920. */
  33921. getProjectionMatrix(force?: boolean): Matrix;
  33922. /**
  33923. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  33924. * @returns a Matrix
  33925. */
  33926. getTransformationMatrix(): Matrix;
  33927. private _updateFrustumPlanes;
  33928. /**
  33929. * Checks if a cullable object (mesh...) is in the camera frustum
  33930. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  33931. * @param target The object to check
  33932. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  33933. * @returns true if the object is in frustum otherwise false
  33934. */
  33935. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  33936. /**
  33937. * Checks if a cullable object (mesh...) is in the camera frustum
  33938. * Unlike isInFrustum this cheks the full bounding box
  33939. * @param target The object to check
  33940. * @returns true if the object is in frustum otherwise false
  33941. */
  33942. isCompletelyInFrustum(target: ICullable): boolean;
  33943. /**
  33944. * Gets a ray in the forward direction from the camera.
  33945. * @param length Defines the length of the ray to create
  33946. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  33947. * @param origin Defines the start point of the ray which defaults to the camera position
  33948. * @returns the forward ray
  33949. */
  33950. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  33951. /**
  33952. * Gets a ray in the forward direction from the camera.
  33953. * @param refRay the ray to (re)use when setting the values
  33954. * @param length Defines the length of the ray to create
  33955. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  33956. * @param origin Defines the start point of the ray which defaults to the camera position
  33957. * @returns the forward ray
  33958. */
  33959. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  33960. /**
  33961. * Releases resources associated with this node.
  33962. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33963. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33964. */
  33965. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33966. /** @hidden */
  33967. _isLeftCamera: boolean;
  33968. /**
  33969. * Gets the left camera of a rig setup in case of Rigged Camera
  33970. */
  33971. get isLeftCamera(): boolean;
  33972. /** @hidden */
  33973. _isRightCamera: boolean;
  33974. /**
  33975. * Gets the right camera of a rig setup in case of Rigged Camera
  33976. */
  33977. get isRightCamera(): boolean;
  33978. /**
  33979. * Gets the left camera of a rig setup in case of Rigged Camera
  33980. */
  33981. get leftCamera(): Nullable<FreeCamera>;
  33982. /**
  33983. * Gets the right camera of a rig setup in case of Rigged Camera
  33984. */
  33985. get rightCamera(): Nullable<FreeCamera>;
  33986. /**
  33987. * Gets the left camera target of a rig setup in case of Rigged Camera
  33988. * @returns the target position
  33989. */
  33990. getLeftTarget(): Nullable<Vector3>;
  33991. /**
  33992. * Gets the right camera target of a rig setup in case of Rigged Camera
  33993. * @returns the target position
  33994. */
  33995. getRightTarget(): Nullable<Vector3>;
  33996. /**
  33997. * @hidden
  33998. */
  33999. setCameraRigMode(mode: number, rigParams: any): void;
  34000. /** @hidden */
  34001. static _setStereoscopicRigMode(camera: Camera): void;
  34002. /** @hidden */
  34003. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34004. /** @hidden */
  34005. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34006. /** @hidden */
  34007. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34008. /** @hidden */
  34009. _getVRProjectionMatrix(): Matrix;
  34010. protected _updateCameraRotationMatrix(): void;
  34011. protected _updateWebVRCameraRotationMatrix(): void;
  34012. /**
  34013. * This function MUST be overwritten by the different WebVR cameras available.
  34014. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34015. * @hidden
  34016. */
  34017. _getWebVRProjectionMatrix(): Matrix;
  34018. /**
  34019. * This function MUST be overwritten by the different WebVR cameras available.
  34020. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34021. * @hidden
  34022. */
  34023. _getWebVRViewMatrix(): Matrix;
  34024. /** @hidden */
  34025. setCameraRigParameter(name: string, value: any): void;
  34026. /**
  34027. * needs to be overridden by children so sub has required properties to be copied
  34028. * @hidden
  34029. */
  34030. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34031. /**
  34032. * May need to be overridden by children
  34033. * @hidden
  34034. */
  34035. _updateRigCameras(): void;
  34036. /** @hidden */
  34037. _setupInputs(): void;
  34038. /**
  34039. * Serialiaze the camera setup to a json represention
  34040. * @returns the JSON representation
  34041. */
  34042. serialize(): any;
  34043. /**
  34044. * Clones the current camera.
  34045. * @param name The cloned camera name
  34046. * @returns the cloned camera
  34047. */
  34048. clone(name: string): Camera;
  34049. /**
  34050. * Gets the direction of the camera relative to a given local axis.
  34051. * @param localAxis Defines the reference axis to provide a relative direction.
  34052. * @return the direction
  34053. */
  34054. getDirection(localAxis: Vector3): Vector3;
  34055. /**
  34056. * Returns the current camera absolute rotation
  34057. */
  34058. get absoluteRotation(): Quaternion;
  34059. /**
  34060. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34061. * @param localAxis Defines the reference axis to provide a relative direction.
  34062. * @param result Defines the vector to store the result in
  34063. */
  34064. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34065. /**
  34066. * Gets a camera constructor for a given camera type
  34067. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34068. * @param name The name of the camera the result will be able to instantiate
  34069. * @param scene The scene the result will construct the camera in
  34070. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34071. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34072. * @returns a factory method to construc the camera
  34073. */
  34074. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34075. /**
  34076. * Compute the world matrix of the camera.
  34077. * @returns the camera world matrix
  34078. */
  34079. computeWorldMatrix(): Matrix;
  34080. /**
  34081. * Parse a JSON and creates the camera from the parsed information
  34082. * @param parsedCamera The JSON to parse
  34083. * @param scene The scene to instantiate the camera in
  34084. * @returns the newly constructed camera
  34085. */
  34086. static Parse(parsedCamera: any, scene: Scene): Camera;
  34087. }
  34088. }
  34089. declare module BABYLON {
  34090. /**
  34091. * Class containing static functions to help procedurally build meshes
  34092. */
  34093. export class DiscBuilder {
  34094. /**
  34095. * Creates a plane polygonal mesh. By default, this is a disc
  34096. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34097. * * 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
  34098. * * 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
  34099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34100. * * 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
  34101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34102. * @param name defines the name of the mesh
  34103. * @param options defines the options used to create the mesh
  34104. * @param scene defines the hosting scene
  34105. * @returns the plane polygonal mesh
  34106. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34107. */
  34108. static CreateDisc(name: string, options: {
  34109. radius?: number;
  34110. tessellation?: number;
  34111. arc?: number;
  34112. updatable?: boolean;
  34113. sideOrientation?: number;
  34114. frontUVs?: Vector4;
  34115. backUVs?: Vector4;
  34116. }, scene?: Nullable<Scene>): Mesh;
  34117. }
  34118. }
  34119. declare module BABYLON {
  34120. /**
  34121. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34122. *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.
  34123. * The SPS is also a particle system. It provides some methods to manage the particles.
  34124. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34125. *
  34126. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34127. */
  34128. export class SolidParticleSystem implements IDisposable {
  34129. /**
  34130. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34131. * Example : var p = SPS.particles[i];
  34132. */
  34133. particles: SolidParticle[];
  34134. /**
  34135. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34136. */
  34137. nbParticles: number;
  34138. /**
  34139. * If the particles must ever face the camera (default false). Useful for planar particles.
  34140. */
  34141. billboard: boolean;
  34142. /**
  34143. * Recompute normals when adding a shape
  34144. */
  34145. recomputeNormals: boolean;
  34146. /**
  34147. * This a counter ofr your own usage. It's not set by any SPS functions.
  34148. */
  34149. counter: number;
  34150. /**
  34151. * The SPS name. This name is also given to the underlying mesh.
  34152. */
  34153. name: string;
  34154. /**
  34155. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34156. */
  34157. mesh: Mesh;
  34158. /**
  34159. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34160. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34161. */
  34162. vars: any;
  34163. /**
  34164. * This array is populated when the SPS is set as 'pickable'.
  34165. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34166. * Each element of this array is an object `{idx: int, faceId: int}`.
  34167. * `idx` is the picked particle index in the `SPS.particles` array
  34168. * `faceId` is the picked face index counted within this particle.
  34169. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34170. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34171. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34172. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34173. */
  34174. pickedParticles: {
  34175. idx: number;
  34176. faceId: number;
  34177. }[];
  34178. /**
  34179. * This array is populated when the SPS is set as 'pickable'
  34180. * Each key of this array is a submesh index.
  34181. * Each element of this array is a second array defined like this :
  34182. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34183. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34184. * `idx` is the picked particle index in the `SPS.particles` array
  34185. * `faceId` is the picked face index counted within this particle.
  34186. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34187. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34188. */
  34189. pickedBySubMesh: {
  34190. idx: number;
  34191. faceId: number;
  34192. }[][];
  34193. /**
  34194. * This array is populated when `enableDepthSort` is set to true.
  34195. * Each element of this array is an instance of the class DepthSortedParticle.
  34196. */
  34197. depthSortedParticles: DepthSortedParticle[];
  34198. /**
  34199. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34200. * @hidden
  34201. */
  34202. _bSphereOnly: boolean;
  34203. /**
  34204. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34205. * @hidden
  34206. */
  34207. _bSphereRadiusFactor: number;
  34208. private _scene;
  34209. private _positions;
  34210. private _indices;
  34211. private _normals;
  34212. private _colors;
  34213. private _uvs;
  34214. private _indices32;
  34215. private _positions32;
  34216. private _normals32;
  34217. private _fixedNormal32;
  34218. private _colors32;
  34219. private _uvs32;
  34220. private _index;
  34221. private _updatable;
  34222. private _pickable;
  34223. private _isVisibilityBoxLocked;
  34224. private _alwaysVisible;
  34225. private _depthSort;
  34226. private _expandable;
  34227. private _shapeCounter;
  34228. private _copy;
  34229. private _color;
  34230. private _computeParticleColor;
  34231. private _computeParticleTexture;
  34232. private _computeParticleRotation;
  34233. private _computeParticleVertex;
  34234. private _computeBoundingBox;
  34235. private _depthSortParticles;
  34236. private _camera;
  34237. private _mustUnrotateFixedNormals;
  34238. private _particlesIntersect;
  34239. private _needs32Bits;
  34240. private _isNotBuilt;
  34241. private _lastParticleId;
  34242. private _idxOfId;
  34243. private _multimaterialEnabled;
  34244. private _useModelMaterial;
  34245. private _indicesByMaterial;
  34246. private _materialIndexes;
  34247. private _depthSortFunction;
  34248. private _materialSortFunction;
  34249. private _materials;
  34250. private _multimaterial;
  34251. private _materialIndexesById;
  34252. private _defaultMaterial;
  34253. private _autoUpdateSubMeshes;
  34254. private _tmpVertex;
  34255. /**
  34256. * Creates a SPS (Solid Particle System) object.
  34257. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34258. * @param scene (Scene) is the scene in which the SPS is added.
  34259. * @param options defines the options of the sps e.g.
  34260. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34261. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34262. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34263. * * 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.
  34264. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34265. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34266. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34267. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34268. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34269. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34270. */
  34271. constructor(name: string, scene: Scene, options?: {
  34272. updatable?: boolean;
  34273. isPickable?: boolean;
  34274. enableDepthSort?: boolean;
  34275. particleIntersection?: boolean;
  34276. boundingSphereOnly?: boolean;
  34277. bSphereRadiusFactor?: number;
  34278. expandable?: boolean;
  34279. useModelMaterial?: boolean;
  34280. enableMultiMaterial?: boolean;
  34281. });
  34282. /**
  34283. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34284. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34285. * @returns the created mesh
  34286. */
  34287. buildMesh(): Mesh;
  34288. /**
  34289. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34290. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34291. * Thus the particles generated from `digest()` have their property `position` set yet.
  34292. * @param mesh ( Mesh ) is the mesh to be digested
  34293. * @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
  34294. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34295. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34296. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34297. * @returns the current SPS
  34298. */
  34299. digest(mesh: Mesh, options?: {
  34300. facetNb?: number;
  34301. number?: number;
  34302. delta?: number;
  34303. storage?: [];
  34304. }): SolidParticleSystem;
  34305. /**
  34306. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34307. * @hidden
  34308. */
  34309. private _unrotateFixedNormals;
  34310. /**
  34311. * Resets the temporary working copy particle
  34312. * @hidden
  34313. */
  34314. private _resetCopy;
  34315. /**
  34316. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34317. * @param p the current index in the positions array to be updated
  34318. * @param ind the current index in the indices array
  34319. * @param shape a Vector3 array, the shape geometry
  34320. * @param positions the positions array to be updated
  34321. * @param meshInd the shape indices array
  34322. * @param indices the indices array to be updated
  34323. * @param meshUV the shape uv array
  34324. * @param uvs the uv array to be updated
  34325. * @param meshCol the shape color array
  34326. * @param colors the color array to be updated
  34327. * @param meshNor the shape normals array
  34328. * @param normals the normals array to be updated
  34329. * @param idx the particle index
  34330. * @param idxInShape the particle index in its shape
  34331. * @param options the addShape() method passed options
  34332. * @model the particle model
  34333. * @hidden
  34334. */
  34335. private _meshBuilder;
  34336. /**
  34337. * Returns a shape Vector3 array from positions float array
  34338. * @param positions float array
  34339. * @returns a vector3 array
  34340. * @hidden
  34341. */
  34342. private _posToShape;
  34343. /**
  34344. * Returns a shapeUV array from a float uvs (array deep copy)
  34345. * @param uvs as a float array
  34346. * @returns a shapeUV array
  34347. * @hidden
  34348. */
  34349. private _uvsToShapeUV;
  34350. /**
  34351. * Adds a new particle object in the particles array
  34352. * @param idx particle index in particles array
  34353. * @param id particle id
  34354. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34355. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34356. * @param model particle ModelShape object
  34357. * @param shapeId model shape identifier
  34358. * @param idxInShape index of the particle in the current model
  34359. * @param bInfo model bounding info object
  34360. * @param storage target storage array, if any
  34361. * @hidden
  34362. */
  34363. private _addParticle;
  34364. /**
  34365. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34366. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34367. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34368. * @param nb (positive integer) the number of particles to be created from this model
  34369. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34370. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34371. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34372. * @returns the number of shapes in the system
  34373. */
  34374. addShape(mesh: Mesh, nb: number, options?: {
  34375. positionFunction?: any;
  34376. vertexFunction?: any;
  34377. storage?: [];
  34378. }): number;
  34379. /**
  34380. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34381. * @hidden
  34382. */
  34383. private _rebuildParticle;
  34384. /**
  34385. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34386. * @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.
  34387. * @returns the SPS.
  34388. */
  34389. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34390. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34391. * Returns an array with the removed particles.
  34392. * 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.
  34393. * The SPS can't be empty so at least one particle needs to remain in place.
  34394. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34395. * @param start index of the first particle to remove
  34396. * @param end index of the last particle to remove (included)
  34397. * @returns an array populated with the removed particles
  34398. */
  34399. removeParticles(start: number, end: number): SolidParticle[];
  34400. /**
  34401. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34402. * @param solidParticleArray an array populated with Solid Particles objects
  34403. * @returns the SPS
  34404. */
  34405. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34406. /**
  34407. * Creates a new particle and modifies the SPS mesh geometry :
  34408. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34409. * - calls _addParticle() to populate the particle array
  34410. * factorized code from addShape() and insertParticlesFromArray()
  34411. * @param idx particle index in the particles array
  34412. * @param i particle index in its shape
  34413. * @param modelShape particle ModelShape object
  34414. * @param shape shape vertex array
  34415. * @param meshInd shape indices array
  34416. * @param meshUV shape uv array
  34417. * @param meshCol shape color array
  34418. * @param meshNor shape normals array
  34419. * @param bbInfo shape bounding info
  34420. * @param storage target particle storage
  34421. * @options addShape() passed options
  34422. * @hidden
  34423. */
  34424. private _insertNewParticle;
  34425. /**
  34426. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34427. * This method calls `updateParticle()` for each particle of the SPS.
  34428. * For an animated SPS, it is usually called within the render loop.
  34429. * 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.
  34430. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34431. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34432. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34433. * @returns the SPS.
  34434. */
  34435. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34436. /**
  34437. * Disposes the SPS.
  34438. */
  34439. dispose(): void;
  34440. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34441. * idx is the particle index in the SPS
  34442. * faceId is the picked face index counted within this particle.
  34443. * Returns null if the pickInfo can't identify a picked particle.
  34444. * @param pickingInfo (PickingInfo object)
  34445. * @returns {idx: number, faceId: number} or null
  34446. */
  34447. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34448. idx: number;
  34449. faceId: number;
  34450. }>;
  34451. /**
  34452. * Returns a SolidParticle object from its identifier : particle.id
  34453. * @param id (integer) the particle Id
  34454. * @returns the searched particle or null if not found in the SPS.
  34455. */
  34456. getParticleById(id: number): Nullable<SolidParticle>;
  34457. /**
  34458. * Returns a new array populated with the particles having the passed shapeId.
  34459. * @param shapeId (integer) the shape identifier
  34460. * @returns a new solid particle array
  34461. */
  34462. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34463. /**
  34464. * Populates the passed array "ref" with the particles having the passed shapeId.
  34465. * @param shapeId the shape identifier
  34466. * @returns the SPS
  34467. * @param ref
  34468. */
  34469. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34470. /**
  34471. * Computes the required SubMeshes according the materials assigned to the particles.
  34472. * @returns the solid particle system.
  34473. * Does nothing if called before the SPS mesh is built.
  34474. */
  34475. computeSubMeshes(): SolidParticleSystem;
  34476. /**
  34477. * Sorts the solid particles by material when MultiMaterial is enabled.
  34478. * Updates the indices32 array.
  34479. * Updates the indicesByMaterial array.
  34480. * Updates the mesh indices array.
  34481. * @returns the SPS
  34482. * @hidden
  34483. */
  34484. private _sortParticlesByMaterial;
  34485. /**
  34486. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34487. * @hidden
  34488. */
  34489. private _setMaterialIndexesById;
  34490. /**
  34491. * Returns an array with unique values of Materials from the passed array
  34492. * @param array the material array to be checked and filtered
  34493. * @hidden
  34494. */
  34495. private _filterUniqueMaterialId;
  34496. /**
  34497. * Sets a new Standard Material as _defaultMaterial if not already set.
  34498. * @hidden
  34499. */
  34500. private _setDefaultMaterial;
  34501. /**
  34502. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34503. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34504. * @returns the SPS.
  34505. */
  34506. refreshVisibleSize(): SolidParticleSystem;
  34507. /**
  34508. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34509. * @param size the size (float) of the visibility box
  34510. * note : this doesn't lock the SPS mesh bounding box.
  34511. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34512. */
  34513. setVisibilityBox(size: number): void;
  34514. /**
  34515. * Gets whether the SPS as always visible or not
  34516. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34517. */
  34518. get isAlwaysVisible(): boolean;
  34519. /**
  34520. * Sets the SPS as always visible or not
  34521. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34522. */
  34523. set isAlwaysVisible(val: boolean);
  34524. /**
  34525. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34526. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34527. */
  34528. set isVisibilityBoxLocked(val: boolean);
  34529. /**
  34530. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34531. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34532. */
  34533. get isVisibilityBoxLocked(): boolean;
  34534. /**
  34535. * Tells to `setParticles()` to compute the particle rotations or not.
  34536. * Default value : true. The SPS is faster when it's set to false.
  34537. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34538. */
  34539. set computeParticleRotation(val: boolean);
  34540. /**
  34541. * Tells to `setParticles()` to compute the particle colors or not.
  34542. * Default value : true. The SPS is faster when it's set to false.
  34543. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34544. */
  34545. set computeParticleColor(val: boolean);
  34546. set computeParticleTexture(val: boolean);
  34547. /**
  34548. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34549. * Default value : false. The SPS is faster when it's set to false.
  34550. * Note : the particle custom vertex positions aren't stored values.
  34551. */
  34552. set computeParticleVertex(val: boolean);
  34553. /**
  34554. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34555. */
  34556. set computeBoundingBox(val: boolean);
  34557. /**
  34558. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34559. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34560. * Default : `true`
  34561. */
  34562. set depthSortParticles(val: boolean);
  34563. /**
  34564. * Gets if `setParticles()` computes the particle rotations or not.
  34565. * Default value : true. The SPS is faster when it's set to false.
  34566. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34567. */
  34568. get computeParticleRotation(): boolean;
  34569. /**
  34570. * Gets if `setParticles()` computes the particle colors or not.
  34571. * Default value : true. The SPS is faster when it's set to false.
  34572. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34573. */
  34574. get computeParticleColor(): boolean;
  34575. /**
  34576. * Gets if `setParticles()` computes the particle textures or not.
  34577. * Default value : true. The SPS is faster when it's set to false.
  34578. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34579. */
  34580. get computeParticleTexture(): boolean;
  34581. /**
  34582. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34583. * Default value : false. The SPS is faster when it's set to false.
  34584. * Note : the particle custom vertex positions aren't stored values.
  34585. */
  34586. get computeParticleVertex(): boolean;
  34587. /**
  34588. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34589. */
  34590. get computeBoundingBox(): boolean;
  34591. /**
  34592. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34593. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34594. * Default : `true`
  34595. */
  34596. get depthSortParticles(): boolean;
  34597. /**
  34598. * Gets if the SPS is created as expandable at construction time.
  34599. * Default : `false`
  34600. */
  34601. get expandable(): boolean;
  34602. /**
  34603. * Gets if the SPS supports the Multi Materials
  34604. */
  34605. get multimaterialEnabled(): boolean;
  34606. /**
  34607. * Gets if the SPS uses the model materials for its own multimaterial.
  34608. */
  34609. get useModelMaterial(): boolean;
  34610. /**
  34611. * The SPS used material array.
  34612. */
  34613. get materials(): Material[];
  34614. /**
  34615. * Sets the SPS MultiMaterial from the passed materials.
  34616. * Note : the passed array is internally copied and not used then by reference.
  34617. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34618. */
  34619. setMultiMaterial(materials: Material[]): void;
  34620. /**
  34621. * The SPS computed multimaterial object
  34622. */
  34623. get multimaterial(): MultiMaterial;
  34624. set multimaterial(mm: MultiMaterial);
  34625. /**
  34626. * If the subMeshes must be updated on the next call to setParticles()
  34627. */
  34628. get autoUpdateSubMeshes(): boolean;
  34629. set autoUpdateSubMeshes(val: boolean);
  34630. /**
  34631. * This function does nothing. It may be overwritten to set all the particle first values.
  34632. * The SPS doesn't call this function, you may have to call it by your own.
  34633. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34634. */
  34635. initParticles(): void;
  34636. /**
  34637. * This function does nothing. It may be overwritten to recycle a particle.
  34638. * The SPS doesn't call this function, you may have to call it by your own.
  34639. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34640. * @param particle The particle to recycle
  34641. * @returns the recycled particle
  34642. */
  34643. recycleParticle(particle: SolidParticle): SolidParticle;
  34644. /**
  34645. * Updates a particle : this function should be overwritten by the user.
  34646. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34647. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34648. * @example : just set a particle position or velocity and recycle conditions
  34649. * @param particle The particle to update
  34650. * @returns the updated particle
  34651. */
  34652. updateParticle(particle: SolidParticle): SolidParticle;
  34653. /**
  34654. * Updates a vertex of a particle : it can be overwritten by the user.
  34655. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34656. * @param particle the current particle
  34657. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34658. * @param pt the index of the current vertex in the particle shape
  34659. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34660. * @example : just set a vertex particle position or color
  34661. * @returns the sps
  34662. */
  34663. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34664. /**
  34665. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34666. * This does nothing and may be overwritten by the user.
  34667. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34668. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34669. * @param update the boolean update value actually passed to setParticles()
  34670. */
  34671. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34672. /**
  34673. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34674. * This will be passed three parameters.
  34675. * This does nothing and may be overwritten by the user.
  34676. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34677. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34678. * @param update the boolean update value actually passed to setParticles()
  34679. */
  34680. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34681. }
  34682. }
  34683. declare module BABYLON {
  34684. /**
  34685. * Represents one particle of a solid particle system.
  34686. */
  34687. export class SolidParticle {
  34688. /**
  34689. * particle global index
  34690. */
  34691. idx: number;
  34692. /**
  34693. * particle identifier
  34694. */
  34695. id: number;
  34696. /**
  34697. * The color of the particle
  34698. */
  34699. color: Nullable<Color4>;
  34700. /**
  34701. * The world space position of the particle.
  34702. */
  34703. position: Vector3;
  34704. /**
  34705. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34706. */
  34707. rotation: Vector3;
  34708. /**
  34709. * The world space rotation quaternion of the particle.
  34710. */
  34711. rotationQuaternion: Nullable<Quaternion>;
  34712. /**
  34713. * The scaling of the particle.
  34714. */
  34715. scaling: Vector3;
  34716. /**
  34717. * The uvs of the particle.
  34718. */
  34719. uvs: Vector4;
  34720. /**
  34721. * The current speed of the particle.
  34722. */
  34723. velocity: Vector3;
  34724. /**
  34725. * The pivot point in the particle local space.
  34726. */
  34727. pivot: Vector3;
  34728. /**
  34729. * Must the particle be translated from its pivot point in its local space ?
  34730. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34731. * Default : false
  34732. */
  34733. translateFromPivot: boolean;
  34734. /**
  34735. * Is the particle active or not ?
  34736. */
  34737. alive: boolean;
  34738. /**
  34739. * Is the particle visible or not ?
  34740. */
  34741. isVisible: boolean;
  34742. /**
  34743. * Index of this particle in the global "positions" array (Internal use)
  34744. * @hidden
  34745. */
  34746. _pos: number;
  34747. /**
  34748. * @hidden Index of this particle in the global "indices" array (Internal use)
  34749. */
  34750. _ind: number;
  34751. /**
  34752. * @hidden ModelShape of this particle (Internal use)
  34753. */
  34754. _model: ModelShape;
  34755. /**
  34756. * ModelShape id of this particle
  34757. */
  34758. shapeId: number;
  34759. /**
  34760. * Index of the particle in its shape id
  34761. */
  34762. idxInShape: number;
  34763. /**
  34764. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34765. */
  34766. _modelBoundingInfo: BoundingInfo;
  34767. /**
  34768. * @hidden Particle BoundingInfo object (Internal use)
  34769. */
  34770. _boundingInfo: BoundingInfo;
  34771. /**
  34772. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34773. */
  34774. _sps: SolidParticleSystem;
  34775. /**
  34776. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34777. */
  34778. _stillInvisible: boolean;
  34779. /**
  34780. * @hidden Last computed particle rotation matrix
  34781. */
  34782. _rotationMatrix: number[];
  34783. /**
  34784. * Parent particle Id, if any.
  34785. * Default null.
  34786. */
  34787. parentId: Nullable<number>;
  34788. /**
  34789. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34790. */
  34791. materialIndex: Nullable<number>;
  34792. /**
  34793. * Custom object or properties.
  34794. */
  34795. props: Nullable<any>;
  34796. /**
  34797. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34798. * The possible values are :
  34799. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34800. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34801. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34802. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34803. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34804. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34805. * */
  34806. cullingStrategy: number;
  34807. /**
  34808. * @hidden Internal global position in the SPS.
  34809. */
  34810. _globalPosition: Vector3;
  34811. /**
  34812. * Creates a Solid Particle object.
  34813. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34814. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34815. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34816. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34817. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34818. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34819. * @param shapeId (integer) is the model shape identifier in the SPS.
  34820. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34821. * @param sps defines the sps it is associated to
  34822. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34823. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34824. */
  34825. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34826. /**
  34827. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34828. * @param target the particle target
  34829. * @returns the current particle
  34830. */
  34831. copyToRef(target: SolidParticle): SolidParticle;
  34832. /**
  34833. * Legacy support, changed scale to scaling
  34834. */
  34835. get scale(): Vector3;
  34836. /**
  34837. * Legacy support, changed scale to scaling
  34838. */
  34839. set scale(scale: Vector3);
  34840. /**
  34841. * Legacy support, changed quaternion to rotationQuaternion
  34842. */
  34843. get quaternion(): Nullable<Quaternion>;
  34844. /**
  34845. * Legacy support, changed quaternion to rotationQuaternion
  34846. */
  34847. set quaternion(q: Nullable<Quaternion>);
  34848. /**
  34849. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34850. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34851. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34852. * @returns true if it intersects
  34853. */
  34854. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34855. /**
  34856. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34857. * A particle is in the frustum if its bounding box intersects the frustum
  34858. * @param frustumPlanes defines the frustum to test
  34859. * @returns true if the particle is in the frustum planes
  34860. */
  34861. isInFrustum(frustumPlanes: Plane[]): boolean;
  34862. /**
  34863. * get the rotation matrix of the particle
  34864. * @hidden
  34865. */
  34866. getRotationMatrix(m: Matrix): void;
  34867. }
  34868. /**
  34869. * Represents the shape of the model used by one particle of a solid particle system.
  34870. * SPS internal tool, don't use it manually.
  34871. */
  34872. export class ModelShape {
  34873. /**
  34874. * The shape id
  34875. * @hidden
  34876. */
  34877. shapeID: number;
  34878. /**
  34879. * flat array of model positions (internal use)
  34880. * @hidden
  34881. */
  34882. _shape: Vector3[];
  34883. /**
  34884. * flat array of model UVs (internal use)
  34885. * @hidden
  34886. */
  34887. _shapeUV: number[];
  34888. /**
  34889. * color array of the model
  34890. * @hidden
  34891. */
  34892. _shapeColors: number[];
  34893. /**
  34894. * indices array of the model
  34895. * @hidden
  34896. */
  34897. _indices: number[];
  34898. /**
  34899. * normals array of the model
  34900. * @hidden
  34901. */
  34902. _normals: number[];
  34903. /**
  34904. * length of the shape in the model indices array (internal use)
  34905. * @hidden
  34906. */
  34907. _indicesLength: number;
  34908. /**
  34909. * Custom position function (internal use)
  34910. * @hidden
  34911. */
  34912. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34913. /**
  34914. * Custom vertex function (internal use)
  34915. * @hidden
  34916. */
  34917. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34918. /**
  34919. * Model material (internal use)
  34920. * @hidden
  34921. */
  34922. _material: Nullable<Material>;
  34923. /**
  34924. * 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.
  34925. * SPS internal tool, don't use it manually.
  34926. * @hidden
  34927. */
  34928. 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>);
  34929. }
  34930. /**
  34931. * Represents a Depth Sorted Particle in the solid particle system.
  34932. * @hidden
  34933. */
  34934. export class DepthSortedParticle {
  34935. /**
  34936. * Particle index
  34937. */
  34938. idx: number;
  34939. /**
  34940. * Index of the particle in the "indices" array
  34941. */
  34942. ind: number;
  34943. /**
  34944. * Length of the particle shape in the "indices" array
  34945. */
  34946. indicesLength: number;
  34947. /**
  34948. * Squared distance from the particle to the camera
  34949. */
  34950. sqDistance: number;
  34951. /**
  34952. * Material index when used with MultiMaterials
  34953. */
  34954. materialIndex: number;
  34955. /**
  34956. * Creates a new sorted particle
  34957. * @param materialIndex
  34958. */
  34959. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  34960. }
  34961. /**
  34962. * Represents a solid particle vertex
  34963. */
  34964. export class SolidParticleVertex {
  34965. /**
  34966. * Vertex position
  34967. */
  34968. position: Vector3;
  34969. /**
  34970. * Vertex color
  34971. */
  34972. color: Color4;
  34973. /**
  34974. * Vertex UV
  34975. */
  34976. uv: Vector2;
  34977. /**
  34978. * Creates a new solid particle vertex
  34979. */
  34980. constructor();
  34981. /** Vertex x coordinate */
  34982. get x(): number;
  34983. set x(val: number);
  34984. /** Vertex y coordinate */
  34985. get y(): number;
  34986. set y(val: number);
  34987. /** Vertex z coordinate */
  34988. get z(): number;
  34989. set z(val: number);
  34990. }
  34991. }
  34992. declare module BABYLON {
  34993. /**
  34994. * @hidden
  34995. */
  34996. export class _MeshCollisionData {
  34997. _checkCollisions: boolean;
  34998. _collisionMask: number;
  34999. _collisionGroup: number;
  35000. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35001. _collider: Nullable<Collider>;
  35002. _oldPositionForCollisions: Vector3;
  35003. _diffPositionForCollisions: Vector3;
  35004. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35005. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35006. _collisionResponse: boolean;
  35007. }
  35008. }
  35009. declare module BABYLON {
  35010. /** @hidden */
  35011. class _FacetDataStorage {
  35012. facetPositions: Vector3[];
  35013. facetNormals: Vector3[];
  35014. facetPartitioning: number[][];
  35015. facetNb: number;
  35016. partitioningSubdivisions: number;
  35017. partitioningBBoxRatio: number;
  35018. facetDataEnabled: boolean;
  35019. facetParameters: any;
  35020. bbSize: Vector3;
  35021. subDiv: {
  35022. max: number;
  35023. X: number;
  35024. Y: number;
  35025. Z: number;
  35026. };
  35027. facetDepthSort: boolean;
  35028. facetDepthSortEnabled: boolean;
  35029. depthSortedIndices: IndicesArray;
  35030. depthSortedFacets: {
  35031. ind: number;
  35032. sqDistance: number;
  35033. }[];
  35034. facetDepthSortFunction: (f1: {
  35035. ind: number;
  35036. sqDistance: number;
  35037. }, f2: {
  35038. ind: number;
  35039. sqDistance: number;
  35040. }) => number;
  35041. facetDepthSortFrom: Vector3;
  35042. facetDepthSortOrigin: Vector3;
  35043. invertedMatrix: Matrix;
  35044. }
  35045. /**
  35046. * @hidden
  35047. **/
  35048. class _InternalAbstractMeshDataInfo {
  35049. _hasVertexAlpha: boolean;
  35050. _useVertexColors: boolean;
  35051. _numBoneInfluencers: number;
  35052. _applyFog: boolean;
  35053. _receiveShadows: boolean;
  35054. _facetData: _FacetDataStorage;
  35055. _visibility: number;
  35056. _skeleton: Nullable<Skeleton>;
  35057. _layerMask: number;
  35058. _computeBonesUsingShaders: boolean;
  35059. _isActive: boolean;
  35060. _onlyForInstances: boolean;
  35061. _isActiveIntermediate: boolean;
  35062. _onlyForInstancesIntermediate: boolean;
  35063. _actAsRegularMesh: boolean;
  35064. }
  35065. /**
  35066. * Class used to store all common mesh properties
  35067. */
  35068. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35069. /** No occlusion */
  35070. static OCCLUSION_TYPE_NONE: number;
  35071. /** Occlusion set to optimisitic */
  35072. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35073. /** Occlusion set to strict */
  35074. static OCCLUSION_TYPE_STRICT: number;
  35075. /** Use an accurante occlusion algorithm */
  35076. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35077. /** Use a conservative occlusion algorithm */
  35078. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35079. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35080. * Test order :
  35081. * Is the bounding sphere outside the frustum ?
  35082. * If not, are the bounding box vertices outside the frustum ?
  35083. * It not, then the cullable object is in the frustum.
  35084. */
  35085. static readonly CULLINGSTRATEGY_STANDARD: number;
  35086. /** Culling strategy : Bounding Sphere Only.
  35087. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35088. * It's also less accurate than the standard because some not visible objects can still be selected.
  35089. * Test : is the bounding sphere outside the frustum ?
  35090. * If not, then the cullable object is in the frustum.
  35091. */
  35092. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35093. /** Culling strategy : Optimistic Inclusion.
  35094. * This in an inclusion test first, then the standard exclusion test.
  35095. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35096. * 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.
  35097. * Anyway, it's as accurate as the standard strategy.
  35098. * Test :
  35099. * Is the cullable object bounding sphere center in the frustum ?
  35100. * If not, apply the default culling strategy.
  35101. */
  35102. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35103. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35104. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35105. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35106. * 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.
  35107. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35108. * Test :
  35109. * Is the cullable object bounding sphere center in the frustum ?
  35110. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35111. */
  35112. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35113. /**
  35114. * No billboard
  35115. */
  35116. static get BILLBOARDMODE_NONE(): number;
  35117. /** Billboard on X axis */
  35118. static get BILLBOARDMODE_X(): number;
  35119. /** Billboard on Y axis */
  35120. static get BILLBOARDMODE_Y(): number;
  35121. /** Billboard on Z axis */
  35122. static get BILLBOARDMODE_Z(): number;
  35123. /** Billboard on all axes */
  35124. static get BILLBOARDMODE_ALL(): number;
  35125. /** Billboard on using position instead of orientation */
  35126. static get BILLBOARDMODE_USE_POSITION(): number;
  35127. /** @hidden */
  35128. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35129. /**
  35130. * The culling strategy to use to check whether the mesh must be rendered or not.
  35131. * This value can be changed at any time and will be used on the next render mesh selection.
  35132. * The possible values are :
  35133. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35134. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35135. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35136. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35137. * Please read each static variable documentation to get details about the culling process.
  35138. * */
  35139. cullingStrategy: number;
  35140. /**
  35141. * Gets the number of facets in the mesh
  35142. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35143. */
  35144. get facetNb(): number;
  35145. /**
  35146. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35147. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35148. */
  35149. get partitioningSubdivisions(): number;
  35150. set partitioningSubdivisions(nb: number);
  35151. /**
  35152. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35153. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35154. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35155. */
  35156. get partitioningBBoxRatio(): number;
  35157. set partitioningBBoxRatio(ratio: number);
  35158. /**
  35159. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35160. * Works only for updatable meshes.
  35161. * Doesn't work with multi-materials
  35162. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35163. */
  35164. get mustDepthSortFacets(): boolean;
  35165. set mustDepthSortFacets(sort: boolean);
  35166. /**
  35167. * The location (Vector3) where the facet depth sort must be computed from.
  35168. * By default, the active camera position.
  35169. * Used only when facet depth sort is enabled
  35170. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35171. */
  35172. get facetDepthSortFrom(): Vector3;
  35173. set facetDepthSortFrom(location: Vector3);
  35174. /**
  35175. * gets a boolean indicating if facetData is enabled
  35176. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35177. */
  35178. get isFacetDataEnabled(): boolean;
  35179. /** @hidden */
  35180. _updateNonUniformScalingState(value: boolean): boolean;
  35181. /**
  35182. * An event triggered when this mesh collides with another one
  35183. */
  35184. onCollideObservable: Observable<AbstractMesh>;
  35185. /** Set a function to call when this mesh collides with another one */
  35186. set onCollide(callback: () => void);
  35187. /**
  35188. * An event triggered when the collision's position changes
  35189. */
  35190. onCollisionPositionChangeObservable: Observable<Vector3>;
  35191. /** Set a function to call when the collision's position changes */
  35192. set onCollisionPositionChange(callback: () => void);
  35193. /**
  35194. * An event triggered when material is changed
  35195. */
  35196. onMaterialChangedObservable: Observable<AbstractMesh>;
  35197. /**
  35198. * Gets or sets the orientation for POV movement & rotation
  35199. */
  35200. definedFacingForward: boolean;
  35201. /** @hidden */
  35202. _occlusionQuery: Nullable<WebGLQuery>;
  35203. /** @hidden */
  35204. _renderingGroup: Nullable<RenderingGroup>;
  35205. /**
  35206. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35207. */
  35208. get visibility(): number;
  35209. /**
  35210. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35211. */
  35212. set visibility(value: number);
  35213. /** Gets or sets the alpha index used to sort transparent meshes
  35214. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35215. */
  35216. alphaIndex: number;
  35217. /**
  35218. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35219. */
  35220. isVisible: boolean;
  35221. /**
  35222. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35223. */
  35224. isPickable: boolean;
  35225. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35226. showSubMeshesBoundingBox: boolean;
  35227. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35228. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35229. */
  35230. isBlocker: boolean;
  35231. /**
  35232. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35233. */
  35234. enablePointerMoveEvents: boolean;
  35235. private _renderingGroupId;
  35236. /**
  35237. * Specifies the rendering group id for this mesh (0 by default)
  35238. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35239. */
  35240. get renderingGroupId(): number;
  35241. set renderingGroupId(value: number);
  35242. private _material;
  35243. /** Gets or sets current material */
  35244. get material(): Nullable<Material>;
  35245. set material(value: Nullable<Material>);
  35246. /**
  35247. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35248. * @see https://doc.babylonjs.com/babylon101/shadows
  35249. */
  35250. get receiveShadows(): boolean;
  35251. set receiveShadows(value: boolean);
  35252. /** Defines color to use when rendering outline */
  35253. outlineColor: Color3;
  35254. /** Define width to use when rendering outline */
  35255. outlineWidth: number;
  35256. /** Defines color to use when rendering overlay */
  35257. overlayColor: Color3;
  35258. /** Defines alpha to use when rendering overlay */
  35259. overlayAlpha: number;
  35260. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35261. get hasVertexAlpha(): boolean;
  35262. set hasVertexAlpha(value: boolean);
  35263. /** 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) */
  35264. get useVertexColors(): boolean;
  35265. set useVertexColors(value: boolean);
  35266. /**
  35267. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35268. */
  35269. get computeBonesUsingShaders(): boolean;
  35270. set computeBonesUsingShaders(value: boolean);
  35271. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35272. get numBoneInfluencers(): number;
  35273. set numBoneInfluencers(value: number);
  35274. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35275. get applyFog(): boolean;
  35276. set applyFog(value: boolean);
  35277. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35278. useOctreeForRenderingSelection: boolean;
  35279. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35280. useOctreeForPicking: boolean;
  35281. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35282. useOctreeForCollisions: boolean;
  35283. /**
  35284. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35285. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35286. */
  35287. get layerMask(): number;
  35288. set layerMask(value: number);
  35289. /**
  35290. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35291. */
  35292. alwaysSelectAsActiveMesh: boolean;
  35293. /**
  35294. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35295. */
  35296. doNotSyncBoundingInfo: boolean;
  35297. /**
  35298. * Gets or sets the current action manager
  35299. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35300. */
  35301. actionManager: Nullable<AbstractActionManager>;
  35302. private _meshCollisionData;
  35303. /**
  35304. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35305. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35306. */
  35307. ellipsoid: Vector3;
  35308. /**
  35309. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35310. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35311. */
  35312. ellipsoidOffset: Vector3;
  35313. /**
  35314. * Gets or sets a collision mask used to mask collisions (default is -1).
  35315. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35316. */
  35317. get collisionMask(): number;
  35318. set collisionMask(mask: number);
  35319. /**
  35320. * Gets or sets a collision response flag (default is true).
  35321. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35322. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35323. * to respond to the collision.
  35324. */
  35325. get collisionResponse(): boolean;
  35326. set collisionResponse(response: boolean);
  35327. /**
  35328. * Gets or sets the current collision group mask (-1 by default).
  35329. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35330. */
  35331. get collisionGroup(): number;
  35332. set collisionGroup(mask: number);
  35333. /**
  35334. * Gets or sets current surrounding meshes (null by default).
  35335. *
  35336. * By default collision detection is tested against every mesh in the scene.
  35337. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35338. * meshes will be tested for the collision.
  35339. *
  35340. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35341. */
  35342. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35343. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35344. /**
  35345. * Defines edge width used when edgesRenderer is enabled
  35346. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35347. */
  35348. edgesWidth: number;
  35349. /**
  35350. * Defines edge color used when edgesRenderer is enabled
  35351. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35352. */
  35353. edgesColor: Color4;
  35354. /** @hidden */
  35355. _edgesRenderer: Nullable<IEdgesRenderer>;
  35356. /** @hidden */
  35357. _masterMesh: Nullable<AbstractMesh>;
  35358. /** @hidden */
  35359. _boundingInfo: Nullable<BoundingInfo>;
  35360. /** @hidden */
  35361. _renderId: number;
  35362. /**
  35363. * Gets or sets the list of subMeshes
  35364. * @see https://doc.babylonjs.com/how_to/multi_materials
  35365. */
  35366. subMeshes: SubMesh[];
  35367. /** @hidden */
  35368. _intersectionsInProgress: AbstractMesh[];
  35369. /** @hidden */
  35370. _unIndexed: boolean;
  35371. /** @hidden */
  35372. _lightSources: Light[];
  35373. /** Gets the list of lights affecting that mesh */
  35374. get lightSources(): Light[];
  35375. /** @hidden */
  35376. get _positions(): Nullable<Vector3[]>;
  35377. /** @hidden */
  35378. _waitingData: {
  35379. lods: Nullable<any>;
  35380. actions: Nullable<any>;
  35381. freezeWorldMatrix: Nullable<boolean>;
  35382. };
  35383. /** @hidden */
  35384. _bonesTransformMatrices: Nullable<Float32Array>;
  35385. /** @hidden */
  35386. _transformMatrixTexture: Nullable<RawTexture>;
  35387. /**
  35388. * Gets or sets a skeleton to apply skining transformations
  35389. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35390. */
  35391. set skeleton(value: Nullable<Skeleton>);
  35392. get skeleton(): Nullable<Skeleton>;
  35393. /**
  35394. * An event triggered when the mesh is rebuilt.
  35395. */
  35396. onRebuildObservable: Observable<AbstractMesh>;
  35397. /**
  35398. * Creates a new AbstractMesh
  35399. * @param name defines the name of the mesh
  35400. * @param scene defines the hosting scene
  35401. */
  35402. constructor(name: string, scene?: Nullable<Scene>);
  35403. /**
  35404. * Returns the string "AbstractMesh"
  35405. * @returns "AbstractMesh"
  35406. */
  35407. getClassName(): string;
  35408. /**
  35409. * Gets a string representation of the current mesh
  35410. * @param fullDetails defines a boolean indicating if full details must be included
  35411. * @returns a string representation of the current mesh
  35412. */
  35413. toString(fullDetails?: boolean): string;
  35414. /**
  35415. * @hidden
  35416. */
  35417. protected _getEffectiveParent(): Nullable<Node>;
  35418. /** @hidden */
  35419. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35420. /** @hidden */
  35421. _rebuild(): void;
  35422. /** @hidden */
  35423. _resyncLightSources(): void;
  35424. /** @hidden */
  35425. _resyncLightSource(light: Light): void;
  35426. /** @hidden */
  35427. _unBindEffect(): void;
  35428. /** @hidden */
  35429. _removeLightSource(light: Light, dispose: boolean): void;
  35430. private _markSubMeshesAsDirty;
  35431. /** @hidden */
  35432. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35433. /** @hidden */
  35434. _markSubMeshesAsAttributesDirty(): void;
  35435. /** @hidden */
  35436. _markSubMeshesAsMiscDirty(): void;
  35437. /**
  35438. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35439. */
  35440. get scaling(): Vector3;
  35441. set scaling(newScaling: Vector3);
  35442. /**
  35443. * Returns true if the mesh is blocked. Implemented by child classes
  35444. */
  35445. get isBlocked(): boolean;
  35446. /**
  35447. * Returns the mesh itself by default. Implemented by child classes
  35448. * @param camera defines the camera to use to pick the right LOD level
  35449. * @returns the currentAbstractMesh
  35450. */
  35451. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35452. /**
  35453. * Returns 0 by default. Implemented by child classes
  35454. * @returns an integer
  35455. */
  35456. getTotalVertices(): number;
  35457. /**
  35458. * Returns a positive integer : the total number of indices in this mesh geometry.
  35459. * @returns the numner of indices or zero if the mesh has no geometry.
  35460. */
  35461. getTotalIndices(): number;
  35462. /**
  35463. * Returns null by default. Implemented by child classes
  35464. * @returns null
  35465. */
  35466. getIndices(): Nullable<IndicesArray>;
  35467. /**
  35468. * Returns the array of the requested vertex data kind. Implemented by child classes
  35469. * @param kind defines the vertex data kind to use
  35470. * @returns null
  35471. */
  35472. getVerticesData(kind: string): Nullable<FloatArray>;
  35473. /**
  35474. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35475. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35476. * Note that a new underlying VertexBuffer object is created each call.
  35477. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35478. * @param kind defines vertex data kind:
  35479. * * VertexBuffer.PositionKind
  35480. * * VertexBuffer.UVKind
  35481. * * VertexBuffer.UV2Kind
  35482. * * VertexBuffer.UV3Kind
  35483. * * VertexBuffer.UV4Kind
  35484. * * VertexBuffer.UV5Kind
  35485. * * VertexBuffer.UV6Kind
  35486. * * VertexBuffer.ColorKind
  35487. * * VertexBuffer.MatricesIndicesKind
  35488. * * VertexBuffer.MatricesIndicesExtraKind
  35489. * * VertexBuffer.MatricesWeightsKind
  35490. * * VertexBuffer.MatricesWeightsExtraKind
  35491. * @param data defines the data source
  35492. * @param updatable defines if the data must be flagged as updatable (or static)
  35493. * @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
  35494. * @returns the current mesh
  35495. */
  35496. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35497. /**
  35498. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35499. * If the mesh has no geometry, it is simply returned as it is.
  35500. * @param kind defines vertex data kind:
  35501. * * VertexBuffer.PositionKind
  35502. * * VertexBuffer.UVKind
  35503. * * VertexBuffer.UV2Kind
  35504. * * VertexBuffer.UV3Kind
  35505. * * VertexBuffer.UV4Kind
  35506. * * VertexBuffer.UV5Kind
  35507. * * VertexBuffer.UV6Kind
  35508. * * VertexBuffer.ColorKind
  35509. * * VertexBuffer.MatricesIndicesKind
  35510. * * VertexBuffer.MatricesIndicesExtraKind
  35511. * * VertexBuffer.MatricesWeightsKind
  35512. * * VertexBuffer.MatricesWeightsExtraKind
  35513. * @param data defines the data source
  35514. * @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
  35515. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35516. * @returns the current mesh
  35517. */
  35518. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35519. /**
  35520. * Sets the mesh indices,
  35521. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35522. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35523. * @param totalVertices Defines the total number of vertices
  35524. * @returns the current mesh
  35525. */
  35526. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35527. /**
  35528. * Gets a boolean indicating if specific vertex data is present
  35529. * @param kind defines the vertex data kind to use
  35530. * @returns true is data kind is present
  35531. */
  35532. isVerticesDataPresent(kind: string): boolean;
  35533. /**
  35534. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35535. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35536. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35537. * @returns a BoundingInfo
  35538. */
  35539. getBoundingInfo(): BoundingInfo;
  35540. /**
  35541. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35542. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35543. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35544. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35545. * @returns the current mesh
  35546. */
  35547. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35548. /**
  35549. * Overwrite the current bounding info
  35550. * @param boundingInfo defines the new bounding info
  35551. * @returns the current mesh
  35552. */
  35553. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35554. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35555. get useBones(): boolean;
  35556. /** @hidden */
  35557. _preActivate(): void;
  35558. /** @hidden */
  35559. _preActivateForIntermediateRendering(renderId: number): void;
  35560. /** @hidden */
  35561. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35562. /** @hidden */
  35563. _postActivate(): void;
  35564. /** @hidden */
  35565. _freeze(): void;
  35566. /** @hidden */
  35567. _unFreeze(): void;
  35568. /**
  35569. * Gets the current world matrix
  35570. * @returns a Matrix
  35571. */
  35572. getWorldMatrix(): Matrix;
  35573. /** @hidden */
  35574. _getWorldMatrixDeterminant(): number;
  35575. /**
  35576. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35577. */
  35578. get isAnInstance(): boolean;
  35579. /**
  35580. * Gets a boolean indicating if this mesh has instances
  35581. */
  35582. get hasInstances(): boolean;
  35583. /**
  35584. * Gets a boolean indicating if this mesh has thin instances
  35585. */
  35586. get hasThinInstances(): boolean;
  35587. /**
  35588. * Perform relative position change from the point of view of behind the front of the mesh.
  35589. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35590. * Supports definition of mesh facing forward or backward
  35591. * @param amountRight defines the distance on the right axis
  35592. * @param amountUp defines the distance on the up axis
  35593. * @param amountForward defines the distance on the forward axis
  35594. * @returns the current mesh
  35595. */
  35596. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35597. /**
  35598. * Calculate relative position change from the point of view of behind the front of the mesh.
  35599. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35600. * Supports definition of mesh facing forward or backward
  35601. * @param amountRight defines the distance on the right axis
  35602. * @param amountUp defines the distance on the up axis
  35603. * @param amountForward defines the distance on the forward axis
  35604. * @returns the new displacement vector
  35605. */
  35606. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35607. /**
  35608. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35609. * Supports definition of mesh facing forward or backward
  35610. * @param flipBack defines the flip
  35611. * @param twirlClockwise defines the twirl
  35612. * @param tiltRight defines the tilt
  35613. * @returns the current mesh
  35614. */
  35615. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35616. /**
  35617. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35618. * Supports definition of mesh facing forward or backward.
  35619. * @param flipBack defines the flip
  35620. * @param twirlClockwise defines the twirl
  35621. * @param tiltRight defines the tilt
  35622. * @returns the new rotation vector
  35623. */
  35624. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35625. /**
  35626. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35627. * This means the mesh underlying bounding box and sphere are recomputed.
  35628. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35629. * @returns the current mesh
  35630. */
  35631. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35632. /** @hidden */
  35633. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35634. /** @hidden */
  35635. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35636. /** @hidden */
  35637. _updateBoundingInfo(): AbstractMesh;
  35638. /** @hidden */
  35639. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35640. /** @hidden */
  35641. protected _afterComputeWorldMatrix(): void;
  35642. /** @hidden */
  35643. get _effectiveMesh(): AbstractMesh;
  35644. /**
  35645. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35646. * A mesh is in the frustum if its bounding box intersects the frustum
  35647. * @param frustumPlanes defines the frustum to test
  35648. * @returns true if the mesh is in the frustum planes
  35649. */
  35650. isInFrustum(frustumPlanes: Plane[]): boolean;
  35651. /**
  35652. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35653. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35654. * @param frustumPlanes defines the frustum to test
  35655. * @returns true if the mesh is completely in the frustum planes
  35656. */
  35657. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35658. /**
  35659. * True if the mesh intersects another mesh or a SolidParticle object
  35660. * @param mesh defines a target mesh or SolidParticle to test
  35661. * @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)
  35662. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35663. * @returns true if there is an intersection
  35664. */
  35665. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35666. /**
  35667. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35668. * @param point defines the point to test
  35669. * @returns true if there is an intersection
  35670. */
  35671. intersectsPoint(point: Vector3): boolean;
  35672. /**
  35673. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35674. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35675. */
  35676. get checkCollisions(): boolean;
  35677. set checkCollisions(collisionEnabled: boolean);
  35678. /**
  35679. * Gets Collider object used to compute collisions (not physics)
  35680. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35681. */
  35682. get collider(): Nullable<Collider>;
  35683. /**
  35684. * Move the mesh using collision engine
  35685. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35686. * @param displacement defines the requested displacement vector
  35687. * @returns the current mesh
  35688. */
  35689. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35690. private _onCollisionPositionChange;
  35691. /** @hidden */
  35692. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35693. /** @hidden */
  35694. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35695. /** @hidden */
  35696. _checkCollision(collider: Collider): AbstractMesh;
  35697. /** @hidden */
  35698. _generatePointsArray(): boolean;
  35699. /**
  35700. * Checks if the passed Ray intersects with the mesh
  35701. * @param ray defines the ray to use
  35702. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35703. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35704. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35705. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35706. * @returns the picking info
  35707. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35708. */
  35709. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  35710. /**
  35711. * Clones the current mesh
  35712. * @param name defines the mesh name
  35713. * @param newParent defines the new mesh parent
  35714. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35715. * @returns the new mesh
  35716. */
  35717. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35718. /**
  35719. * Disposes all the submeshes of the current meshnp
  35720. * @returns the current mesh
  35721. */
  35722. releaseSubMeshes(): AbstractMesh;
  35723. /**
  35724. * Releases resources associated with this abstract mesh.
  35725. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35726. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35727. */
  35728. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35729. /**
  35730. * Adds the passed mesh as a child to the current mesh
  35731. * @param mesh defines the child mesh
  35732. * @returns the current mesh
  35733. */
  35734. addChild(mesh: AbstractMesh): AbstractMesh;
  35735. /**
  35736. * Removes the passed mesh from the current mesh children list
  35737. * @param mesh defines the child mesh
  35738. * @returns the current mesh
  35739. */
  35740. removeChild(mesh: AbstractMesh): AbstractMesh;
  35741. /** @hidden */
  35742. private _initFacetData;
  35743. /**
  35744. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35745. * This method can be called within the render loop.
  35746. * 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
  35747. * @returns the current mesh
  35748. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35749. */
  35750. updateFacetData(): AbstractMesh;
  35751. /**
  35752. * Returns the facetLocalNormals array.
  35753. * The normals are expressed in the mesh local spac
  35754. * @returns an array of Vector3
  35755. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35756. */
  35757. getFacetLocalNormals(): Vector3[];
  35758. /**
  35759. * Returns the facetLocalPositions array.
  35760. * The facet positions are expressed in the mesh local space
  35761. * @returns an array of Vector3
  35762. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35763. */
  35764. getFacetLocalPositions(): Vector3[];
  35765. /**
  35766. * Returns the facetLocalPartioning array
  35767. * @returns an array of array of numbers
  35768. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35769. */
  35770. getFacetLocalPartitioning(): number[][];
  35771. /**
  35772. * Returns the i-th facet position in the world system.
  35773. * This method allocates a new Vector3 per call
  35774. * @param i defines the facet index
  35775. * @returns a new Vector3
  35776. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35777. */
  35778. getFacetPosition(i: number): Vector3;
  35779. /**
  35780. * Sets the reference Vector3 with the i-th facet position in the world system
  35781. * @param i defines the facet index
  35782. * @param ref defines the target vector
  35783. * @returns the current mesh
  35784. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35785. */
  35786. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35787. /**
  35788. * Returns the i-th facet normal in the world system.
  35789. * This method allocates a new Vector3 per call
  35790. * @param i defines the facet index
  35791. * @returns a new Vector3
  35792. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35793. */
  35794. getFacetNormal(i: number): Vector3;
  35795. /**
  35796. * Sets the reference Vector3 with the i-th facet normal in the world system
  35797. * @param i defines the facet index
  35798. * @param ref defines the target vector
  35799. * @returns the current mesh
  35800. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35801. */
  35802. getFacetNormalToRef(i: number, ref: Vector3): this;
  35803. /**
  35804. * 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)
  35805. * @param x defines x coordinate
  35806. * @param y defines y coordinate
  35807. * @param z defines z coordinate
  35808. * @returns the array of facet indexes
  35809. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35810. */
  35811. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35812. /**
  35813. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35814. * @param projected sets as the (x,y,z) world projection on the facet
  35815. * @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
  35816. * @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
  35817. * @param x defines x coordinate
  35818. * @param y defines y coordinate
  35819. * @param z defines z coordinate
  35820. * @returns the face index if found (or null instead)
  35821. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35822. */
  35823. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35824. /**
  35825. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35826. * @param projected sets as the (x,y,z) local projection on the facet
  35827. * @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
  35828. * @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
  35829. * @param x defines x coordinate
  35830. * @param y defines y coordinate
  35831. * @param z defines z coordinate
  35832. * @returns the face index if found (or null instead)
  35833. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35834. */
  35835. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35836. /**
  35837. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35838. * @returns the parameters
  35839. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35840. */
  35841. getFacetDataParameters(): any;
  35842. /**
  35843. * Disables the feature FacetData and frees the related memory
  35844. * @returns the current mesh
  35845. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35846. */
  35847. disableFacetData(): AbstractMesh;
  35848. /**
  35849. * Updates the AbstractMesh indices array
  35850. * @param indices defines the data source
  35851. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35852. * @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)
  35853. * @returns the current mesh
  35854. */
  35855. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35856. /**
  35857. * Creates new normals data for the mesh
  35858. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35859. * @returns the current mesh
  35860. */
  35861. createNormals(updatable: boolean): AbstractMesh;
  35862. /**
  35863. * Align the mesh with a normal
  35864. * @param normal defines the normal to use
  35865. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35866. * @returns the current mesh
  35867. */
  35868. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35869. /** @hidden */
  35870. _checkOcclusionQuery(): boolean;
  35871. /**
  35872. * Disables the mesh edge rendering mode
  35873. * @returns the currentAbstractMesh
  35874. */
  35875. disableEdgesRendering(): AbstractMesh;
  35876. /**
  35877. * Enables the edge rendering mode on the mesh.
  35878. * This mode makes the mesh edges visible
  35879. * @param epsilon defines the maximal distance between two angles to detect a face
  35880. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35881. * @returns the currentAbstractMesh
  35882. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35883. */
  35884. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35885. /**
  35886. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35887. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35888. */
  35889. getConnectedParticleSystems(): IParticleSystem[];
  35890. }
  35891. }
  35892. declare module BABYLON {
  35893. /**
  35894. * Interface used to define ActionEvent
  35895. */
  35896. export interface IActionEvent {
  35897. /** The mesh or sprite that triggered the action */
  35898. source: any;
  35899. /** The X mouse cursor position at the time of the event */
  35900. pointerX: number;
  35901. /** The Y mouse cursor position at the time of the event */
  35902. pointerY: number;
  35903. /** The mesh that is currently pointed at (can be null) */
  35904. meshUnderPointer: Nullable<AbstractMesh>;
  35905. /** the original (browser) event that triggered the ActionEvent */
  35906. sourceEvent?: any;
  35907. /** additional data for the event */
  35908. additionalData?: any;
  35909. }
  35910. /**
  35911. * ActionEvent is the event being sent when an action is triggered.
  35912. */
  35913. export class ActionEvent implements IActionEvent {
  35914. /** The mesh or sprite that triggered the action */
  35915. source: any;
  35916. /** The X mouse cursor position at the time of the event */
  35917. pointerX: number;
  35918. /** The Y mouse cursor position at the time of the event */
  35919. pointerY: number;
  35920. /** The mesh that is currently pointed at (can be null) */
  35921. meshUnderPointer: Nullable<AbstractMesh>;
  35922. /** the original (browser) event that triggered the ActionEvent */
  35923. sourceEvent?: any;
  35924. /** additional data for the event */
  35925. additionalData?: any;
  35926. /**
  35927. * Creates a new ActionEvent
  35928. * @param source The mesh or sprite that triggered the action
  35929. * @param pointerX The X mouse cursor position at the time of the event
  35930. * @param pointerY The Y mouse cursor position at the time of the event
  35931. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  35932. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  35933. * @param additionalData additional data for the event
  35934. */
  35935. constructor(
  35936. /** The mesh or sprite that triggered the action */
  35937. source: any,
  35938. /** The X mouse cursor position at the time of the event */
  35939. pointerX: number,
  35940. /** The Y mouse cursor position at the time of the event */
  35941. pointerY: number,
  35942. /** The mesh that is currently pointed at (can be null) */
  35943. meshUnderPointer: Nullable<AbstractMesh>,
  35944. /** the original (browser) event that triggered the ActionEvent */
  35945. sourceEvent?: any,
  35946. /** additional data for the event */
  35947. additionalData?: any);
  35948. /**
  35949. * Helper function to auto-create an ActionEvent from a source mesh.
  35950. * @param source The source mesh that triggered the event
  35951. * @param evt The original (browser) event
  35952. * @param additionalData additional data for the event
  35953. * @returns the new ActionEvent
  35954. */
  35955. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  35956. /**
  35957. * Helper function to auto-create an ActionEvent from a source sprite
  35958. * @param source The source sprite that triggered the event
  35959. * @param scene Scene associated with the sprite
  35960. * @param evt The original (browser) event
  35961. * @param additionalData additional data for the event
  35962. * @returns the new ActionEvent
  35963. */
  35964. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  35965. /**
  35966. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  35967. * @param scene the scene where the event occurred
  35968. * @param evt The original (browser) event
  35969. * @returns the new ActionEvent
  35970. */
  35971. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  35972. /**
  35973. * Helper function to auto-create an ActionEvent from a primitive
  35974. * @param prim defines the target primitive
  35975. * @param pointerPos defines the pointer position
  35976. * @param evt The original (browser) event
  35977. * @param additionalData additional data for the event
  35978. * @returns the new ActionEvent
  35979. */
  35980. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  35981. }
  35982. }
  35983. declare module BABYLON {
  35984. /**
  35985. * Abstract class used to decouple action Manager from scene and meshes.
  35986. * Do not instantiate.
  35987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35988. */
  35989. export abstract class AbstractActionManager implements IDisposable {
  35990. /** Gets the list of active triggers */
  35991. static Triggers: {
  35992. [key: string]: number;
  35993. };
  35994. /** Gets the cursor to use when hovering items */
  35995. hoverCursor: string;
  35996. /** Gets the list of actions */
  35997. actions: IAction[];
  35998. /**
  35999. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36000. */
  36001. isRecursive: boolean;
  36002. /**
  36003. * Releases all associated resources
  36004. */
  36005. abstract dispose(): void;
  36006. /**
  36007. * Does this action manager has pointer triggers
  36008. */
  36009. abstract get hasPointerTriggers(): boolean;
  36010. /**
  36011. * Does this action manager has pick triggers
  36012. */
  36013. abstract get hasPickTriggers(): boolean;
  36014. /**
  36015. * Process a specific trigger
  36016. * @param trigger defines the trigger to process
  36017. * @param evt defines the event details to be processed
  36018. */
  36019. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36020. /**
  36021. * Does this action manager handles actions of any of the given triggers
  36022. * @param triggers defines the triggers to be tested
  36023. * @return a boolean indicating whether one (or more) of the triggers is handled
  36024. */
  36025. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36026. /**
  36027. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36028. * speed.
  36029. * @param triggerA defines the trigger to be tested
  36030. * @param triggerB defines the trigger to be tested
  36031. * @return a boolean indicating whether one (or more) of the triggers is handled
  36032. */
  36033. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36034. /**
  36035. * Does this action manager handles actions of a given trigger
  36036. * @param trigger defines the trigger to be tested
  36037. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36038. * @return whether the trigger is handled
  36039. */
  36040. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36041. /**
  36042. * Serialize this manager to a JSON object
  36043. * @param name defines the property name to store this manager
  36044. * @returns a JSON representation of this manager
  36045. */
  36046. abstract serialize(name: string): any;
  36047. /**
  36048. * Registers an action to this action manager
  36049. * @param action defines the action to be registered
  36050. * @return the action amended (prepared) after registration
  36051. */
  36052. abstract registerAction(action: IAction): Nullable<IAction>;
  36053. /**
  36054. * Unregisters an action to this action manager
  36055. * @param action defines the action to be unregistered
  36056. * @return a boolean indicating whether the action has been unregistered
  36057. */
  36058. abstract unregisterAction(action: IAction): Boolean;
  36059. /**
  36060. * Does exist one action manager with at least one trigger
  36061. **/
  36062. static get HasTriggers(): boolean;
  36063. /**
  36064. * Does exist one action manager with at least one pick trigger
  36065. **/
  36066. static get HasPickTriggers(): boolean;
  36067. /**
  36068. * Does exist one action manager that handles actions of a given trigger
  36069. * @param trigger defines the trigger to be tested
  36070. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36071. **/
  36072. static HasSpecificTrigger(trigger: number): boolean;
  36073. }
  36074. }
  36075. declare module BABYLON {
  36076. /**
  36077. * Defines how a node can be built from a string name.
  36078. */
  36079. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36080. /**
  36081. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36082. */
  36083. export class Node implements IBehaviorAware<Node> {
  36084. /** @hidden */
  36085. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36086. private static _NodeConstructors;
  36087. /**
  36088. * Add a new node constructor
  36089. * @param type defines the type name of the node to construct
  36090. * @param constructorFunc defines the constructor function
  36091. */
  36092. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36093. /**
  36094. * Returns a node constructor based on type name
  36095. * @param type defines the type name
  36096. * @param name defines the new node name
  36097. * @param scene defines the hosting scene
  36098. * @param options defines optional options to transmit to constructors
  36099. * @returns the new constructor or null
  36100. */
  36101. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36102. /**
  36103. * Gets or sets the name of the node
  36104. */
  36105. name: string;
  36106. /**
  36107. * Gets or sets the id of the node
  36108. */
  36109. id: string;
  36110. /**
  36111. * Gets or sets the unique id of the node
  36112. */
  36113. uniqueId: number;
  36114. /**
  36115. * Gets or sets a string used to store user defined state for the node
  36116. */
  36117. state: string;
  36118. /**
  36119. * Gets or sets an object used to store user defined information for the node
  36120. */
  36121. metadata: any;
  36122. /**
  36123. * For internal use only. Please do not use.
  36124. */
  36125. reservedDataStore: any;
  36126. /**
  36127. * List of inspectable custom properties (used by the Inspector)
  36128. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36129. */
  36130. inspectableCustomProperties: IInspectable[];
  36131. private _doNotSerialize;
  36132. /**
  36133. * Gets or sets a boolean used to define if the node must be serialized
  36134. */
  36135. get doNotSerialize(): boolean;
  36136. set doNotSerialize(value: boolean);
  36137. /** @hidden */
  36138. _isDisposed: boolean;
  36139. /**
  36140. * Gets a list of Animations associated with the node
  36141. */
  36142. animations: Animation[];
  36143. protected _ranges: {
  36144. [name: string]: Nullable<AnimationRange>;
  36145. };
  36146. /**
  36147. * Callback raised when the node is ready to be used
  36148. */
  36149. onReady: Nullable<(node: Node) => void>;
  36150. private _isEnabled;
  36151. private _isParentEnabled;
  36152. private _isReady;
  36153. /** @hidden */
  36154. _currentRenderId: number;
  36155. private _parentUpdateId;
  36156. /** @hidden */
  36157. _childUpdateId: number;
  36158. /** @hidden */
  36159. _waitingParentId: Nullable<string>;
  36160. /** @hidden */
  36161. _scene: Scene;
  36162. /** @hidden */
  36163. _cache: any;
  36164. private _parentNode;
  36165. private _children;
  36166. /** @hidden */
  36167. _worldMatrix: Matrix;
  36168. /** @hidden */
  36169. _worldMatrixDeterminant: number;
  36170. /** @hidden */
  36171. _worldMatrixDeterminantIsDirty: boolean;
  36172. /** @hidden */
  36173. private _sceneRootNodesIndex;
  36174. /**
  36175. * Gets a boolean indicating if the node has been disposed
  36176. * @returns true if the node was disposed
  36177. */
  36178. isDisposed(): boolean;
  36179. /**
  36180. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36181. * @see https://doc.babylonjs.com/how_to/parenting
  36182. */
  36183. set parent(parent: Nullable<Node>);
  36184. get parent(): Nullable<Node>;
  36185. /** @hidden */
  36186. _addToSceneRootNodes(): void;
  36187. /** @hidden */
  36188. _removeFromSceneRootNodes(): void;
  36189. private _animationPropertiesOverride;
  36190. /**
  36191. * Gets or sets the animation properties override
  36192. */
  36193. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36194. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36195. /**
  36196. * Gets a string identifying the name of the class
  36197. * @returns "Node" string
  36198. */
  36199. getClassName(): string;
  36200. /** @hidden */
  36201. readonly _isNode: boolean;
  36202. /**
  36203. * An event triggered when the mesh is disposed
  36204. */
  36205. onDisposeObservable: Observable<Node>;
  36206. private _onDisposeObserver;
  36207. /**
  36208. * Sets a callback that will be raised when the node will be disposed
  36209. */
  36210. set onDispose(callback: () => void);
  36211. /**
  36212. * Creates a new Node
  36213. * @param name the name and id to be given to this node
  36214. * @param scene the scene this node will be added to
  36215. */
  36216. constructor(name: string, scene?: Nullable<Scene>);
  36217. /**
  36218. * Gets the scene of the node
  36219. * @returns a scene
  36220. */
  36221. getScene(): Scene;
  36222. /**
  36223. * Gets the engine of the node
  36224. * @returns a Engine
  36225. */
  36226. getEngine(): Engine;
  36227. private _behaviors;
  36228. /**
  36229. * Attach a behavior to the node
  36230. * @see https://doc.babylonjs.com/features/behaviour
  36231. * @param behavior defines the behavior to attach
  36232. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36233. * @returns the current Node
  36234. */
  36235. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36236. /**
  36237. * Remove an attached behavior
  36238. * @see https://doc.babylonjs.com/features/behaviour
  36239. * @param behavior defines the behavior to attach
  36240. * @returns the current Node
  36241. */
  36242. removeBehavior(behavior: Behavior<Node>): Node;
  36243. /**
  36244. * Gets the list of attached behaviors
  36245. * @see https://doc.babylonjs.com/features/behaviour
  36246. */
  36247. get behaviors(): Behavior<Node>[];
  36248. /**
  36249. * Gets an attached behavior by name
  36250. * @param name defines the name of the behavior to look for
  36251. * @see https://doc.babylonjs.com/features/behaviour
  36252. * @returns null if behavior was not found else the requested behavior
  36253. */
  36254. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36255. /**
  36256. * Returns the latest update of the World matrix
  36257. * @returns a Matrix
  36258. */
  36259. getWorldMatrix(): Matrix;
  36260. /** @hidden */
  36261. _getWorldMatrixDeterminant(): number;
  36262. /**
  36263. * Returns directly the latest state of the mesh World matrix.
  36264. * A Matrix is returned.
  36265. */
  36266. get worldMatrixFromCache(): Matrix;
  36267. /** @hidden */
  36268. _initCache(): void;
  36269. /** @hidden */
  36270. updateCache(force?: boolean): void;
  36271. /** @hidden */
  36272. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36273. /** @hidden */
  36274. _updateCache(ignoreParentClass?: boolean): void;
  36275. /** @hidden */
  36276. _isSynchronized(): boolean;
  36277. /** @hidden */
  36278. _markSyncedWithParent(): void;
  36279. /** @hidden */
  36280. isSynchronizedWithParent(): boolean;
  36281. /** @hidden */
  36282. isSynchronized(): boolean;
  36283. /**
  36284. * Is this node ready to be used/rendered
  36285. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36286. * @return true if the node is ready
  36287. */
  36288. isReady(completeCheck?: boolean): boolean;
  36289. /**
  36290. * Is this node enabled?
  36291. * 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
  36292. * @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
  36293. * @return whether this node (and its parent) is enabled
  36294. */
  36295. isEnabled(checkAncestors?: boolean): boolean;
  36296. /** @hidden */
  36297. protected _syncParentEnabledState(): void;
  36298. /**
  36299. * Set the enabled state of this node
  36300. * @param value defines the new enabled state
  36301. */
  36302. setEnabled(value: boolean): void;
  36303. /**
  36304. * Is this node a descendant of the given node?
  36305. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36306. * @param ancestor defines the parent node to inspect
  36307. * @returns a boolean indicating if this node is a descendant of the given node
  36308. */
  36309. isDescendantOf(ancestor: Node): boolean;
  36310. /** @hidden */
  36311. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36312. /**
  36313. * Will return all nodes that have this node as ascendant
  36314. * @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
  36315. * @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
  36316. * @return all children nodes of all types
  36317. */
  36318. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36319. /**
  36320. * Get all child-meshes of this node
  36321. * @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)
  36322. * @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
  36323. * @returns an array of AbstractMesh
  36324. */
  36325. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36326. /**
  36327. * Get all direct children of this node
  36328. * @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
  36329. * @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)
  36330. * @returns an array of Node
  36331. */
  36332. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36333. /** @hidden */
  36334. _setReady(state: boolean): void;
  36335. /**
  36336. * Get an animation by name
  36337. * @param name defines the name of the animation to look for
  36338. * @returns null if not found else the requested animation
  36339. */
  36340. getAnimationByName(name: string): Nullable<Animation>;
  36341. /**
  36342. * Creates an animation range for this node
  36343. * @param name defines the name of the range
  36344. * @param from defines the starting key
  36345. * @param to defines the end key
  36346. */
  36347. createAnimationRange(name: string, from: number, to: number): void;
  36348. /**
  36349. * Delete a specific animation range
  36350. * @param name defines the name of the range to delete
  36351. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36352. */
  36353. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36354. /**
  36355. * Get an animation range by name
  36356. * @param name defines the name of the animation range to look for
  36357. * @returns null if not found else the requested animation range
  36358. */
  36359. getAnimationRange(name: string): Nullable<AnimationRange>;
  36360. /**
  36361. * Gets the list of all animation ranges defined on this node
  36362. * @returns an array
  36363. */
  36364. getAnimationRanges(): Nullable<AnimationRange>[];
  36365. /**
  36366. * Will start the animation sequence
  36367. * @param name defines the range frames for animation sequence
  36368. * @param loop defines if the animation should loop (false by default)
  36369. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36370. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36371. * @returns the object created for this animation. If range does not exist, it will return null
  36372. */
  36373. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36374. /**
  36375. * Serialize animation ranges into a JSON compatible object
  36376. * @returns serialization object
  36377. */
  36378. serializeAnimationRanges(): any;
  36379. /**
  36380. * Computes the world matrix of the node
  36381. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36382. * @returns the world matrix
  36383. */
  36384. computeWorldMatrix(force?: boolean): Matrix;
  36385. /**
  36386. * Releases resources associated with this node.
  36387. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36388. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36389. */
  36390. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36391. /**
  36392. * Parse animation range data from a serialization object and store them into a given node
  36393. * @param node defines where to store the animation ranges
  36394. * @param parsedNode defines the serialization object to read data from
  36395. * @param scene defines the hosting scene
  36396. */
  36397. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36398. /**
  36399. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36400. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36401. * @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
  36402. * @returns the new bounding vectors
  36403. */
  36404. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36405. min: Vector3;
  36406. max: Vector3;
  36407. };
  36408. }
  36409. }
  36410. declare module BABYLON {
  36411. /**
  36412. * @hidden
  36413. */
  36414. export class _IAnimationState {
  36415. key: number;
  36416. repeatCount: number;
  36417. workValue?: any;
  36418. loopMode?: number;
  36419. offsetValue?: any;
  36420. highLimitValue?: any;
  36421. }
  36422. /**
  36423. * Class used to store any kind of animation
  36424. */
  36425. export class Animation {
  36426. /**Name of the animation */
  36427. name: string;
  36428. /**Property to animate */
  36429. targetProperty: string;
  36430. /**The frames per second of the animation */
  36431. framePerSecond: number;
  36432. /**The data type of the animation */
  36433. dataType: number;
  36434. /**The loop mode of the animation */
  36435. loopMode?: number | undefined;
  36436. /**Specifies if blending should be enabled */
  36437. enableBlending?: boolean | undefined;
  36438. /**
  36439. * Use matrix interpolation instead of using direct key value when animating matrices
  36440. */
  36441. static AllowMatricesInterpolation: boolean;
  36442. /**
  36443. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36444. */
  36445. static AllowMatrixDecomposeForInterpolation: boolean;
  36446. /** Define the Url to load snippets */
  36447. static SnippetUrl: string;
  36448. /** Snippet ID if the animation was created from the snippet server */
  36449. snippetId: string;
  36450. /**
  36451. * Stores the key frames of the animation
  36452. */
  36453. private _keys;
  36454. /**
  36455. * Stores the easing function of the animation
  36456. */
  36457. private _easingFunction;
  36458. /**
  36459. * @hidden Internal use only
  36460. */
  36461. _runtimeAnimations: RuntimeAnimation[];
  36462. /**
  36463. * The set of event that will be linked to this animation
  36464. */
  36465. private _events;
  36466. /**
  36467. * Stores an array of target property paths
  36468. */
  36469. targetPropertyPath: string[];
  36470. /**
  36471. * Stores the blending speed of the animation
  36472. */
  36473. blendingSpeed: number;
  36474. /**
  36475. * Stores the animation ranges for the animation
  36476. */
  36477. private _ranges;
  36478. /**
  36479. * @hidden Internal use
  36480. */
  36481. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36482. /**
  36483. * Sets up an animation
  36484. * @param property The property to animate
  36485. * @param animationType The animation type to apply
  36486. * @param framePerSecond The frames per second of the animation
  36487. * @param easingFunction The easing function used in the animation
  36488. * @returns The created animation
  36489. */
  36490. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36491. /**
  36492. * Create and start an animation on a node
  36493. * @param name defines the name of the global animation that will be run on all nodes
  36494. * @param node defines the root node where the animation will take place
  36495. * @param targetProperty defines property to animate
  36496. * @param framePerSecond defines the number of frame per second yo use
  36497. * @param totalFrame defines the number of frames in total
  36498. * @param from defines the initial value
  36499. * @param to defines the final value
  36500. * @param loopMode defines which loop mode you want to use (off by default)
  36501. * @param easingFunction defines the easing function to use (linear by default)
  36502. * @param onAnimationEnd defines the callback to call when animation end
  36503. * @returns the animatable created for this animation
  36504. */
  36505. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36506. /**
  36507. * Create and start an animation on a node and its descendants
  36508. * @param name defines the name of the global animation that will be run on all nodes
  36509. * @param node defines the root node where the animation will take place
  36510. * @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
  36511. * @param targetProperty defines property to animate
  36512. * @param framePerSecond defines the number of frame per second to use
  36513. * @param totalFrame defines the number of frames in total
  36514. * @param from defines the initial value
  36515. * @param to defines the final value
  36516. * @param loopMode defines which loop mode you want to use (off by default)
  36517. * @param easingFunction defines the easing function to use (linear by default)
  36518. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36519. * @returns the list of animatables created for all nodes
  36520. * @example https://www.babylonjs-playground.com/#MH0VLI
  36521. */
  36522. 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[]>;
  36523. /**
  36524. * Creates a new animation, merges it with the existing animations and starts it
  36525. * @param name Name of the animation
  36526. * @param node Node which contains the scene that begins the animations
  36527. * @param targetProperty Specifies which property to animate
  36528. * @param framePerSecond The frames per second of the animation
  36529. * @param totalFrame The total number of frames
  36530. * @param from The frame at the beginning of the animation
  36531. * @param to The frame at the end of the animation
  36532. * @param loopMode Specifies the loop mode of the animation
  36533. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36534. * @param onAnimationEnd Callback to run once the animation is complete
  36535. * @returns Nullable animation
  36536. */
  36537. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36538. /**
  36539. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36540. * @param sourceAnimation defines the Animation containing keyframes to convert
  36541. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36542. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36543. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36544. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36545. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36546. */
  36547. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36548. /**
  36549. * Transition property of an host to the target Value
  36550. * @param property The property to transition
  36551. * @param targetValue The target Value of the property
  36552. * @param host The object where the property to animate belongs
  36553. * @param scene Scene used to run the animation
  36554. * @param frameRate Framerate (in frame/s) to use
  36555. * @param transition The transition type we want to use
  36556. * @param duration The duration of the animation, in milliseconds
  36557. * @param onAnimationEnd Callback trigger at the end of the animation
  36558. * @returns Nullable animation
  36559. */
  36560. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36561. /**
  36562. * Return the array of runtime animations currently using this animation
  36563. */
  36564. get runtimeAnimations(): RuntimeAnimation[];
  36565. /**
  36566. * Specifies if any of the runtime animations are currently running
  36567. */
  36568. get hasRunningRuntimeAnimations(): boolean;
  36569. /**
  36570. * Initializes the animation
  36571. * @param name Name of the animation
  36572. * @param targetProperty Property to animate
  36573. * @param framePerSecond The frames per second of the animation
  36574. * @param dataType The data type of the animation
  36575. * @param loopMode The loop mode of the animation
  36576. * @param enableBlending Specifies if blending should be enabled
  36577. */
  36578. constructor(
  36579. /**Name of the animation */
  36580. name: string,
  36581. /**Property to animate */
  36582. targetProperty: string,
  36583. /**The frames per second of the animation */
  36584. framePerSecond: number,
  36585. /**The data type of the animation */
  36586. dataType: number,
  36587. /**The loop mode of the animation */
  36588. loopMode?: number | undefined,
  36589. /**Specifies if blending should be enabled */
  36590. enableBlending?: boolean | undefined);
  36591. /**
  36592. * Converts the animation to a string
  36593. * @param fullDetails support for multiple levels of logging within scene loading
  36594. * @returns String form of the animation
  36595. */
  36596. toString(fullDetails?: boolean): string;
  36597. /**
  36598. * Add an event to this animation
  36599. * @param event Event to add
  36600. */
  36601. addEvent(event: AnimationEvent): void;
  36602. /**
  36603. * Remove all events found at the given frame
  36604. * @param frame The frame to remove events from
  36605. */
  36606. removeEvents(frame: number): void;
  36607. /**
  36608. * Retrieves all the events from the animation
  36609. * @returns Events from the animation
  36610. */
  36611. getEvents(): AnimationEvent[];
  36612. /**
  36613. * Creates an animation range
  36614. * @param name Name of the animation range
  36615. * @param from Starting frame of the animation range
  36616. * @param to Ending frame of the animation
  36617. */
  36618. createRange(name: string, from: number, to: number): void;
  36619. /**
  36620. * Deletes an animation range by name
  36621. * @param name Name of the animation range to delete
  36622. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36623. */
  36624. deleteRange(name: string, deleteFrames?: boolean): void;
  36625. /**
  36626. * Gets the animation range by name, or null if not defined
  36627. * @param name Name of the animation range
  36628. * @returns Nullable animation range
  36629. */
  36630. getRange(name: string): Nullable<AnimationRange>;
  36631. /**
  36632. * Gets the key frames from the animation
  36633. * @returns The key frames of the animation
  36634. */
  36635. getKeys(): Array<IAnimationKey>;
  36636. /**
  36637. * Gets the highest frame rate of the animation
  36638. * @returns Highest frame rate of the animation
  36639. */
  36640. getHighestFrame(): number;
  36641. /**
  36642. * Gets the easing function of the animation
  36643. * @returns Easing function of the animation
  36644. */
  36645. getEasingFunction(): IEasingFunction;
  36646. /**
  36647. * Sets the easing function of the animation
  36648. * @param easingFunction A custom mathematical formula for animation
  36649. */
  36650. setEasingFunction(easingFunction: EasingFunction): void;
  36651. /**
  36652. * Interpolates a scalar linearly
  36653. * @param startValue Start value of the animation curve
  36654. * @param endValue End value of the animation curve
  36655. * @param gradient Scalar amount to interpolate
  36656. * @returns Interpolated scalar value
  36657. */
  36658. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36659. /**
  36660. * Interpolates a scalar cubically
  36661. * @param startValue Start value of the animation curve
  36662. * @param outTangent End tangent of the animation
  36663. * @param endValue End value of the animation curve
  36664. * @param inTangent Start tangent of the animation curve
  36665. * @param gradient Scalar amount to interpolate
  36666. * @returns Interpolated scalar value
  36667. */
  36668. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36669. /**
  36670. * Interpolates a quaternion using a spherical linear interpolation
  36671. * @param startValue Start value of the animation curve
  36672. * @param endValue End value of the animation curve
  36673. * @param gradient Scalar amount to interpolate
  36674. * @returns Interpolated quaternion value
  36675. */
  36676. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36677. /**
  36678. * Interpolates a quaternion cubically
  36679. * @param startValue Start value of the animation curve
  36680. * @param outTangent End tangent of the animation curve
  36681. * @param endValue End value of the animation curve
  36682. * @param inTangent Start tangent of the animation curve
  36683. * @param gradient Scalar amount to interpolate
  36684. * @returns Interpolated quaternion value
  36685. */
  36686. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36687. /**
  36688. * Interpolates a Vector3 linearl
  36689. * @param startValue Start value of the animation curve
  36690. * @param endValue End value of the animation curve
  36691. * @param gradient Scalar amount to interpolate
  36692. * @returns Interpolated scalar value
  36693. */
  36694. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36695. /**
  36696. * Interpolates a Vector3 cubically
  36697. * @param startValue Start value of the animation curve
  36698. * @param outTangent End tangent of the animation
  36699. * @param endValue End value of the animation curve
  36700. * @param inTangent Start tangent of the animation curve
  36701. * @param gradient Scalar amount to interpolate
  36702. * @returns InterpolatedVector3 value
  36703. */
  36704. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36705. /**
  36706. * Interpolates a Vector2 linearly
  36707. * @param startValue Start value of the animation curve
  36708. * @param endValue End value of the animation curve
  36709. * @param gradient Scalar amount to interpolate
  36710. * @returns Interpolated Vector2 value
  36711. */
  36712. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36713. /**
  36714. * Interpolates a Vector2 cubically
  36715. * @param startValue Start value of the animation curve
  36716. * @param outTangent End tangent of the animation
  36717. * @param endValue End value of the animation curve
  36718. * @param inTangent Start tangent of the animation curve
  36719. * @param gradient Scalar amount to interpolate
  36720. * @returns Interpolated Vector2 value
  36721. */
  36722. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36723. /**
  36724. * Interpolates a size linearly
  36725. * @param startValue Start value of the animation curve
  36726. * @param endValue End value of the animation curve
  36727. * @param gradient Scalar amount to interpolate
  36728. * @returns Interpolated Size value
  36729. */
  36730. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36731. /**
  36732. * Interpolates a Color3 linearly
  36733. * @param startValue Start value of the animation curve
  36734. * @param endValue End value of the animation curve
  36735. * @param gradient Scalar amount to interpolate
  36736. * @returns Interpolated Color3 value
  36737. */
  36738. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36739. /**
  36740. * Interpolates a Color4 linearly
  36741. * @param startValue Start value of the animation curve
  36742. * @param endValue End value of the animation curve
  36743. * @param gradient Scalar amount to interpolate
  36744. * @returns Interpolated Color3 value
  36745. */
  36746. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36747. /**
  36748. * @hidden Internal use only
  36749. */
  36750. _getKeyValue(value: any): any;
  36751. /**
  36752. * @hidden Internal use only
  36753. */
  36754. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36755. /**
  36756. * Defines the function to use to interpolate matrices
  36757. * @param startValue defines the start matrix
  36758. * @param endValue defines the end matrix
  36759. * @param gradient defines the gradient between both matrices
  36760. * @param result defines an optional target matrix where to store the interpolation
  36761. * @returns the interpolated matrix
  36762. */
  36763. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36764. /**
  36765. * Makes a copy of the animation
  36766. * @returns Cloned animation
  36767. */
  36768. clone(): Animation;
  36769. /**
  36770. * Sets the key frames of the animation
  36771. * @param values The animation key frames to set
  36772. */
  36773. setKeys(values: Array<IAnimationKey>): void;
  36774. /**
  36775. * Serializes the animation to an object
  36776. * @returns Serialized object
  36777. */
  36778. serialize(): any;
  36779. /**
  36780. * Float animation type
  36781. */
  36782. static readonly ANIMATIONTYPE_FLOAT: number;
  36783. /**
  36784. * Vector3 animation type
  36785. */
  36786. static readonly ANIMATIONTYPE_VECTOR3: number;
  36787. /**
  36788. * Quaternion animation type
  36789. */
  36790. static readonly ANIMATIONTYPE_QUATERNION: number;
  36791. /**
  36792. * Matrix animation type
  36793. */
  36794. static readonly ANIMATIONTYPE_MATRIX: number;
  36795. /**
  36796. * Color3 animation type
  36797. */
  36798. static readonly ANIMATIONTYPE_COLOR3: number;
  36799. /**
  36800. * Color3 animation type
  36801. */
  36802. static readonly ANIMATIONTYPE_COLOR4: number;
  36803. /**
  36804. * Vector2 animation type
  36805. */
  36806. static readonly ANIMATIONTYPE_VECTOR2: number;
  36807. /**
  36808. * Size animation type
  36809. */
  36810. static readonly ANIMATIONTYPE_SIZE: number;
  36811. /**
  36812. * Relative Loop Mode
  36813. */
  36814. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36815. /**
  36816. * Cycle Loop Mode
  36817. */
  36818. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36819. /**
  36820. * Constant Loop Mode
  36821. */
  36822. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36823. /** @hidden */
  36824. static _UniversalLerp(left: any, right: any, amount: number): any;
  36825. /**
  36826. * Parses an animation object and creates an animation
  36827. * @param parsedAnimation Parsed animation object
  36828. * @returns Animation object
  36829. */
  36830. static Parse(parsedAnimation: any): Animation;
  36831. /**
  36832. * Appends the serialized animations from the source animations
  36833. * @param source Source containing the animations
  36834. * @param destination Target to store the animations
  36835. */
  36836. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36837. /**
  36838. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36839. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36840. * @param url defines the url to load from
  36841. * @returns a promise that will resolve to the new animation or an array of animations
  36842. */
  36843. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36844. /**
  36845. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36846. * @param snippetId defines the snippet to load
  36847. * @returns a promise that will resolve to the new animation or a new array of animations
  36848. */
  36849. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36850. }
  36851. }
  36852. declare module BABYLON {
  36853. /**
  36854. * Interface containing an array of animations
  36855. */
  36856. export interface IAnimatable {
  36857. /**
  36858. * Array of animations
  36859. */
  36860. animations: Nullable<Array<Animation>>;
  36861. }
  36862. }
  36863. declare module BABYLON {
  36864. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36865. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36866. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36867. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36868. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36869. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36870. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36871. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36872. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36873. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36874. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36875. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36876. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36877. /**
  36878. * Decorator used to define property that can be serialized as reference to a camera
  36879. * @param sourceName defines the name of the property to decorate
  36880. */
  36881. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36882. /**
  36883. * Class used to help serialization objects
  36884. */
  36885. export class SerializationHelper {
  36886. /** @hidden */
  36887. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36888. /** @hidden */
  36889. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36890. /** @hidden */
  36891. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36892. /** @hidden */
  36893. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36894. /**
  36895. * Appends the serialized animations from the source animations
  36896. * @param source Source containing the animations
  36897. * @param destination Target to store the animations
  36898. */
  36899. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36900. /**
  36901. * Static function used to serialized a specific entity
  36902. * @param entity defines the entity to serialize
  36903. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36904. * @returns a JSON compatible object representing the serialization of the entity
  36905. */
  36906. static Serialize<T>(entity: T, serializationObject?: any): any;
  36907. /**
  36908. * Creates a new entity from a serialization data object
  36909. * @param creationFunction defines a function used to instanciated the new entity
  36910. * @param source defines the source serialization data
  36911. * @param scene defines the hosting scene
  36912. * @param rootUrl defines the root url for resources
  36913. * @returns a new entity
  36914. */
  36915. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  36916. /**
  36917. * Clones an object
  36918. * @param creationFunction defines the function used to instanciate the new object
  36919. * @param source defines the source object
  36920. * @returns the cloned object
  36921. */
  36922. static Clone<T>(creationFunction: () => T, source: T): T;
  36923. /**
  36924. * Instanciates a new object based on a source one (some data will be shared between both object)
  36925. * @param creationFunction defines the function used to instanciate the new object
  36926. * @param source defines the source object
  36927. * @returns the new object
  36928. */
  36929. static Instanciate<T>(creationFunction: () => T, source: T): T;
  36930. }
  36931. }
  36932. declare module BABYLON {
  36933. /**
  36934. * Base class of all the textures in babylon.
  36935. * It groups all the common properties the materials, post process, lights... might need
  36936. * in order to make a correct use of the texture.
  36937. */
  36938. export class BaseTexture implements IAnimatable {
  36939. /**
  36940. * Default anisotropic filtering level for the application.
  36941. * It is set to 4 as a good tradeoff between perf and quality.
  36942. */
  36943. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  36944. /**
  36945. * Gets or sets the unique id of the texture
  36946. */
  36947. uniqueId: number;
  36948. /**
  36949. * Define the name of the texture.
  36950. */
  36951. name: string;
  36952. /**
  36953. * Gets or sets an object used to store user defined information.
  36954. */
  36955. metadata: any;
  36956. /**
  36957. * For internal use only. Please do not use.
  36958. */
  36959. reservedDataStore: any;
  36960. private _hasAlpha;
  36961. /**
  36962. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  36963. */
  36964. set hasAlpha(value: boolean);
  36965. get hasAlpha(): boolean;
  36966. /**
  36967. * Defines if the alpha value should be determined via the rgb values.
  36968. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  36969. */
  36970. getAlphaFromRGB: boolean;
  36971. /**
  36972. * Intensity or strength of the texture.
  36973. * It is commonly used by materials to fine tune the intensity of the texture
  36974. */
  36975. level: number;
  36976. /**
  36977. * Define the UV chanel to use starting from 0 and defaulting to 0.
  36978. * This is part of the texture as textures usually maps to one uv set.
  36979. */
  36980. coordinatesIndex: number;
  36981. protected _coordinatesMode: number;
  36982. /**
  36983. * How a texture is mapped.
  36984. *
  36985. * | Value | Type | Description |
  36986. * | ----- | ----------------------------------- | ----------- |
  36987. * | 0 | EXPLICIT_MODE | |
  36988. * | 1 | SPHERICAL_MODE | |
  36989. * | 2 | PLANAR_MODE | |
  36990. * | 3 | CUBIC_MODE | |
  36991. * | 4 | PROJECTION_MODE | |
  36992. * | 5 | SKYBOX_MODE | |
  36993. * | 6 | INVCUBIC_MODE | |
  36994. * | 7 | EQUIRECTANGULAR_MODE | |
  36995. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  36996. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  36997. */
  36998. set coordinatesMode(value: number);
  36999. get coordinatesMode(): number;
  37000. private _wrapU;
  37001. /**
  37002. * | Value | Type | Description |
  37003. * | ----- | ------------------ | ----------- |
  37004. * | 0 | CLAMP_ADDRESSMODE | |
  37005. * | 1 | WRAP_ADDRESSMODE | |
  37006. * | 2 | MIRROR_ADDRESSMODE | |
  37007. */
  37008. get wrapU(): number;
  37009. set wrapU(value: number);
  37010. private _wrapV;
  37011. /**
  37012. * | Value | Type | Description |
  37013. * | ----- | ------------------ | ----------- |
  37014. * | 0 | CLAMP_ADDRESSMODE | |
  37015. * | 1 | WRAP_ADDRESSMODE | |
  37016. * | 2 | MIRROR_ADDRESSMODE | |
  37017. */
  37018. get wrapV(): number;
  37019. set wrapV(value: number);
  37020. /**
  37021. * | Value | Type | Description |
  37022. * | ----- | ------------------ | ----------- |
  37023. * | 0 | CLAMP_ADDRESSMODE | |
  37024. * | 1 | WRAP_ADDRESSMODE | |
  37025. * | 2 | MIRROR_ADDRESSMODE | |
  37026. */
  37027. wrapR: number;
  37028. /**
  37029. * With compliant hardware and browser (supporting anisotropic filtering)
  37030. * this defines the level of anisotropic filtering in the texture.
  37031. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37032. */
  37033. anisotropicFilteringLevel: number;
  37034. /**
  37035. * Define if the texture is a cube texture or if false a 2d texture.
  37036. */
  37037. get isCube(): boolean;
  37038. set isCube(value: boolean);
  37039. /**
  37040. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37041. */
  37042. get is3D(): boolean;
  37043. set is3D(value: boolean);
  37044. /**
  37045. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37046. */
  37047. get is2DArray(): boolean;
  37048. set is2DArray(value: boolean);
  37049. private _gammaSpace;
  37050. /**
  37051. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37052. * HDR texture are usually stored in linear space.
  37053. * This only impacts the PBR and Background materials
  37054. */
  37055. get gammaSpace(): boolean;
  37056. set gammaSpace(gamma: boolean);
  37057. /**
  37058. * Gets or sets whether or not the texture contains RGBD data.
  37059. */
  37060. get isRGBD(): boolean;
  37061. set isRGBD(value: boolean);
  37062. /**
  37063. * Is Z inverted in the texture (useful in a cube texture).
  37064. */
  37065. invertZ: boolean;
  37066. /**
  37067. * Are mip maps generated for this texture or not.
  37068. */
  37069. get noMipmap(): boolean;
  37070. /**
  37071. * @hidden
  37072. */
  37073. lodLevelInAlpha: boolean;
  37074. /**
  37075. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37076. */
  37077. get lodGenerationOffset(): number;
  37078. set lodGenerationOffset(value: number);
  37079. /**
  37080. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37081. */
  37082. get lodGenerationScale(): number;
  37083. set lodGenerationScale(value: number);
  37084. /**
  37085. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37086. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37087. * average roughness values.
  37088. */
  37089. get linearSpecularLOD(): boolean;
  37090. set linearSpecularLOD(value: boolean);
  37091. /**
  37092. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37093. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37094. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37095. */
  37096. get irradianceTexture(): Nullable<BaseTexture>;
  37097. set irradianceTexture(value: Nullable<BaseTexture>);
  37098. /**
  37099. * Define if the texture is a render target.
  37100. */
  37101. isRenderTarget: boolean;
  37102. /**
  37103. * Define the unique id of the texture in the scene.
  37104. */
  37105. get uid(): string;
  37106. /** @hidden */
  37107. _prefiltered: boolean;
  37108. /**
  37109. * Return a string representation of the texture.
  37110. * @returns the texture as a string
  37111. */
  37112. toString(): string;
  37113. /**
  37114. * Get the class name of the texture.
  37115. * @returns "BaseTexture"
  37116. */
  37117. getClassName(): string;
  37118. /**
  37119. * Define the list of animation attached to the texture.
  37120. */
  37121. animations: Animation[];
  37122. /**
  37123. * An event triggered when the texture is disposed.
  37124. */
  37125. onDisposeObservable: Observable<BaseTexture>;
  37126. private _onDisposeObserver;
  37127. /**
  37128. * Callback triggered when the texture has been disposed.
  37129. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37130. */
  37131. set onDispose(callback: () => void);
  37132. /**
  37133. * Define the current state of the loading sequence when in delayed load mode.
  37134. */
  37135. delayLoadState: number;
  37136. protected _scene: Nullable<Scene>;
  37137. protected _engine: Nullable<ThinEngine>;
  37138. /** @hidden */
  37139. _texture: Nullable<InternalTexture>;
  37140. private _uid;
  37141. /**
  37142. * Define if the texture is preventinga material to render or not.
  37143. * If not and the texture is not ready, the engine will use a default black texture instead.
  37144. */
  37145. get isBlocking(): boolean;
  37146. /**
  37147. * Instantiates a new BaseTexture.
  37148. * Base class of all the textures in babylon.
  37149. * It groups all the common properties the materials, post process, lights... might need
  37150. * in order to make a correct use of the texture.
  37151. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37152. */
  37153. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37154. /**
  37155. * Get the scene the texture belongs to.
  37156. * @returns the scene or null if undefined
  37157. */
  37158. getScene(): Nullable<Scene>;
  37159. /** @hidden */
  37160. protected _getEngine(): Nullable<ThinEngine>;
  37161. /**
  37162. * Get the texture transform matrix used to offset tile the texture for istance.
  37163. * @returns the transformation matrix
  37164. */
  37165. getTextureMatrix(): Matrix;
  37166. /**
  37167. * Get the texture reflection matrix used to rotate/transform the reflection.
  37168. * @returns the reflection matrix
  37169. */
  37170. getReflectionTextureMatrix(): Matrix;
  37171. /**
  37172. * Get the underlying lower level texture from Babylon.
  37173. * @returns the insternal texture
  37174. */
  37175. getInternalTexture(): Nullable<InternalTexture>;
  37176. /**
  37177. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37178. * @returns true if ready or not blocking
  37179. */
  37180. isReadyOrNotBlocking(): boolean;
  37181. /**
  37182. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37183. * @returns true if fully ready
  37184. */
  37185. isReady(): boolean;
  37186. private _cachedSize;
  37187. /**
  37188. * Get the size of the texture.
  37189. * @returns the texture size.
  37190. */
  37191. getSize(): ISize;
  37192. /**
  37193. * Get the base size of the texture.
  37194. * It can be different from the size if the texture has been resized for POT for instance
  37195. * @returns the base size
  37196. */
  37197. getBaseSize(): ISize;
  37198. /**
  37199. * Update the sampling mode of the texture.
  37200. * Default is Trilinear mode.
  37201. *
  37202. * | Value | Type | Description |
  37203. * | ----- | ------------------ | ----------- |
  37204. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37205. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37206. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37207. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37208. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37209. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37210. * | 7 | NEAREST_LINEAR | |
  37211. * | 8 | NEAREST_NEAREST | |
  37212. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37213. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37214. * | 11 | LINEAR_LINEAR | |
  37215. * | 12 | LINEAR_NEAREST | |
  37216. *
  37217. * > _mag_: magnification filter (close to the viewer)
  37218. * > _min_: minification filter (far from the viewer)
  37219. * > _mip_: filter used between mip map levels
  37220. *@param samplingMode Define the new sampling mode of the texture
  37221. */
  37222. updateSamplingMode(samplingMode: number): void;
  37223. /**
  37224. * Scales the texture if is `canRescale()`
  37225. * @param ratio the resize factor we want to use to rescale
  37226. */
  37227. scale(ratio: number): void;
  37228. /**
  37229. * Get if the texture can rescale.
  37230. */
  37231. get canRescale(): boolean;
  37232. /** @hidden */
  37233. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37234. /** @hidden */
  37235. _rebuild(): void;
  37236. /**
  37237. * Triggers the load sequence in delayed load mode.
  37238. */
  37239. delayLoad(): void;
  37240. /**
  37241. * Clones the texture.
  37242. * @returns the cloned texture
  37243. */
  37244. clone(): Nullable<BaseTexture>;
  37245. /**
  37246. * Get the texture underlying type (INT, FLOAT...)
  37247. */
  37248. get textureType(): number;
  37249. /**
  37250. * Get the texture underlying format (RGB, RGBA...)
  37251. */
  37252. get textureFormat(): number;
  37253. /**
  37254. * Indicates that textures need to be re-calculated for all materials
  37255. */
  37256. protected _markAllSubMeshesAsTexturesDirty(): void;
  37257. /**
  37258. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37259. * This will returns an RGBA array buffer containing either in values (0-255) or
  37260. * float values (0-1) depending of the underlying buffer type.
  37261. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37262. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37263. * @param buffer defines a user defined buffer to fill with data (can be null)
  37264. * @returns The Array buffer containing the pixels data.
  37265. */
  37266. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37267. /**
  37268. * Release and destroy the underlying lower level texture aka internalTexture.
  37269. */
  37270. releaseInternalTexture(): void;
  37271. /** @hidden */
  37272. get _lodTextureHigh(): Nullable<BaseTexture>;
  37273. /** @hidden */
  37274. get _lodTextureMid(): Nullable<BaseTexture>;
  37275. /** @hidden */
  37276. get _lodTextureLow(): Nullable<BaseTexture>;
  37277. /**
  37278. * Dispose the texture and release its associated resources.
  37279. */
  37280. dispose(): void;
  37281. /**
  37282. * Serialize the texture into a JSON representation that can be parsed later on.
  37283. * @returns the JSON representation of the texture
  37284. */
  37285. serialize(): any;
  37286. /**
  37287. * Helper function to be called back once a list of texture contains only ready textures.
  37288. * @param textures Define the list of textures to wait for
  37289. * @param callback Define the callback triggered once the entire list will be ready
  37290. */
  37291. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37292. private static _isScene;
  37293. }
  37294. }
  37295. declare module BABYLON {
  37296. /**
  37297. * Options to be used when creating an effect.
  37298. */
  37299. export interface IEffectCreationOptions {
  37300. /**
  37301. * Atrributes that will be used in the shader.
  37302. */
  37303. attributes: string[];
  37304. /**
  37305. * Uniform varible names that will be set in the shader.
  37306. */
  37307. uniformsNames: string[];
  37308. /**
  37309. * Uniform buffer variable names that will be set in the shader.
  37310. */
  37311. uniformBuffersNames: string[];
  37312. /**
  37313. * Sampler texture variable names that will be set in the shader.
  37314. */
  37315. samplers: string[];
  37316. /**
  37317. * Define statements that will be set in the shader.
  37318. */
  37319. defines: any;
  37320. /**
  37321. * Possible fallbacks for this effect to improve performance when needed.
  37322. */
  37323. fallbacks: Nullable<IEffectFallbacks>;
  37324. /**
  37325. * Callback that will be called when the shader is compiled.
  37326. */
  37327. onCompiled: Nullable<(effect: Effect) => void>;
  37328. /**
  37329. * Callback that will be called if an error occurs during shader compilation.
  37330. */
  37331. onError: Nullable<(effect: Effect, errors: string) => void>;
  37332. /**
  37333. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37334. */
  37335. indexParameters?: any;
  37336. /**
  37337. * Max number of lights that can be used in the shader.
  37338. */
  37339. maxSimultaneousLights?: number;
  37340. /**
  37341. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37342. */
  37343. transformFeedbackVaryings?: Nullable<string[]>;
  37344. /**
  37345. * 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
  37346. */
  37347. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37348. /**
  37349. * Is this effect rendering to several color attachments ?
  37350. */
  37351. multiTarget?: boolean;
  37352. }
  37353. /**
  37354. * Effect containing vertex and fragment shader that can be executed on an object.
  37355. */
  37356. export class Effect implements IDisposable {
  37357. /**
  37358. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37359. */
  37360. static ShadersRepository: string;
  37361. /**
  37362. * Enable logging of the shader code when a compilation error occurs
  37363. */
  37364. static LogShaderCodeOnCompilationError: boolean;
  37365. /**
  37366. * Name of the effect.
  37367. */
  37368. name: any;
  37369. /**
  37370. * String container all the define statements that should be set on the shader.
  37371. */
  37372. defines: string;
  37373. /**
  37374. * Callback that will be called when the shader is compiled.
  37375. */
  37376. onCompiled: Nullable<(effect: Effect) => void>;
  37377. /**
  37378. * Callback that will be called if an error occurs during shader compilation.
  37379. */
  37380. onError: Nullable<(effect: Effect, errors: string) => void>;
  37381. /**
  37382. * Callback that will be called when effect is bound.
  37383. */
  37384. onBind: Nullable<(effect: Effect) => void>;
  37385. /**
  37386. * Unique ID of the effect.
  37387. */
  37388. uniqueId: number;
  37389. /**
  37390. * Observable that will be called when the shader is compiled.
  37391. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37392. */
  37393. onCompileObservable: Observable<Effect>;
  37394. /**
  37395. * Observable that will be called if an error occurs during shader compilation.
  37396. */
  37397. onErrorObservable: Observable<Effect>;
  37398. /** @hidden */
  37399. _onBindObservable: Nullable<Observable<Effect>>;
  37400. /**
  37401. * @hidden
  37402. * Specifies if the effect was previously ready
  37403. */
  37404. _wasPreviouslyReady: boolean;
  37405. /**
  37406. * Observable that will be called when effect is bound.
  37407. */
  37408. get onBindObservable(): Observable<Effect>;
  37409. /** @hidden */
  37410. _bonesComputationForcedToCPU: boolean;
  37411. /** @hidden */
  37412. _multiTarget: boolean;
  37413. private static _uniqueIdSeed;
  37414. private _engine;
  37415. private _uniformBuffersNames;
  37416. private _uniformBuffersNamesList;
  37417. private _uniformsNames;
  37418. private _samplerList;
  37419. private _samplers;
  37420. private _isReady;
  37421. private _compilationError;
  37422. private _allFallbacksProcessed;
  37423. private _attributesNames;
  37424. private _attributes;
  37425. private _attributeLocationByName;
  37426. private _uniforms;
  37427. /**
  37428. * Key for the effect.
  37429. * @hidden
  37430. */
  37431. _key: string;
  37432. private _indexParameters;
  37433. private _fallbacks;
  37434. private _vertexSourceCode;
  37435. private _fragmentSourceCode;
  37436. private _vertexSourceCodeOverride;
  37437. private _fragmentSourceCodeOverride;
  37438. private _transformFeedbackVaryings;
  37439. /**
  37440. * Compiled shader to webGL program.
  37441. * @hidden
  37442. */
  37443. _pipelineContext: Nullable<IPipelineContext>;
  37444. private _valueCache;
  37445. private static _baseCache;
  37446. /**
  37447. * Instantiates an effect.
  37448. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37449. * @param baseName Name of the effect.
  37450. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37451. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37452. * @param samplers List of sampler variables that will be passed to the shader.
  37453. * @param engine Engine to be used to render the effect
  37454. * @param defines Define statements to be added to the shader.
  37455. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37456. * @param onCompiled Callback that will be called when the shader is compiled.
  37457. * @param onError Callback that will be called if an error occurs during shader compilation.
  37458. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37459. */
  37460. 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);
  37461. private _useFinalCode;
  37462. /**
  37463. * Unique key for this effect
  37464. */
  37465. get key(): string;
  37466. /**
  37467. * If the effect has been compiled and prepared.
  37468. * @returns if the effect is compiled and prepared.
  37469. */
  37470. isReady(): boolean;
  37471. private _isReadyInternal;
  37472. /**
  37473. * The engine the effect was initialized with.
  37474. * @returns the engine.
  37475. */
  37476. getEngine(): Engine;
  37477. /**
  37478. * The pipeline context for this effect
  37479. * @returns the associated pipeline context
  37480. */
  37481. getPipelineContext(): Nullable<IPipelineContext>;
  37482. /**
  37483. * The set of names of attribute variables for the shader.
  37484. * @returns An array of attribute names.
  37485. */
  37486. getAttributesNames(): string[];
  37487. /**
  37488. * Returns the attribute at the given index.
  37489. * @param index The index of the attribute.
  37490. * @returns The location of the attribute.
  37491. */
  37492. getAttributeLocation(index: number): number;
  37493. /**
  37494. * Returns the attribute based on the name of the variable.
  37495. * @param name of the attribute to look up.
  37496. * @returns the attribute location.
  37497. */
  37498. getAttributeLocationByName(name: string): number;
  37499. /**
  37500. * The number of attributes.
  37501. * @returns the numnber of attributes.
  37502. */
  37503. getAttributesCount(): number;
  37504. /**
  37505. * Gets the index of a uniform variable.
  37506. * @param uniformName of the uniform to look up.
  37507. * @returns the index.
  37508. */
  37509. getUniformIndex(uniformName: string): number;
  37510. /**
  37511. * Returns the attribute based on the name of the variable.
  37512. * @param uniformName of the uniform to look up.
  37513. * @returns the location of the uniform.
  37514. */
  37515. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37516. /**
  37517. * Returns an array of sampler variable names
  37518. * @returns The array of sampler variable names.
  37519. */
  37520. getSamplers(): string[];
  37521. /**
  37522. * Returns an array of uniform variable names
  37523. * @returns The array of uniform variable names.
  37524. */
  37525. getUniformNames(): string[];
  37526. /**
  37527. * Returns an array of uniform buffer variable names
  37528. * @returns The array of uniform buffer variable names.
  37529. */
  37530. getUniformBuffersNames(): string[];
  37531. /**
  37532. * Returns the index parameters used to create the effect
  37533. * @returns The index parameters object
  37534. */
  37535. getIndexParameters(): any;
  37536. /**
  37537. * The error from the last compilation.
  37538. * @returns the error string.
  37539. */
  37540. getCompilationError(): string;
  37541. /**
  37542. * Gets a boolean indicating that all fallbacks were used during compilation
  37543. * @returns true if all fallbacks were used
  37544. */
  37545. allFallbacksProcessed(): boolean;
  37546. /**
  37547. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37548. * @param func The callback to be used.
  37549. */
  37550. executeWhenCompiled(func: (effect: Effect) => void): void;
  37551. private _checkIsReady;
  37552. private _loadShader;
  37553. /**
  37554. * Gets the vertex shader source code of this effect
  37555. */
  37556. get vertexSourceCode(): string;
  37557. /**
  37558. * Gets the fragment shader source code of this effect
  37559. */
  37560. get fragmentSourceCode(): string;
  37561. /**
  37562. * Recompiles the webGL program
  37563. * @param vertexSourceCode The source code for the vertex shader.
  37564. * @param fragmentSourceCode The source code for the fragment shader.
  37565. * @param onCompiled Callback called when completed.
  37566. * @param onError Callback called on error.
  37567. * @hidden
  37568. */
  37569. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37570. /**
  37571. * Prepares the effect
  37572. * @hidden
  37573. */
  37574. _prepareEffect(): void;
  37575. private _getShaderCodeAndErrorLine;
  37576. private _processCompilationErrors;
  37577. /**
  37578. * Checks if the effect is supported. (Must be called after compilation)
  37579. */
  37580. get isSupported(): boolean;
  37581. /**
  37582. * Binds a texture to the engine to be used as output of the shader.
  37583. * @param channel Name of the output variable.
  37584. * @param texture Texture to bind.
  37585. * @hidden
  37586. */
  37587. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37588. /**
  37589. * Sets a texture on the engine to be used in the shader.
  37590. * @param channel Name of the sampler variable.
  37591. * @param texture Texture to set.
  37592. */
  37593. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37594. /**
  37595. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37596. * @param channel Name of the sampler variable.
  37597. * @param texture Texture to set.
  37598. */
  37599. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37600. /**
  37601. * Sets an array of textures on the engine to be used in the shader.
  37602. * @param channel Name of the variable.
  37603. * @param textures Textures to set.
  37604. */
  37605. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37606. /**
  37607. * 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)
  37608. * @param channel Name of the sampler variable.
  37609. * @param postProcess Post process to get the input texture from.
  37610. */
  37611. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  37612. /**
  37613. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  37614. * 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)
  37615. * @param channel Name of the sampler variable.
  37616. * @param postProcess Post process to get the output texture from.
  37617. */
  37618. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  37619. /** @hidden */
  37620. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  37621. /** @hidden */
  37622. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  37623. /** @hidden */
  37624. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  37625. /** @hidden */
  37626. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  37627. /**
  37628. * Binds a buffer to a uniform.
  37629. * @param buffer Buffer to bind.
  37630. * @param name Name of the uniform variable to bind to.
  37631. */
  37632. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  37633. /**
  37634. * Binds block to a uniform.
  37635. * @param blockName Name of the block to bind.
  37636. * @param index Index to bind.
  37637. */
  37638. bindUniformBlock(blockName: string, index: number): void;
  37639. /**
  37640. * Sets an interger value on a uniform variable.
  37641. * @param uniformName Name of the variable.
  37642. * @param value Value to be set.
  37643. * @returns this effect.
  37644. */
  37645. setInt(uniformName: string, value: number): Effect;
  37646. /**
  37647. * Sets an int array on a uniform variable.
  37648. * @param uniformName Name of the variable.
  37649. * @param array array to be set.
  37650. * @returns this effect.
  37651. */
  37652. setIntArray(uniformName: string, array: Int32Array): Effect;
  37653. /**
  37654. * 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)
  37655. * @param uniformName Name of the variable.
  37656. * @param array array to be set.
  37657. * @returns this effect.
  37658. */
  37659. setIntArray2(uniformName: string, array: Int32Array): Effect;
  37660. /**
  37661. * 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)
  37662. * @param uniformName Name of the variable.
  37663. * @param array array to be set.
  37664. * @returns this effect.
  37665. */
  37666. setIntArray3(uniformName: string, array: Int32Array): Effect;
  37667. /**
  37668. * 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)
  37669. * @param uniformName Name of the variable.
  37670. * @param array array to be set.
  37671. * @returns this effect.
  37672. */
  37673. setIntArray4(uniformName: string, array: Int32Array): Effect;
  37674. /**
  37675. * Sets an float array on a uniform variable.
  37676. * @param uniformName Name of the variable.
  37677. * @param array array to be set.
  37678. * @returns this effect.
  37679. */
  37680. setFloatArray(uniformName: string, array: Float32Array): Effect;
  37681. /**
  37682. * 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)
  37683. * @param uniformName Name of the variable.
  37684. * @param array array to be set.
  37685. * @returns this effect.
  37686. */
  37687. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  37688. /**
  37689. * 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)
  37690. * @param uniformName Name of the variable.
  37691. * @param array array to be set.
  37692. * @returns this effect.
  37693. */
  37694. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  37695. /**
  37696. * 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)
  37697. * @param uniformName Name of the variable.
  37698. * @param array array to be set.
  37699. * @returns this effect.
  37700. */
  37701. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  37702. /**
  37703. * Sets an array on a uniform variable.
  37704. * @param uniformName Name of the variable.
  37705. * @param array array to be set.
  37706. * @returns this effect.
  37707. */
  37708. setArray(uniformName: string, array: number[]): Effect;
  37709. /**
  37710. * 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)
  37711. * @param uniformName Name of the variable.
  37712. * @param array array to be set.
  37713. * @returns this effect.
  37714. */
  37715. setArray2(uniformName: string, array: number[]): Effect;
  37716. /**
  37717. * 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)
  37718. * @param uniformName Name of the variable.
  37719. * @param array array to be set.
  37720. * @returns this effect.
  37721. */
  37722. setArray3(uniformName: string, array: number[]): Effect;
  37723. /**
  37724. * 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)
  37725. * @param uniformName Name of the variable.
  37726. * @param array array to be set.
  37727. * @returns this effect.
  37728. */
  37729. setArray4(uniformName: string, array: number[]): Effect;
  37730. /**
  37731. * Sets matrices on a uniform variable.
  37732. * @param uniformName Name of the variable.
  37733. * @param matrices matrices to be set.
  37734. * @returns this effect.
  37735. */
  37736. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  37737. /**
  37738. * Sets matrix on a uniform variable.
  37739. * @param uniformName Name of the variable.
  37740. * @param matrix matrix to be set.
  37741. * @returns this effect.
  37742. */
  37743. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  37744. /**
  37745. * 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)
  37746. * @param uniformName Name of the variable.
  37747. * @param matrix matrix to be set.
  37748. * @returns this effect.
  37749. */
  37750. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37751. /**
  37752. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  37753. * @param uniformName Name of the variable.
  37754. * @param matrix matrix to be set.
  37755. * @returns this effect.
  37756. */
  37757. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37758. /**
  37759. * Sets a float on a uniform variable.
  37760. * @param uniformName Name of the variable.
  37761. * @param value value to be set.
  37762. * @returns this effect.
  37763. */
  37764. setFloat(uniformName: string, value: number): Effect;
  37765. /**
  37766. * Sets a boolean on a uniform variable.
  37767. * @param uniformName Name of the variable.
  37768. * @param bool value to be set.
  37769. * @returns this effect.
  37770. */
  37771. setBool(uniformName: string, bool: boolean): Effect;
  37772. /**
  37773. * Sets a Vector2 on a uniform variable.
  37774. * @param uniformName Name of the variable.
  37775. * @param vector2 vector2 to be set.
  37776. * @returns this effect.
  37777. */
  37778. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  37779. /**
  37780. * Sets a float2 on a uniform variable.
  37781. * @param uniformName Name of the variable.
  37782. * @param x First float in float2.
  37783. * @param y Second float in float2.
  37784. * @returns this effect.
  37785. */
  37786. setFloat2(uniformName: string, x: number, y: number): Effect;
  37787. /**
  37788. * Sets a Vector3 on a uniform variable.
  37789. * @param uniformName Name of the variable.
  37790. * @param vector3 Value to be set.
  37791. * @returns this effect.
  37792. */
  37793. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  37794. /**
  37795. * Sets a float3 on a uniform variable.
  37796. * @param uniformName Name of the variable.
  37797. * @param x First float in float3.
  37798. * @param y Second float in float3.
  37799. * @param z Third float in float3.
  37800. * @returns this effect.
  37801. */
  37802. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  37803. /**
  37804. * Sets a Vector4 on a uniform variable.
  37805. * @param uniformName Name of the variable.
  37806. * @param vector4 Value to be set.
  37807. * @returns this effect.
  37808. */
  37809. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  37810. /**
  37811. * Sets a float4 on a uniform variable.
  37812. * @param uniformName Name of the variable.
  37813. * @param x First float in float4.
  37814. * @param y Second float in float4.
  37815. * @param z Third float in float4.
  37816. * @param w Fourth float in float4.
  37817. * @returns this effect.
  37818. */
  37819. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  37820. /**
  37821. * Sets a Color3 on a uniform variable.
  37822. * @param uniformName Name of the variable.
  37823. * @param color3 Value to be set.
  37824. * @returns this effect.
  37825. */
  37826. setColor3(uniformName: string, color3: IColor3Like): Effect;
  37827. /**
  37828. * Sets a Color4 on a uniform variable.
  37829. * @param uniformName Name of the variable.
  37830. * @param color3 Value to be set.
  37831. * @param alpha Alpha value to be set.
  37832. * @returns this effect.
  37833. */
  37834. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  37835. /**
  37836. * Sets a Color4 on a uniform variable
  37837. * @param uniformName defines the name of the variable
  37838. * @param color4 defines the value to be set
  37839. * @returns this effect.
  37840. */
  37841. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  37842. /** Release all associated resources */
  37843. dispose(): void;
  37844. /**
  37845. * This function will add a new shader to the shader store
  37846. * @param name the name of the shader
  37847. * @param pixelShader optional pixel shader content
  37848. * @param vertexShader optional vertex shader content
  37849. */
  37850. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  37851. /**
  37852. * Store of each shader (The can be looked up using effect.key)
  37853. */
  37854. static ShadersStore: {
  37855. [key: string]: string;
  37856. };
  37857. /**
  37858. * Store of each included file for a shader (The can be looked up using effect.key)
  37859. */
  37860. static IncludesShadersStore: {
  37861. [key: string]: string;
  37862. };
  37863. /**
  37864. * Resets the cache of effects.
  37865. */
  37866. static ResetCache(): void;
  37867. }
  37868. }
  37869. declare module BABYLON {
  37870. /**
  37871. * Interface used to describe the capabilities of the engine relatively to the current browser
  37872. */
  37873. export interface EngineCapabilities {
  37874. /** Maximum textures units per fragment shader */
  37875. maxTexturesImageUnits: number;
  37876. /** Maximum texture units per vertex shader */
  37877. maxVertexTextureImageUnits: number;
  37878. /** Maximum textures units in the entire pipeline */
  37879. maxCombinedTexturesImageUnits: number;
  37880. /** Maximum texture size */
  37881. maxTextureSize: number;
  37882. /** Maximum texture samples */
  37883. maxSamples?: number;
  37884. /** Maximum cube texture size */
  37885. maxCubemapTextureSize: number;
  37886. /** Maximum render texture size */
  37887. maxRenderTextureSize: number;
  37888. /** Maximum number of vertex attributes */
  37889. maxVertexAttribs: number;
  37890. /** Maximum number of varyings */
  37891. maxVaryingVectors: number;
  37892. /** Maximum number of uniforms per vertex shader */
  37893. maxVertexUniformVectors: number;
  37894. /** Maximum number of uniforms per fragment shader */
  37895. maxFragmentUniformVectors: number;
  37896. /** Defines if standard derivates (dx/dy) are supported */
  37897. standardDerivatives: boolean;
  37898. /** Defines if s3tc texture compression is supported */
  37899. s3tc?: WEBGL_compressed_texture_s3tc;
  37900. /** Defines if pvrtc texture compression is supported */
  37901. pvrtc: any;
  37902. /** Defines if etc1 texture compression is supported */
  37903. etc1: any;
  37904. /** Defines if etc2 texture compression is supported */
  37905. etc2: any;
  37906. /** Defines if astc texture compression is supported */
  37907. astc: any;
  37908. /** Defines if bptc texture compression is supported */
  37909. bptc: any;
  37910. /** Defines if float textures are supported */
  37911. textureFloat: boolean;
  37912. /** Defines if vertex array objects are supported */
  37913. vertexArrayObject: boolean;
  37914. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  37915. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  37916. /** Gets the maximum level of anisotropy supported */
  37917. maxAnisotropy: number;
  37918. /** Defines if instancing is supported */
  37919. instancedArrays: boolean;
  37920. /** Defines if 32 bits indices are supported */
  37921. uintIndices: boolean;
  37922. /** Defines if high precision shaders are supported */
  37923. highPrecisionShaderSupported: boolean;
  37924. /** Defines if depth reading in the fragment shader is supported */
  37925. fragmentDepthSupported: boolean;
  37926. /** Defines if float texture linear filtering is supported*/
  37927. textureFloatLinearFiltering: boolean;
  37928. /** Defines if rendering to float textures is supported */
  37929. textureFloatRender: boolean;
  37930. /** Defines if half float textures are supported*/
  37931. textureHalfFloat: boolean;
  37932. /** Defines if half float texture linear filtering is supported*/
  37933. textureHalfFloatLinearFiltering: boolean;
  37934. /** Defines if rendering to half float textures is supported */
  37935. textureHalfFloatRender: boolean;
  37936. /** Defines if textureLOD shader command is supported */
  37937. textureLOD: boolean;
  37938. /** Defines if draw buffers extension is supported */
  37939. drawBuffersExtension: boolean;
  37940. /** Defines if depth textures are supported */
  37941. depthTextureExtension: boolean;
  37942. /** Defines if float color buffer are supported */
  37943. colorBufferFloat: boolean;
  37944. /** Gets disjoint timer query extension (null if not supported) */
  37945. timerQuery?: EXT_disjoint_timer_query;
  37946. /** Defines if timestamp can be used with timer query */
  37947. canUseTimestampForTimerQuery: boolean;
  37948. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  37949. multiview?: any;
  37950. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  37951. oculusMultiview?: any;
  37952. /** Function used to let the system compiles shaders in background */
  37953. parallelShaderCompile?: {
  37954. COMPLETION_STATUS_KHR: number;
  37955. };
  37956. /** Max number of texture samples for MSAA */
  37957. maxMSAASamples: number;
  37958. /** Defines if the blend min max extension is supported */
  37959. blendMinMax: boolean;
  37960. }
  37961. }
  37962. declare module BABYLON {
  37963. /**
  37964. * @hidden
  37965. **/
  37966. export class DepthCullingState {
  37967. private _isDepthTestDirty;
  37968. private _isDepthMaskDirty;
  37969. private _isDepthFuncDirty;
  37970. private _isCullFaceDirty;
  37971. private _isCullDirty;
  37972. private _isZOffsetDirty;
  37973. private _isFrontFaceDirty;
  37974. private _depthTest;
  37975. private _depthMask;
  37976. private _depthFunc;
  37977. private _cull;
  37978. private _cullFace;
  37979. private _zOffset;
  37980. private _frontFace;
  37981. /**
  37982. * Initializes the state.
  37983. */
  37984. constructor();
  37985. get isDirty(): boolean;
  37986. get zOffset(): number;
  37987. set zOffset(value: number);
  37988. get cullFace(): Nullable<number>;
  37989. set cullFace(value: Nullable<number>);
  37990. get cull(): Nullable<boolean>;
  37991. set cull(value: Nullable<boolean>);
  37992. get depthFunc(): Nullable<number>;
  37993. set depthFunc(value: Nullable<number>);
  37994. get depthMask(): boolean;
  37995. set depthMask(value: boolean);
  37996. get depthTest(): boolean;
  37997. set depthTest(value: boolean);
  37998. get frontFace(): Nullable<number>;
  37999. set frontFace(value: Nullable<number>);
  38000. reset(): void;
  38001. apply(gl: WebGLRenderingContext): void;
  38002. }
  38003. }
  38004. declare module BABYLON {
  38005. /**
  38006. * @hidden
  38007. **/
  38008. export class StencilState {
  38009. /** 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 */
  38010. static readonly ALWAYS: number;
  38011. /** Passed to stencilOperation to specify that stencil value must be kept */
  38012. static readonly KEEP: number;
  38013. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38014. static readonly REPLACE: number;
  38015. private _isStencilTestDirty;
  38016. private _isStencilMaskDirty;
  38017. private _isStencilFuncDirty;
  38018. private _isStencilOpDirty;
  38019. private _stencilTest;
  38020. private _stencilMask;
  38021. private _stencilFunc;
  38022. private _stencilFuncRef;
  38023. private _stencilFuncMask;
  38024. private _stencilOpStencilFail;
  38025. private _stencilOpDepthFail;
  38026. private _stencilOpStencilDepthPass;
  38027. get isDirty(): boolean;
  38028. get stencilFunc(): number;
  38029. set stencilFunc(value: number);
  38030. get stencilFuncRef(): number;
  38031. set stencilFuncRef(value: number);
  38032. get stencilFuncMask(): number;
  38033. set stencilFuncMask(value: number);
  38034. get stencilOpStencilFail(): number;
  38035. set stencilOpStencilFail(value: number);
  38036. get stencilOpDepthFail(): number;
  38037. set stencilOpDepthFail(value: number);
  38038. get stencilOpStencilDepthPass(): number;
  38039. set stencilOpStencilDepthPass(value: number);
  38040. get stencilMask(): number;
  38041. set stencilMask(value: number);
  38042. get stencilTest(): boolean;
  38043. set stencilTest(value: boolean);
  38044. constructor();
  38045. reset(): void;
  38046. apply(gl: WebGLRenderingContext): void;
  38047. }
  38048. }
  38049. declare module BABYLON {
  38050. /**
  38051. * @hidden
  38052. **/
  38053. export class AlphaState {
  38054. private _isAlphaBlendDirty;
  38055. private _isBlendFunctionParametersDirty;
  38056. private _isBlendEquationParametersDirty;
  38057. private _isBlendConstantsDirty;
  38058. private _alphaBlend;
  38059. private _blendFunctionParameters;
  38060. private _blendEquationParameters;
  38061. private _blendConstants;
  38062. /**
  38063. * Initializes the state.
  38064. */
  38065. constructor();
  38066. get isDirty(): boolean;
  38067. get alphaBlend(): boolean;
  38068. set alphaBlend(value: boolean);
  38069. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38070. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38071. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38072. reset(): void;
  38073. apply(gl: WebGLRenderingContext): void;
  38074. }
  38075. }
  38076. declare module BABYLON {
  38077. /** @hidden */
  38078. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38079. attributeProcessor(attribute: string): string;
  38080. varyingProcessor(varying: string, isFragment: boolean): string;
  38081. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38082. }
  38083. }
  38084. declare module BABYLON {
  38085. /**
  38086. * Interface for attribute information associated with buffer instanciation
  38087. */
  38088. export interface InstancingAttributeInfo {
  38089. /**
  38090. * Name of the GLSL attribute
  38091. * if attribute index is not specified, this is used to retrieve the index from the effect
  38092. */
  38093. attributeName: string;
  38094. /**
  38095. * Index/offset of the attribute in the vertex shader
  38096. * if not specified, this will be computes from the name.
  38097. */
  38098. index?: number;
  38099. /**
  38100. * size of the attribute, 1, 2, 3 or 4
  38101. */
  38102. attributeSize: number;
  38103. /**
  38104. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38105. */
  38106. offset: number;
  38107. /**
  38108. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38109. * default to 1
  38110. */
  38111. divisor?: number;
  38112. /**
  38113. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38114. * default is FLOAT
  38115. */
  38116. attributeType?: number;
  38117. /**
  38118. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38119. */
  38120. normalized?: boolean;
  38121. }
  38122. }
  38123. declare module BABYLON {
  38124. interface ThinEngine {
  38125. /**
  38126. * Update a video texture
  38127. * @param texture defines the texture to update
  38128. * @param video defines the video element to use
  38129. * @param invertY defines if data must be stored with Y axis inverted
  38130. */
  38131. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38132. }
  38133. }
  38134. declare module BABYLON {
  38135. interface ThinEngine {
  38136. /**
  38137. * Creates a dynamic texture
  38138. * @param width defines the width of the texture
  38139. * @param height defines the height of the texture
  38140. * @param generateMipMaps defines if the engine should generate the mip levels
  38141. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38142. * @returns the dynamic texture inside an InternalTexture
  38143. */
  38144. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38145. /**
  38146. * Update the content of a dynamic texture
  38147. * @param texture defines the texture to update
  38148. * @param canvas defines the canvas containing the source
  38149. * @param invertY defines if data must be stored with Y axis inverted
  38150. * @param premulAlpha defines if alpha is stored as premultiplied
  38151. * @param format defines the format of the data
  38152. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38153. */
  38154. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38155. }
  38156. }
  38157. declare module BABYLON {
  38158. /**
  38159. * Settings for finer control over video usage
  38160. */
  38161. export interface VideoTextureSettings {
  38162. /**
  38163. * Applies `autoplay` to video, if specified
  38164. */
  38165. autoPlay?: boolean;
  38166. /**
  38167. * Applies `muted` to video, if specified
  38168. */
  38169. muted?: boolean;
  38170. /**
  38171. * Applies `loop` to video, if specified
  38172. */
  38173. loop?: boolean;
  38174. /**
  38175. * Automatically updates internal texture from video at every frame in the render loop
  38176. */
  38177. autoUpdateTexture: boolean;
  38178. /**
  38179. * Image src displayed during the video loading or until the user interacts with the video.
  38180. */
  38181. poster?: string;
  38182. }
  38183. /**
  38184. * If you want to display a video in your scene, this is the special texture for that.
  38185. * This special texture works similar to other textures, with the exception of a few parameters.
  38186. * @see https://doc.babylonjs.com/how_to/video_texture
  38187. */
  38188. export class VideoTexture extends Texture {
  38189. /**
  38190. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38191. */
  38192. readonly autoUpdateTexture: boolean;
  38193. /**
  38194. * The video instance used by the texture internally
  38195. */
  38196. readonly video: HTMLVideoElement;
  38197. private _onUserActionRequestedObservable;
  38198. /**
  38199. * Event triggerd when a dom action is required by the user to play the video.
  38200. * This happens due to recent changes in browser policies preventing video to auto start.
  38201. */
  38202. get onUserActionRequestedObservable(): Observable<Texture>;
  38203. private _generateMipMaps;
  38204. private _stillImageCaptured;
  38205. private _displayingPosterTexture;
  38206. private _settings;
  38207. private _createInternalTextureOnEvent;
  38208. private _frameId;
  38209. private _currentSrc;
  38210. /**
  38211. * Creates a video texture.
  38212. * If you want to display a video in your scene, this is the special texture for that.
  38213. * This special texture works similar to other textures, with the exception of a few parameters.
  38214. * @see https://doc.babylonjs.com/how_to/video_texture
  38215. * @param name optional name, will detect from video source, if not defined
  38216. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38217. * @param scene is obviously the current scene.
  38218. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38219. * @param invertY is false by default but can be used to invert video on Y axis
  38220. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38221. * @param settings allows finer control over video usage
  38222. */
  38223. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38224. private _getName;
  38225. private _getVideo;
  38226. private _createInternalTexture;
  38227. private reset;
  38228. /**
  38229. * @hidden Internal method to initiate `update`.
  38230. */
  38231. _rebuild(): void;
  38232. /**
  38233. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38234. */
  38235. update(): void;
  38236. /**
  38237. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38238. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38239. */
  38240. updateTexture(isVisible: boolean): void;
  38241. protected _updateInternalTexture: () => void;
  38242. /**
  38243. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38244. * @param url New url.
  38245. */
  38246. updateURL(url: string): void;
  38247. /**
  38248. * Clones the texture.
  38249. * @returns the cloned texture
  38250. */
  38251. clone(): VideoTexture;
  38252. /**
  38253. * Dispose the texture and release its associated resources.
  38254. */
  38255. dispose(): void;
  38256. /**
  38257. * Creates a video texture straight from a stream.
  38258. * @param scene Define the scene the texture should be created in
  38259. * @param stream Define the stream the texture should be created from
  38260. * @returns The created video texture as a promise
  38261. */
  38262. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38263. /**
  38264. * Creates a video texture straight from your WebCam video feed.
  38265. * @param scene Define the scene the texture should be created in
  38266. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38267. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38268. * @returns The created video texture as a promise
  38269. */
  38270. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38271. minWidth: number;
  38272. maxWidth: number;
  38273. minHeight: number;
  38274. maxHeight: number;
  38275. deviceId: string;
  38276. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38277. /**
  38278. * Creates a video texture straight from your WebCam video feed.
  38279. * @param scene Define the scene the texture should be created in
  38280. * @param onReady Define a callback to triggered once the texture will be ready
  38281. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38282. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38283. */
  38284. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38285. minWidth: number;
  38286. maxWidth: number;
  38287. minHeight: number;
  38288. maxHeight: number;
  38289. deviceId: string;
  38290. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38291. }
  38292. }
  38293. declare module BABYLON {
  38294. /**
  38295. * Defines the interface used by objects working like Scene
  38296. * @hidden
  38297. */
  38298. export interface ISceneLike {
  38299. _addPendingData(data: any): void;
  38300. _removePendingData(data: any): void;
  38301. offlineProvider: IOfflineProvider;
  38302. }
  38303. /**
  38304. * Information about the current host
  38305. */
  38306. export interface HostInformation {
  38307. /**
  38308. * Defines if the current host is a mobile
  38309. */
  38310. isMobile: boolean;
  38311. }
  38312. /** Interface defining initialization parameters for Engine class */
  38313. export interface EngineOptions extends WebGLContextAttributes {
  38314. /**
  38315. * Defines if the engine should no exceed a specified device ratio
  38316. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38317. */
  38318. limitDeviceRatio?: number;
  38319. /**
  38320. * Defines if webvr should be enabled automatically
  38321. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38322. */
  38323. autoEnableWebVR?: boolean;
  38324. /**
  38325. * Defines if webgl2 should be turned off even if supported
  38326. * @see https://doc.babylonjs.com/features/webgl2
  38327. */
  38328. disableWebGL2Support?: boolean;
  38329. /**
  38330. * Defines if webaudio should be initialized as well
  38331. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38332. */
  38333. audioEngine?: boolean;
  38334. /**
  38335. * Defines if animations should run using a deterministic lock step
  38336. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38337. */
  38338. deterministicLockstep?: boolean;
  38339. /** Defines the maximum steps to use with deterministic lock step mode */
  38340. lockstepMaxSteps?: number;
  38341. /** Defines the seconds between each deterministic lock step */
  38342. timeStep?: number;
  38343. /**
  38344. * Defines that engine should ignore context lost events
  38345. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38346. */
  38347. doNotHandleContextLost?: boolean;
  38348. /**
  38349. * Defines that engine should ignore modifying touch action attribute and style
  38350. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38351. */
  38352. doNotHandleTouchAction?: boolean;
  38353. /**
  38354. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38355. */
  38356. useHighPrecisionFloats?: boolean;
  38357. /**
  38358. * Make the canvas XR Compatible for XR sessions
  38359. */
  38360. xrCompatible?: boolean;
  38361. /**
  38362. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38363. */
  38364. useHighPrecisionMatrix?: boolean;
  38365. /**
  38366. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38367. */
  38368. failIfMajorPerformanceCaveat?: boolean;
  38369. }
  38370. /**
  38371. * The base engine class (root of all engines)
  38372. */
  38373. export class ThinEngine {
  38374. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38375. static ExceptionList: ({
  38376. key: string;
  38377. capture: string;
  38378. captureConstraint: number;
  38379. targets: string[];
  38380. } | {
  38381. key: string;
  38382. capture: null;
  38383. captureConstraint: null;
  38384. targets: string[];
  38385. })[];
  38386. /** @hidden */
  38387. static _TextureLoaders: IInternalTextureLoader[];
  38388. /**
  38389. * Returns the current npm package of the sdk
  38390. */
  38391. static get NpmPackage(): string;
  38392. /**
  38393. * Returns the current version of the framework
  38394. */
  38395. static get Version(): string;
  38396. /**
  38397. * Returns a string describing the current engine
  38398. */
  38399. get description(): string;
  38400. /**
  38401. * Gets or sets the epsilon value used by collision engine
  38402. */
  38403. static CollisionsEpsilon: number;
  38404. /**
  38405. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38406. */
  38407. static get ShadersRepository(): string;
  38408. static set ShadersRepository(value: string);
  38409. /** @hidden */
  38410. _shaderProcessor: IShaderProcessor;
  38411. /**
  38412. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38413. */
  38414. forcePOTTextures: boolean;
  38415. /**
  38416. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38417. */
  38418. isFullscreen: boolean;
  38419. /**
  38420. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38421. */
  38422. cullBackFaces: boolean;
  38423. /**
  38424. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38425. */
  38426. renderEvenInBackground: boolean;
  38427. /**
  38428. * Gets or sets a boolean indicating that cache can be kept between frames
  38429. */
  38430. preventCacheWipeBetweenFrames: boolean;
  38431. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38432. validateShaderPrograms: boolean;
  38433. /**
  38434. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38435. * This can provide greater z depth for distant objects.
  38436. */
  38437. useReverseDepthBuffer: boolean;
  38438. /**
  38439. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38440. */
  38441. disableUniformBuffers: boolean;
  38442. /** @hidden */
  38443. _uniformBuffers: UniformBuffer[];
  38444. /**
  38445. * Gets a boolean indicating that the engine supports uniform buffers
  38446. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38447. */
  38448. get supportsUniformBuffers(): boolean;
  38449. /** @hidden */
  38450. _gl: WebGLRenderingContext;
  38451. /** @hidden */
  38452. _webGLVersion: number;
  38453. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38454. protected _windowIsBackground: boolean;
  38455. protected _creationOptions: EngineOptions;
  38456. protected _highPrecisionShadersAllowed: boolean;
  38457. /** @hidden */
  38458. get _shouldUseHighPrecisionShader(): boolean;
  38459. /**
  38460. * Gets a boolean indicating that only power of 2 textures are supported
  38461. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38462. */
  38463. get needPOTTextures(): boolean;
  38464. /** @hidden */
  38465. _badOS: boolean;
  38466. /** @hidden */
  38467. _badDesktopOS: boolean;
  38468. private _hardwareScalingLevel;
  38469. /** @hidden */
  38470. _caps: EngineCapabilities;
  38471. private _isStencilEnable;
  38472. private _glVersion;
  38473. private _glRenderer;
  38474. private _glVendor;
  38475. /** @hidden */
  38476. _videoTextureSupported: boolean;
  38477. protected _renderingQueueLaunched: boolean;
  38478. protected _activeRenderLoops: (() => void)[];
  38479. /**
  38480. * Observable signaled when a context lost event is raised
  38481. */
  38482. onContextLostObservable: Observable<ThinEngine>;
  38483. /**
  38484. * Observable signaled when a context restored event is raised
  38485. */
  38486. onContextRestoredObservable: Observable<ThinEngine>;
  38487. private _onContextLost;
  38488. private _onContextRestored;
  38489. protected _contextWasLost: boolean;
  38490. /** @hidden */
  38491. _doNotHandleContextLost: boolean;
  38492. /**
  38493. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38494. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38495. */
  38496. get doNotHandleContextLost(): boolean;
  38497. set doNotHandleContextLost(value: boolean);
  38498. /**
  38499. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38500. */
  38501. disableVertexArrayObjects: boolean;
  38502. /** @hidden */
  38503. protected _colorWrite: boolean;
  38504. /** @hidden */
  38505. protected _colorWriteChanged: boolean;
  38506. /** @hidden */
  38507. protected _depthCullingState: DepthCullingState;
  38508. /** @hidden */
  38509. protected _stencilState: StencilState;
  38510. /** @hidden */
  38511. _alphaState: AlphaState;
  38512. /** @hidden */
  38513. _alphaMode: number;
  38514. /** @hidden */
  38515. _alphaEquation: number;
  38516. /** @hidden */
  38517. _internalTexturesCache: InternalTexture[];
  38518. /** @hidden */
  38519. protected _activeChannel: number;
  38520. private _currentTextureChannel;
  38521. /** @hidden */
  38522. protected _boundTexturesCache: {
  38523. [key: string]: Nullable<InternalTexture>;
  38524. };
  38525. /** @hidden */
  38526. protected _currentEffect: Nullable<Effect>;
  38527. /** @hidden */
  38528. protected _currentProgram: Nullable<WebGLProgram>;
  38529. private _compiledEffects;
  38530. private _vertexAttribArraysEnabled;
  38531. /** @hidden */
  38532. protected _cachedViewport: Nullable<IViewportLike>;
  38533. private _cachedVertexArrayObject;
  38534. /** @hidden */
  38535. protected _cachedVertexBuffers: any;
  38536. /** @hidden */
  38537. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38538. /** @hidden */
  38539. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38540. /** @hidden */
  38541. _currentRenderTarget: Nullable<InternalTexture>;
  38542. private _uintIndicesCurrentlySet;
  38543. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38544. /** @hidden */
  38545. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38546. /** @hidden */
  38547. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38548. private _currentBufferPointers;
  38549. private _currentInstanceLocations;
  38550. private _currentInstanceBuffers;
  38551. private _textureUnits;
  38552. /** @hidden */
  38553. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38554. /** @hidden */
  38555. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38556. /** @hidden */
  38557. _boundRenderFunction: any;
  38558. private _vaoRecordInProgress;
  38559. private _mustWipeVertexAttributes;
  38560. private _emptyTexture;
  38561. private _emptyCubeTexture;
  38562. private _emptyTexture3D;
  38563. private _emptyTexture2DArray;
  38564. /** @hidden */
  38565. _frameHandler: number;
  38566. private _nextFreeTextureSlots;
  38567. private _maxSimultaneousTextures;
  38568. private _activeRequests;
  38569. /** @hidden */
  38570. _transformTextureUrl: Nullable<(url: string) => string>;
  38571. /**
  38572. * Gets information about the current host
  38573. */
  38574. hostInformation: HostInformation;
  38575. protected get _supportsHardwareTextureRescaling(): boolean;
  38576. private _framebufferDimensionsObject;
  38577. /**
  38578. * sets the object from which width and height will be taken from when getting render width and height
  38579. * Will fallback to the gl object
  38580. * @param dimensions the framebuffer width and height that will be used.
  38581. */
  38582. set framebufferDimensionsObject(dimensions: Nullable<{
  38583. framebufferWidth: number;
  38584. framebufferHeight: number;
  38585. }>);
  38586. /**
  38587. * Gets the current viewport
  38588. */
  38589. get currentViewport(): Nullable<IViewportLike>;
  38590. /**
  38591. * Gets the default empty texture
  38592. */
  38593. get emptyTexture(): InternalTexture;
  38594. /**
  38595. * Gets the default empty 3D texture
  38596. */
  38597. get emptyTexture3D(): InternalTexture;
  38598. /**
  38599. * Gets the default empty 2D array texture
  38600. */
  38601. get emptyTexture2DArray(): InternalTexture;
  38602. /**
  38603. * Gets the default empty cube texture
  38604. */
  38605. get emptyCubeTexture(): InternalTexture;
  38606. /**
  38607. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  38608. */
  38609. readonly premultipliedAlpha: boolean;
  38610. /**
  38611. * Observable event triggered before each texture is initialized
  38612. */
  38613. onBeforeTextureInitObservable: Observable<Texture>;
  38614. /**
  38615. * Creates a new engine
  38616. * @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
  38617. * @param antialias defines enable antialiasing (default: false)
  38618. * @param options defines further options to be sent to the getContext() function
  38619. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38620. */
  38621. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38622. private _rebuildInternalTextures;
  38623. private _rebuildEffects;
  38624. /**
  38625. * Gets a boolean indicating if all created effects are ready
  38626. * @returns true if all effects are ready
  38627. */
  38628. areAllEffectsReady(): boolean;
  38629. protected _rebuildBuffers(): void;
  38630. protected _initGLContext(): void;
  38631. /**
  38632. * Gets version of the current webGL context
  38633. */
  38634. get webGLVersion(): number;
  38635. /**
  38636. * Gets a string identifying the name of the class
  38637. * @returns "Engine" string
  38638. */
  38639. getClassName(): string;
  38640. /**
  38641. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  38642. */
  38643. get isStencilEnable(): boolean;
  38644. /** @hidden */
  38645. _prepareWorkingCanvas(): void;
  38646. /**
  38647. * Reset the texture cache to empty state
  38648. */
  38649. resetTextureCache(): void;
  38650. /**
  38651. * Gets an object containing information about the current webGL context
  38652. * @returns an object containing the vender, the renderer and the version of the current webGL context
  38653. */
  38654. getGlInfo(): {
  38655. vendor: string;
  38656. renderer: string;
  38657. version: string;
  38658. };
  38659. /**
  38660. * Defines the hardware scaling level.
  38661. * By default the hardware scaling level is computed from the window device ratio.
  38662. * 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.
  38663. * @param level defines the level to use
  38664. */
  38665. setHardwareScalingLevel(level: number): void;
  38666. /**
  38667. * Gets the current hardware scaling level.
  38668. * By default the hardware scaling level is computed from the window device ratio.
  38669. * 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.
  38670. * @returns a number indicating the current hardware scaling level
  38671. */
  38672. getHardwareScalingLevel(): number;
  38673. /**
  38674. * Gets the list of loaded textures
  38675. * @returns an array containing all loaded textures
  38676. */
  38677. getLoadedTexturesCache(): InternalTexture[];
  38678. /**
  38679. * Gets the object containing all engine capabilities
  38680. * @returns the EngineCapabilities object
  38681. */
  38682. getCaps(): EngineCapabilities;
  38683. /**
  38684. * stop executing a render loop function and remove it from the execution array
  38685. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  38686. */
  38687. stopRenderLoop(renderFunction?: () => void): void;
  38688. /** @hidden */
  38689. _renderLoop(): void;
  38690. /**
  38691. * Gets the HTML canvas attached with the current webGL context
  38692. * @returns a HTML canvas
  38693. */
  38694. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  38695. /**
  38696. * Gets host window
  38697. * @returns the host window object
  38698. */
  38699. getHostWindow(): Nullable<Window>;
  38700. /**
  38701. * Gets the current render width
  38702. * @param useScreen defines if screen size must be used (or the current render target if any)
  38703. * @returns a number defining the current render width
  38704. */
  38705. getRenderWidth(useScreen?: boolean): number;
  38706. /**
  38707. * Gets the current render height
  38708. * @param useScreen defines if screen size must be used (or the current render target if any)
  38709. * @returns a number defining the current render height
  38710. */
  38711. getRenderHeight(useScreen?: boolean): number;
  38712. /**
  38713. * Can be used to override the current requestAnimationFrame requester.
  38714. * @hidden
  38715. */
  38716. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  38717. /**
  38718. * Register and execute a render loop. The engine can have more than one render function
  38719. * @param renderFunction defines the function to continuously execute
  38720. */
  38721. runRenderLoop(renderFunction: () => void): void;
  38722. /**
  38723. * Clear the current render buffer or the current render target (if any is set up)
  38724. * @param color defines the color to use
  38725. * @param backBuffer defines if the back buffer must be cleared
  38726. * @param depth defines if the depth buffer must be cleared
  38727. * @param stencil defines if the stencil buffer must be cleared
  38728. */
  38729. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  38730. private _viewportCached;
  38731. /** @hidden */
  38732. _viewport(x: number, y: number, width: number, height: number): void;
  38733. /**
  38734. * Set the WebGL's viewport
  38735. * @param viewport defines the viewport element to be used
  38736. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  38737. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  38738. */
  38739. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  38740. /**
  38741. * Begin a new frame
  38742. */
  38743. beginFrame(): void;
  38744. /**
  38745. * Enf the current frame
  38746. */
  38747. endFrame(): void;
  38748. /**
  38749. * Resize the view according to the canvas' size
  38750. */
  38751. resize(): void;
  38752. /**
  38753. * Force a specific size of the canvas
  38754. * @param width defines the new canvas' width
  38755. * @param height defines the new canvas' height
  38756. * @returns true if the size was changed
  38757. */
  38758. setSize(width: number, height: number): boolean;
  38759. /**
  38760. * Binds the frame buffer to the specified texture.
  38761. * @param texture The texture to render to or null for the default canvas
  38762. * @param faceIndex The face of the texture to render to in case of cube texture
  38763. * @param requiredWidth The width of the target to render to
  38764. * @param requiredHeight The height of the target to render to
  38765. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  38766. * @param lodLevel defines the lod level to bind to the frame buffer
  38767. * @param layer defines the 2d array index to bind to frame buffer to
  38768. */
  38769. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  38770. /** @hidden */
  38771. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  38772. /**
  38773. * Unbind the current render target texture from the webGL context
  38774. * @param texture defines the render target texture to unbind
  38775. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  38776. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  38777. */
  38778. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  38779. /**
  38780. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  38781. */
  38782. flushFramebuffer(): void;
  38783. /**
  38784. * Unbind the current render target and bind the default framebuffer
  38785. */
  38786. restoreDefaultFramebuffer(): void;
  38787. /** @hidden */
  38788. protected _resetVertexBufferBinding(): void;
  38789. /**
  38790. * Creates a vertex buffer
  38791. * @param data the data for the vertex buffer
  38792. * @returns the new WebGL static buffer
  38793. */
  38794. createVertexBuffer(data: DataArray): DataBuffer;
  38795. private _createVertexBuffer;
  38796. /**
  38797. * Creates a dynamic vertex buffer
  38798. * @param data the data for the dynamic vertex buffer
  38799. * @returns the new WebGL dynamic buffer
  38800. */
  38801. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  38802. protected _resetIndexBufferBinding(): void;
  38803. /**
  38804. * Creates a new index buffer
  38805. * @param indices defines the content of the index buffer
  38806. * @param updatable defines if the index buffer must be updatable
  38807. * @returns a new webGL buffer
  38808. */
  38809. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  38810. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  38811. /**
  38812. * Bind a webGL buffer to the webGL context
  38813. * @param buffer defines the buffer to bind
  38814. */
  38815. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  38816. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  38817. private bindBuffer;
  38818. /**
  38819. * update the bound buffer with the given data
  38820. * @param data defines the data to update
  38821. */
  38822. updateArrayBuffer(data: Float32Array): void;
  38823. private _vertexAttribPointer;
  38824. /** @hidden */
  38825. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  38826. private _bindVertexBuffersAttributes;
  38827. /**
  38828. * Records a vertex array object
  38829. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38830. * @param vertexBuffers defines the list of vertex buffers to store
  38831. * @param indexBuffer defines the index buffer to store
  38832. * @param effect defines the effect to store
  38833. * @returns the new vertex array object
  38834. */
  38835. recordVertexArrayObject(vertexBuffers: {
  38836. [key: string]: VertexBuffer;
  38837. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  38838. /**
  38839. * Bind a specific vertex array object
  38840. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38841. * @param vertexArrayObject defines the vertex array object to bind
  38842. * @param indexBuffer defines the index buffer to bind
  38843. */
  38844. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  38845. /**
  38846. * Bind webGl buffers directly to the webGL context
  38847. * @param vertexBuffer defines the vertex buffer to bind
  38848. * @param indexBuffer defines the index buffer to bind
  38849. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  38850. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  38851. * @param effect defines the effect associated with the vertex buffer
  38852. */
  38853. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  38854. private _unbindVertexArrayObject;
  38855. /**
  38856. * Bind a list of vertex buffers to the webGL context
  38857. * @param vertexBuffers defines the list of vertex buffers to bind
  38858. * @param indexBuffer defines the index buffer to bind
  38859. * @param effect defines the effect associated with the vertex buffers
  38860. */
  38861. bindBuffers(vertexBuffers: {
  38862. [key: string]: Nullable<VertexBuffer>;
  38863. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  38864. /**
  38865. * Unbind all instance attributes
  38866. */
  38867. unbindInstanceAttributes(): void;
  38868. /**
  38869. * Release and free the memory of a vertex array object
  38870. * @param vao defines the vertex array object to delete
  38871. */
  38872. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  38873. /** @hidden */
  38874. _releaseBuffer(buffer: DataBuffer): boolean;
  38875. protected _deleteBuffer(buffer: DataBuffer): void;
  38876. /**
  38877. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  38878. * @param instancesBuffer defines the webGL buffer to update and bind
  38879. * @param data defines the data to store in the buffer
  38880. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  38881. */
  38882. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  38883. /**
  38884. * Bind the content of a webGL buffer used with instantiation
  38885. * @param instancesBuffer defines the webGL buffer to bind
  38886. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  38887. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  38888. */
  38889. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  38890. /**
  38891. * Disable the instance attribute corresponding to the name in parameter
  38892. * @param name defines the name of the attribute to disable
  38893. */
  38894. disableInstanceAttributeByName(name: string): void;
  38895. /**
  38896. * Disable the instance attribute corresponding to the location in parameter
  38897. * @param attributeLocation defines the attribute location of the attribute to disable
  38898. */
  38899. disableInstanceAttribute(attributeLocation: number): void;
  38900. /**
  38901. * Disable the attribute corresponding to the location in parameter
  38902. * @param attributeLocation defines the attribute location of the attribute to disable
  38903. */
  38904. disableAttributeByIndex(attributeLocation: number): void;
  38905. /**
  38906. * Send a draw order
  38907. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  38908. * @param indexStart defines the starting index
  38909. * @param indexCount defines the number of index to draw
  38910. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38911. */
  38912. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  38913. /**
  38914. * Draw a list of points
  38915. * @param verticesStart defines the index of first vertex to draw
  38916. * @param verticesCount defines the count of vertices to draw
  38917. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38918. */
  38919. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  38920. /**
  38921. * Draw a list of unindexed primitives
  38922. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  38923. * @param verticesStart defines the index of first vertex to draw
  38924. * @param verticesCount defines the count of vertices to draw
  38925. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38926. */
  38927. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  38928. /**
  38929. * Draw a list of indexed primitives
  38930. * @param fillMode defines the primitive to use
  38931. * @param indexStart defines the starting index
  38932. * @param indexCount defines the number of index to draw
  38933. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38934. */
  38935. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  38936. /**
  38937. * Draw a list of unindexed primitives
  38938. * @param fillMode defines the primitive to use
  38939. * @param verticesStart defines the index of first vertex to draw
  38940. * @param verticesCount defines the count of vertices to draw
  38941. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38942. */
  38943. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  38944. private _drawMode;
  38945. /** @hidden */
  38946. protected _reportDrawCall(): void;
  38947. /** @hidden */
  38948. _releaseEffect(effect: Effect): void;
  38949. /** @hidden */
  38950. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38951. /**
  38952. * Create a new effect (used to store vertex/fragment shaders)
  38953. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  38954. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  38955. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  38956. * @param samplers defines an array of string used to represent textures
  38957. * @param defines defines the string containing the defines to use to compile the shaders
  38958. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  38959. * @param onCompiled defines a function to call when the effect creation is successful
  38960. * @param onError defines a function to call when the effect creation has failed
  38961. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  38962. * @returns the new Effect
  38963. */
  38964. 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;
  38965. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  38966. private _compileShader;
  38967. private _compileRawShader;
  38968. /** @hidden */
  38969. _getShaderSource(shader: WebGLShader): Nullable<string>;
  38970. /**
  38971. * Directly creates a webGL program
  38972. * @param pipelineContext defines the pipeline context to attach to
  38973. * @param vertexCode defines the vertex shader code to use
  38974. * @param fragmentCode defines the fragment shader code to use
  38975. * @param context defines the webGL context to use (if not set, the current one will be used)
  38976. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  38977. * @returns the new webGL program
  38978. */
  38979. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38980. /**
  38981. * Creates a webGL program
  38982. * @param pipelineContext defines the pipeline context to attach to
  38983. * @param vertexCode defines the vertex shader code to use
  38984. * @param fragmentCode defines the fragment shader code to use
  38985. * @param defines defines the string containing the defines to use to compile the shaders
  38986. * @param context defines the webGL context to use (if not set, the current one will be used)
  38987. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  38988. * @returns the new webGL program
  38989. */
  38990. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38991. /**
  38992. * Creates a new pipeline context
  38993. * @returns the new pipeline
  38994. */
  38995. createPipelineContext(): IPipelineContext;
  38996. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38997. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  38998. /** @hidden */
  38999. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39000. /** @hidden */
  39001. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39002. /** @hidden */
  39003. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39004. /**
  39005. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39006. * @param pipelineContext defines the pipeline context to use
  39007. * @param uniformsNames defines the list of uniform names
  39008. * @returns an array of webGL uniform locations
  39009. */
  39010. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39011. /**
  39012. * Gets the lsit of active attributes for a given webGL program
  39013. * @param pipelineContext defines the pipeline context to use
  39014. * @param attributesNames defines the list of attribute names to get
  39015. * @returns an array of indices indicating the offset of each attribute
  39016. */
  39017. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39018. /**
  39019. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39020. * @param effect defines the effect to activate
  39021. */
  39022. enableEffect(effect: Nullable<Effect>): void;
  39023. /**
  39024. * Set the value of an uniform to a number (int)
  39025. * @param uniform defines the webGL uniform location where to store the value
  39026. * @param value defines the int number to store
  39027. * @returns true if the value was set
  39028. */
  39029. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39030. /**
  39031. * Set the value of an uniform to an array of int32
  39032. * @param uniform defines the webGL uniform location where to store the value
  39033. * @param array defines the array of int32 to store
  39034. * @returns true if the value was set
  39035. */
  39036. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39037. /**
  39038. * Set the value of an uniform to an array of int32 (stored as vec2)
  39039. * @param uniform defines the webGL uniform location where to store the value
  39040. * @param array defines the array of int32 to store
  39041. * @returns true if the value was set
  39042. */
  39043. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39044. /**
  39045. * Set the value of an uniform to an array of int32 (stored as vec3)
  39046. * @param uniform defines the webGL uniform location where to store the value
  39047. * @param array defines the array of int32 to store
  39048. * @returns true if the value was set
  39049. */
  39050. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39051. /**
  39052. * Set the value of an uniform to an array of int32 (stored as vec4)
  39053. * @param uniform defines the webGL uniform location where to store the value
  39054. * @param array defines the array of int32 to store
  39055. * @returns true if the value was set
  39056. */
  39057. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39058. /**
  39059. * Set the value of an uniform to an array of number
  39060. * @param uniform defines the webGL uniform location where to store the value
  39061. * @param array defines the array of number to store
  39062. * @returns true if the value was set
  39063. */
  39064. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39065. /**
  39066. * Set the value of an uniform to an array of number (stored as vec2)
  39067. * @param uniform defines the webGL uniform location where to store the value
  39068. * @param array defines the array of number to store
  39069. * @returns true if the value was set
  39070. */
  39071. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39072. /**
  39073. * Set the value of an uniform to an array of number (stored as vec3)
  39074. * @param uniform defines the webGL uniform location where to store the value
  39075. * @param array defines the array of number to store
  39076. * @returns true if the value was set
  39077. */
  39078. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39079. /**
  39080. * Set the value of an uniform to an array of number (stored as vec4)
  39081. * @param uniform defines the webGL uniform location where to store the value
  39082. * @param array defines the array of number to store
  39083. * @returns true if the value was set
  39084. */
  39085. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39086. /**
  39087. * Set the value of an uniform to an array of float32 (stored as matrices)
  39088. * @param uniform defines the webGL uniform location where to store the value
  39089. * @param matrices defines the array of float32 to store
  39090. * @returns true if the value was set
  39091. */
  39092. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39093. /**
  39094. * Set the value of an uniform to a matrix (3x3)
  39095. * @param uniform defines the webGL uniform location where to store the value
  39096. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39097. * @returns true if the value was set
  39098. */
  39099. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39100. /**
  39101. * Set the value of an uniform to a matrix (2x2)
  39102. * @param uniform defines the webGL uniform location where to store the value
  39103. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39104. * @returns true if the value was set
  39105. */
  39106. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39107. /**
  39108. * Set the value of an uniform to a number (float)
  39109. * @param uniform defines the webGL uniform location where to store the value
  39110. * @param value defines the float number to store
  39111. * @returns true if the value was transfered
  39112. */
  39113. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39114. /**
  39115. * Set the value of an uniform to a vec2
  39116. * @param uniform defines the webGL uniform location where to store the value
  39117. * @param x defines the 1st component of the value
  39118. * @param y defines the 2nd component of the value
  39119. * @returns true if the value was set
  39120. */
  39121. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39122. /**
  39123. * Set the value of an uniform to a vec3
  39124. * @param uniform defines the webGL uniform location where to store the value
  39125. * @param x defines the 1st component of the value
  39126. * @param y defines the 2nd component of the value
  39127. * @param z defines the 3rd component of the value
  39128. * @returns true if the value was set
  39129. */
  39130. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39131. /**
  39132. * Set the value of an uniform to a vec4
  39133. * @param uniform defines the webGL uniform location where to store the value
  39134. * @param x defines the 1st component of the value
  39135. * @param y defines the 2nd component of the value
  39136. * @param z defines the 3rd component of the value
  39137. * @param w defines the 4th component of the value
  39138. * @returns true if the value was set
  39139. */
  39140. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39141. /**
  39142. * Apply all cached states (depth, culling, stencil and alpha)
  39143. */
  39144. applyStates(): void;
  39145. /**
  39146. * Enable or disable color writing
  39147. * @param enable defines the state to set
  39148. */
  39149. setColorWrite(enable: boolean): void;
  39150. /**
  39151. * Gets a boolean indicating if color writing is enabled
  39152. * @returns the current color writing state
  39153. */
  39154. getColorWrite(): boolean;
  39155. /**
  39156. * Gets the depth culling state manager
  39157. */
  39158. get depthCullingState(): DepthCullingState;
  39159. /**
  39160. * Gets the alpha state manager
  39161. */
  39162. get alphaState(): AlphaState;
  39163. /**
  39164. * Gets the stencil state manager
  39165. */
  39166. get stencilState(): StencilState;
  39167. /**
  39168. * Clears the list of texture accessible through engine.
  39169. * This can help preventing texture load conflict due to name collision.
  39170. */
  39171. clearInternalTexturesCache(): void;
  39172. /**
  39173. * Force the entire cache to be cleared
  39174. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39175. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39176. */
  39177. wipeCaches(bruteForce?: boolean): void;
  39178. /** @hidden */
  39179. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39180. min: number;
  39181. mag: number;
  39182. };
  39183. /** @hidden */
  39184. _createTexture(): WebGLTexture;
  39185. /**
  39186. * Usually called from Texture.ts.
  39187. * Passed information to create a WebGLTexture
  39188. * @param url defines a value which contains one of the following:
  39189. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39190. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39191. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39192. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39193. * @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)
  39194. * @param scene needed for loading to the correct scene
  39195. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39196. * @param onLoad optional callback to be called upon successful completion
  39197. * @param onError optional callback to be called upon failure
  39198. * @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
  39199. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39200. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39201. * @param forcedExtension defines the extension to use to pick the right loader
  39202. * @param mimeType defines an optional mime type
  39203. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39204. */
  39205. 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;
  39206. /**
  39207. * Loads an image as an HTMLImageElement.
  39208. * @param input url string, ArrayBuffer, or Blob to load
  39209. * @param onLoad callback called when the image successfully loads
  39210. * @param onError callback called when the image fails to load
  39211. * @param offlineProvider offline provider for caching
  39212. * @param mimeType optional mime type
  39213. * @returns the HTMLImageElement of the loaded image
  39214. * @hidden
  39215. */
  39216. 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>;
  39217. /**
  39218. * @hidden
  39219. */
  39220. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39221. private _unpackFlipYCached;
  39222. /**
  39223. * In case you are sharing the context with other applications, it might
  39224. * be interested to not cache the unpack flip y state to ensure a consistent
  39225. * value would be set.
  39226. */
  39227. enableUnpackFlipYCached: boolean;
  39228. /** @hidden */
  39229. _unpackFlipY(value: boolean): void;
  39230. /** @hidden */
  39231. _getUnpackAlignement(): number;
  39232. private _getTextureTarget;
  39233. /**
  39234. * Update the sampling mode of a given texture
  39235. * @param samplingMode defines the required sampling mode
  39236. * @param texture defines the texture to update
  39237. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39238. */
  39239. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39240. /**
  39241. * Update the sampling mode of a given texture
  39242. * @param texture defines the texture to update
  39243. * @param wrapU defines the texture wrap mode of the u coordinates
  39244. * @param wrapV defines the texture wrap mode of the v coordinates
  39245. * @param wrapR defines the texture wrap mode of the r coordinates
  39246. */
  39247. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39248. /** @hidden */
  39249. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39250. width: number;
  39251. height: number;
  39252. layers?: number;
  39253. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39254. /** @hidden */
  39255. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39256. /** @hidden */
  39257. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39258. /**
  39259. * Update a portion of an internal texture
  39260. * @param texture defines the texture to update
  39261. * @param imageData defines the data to store into the texture
  39262. * @param xOffset defines the x coordinates of the update rectangle
  39263. * @param yOffset defines the y coordinates of the update rectangle
  39264. * @param width defines the width of the update rectangle
  39265. * @param height defines the height of the update rectangle
  39266. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39267. * @param lod defines the lod level to update (0 by default)
  39268. */
  39269. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39270. /** @hidden */
  39271. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39272. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39273. private _prepareWebGLTexture;
  39274. /** @hidden */
  39275. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39276. private _getDepthStencilBuffer;
  39277. /** @hidden */
  39278. _releaseFramebufferObjects(texture: InternalTexture): void;
  39279. /** @hidden */
  39280. _releaseTexture(texture: InternalTexture): void;
  39281. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39282. protected _setProgram(program: WebGLProgram): void;
  39283. protected _boundUniforms: {
  39284. [key: number]: WebGLUniformLocation;
  39285. };
  39286. /**
  39287. * Binds an effect to the webGL context
  39288. * @param effect defines the effect to bind
  39289. */
  39290. bindSamplers(effect: Effect): void;
  39291. private _activateCurrentTexture;
  39292. /** @hidden */
  39293. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39294. /** @hidden */
  39295. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39296. /**
  39297. * Unbind all textures from the webGL context
  39298. */
  39299. unbindAllTextures(): void;
  39300. /**
  39301. * Sets a texture to the according uniform.
  39302. * @param channel The texture channel
  39303. * @param uniform The uniform to set
  39304. * @param texture The texture to apply
  39305. */
  39306. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39307. private _bindSamplerUniformToChannel;
  39308. private _getTextureWrapMode;
  39309. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39310. /**
  39311. * Sets an array of texture to the webGL context
  39312. * @param channel defines the channel where the texture array must be set
  39313. * @param uniform defines the associated uniform location
  39314. * @param textures defines the array of textures to bind
  39315. */
  39316. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39317. /** @hidden */
  39318. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39319. private _setTextureParameterFloat;
  39320. private _setTextureParameterInteger;
  39321. /**
  39322. * Unbind all vertex attributes from the webGL context
  39323. */
  39324. unbindAllAttributes(): void;
  39325. /**
  39326. * 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
  39327. */
  39328. releaseEffects(): void;
  39329. /**
  39330. * Dispose and release all associated resources
  39331. */
  39332. dispose(): void;
  39333. /**
  39334. * Attach a new callback raised when context lost event is fired
  39335. * @param callback defines the callback to call
  39336. */
  39337. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39338. /**
  39339. * Attach a new callback raised when context restored event is fired
  39340. * @param callback defines the callback to call
  39341. */
  39342. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39343. /**
  39344. * Get the current error code of the webGL context
  39345. * @returns the error code
  39346. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39347. */
  39348. getError(): number;
  39349. private _canRenderToFloatFramebuffer;
  39350. private _canRenderToHalfFloatFramebuffer;
  39351. private _canRenderToFramebuffer;
  39352. /** @hidden */
  39353. _getWebGLTextureType(type: number): number;
  39354. /** @hidden */
  39355. _getInternalFormat(format: number): number;
  39356. /** @hidden */
  39357. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39358. /** @hidden */
  39359. _getRGBAMultiSampleBufferFormat(type: number): number;
  39360. /** @hidden */
  39361. _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;
  39362. /**
  39363. * Loads a file from a url
  39364. * @param url url to load
  39365. * @param onSuccess callback called when the file successfully loads
  39366. * @param onProgress callback called while file is loading (if the server supports this mode)
  39367. * @param offlineProvider defines the offline provider for caching
  39368. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39369. * @param onError callback called when the file fails to load
  39370. * @returns a file request object
  39371. * @hidden
  39372. */
  39373. 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;
  39374. /**
  39375. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39376. * @param x defines the x coordinate of the rectangle where pixels must be read
  39377. * @param y defines the y coordinate of the rectangle where pixels must be read
  39378. * @param width defines the width of the rectangle where pixels must be read
  39379. * @param height defines the height of the rectangle where pixels must be read
  39380. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39381. * @returns a Uint8Array containing RGBA colors
  39382. */
  39383. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39384. private static _IsSupported;
  39385. private static _HasMajorPerformanceCaveat;
  39386. /**
  39387. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39388. */
  39389. static get IsSupported(): boolean;
  39390. /**
  39391. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39392. * @returns true if the engine can be created
  39393. * @ignorenaming
  39394. */
  39395. static isSupported(): boolean;
  39396. /**
  39397. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  39398. */
  39399. static get HasMajorPerformanceCaveat(): boolean;
  39400. /**
  39401. * Find the next highest power of two.
  39402. * @param x Number to start search from.
  39403. * @return Next highest power of two.
  39404. */
  39405. static CeilingPOT(x: number): number;
  39406. /**
  39407. * Find the next lowest power of two.
  39408. * @param x Number to start search from.
  39409. * @return Next lowest power of two.
  39410. */
  39411. static FloorPOT(x: number): number;
  39412. /**
  39413. * Find the nearest power of two.
  39414. * @param x Number to start search from.
  39415. * @return Next nearest power of two.
  39416. */
  39417. static NearestPOT(x: number): number;
  39418. /**
  39419. * Get the closest exponent of two
  39420. * @param value defines the value to approximate
  39421. * @param max defines the maximum value to return
  39422. * @param mode defines how to define the closest value
  39423. * @returns closest exponent of two of the given value
  39424. */
  39425. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39426. /**
  39427. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39428. * @param func - the function to be called
  39429. * @param requester - the object that will request the next frame. Falls back to window.
  39430. * @returns frame number
  39431. */
  39432. static QueueNewFrame(func: () => void, requester?: any): number;
  39433. /**
  39434. * Gets host document
  39435. * @returns the host document object
  39436. */
  39437. getHostDocument(): Nullable<Document>;
  39438. }
  39439. }
  39440. declare module BABYLON {
  39441. /**
  39442. * Defines the source of the internal texture
  39443. */
  39444. export enum InternalTextureSource {
  39445. /**
  39446. * The source of the texture data is unknown
  39447. */
  39448. Unknown = 0,
  39449. /**
  39450. * Texture data comes from an URL
  39451. */
  39452. Url = 1,
  39453. /**
  39454. * Texture data is only used for temporary storage
  39455. */
  39456. Temp = 2,
  39457. /**
  39458. * Texture data comes from raw data (ArrayBuffer)
  39459. */
  39460. Raw = 3,
  39461. /**
  39462. * Texture content is dynamic (video or dynamic texture)
  39463. */
  39464. Dynamic = 4,
  39465. /**
  39466. * Texture content is generated by rendering to it
  39467. */
  39468. RenderTarget = 5,
  39469. /**
  39470. * Texture content is part of a multi render target process
  39471. */
  39472. MultiRenderTarget = 6,
  39473. /**
  39474. * Texture data comes from a cube data file
  39475. */
  39476. Cube = 7,
  39477. /**
  39478. * Texture data comes from a raw cube data
  39479. */
  39480. CubeRaw = 8,
  39481. /**
  39482. * Texture data come from a prefiltered cube data file
  39483. */
  39484. CubePrefiltered = 9,
  39485. /**
  39486. * Texture content is raw 3D data
  39487. */
  39488. Raw3D = 10,
  39489. /**
  39490. * Texture content is raw 2D array data
  39491. */
  39492. Raw2DArray = 11,
  39493. /**
  39494. * Texture content is a depth texture
  39495. */
  39496. Depth = 12,
  39497. /**
  39498. * Texture data comes from a raw cube data encoded with RGBD
  39499. */
  39500. CubeRawRGBD = 13
  39501. }
  39502. /**
  39503. * Class used to store data associated with WebGL texture data for the engine
  39504. * This class should not be used directly
  39505. */
  39506. export class InternalTexture {
  39507. /** @hidden */
  39508. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39509. /**
  39510. * Defines if the texture is ready
  39511. */
  39512. isReady: boolean;
  39513. /**
  39514. * Defines if the texture is a cube texture
  39515. */
  39516. isCube: boolean;
  39517. /**
  39518. * Defines if the texture contains 3D data
  39519. */
  39520. is3D: boolean;
  39521. /**
  39522. * Defines if the texture contains 2D array data
  39523. */
  39524. is2DArray: boolean;
  39525. /**
  39526. * Defines if the texture contains multiview data
  39527. */
  39528. isMultiview: boolean;
  39529. /**
  39530. * Gets the URL used to load this texture
  39531. */
  39532. url: string;
  39533. /**
  39534. * Gets the sampling mode of the texture
  39535. */
  39536. samplingMode: number;
  39537. /**
  39538. * Gets a boolean indicating if the texture needs mipmaps generation
  39539. */
  39540. generateMipMaps: boolean;
  39541. /**
  39542. * Gets the number of samples used by the texture (WebGL2+ only)
  39543. */
  39544. samples: number;
  39545. /**
  39546. * Gets the type of the texture (int, float...)
  39547. */
  39548. type: number;
  39549. /**
  39550. * Gets the format of the texture (RGB, RGBA...)
  39551. */
  39552. format: number;
  39553. /**
  39554. * Observable called when the texture is loaded
  39555. */
  39556. onLoadedObservable: Observable<InternalTexture>;
  39557. /**
  39558. * Gets the width of the texture
  39559. */
  39560. width: number;
  39561. /**
  39562. * Gets the height of the texture
  39563. */
  39564. height: number;
  39565. /**
  39566. * Gets the depth of the texture
  39567. */
  39568. depth: number;
  39569. /**
  39570. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39571. */
  39572. baseWidth: number;
  39573. /**
  39574. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39575. */
  39576. baseHeight: number;
  39577. /**
  39578. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39579. */
  39580. baseDepth: number;
  39581. /**
  39582. * Gets a boolean indicating if the texture is inverted on Y axis
  39583. */
  39584. invertY: boolean;
  39585. /** @hidden */
  39586. _invertVScale: boolean;
  39587. /** @hidden */
  39588. _associatedChannel: number;
  39589. /** @hidden */
  39590. _source: InternalTextureSource;
  39591. /** @hidden */
  39592. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39593. /** @hidden */
  39594. _bufferView: Nullable<ArrayBufferView>;
  39595. /** @hidden */
  39596. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39597. /** @hidden */
  39598. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39599. /** @hidden */
  39600. _size: number;
  39601. /** @hidden */
  39602. _extension: string;
  39603. /** @hidden */
  39604. _files: Nullable<string[]>;
  39605. /** @hidden */
  39606. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39607. /** @hidden */
  39608. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39609. /** @hidden */
  39610. _framebuffer: Nullable<WebGLFramebuffer>;
  39611. /** @hidden */
  39612. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  39613. /** @hidden */
  39614. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  39615. /** @hidden */
  39616. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  39617. /** @hidden */
  39618. _attachments: Nullable<number[]>;
  39619. /** @hidden */
  39620. _textureArray: Nullable<InternalTexture[]>;
  39621. /** @hidden */
  39622. _cachedCoordinatesMode: Nullable<number>;
  39623. /** @hidden */
  39624. _cachedWrapU: Nullable<number>;
  39625. /** @hidden */
  39626. _cachedWrapV: Nullable<number>;
  39627. /** @hidden */
  39628. _cachedWrapR: Nullable<number>;
  39629. /** @hidden */
  39630. _cachedAnisotropicFilteringLevel: Nullable<number>;
  39631. /** @hidden */
  39632. _isDisabled: boolean;
  39633. /** @hidden */
  39634. _compression: Nullable<string>;
  39635. /** @hidden */
  39636. _generateStencilBuffer: boolean;
  39637. /** @hidden */
  39638. _generateDepthBuffer: boolean;
  39639. /** @hidden */
  39640. _comparisonFunction: number;
  39641. /** @hidden */
  39642. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  39643. /** @hidden */
  39644. _lodGenerationScale: number;
  39645. /** @hidden */
  39646. _lodGenerationOffset: number;
  39647. /** @hidden */
  39648. _depthStencilTexture: Nullable<InternalTexture>;
  39649. /** @hidden */
  39650. _colorTextureArray: Nullable<WebGLTexture>;
  39651. /** @hidden */
  39652. _depthStencilTextureArray: Nullable<WebGLTexture>;
  39653. /** @hidden */
  39654. _lodTextureHigh: Nullable<BaseTexture>;
  39655. /** @hidden */
  39656. _lodTextureMid: Nullable<BaseTexture>;
  39657. /** @hidden */
  39658. _lodTextureLow: Nullable<BaseTexture>;
  39659. /** @hidden */
  39660. _isRGBD: boolean;
  39661. /** @hidden */
  39662. _linearSpecularLOD: boolean;
  39663. /** @hidden */
  39664. _irradianceTexture: Nullable<BaseTexture>;
  39665. /** @hidden */
  39666. _webGLTexture: Nullable<WebGLTexture>;
  39667. /** @hidden */
  39668. _references: number;
  39669. /** @hidden */
  39670. _gammaSpace: Nullable<boolean>;
  39671. private _engine;
  39672. /**
  39673. * Gets the Engine the texture belongs to.
  39674. * @returns The babylon engine
  39675. */
  39676. getEngine(): ThinEngine;
  39677. /**
  39678. * Gets the data source type of the texture
  39679. */
  39680. get source(): InternalTextureSource;
  39681. /**
  39682. * Creates a new InternalTexture
  39683. * @param engine defines the engine to use
  39684. * @param source defines the type of data that will be used
  39685. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39686. */
  39687. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  39688. /**
  39689. * Increments the number of references (ie. the number of Texture that point to it)
  39690. */
  39691. incrementReferences(): void;
  39692. /**
  39693. * Change the size of the texture (not the size of the content)
  39694. * @param width defines the new width
  39695. * @param height defines the new height
  39696. * @param depth defines the new depth (1 by default)
  39697. */
  39698. updateSize(width: int, height: int, depth?: int): void;
  39699. /** @hidden */
  39700. _rebuild(): void;
  39701. /** @hidden */
  39702. _swapAndDie(target: InternalTexture): void;
  39703. /**
  39704. * Dispose the current allocated resources
  39705. */
  39706. dispose(): void;
  39707. }
  39708. }
  39709. declare module BABYLON {
  39710. /**
  39711. * Class used to work with sound analyzer using fast fourier transform (FFT)
  39712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39713. */
  39714. export class Analyser {
  39715. /**
  39716. * Gets or sets the smoothing
  39717. * @ignorenaming
  39718. */
  39719. SMOOTHING: number;
  39720. /**
  39721. * Gets or sets the FFT table size
  39722. * @ignorenaming
  39723. */
  39724. FFT_SIZE: number;
  39725. /**
  39726. * Gets or sets the bar graph amplitude
  39727. * @ignorenaming
  39728. */
  39729. BARGRAPHAMPLITUDE: number;
  39730. /**
  39731. * Gets or sets the position of the debug canvas
  39732. * @ignorenaming
  39733. */
  39734. DEBUGCANVASPOS: {
  39735. x: number;
  39736. y: number;
  39737. };
  39738. /**
  39739. * Gets or sets the debug canvas size
  39740. * @ignorenaming
  39741. */
  39742. DEBUGCANVASSIZE: {
  39743. width: number;
  39744. height: number;
  39745. };
  39746. private _byteFreqs;
  39747. private _byteTime;
  39748. private _floatFreqs;
  39749. private _webAudioAnalyser;
  39750. private _debugCanvas;
  39751. private _debugCanvasContext;
  39752. private _scene;
  39753. private _registerFunc;
  39754. private _audioEngine;
  39755. /**
  39756. * Creates a new analyser
  39757. * @param scene defines hosting scene
  39758. */
  39759. constructor(scene: Scene);
  39760. /**
  39761. * Get the number of data values you will have to play with for the visualization
  39762. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  39763. * @returns a number
  39764. */
  39765. getFrequencyBinCount(): number;
  39766. /**
  39767. * Gets the current frequency data as a byte array
  39768. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39769. * @returns a Uint8Array
  39770. */
  39771. getByteFrequencyData(): Uint8Array;
  39772. /**
  39773. * Gets the current waveform as a byte array
  39774. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  39775. * @returns a Uint8Array
  39776. */
  39777. getByteTimeDomainData(): Uint8Array;
  39778. /**
  39779. * Gets the current frequency data as a float array
  39780. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39781. * @returns a Float32Array
  39782. */
  39783. getFloatFrequencyData(): Float32Array;
  39784. /**
  39785. * Renders the debug canvas
  39786. */
  39787. drawDebugCanvas(): void;
  39788. /**
  39789. * Stops rendering the debug canvas and removes it
  39790. */
  39791. stopDebugCanvas(): void;
  39792. /**
  39793. * Connects two audio nodes
  39794. * @param inputAudioNode defines first node to connect
  39795. * @param outputAudioNode defines second node to connect
  39796. */
  39797. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  39798. /**
  39799. * Releases all associated resources
  39800. */
  39801. dispose(): void;
  39802. }
  39803. }
  39804. declare module BABYLON {
  39805. /**
  39806. * This represents an audio engine and it is responsible
  39807. * to play, synchronize and analyse sounds throughout the application.
  39808. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39809. */
  39810. export interface IAudioEngine extends IDisposable {
  39811. /**
  39812. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39813. */
  39814. readonly canUseWebAudio: boolean;
  39815. /**
  39816. * Gets the current AudioContext if available.
  39817. */
  39818. readonly audioContext: Nullable<AudioContext>;
  39819. /**
  39820. * The master gain node defines the global audio volume of your audio engine.
  39821. */
  39822. readonly masterGain: GainNode;
  39823. /**
  39824. * Gets whether or not mp3 are supported by your browser.
  39825. */
  39826. readonly isMP3supported: boolean;
  39827. /**
  39828. * Gets whether or not ogg are supported by your browser.
  39829. */
  39830. readonly isOGGsupported: boolean;
  39831. /**
  39832. * Defines if Babylon should emit a warning if WebAudio is not supported.
  39833. * @ignoreNaming
  39834. */
  39835. WarnedWebAudioUnsupported: boolean;
  39836. /**
  39837. * Defines if the audio engine relies on a custom unlocked button.
  39838. * In this case, the embedded button will not be displayed.
  39839. */
  39840. useCustomUnlockedButton: boolean;
  39841. /**
  39842. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  39843. */
  39844. readonly unlocked: boolean;
  39845. /**
  39846. * Event raised when audio has been unlocked on the browser.
  39847. */
  39848. onAudioUnlockedObservable: Observable<AudioEngine>;
  39849. /**
  39850. * Event raised when audio has been locked on the browser.
  39851. */
  39852. onAudioLockedObservable: Observable<AudioEngine>;
  39853. /**
  39854. * Flags the audio engine in Locked state.
  39855. * This happens due to new browser policies preventing audio to autoplay.
  39856. */
  39857. lock(): void;
  39858. /**
  39859. * Unlocks the audio engine once a user action has been done on the dom.
  39860. * This is helpful to resume play once browser policies have been satisfied.
  39861. */
  39862. unlock(): void;
  39863. /**
  39864. * Gets the global volume sets on the master gain.
  39865. * @returns the global volume if set or -1 otherwise
  39866. */
  39867. getGlobalVolume(): number;
  39868. /**
  39869. * Sets the global volume of your experience (sets on the master gain).
  39870. * @param newVolume Defines the new global volume of the application
  39871. */
  39872. setGlobalVolume(newVolume: number): void;
  39873. /**
  39874. * Connect the audio engine to an audio analyser allowing some amazing
  39875. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39876. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39877. * @param analyser The analyser to connect to the engine
  39878. */
  39879. connectToAnalyser(analyser: Analyser): void;
  39880. }
  39881. /**
  39882. * This represents the default audio engine used in babylon.
  39883. * It is responsible to play, synchronize and analyse sounds throughout the application.
  39884. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39885. */
  39886. export class AudioEngine implements IAudioEngine {
  39887. private _audioContext;
  39888. private _audioContextInitialized;
  39889. private _muteButton;
  39890. private _hostElement;
  39891. /**
  39892. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39893. */
  39894. canUseWebAudio: boolean;
  39895. /**
  39896. * The master gain node defines the global audio volume of your audio engine.
  39897. */
  39898. masterGain: GainNode;
  39899. /**
  39900. * Defines if Babylon should emit a warning if WebAudio is not supported.
  39901. * @ignoreNaming
  39902. */
  39903. WarnedWebAudioUnsupported: boolean;
  39904. /**
  39905. * Gets whether or not mp3 are supported by your browser.
  39906. */
  39907. isMP3supported: boolean;
  39908. /**
  39909. * Gets whether or not ogg are supported by your browser.
  39910. */
  39911. isOGGsupported: boolean;
  39912. /**
  39913. * Gets whether audio has been unlocked on the device.
  39914. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  39915. * a user interaction has happened.
  39916. */
  39917. unlocked: boolean;
  39918. /**
  39919. * Defines if the audio engine relies on a custom unlocked button.
  39920. * In this case, the embedded button will not be displayed.
  39921. */
  39922. useCustomUnlockedButton: boolean;
  39923. /**
  39924. * Event raised when audio has been unlocked on the browser.
  39925. */
  39926. onAudioUnlockedObservable: Observable<AudioEngine>;
  39927. /**
  39928. * Event raised when audio has been locked on the browser.
  39929. */
  39930. onAudioLockedObservable: Observable<AudioEngine>;
  39931. /**
  39932. * Gets the current AudioContext if available.
  39933. */
  39934. get audioContext(): Nullable<AudioContext>;
  39935. private _connectedAnalyser;
  39936. /**
  39937. * Instantiates a new audio engine.
  39938. *
  39939. * There should be only one per page as some browsers restrict the number
  39940. * of audio contexts you can create.
  39941. * @param hostElement defines the host element where to display the mute icon if necessary
  39942. */
  39943. constructor(hostElement?: Nullable<HTMLElement>);
  39944. /**
  39945. * Flags the audio engine in Locked state.
  39946. * This happens due to new browser policies preventing audio to autoplay.
  39947. */
  39948. lock(): void;
  39949. /**
  39950. * Unlocks the audio engine once a user action has been done on the dom.
  39951. * This is helpful to resume play once browser policies have been satisfied.
  39952. */
  39953. unlock(): void;
  39954. private _resumeAudioContext;
  39955. private _initializeAudioContext;
  39956. private _tryToRun;
  39957. private _triggerRunningState;
  39958. private _triggerSuspendedState;
  39959. private _displayMuteButton;
  39960. private _moveButtonToTopLeft;
  39961. private _onResize;
  39962. private _hideMuteButton;
  39963. /**
  39964. * Destroy and release the resources associated with the audio ccontext.
  39965. */
  39966. dispose(): void;
  39967. /**
  39968. * Gets the global volume sets on the master gain.
  39969. * @returns the global volume if set or -1 otherwise
  39970. */
  39971. getGlobalVolume(): number;
  39972. /**
  39973. * Sets the global volume of your experience (sets on the master gain).
  39974. * @param newVolume Defines the new global volume of the application
  39975. */
  39976. setGlobalVolume(newVolume: number): void;
  39977. /**
  39978. * Connect the audio engine to an audio analyser allowing some amazing
  39979. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39980. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39981. * @param analyser The analyser to connect to the engine
  39982. */
  39983. connectToAnalyser(analyser: Analyser): void;
  39984. }
  39985. }
  39986. declare module BABYLON {
  39987. /**
  39988. * Interface used to present a loading screen while loading a scene
  39989. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39990. */
  39991. export interface ILoadingScreen {
  39992. /**
  39993. * Function called to display the loading screen
  39994. */
  39995. displayLoadingUI: () => void;
  39996. /**
  39997. * Function called to hide the loading screen
  39998. */
  39999. hideLoadingUI: () => void;
  40000. /**
  40001. * Gets or sets the color to use for the background
  40002. */
  40003. loadingUIBackgroundColor: string;
  40004. /**
  40005. * Gets or sets the text to display while loading
  40006. */
  40007. loadingUIText: string;
  40008. }
  40009. /**
  40010. * Class used for the default loading screen
  40011. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40012. */
  40013. export class DefaultLoadingScreen implements ILoadingScreen {
  40014. private _renderingCanvas;
  40015. private _loadingText;
  40016. private _loadingDivBackgroundColor;
  40017. private _loadingDiv;
  40018. private _loadingTextDiv;
  40019. /** Gets or sets the logo url to use for the default loading screen */
  40020. static DefaultLogoUrl: string;
  40021. /** Gets or sets the spinner url to use for the default loading screen */
  40022. static DefaultSpinnerUrl: string;
  40023. /**
  40024. * Creates a new default loading screen
  40025. * @param _renderingCanvas defines the canvas used to render the scene
  40026. * @param _loadingText defines the default text to display
  40027. * @param _loadingDivBackgroundColor defines the default background color
  40028. */
  40029. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40030. /**
  40031. * Function called to display the loading screen
  40032. */
  40033. displayLoadingUI(): void;
  40034. /**
  40035. * Function called to hide the loading screen
  40036. */
  40037. hideLoadingUI(): void;
  40038. /**
  40039. * Gets or sets the text to display while loading
  40040. */
  40041. set loadingUIText(text: string);
  40042. get loadingUIText(): string;
  40043. /**
  40044. * Gets or sets the color to use for the background
  40045. */
  40046. get loadingUIBackgroundColor(): string;
  40047. set loadingUIBackgroundColor(color: string);
  40048. private _resizeLoadingUI;
  40049. }
  40050. }
  40051. declare module BABYLON {
  40052. /**
  40053. * Interface for any object that can request an animation frame
  40054. */
  40055. export interface ICustomAnimationFrameRequester {
  40056. /**
  40057. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40058. */
  40059. renderFunction?: Function;
  40060. /**
  40061. * Called to request the next frame to render to
  40062. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40063. */
  40064. requestAnimationFrame: Function;
  40065. /**
  40066. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40067. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40068. */
  40069. requestID?: number;
  40070. }
  40071. }
  40072. declare module BABYLON {
  40073. /**
  40074. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40075. */
  40076. export class PerformanceMonitor {
  40077. private _enabled;
  40078. private _rollingFrameTime;
  40079. private _lastFrameTimeMs;
  40080. /**
  40081. * constructor
  40082. * @param frameSampleSize The number of samples required to saturate the sliding window
  40083. */
  40084. constructor(frameSampleSize?: number);
  40085. /**
  40086. * Samples current frame
  40087. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40088. */
  40089. sampleFrame(timeMs?: number): void;
  40090. /**
  40091. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40092. */
  40093. get averageFrameTime(): number;
  40094. /**
  40095. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40096. */
  40097. get averageFrameTimeVariance(): number;
  40098. /**
  40099. * Returns the frame time of the most recent frame
  40100. */
  40101. get instantaneousFrameTime(): number;
  40102. /**
  40103. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40104. */
  40105. get averageFPS(): number;
  40106. /**
  40107. * Returns the average framerate in frames per second using the most recent frame time
  40108. */
  40109. get instantaneousFPS(): number;
  40110. /**
  40111. * Returns true if enough samples have been taken to completely fill the sliding window
  40112. */
  40113. get isSaturated(): boolean;
  40114. /**
  40115. * Enables contributions to the sliding window sample set
  40116. */
  40117. enable(): void;
  40118. /**
  40119. * Disables contributions to the sliding window sample set
  40120. * Samples will not be interpolated over the disabled period
  40121. */
  40122. disable(): void;
  40123. /**
  40124. * Returns true if sampling is enabled
  40125. */
  40126. get isEnabled(): boolean;
  40127. /**
  40128. * Resets performance monitor
  40129. */
  40130. reset(): void;
  40131. }
  40132. /**
  40133. * RollingAverage
  40134. *
  40135. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40136. */
  40137. export class RollingAverage {
  40138. /**
  40139. * Current average
  40140. */
  40141. average: number;
  40142. /**
  40143. * Current variance
  40144. */
  40145. variance: number;
  40146. protected _samples: Array<number>;
  40147. protected _sampleCount: number;
  40148. protected _pos: number;
  40149. protected _m2: number;
  40150. /**
  40151. * constructor
  40152. * @param length The number of samples required to saturate the sliding window
  40153. */
  40154. constructor(length: number);
  40155. /**
  40156. * Adds a sample to the sample set
  40157. * @param v The sample value
  40158. */
  40159. add(v: number): void;
  40160. /**
  40161. * Returns previously added values or null if outside of history or outside the sliding window domain
  40162. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40163. * @return Value previously recorded with add() or null if outside of range
  40164. */
  40165. history(i: number): number;
  40166. /**
  40167. * Returns true if enough samples have been taken to completely fill the sliding window
  40168. * @return true if sample-set saturated
  40169. */
  40170. isSaturated(): boolean;
  40171. /**
  40172. * Resets the rolling average (equivalent to 0 samples taken so far)
  40173. */
  40174. reset(): void;
  40175. /**
  40176. * Wraps a value around the sample range boundaries
  40177. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40178. * @return Wrapped position in sample range
  40179. */
  40180. protected _wrapPosition(i: number): number;
  40181. }
  40182. }
  40183. declare module BABYLON {
  40184. /**
  40185. * This class is used to track a performance counter which is number based.
  40186. * The user has access to many properties which give statistics of different nature.
  40187. *
  40188. * The implementer can track two kinds of Performance Counter: time and count.
  40189. * 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.
  40190. * 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.
  40191. */
  40192. export class PerfCounter {
  40193. /**
  40194. * Gets or sets a global boolean to turn on and off all the counters
  40195. */
  40196. static Enabled: boolean;
  40197. /**
  40198. * Returns the smallest value ever
  40199. */
  40200. get min(): number;
  40201. /**
  40202. * Returns the biggest value ever
  40203. */
  40204. get max(): number;
  40205. /**
  40206. * Returns the average value since the performance counter is running
  40207. */
  40208. get average(): number;
  40209. /**
  40210. * Returns the average value of the last second the counter was monitored
  40211. */
  40212. get lastSecAverage(): number;
  40213. /**
  40214. * Returns the current value
  40215. */
  40216. get current(): number;
  40217. /**
  40218. * Gets the accumulated total
  40219. */
  40220. get total(): number;
  40221. /**
  40222. * Gets the total value count
  40223. */
  40224. get count(): number;
  40225. /**
  40226. * Creates a new counter
  40227. */
  40228. constructor();
  40229. /**
  40230. * Call this method to start monitoring a new frame.
  40231. * 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.
  40232. */
  40233. fetchNewFrame(): void;
  40234. /**
  40235. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40236. * @param newCount the count value to add to the monitored count
  40237. * @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.
  40238. */
  40239. addCount(newCount: number, fetchResult: boolean): void;
  40240. /**
  40241. * Start monitoring this performance counter
  40242. */
  40243. beginMonitoring(): void;
  40244. /**
  40245. * Compute the time lapsed since the previous beginMonitoring() call.
  40246. * @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
  40247. */
  40248. endMonitoring(newFrame?: boolean): void;
  40249. private _fetchResult;
  40250. private _startMonitoringTime;
  40251. private _min;
  40252. private _max;
  40253. private _average;
  40254. private _current;
  40255. private _totalValueCount;
  40256. private _totalAccumulated;
  40257. private _lastSecAverage;
  40258. private _lastSecAccumulated;
  40259. private _lastSecTime;
  40260. private _lastSecValueCount;
  40261. }
  40262. }
  40263. declare module BABYLON {
  40264. interface ThinEngine {
  40265. /** @hidden */
  40266. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40267. }
  40268. }
  40269. declare module BABYLON {
  40270. /**
  40271. * Defines the interface used by display changed events
  40272. */
  40273. export interface IDisplayChangedEventArgs {
  40274. /** Gets the vrDisplay object (if any) */
  40275. vrDisplay: Nullable<any>;
  40276. /** Gets a boolean indicating if webVR is supported */
  40277. vrSupported: boolean;
  40278. }
  40279. /**
  40280. * Defines the interface used by objects containing a viewport (like a camera)
  40281. */
  40282. interface IViewportOwnerLike {
  40283. /**
  40284. * Gets or sets the viewport
  40285. */
  40286. viewport: IViewportLike;
  40287. }
  40288. /**
  40289. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40290. */
  40291. export class Engine extends ThinEngine {
  40292. /** Defines that alpha blending is disabled */
  40293. static readonly ALPHA_DISABLE: number;
  40294. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40295. static readonly ALPHA_ADD: number;
  40296. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40297. static readonly ALPHA_COMBINE: number;
  40298. /** Defines that alpha blending to DEST - SRC * DEST */
  40299. static readonly ALPHA_SUBTRACT: number;
  40300. /** Defines that alpha blending to SRC * DEST */
  40301. static readonly ALPHA_MULTIPLY: number;
  40302. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40303. static readonly ALPHA_MAXIMIZED: number;
  40304. /** Defines that alpha blending to SRC + DEST */
  40305. static readonly ALPHA_ONEONE: number;
  40306. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40307. static readonly ALPHA_PREMULTIPLIED: number;
  40308. /**
  40309. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40310. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40311. */
  40312. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40313. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40314. static readonly ALPHA_INTERPOLATE: number;
  40315. /**
  40316. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40317. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40318. */
  40319. static readonly ALPHA_SCREENMODE: number;
  40320. /** Defines that the ressource is not delayed*/
  40321. static readonly DELAYLOADSTATE_NONE: number;
  40322. /** Defines that the ressource was successfully delay loaded */
  40323. static readonly DELAYLOADSTATE_LOADED: number;
  40324. /** Defines that the ressource is currently delay loading */
  40325. static readonly DELAYLOADSTATE_LOADING: number;
  40326. /** Defines that the ressource is delayed and has not started loading */
  40327. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40328. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40329. static readonly NEVER: number;
  40330. /** 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 */
  40331. static readonly ALWAYS: number;
  40332. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40333. static readonly LESS: number;
  40334. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40335. static readonly EQUAL: number;
  40336. /** 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 */
  40337. static readonly LEQUAL: number;
  40338. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40339. static readonly GREATER: number;
  40340. /** 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 */
  40341. static readonly GEQUAL: number;
  40342. /** 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 */
  40343. static readonly NOTEQUAL: number;
  40344. /** Passed to stencilOperation to specify that stencil value must be kept */
  40345. static readonly KEEP: number;
  40346. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40347. static readonly REPLACE: number;
  40348. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40349. static readonly INCR: number;
  40350. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40351. static readonly DECR: number;
  40352. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40353. static readonly INVERT: number;
  40354. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40355. static readonly INCR_WRAP: number;
  40356. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40357. static readonly DECR_WRAP: number;
  40358. /** Texture is not repeating outside of 0..1 UVs */
  40359. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40360. /** Texture is repeating outside of 0..1 UVs */
  40361. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40362. /** Texture is repeating and mirrored */
  40363. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40364. /** ALPHA */
  40365. static readonly TEXTUREFORMAT_ALPHA: number;
  40366. /** LUMINANCE */
  40367. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40368. /** LUMINANCE_ALPHA */
  40369. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40370. /** RGB */
  40371. static readonly TEXTUREFORMAT_RGB: number;
  40372. /** RGBA */
  40373. static readonly TEXTUREFORMAT_RGBA: number;
  40374. /** RED */
  40375. static readonly TEXTUREFORMAT_RED: number;
  40376. /** RED (2nd reference) */
  40377. static readonly TEXTUREFORMAT_R: number;
  40378. /** RG */
  40379. static readonly TEXTUREFORMAT_RG: number;
  40380. /** RED_INTEGER */
  40381. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40382. /** RED_INTEGER (2nd reference) */
  40383. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40384. /** RG_INTEGER */
  40385. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40386. /** RGB_INTEGER */
  40387. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40388. /** RGBA_INTEGER */
  40389. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40390. /** UNSIGNED_BYTE */
  40391. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40392. /** UNSIGNED_BYTE (2nd reference) */
  40393. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40394. /** FLOAT */
  40395. static readonly TEXTURETYPE_FLOAT: number;
  40396. /** HALF_FLOAT */
  40397. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40398. /** BYTE */
  40399. static readonly TEXTURETYPE_BYTE: number;
  40400. /** SHORT */
  40401. static readonly TEXTURETYPE_SHORT: number;
  40402. /** UNSIGNED_SHORT */
  40403. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40404. /** INT */
  40405. static readonly TEXTURETYPE_INT: number;
  40406. /** UNSIGNED_INT */
  40407. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40408. /** UNSIGNED_SHORT_4_4_4_4 */
  40409. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40410. /** UNSIGNED_SHORT_5_5_5_1 */
  40411. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40412. /** UNSIGNED_SHORT_5_6_5 */
  40413. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40414. /** UNSIGNED_INT_2_10_10_10_REV */
  40415. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40416. /** UNSIGNED_INT_24_8 */
  40417. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40418. /** UNSIGNED_INT_10F_11F_11F_REV */
  40419. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40420. /** UNSIGNED_INT_5_9_9_9_REV */
  40421. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40422. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40423. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40424. /** nearest is mag = nearest and min = nearest and mip = linear */
  40425. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40426. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40427. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40428. /** Trilinear is mag = linear and min = linear and mip = linear */
  40429. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40430. /** nearest is mag = nearest and min = nearest and mip = linear */
  40431. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40432. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40433. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40434. /** Trilinear is mag = linear and min = linear and mip = linear */
  40435. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40436. /** mag = nearest and min = nearest and mip = nearest */
  40437. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40438. /** mag = nearest and min = linear and mip = nearest */
  40439. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40440. /** mag = nearest and min = linear and mip = linear */
  40441. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40442. /** mag = nearest and min = linear and mip = none */
  40443. static readonly TEXTURE_NEAREST_LINEAR: number;
  40444. /** mag = nearest and min = nearest and mip = none */
  40445. static readonly TEXTURE_NEAREST_NEAREST: number;
  40446. /** mag = linear and min = nearest and mip = nearest */
  40447. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40448. /** mag = linear and min = nearest and mip = linear */
  40449. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40450. /** mag = linear and min = linear and mip = none */
  40451. static readonly TEXTURE_LINEAR_LINEAR: number;
  40452. /** mag = linear and min = nearest and mip = none */
  40453. static readonly TEXTURE_LINEAR_NEAREST: number;
  40454. /** Explicit coordinates mode */
  40455. static readonly TEXTURE_EXPLICIT_MODE: number;
  40456. /** Spherical coordinates mode */
  40457. static readonly TEXTURE_SPHERICAL_MODE: number;
  40458. /** Planar coordinates mode */
  40459. static readonly TEXTURE_PLANAR_MODE: number;
  40460. /** Cubic coordinates mode */
  40461. static readonly TEXTURE_CUBIC_MODE: number;
  40462. /** Projection coordinates mode */
  40463. static readonly TEXTURE_PROJECTION_MODE: number;
  40464. /** Skybox coordinates mode */
  40465. static readonly TEXTURE_SKYBOX_MODE: number;
  40466. /** Inverse Cubic coordinates mode */
  40467. static readonly TEXTURE_INVCUBIC_MODE: number;
  40468. /** Equirectangular coordinates mode */
  40469. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40470. /** Equirectangular Fixed coordinates mode */
  40471. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40472. /** Equirectangular Fixed Mirrored coordinates mode */
  40473. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40474. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40475. static readonly SCALEMODE_FLOOR: number;
  40476. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40477. static readonly SCALEMODE_NEAREST: number;
  40478. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40479. static readonly SCALEMODE_CEILING: number;
  40480. /**
  40481. * Returns the current npm package of the sdk
  40482. */
  40483. static get NpmPackage(): string;
  40484. /**
  40485. * Returns the current version of the framework
  40486. */
  40487. static get Version(): string;
  40488. /** Gets the list of created engines */
  40489. static get Instances(): Engine[];
  40490. /**
  40491. * Gets the latest created engine
  40492. */
  40493. static get LastCreatedEngine(): Nullable<Engine>;
  40494. /**
  40495. * Gets the latest created scene
  40496. */
  40497. static get LastCreatedScene(): Nullable<Scene>;
  40498. /**
  40499. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40500. * @param flag defines which part of the materials must be marked as dirty
  40501. * @param predicate defines a predicate used to filter which materials should be affected
  40502. */
  40503. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40504. /**
  40505. * Method called to create the default loading screen.
  40506. * This can be overriden in your own app.
  40507. * @param canvas The rendering canvas element
  40508. * @returns The loading screen
  40509. */
  40510. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40511. /**
  40512. * Method called to create the default rescale post process on each engine.
  40513. */
  40514. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40515. /**
  40516. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40517. **/
  40518. enableOfflineSupport: boolean;
  40519. /**
  40520. * 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)
  40521. **/
  40522. disableManifestCheck: boolean;
  40523. /**
  40524. * Gets the list of created scenes
  40525. */
  40526. scenes: Scene[];
  40527. /**
  40528. * Event raised when a new scene is created
  40529. */
  40530. onNewSceneAddedObservable: Observable<Scene>;
  40531. /**
  40532. * Gets the list of created postprocesses
  40533. */
  40534. postProcesses: PostProcess[];
  40535. /**
  40536. * Gets a boolean indicating if the pointer is currently locked
  40537. */
  40538. isPointerLock: boolean;
  40539. /**
  40540. * Observable event triggered each time the rendering canvas is resized
  40541. */
  40542. onResizeObservable: Observable<Engine>;
  40543. /**
  40544. * Observable event triggered each time the canvas loses focus
  40545. */
  40546. onCanvasBlurObservable: Observable<Engine>;
  40547. /**
  40548. * Observable event triggered each time the canvas gains focus
  40549. */
  40550. onCanvasFocusObservable: Observable<Engine>;
  40551. /**
  40552. * Observable event triggered each time the canvas receives pointerout event
  40553. */
  40554. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40555. /**
  40556. * Observable raised when the engine begins a new frame
  40557. */
  40558. onBeginFrameObservable: Observable<Engine>;
  40559. /**
  40560. * If set, will be used to request the next animation frame for the render loop
  40561. */
  40562. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40563. /**
  40564. * Observable raised when the engine ends the current frame
  40565. */
  40566. onEndFrameObservable: Observable<Engine>;
  40567. /**
  40568. * Observable raised when the engine is about to compile a shader
  40569. */
  40570. onBeforeShaderCompilationObservable: Observable<Engine>;
  40571. /**
  40572. * Observable raised when the engine has jsut compiled a shader
  40573. */
  40574. onAfterShaderCompilationObservable: Observable<Engine>;
  40575. /**
  40576. * Gets the audio engine
  40577. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40578. * @ignorenaming
  40579. */
  40580. static audioEngine: IAudioEngine;
  40581. /**
  40582. * Default AudioEngine factory responsible of creating the Audio Engine.
  40583. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40584. */
  40585. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40586. /**
  40587. * Default offline support factory responsible of creating a tool used to store data locally.
  40588. * By default, this will create a Database object if the workload has been embedded.
  40589. */
  40590. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40591. private _loadingScreen;
  40592. private _pointerLockRequested;
  40593. private _rescalePostProcess;
  40594. private _deterministicLockstep;
  40595. private _lockstepMaxSteps;
  40596. private _timeStep;
  40597. protected get _supportsHardwareTextureRescaling(): boolean;
  40598. private _fps;
  40599. private _deltaTime;
  40600. /** @hidden */
  40601. _drawCalls: PerfCounter;
  40602. /** 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 */
  40603. canvasTabIndex: number;
  40604. /**
  40605. * Turn this value on if you want to pause FPS computation when in background
  40606. */
  40607. disablePerformanceMonitorInBackground: boolean;
  40608. private _performanceMonitor;
  40609. /**
  40610. * Gets the performance monitor attached to this engine
  40611. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40612. */
  40613. get performanceMonitor(): PerformanceMonitor;
  40614. private _onFocus;
  40615. private _onBlur;
  40616. private _onCanvasPointerOut;
  40617. private _onCanvasBlur;
  40618. private _onCanvasFocus;
  40619. private _onFullscreenChange;
  40620. private _onPointerLockChange;
  40621. /**
  40622. * Gets the HTML element used to attach event listeners
  40623. * @returns a HTML element
  40624. */
  40625. getInputElement(): Nullable<HTMLElement>;
  40626. /**
  40627. * Creates a new engine
  40628. * @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
  40629. * @param antialias defines enable antialiasing (default: false)
  40630. * @param options defines further options to be sent to the getContext() function
  40631. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40632. */
  40633. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40634. /**
  40635. * Gets current aspect ratio
  40636. * @param viewportOwner defines the camera to use to get the aspect ratio
  40637. * @param useScreen defines if screen size must be used (or the current render target if any)
  40638. * @returns a number defining the aspect ratio
  40639. */
  40640. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  40641. /**
  40642. * Gets current screen aspect ratio
  40643. * @returns a number defining the aspect ratio
  40644. */
  40645. getScreenAspectRatio(): number;
  40646. /**
  40647. * Gets the client rect of the HTML canvas attached with the current webGL context
  40648. * @returns a client rectanglee
  40649. */
  40650. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  40651. /**
  40652. * Gets the client rect of the HTML element used for events
  40653. * @returns a client rectanglee
  40654. */
  40655. getInputElementClientRect(): Nullable<ClientRect>;
  40656. /**
  40657. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  40658. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40659. * @returns true if engine is in deterministic lock step mode
  40660. */
  40661. isDeterministicLockStep(): boolean;
  40662. /**
  40663. * Gets the max steps when engine is running in deterministic lock step
  40664. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40665. * @returns the max steps
  40666. */
  40667. getLockstepMaxSteps(): number;
  40668. /**
  40669. * Returns the time in ms between steps when using deterministic lock step.
  40670. * @returns time step in (ms)
  40671. */
  40672. getTimeStep(): number;
  40673. /**
  40674. * Force the mipmap generation for the given render target texture
  40675. * @param texture defines the render target texture to use
  40676. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  40677. */
  40678. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  40679. /** States */
  40680. /**
  40681. * Set various states to the webGL context
  40682. * @param culling defines backface culling state
  40683. * @param zOffset defines the value to apply to zOffset (0 by default)
  40684. * @param force defines if states must be applied even if cache is up to date
  40685. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  40686. */
  40687. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40688. /**
  40689. * Set the z offset to apply to current rendering
  40690. * @param value defines the offset to apply
  40691. */
  40692. setZOffset(value: number): void;
  40693. /**
  40694. * Gets the current value of the zOffset
  40695. * @returns the current zOffset state
  40696. */
  40697. getZOffset(): number;
  40698. /**
  40699. * Enable or disable depth buffering
  40700. * @param enable defines the state to set
  40701. */
  40702. setDepthBuffer(enable: boolean): void;
  40703. /**
  40704. * Gets a boolean indicating if depth writing is enabled
  40705. * @returns the current depth writing state
  40706. */
  40707. getDepthWrite(): boolean;
  40708. /**
  40709. * Enable or disable depth writing
  40710. * @param enable defines the state to set
  40711. */
  40712. setDepthWrite(enable: boolean): void;
  40713. /**
  40714. * Gets a boolean indicating if stencil buffer is enabled
  40715. * @returns the current stencil buffer state
  40716. */
  40717. getStencilBuffer(): boolean;
  40718. /**
  40719. * Enable or disable the stencil buffer
  40720. * @param enable defines if the stencil buffer must be enabled or disabled
  40721. */
  40722. setStencilBuffer(enable: boolean): void;
  40723. /**
  40724. * Gets the current stencil mask
  40725. * @returns a number defining the new stencil mask to use
  40726. */
  40727. getStencilMask(): number;
  40728. /**
  40729. * Sets the current stencil mask
  40730. * @param mask defines the new stencil mask to use
  40731. */
  40732. setStencilMask(mask: number): void;
  40733. /**
  40734. * Gets the current stencil function
  40735. * @returns a number defining the stencil function to use
  40736. */
  40737. getStencilFunction(): number;
  40738. /**
  40739. * Gets the current stencil reference value
  40740. * @returns a number defining the stencil reference value to use
  40741. */
  40742. getStencilFunctionReference(): number;
  40743. /**
  40744. * Gets the current stencil mask
  40745. * @returns a number defining the stencil mask to use
  40746. */
  40747. getStencilFunctionMask(): number;
  40748. /**
  40749. * Sets the current stencil function
  40750. * @param stencilFunc defines the new stencil function to use
  40751. */
  40752. setStencilFunction(stencilFunc: number): void;
  40753. /**
  40754. * Sets the current stencil reference
  40755. * @param reference defines the new stencil reference to use
  40756. */
  40757. setStencilFunctionReference(reference: number): void;
  40758. /**
  40759. * Sets the current stencil mask
  40760. * @param mask defines the new stencil mask to use
  40761. */
  40762. setStencilFunctionMask(mask: number): void;
  40763. /**
  40764. * Gets the current stencil operation when stencil fails
  40765. * @returns a number defining stencil operation to use when stencil fails
  40766. */
  40767. getStencilOperationFail(): number;
  40768. /**
  40769. * Gets the current stencil operation when depth fails
  40770. * @returns a number defining stencil operation to use when depth fails
  40771. */
  40772. getStencilOperationDepthFail(): number;
  40773. /**
  40774. * Gets the current stencil operation when stencil passes
  40775. * @returns a number defining stencil operation to use when stencil passes
  40776. */
  40777. getStencilOperationPass(): number;
  40778. /**
  40779. * Sets the stencil operation to use when stencil fails
  40780. * @param operation defines the stencil operation to use when stencil fails
  40781. */
  40782. setStencilOperationFail(operation: number): void;
  40783. /**
  40784. * Sets the stencil operation to use when depth fails
  40785. * @param operation defines the stencil operation to use when depth fails
  40786. */
  40787. setStencilOperationDepthFail(operation: number): void;
  40788. /**
  40789. * Sets the stencil operation to use when stencil passes
  40790. * @param operation defines the stencil operation to use when stencil passes
  40791. */
  40792. setStencilOperationPass(operation: number): void;
  40793. /**
  40794. * Sets a boolean indicating if the dithering state is enabled or disabled
  40795. * @param value defines the dithering state
  40796. */
  40797. setDitheringState(value: boolean): void;
  40798. /**
  40799. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  40800. * @param value defines the rasterizer state
  40801. */
  40802. setRasterizerState(value: boolean): void;
  40803. /**
  40804. * Gets the current depth function
  40805. * @returns a number defining the depth function
  40806. */
  40807. getDepthFunction(): Nullable<number>;
  40808. /**
  40809. * Sets the current depth function
  40810. * @param depthFunc defines the function to use
  40811. */
  40812. setDepthFunction(depthFunc: number): void;
  40813. /**
  40814. * Sets the current depth function to GREATER
  40815. */
  40816. setDepthFunctionToGreater(): void;
  40817. /**
  40818. * Sets the current depth function to GEQUAL
  40819. */
  40820. setDepthFunctionToGreaterOrEqual(): void;
  40821. /**
  40822. * Sets the current depth function to LESS
  40823. */
  40824. setDepthFunctionToLess(): void;
  40825. /**
  40826. * Sets the current depth function to LEQUAL
  40827. */
  40828. setDepthFunctionToLessOrEqual(): void;
  40829. private _cachedStencilBuffer;
  40830. private _cachedStencilFunction;
  40831. private _cachedStencilMask;
  40832. private _cachedStencilOperationPass;
  40833. private _cachedStencilOperationFail;
  40834. private _cachedStencilOperationDepthFail;
  40835. private _cachedStencilReference;
  40836. /**
  40837. * Caches the the state of the stencil buffer
  40838. */
  40839. cacheStencilState(): void;
  40840. /**
  40841. * Restores the state of the stencil buffer
  40842. */
  40843. restoreStencilState(): void;
  40844. /**
  40845. * Directly set the WebGL Viewport
  40846. * @param x defines the x coordinate of the viewport (in screen space)
  40847. * @param y defines the y coordinate of the viewport (in screen space)
  40848. * @param width defines the width of the viewport (in screen space)
  40849. * @param height defines the height of the viewport (in screen space)
  40850. * @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
  40851. */
  40852. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  40853. /**
  40854. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  40855. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40856. * @param y defines the y-coordinate of the corner of the clear rectangle
  40857. * @param width defines the width of the clear rectangle
  40858. * @param height defines the height of the clear rectangle
  40859. * @param clearColor defines the clear color
  40860. */
  40861. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  40862. /**
  40863. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  40864. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40865. * @param y defines the y-coordinate of the corner of the clear rectangle
  40866. * @param width defines the width of the clear rectangle
  40867. * @param height defines the height of the clear rectangle
  40868. */
  40869. enableScissor(x: number, y: number, width: number, height: number): void;
  40870. /**
  40871. * Disable previously set scissor test rectangle
  40872. */
  40873. disableScissor(): void;
  40874. protected _reportDrawCall(): void;
  40875. /**
  40876. * Initializes a webVR display and starts listening to display change events
  40877. * The onVRDisplayChangedObservable will be notified upon these changes
  40878. * @returns The onVRDisplayChangedObservable
  40879. */
  40880. initWebVR(): Observable<IDisplayChangedEventArgs>;
  40881. /** @hidden */
  40882. _prepareVRComponent(): void;
  40883. /** @hidden */
  40884. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  40885. /** @hidden */
  40886. _submitVRFrame(): void;
  40887. /**
  40888. * Call this function to leave webVR mode
  40889. * Will do nothing if webVR is not supported or if there is no webVR device
  40890. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40891. */
  40892. disableVR(): void;
  40893. /**
  40894. * Gets a boolean indicating that the system is in VR mode and is presenting
  40895. * @returns true if VR mode is engaged
  40896. */
  40897. isVRPresenting(): boolean;
  40898. /** @hidden */
  40899. _requestVRFrame(): void;
  40900. /** @hidden */
  40901. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40902. /**
  40903. * Gets the source code of the vertex shader associated with a specific webGL program
  40904. * @param program defines the program to use
  40905. * @returns a string containing the source code of the vertex shader associated with the program
  40906. */
  40907. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  40908. /**
  40909. * Gets the source code of the fragment shader associated with a specific webGL program
  40910. * @param program defines the program to use
  40911. * @returns a string containing the source code of the fragment shader associated with the program
  40912. */
  40913. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  40914. /**
  40915. * Sets a depth stencil texture from a render target to the according uniform.
  40916. * @param channel The texture channel
  40917. * @param uniform The uniform to set
  40918. * @param texture The render target texture containing the depth stencil texture to apply
  40919. */
  40920. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  40921. /**
  40922. * Sets a texture to the webGL context from a postprocess
  40923. * @param channel defines the channel to use
  40924. * @param postProcess defines the source postprocess
  40925. */
  40926. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  40927. /**
  40928. * Binds the output of the passed in post process to the texture channel specified
  40929. * @param channel The channel the texture should be bound to
  40930. * @param postProcess The post process which's output should be bound
  40931. */
  40932. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  40933. protected _rebuildBuffers(): void;
  40934. /** @hidden */
  40935. _renderFrame(): void;
  40936. _renderLoop(): void;
  40937. /** @hidden */
  40938. _renderViews(): boolean;
  40939. /**
  40940. * Toggle full screen mode
  40941. * @param requestPointerLock defines if a pointer lock should be requested from the user
  40942. */
  40943. switchFullscreen(requestPointerLock: boolean): void;
  40944. /**
  40945. * Enters full screen mode
  40946. * @param requestPointerLock defines if a pointer lock should be requested from the user
  40947. */
  40948. enterFullscreen(requestPointerLock: boolean): void;
  40949. /**
  40950. * Exits full screen mode
  40951. */
  40952. exitFullscreen(): void;
  40953. /**
  40954. * Enters Pointerlock mode
  40955. */
  40956. enterPointerlock(): void;
  40957. /**
  40958. * Exits Pointerlock mode
  40959. */
  40960. exitPointerlock(): void;
  40961. /**
  40962. * Begin a new frame
  40963. */
  40964. beginFrame(): void;
  40965. /**
  40966. * Enf the current frame
  40967. */
  40968. endFrame(): void;
  40969. resize(): void;
  40970. /**
  40971. * Force a specific size of the canvas
  40972. * @param width defines the new canvas' width
  40973. * @param height defines the new canvas' height
  40974. * @returns true if the size was changed
  40975. */
  40976. setSize(width: number, height: number): boolean;
  40977. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40978. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40979. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40980. _releaseTexture(texture: InternalTexture): void;
  40981. /**
  40982. * @hidden
  40983. * Rescales a texture
  40984. * @param source input texutre
  40985. * @param destination destination texture
  40986. * @param scene scene to use to render the resize
  40987. * @param internalFormat format to use when resizing
  40988. * @param onComplete callback to be called when resize has completed
  40989. */
  40990. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40991. /**
  40992. * Gets the current framerate
  40993. * @returns a number representing the framerate
  40994. */
  40995. getFps(): number;
  40996. /**
  40997. * Gets the time spent between current and previous frame
  40998. * @returns a number representing the delta time in ms
  40999. */
  41000. getDeltaTime(): number;
  41001. private _measureFps;
  41002. /** @hidden */
  41003. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41004. /**
  41005. * Updates the sample count of a render target texture
  41006. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41007. * @param texture defines the texture to update
  41008. * @param samples defines the sample count to set
  41009. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41010. */
  41011. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41012. /**
  41013. * Updates a depth texture Comparison Mode and Function.
  41014. * If the comparison Function is equal to 0, the mode will be set to none.
  41015. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41016. * @param texture The texture to set the comparison function for
  41017. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41018. */
  41019. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41020. /**
  41021. * Creates a webGL buffer to use with instanciation
  41022. * @param capacity defines the size of the buffer
  41023. * @returns the webGL buffer
  41024. */
  41025. createInstancesBuffer(capacity: number): DataBuffer;
  41026. /**
  41027. * Delete a webGL buffer used with instanciation
  41028. * @param buffer defines the webGL buffer to delete
  41029. */
  41030. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41031. private _clientWaitAsync;
  41032. /** @hidden */
  41033. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41034. dispose(): void;
  41035. private _disableTouchAction;
  41036. /**
  41037. * Display the loading screen
  41038. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41039. */
  41040. displayLoadingUI(): void;
  41041. /**
  41042. * Hide the loading screen
  41043. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41044. */
  41045. hideLoadingUI(): void;
  41046. /**
  41047. * Gets the current loading screen object
  41048. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41049. */
  41050. get loadingScreen(): ILoadingScreen;
  41051. /**
  41052. * Sets the current loading screen object
  41053. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41054. */
  41055. set loadingScreen(loadingScreen: ILoadingScreen);
  41056. /**
  41057. * Sets the current loading screen text
  41058. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41059. */
  41060. set loadingUIText(text: string);
  41061. /**
  41062. * Sets the current loading screen background color
  41063. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41064. */
  41065. set loadingUIBackgroundColor(color: string);
  41066. /** Pointerlock and fullscreen */
  41067. /**
  41068. * Ask the browser to promote the current element to pointerlock mode
  41069. * @param element defines the DOM element to promote
  41070. */
  41071. static _RequestPointerlock(element: HTMLElement): void;
  41072. /**
  41073. * Asks the browser to exit pointerlock mode
  41074. */
  41075. static _ExitPointerlock(): void;
  41076. /**
  41077. * Ask the browser to promote the current element to fullscreen rendering mode
  41078. * @param element defines the DOM element to promote
  41079. */
  41080. static _RequestFullscreen(element: HTMLElement): void;
  41081. /**
  41082. * Asks the browser to exit fullscreen mode
  41083. */
  41084. static _ExitFullscreen(): void;
  41085. }
  41086. }
  41087. declare module BABYLON {
  41088. /**
  41089. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41090. * during the life time of the application.
  41091. */
  41092. export class EngineStore {
  41093. /** Gets the list of created engines */
  41094. static Instances: Engine[];
  41095. /** @hidden */
  41096. static _LastCreatedScene: Nullable<Scene>;
  41097. /**
  41098. * Gets the latest created engine
  41099. */
  41100. static get LastCreatedEngine(): Nullable<Engine>;
  41101. /**
  41102. * Gets the latest created scene
  41103. */
  41104. static get LastCreatedScene(): Nullable<Scene>;
  41105. /**
  41106. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41107. * @ignorenaming
  41108. */
  41109. static UseFallbackTexture: boolean;
  41110. /**
  41111. * Texture content used if a texture cannot loaded
  41112. * @ignorenaming
  41113. */
  41114. static FallbackTexture: string;
  41115. }
  41116. }
  41117. declare module BABYLON {
  41118. /**
  41119. * Helper class that provides a small promise polyfill
  41120. */
  41121. export class PromisePolyfill {
  41122. /**
  41123. * Static function used to check if the polyfill is required
  41124. * If this is the case then the function will inject the polyfill to window.Promise
  41125. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41126. */
  41127. static Apply(force?: boolean): void;
  41128. }
  41129. }
  41130. declare module BABYLON {
  41131. /**
  41132. * Interface for screenshot methods with describe argument called `size` as object with options
  41133. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41134. */
  41135. export interface IScreenshotSize {
  41136. /**
  41137. * number in pixels for canvas height
  41138. */
  41139. height?: number;
  41140. /**
  41141. * multiplier allowing render at a higher or lower resolution
  41142. * If value is defined then height and width will be ignored and taken from camera
  41143. */
  41144. precision?: number;
  41145. /**
  41146. * number in pixels for canvas width
  41147. */
  41148. width?: number;
  41149. }
  41150. }
  41151. declare module BABYLON {
  41152. interface IColor4Like {
  41153. r: float;
  41154. g: float;
  41155. b: float;
  41156. a: float;
  41157. }
  41158. /**
  41159. * Class containing a set of static utilities functions
  41160. */
  41161. export class Tools {
  41162. /**
  41163. * Gets or sets the base URL to use to load assets
  41164. */
  41165. static get BaseUrl(): string;
  41166. static set BaseUrl(value: string);
  41167. /**
  41168. * Enable/Disable Custom HTTP Request Headers globally.
  41169. * default = false
  41170. * @see CustomRequestHeaders
  41171. */
  41172. static UseCustomRequestHeaders: boolean;
  41173. /**
  41174. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41175. * i.e. when loading files, where the server/service expects an Authorization header
  41176. */
  41177. static CustomRequestHeaders: {
  41178. [key: string]: string;
  41179. };
  41180. /**
  41181. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41182. */
  41183. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41184. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41185. /**
  41186. * Default behaviour for cors in the application.
  41187. * It can be a string if the expected behavior is identical in the entire app.
  41188. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41189. */
  41190. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41191. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41192. /**
  41193. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41194. * @ignorenaming
  41195. */
  41196. static get UseFallbackTexture(): boolean;
  41197. static set UseFallbackTexture(value: boolean);
  41198. /**
  41199. * Use this object to register external classes like custom textures or material
  41200. * to allow the laoders to instantiate them
  41201. */
  41202. static get RegisteredExternalClasses(): {
  41203. [key: string]: Object;
  41204. };
  41205. static set RegisteredExternalClasses(classes: {
  41206. [key: string]: Object;
  41207. });
  41208. /**
  41209. * Texture content used if a texture cannot loaded
  41210. * @ignorenaming
  41211. */
  41212. static get fallbackTexture(): string;
  41213. static set fallbackTexture(value: string);
  41214. /**
  41215. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41216. * @param u defines the coordinate on X axis
  41217. * @param v defines the coordinate on Y axis
  41218. * @param width defines the width of the source data
  41219. * @param height defines the height of the source data
  41220. * @param pixels defines the source byte array
  41221. * @param color defines the output color
  41222. */
  41223. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41224. /**
  41225. * Interpolates between a and b via alpha
  41226. * @param a The lower value (returned when alpha = 0)
  41227. * @param b The upper value (returned when alpha = 1)
  41228. * @param alpha The interpolation-factor
  41229. * @return The mixed value
  41230. */
  41231. static Mix(a: number, b: number, alpha: number): number;
  41232. /**
  41233. * Tries to instantiate a new object from a given class name
  41234. * @param className defines the class name to instantiate
  41235. * @returns the new object or null if the system was not able to do the instantiation
  41236. */
  41237. static Instantiate(className: string): any;
  41238. /**
  41239. * Provides a slice function that will work even on IE
  41240. * @param data defines the array to slice
  41241. * @param start defines the start of the data (optional)
  41242. * @param end defines the end of the data (optional)
  41243. * @returns the new sliced array
  41244. */
  41245. static Slice<T>(data: T, start?: number, end?: number): T;
  41246. /**
  41247. * Polyfill for setImmediate
  41248. * @param action defines the action to execute after the current execution block
  41249. */
  41250. static SetImmediate(action: () => void): void;
  41251. /**
  41252. * Function indicating if a number is an exponent of 2
  41253. * @param value defines the value to test
  41254. * @returns true if the value is an exponent of 2
  41255. */
  41256. static IsExponentOfTwo(value: number): boolean;
  41257. private static _tmpFloatArray;
  41258. /**
  41259. * Returns the nearest 32-bit single precision float representation of a Number
  41260. * @param value A Number. If the parameter is of a different type, it will get converted
  41261. * to a number or to NaN if it cannot be converted
  41262. * @returns number
  41263. */
  41264. static FloatRound(value: number): number;
  41265. /**
  41266. * Extracts the filename from a path
  41267. * @param path defines the path to use
  41268. * @returns the filename
  41269. */
  41270. static GetFilename(path: string): string;
  41271. /**
  41272. * Extracts the "folder" part of a path (everything before the filename).
  41273. * @param uri The URI to extract the info from
  41274. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41275. * @returns The "folder" part of the path
  41276. */
  41277. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41278. /**
  41279. * Extracts text content from a DOM element hierarchy
  41280. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41281. */
  41282. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41283. /**
  41284. * Convert an angle in radians to degrees
  41285. * @param angle defines the angle to convert
  41286. * @returns the angle in degrees
  41287. */
  41288. static ToDegrees(angle: number): number;
  41289. /**
  41290. * Convert an angle in degrees to radians
  41291. * @param angle defines the angle to convert
  41292. * @returns the angle in radians
  41293. */
  41294. static ToRadians(angle: number): number;
  41295. /**
  41296. * Returns an array if obj is not an array
  41297. * @param obj defines the object to evaluate as an array
  41298. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41299. * @returns either obj directly if obj is an array or a new array containing obj
  41300. */
  41301. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41302. /**
  41303. * Gets the pointer prefix to use
  41304. * @param engine defines the engine we are finding the prefix for
  41305. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41306. */
  41307. static GetPointerPrefix(engine: Engine): string;
  41308. /**
  41309. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41310. * @param url define the url we are trying
  41311. * @param element define the dom element where to configure the cors policy
  41312. */
  41313. static SetCorsBehavior(url: string | string[], element: {
  41314. crossOrigin: string | null;
  41315. }): void;
  41316. /**
  41317. * Removes unwanted characters from an url
  41318. * @param url defines the url to clean
  41319. * @returns the cleaned url
  41320. */
  41321. static CleanUrl(url: string): string;
  41322. /**
  41323. * Gets or sets a function used to pre-process url before using them to load assets
  41324. */
  41325. static get PreprocessUrl(): (url: string) => string;
  41326. static set PreprocessUrl(processor: (url: string) => string);
  41327. /**
  41328. * Loads an image as an HTMLImageElement.
  41329. * @param input url string, ArrayBuffer, or Blob to load
  41330. * @param onLoad callback called when the image successfully loads
  41331. * @param onError callback called when the image fails to load
  41332. * @param offlineProvider offline provider for caching
  41333. * @param mimeType optional mime type
  41334. * @returns the HTMLImageElement of the loaded image
  41335. */
  41336. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41337. /**
  41338. * Loads a file from a url
  41339. * @param url url string, ArrayBuffer, or Blob to load
  41340. * @param onSuccess callback called when the file successfully loads
  41341. * @param onProgress callback called while file is loading (if the server supports this mode)
  41342. * @param offlineProvider defines the offline provider for caching
  41343. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41344. * @param onError callback called when the file fails to load
  41345. * @returns a file request object
  41346. */
  41347. 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;
  41348. /**
  41349. * Loads a file from a url
  41350. * @param url the file url to load
  41351. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41352. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41353. */
  41354. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41355. /**
  41356. * Load a script (identified by an url). When the url returns, the
  41357. * content of this file is added into a new script element, attached to the DOM (body element)
  41358. * @param scriptUrl defines the url of the script to laod
  41359. * @param onSuccess defines the callback called when the script is loaded
  41360. * @param onError defines the callback to call if an error occurs
  41361. * @param scriptId defines the id of the script element
  41362. */
  41363. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41364. /**
  41365. * Load an asynchronous script (identified by an url). When the url returns, the
  41366. * content of this file is added into a new script element, attached to the DOM (body element)
  41367. * @param scriptUrl defines the url of the script to laod
  41368. * @param scriptId defines the id of the script element
  41369. * @returns a promise request object
  41370. */
  41371. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41372. /**
  41373. * Loads a file from a blob
  41374. * @param fileToLoad defines the blob to use
  41375. * @param callback defines the callback to call when data is loaded
  41376. * @param progressCallback defines the callback to call during loading process
  41377. * @returns a file request object
  41378. */
  41379. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41380. /**
  41381. * Reads a file from a File object
  41382. * @param file defines the file to load
  41383. * @param onSuccess defines the callback to call when data is loaded
  41384. * @param onProgress defines the callback to call during loading process
  41385. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41386. * @param onError defines the callback to call when an error occurs
  41387. * @returns a file request object
  41388. */
  41389. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41390. /**
  41391. * Creates a data url from a given string content
  41392. * @param content defines the content to convert
  41393. * @returns the new data url link
  41394. */
  41395. static FileAsURL(content: string): string;
  41396. /**
  41397. * Format the given number to a specific decimal format
  41398. * @param value defines the number to format
  41399. * @param decimals defines the number of decimals to use
  41400. * @returns the formatted string
  41401. */
  41402. static Format(value: number, decimals?: number): string;
  41403. /**
  41404. * Tries to copy an object by duplicating every property
  41405. * @param source defines the source object
  41406. * @param destination defines the target object
  41407. * @param doNotCopyList defines a list of properties to avoid
  41408. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41409. */
  41410. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41411. /**
  41412. * Gets a boolean indicating if the given object has no own property
  41413. * @param obj defines the object to test
  41414. * @returns true if object has no own property
  41415. */
  41416. static IsEmpty(obj: any): boolean;
  41417. /**
  41418. * Function used to register events at window level
  41419. * @param windowElement defines the Window object to use
  41420. * @param events defines the events to register
  41421. */
  41422. static RegisterTopRootEvents(windowElement: Window, events: {
  41423. name: string;
  41424. handler: Nullable<(e: FocusEvent) => any>;
  41425. }[]): void;
  41426. /**
  41427. * Function used to unregister events from window level
  41428. * @param windowElement defines the Window object to use
  41429. * @param events defines the events to unregister
  41430. */
  41431. static UnregisterTopRootEvents(windowElement: Window, events: {
  41432. name: string;
  41433. handler: Nullable<(e: FocusEvent) => any>;
  41434. }[]): void;
  41435. /**
  41436. * @ignore
  41437. */
  41438. static _ScreenshotCanvas: HTMLCanvasElement;
  41439. /**
  41440. * Dumps the current bound framebuffer
  41441. * @param width defines the rendering width
  41442. * @param height defines the rendering height
  41443. * @param engine defines the hosting engine
  41444. * @param successCallback defines the callback triggered once the data are available
  41445. * @param mimeType defines the mime type of the result
  41446. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41447. */
  41448. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41449. /**
  41450. * Converts the canvas data to blob.
  41451. * This acts as a polyfill for browsers not supporting the to blob function.
  41452. * @param canvas Defines the canvas to extract the data from
  41453. * @param successCallback Defines the callback triggered once the data are available
  41454. * @param mimeType Defines the mime type of the result
  41455. */
  41456. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41457. /**
  41458. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41459. * @param successCallback defines the callback triggered once the data are available
  41460. * @param mimeType defines the mime type of the result
  41461. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41462. */
  41463. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41464. /**
  41465. * Downloads a blob in the browser
  41466. * @param blob defines the blob to download
  41467. * @param fileName defines the name of the downloaded file
  41468. */
  41469. static Download(blob: Blob, fileName: string): void;
  41470. /**
  41471. * Captures a screenshot of the current rendering
  41472. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41473. * @param engine defines the rendering engine
  41474. * @param camera defines the source camera
  41475. * @param size This parameter can be set to a single number or to an object with the
  41476. * following (optional) properties: precision, width, height. If a single number is passed,
  41477. * it will be used for both width and height. If an object is passed, the screenshot size
  41478. * will be derived from the parameters. The precision property is a multiplier allowing
  41479. * rendering at a higher or lower resolution
  41480. * @param successCallback defines the callback receives a single parameter which contains the
  41481. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41482. * src parameter of an <img> to display it
  41483. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41484. * Check your browser for supported MIME types
  41485. */
  41486. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41487. /**
  41488. * Captures a screenshot of the current rendering
  41489. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41490. * @param engine defines the rendering engine
  41491. * @param camera defines the source camera
  41492. * @param size This parameter can be set to a single number or to an object with the
  41493. * following (optional) properties: precision, width, height. If a single number is passed,
  41494. * it will be used for both width and height. If an object is passed, the screenshot size
  41495. * will be derived from the parameters. The precision property is a multiplier allowing
  41496. * rendering at a higher or lower resolution
  41497. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41498. * Check your browser for supported MIME types
  41499. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41500. * to the src parameter of an <img> to display it
  41501. */
  41502. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41503. /**
  41504. * Generates an image screenshot from the specified camera.
  41505. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41506. * @param engine The engine to use for rendering
  41507. * @param camera The camera to use for rendering
  41508. * @param size This parameter can be set to a single number or to an object with the
  41509. * following (optional) properties: precision, width, height. If a single number is passed,
  41510. * it will be used for both width and height. If an object is passed, the screenshot size
  41511. * will be derived from the parameters. The precision property is a multiplier allowing
  41512. * rendering at a higher or lower resolution
  41513. * @param successCallback The callback receives a single parameter which contains the
  41514. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41515. * src parameter of an <img> to display it
  41516. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41517. * Check your browser for supported MIME types
  41518. * @param samples Texture samples (default: 1)
  41519. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41520. * @param fileName A name for for the downloaded file.
  41521. */
  41522. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41523. /**
  41524. * Generates an image screenshot from the specified camera.
  41525. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41526. * @param engine The engine to use for rendering
  41527. * @param camera The camera to use for rendering
  41528. * @param size This parameter can be set to a single number or to an object with the
  41529. * following (optional) properties: precision, width, height. If a single number is passed,
  41530. * it will be used for both width and height. If an object is passed, the screenshot size
  41531. * will be derived from the parameters. The precision property is a multiplier allowing
  41532. * rendering at a higher or lower resolution
  41533. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41534. * Check your browser for supported MIME types
  41535. * @param samples Texture samples (default: 1)
  41536. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41537. * @param fileName A name for for the downloaded file.
  41538. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41539. * to the src parameter of an <img> to display it
  41540. */
  41541. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41542. /**
  41543. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41544. * Be aware Math.random() could cause collisions, but:
  41545. * "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"
  41546. * @returns a pseudo random id
  41547. */
  41548. static RandomId(): string;
  41549. /**
  41550. * Test if the given uri is a base64 string
  41551. * @param uri The uri to test
  41552. * @return True if the uri is a base64 string or false otherwise
  41553. */
  41554. static IsBase64(uri: string): boolean;
  41555. /**
  41556. * Decode the given base64 uri.
  41557. * @param uri The uri to decode
  41558. * @return The decoded base64 data.
  41559. */
  41560. static DecodeBase64(uri: string): ArrayBuffer;
  41561. /**
  41562. * Gets the absolute url.
  41563. * @param url the input url
  41564. * @return the absolute url
  41565. */
  41566. static GetAbsoluteUrl(url: string): string;
  41567. /**
  41568. * No log
  41569. */
  41570. static readonly NoneLogLevel: number;
  41571. /**
  41572. * Only message logs
  41573. */
  41574. static readonly MessageLogLevel: number;
  41575. /**
  41576. * Only warning logs
  41577. */
  41578. static readonly WarningLogLevel: number;
  41579. /**
  41580. * Only error logs
  41581. */
  41582. static readonly ErrorLogLevel: number;
  41583. /**
  41584. * All logs
  41585. */
  41586. static readonly AllLogLevel: number;
  41587. /**
  41588. * Gets a value indicating the number of loading errors
  41589. * @ignorenaming
  41590. */
  41591. static get errorsCount(): number;
  41592. /**
  41593. * Callback called when a new log is added
  41594. */
  41595. static OnNewCacheEntry: (entry: string) => void;
  41596. /**
  41597. * Log a message to the console
  41598. * @param message defines the message to log
  41599. */
  41600. static Log(message: string): void;
  41601. /**
  41602. * Write a warning message to the console
  41603. * @param message defines the message to log
  41604. */
  41605. static Warn(message: string): void;
  41606. /**
  41607. * Write an error message to the console
  41608. * @param message defines the message to log
  41609. */
  41610. static Error(message: string): void;
  41611. /**
  41612. * Gets current log cache (list of logs)
  41613. */
  41614. static get LogCache(): string;
  41615. /**
  41616. * Clears the log cache
  41617. */
  41618. static ClearLogCache(): void;
  41619. /**
  41620. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41621. */
  41622. static set LogLevels(level: number);
  41623. /**
  41624. * Checks if the window object exists
  41625. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  41626. */
  41627. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  41628. /**
  41629. * No performance log
  41630. */
  41631. static readonly PerformanceNoneLogLevel: number;
  41632. /**
  41633. * Use user marks to log performance
  41634. */
  41635. static readonly PerformanceUserMarkLogLevel: number;
  41636. /**
  41637. * Log performance to the console
  41638. */
  41639. static readonly PerformanceConsoleLogLevel: number;
  41640. private static _performance;
  41641. /**
  41642. * Sets the current performance log level
  41643. */
  41644. static set PerformanceLogLevel(level: number);
  41645. private static _StartPerformanceCounterDisabled;
  41646. private static _EndPerformanceCounterDisabled;
  41647. private static _StartUserMark;
  41648. private static _EndUserMark;
  41649. private static _StartPerformanceConsole;
  41650. private static _EndPerformanceConsole;
  41651. /**
  41652. * Starts a performance counter
  41653. */
  41654. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41655. /**
  41656. * Ends a specific performance coutner
  41657. */
  41658. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41659. /**
  41660. * Gets either window.performance.now() if supported or Date.now() else
  41661. */
  41662. static get Now(): number;
  41663. /**
  41664. * This method will return the name of the class used to create the instance of the given object.
  41665. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  41666. * @param object the object to get the class name from
  41667. * @param isType defines if the object is actually a type
  41668. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  41669. */
  41670. static GetClassName(object: any, isType?: boolean): string;
  41671. /**
  41672. * Gets the first element of an array satisfying a given predicate
  41673. * @param array defines the array to browse
  41674. * @param predicate defines the predicate to use
  41675. * @returns null if not found or the element
  41676. */
  41677. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  41678. /**
  41679. * This method will return the name of the full name of the class, including its owning module (if any).
  41680. * 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).
  41681. * @param object the object to get the class name from
  41682. * @param isType defines if the object is actually a type
  41683. * @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.
  41684. * @ignorenaming
  41685. */
  41686. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  41687. /**
  41688. * Returns a promise that resolves after the given amount of time.
  41689. * @param delay Number of milliseconds to delay
  41690. * @returns Promise that resolves after the given amount of time
  41691. */
  41692. static DelayAsync(delay: number): Promise<void>;
  41693. /**
  41694. * Utility function to detect if the current user agent is Safari
  41695. * @returns whether or not the current user agent is safari
  41696. */
  41697. static IsSafari(): boolean;
  41698. }
  41699. /**
  41700. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  41701. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  41702. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  41703. * @param name The name of the class, case should be preserved
  41704. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  41705. */
  41706. export function className(name: string, module?: string): (target: Object) => void;
  41707. /**
  41708. * An implementation of a loop for asynchronous functions.
  41709. */
  41710. export class AsyncLoop {
  41711. /**
  41712. * Defines the number of iterations for the loop
  41713. */
  41714. iterations: number;
  41715. /**
  41716. * Defines the current index of the loop.
  41717. */
  41718. index: number;
  41719. private _done;
  41720. private _fn;
  41721. private _successCallback;
  41722. /**
  41723. * Constructor.
  41724. * @param iterations the number of iterations.
  41725. * @param func the function to run each iteration
  41726. * @param successCallback the callback that will be called upon succesful execution
  41727. * @param offset starting offset.
  41728. */
  41729. constructor(
  41730. /**
  41731. * Defines the number of iterations for the loop
  41732. */
  41733. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  41734. /**
  41735. * Execute the next iteration. Must be called after the last iteration was finished.
  41736. */
  41737. executeNext(): void;
  41738. /**
  41739. * Break the loop and run the success callback.
  41740. */
  41741. breakLoop(): void;
  41742. /**
  41743. * Create and run an async loop.
  41744. * @param iterations the number of iterations.
  41745. * @param fn the function to run each iteration
  41746. * @param successCallback the callback that will be called upon succesful execution
  41747. * @param offset starting offset.
  41748. * @returns the created async loop object
  41749. */
  41750. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  41751. /**
  41752. * A for-loop that will run a given number of iterations synchronous and the rest async.
  41753. * @param iterations total number of iterations
  41754. * @param syncedIterations number of synchronous iterations in each async iteration.
  41755. * @param fn the function to call each iteration.
  41756. * @param callback a success call back that will be called when iterating stops.
  41757. * @param breakFunction a break condition (optional)
  41758. * @param timeout timeout settings for the setTimeout function. default - 0.
  41759. * @returns the created async loop object
  41760. */
  41761. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  41762. }
  41763. }
  41764. declare module BABYLON {
  41765. /**
  41766. * This class implement a typical dictionary using a string as key and the generic type T as value.
  41767. * The underlying implementation relies on an associative array to ensure the best performances.
  41768. * The value can be anything including 'null' but except 'undefined'
  41769. */
  41770. export class StringDictionary<T> {
  41771. /**
  41772. * This will clear this dictionary and copy the content from the 'source' one.
  41773. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  41774. * @param source the dictionary to take the content from and copy to this dictionary
  41775. */
  41776. copyFrom(source: StringDictionary<T>): void;
  41777. /**
  41778. * Get a value based from its key
  41779. * @param key the given key to get the matching value from
  41780. * @return the value if found, otherwise undefined is returned
  41781. */
  41782. get(key: string): T | undefined;
  41783. /**
  41784. * Get a value from its key or add it if it doesn't exist.
  41785. * This method will ensure you that a given key/data will be present in the dictionary.
  41786. * @param key the given key to get the matching value from
  41787. * @param factory the factory that will create the value if the key is not present in the dictionary.
  41788. * The factory will only be invoked if there's no data for the given key.
  41789. * @return the value corresponding to the key.
  41790. */
  41791. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  41792. /**
  41793. * Get a value from its key if present in the dictionary otherwise add it
  41794. * @param key the key to get the value from
  41795. * @param val if there's no such key/value pair in the dictionary add it with this value
  41796. * @return the value corresponding to the key
  41797. */
  41798. getOrAdd(key: string, val: T): T;
  41799. /**
  41800. * Check if there's a given key in the dictionary
  41801. * @param key the key to check for
  41802. * @return true if the key is present, false otherwise
  41803. */
  41804. contains(key: string): boolean;
  41805. /**
  41806. * Add a new key and its corresponding value
  41807. * @param key the key to add
  41808. * @param value the value corresponding to the key
  41809. * @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
  41810. */
  41811. add(key: string, value: T): boolean;
  41812. /**
  41813. * Update a specific value associated to a key
  41814. * @param key defines the key to use
  41815. * @param value defines the value to store
  41816. * @returns true if the value was updated (or false if the key was not found)
  41817. */
  41818. set(key: string, value: T): boolean;
  41819. /**
  41820. * Get the element of the given key and remove it from the dictionary
  41821. * @param key defines the key to search
  41822. * @returns the value associated with the key or null if not found
  41823. */
  41824. getAndRemove(key: string): Nullable<T>;
  41825. /**
  41826. * Remove a key/value from the dictionary.
  41827. * @param key the key to remove
  41828. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  41829. */
  41830. remove(key: string): boolean;
  41831. /**
  41832. * Clear the whole content of the dictionary
  41833. */
  41834. clear(): void;
  41835. /**
  41836. * Gets the current count
  41837. */
  41838. get count(): number;
  41839. /**
  41840. * Execute a callback on each key/val of the dictionary.
  41841. * Note that you can remove any element in this dictionary in the callback implementation
  41842. * @param callback the callback to execute on a given key/value pair
  41843. */
  41844. forEach(callback: (key: string, val: T) => void): void;
  41845. /**
  41846. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  41847. * If the callback returns null or undefined the method will iterate to the next key/value pair
  41848. * Note that you can remove any element in this dictionary in the callback implementation
  41849. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  41850. * @returns the first item
  41851. */
  41852. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  41853. private _count;
  41854. private _data;
  41855. }
  41856. }
  41857. declare module BABYLON {
  41858. /** @hidden */
  41859. export interface ICollisionCoordinator {
  41860. createCollider(): Collider;
  41861. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41862. init(scene: Scene): void;
  41863. }
  41864. /** @hidden */
  41865. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  41866. private _scene;
  41867. private _scaledPosition;
  41868. private _scaledVelocity;
  41869. private _finalPosition;
  41870. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41871. createCollider(): Collider;
  41872. init(scene: Scene): void;
  41873. private _collideWithWorld;
  41874. }
  41875. }
  41876. declare module BABYLON {
  41877. /**
  41878. * Class used to manage all inputs for the scene.
  41879. */
  41880. export class InputManager {
  41881. /** The distance in pixel that you have to move to prevent some events */
  41882. static DragMovementThreshold: number;
  41883. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  41884. static LongPressDelay: number;
  41885. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  41886. static DoubleClickDelay: number;
  41887. /** If you need to check double click without raising a single click at first click, enable this flag */
  41888. static ExclusiveDoubleClickMode: boolean;
  41889. /** 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. */
  41890. private _alreadyAttached;
  41891. private _wheelEventName;
  41892. private _onPointerMove;
  41893. private _onPointerDown;
  41894. private _onPointerUp;
  41895. private _initClickEvent;
  41896. private _initActionManager;
  41897. private _delayedSimpleClick;
  41898. private _delayedSimpleClickTimeout;
  41899. private _previousDelayedSimpleClickTimeout;
  41900. private _meshPickProceed;
  41901. private _previousButtonPressed;
  41902. private _currentPickResult;
  41903. private _previousPickResult;
  41904. private _totalPointersPressed;
  41905. private _doubleClickOccured;
  41906. private _pointerOverMesh;
  41907. private _pickedDownMesh;
  41908. private _pickedUpMesh;
  41909. private _pointerX;
  41910. private _pointerY;
  41911. private _unTranslatedPointerX;
  41912. private _unTranslatedPointerY;
  41913. private _startingPointerPosition;
  41914. private _previousStartingPointerPosition;
  41915. private _startingPointerTime;
  41916. private _previousStartingPointerTime;
  41917. private _pointerCaptures;
  41918. private _meshUnderPointerId;
  41919. private _onKeyDown;
  41920. private _onKeyUp;
  41921. private _onCanvasFocusObserver;
  41922. private _onCanvasBlurObserver;
  41923. private _scene;
  41924. /**
  41925. * Creates a new InputManager
  41926. * @param scene defines the hosting scene
  41927. */
  41928. constructor(scene: Scene);
  41929. /**
  41930. * Gets the mesh that is currently under the pointer
  41931. */
  41932. get meshUnderPointer(): Nullable<AbstractMesh>;
  41933. /**
  41934. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  41935. * @param pointerId the pointer id to use
  41936. * @returns The mesh under this pointer id or null if not found
  41937. */
  41938. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  41939. /**
  41940. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  41941. */
  41942. get unTranslatedPointer(): Vector2;
  41943. /**
  41944. * Gets or sets the current on-screen X position of the pointer
  41945. */
  41946. get pointerX(): number;
  41947. set pointerX(value: number);
  41948. /**
  41949. * Gets or sets the current on-screen Y position of the pointer
  41950. */
  41951. get pointerY(): number;
  41952. set pointerY(value: number);
  41953. private _updatePointerPosition;
  41954. private _processPointerMove;
  41955. private _setRayOnPointerInfo;
  41956. private _checkPrePointerObservable;
  41957. /**
  41958. * Use this method to simulate a pointer move on a mesh
  41959. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41960. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41961. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41962. */
  41963. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  41964. /**
  41965. * Use this method to simulate a pointer down on a mesh
  41966. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41967. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41968. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41969. */
  41970. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  41971. private _processPointerDown;
  41972. /** @hidden */
  41973. _isPointerSwiping(): boolean;
  41974. /**
  41975. * Use this method to simulate a pointer up on a mesh
  41976. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41977. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41978. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41979. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41980. */
  41981. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  41982. private _processPointerUp;
  41983. /**
  41984. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41985. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41986. * @returns true if the pointer was captured
  41987. */
  41988. isPointerCaptured(pointerId?: number): boolean;
  41989. /**
  41990. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41991. * @param attachUp defines if you want to attach events to pointerup
  41992. * @param attachDown defines if you want to attach events to pointerdown
  41993. * @param attachMove defines if you want to attach events to pointermove
  41994. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  41995. */
  41996. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  41997. /**
  41998. * Detaches all event handlers
  41999. */
  42000. detachControl(): void;
  42001. /**
  42002. * Force the value of meshUnderPointer
  42003. * @param mesh defines the mesh to use
  42004. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42005. */
  42006. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42007. /**
  42008. * Gets the mesh under the pointer
  42009. * @returns a Mesh or null if no mesh is under the pointer
  42010. */
  42011. getPointerOverMesh(): Nullable<AbstractMesh>;
  42012. }
  42013. }
  42014. declare module BABYLON {
  42015. /**
  42016. * This class defines the direct association between an animation and a target
  42017. */
  42018. export class TargetedAnimation {
  42019. /**
  42020. * Animation to perform
  42021. */
  42022. animation: Animation;
  42023. /**
  42024. * Target to animate
  42025. */
  42026. target: any;
  42027. /**
  42028. * Returns the string "TargetedAnimation"
  42029. * @returns "TargetedAnimation"
  42030. */
  42031. getClassName(): string;
  42032. /**
  42033. * Serialize the object
  42034. * @returns the JSON object representing the current entity
  42035. */
  42036. serialize(): any;
  42037. }
  42038. /**
  42039. * Use this class to create coordinated animations on multiple targets
  42040. */
  42041. export class AnimationGroup implements IDisposable {
  42042. /** The name of the animation group */
  42043. name: string;
  42044. private _scene;
  42045. private _targetedAnimations;
  42046. private _animatables;
  42047. private _from;
  42048. private _to;
  42049. private _isStarted;
  42050. private _isPaused;
  42051. private _speedRatio;
  42052. private _loopAnimation;
  42053. private _isAdditive;
  42054. /**
  42055. * Gets or sets the unique id of the node
  42056. */
  42057. uniqueId: number;
  42058. /**
  42059. * This observable will notify when one animation have ended
  42060. */
  42061. onAnimationEndObservable: Observable<TargetedAnimation>;
  42062. /**
  42063. * Observer raised when one animation loops
  42064. */
  42065. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42066. /**
  42067. * Observer raised when all animations have looped
  42068. */
  42069. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42070. /**
  42071. * This observable will notify when all animations have ended.
  42072. */
  42073. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42074. /**
  42075. * This observable will notify when all animations have paused.
  42076. */
  42077. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42078. /**
  42079. * This observable will notify when all animations are playing.
  42080. */
  42081. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42082. /**
  42083. * Gets the first frame
  42084. */
  42085. get from(): number;
  42086. /**
  42087. * Gets the last frame
  42088. */
  42089. get to(): number;
  42090. /**
  42091. * Define if the animations are started
  42092. */
  42093. get isStarted(): boolean;
  42094. /**
  42095. * Gets a value indicating that the current group is playing
  42096. */
  42097. get isPlaying(): boolean;
  42098. /**
  42099. * Gets or sets the speed ratio to use for all animations
  42100. */
  42101. get speedRatio(): number;
  42102. /**
  42103. * Gets or sets the speed ratio to use for all animations
  42104. */
  42105. set speedRatio(value: number);
  42106. /**
  42107. * Gets or sets if all animations should loop or not
  42108. */
  42109. get loopAnimation(): boolean;
  42110. set loopAnimation(value: boolean);
  42111. /**
  42112. * Gets or sets if all animations should be evaluated additively
  42113. */
  42114. get isAdditive(): boolean;
  42115. set isAdditive(value: boolean);
  42116. /**
  42117. * Gets the targeted animations for this animation group
  42118. */
  42119. get targetedAnimations(): Array<TargetedAnimation>;
  42120. /**
  42121. * returning the list of animatables controlled by this animation group.
  42122. */
  42123. get animatables(): Array<Animatable>;
  42124. /**
  42125. * Gets the list of target animations
  42126. */
  42127. get children(): TargetedAnimation[];
  42128. /**
  42129. * Instantiates a new Animation Group.
  42130. * This helps managing several animations at once.
  42131. * @see https://doc.babylonjs.com/how_to/group
  42132. * @param name Defines the name of the group
  42133. * @param scene Defines the scene the group belongs to
  42134. */
  42135. constructor(
  42136. /** The name of the animation group */
  42137. name: string, scene?: Nullable<Scene>);
  42138. /**
  42139. * Add an animation (with its target) in the group
  42140. * @param animation defines the animation we want to add
  42141. * @param target defines the target of the animation
  42142. * @returns the TargetedAnimation object
  42143. */
  42144. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42145. /**
  42146. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42147. * It can add constant keys at begin or end
  42148. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42149. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42150. * @returns the animation group
  42151. */
  42152. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42153. private _animationLoopCount;
  42154. private _animationLoopFlags;
  42155. private _processLoop;
  42156. /**
  42157. * Start all animations on given targets
  42158. * @param loop defines if animations must loop
  42159. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42160. * @param from defines the from key (optional)
  42161. * @param to defines the to key (optional)
  42162. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42163. * @returns the current animation group
  42164. */
  42165. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42166. /**
  42167. * Pause all animations
  42168. * @returns the animation group
  42169. */
  42170. pause(): AnimationGroup;
  42171. /**
  42172. * Play all animations to initial state
  42173. * This function will start() the animations if they were not started or will restart() them if they were paused
  42174. * @param loop defines if animations must loop
  42175. * @returns the animation group
  42176. */
  42177. play(loop?: boolean): AnimationGroup;
  42178. /**
  42179. * Reset all animations to initial state
  42180. * @returns the animation group
  42181. */
  42182. reset(): AnimationGroup;
  42183. /**
  42184. * Restart animations from key 0
  42185. * @returns the animation group
  42186. */
  42187. restart(): AnimationGroup;
  42188. /**
  42189. * Stop all animations
  42190. * @returns the animation group
  42191. */
  42192. stop(): AnimationGroup;
  42193. /**
  42194. * Set animation weight for all animatables
  42195. * @param weight defines the weight to use
  42196. * @return the animationGroup
  42197. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42198. */
  42199. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42200. /**
  42201. * Synchronize and normalize all animatables with a source animatable
  42202. * @param root defines the root animatable to synchronize with
  42203. * @return the animationGroup
  42204. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42205. */
  42206. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42207. /**
  42208. * Goes to a specific frame in this animation group
  42209. * @param frame the frame number to go to
  42210. * @return the animationGroup
  42211. */
  42212. goToFrame(frame: number): AnimationGroup;
  42213. /**
  42214. * Dispose all associated resources
  42215. */
  42216. dispose(): void;
  42217. private _checkAnimationGroupEnded;
  42218. /**
  42219. * Clone the current animation group and returns a copy
  42220. * @param newName defines the name of the new group
  42221. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42222. * @returns the new aniamtion group
  42223. */
  42224. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42225. /**
  42226. * Serializes the animationGroup to an object
  42227. * @returns Serialized object
  42228. */
  42229. serialize(): any;
  42230. /**
  42231. * Returns a new AnimationGroup object parsed from the source provided.
  42232. * @param parsedAnimationGroup defines the source
  42233. * @param scene defines the scene that will receive the animationGroup
  42234. * @returns a new AnimationGroup
  42235. */
  42236. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42237. /**
  42238. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42239. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42240. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42241. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42242. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42243. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42244. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42245. */
  42246. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42247. /**
  42248. * Returns the string "AnimationGroup"
  42249. * @returns "AnimationGroup"
  42250. */
  42251. getClassName(): string;
  42252. /**
  42253. * Creates a detailled string about the object
  42254. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42255. * @returns a string representing the object
  42256. */
  42257. toString(fullDetails?: boolean): string;
  42258. }
  42259. }
  42260. declare module BABYLON {
  42261. /**
  42262. * Define an interface for all classes that will hold resources
  42263. */
  42264. export interface IDisposable {
  42265. /**
  42266. * Releases all held resources
  42267. */
  42268. dispose(): void;
  42269. }
  42270. /** Interface defining initialization parameters for Scene class */
  42271. export interface SceneOptions {
  42272. /**
  42273. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42274. * It will improve performance when the number of geometries becomes important.
  42275. */
  42276. useGeometryUniqueIdsMap?: boolean;
  42277. /**
  42278. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42279. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42280. */
  42281. useMaterialMeshMap?: boolean;
  42282. /**
  42283. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42284. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42285. */
  42286. useClonedMeshMap?: boolean;
  42287. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42288. virtual?: boolean;
  42289. }
  42290. /**
  42291. * Represents a scene to be rendered by the engine.
  42292. * @see https://doc.babylonjs.com/features/scene
  42293. */
  42294. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42295. /** The fog is deactivated */
  42296. static readonly FOGMODE_NONE: number;
  42297. /** The fog density is following an exponential function */
  42298. static readonly FOGMODE_EXP: number;
  42299. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42300. static readonly FOGMODE_EXP2: number;
  42301. /** The fog density is following a linear function. */
  42302. static readonly FOGMODE_LINEAR: number;
  42303. /**
  42304. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42305. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42306. */
  42307. static MinDeltaTime: number;
  42308. /**
  42309. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42310. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42311. */
  42312. static MaxDeltaTime: number;
  42313. /**
  42314. * Factory used to create the default material.
  42315. * @param name The name of the material to create
  42316. * @param scene The scene to create the material for
  42317. * @returns The default material
  42318. */
  42319. static DefaultMaterialFactory(scene: Scene): Material;
  42320. /**
  42321. * Factory used to create the a collision coordinator.
  42322. * @returns The collision coordinator
  42323. */
  42324. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42325. /** @hidden */
  42326. _inputManager: InputManager;
  42327. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42328. cameraToUseForPointers: Nullable<Camera>;
  42329. /** @hidden */
  42330. readonly _isScene: boolean;
  42331. /** @hidden */
  42332. _blockEntityCollection: boolean;
  42333. /**
  42334. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42335. */
  42336. autoClear: boolean;
  42337. /**
  42338. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42339. */
  42340. autoClearDepthAndStencil: boolean;
  42341. /**
  42342. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42343. */
  42344. clearColor: Color4;
  42345. /**
  42346. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42347. */
  42348. ambientColor: Color3;
  42349. /**
  42350. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42351. * It should only be one of the following (if not the default embedded one):
  42352. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42353. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42354. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42355. * The material properties need to be setup according to the type of texture in use.
  42356. */
  42357. environmentBRDFTexture: BaseTexture;
  42358. /**
  42359. * Texture used in all pbr material as the reflection texture.
  42360. * As in the majority of the scene they are the same (exception for multi room and so on),
  42361. * this is easier to reference from here than from all the materials.
  42362. */
  42363. get environmentTexture(): Nullable<BaseTexture>;
  42364. /**
  42365. * Texture used in all pbr material as the reflection texture.
  42366. * As in the majority of the scene they are the same (exception for multi room and so on),
  42367. * this is easier to set here than in all the materials.
  42368. */
  42369. set environmentTexture(value: Nullable<BaseTexture>);
  42370. /** @hidden */
  42371. protected _environmentIntensity: number;
  42372. /**
  42373. * Intensity of the environment in all pbr material.
  42374. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42375. * As in the majority of the scene they are the same (exception for multi room and so on),
  42376. * this is easier to reference from here than from all the materials.
  42377. */
  42378. get environmentIntensity(): number;
  42379. /**
  42380. * Intensity of the environment in all pbr material.
  42381. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42382. * As in the majority of the scene they are the same (exception for multi room and so on),
  42383. * this is easier to set here than in all the materials.
  42384. */
  42385. set environmentIntensity(value: number);
  42386. /** @hidden */
  42387. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42388. /**
  42389. * Default image processing configuration used either in the rendering
  42390. * Forward main pass or through the imageProcessingPostProcess if present.
  42391. * As in the majority of the scene they are the same (exception for multi camera),
  42392. * this is easier to reference from here than from all the materials and post process.
  42393. *
  42394. * No setter as we it is a shared configuration, you can set the values instead.
  42395. */
  42396. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42397. private _forceWireframe;
  42398. /**
  42399. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42400. */
  42401. set forceWireframe(value: boolean);
  42402. get forceWireframe(): boolean;
  42403. private _skipFrustumClipping;
  42404. /**
  42405. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42406. */
  42407. set skipFrustumClipping(value: boolean);
  42408. get skipFrustumClipping(): boolean;
  42409. private _forcePointsCloud;
  42410. /**
  42411. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42412. */
  42413. set forcePointsCloud(value: boolean);
  42414. get forcePointsCloud(): boolean;
  42415. /**
  42416. * Gets or sets the active clipplane 1
  42417. */
  42418. clipPlane: Nullable<Plane>;
  42419. /**
  42420. * Gets or sets the active clipplane 2
  42421. */
  42422. clipPlane2: Nullable<Plane>;
  42423. /**
  42424. * Gets or sets the active clipplane 3
  42425. */
  42426. clipPlane3: Nullable<Plane>;
  42427. /**
  42428. * Gets or sets the active clipplane 4
  42429. */
  42430. clipPlane4: Nullable<Plane>;
  42431. /**
  42432. * Gets or sets the active clipplane 5
  42433. */
  42434. clipPlane5: Nullable<Plane>;
  42435. /**
  42436. * Gets or sets the active clipplane 6
  42437. */
  42438. clipPlane6: Nullable<Plane>;
  42439. /**
  42440. * Gets or sets a boolean indicating if animations are enabled
  42441. */
  42442. animationsEnabled: boolean;
  42443. private _animationPropertiesOverride;
  42444. /**
  42445. * Gets or sets the animation properties override
  42446. */
  42447. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42448. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42449. /**
  42450. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42451. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42452. */
  42453. useConstantAnimationDeltaTime: boolean;
  42454. /**
  42455. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42456. * Please note that it requires to run a ray cast through the scene on every frame
  42457. */
  42458. constantlyUpdateMeshUnderPointer: boolean;
  42459. /**
  42460. * Defines the HTML cursor to use when hovering over interactive elements
  42461. */
  42462. hoverCursor: string;
  42463. /**
  42464. * Defines the HTML default cursor to use (empty by default)
  42465. */
  42466. defaultCursor: string;
  42467. /**
  42468. * Defines whether cursors are handled by the scene.
  42469. */
  42470. doNotHandleCursors: boolean;
  42471. /**
  42472. * This is used to call preventDefault() on pointer down
  42473. * in order to block unwanted artifacts like system double clicks
  42474. */
  42475. preventDefaultOnPointerDown: boolean;
  42476. /**
  42477. * This is used to call preventDefault() on pointer up
  42478. * in order to block unwanted artifacts like system double clicks
  42479. */
  42480. preventDefaultOnPointerUp: boolean;
  42481. /**
  42482. * Gets or sets user defined metadata
  42483. */
  42484. metadata: any;
  42485. /**
  42486. * For internal use only. Please do not use.
  42487. */
  42488. reservedDataStore: any;
  42489. /**
  42490. * Gets the name of the plugin used to load this scene (null by default)
  42491. */
  42492. loadingPluginName: string;
  42493. /**
  42494. * Use this array to add regular expressions used to disable offline support for specific urls
  42495. */
  42496. disableOfflineSupportExceptionRules: RegExp[];
  42497. /**
  42498. * An event triggered when the scene is disposed.
  42499. */
  42500. onDisposeObservable: Observable<Scene>;
  42501. private _onDisposeObserver;
  42502. /** Sets a function to be executed when this scene is disposed. */
  42503. set onDispose(callback: () => void);
  42504. /**
  42505. * An event triggered before rendering the scene (right after animations and physics)
  42506. */
  42507. onBeforeRenderObservable: Observable<Scene>;
  42508. private _onBeforeRenderObserver;
  42509. /** Sets a function to be executed before rendering this scene */
  42510. set beforeRender(callback: Nullable<() => void>);
  42511. /**
  42512. * An event triggered after rendering the scene
  42513. */
  42514. onAfterRenderObservable: Observable<Scene>;
  42515. /**
  42516. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42517. */
  42518. onAfterRenderCameraObservable: Observable<Camera>;
  42519. private _onAfterRenderObserver;
  42520. /** Sets a function to be executed after rendering this scene */
  42521. set afterRender(callback: Nullable<() => void>);
  42522. /**
  42523. * An event triggered before animating the scene
  42524. */
  42525. onBeforeAnimationsObservable: Observable<Scene>;
  42526. /**
  42527. * An event triggered after animations processing
  42528. */
  42529. onAfterAnimationsObservable: Observable<Scene>;
  42530. /**
  42531. * An event triggered before draw calls are ready to be sent
  42532. */
  42533. onBeforeDrawPhaseObservable: Observable<Scene>;
  42534. /**
  42535. * An event triggered after draw calls have been sent
  42536. */
  42537. onAfterDrawPhaseObservable: Observable<Scene>;
  42538. /**
  42539. * An event triggered when the scene is ready
  42540. */
  42541. onReadyObservable: Observable<Scene>;
  42542. /**
  42543. * An event triggered before rendering a camera
  42544. */
  42545. onBeforeCameraRenderObservable: Observable<Camera>;
  42546. private _onBeforeCameraRenderObserver;
  42547. /** Sets a function to be executed before rendering a camera*/
  42548. set beforeCameraRender(callback: () => void);
  42549. /**
  42550. * An event triggered after rendering a camera
  42551. */
  42552. onAfterCameraRenderObservable: Observable<Camera>;
  42553. private _onAfterCameraRenderObserver;
  42554. /** Sets a function to be executed after rendering a camera*/
  42555. set afterCameraRender(callback: () => void);
  42556. /**
  42557. * An event triggered when active meshes evaluation is about to start
  42558. */
  42559. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42560. /**
  42561. * An event triggered when active meshes evaluation is done
  42562. */
  42563. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42564. /**
  42565. * An event triggered when particles rendering is about to start
  42566. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42567. */
  42568. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42569. /**
  42570. * An event triggered when particles rendering is done
  42571. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42572. */
  42573. onAfterParticlesRenderingObservable: Observable<Scene>;
  42574. /**
  42575. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42576. */
  42577. onDataLoadedObservable: Observable<Scene>;
  42578. /**
  42579. * An event triggered when a camera is created
  42580. */
  42581. onNewCameraAddedObservable: Observable<Camera>;
  42582. /**
  42583. * An event triggered when a camera is removed
  42584. */
  42585. onCameraRemovedObservable: Observable<Camera>;
  42586. /**
  42587. * An event triggered when a light is created
  42588. */
  42589. onNewLightAddedObservable: Observable<Light>;
  42590. /**
  42591. * An event triggered when a light is removed
  42592. */
  42593. onLightRemovedObservable: Observable<Light>;
  42594. /**
  42595. * An event triggered when a geometry is created
  42596. */
  42597. onNewGeometryAddedObservable: Observable<Geometry>;
  42598. /**
  42599. * An event triggered when a geometry is removed
  42600. */
  42601. onGeometryRemovedObservable: Observable<Geometry>;
  42602. /**
  42603. * An event triggered when a transform node is created
  42604. */
  42605. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42606. /**
  42607. * An event triggered when a transform node is removed
  42608. */
  42609. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42610. /**
  42611. * An event triggered when a mesh is created
  42612. */
  42613. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42614. /**
  42615. * An event triggered when a mesh is removed
  42616. */
  42617. onMeshRemovedObservable: Observable<AbstractMesh>;
  42618. /**
  42619. * An event triggered when a skeleton is created
  42620. */
  42621. onNewSkeletonAddedObservable: Observable<Skeleton>;
  42622. /**
  42623. * An event triggered when a skeleton is removed
  42624. */
  42625. onSkeletonRemovedObservable: Observable<Skeleton>;
  42626. /**
  42627. * An event triggered when a material is created
  42628. */
  42629. onNewMaterialAddedObservable: Observable<Material>;
  42630. /**
  42631. * An event triggered when a material is removed
  42632. */
  42633. onMaterialRemovedObservable: Observable<Material>;
  42634. /**
  42635. * An event triggered when a texture is created
  42636. */
  42637. onNewTextureAddedObservable: Observable<BaseTexture>;
  42638. /**
  42639. * An event triggered when a texture is removed
  42640. */
  42641. onTextureRemovedObservable: Observable<BaseTexture>;
  42642. /**
  42643. * An event triggered when render targets are about to be rendered
  42644. * Can happen multiple times per frame.
  42645. */
  42646. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  42647. /**
  42648. * An event triggered when render targets were rendered.
  42649. * Can happen multiple times per frame.
  42650. */
  42651. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  42652. /**
  42653. * An event triggered before calculating deterministic simulation step
  42654. */
  42655. onBeforeStepObservable: Observable<Scene>;
  42656. /**
  42657. * An event triggered after calculating deterministic simulation step
  42658. */
  42659. onAfterStepObservable: Observable<Scene>;
  42660. /**
  42661. * An event triggered when the activeCamera property is updated
  42662. */
  42663. onActiveCameraChanged: Observable<Scene>;
  42664. /**
  42665. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  42666. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42667. * 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)
  42668. */
  42669. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42670. /**
  42671. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  42672. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42673. * 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)
  42674. */
  42675. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42676. /**
  42677. * This Observable will when a mesh has been imported into the scene.
  42678. */
  42679. onMeshImportedObservable: Observable<AbstractMesh>;
  42680. /**
  42681. * This Observable will when an animation file has been imported into the scene.
  42682. */
  42683. onAnimationFileImportedObservable: Observable<Scene>;
  42684. /**
  42685. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  42686. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  42687. */
  42688. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  42689. /** @hidden */
  42690. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  42691. /**
  42692. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  42693. */
  42694. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  42695. /**
  42696. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  42697. */
  42698. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  42699. /**
  42700. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  42701. */
  42702. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  42703. /** Callback called when a pointer move is detected */
  42704. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42705. /** Callback called when a pointer down is detected */
  42706. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42707. /** Callback called when a pointer up is detected */
  42708. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  42709. /** Callback called when a pointer pick is detected */
  42710. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  42711. /**
  42712. * 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).
  42713. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  42714. */
  42715. onPrePointerObservable: Observable<PointerInfoPre>;
  42716. /**
  42717. * Observable event triggered each time an input event is received from the rendering canvas
  42718. */
  42719. onPointerObservable: Observable<PointerInfo>;
  42720. /**
  42721. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  42722. */
  42723. get unTranslatedPointer(): Vector2;
  42724. /**
  42725. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  42726. */
  42727. static get DragMovementThreshold(): number;
  42728. static set DragMovementThreshold(value: number);
  42729. /**
  42730. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  42731. */
  42732. static get LongPressDelay(): number;
  42733. static set LongPressDelay(value: number);
  42734. /**
  42735. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  42736. */
  42737. static get DoubleClickDelay(): number;
  42738. static set DoubleClickDelay(value: number);
  42739. /** If you need to check double click without raising a single click at first click, enable this flag */
  42740. static get ExclusiveDoubleClickMode(): boolean;
  42741. static set ExclusiveDoubleClickMode(value: boolean);
  42742. /** @hidden */
  42743. _mirroredCameraPosition: Nullable<Vector3>;
  42744. /**
  42745. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  42746. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  42747. */
  42748. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  42749. /**
  42750. * Observable event triggered each time an keyboard event is received from the hosting window
  42751. */
  42752. onKeyboardObservable: Observable<KeyboardInfo>;
  42753. private _useRightHandedSystem;
  42754. /**
  42755. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  42756. */
  42757. set useRightHandedSystem(value: boolean);
  42758. get useRightHandedSystem(): boolean;
  42759. private _timeAccumulator;
  42760. private _currentStepId;
  42761. private _currentInternalStep;
  42762. /**
  42763. * Sets the step Id used by deterministic lock step
  42764. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42765. * @param newStepId defines the step Id
  42766. */
  42767. setStepId(newStepId: number): void;
  42768. /**
  42769. * Gets the step Id used by deterministic lock step
  42770. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42771. * @returns the step Id
  42772. */
  42773. getStepId(): number;
  42774. /**
  42775. * Gets the internal step used by deterministic lock step
  42776. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42777. * @returns the internal step
  42778. */
  42779. getInternalStep(): number;
  42780. private _fogEnabled;
  42781. /**
  42782. * Gets or sets a boolean indicating if fog is enabled on this scene
  42783. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42784. * (Default is true)
  42785. */
  42786. set fogEnabled(value: boolean);
  42787. get fogEnabled(): boolean;
  42788. private _fogMode;
  42789. /**
  42790. * Gets or sets the fog mode to use
  42791. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42792. * | mode | value |
  42793. * | --- | --- |
  42794. * | FOGMODE_NONE | 0 |
  42795. * | FOGMODE_EXP | 1 |
  42796. * | FOGMODE_EXP2 | 2 |
  42797. * | FOGMODE_LINEAR | 3 |
  42798. */
  42799. set fogMode(value: number);
  42800. get fogMode(): number;
  42801. /**
  42802. * Gets or sets the fog color to use
  42803. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42804. * (Default is Color3(0.2, 0.2, 0.3))
  42805. */
  42806. fogColor: Color3;
  42807. /**
  42808. * Gets or sets the fog density to use
  42809. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42810. * (Default is 0.1)
  42811. */
  42812. fogDensity: number;
  42813. /**
  42814. * Gets or sets the fog start distance to use
  42815. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42816. * (Default is 0)
  42817. */
  42818. fogStart: number;
  42819. /**
  42820. * Gets or sets the fog end distance to use
  42821. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42822. * (Default is 1000)
  42823. */
  42824. fogEnd: number;
  42825. /**
  42826. * Flag indicating that the frame buffer binding is handled by another component
  42827. */
  42828. prePass: boolean;
  42829. private _shadowsEnabled;
  42830. /**
  42831. * Gets or sets a boolean indicating if shadows are enabled on this scene
  42832. */
  42833. set shadowsEnabled(value: boolean);
  42834. get shadowsEnabled(): boolean;
  42835. private _lightsEnabled;
  42836. /**
  42837. * Gets or sets a boolean indicating if lights are enabled on this scene
  42838. */
  42839. set lightsEnabled(value: boolean);
  42840. get lightsEnabled(): boolean;
  42841. /** All of the active cameras added to this scene. */
  42842. activeCameras: Camera[];
  42843. /** @hidden */
  42844. _activeCamera: Nullable<Camera>;
  42845. /** Gets or sets the current active camera */
  42846. get activeCamera(): Nullable<Camera>;
  42847. set activeCamera(value: Nullable<Camera>);
  42848. private _defaultMaterial;
  42849. /** The default material used on meshes when no material is affected */
  42850. get defaultMaterial(): Material;
  42851. /** The default material used on meshes when no material is affected */
  42852. set defaultMaterial(value: Material);
  42853. private _texturesEnabled;
  42854. /**
  42855. * Gets or sets a boolean indicating if textures are enabled on this scene
  42856. */
  42857. set texturesEnabled(value: boolean);
  42858. get texturesEnabled(): boolean;
  42859. /**
  42860. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  42861. */
  42862. physicsEnabled: boolean;
  42863. /**
  42864. * Gets or sets a boolean indicating if particles are enabled on this scene
  42865. */
  42866. particlesEnabled: boolean;
  42867. /**
  42868. * Gets or sets a boolean indicating if sprites are enabled on this scene
  42869. */
  42870. spritesEnabled: boolean;
  42871. private _skeletonsEnabled;
  42872. /**
  42873. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  42874. */
  42875. set skeletonsEnabled(value: boolean);
  42876. get skeletonsEnabled(): boolean;
  42877. /**
  42878. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  42879. */
  42880. lensFlaresEnabled: boolean;
  42881. /**
  42882. * Gets or sets a boolean indicating if collisions are enabled on this scene
  42883. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  42884. */
  42885. collisionsEnabled: boolean;
  42886. private _collisionCoordinator;
  42887. /** @hidden */
  42888. get collisionCoordinator(): ICollisionCoordinator;
  42889. /**
  42890. * Defines the gravity applied to this scene (used only for collisions)
  42891. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  42892. */
  42893. gravity: Vector3;
  42894. /**
  42895. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  42896. */
  42897. postProcessesEnabled: boolean;
  42898. /**
  42899. * Gets the current postprocess manager
  42900. */
  42901. postProcessManager: PostProcessManager;
  42902. /**
  42903. * Gets or sets a boolean indicating if render targets are enabled on this scene
  42904. */
  42905. renderTargetsEnabled: boolean;
  42906. /**
  42907. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  42908. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  42909. */
  42910. dumpNextRenderTargets: boolean;
  42911. /**
  42912. * The list of user defined render targets added to the scene
  42913. */
  42914. customRenderTargets: RenderTargetTexture[];
  42915. /**
  42916. * Defines if texture loading must be delayed
  42917. * If true, textures will only be loaded when they need to be rendered
  42918. */
  42919. useDelayedTextureLoading: boolean;
  42920. /**
  42921. * Gets the list of meshes imported to the scene through SceneLoader
  42922. */
  42923. importedMeshesFiles: String[];
  42924. /**
  42925. * Gets or sets a boolean indicating if probes are enabled on this scene
  42926. */
  42927. probesEnabled: boolean;
  42928. /**
  42929. * Gets or sets the current offline provider to use to store scene data
  42930. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  42931. */
  42932. offlineProvider: IOfflineProvider;
  42933. /**
  42934. * Gets or sets the action manager associated with the scene
  42935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42936. */
  42937. actionManager: AbstractActionManager;
  42938. private _meshesForIntersections;
  42939. /**
  42940. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  42941. */
  42942. proceduralTexturesEnabled: boolean;
  42943. private _engine;
  42944. private _totalVertices;
  42945. /** @hidden */
  42946. _activeIndices: PerfCounter;
  42947. /** @hidden */
  42948. _activeParticles: PerfCounter;
  42949. /** @hidden */
  42950. _activeBones: PerfCounter;
  42951. private _animationRatio;
  42952. /** @hidden */
  42953. _animationTimeLast: number;
  42954. /** @hidden */
  42955. _animationTime: number;
  42956. /**
  42957. * Gets or sets a general scale for animation speed
  42958. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  42959. */
  42960. animationTimeScale: number;
  42961. /** @hidden */
  42962. _cachedMaterial: Nullable<Material>;
  42963. /** @hidden */
  42964. _cachedEffect: Nullable<Effect>;
  42965. /** @hidden */
  42966. _cachedVisibility: Nullable<number>;
  42967. private _renderId;
  42968. private _frameId;
  42969. private _executeWhenReadyTimeoutId;
  42970. private _intermediateRendering;
  42971. private _viewUpdateFlag;
  42972. private _projectionUpdateFlag;
  42973. /** @hidden */
  42974. _toBeDisposed: Nullable<IDisposable>[];
  42975. private _activeRequests;
  42976. /** @hidden */
  42977. _pendingData: any[];
  42978. private _isDisposed;
  42979. /**
  42980. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  42981. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  42982. */
  42983. dispatchAllSubMeshesOfActiveMeshes: boolean;
  42984. private _activeMeshes;
  42985. private _processedMaterials;
  42986. private _renderTargets;
  42987. /** @hidden */
  42988. _activeParticleSystems: SmartArray<IParticleSystem>;
  42989. private _activeSkeletons;
  42990. private _softwareSkinnedMeshes;
  42991. private _renderingManager;
  42992. /** @hidden */
  42993. _activeAnimatables: Animatable[];
  42994. private _transformMatrix;
  42995. private _sceneUbo;
  42996. /** @hidden */
  42997. _viewMatrix: Matrix;
  42998. private _projectionMatrix;
  42999. /** @hidden */
  43000. _forcedViewPosition: Nullable<Vector3>;
  43001. /** @hidden */
  43002. _frustumPlanes: Plane[];
  43003. /**
  43004. * Gets the list of frustum planes (built from the active camera)
  43005. */
  43006. get frustumPlanes(): Plane[];
  43007. /**
  43008. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43009. * This is useful if there are more lights that the maximum simulteanous authorized
  43010. */
  43011. requireLightSorting: boolean;
  43012. /** @hidden */
  43013. readonly useMaterialMeshMap: boolean;
  43014. /** @hidden */
  43015. readonly useClonedMeshMap: boolean;
  43016. private _externalData;
  43017. private _uid;
  43018. /**
  43019. * @hidden
  43020. * Backing store of defined scene components.
  43021. */
  43022. _components: ISceneComponent[];
  43023. /**
  43024. * @hidden
  43025. * Backing store of defined scene components.
  43026. */
  43027. _serializableComponents: ISceneSerializableComponent[];
  43028. /**
  43029. * List of components to register on the next registration step.
  43030. */
  43031. private _transientComponents;
  43032. /**
  43033. * Registers the transient components if needed.
  43034. */
  43035. private _registerTransientComponents;
  43036. /**
  43037. * @hidden
  43038. * Add a component to the scene.
  43039. * Note that the ccomponent could be registered on th next frame if this is called after
  43040. * the register component stage.
  43041. * @param component Defines the component to add to the scene
  43042. */
  43043. _addComponent(component: ISceneComponent): void;
  43044. /**
  43045. * @hidden
  43046. * Gets a component from the scene.
  43047. * @param name defines the name of the component to retrieve
  43048. * @returns the component or null if not present
  43049. */
  43050. _getComponent(name: string): Nullable<ISceneComponent>;
  43051. /**
  43052. * @hidden
  43053. * Defines the actions happening before camera updates.
  43054. */
  43055. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43056. /**
  43057. * @hidden
  43058. * Defines the actions happening before clear the canvas.
  43059. */
  43060. _beforeClearStage: Stage<SimpleStageAction>;
  43061. /**
  43062. * @hidden
  43063. * Defines the actions when collecting render targets for the frame.
  43064. */
  43065. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43066. /**
  43067. * @hidden
  43068. * Defines the actions happening for one camera in the frame.
  43069. */
  43070. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43071. /**
  43072. * @hidden
  43073. * Defines the actions happening during the per mesh ready checks.
  43074. */
  43075. _isReadyForMeshStage: Stage<MeshStageAction>;
  43076. /**
  43077. * @hidden
  43078. * Defines the actions happening before evaluate active mesh checks.
  43079. */
  43080. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43081. /**
  43082. * @hidden
  43083. * Defines the actions happening during the evaluate sub mesh checks.
  43084. */
  43085. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43086. /**
  43087. * @hidden
  43088. * Defines the actions happening during the active mesh stage.
  43089. */
  43090. _activeMeshStage: Stage<ActiveMeshStageAction>;
  43091. /**
  43092. * @hidden
  43093. * Defines the actions happening during the per camera render target step.
  43094. */
  43095. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43096. /**
  43097. * @hidden
  43098. * Defines the actions happening just before the active camera is drawing.
  43099. */
  43100. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43101. /**
  43102. * @hidden
  43103. * Defines the actions happening just before a render target is drawing.
  43104. */
  43105. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43106. /**
  43107. * @hidden
  43108. * Defines the actions happening just before a rendering group is drawing.
  43109. */
  43110. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43111. /**
  43112. * @hidden
  43113. * Defines the actions happening just before a mesh is drawing.
  43114. */
  43115. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43116. /**
  43117. * @hidden
  43118. * Defines the actions happening just after a mesh has been drawn.
  43119. */
  43120. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43121. /**
  43122. * @hidden
  43123. * Defines the actions happening just after a rendering group has been drawn.
  43124. */
  43125. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43126. /**
  43127. * @hidden
  43128. * Defines the actions happening just after the active camera has been drawn.
  43129. */
  43130. _afterCameraDrawStage: Stage<CameraStageAction>;
  43131. /**
  43132. * @hidden
  43133. * Defines the actions happening just after a render target has been drawn.
  43134. */
  43135. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43136. /**
  43137. * @hidden
  43138. * Defines the actions happening just after rendering all cameras and computing intersections.
  43139. */
  43140. _afterRenderStage: Stage<SimpleStageAction>;
  43141. /**
  43142. * @hidden
  43143. * Defines the actions happening when a pointer move event happens.
  43144. */
  43145. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43146. /**
  43147. * @hidden
  43148. * Defines the actions happening when a pointer down event happens.
  43149. */
  43150. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43151. /**
  43152. * @hidden
  43153. * Defines the actions happening when a pointer up event happens.
  43154. */
  43155. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43156. /**
  43157. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43158. */
  43159. private geometriesByUniqueId;
  43160. /**
  43161. * Creates a new Scene
  43162. * @param engine defines the engine to use to render this scene
  43163. * @param options defines the scene options
  43164. */
  43165. constructor(engine: Engine, options?: SceneOptions);
  43166. /**
  43167. * Gets a string identifying the name of the class
  43168. * @returns "Scene" string
  43169. */
  43170. getClassName(): string;
  43171. private _defaultMeshCandidates;
  43172. /**
  43173. * @hidden
  43174. */
  43175. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43176. private _defaultSubMeshCandidates;
  43177. /**
  43178. * @hidden
  43179. */
  43180. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43181. /**
  43182. * Sets the default candidate providers for the scene.
  43183. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43184. * and getCollidingSubMeshCandidates to their default function
  43185. */
  43186. setDefaultCandidateProviders(): void;
  43187. /**
  43188. * Gets the mesh that is currently under the pointer
  43189. */
  43190. get meshUnderPointer(): Nullable<AbstractMesh>;
  43191. /**
  43192. * Gets or sets the current on-screen X position of the pointer
  43193. */
  43194. get pointerX(): number;
  43195. set pointerX(value: number);
  43196. /**
  43197. * Gets or sets the current on-screen Y position of the pointer
  43198. */
  43199. get pointerY(): number;
  43200. set pointerY(value: number);
  43201. /**
  43202. * Gets the cached material (ie. the latest rendered one)
  43203. * @returns the cached material
  43204. */
  43205. getCachedMaterial(): Nullable<Material>;
  43206. /**
  43207. * Gets the cached effect (ie. the latest rendered one)
  43208. * @returns the cached effect
  43209. */
  43210. getCachedEffect(): Nullable<Effect>;
  43211. /**
  43212. * Gets the cached visibility state (ie. the latest rendered one)
  43213. * @returns the cached visibility state
  43214. */
  43215. getCachedVisibility(): Nullable<number>;
  43216. /**
  43217. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43218. * @param material defines the current material
  43219. * @param effect defines the current effect
  43220. * @param visibility defines the current visibility state
  43221. * @returns true if one parameter is not cached
  43222. */
  43223. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43224. /**
  43225. * Gets the engine associated with the scene
  43226. * @returns an Engine
  43227. */
  43228. getEngine(): Engine;
  43229. /**
  43230. * Gets the total number of vertices rendered per frame
  43231. * @returns the total number of vertices rendered per frame
  43232. */
  43233. getTotalVertices(): number;
  43234. /**
  43235. * Gets the performance counter for total vertices
  43236. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43237. */
  43238. get totalVerticesPerfCounter(): PerfCounter;
  43239. /**
  43240. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43241. * @returns the total number of active indices rendered per frame
  43242. */
  43243. getActiveIndices(): number;
  43244. /**
  43245. * Gets the performance counter for active indices
  43246. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43247. */
  43248. get totalActiveIndicesPerfCounter(): PerfCounter;
  43249. /**
  43250. * Gets the total number of active particles rendered per frame
  43251. * @returns the total number of active particles rendered per frame
  43252. */
  43253. getActiveParticles(): number;
  43254. /**
  43255. * Gets the performance counter for active particles
  43256. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43257. */
  43258. get activeParticlesPerfCounter(): PerfCounter;
  43259. /**
  43260. * Gets the total number of active bones rendered per frame
  43261. * @returns the total number of active bones rendered per frame
  43262. */
  43263. getActiveBones(): number;
  43264. /**
  43265. * Gets the performance counter for active bones
  43266. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43267. */
  43268. get activeBonesPerfCounter(): PerfCounter;
  43269. /**
  43270. * Gets the array of active meshes
  43271. * @returns an array of AbstractMesh
  43272. */
  43273. getActiveMeshes(): SmartArray<AbstractMesh>;
  43274. /**
  43275. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43276. * @returns a number
  43277. */
  43278. getAnimationRatio(): number;
  43279. /**
  43280. * Gets an unique Id for the current render phase
  43281. * @returns a number
  43282. */
  43283. getRenderId(): number;
  43284. /**
  43285. * Gets an unique Id for the current frame
  43286. * @returns a number
  43287. */
  43288. getFrameId(): number;
  43289. /** Call this function if you want to manually increment the render Id*/
  43290. incrementRenderId(): void;
  43291. private _createUbo;
  43292. /**
  43293. * Use this method to simulate a pointer move on a mesh
  43294. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43295. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43296. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43297. * @returns the current scene
  43298. */
  43299. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43300. /**
  43301. * Use this method to simulate a pointer down on a mesh
  43302. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43303. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43304. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43305. * @returns the current scene
  43306. */
  43307. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43308. /**
  43309. * Use this method to simulate a pointer up on a mesh
  43310. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43311. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43312. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43313. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43314. * @returns the current scene
  43315. */
  43316. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43317. /**
  43318. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43319. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43320. * @returns true if the pointer was captured
  43321. */
  43322. isPointerCaptured(pointerId?: number): boolean;
  43323. /**
  43324. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43325. * @param attachUp defines if you want to attach events to pointerup
  43326. * @param attachDown defines if you want to attach events to pointerdown
  43327. * @param attachMove defines if you want to attach events to pointermove
  43328. */
  43329. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43330. /** Detaches all event handlers*/
  43331. detachControl(): void;
  43332. /**
  43333. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43334. * Delay loaded resources are not taking in account
  43335. * @return true if all required resources are ready
  43336. */
  43337. isReady(): boolean;
  43338. /** Resets all cached information relative to material (including effect and visibility) */
  43339. resetCachedMaterial(): void;
  43340. /**
  43341. * Registers a function to be called before every frame render
  43342. * @param func defines the function to register
  43343. */
  43344. registerBeforeRender(func: () => void): void;
  43345. /**
  43346. * Unregisters a function called before every frame render
  43347. * @param func defines the function to unregister
  43348. */
  43349. unregisterBeforeRender(func: () => void): void;
  43350. /**
  43351. * Registers a function to be called after every frame render
  43352. * @param func defines the function to register
  43353. */
  43354. registerAfterRender(func: () => void): void;
  43355. /**
  43356. * Unregisters a function called after every frame render
  43357. * @param func defines the function to unregister
  43358. */
  43359. unregisterAfterRender(func: () => void): void;
  43360. private _executeOnceBeforeRender;
  43361. /**
  43362. * The provided function will run before render once and will be disposed afterwards.
  43363. * A timeout delay can be provided so that the function will be executed in N ms.
  43364. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43365. * @param func The function to be executed.
  43366. * @param timeout optional delay in ms
  43367. */
  43368. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43369. /** @hidden */
  43370. _addPendingData(data: any): void;
  43371. /** @hidden */
  43372. _removePendingData(data: any): void;
  43373. /**
  43374. * Returns the number of items waiting to be loaded
  43375. * @returns the number of items waiting to be loaded
  43376. */
  43377. getWaitingItemsCount(): number;
  43378. /**
  43379. * Returns a boolean indicating if the scene is still loading data
  43380. */
  43381. get isLoading(): boolean;
  43382. /**
  43383. * Registers a function to be executed when the scene is ready
  43384. * @param {Function} func - the function to be executed
  43385. */
  43386. executeWhenReady(func: () => void): void;
  43387. /**
  43388. * Returns a promise that resolves when the scene is ready
  43389. * @returns A promise that resolves when the scene is ready
  43390. */
  43391. whenReadyAsync(): Promise<void>;
  43392. /** @hidden */
  43393. _checkIsReady(): void;
  43394. /**
  43395. * Gets all animatable attached to the scene
  43396. */
  43397. get animatables(): Animatable[];
  43398. /**
  43399. * Resets the last animation time frame.
  43400. * Useful to override when animations start running when loading a scene for the first time.
  43401. */
  43402. resetLastAnimationTimeFrame(): void;
  43403. /**
  43404. * Gets the current view matrix
  43405. * @returns a Matrix
  43406. */
  43407. getViewMatrix(): Matrix;
  43408. /**
  43409. * Gets the current projection matrix
  43410. * @returns a Matrix
  43411. */
  43412. getProjectionMatrix(): Matrix;
  43413. /**
  43414. * Gets the current transform matrix
  43415. * @returns a Matrix made of View * Projection
  43416. */
  43417. getTransformMatrix(): Matrix;
  43418. /**
  43419. * Sets the current transform matrix
  43420. * @param viewL defines the View matrix to use
  43421. * @param projectionL defines the Projection matrix to use
  43422. * @param viewR defines the right View matrix to use (if provided)
  43423. * @param projectionR defines the right Projection matrix to use (if provided)
  43424. */
  43425. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43426. /**
  43427. * Gets the uniform buffer used to store scene data
  43428. * @returns a UniformBuffer
  43429. */
  43430. getSceneUniformBuffer(): UniformBuffer;
  43431. /**
  43432. * Gets an unique (relatively to the current scene) Id
  43433. * @returns an unique number for the scene
  43434. */
  43435. getUniqueId(): number;
  43436. /**
  43437. * Add a mesh to the list of scene's meshes
  43438. * @param newMesh defines the mesh to add
  43439. * @param recursive if all child meshes should also be added to the scene
  43440. */
  43441. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43442. /**
  43443. * Remove a mesh for the list of scene's meshes
  43444. * @param toRemove defines the mesh to remove
  43445. * @param recursive if all child meshes should also be removed from the scene
  43446. * @returns the index where the mesh was in the mesh list
  43447. */
  43448. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43449. /**
  43450. * Add a transform node to the list of scene's transform nodes
  43451. * @param newTransformNode defines the transform node to add
  43452. */
  43453. addTransformNode(newTransformNode: TransformNode): void;
  43454. /**
  43455. * Remove a transform node for the list of scene's transform nodes
  43456. * @param toRemove defines the transform node to remove
  43457. * @returns the index where the transform node was in the transform node list
  43458. */
  43459. removeTransformNode(toRemove: TransformNode): number;
  43460. /**
  43461. * Remove a skeleton for the list of scene's skeletons
  43462. * @param toRemove defines the skeleton to remove
  43463. * @returns the index where the skeleton was in the skeleton list
  43464. */
  43465. removeSkeleton(toRemove: Skeleton): number;
  43466. /**
  43467. * Remove a morph target for the list of scene's morph targets
  43468. * @param toRemove defines the morph target to remove
  43469. * @returns the index where the morph target was in the morph target list
  43470. */
  43471. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43472. /**
  43473. * Remove a light for the list of scene's lights
  43474. * @param toRemove defines the light to remove
  43475. * @returns the index where the light was in the light list
  43476. */
  43477. removeLight(toRemove: Light): number;
  43478. /**
  43479. * Remove a camera for the list of scene's cameras
  43480. * @param toRemove defines the camera to remove
  43481. * @returns the index where the camera was in the camera list
  43482. */
  43483. removeCamera(toRemove: Camera): number;
  43484. /**
  43485. * Remove a particle system for the list of scene's particle systems
  43486. * @param toRemove defines the particle system to remove
  43487. * @returns the index where the particle system was in the particle system list
  43488. */
  43489. removeParticleSystem(toRemove: IParticleSystem): number;
  43490. /**
  43491. * Remove a animation for the list of scene's animations
  43492. * @param toRemove defines the animation to remove
  43493. * @returns the index where the animation was in the animation list
  43494. */
  43495. removeAnimation(toRemove: Animation): number;
  43496. /**
  43497. * Will stop the animation of the given target
  43498. * @param target - the target
  43499. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43500. * @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)
  43501. */
  43502. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43503. /**
  43504. * Removes the given animation group from this scene.
  43505. * @param toRemove The animation group to remove
  43506. * @returns The index of the removed animation group
  43507. */
  43508. removeAnimationGroup(toRemove: AnimationGroup): number;
  43509. /**
  43510. * Removes the given multi-material from this scene.
  43511. * @param toRemove The multi-material to remove
  43512. * @returns The index of the removed multi-material
  43513. */
  43514. removeMultiMaterial(toRemove: MultiMaterial): number;
  43515. /**
  43516. * Removes the given material from this scene.
  43517. * @param toRemove The material to remove
  43518. * @returns The index of the removed material
  43519. */
  43520. removeMaterial(toRemove: Material): number;
  43521. /**
  43522. * Removes the given action manager from this scene.
  43523. * @param toRemove The action manager to remove
  43524. * @returns The index of the removed action manager
  43525. */
  43526. removeActionManager(toRemove: AbstractActionManager): number;
  43527. /**
  43528. * Removes the given texture from this scene.
  43529. * @param toRemove The texture to remove
  43530. * @returns The index of the removed texture
  43531. */
  43532. removeTexture(toRemove: BaseTexture): number;
  43533. /**
  43534. * Adds the given light to this scene
  43535. * @param newLight The light to add
  43536. */
  43537. addLight(newLight: Light): void;
  43538. /**
  43539. * Sorts the list list based on light priorities
  43540. */
  43541. sortLightsByPriority(): void;
  43542. /**
  43543. * Adds the given camera to this scene
  43544. * @param newCamera The camera to add
  43545. */
  43546. addCamera(newCamera: Camera): void;
  43547. /**
  43548. * Adds the given skeleton to this scene
  43549. * @param newSkeleton The skeleton to add
  43550. */
  43551. addSkeleton(newSkeleton: Skeleton): void;
  43552. /**
  43553. * Adds the given particle system to this scene
  43554. * @param newParticleSystem The particle system to add
  43555. */
  43556. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43557. /**
  43558. * Adds the given animation to this scene
  43559. * @param newAnimation The animation to add
  43560. */
  43561. addAnimation(newAnimation: Animation): void;
  43562. /**
  43563. * Adds the given animation group to this scene.
  43564. * @param newAnimationGroup The animation group to add
  43565. */
  43566. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43567. /**
  43568. * Adds the given multi-material to this scene
  43569. * @param newMultiMaterial The multi-material to add
  43570. */
  43571. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43572. /**
  43573. * Adds the given material to this scene
  43574. * @param newMaterial The material to add
  43575. */
  43576. addMaterial(newMaterial: Material): void;
  43577. /**
  43578. * Adds the given morph target to this scene
  43579. * @param newMorphTargetManager The morph target to add
  43580. */
  43581. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43582. /**
  43583. * Adds the given geometry to this scene
  43584. * @param newGeometry The geometry to add
  43585. */
  43586. addGeometry(newGeometry: Geometry): void;
  43587. /**
  43588. * Adds the given action manager to this scene
  43589. * @param newActionManager The action manager to add
  43590. */
  43591. addActionManager(newActionManager: AbstractActionManager): void;
  43592. /**
  43593. * Adds the given texture to this scene.
  43594. * @param newTexture The texture to add
  43595. */
  43596. addTexture(newTexture: BaseTexture): void;
  43597. /**
  43598. * Switch active camera
  43599. * @param newCamera defines the new active camera
  43600. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43601. */
  43602. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43603. /**
  43604. * sets the active camera of the scene using its ID
  43605. * @param id defines the camera's ID
  43606. * @return the new active camera or null if none found.
  43607. */
  43608. setActiveCameraByID(id: string): Nullable<Camera>;
  43609. /**
  43610. * sets the active camera of the scene using its name
  43611. * @param name defines the camera's name
  43612. * @returns the new active camera or null if none found.
  43613. */
  43614. setActiveCameraByName(name: string): Nullable<Camera>;
  43615. /**
  43616. * get an animation group using its name
  43617. * @param name defines the material's name
  43618. * @return the animation group or null if none found.
  43619. */
  43620. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  43621. /**
  43622. * Get a material using its unique id
  43623. * @param uniqueId defines the material's unique id
  43624. * @return the material or null if none found.
  43625. */
  43626. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  43627. /**
  43628. * get a material using its id
  43629. * @param id defines the material's ID
  43630. * @return the material or null if none found.
  43631. */
  43632. getMaterialByID(id: string): Nullable<Material>;
  43633. /**
  43634. * Gets a the last added material using a given id
  43635. * @param id defines the material's ID
  43636. * @return the last material with the given id or null if none found.
  43637. */
  43638. getLastMaterialByID(id: string): Nullable<Material>;
  43639. /**
  43640. * Gets a material using its name
  43641. * @param name defines the material's name
  43642. * @return the material or null if none found.
  43643. */
  43644. getMaterialByName(name: string): Nullable<Material>;
  43645. /**
  43646. * Get a texture using its unique id
  43647. * @param uniqueId defines the texture's unique id
  43648. * @return the texture or null if none found.
  43649. */
  43650. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  43651. /**
  43652. * Gets a camera using its id
  43653. * @param id defines the id to look for
  43654. * @returns the camera or null if not found
  43655. */
  43656. getCameraByID(id: string): Nullable<Camera>;
  43657. /**
  43658. * Gets a camera using its unique id
  43659. * @param uniqueId defines the unique id to look for
  43660. * @returns the camera or null if not found
  43661. */
  43662. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  43663. /**
  43664. * Gets a camera using its name
  43665. * @param name defines the camera's name
  43666. * @return the camera or null if none found.
  43667. */
  43668. getCameraByName(name: string): Nullable<Camera>;
  43669. /**
  43670. * Gets a bone using its id
  43671. * @param id defines the bone's id
  43672. * @return the bone or null if not found
  43673. */
  43674. getBoneByID(id: string): Nullable<Bone>;
  43675. /**
  43676. * Gets a bone using its id
  43677. * @param name defines the bone's name
  43678. * @return the bone or null if not found
  43679. */
  43680. getBoneByName(name: string): Nullable<Bone>;
  43681. /**
  43682. * Gets a light node using its name
  43683. * @param name defines the the light's name
  43684. * @return the light or null if none found.
  43685. */
  43686. getLightByName(name: string): Nullable<Light>;
  43687. /**
  43688. * Gets a light node using its id
  43689. * @param id defines the light's id
  43690. * @return the light or null if none found.
  43691. */
  43692. getLightByID(id: string): Nullable<Light>;
  43693. /**
  43694. * Gets a light node using its scene-generated unique ID
  43695. * @param uniqueId defines the light's unique id
  43696. * @return the light or null if none found.
  43697. */
  43698. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  43699. /**
  43700. * Gets a particle system by id
  43701. * @param id defines the particle system id
  43702. * @return the corresponding system or null if none found
  43703. */
  43704. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  43705. /**
  43706. * Gets a geometry using its ID
  43707. * @param id defines the geometry's id
  43708. * @return the geometry or null if none found.
  43709. */
  43710. getGeometryByID(id: string): Nullable<Geometry>;
  43711. private _getGeometryByUniqueID;
  43712. /**
  43713. * Add a new geometry to this scene
  43714. * @param geometry defines the geometry to be added to the scene.
  43715. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  43716. * @return a boolean defining if the geometry was added or not
  43717. */
  43718. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  43719. /**
  43720. * Removes an existing geometry
  43721. * @param geometry defines the geometry to be removed from the scene
  43722. * @return a boolean defining if the geometry was removed or not
  43723. */
  43724. removeGeometry(geometry: Geometry): boolean;
  43725. /**
  43726. * Gets the list of geometries attached to the scene
  43727. * @returns an array of Geometry
  43728. */
  43729. getGeometries(): Geometry[];
  43730. /**
  43731. * Gets the first added mesh found of a given ID
  43732. * @param id defines the id to search for
  43733. * @return the mesh found or null if not found at all
  43734. */
  43735. getMeshByID(id: string): Nullable<AbstractMesh>;
  43736. /**
  43737. * Gets a list of meshes using their id
  43738. * @param id defines the id to search for
  43739. * @returns a list of meshes
  43740. */
  43741. getMeshesByID(id: string): Array<AbstractMesh>;
  43742. /**
  43743. * Gets the first added transform node found of a given ID
  43744. * @param id defines the id to search for
  43745. * @return the found transform node or null if not found at all.
  43746. */
  43747. getTransformNodeByID(id: string): Nullable<TransformNode>;
  43748. /**
  43749. * Gets a transform node with its auto-generated unique id
  43750. * @param uniqueId efines the unique id to search for
  43751. * @return the found transform node or null if not found at all.
  43752. */
  43753. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  43754. /**
  43755. * Gets a list of transform nodes using their id
  43756. * @param id defines the id to search for
  43757. * @returns a list of transform nodes
  43758. */
  43759. getTransformNodesByID(id: string): Array<TransformNode>;
  43760. /**
  43761. * Gets a mesh with its auto-generated unique id
  43762. * @param uniqueId defines the unique id to search for
  43763. * @return the found mesh or null if not found at all.
  43764. */
  43765. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  43766. /**
  43767. * Gets a the last added mesh using a given id
  43768. * @param id defines the id to search for
  43769. * @return the found mesh or null if not found at all.
  43770. */
  43771. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  43772. /**
  43773. * Gets a the last added node (Mesh, Camera, Light) using a given id
  43774. * @param id defines the id to search for
  43775. * @return the found node or null if not found at all
  43776. */
  43777. getLastEntryByID(id: string): Nullable<Node>;
  43778. /**
  43779. * Gets a node (Mesh, Camera, Light) using a given id
  43780. * @param id defines the id to search for
  43781. * @return the found node or null if not found at all
  43782. */
  43783. getNodeByID(id: string): Nullable<Node>;
  43784. /**
  43785. * Gets a node (Mesh, Camera, Light) using a given name
  43786. * @param name defines the name to search for
  43787. * @return the found node or null if not found at all.
  43788. */
  43789. getNodeByName(name: string): Nullable<Node>;
  43790. /**
  43791. * Gets a mesh using a given name
  43792. * @param name defines the name to search for
  43793. * @return the found mesh or null if not found at all.
  43794. */
  43795. getMeshByName(name: string): Nullable<AbstractMesh>;
  43796. /**
  43797. * Gets a transform node using a given name
  43798. * @param name defines the name to search for
  43799. * @return the found transform node or null if not found at all.
  43800. */
  43801. getTransformNodeByName(name: string): Nullable<TransformNode>;
  43802. /**
  43803. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  43804. * @param id defines the id to search for
  43805. * @return the found skeleton or null if not found at all.
  43806. */
  43807. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  43808. /**
  43809. * Gets a skeleton using a given auto generated unique id
  43810. * @param uniqueId defines the unique id to search for
  43811. * @return the found skeleton or null if not found at all.
  43812. */
  43813. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  43814. /**
  43815. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  43816. * @param id defines the id to search for
  43817. * @return the found skeleton or null if not found at all.
  43818. */
  43819. getSkeletonById(id: string): Nullable<Skeleton>;
  43820. /**
  43821. * Gets a skeleton using a given name
  43822. * @param name defines the name to search for
  43823. * @return the found skeleton or null if not found at all.
  43824. */
  43825. getSkeletonByName(name: string): Nullable<Skeleton>;
  43826. /**
  43827. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  43828. * @param id defines the id to search for
  43829. * @return the found morph target manager or null if not found at all.
  43830. */
  43831. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  43832. /**
  43833. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  43834. * @param id defines the id to search for
  43835. * @return the found morph target or null if not found at all.
  43836. */
  43837. getMorphTargetById(id: string): Nullable<MorphTarget>;
  43838. /**
  43839. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  43840. * @param name defines the name to search for
  43841. * @return the found morph target or null if not found at all.
  43842. */
  43843. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  43844. /**
  43845. * Gets a post process using a given name (if many are found, this function will pick the first one)
  43846. * @param name defines the name to search for
  43847. * @return the found post process or null if not found at all.
  43848. */
  43849. getPostProcessByName(name: string): Nullable<PostProcess>;
  43850. /**
  43851. * Gets a boolean indicating if the given mesh is active
  43852. * @param mesh defines the mesh to look for
  43853. * @returns true if the mesh is in the active list
  43854. */
  43855. isActiveMesh(mesh: AbstractMesh): boolean;
  43856. /**
  43857. * Return a unique id as a string which can serve as an identifier for the scene
  43858. */
  43859. get uid(): string;
  43860. /**
  43861. * Add an externaly attached data from its key.
  43862. * This method call will fail and return false, if such key already exists.
  43863. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  43864. * @param key the unique key that identifies the data
  43865. * @param data the data object to associate to the key for this Engine instance
  43866. * @return true if no such key were already present and the data was added successfully, false otherwise
  43867. */
  43868. addExternalData<T>(key: string, data: T): boolean;
  43869. /**
  43870. * Get an externaly attached data from its key
  43871. * @param key the unique key that identifies the data
  43872. * @return the associated data, if present (can be null), or undefined if not present
  43873. */
  43874. getExternalData<T>(key: string): Nullable<T>;
  43875. /**
  43876. * Get an externaly attached data from its key, create it using a factory if it's not already present
  43877. * @param key the unique key that identifies the data
  43878. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  43879. * @return the associated data, can be null if the factory returned null.
  43880. */
  43881. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  43882. /**
  43883. * Remove an externaly attached data from the Engine instance
  43884. * @param key the unique key that identifies the data
  43885. * @return true if the data was successfully removed, false if it doesn't exist
  43886. */
  43887. removeExternalData(key: string): boolean;
  43888. private _evaluateSubMesh;
  43889. /**
  43890. * Clear the processed materials smart array preventing retention point in material dispose.
  43891. */
  43892. freeProcessedMaterials(): void;
  43893. private _preventFreeActiveMeshesAndRenderingGroups;
  43894. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  43895. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  43896. * when disposing several meshes in a row or a hierarchy of meshes.
  43897. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  43898. */
  43899. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  43900. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  43901. /**
  43902. * Clear the active meshes smart array preventing retention point in mesh dispose.
  43903. */
  43904. freeActiveMeshes(): void;
  43905. /**
  43906. * Clear the info related to rendering groups preventing retention points during dispose.
  43907. */
  43908. freeRenderingGroups(): void;
  43909. /** @hidden */
  43910. _isInIntermediateRendering(): boolean;
  43911. /**
  43912. * Lambda returning the list of potentially active meshes.
  43913. */
  43914. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  43915. /**
  43916. * Lambda returning the list of potentially active sub meshes.
  43917. */
  43918. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  43919. /**
  43920. * Lambda returning the list of potentially intersecting sub meshes.
  43921. */
  43922. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  43923. /**
  43924. * Lambda returning the list of potentially colliding sub meshes.
  43925. */
  43926. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  43927. private _activeMeshesFrozen;
  43928. private _skipEvaluateActiveMeshesCompletely;
  43929. /**
  43930. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  43931. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  43932. * @param onSuccess optional success callback
  43933. * @param onError optional error callback
  43934. * @returns the current scene
  43935. */
  43936. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  43937. /**
  43938. * Use this function to restart evaluating active meshes on every frame
  43939. * @returns the current scene
  43940. */
  43941. unfreezeActiveMeshes(): Scene;
  43942. private _evaluateActiveMeshes;
  43943. private _activeMesh;
  43944. /**
  43945. * Update the transform matrix to update from the current active camera
  43946. * @param force defines a boolean used to force the update even if cache is up to date
  43947. */
  43948. updateTransformMatrix(force?: boolean): void;
  43949. private _bindFrameBuffer;
  43950. /** @hidden */
  43951. _allowPostProcessClearColor: boolean;
  43952. /** @hidden */
  43953. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  43954. private _processSubCameras;
  43955. private _checkIntersections;
  43956. /** @hidden */
  43957. _advancePhysicsEngineStep(step: number): void;
  43958. /**
  43959. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  43960. */
  43961. getDeterministicFrameTime: () => number;
  43962. /** @hidden */
  43963. _animate(): void;
  43964. /** Execute all animations (for a frame) */
  43965. animate(): void;
  43966. /**
  43967. * Render the scene
  43968. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  43969. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  43970. */
  43971. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  43972. /**
  43973. * Freeze all materials
  43974. * A frozen material will not be updatable but should be faster to render
  43975. */
  43976. freezeMaterials(): void;
  43977. /**
  43978. * Unfreeze all materials
  43979. * A frozen material will not be updatable but should be faster to render
  43980. */
  43981. unfreezeMaterials(): void;
  43982. /**
  43983. * Releases all held ressources
  43984. */
  43985. dispose(): void;
  43986. /**
  43987. * Gets if the scene is already disposed
  43988. */
  43989. get isDisposed(): boolean;
  43990. /**
  43991. * Call this function to reduce memory footprint of the scene.
  43992. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  43993. */
  43994. clearCachedVertexData(): void;
  43995. /**
  43996. * This function will remove the local cached buffer data from texture.
  43997. * It will save memory but will prevent the texture from being rebuilt
  43998. */
  43999. cleanCachedTextureBuffer(): void;
  44000. /**
  44001. * Get the world extend vectors with an optional filter
  44002. *
  44003. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44004. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44005. */
  44006. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44007. min: Vector3;
  44008. max: Vector3;
  44009. };
  44010. /**
  44011. * Creates a ray that can be used to pick in the scene
  44012. * @param x defines the x coordinate of the origin (on-screen)
  44013. * @param y defines the y coordinate of the origin (on-screen)
  44014. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44015. * @param camera defines the camera to use for the picking
  44016. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44017. * @returns a Ray
  44018. */
  44019. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44020. /**
  44021. * Creates a ray that can be used to pick in the scene
  44022. * @param x defines the x coordinate of the origin (on-screen)
  44023. * @param y defines the y coordinate of the origin (on-screen)
  44024. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44025. * @param result defines the ray where to store the picking ray
  44026. * @param camera defines the camera to use for the picking
  44027. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44028. * @returns the current scene
  44029. */
  44030. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44031. /**
  44032. * Creates a ray that can be used to pick in the scene
  44033. * @param x defines the x coordinate of the origin (on-screen)
  44034. * @param y defines the y coordinate of the origin (on-screen)
  44035. * @param camera defines the camera to use for the picking
  44036. * @returns a Ray
  44037. */
  44038. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44039. /**
  44040. * Creates a ray that can be used to pick in the scene
  44041. * @param x defines the x coordinate of the origin (on-screen)
  44042. * @param y defines the y coordinate of the origin (on-screen)
  44043. * @param result defines the ray where to store the picking ray
  44044. * @param camera defines the camera to use for the picking
  44045. * @returns the current scene
  44046. */
  44047. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44048. /** Launch a ray to try to pick a mesh in the scene
  44049. * @param x position on screen
  44050. * @param y position on screen
  44051. * @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
  44052. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44053. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44054. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44055. * @returns a PickingInfo
  44056. */
  44057. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44058. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44059. * @param x position on screen
  44060. * @param y position on screen
  44061. * @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
  44062. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44063. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44064. * @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)
  44065. */
  44066. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44067. /** Use the given ray to pick a mesh in the scene
  44068. * @param ray The ray to use to pick meshes
  44069. * @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
  44070. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44071. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44072. * @returns a PickingInfo
  44073. */
  44074. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44075. /**
  44076. * Launch a ray to try to pick a mesh in the scene
  44077. * @param x X position on screen
  44078. * @param y Y position on screen
  44079. * @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
  44080. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44081. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44082. * @returns an array of PickingInfo
  44083. */
  44084. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44085. /**
  44086. * Launch a ray to try to pick a mesh in the scene
  44087. * @param ray Ray to use
  44088. * @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
  44089. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44090. * @returns an array of PickingInfo
  44091. */
  44092. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44093. /**
  44094. * Force the value of meshUnderPointer
  44095. * @param mesh defines the mesh to use
  44096. * @param pointerId optional pointer id when using more than one pointer
  44097. */
  44098. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44099. /**
  44100. * Gets the mesh under the pointer
  44101. * @returns a Mesh or null if no mesh is under the pointer
  44102. */
  44103. getPointerOverMesh(): Nullable<AbstractMesh>;
  44104. /** @hidden */
  44105. _rebuildGeometries(): void;
  44106. /** @hidden */
  44107. _rebuildTextures(): void;
  44108. private _getByTags;
  44109. /**
  44110. * Get a list of meshes by tags
  44111. * @param tagsQuery defines the tags query to use
  44112. * @param forEach defines a predicate used to filter results
  44113. * @returns an array of Mesh
  44114. */
  44115. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44116. /**
  44117. * Get a list of cameras by tags
  44118. * @param tagsQuery defines the tags query to use
  44119. * @param forEach defines a predicate used to filter results
  44120. * @returns an array of Camera
  44121. */
  44122. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44123. /**
  44124. * Get a list of lights by tags
  44125. * @param tagsQuery defines the tags query to use
  44126. * @param forEach defines a predicate used to filter results
  44127. * @returns an array of Light
  44128. */
  44129. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44130. /**
  44131. * Get a list of materials by tags
  44132. * @param tagsQuery defines the tags query to use
  44133. * @param forEach defines a predicate used to filter results
  44134. * @returns an array of Material
  44135. */
  44136. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44137. /**
  44138. * Get a list of transform nodes by tags
  44139. * @param tagsQuery defines the tags query to use
  44140. * @param forEach defines a predicate used to filter results
  44141. * @returns an array of TransformNode
  44142. */
  44143. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44144. /**
  44145. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44146. * This allowed control for front to back rendering or reversly depending of the special needs.
  44147. *
  44148. * @param renderingGroupId The rendering group id corresponding to its index
  44149. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44150. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44151. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44152. */
  44153. 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;
  44154. /**
  44155. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44156. *
  44157. * @param renderingGroupId The rendering group id corresponding to its index
  44158. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44159. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44160. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44161. */
  44162. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44163. /**
  44164. * Gets the current auto clear configuration for one rendering group of the rendering
  44165. * manager.
  44166. * @param index the rendering group index to get the information for
  44167. * @returns The auto clear setup for the requested rendering group
  44168. */
  44169. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44170. private _blockMaterialDirtyMechanism;
  44171. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44172. get blockMaterialDirtyMechanism(): boolean;
  44173. set blockMaterialDirtyMechanism(value: boolean);
  44174. /**
  44175. * Will flag all materials as dirty to trigger new shader compilation
  44176. * @param flag defines the flag used to specify which material part must be marked as dirty
  44177. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44178. */
  44179. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44180. /** @hidden */
  44181. _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;
  44182. /** @hidden */
  44183. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44184. /** @hidden */
  44185. _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;
  44186. /** @hidden */
  44187. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44188. /** @hidden */
  44189. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44190. /** @hidden */
  44191. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44192. }
  44193. }
  44194. declare module BABYLON {
  44195. /**
  44196. * Set of assets to keep when moving a scene into an asset container.
  44197. */
  44198. export class KeepAssets extends AbstractScene {
  44199. }
  44200. /**
  44201. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44202. */
  44203. export class InstantiatedEntries {
  44204. /**
  44205. * List of new root nodes (eg. nodes with no parent)
  44206. */
  44207. rootNodes: TransformNode[];
  44208. /**
  44209. * List of new skeletons
  44210. */
  44211. skeletons: Skeleton[];
  44212. /**
  44213. * List of new animation groups
  44214. */
  44215. animationGroups: AnimationGroup[];
  44216. }
  44217. /**
  44218. * Container with a set of assets that can be added or removed from a scene.
  44219. */
  44220. export class AssetContainer extends AbstractScene {
  44221. private _wasAddedToScene;
  44222. /**
  44223. * The scene the AssetContainer belongs to.
  44224. */
  44225. scene: Scene;
  44226. /**
  44227. * Instantiates an AssetContainer.
  44228. * @param scene The scene the AssetContainer belongs to.
  44229. */
  44230. constructor(scene: Scene);
  44231. /**
  44232. * Instantiate or clone all meshes and add the new ones to the scene.
  44233. * Skeletons and animation groups will all be cloned
  44234. * @param nameFunction defines an optional function used to get new names for clones
  44235. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44236. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44237. */
  44238. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44239. /**
  44240. * Adds all the assets from the container to the scene.
  44241. */
  44242. addAllToScene(): void;
  44243. /**
  44244. * Removes all the assets in the container from the scene
  44245. */
  44246. removeAllFromScene(): void;
  44247. /**
  44248. * Disposes all the assets in the container
  44249. */
  44250. dispose(): void;
  44251. private _moveAssets;
  44252. /**
  44253. * Removes all the assets contained in the scene and adds them to the container.
  44254. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44255. */
  44256. moveAllFromScene(keepAssets?: KeepAssets): void;
  44257. /**
  44258. * 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.
  44259. * @returns the root mesh
  44260. */
  44261. createRootMesh(): Mesh;
  44262. /**
  44263. * Merge animations (direct and animation groups) from this asset container into a scene
  44264. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44265. * @param animatables set of animatables to retarget to a node from the scene
  44266. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44267. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44268. */
  44269. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44270. }
  44271. }
  44272. declare module BABYLON {
  44273. /**
  44274. * Defines how the parser contract is defined.
  44275. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44276. */
  44277. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44278. /**
  44279. * Defines how the individual parser contract is defined.
  44280. * These parser can parse an individual asset
  44281. */
  44282. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44283. /**
  44284. * Base class of the scene acting as a container for the different elements composing a scene.
  44285. * This class is dynamically extended by the different components of the scene increasing
  44286. * flexibility and reducing coupling
  44287. */
  44288. export abstract class AbstractScene {
  44289. /**
  44290. * Stores the list of available parsers in the application.
  44291. */
  44292. private static _BabylonFileParsers;
  44293. /**
  44294. * Stores the list of available individual parsers in the application.
  44295. */
  44296. private static _IndividualBabylonFileParsers;
  44297. /**
  44298. * Adds a parser in the list of available ones
  44299. * @param name Defines the name of the parser
  44300. * @param parser Defines the parser to add
  44301. */
  44302. static AddParser(name: string, parser: BabylonFileParser): void;
  44303. /**
  44304. * Gets a general parser from the list of avaialble ones
  44305. * @param name Defines the name of the parser
  44306. * @returns the requested parser or null
  44307. */
  44308. static GetParser(name: string): Nullable<BabylonFileParser>;
  44309. /**
  44310. * Adds n individual parser in the list of available ones
  44311. * @param name Defines the name of the parser
  44312. * @param parser Defines the parser to add
  44313. */
  44314. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44315. /**
  44316. * Gets an individual parser from the list of avaialble ones
  44317. * @param name Defines the name of the parser
  44318. * @returns the requested parser or null
  44319. */
  44320. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44321. /**
  44322. * Parser json data and populate both a scene and its associated container object
  44323. * @param jsonData Defines the data to parse
  44324. * @param scene Defines the scene to parse the data for
  44325. * @param container Defines the container attached to the parsing sequence
  44326. * @param rootUrl Defines the root url of the data
  44327. */
  44328. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44329. /**
  44330. * Gets the list of root nodes (ie. nodes with no parent)
  44331. */
  44332. rootNodes: Node[];
  44333. /** All of the cameras added to this scene
  44334. * @see https://doc.babylonjs.com/babylon101/cameras
  44335. */
  44336. cameras: Camera[];
  44337. /**
  44338. * All of the lights added to this scene
  44339. * @see https://doc.babylonjs.com/babylon101/lights
  44340. */
  44341. lights: Light[];
  44342. /**
  44343. * All of the (abstract) meshes added to this scene
  44344. */
  44345. meshes: AbstractMesh[];
  44346. /**
  44347. * The list of skeletons added to the scene
  44348. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44349. */
  44350. skeletons: Skeleton[];
  44351. /**
  44352. * All of the particle systems added to this scene
  44353. * @see https://doc.babylonjs.com/babylon101/particles
  44354. */
  44355. particleSystems: IParticleSystem[];
  44356. /**
  44357. * Gets a list of Animations associated with the scene
  44358. */
  44359. animations: Animation[];
  44360. /**
  44361. * All of the animation groups added to this scene
  44362. * @see https://doc.babylonjs.com/how_to/group
  44363. */
  44364. animationGroups: AnimationGroup[];
  44365. /**
  44366. * All of the multi-materials added to this scene
  44367. * @see https://doc.babylonjs.com/how_to/multi_materials
  44368. */
  44369. multiMaterials: MultiMaterial[];
  44370. /**
  44371. * All of the materials added to this scene
  44372. * In the context of a Scene, it is not supposed to be modified manually.
  44373. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44374. * Note also that the order of the Material within the array is not significant and might change.
  44375. * @see https://doc.babylonjs.com/babylon101/materials
  44376. */
  44377. materials: Material[];
  44378. /**
  44379. * The list of morph target managers added to the scene
  44380. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44381. */
  44382. morphTargetManagers: MorphTargetManager[];
  44383. /**
  44384. * The list of geometries used in the scene.
  44385. */
  44386. geometries: Geometry[];
  44387. /**
  44388. * All of the tranform nodes added to this scene
  44389. * In the context of a Scene, it is not supposed to be modified manually.
  44390. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44391. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44392. * @see https://doc.babylonjs.com/how_to/transformnode
  44393. */
  44394. transformNodes: TransformNode[];
  44395. /**
  44396. * ActionManagers available on the scene.
  44397. */
  44398. actionManagers: AbstractActionManager[];
  44399. /**
  44400. * Textures to keep.
  44401. */
  44402. textures: BaseTexture[];
  44403. /** @hidden */
  44404. protected _environmentTexture: Nullable<BaseTexture>;
  44405. /**
  44406. * Texture used in all pbr material as the reflection texture.
  44407. * As in the majority of the scene they are the same (exception for multi room and so on),
  44408. * this is easier to reference from here than from all the materials.
  44409. */
  44410. get environmentTexture(): Nullable<BaseTexture>;
  44411. set environmentTexture(value: Nullable<BaseTexture>);
  44412. /**
  44413. * The list of postprocesses added to the scene
  44414. */
  44415. postProcesses: PostProcess[];
  44416. /**
  44417. * @returns all meshes, lights, cameras, transformNodes and bones
  44418. */
  44419. getNodes(): Array<Node>;
  44420. }
  44421. }
  44422. declare module BABYLON {
  44423. /**
  44424. * Interface used to define options for Sound class
  44425. */
  44426. export interface ISoundOptions {
  44427. /**
  44428. * Does the sound autoplay once loaded.
  44429. */
  44430. autoplay?: boolean;
  44431. /**
  44432. * Does the sound loop after it finishes playing once.
  44433. */
  44434. loop?: boolean;
  44435. /**
  44436. * Sound's volume
  44437. */
  44438. volume?: number;
  44439. /**
  44440. * Is it a spatial sound?
  44441. */
  44442. spatialSound?: boolean;
  44443. /**
  44444. * Maximum distance to hear that sound
  44445. */
  44446. maxDistance?: number;
  44447. /**
  44448. * Uses user defined attenuation function
  44449. */
  44450. useCustomAttenuation?: boolean;
  44451. /**
  44452. * Define the roll off factor of spatial sounds.
  44453. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44454. */
  44455. rolloffFactor?: number;
  44456. /**
  44457. * Define the reference distance the sound should be heard perfectly.
  44458. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44459. */
  44460. refDistance?: number;
  44461. /**
  44462. * Define the distance attenuation model the sound will follow.
  44463. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44464. */
  44465. distanceModel?: string;
  44466. /**
  44467. * Defines the playback speed (1 by default)
  44468. */
  44469. playbackRate?: number;
  44470. /**
  44471. * Defines if the sound is from a streaming source
  44472. */
  44473. streaming?: boolean;
  44474. /**
  44475. * Defines an optional length (in seconds) inside the sound file
  44476. */
  44477. length?: number;
  44478. /**
  44479. * Defines an optional offset (in seconds) inside the sound file
  44480. */
  44481. offset?: number;
  44482. /**
  44483. * If true, URLs will not be required to state the audio file codec to use.
  44484. */
  44485. skipCodecCheck?: boolean;
  44486. }
  44487. /**
  44488. * Defines a sound that can be played in the application.
  44489. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44490. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44491. */
  44492. export class Sound {
  44493. /**
  44494. * The name of the sound in the scene.
  44495. */
  44496. name: string;
  44497. /**
  44498. * Does the sound autoplay once loaded.
  44499. */
  44500. autoplay: boolean;
  44501. /**
  44502. * Does the sound loop after it finishes playing once.
  44503. */
  44504. loop: boolean;
  44505. /**
  44506. * Does the sound use a custom attenuation curve to simulate the falloff
  44507. * happening when the source gets further away from the camera.
  44508. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44509. */
  44510. useCustomAttenuation: boolean;
  44511. /**
  44512. * The sound track id this sound belongs to.
  44513. */
  44514. soundTrackId: number;
  44515. /**
  44516. * Is this sound currently played.
  44517. */
  44518. isPlaying: boolean;
  44519. /**
  44520. * Is this sound currently paused.
  44521. */
  44522. isPaused: boolean;
  44523. /**
  44524. * Does this sound enables spatial sound.
  44525. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44526. */
  44527. spatialSound: boolean;
  44528. /**
  44529. * Define the reference distance the sound should be heard perfectly.
  44530. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44531. */
  44532. refDistance: number;
  44533. /**
  44534. * Define the roll off factor of spatial sounds.
  44535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44536. */
  44537. rolloffFactor: number;
  44538. /**
  44539. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44540. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44541. */
  44542. maxDistance: number;
  44543. /**
  44544. * Define the distance attenuation model the sound will follow.
  44545. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44546. */
  44547. distanceModel: string;
  44548. /**
  44549. * @hidden
  44550. * Back Compat
  44551. **/
  44552. onended: () => any;
  44553. /**
  44554. * Gets or sets an object used to store user defined information for the sound.
  44555. */
  44556. metadata: any;
  44557. /**
  44558. * Observable event when the current playing sound finishes.
  44559. */
  44560. onEndedObservable: Observable<Sound>;
  44561. private _panningModel;
  44562. private _playbackRate;
  44563. private _streaming;
  44564. private _startTime;
  44565. private _startOffset;
  44566. private _position;
  44567. /** @hidden */
  44568. _positionInEmitterSpace: boolean;
  44569. private _localDirection;
  44570. private _volume;
  44571. private _isReadyToPlay;
  44572. private _isDirectional;
  44573. private _readyToPlayCallback;
  44574. private _audioBuffer;
  44575. private _soundSource;
  44576. private _streamingSource;
  44577. private _soundPanner;
  44578. private _soundGain;
  44579. private _inputAudioNode;
  44580. private _outputAudioNode;
  44581. private _coneInnerAngle;
  44582. private _coneOuterAngle;
  44583. private _coneOuterGain;
  44584. private _scene;
  44585. private _connectedTransformNode;
  44586. private _customAttenuationFunction;
  44587. private _registerFunc;
  44588. private _isOutputConnected;
  44589. private _htmlAudioElement;
  44590. private _urlType;
  44591. private _length?;
  44592. private _offset?;
  44593. /** @hidden */
  44594. static _SceneComponentInitialization: (scene: Scene) => void;
  44595. /**
  44596. * Create a sound and attach it to a scene
  44597. * @param name Name of your sound
  44598. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44599. * @param scene defines the scene the sound belongs to
  44600. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44601. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44602. */
  44603. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44604. /**
  44605. * Release the sound and its associated resources
  44606. */
  44607. dispose(): void;
  44608. /**
  44609. * Gets if the sounds is ready to be played or not.
  44610. * @returns true if ready, otherwise false
  44611. */
  44612. isReady(): boolean;
  44613. private _soundLoaded;
  44614. /**
  44615. * Sets the data of the sound from an audiobuffer
  44616. * @param audioBuffer The audioBuffer containing the data
  44617. */
  44618. setAudioBuffer(audioBuffer: AudioBuffer): void;
  44619. /**
  44620. * Updates the current sounds options such as maxdistance, loop...
  44621. * @param options A JSON object containing values named as the object properties
  44622. */
  44623. updateOptions(options: ISoundOptions): void;
  44624. private _createSpatialParameters;
  44625. private _updateSpatialParameters;
  44626. /**
  44627. * Switch the panning model to HRTF:
  44628. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44629. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44630. */
  44631. switchPanningModelToHRTF(): void;
  44632. /**
  44633. * Switch the panning model to Equal Power:
  44634. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44635. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44636. */
  44637. switchPanningModelToEqualPower(): void;
  44638. private _switchPanningModel;
  44639. /**
  44640. * Connect this sound to a sound track audio node like gain...
  44641. * @param soundTrackAudioNode the sound track audio node to connect to
  44642. */
  44643. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  44644. /**
  44645. * Transform this sound into a directional source
  44646. * @param coneInnerAngle Size of the inner cone in degree
  44647. * @param coneOuterAngle Size of the outer cone in degree
  44648. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  44649. */
  44650. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  44651. /**
  44652. * Gets or sets the inner angle for the directional cone.
  44653. */
  44654. get directionalConeInnerAngle(): number;
  44655. /**
  44656. * Gets or sets the inner angle for the directional cone.
  44657. */
  44658. set directionalConeInnerAngle(value: number);
  44659. /**
  44660. * Gets or sets the outer angle for the directional cone.
  44661. */
  44662. get directionalConeOuterAngle(): number;
  44663. /**
  44664. * Gets or sets the outer angle for the directional cone.
  44665. */
  44666. set directionalConeOuterAngle(value: number);
  44667. /**
  44668. * Sets the position of the emitter if spatial sound is enabled
  44669. * @param newPosition Defines the new posisiton
  44670. */
  44671. setPosition(newPosition: Vector3): void;
  44672. /**
  44673. * Sets the local direction of the emitter if spatial sound is enabled
  44674. * @param newLocalDirection Defines the new local direction
  44675. */
  44676. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  44677. private _updateDirection;
  44678. /** @hidden */
  44679. updateDistanceFromListener(): void;
  44680. /**
  44681. * Sets a new custom attenuation function for the sound.
  44682. * @param callback Defines the function used for the attenuation
  44683. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44684. */
  44685. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  44686. /**
  44687. * Play the sound
  44688. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  44689. * @param offset (optional) Start the sound at a specific time in seconds
  44690. * @param length (optional) Sound duration (in seconds)
  44691. */
  44692. play(time?: number, offset?: number, length?: number): void;
  44693. private _onended;
  44694. /**
  44695. * Stop the sound
  44696. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  44697. */
  44698. stop(time?: number): void;
  44699. /**
  44700. * Put the sound in pause
  44701. */
  44702. pause(): void;
  44703. /**
  44704. * Sets a dedicated volume for this sounds
  44705. * @param newVolume Define the new volume of the sound
  44706. * @param time Define time for gradual change to new volume
  44707. */
  44708. setVolume(newVolume: number, time?: number): void;
  44709. /**
  44710. * Set the sound play back rate
  44711. * @param newPlaybackRate Define the playback rate the sound should be played at
  44712. */
  44713. setPlaybackRate(newPlaybackRate: number): void;
  44714. /**
  44715. * Gets the volume of the sound.
  44716. * @returns the volume of the sound
  44717. */
  44718. getVolume(): number;
  44719. /**
  44720. * Attach the sound to a dedicated mesh
  44721. * @param transformNode The transform node to connect the sound with
  44722. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44723. */
  44724. attachToMesh(transformNode: TransformNode): void;
  44725. /**
  44726. * Detach the sound from the previously attached mesh
  44727. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44728. */
  44729. detachFromMesh(): void;
  44730. private _onRegisterAfterWorldMatrixUpdate;
  44731. /**
  44732. * Clone the current sound in the scene.
  44733. * @returns the new sound clone
  44734. */
  44735. clone(): Nullable<Sound>;
  44736. /**
  44737. * Gets the current underlying audio buffer containing the data
  44738. * @returns the audio buffer
  44739. */
  44740. getAudioBuffer(): Nullable<AudioBuffer>;
  44741. /**
  44742. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  44743. * @returns the source node
  44744. */
  44745. getSoundSource(): Nullable<AudioBufferSourceNode>;
  44746. /**
  44747. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  44748. * @returns the gain node
  44749. */
  44750. getSoundGain(): Nullable<GainNode>;
  44751. /**
  44752. * Serializes the Sound in a JSON representation
  44753. * @returns the JSON representation of the sound
  44754. */
  44755. serialize(): any;
  44756. /**
  44757. * Parse a JSON representation of a sound to innstantiate in a given scene
  44758. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  44759. * @param scene Define the scene the new parsed sound should be created in
  44760. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  44761. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  44762. * @returns the newly parsed sound
  44763. */
  44764. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  44765. }
  44766. }
  44767. declare module BABYLON {
  44768. /**
  44769. * This defines an action helpful to play a defined sound on a triggered action.
  44770. */
  44771. export class PlaySoundAction extends Action {
  44772. private _sound;
  44773. /**
  44774. * Instantiate the action
  44775. * @param triggerOptions defines the trigger options
  44776. * @param sound defines the sound to play
  44777. * @param condition defines the trigger related conditions
  44778. */
  44779. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44780. /** @hidden */
  44781. _prepare(): void;
  44782. /**
  44783. * Execute the action and play the sound.
  44784. */
  44785. execute(): void;
  44786. /**
  44787. * Serializes the actions and its related information.
  44788. * @param parent defines the object to serialize in
  44789. * @returns the serialized object
  44790. */
  44791. serialize(parent: any): any;
  44792. }
  44793. /**
  44794. * This defines an action helpful to stop a defined sound on a triggered action.
  44795. */
  44796. export class StopSoundAction extends Action {
  44797. private _sound;
  44798. /**
  44799. * Instantiate the action
  44800. * @param triggerOptions defines the trigger options
  44801. * @param sound defines the sound to stop
  44802. * @param condition defines the trigger related conditions
  44803. */
  44804. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44805. /** @hidden */
  44806. _prepare(): void;
  44807. /**
  44808. * Execute the action and stop the sound.
  44809. */
  44810. execute(): void;
  44811. /**
  44812. * Serializes the actions and its related information.
  44813. * @param parent defines the object to serialize in
  44814. * @returns the serialized object
  44815. */
  44816. serialize(parent: any): any;
  44817. }
  44818. }
  44819. declare module BABYLON {
  44820. /**
  44821. * This defines an action responsible to change the value of a property
  44822. * by interpolating between its current value and the newly set one once triggered.
  44823. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44824. */
  44825. export class InterpolateValueAction extends Action {
  44826. /**
  44827. * Defines the path of the property where the value should be interpolated
  44828. */
  44829. propertyPath: string;
  44830. /**
  44831. * Defines the target value at the end of the interpolation.
  44832. */
  44833. value: any;
  44834. /**
  44835. * Defines the time it will take for the property to interpolate to the value.
  44836. */
  44837. duration: number;
  44838. /**
  44839. * Defines if the other scene animations should be stopped when the action has been triggered
  44840. */
  44841. stopOtherAnimations?: boolean;
  44842. /**
  44843. * Defines a callback raised once the interpolation animation has been done.
  44844. */
  44845. onInterpolationDone?: () => void;
  44846. /**
  44847. * Observable triggered once the interpolation animation has been done.
  44848. */
  44849. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  44850. private _target;
  44851. private _effectiveTarget;
  44852. private _property;
  44853. /**
  44854. * Instantiate the action
  44855. * @param triggerOptions defines the trigger options
  44856. * @param target defines the object containing the value to interpolate
  44857. * @param propertyPath defines the path to the property in the target object
  44858. * @param value defines the target value at the end of the interpolation
  44859. * @param duration deines the time it will take for the property to interpolate to the value.
  44860. * @param condition defines the trigger related conditions
  44861. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  44862. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  44863. */
  44864. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  44865. /** @hidden */
  44866. _prepare(): void;
  44867. /**
  44868. * Execute the action starts the value interpolation.
  44869. */
  44870. execute(): void;
  44871. /**
  44872. * Serializes the actions and its related information.
  44873. * @param parent defines the object to serialize in
  44874. * @returns the serialized object
  44875. */
  44876. serialize(parent: any): any;
  44877. }
  44878. }
  44879. declare module BABYLON {
  44880. /**
  44881. * Options allowed during the creation of a sound track.
  44882. */
  44883. export interface ISoundTrackOptions {
  44884. /**
  44885. * The volume the sound track should take during creation
  44886. */
  44887. volume?: number;
  44888. /**
  44889. * Define if the sound track is the main sound track of the scene
  44890. */
  44891. mainTrack?: boolean;
  44892. }
  44893. /**
  44894. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  44895. * It will be also used in a future release to apply effects on a specific track.
  44896. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  44897. */
  44898. export class SoundTrack {
  44899. /**
  44900. * The unique identifier of the sound track in the scene.
  44901. */
  44902. id: number;
  44903. /**
  44904. * The list of sounds included in the sound track.
  44905. */
  44906. soundCollection: Array<Sound>;
  44907. private _outputAudioNode;
  44908. private _scene;
  44909. private _connectedAnalyser;
  44910. private _options;
  44911. private _isInitialized;
  44912. /**
  44913. * Creates a new sound track.
  44914. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  44915. * @param scene Define the scene the sound track belongs to
  44916. * @param options
  44917. */
  44918. constructor(scene: Scene, options?: ISoundTrackOptions);
  44919. private _initializeSoundTrackAudioGraph;
  44920. /**
  44921. * Release the sound track and its associated resources
  44922. */
  44923. dispose(): void;
  44924. /**
  44925. * Adds a sound to this sound track
  44926. * @param sound define the cound to add
  44927. * @ignoreNaming
  44928. */
  44929. AddSound(sound: Sound): void;
  44930. /**
  44931. * Removes a sound to this sound track
  44932. * @param sound define the cound to remove
  44933. * @ignoreNaming
  44934. */
  44935. RemoveSound(sound: Sound): void;
  44936. /**
  44937. * Set a global volume for the full sound track.
  44938. * @param newVolume Define the new volume of the sound track
  44939. */
  44940. setVolume(newVolume: number): void;
  44941. /**
  44942. * Switch the panning model to HRTF:
  44943. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44944. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44945. */
  44946. switchPanningModelToHRTF(): void;
  44947. /**
  44948. * Switch the panning model to Equal Power:
  44949. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44950. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44951. */
  44952. switchPanningModelToEqualPower(): void;
  44953. /**
  44954. * Connect the sound track to an audio analyser allowing some amazing
  44955. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  44956. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  44957. * @param analyser The analyser to connect to the engine
  44958. */
  44959. connectToAnalyser(analyser: Analyser): void;
  44960. }
  44961. }
  44962. declare module BABYLON {
  44963. interface AbstractScene {
  44964. /**
  44965. * The list of sounds used in the scene.
  44966. */
  44967. sounds: Nullable<Array<Sound>>;
  44968. }
  44969. interface Scene {
  44970. /**
  44971. * @hidden
  44972. * Backing field
  44973. */
  44974. _mainSoundTrack: SoundTrack;
  44975. /**
  44976. * The main sound track played by the scene.
  44977. * It cotains your primary collection of sounds.
  44978. */
  44979. mainSoundTrack: SoundTrack;
  44980. /**
  44981. * The list of sound tracks added to the scene
  44982. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44983. */
  44984. soundTracks: Nullable<Array<SoundTrack>>;
  44985. /**
  44986. * Gets a sound using a given name
  44987. * @param name defines the name to search for
  44988. * @return the found sound or null if not found at all.
  44989. */
  44990. getSoundByName(name: string): Nullable<Sound>;
  44991. /**
  44992. * Gets or sets if audio support is enabled
  44993. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44994. */
  44995. audioEnabled: boolean;
  44996. /**
  44997. * Gets or sets if audio will be output to headphones
  44998. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44999. */
  45000. headphone: boolean;
  45001. /**
  45002. * Gets or sets custom audio listener position provider
  45003. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45004. */
  45005. audioListenerPositionProvider: Nullable<() => Vector3>;
  45006. /**
  45007. * Gets or sets a refresh rate when using 3D audio positioning
  45008. */
  45009. audioPositioningRefreshRate: number;
  45010. }
  45011. /**
  45012. * Defines the sound scene component responsible to manage any sounds
  45013. * in a given scene.
  45014. */
  45015. export class AudioSceneComponent implements ISceneSerializableComponent {
  45016. private static _CameraDirectionLH;
  45017. private static _CameraDirectionRH;
  45018. /**
  45019. * The component name helpfull to identify the component in the list of scene components.
  45020. */
  45021. readonly name: string;
  45022. /**
  45023. * The scene the component belongs to.
  45024. */
  45025. scene: Scene;
  45026. private _audioEnabled;
  45027. /**
  45028. * Gets whether audio is enabled or not.
  45029. * Please use related enable/disable method to switch state.
  45030. */
  45031. get audioEnabled(): boolean;
  45032. private _headphone;
  45033. /**
  45034. * Gets whether audio is outputing to headphone or not.
  45035. * Please use the according Switch methods to change output.
  45036. */
  45037. get headphone(): boolean;
  45038. /**
  45039. * Gets or sets a refresh rate when using 3D audio positioning
  45040. */
  45041. audioPositioningRefreshRate: number;
  45042. private _audioListenerPositionProvider;
  45043. /**
  45044. * Gets the current audio listener position provider
  45045. */
  45046. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45047. /**
  45048. * Sets a custom listener position for all sounds in the scene
  45049. * By default, this is the position of the first active camera
  45050. */
  45051. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45052. /**
  45053. * Creates a new instance of the component for the given scene
  45054. * @param scene Defines the scene to register the component in
  45055. */
  45056. constructor(scene: Scene);
  45057. /**
  45058. * Registers the component in a given scene
  45059. */
  45060. register(): void;
  45061. /**
  45062. * Rebuilds the elements related to this component in case of
  45063. * context lost for instance.
  45064. */
  45065. rebuild(): void;
  45066. /**
  45067. * Serializes the component data to the specified json object
  45068. * @param serializationObject The object to serialize to
  45069. */
  45070. serialize(serializationObject: any): void;
  45071. /**
  45072. * Adds all the elements from the container to the scene
  45073. * @param container the container holding the elements
  45074. */
  45075. addFromContainer(container: AbstractScene): void;
  45076. /**
  45077. * Removes all the elements in the container from the scene
  45078. * @param container contains the elements to remove
  45079. * @param dispose if the removed element should be disposed (default: false)
  45080. */
  45081. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45082. /**
  45083. * Disposes the component and the associated ressources.
  45084. */
  45085. dispose(): void;
  45086. /**
  45087. * Disables audio in the associated scene.
  45088. */
  45089. disableAudio(): void;
  45090. /**
  45091. * Enables audio in the associated scene.
  45092. */
  45093. enableAudio(): void;
  45094. /**
  45095. * Switch audio to headphone output.
  45096. */
  45097. switchAudioModeForHeadphones(): void;
  45098. /**
  45099. * Switch audio to normal speakers.
  45100. */
  45101. switchAudioModeForNormalSpeakers(): void;
  45102. private _cachedCameraDirection;
  45103. private _cachedCameraPosition;
  45104. private _lastCheck;
  45105. private _afterRender;
  45106. }
  45107. }
  45108. declare module BABYLON {
  45109. /**
  45110. * Wraps one or more Sound objects and selects one with random weight for playback.
  45111. */
  45112. export class WeightedSound {
  45113. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45114. loop: boolean;
  45115. private _coneInnerAngle;
  45116. private _coneOuterAngle;
  45117. private _volume;
  45118. /** A Sound is currently playing. */
  45119. isPlaying: boolean;
  45120. /** A Sound is currently paused. */
  45121. isPaused: boolean;
  45122. private _sounds;
  45123. private _weights;
  45124. private _currentIndex?;
  45125. /**
  45126. * Creates a new WeightedSound from the list of sounds given.
  45127. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45128. * @param sounds Array of Sounds that will be selected from.
  45129. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45130. */
  45131. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45132. /**
  45133. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45134. */
  45135. get directionalConeInnerAngle(): number;
  45136. /**
  45137. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45138. */
  45139. set directionalConeInnerAngle(value: number);
  45140. /**
  45141. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45142. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45143. */
  45144. get directionalConeOuterAngle(): number;
  45145. /**
  45146. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45147. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45148. */
  45149. set directionalConeOuterAngle(value: number);
  45150. /**
  45151. * Playback volume.
  45152. */
  45153. get volume(): number;
  45154. /**
  45155. * Playback volume.
  45156. */
  45157. set volume(value: number);
  45158. private _onended;
  45159. /**
  45160. * Suspend playback
  45161. */
  45162. pause(): void;
  45163. /**
  45164. * Stop playback
  45165. */
  45166. stop(): void;
  45167. /**
  45168. * Start playback.
  45169. * @param startOffset Position the clip head at a specific time in seconds.
  45170. */
  45171. play(startOffset?: number): void;
  45172. }
  45173. }
  45174. declare module BABYLON {
  45175. /**
  45176. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45177. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45178. */
  45179. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45180. /**
  45181. * Gets the name of the behavior.
  45182. */
  45183. get name(): string;
  45184. /**
  45185. * The easing function used by animations
  45186. */
  45187. static EasingFunction: BackEase;
  45188. /**
  45189. * The easing mode used by animations
  45190. */
  45191. static EasingMode: number;
  45192. /**
  45193. * The duration of the animation, in milliseconds
  45194. */
  45195. transitionDuration: number;
  45196. /**
  45197. * Length of the distance animated by the transition when lower radius is reached
  45198. */
  45199. lowerRadiusTransitionRange: number;
  45200. /**
  45201. * Length of the distance animated by the transition when upper radius is reached
  45202. */
  45203. upperRadiusTransitionRange: number;
  45204. private _autoTransitionRange;
  45205. /**
  45206. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45207. */
  45208. get autoTransitionRange(): boolean;
  45209. /**
  45210. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45211. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45212. */
  45213. set autoTransitionRange(value: boolean);
  45214. private _attachedCamera;
  45215. private _onAfterCheckInputsObserver;
  45216. private _onMeshTargetChangedObserver;
  45217. /**
  45218. * Initializes the behavior.
  45219. */
  45220. init(): void;
  45221. /**
  45222. * Attaches the behavior to its arc rotate camera.
  45223. * @param camera Defines the camera to attach the behavior to
  45224. */
  45225. attach(camera: ArcRotateCamera): void;
  45226. /**
  45227. * Detaches the behavior from its current arc rotate camera.
  45228. */
  45229. detach(): void;
  45230. private _radiusIsAnimating;
  45231. private _radiusBounceTransition;
  45232. private _animatables;
  45233. private _cachedWheelPrecision;
  45234. /**
  45235. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45236. * @param radiusLimit The limit to check against.
  45237. * @return Bool to indicate if at limit.
  45238. */
  45239. private _isRadiusAtLimit;
  45240. /**
  45241. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45242. * @param radiusDelta The delta by which to animate to. Can be negative.
  45243. */
  45244. private _applyBoundRadiusAnimation;
  45245. /**
  45246. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45247. */
  45248. protected _clearAnimationLocks(): void;
  45249. /**
  45250. * Stops and removes all animations that have been applied to the camera
  45251. */
  45252. stopAllAnimations(): void;
  45253. }
  45254. }
  45255. declare module BABYLON {
  45256. /**
  45257. * 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.
  45258. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45259. */
  45260. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45261. /**
  45262. * Gets the name of the behavior.
  45263. */
  45264. get name(): string;
  45265. private _mode;
  45266. private _radiusScale;
  45267. private _positionScale;
  45268. private _defaultElevation;
  45269. private _elevationReturnTime;
  45270. private _elevationReturnWaitTime;
  45271. private _zoomStopsAnimation;
  45272. private _framingTime;
  45273. /**
  45274. * The easing function used by animations
  45275. */
  45276. static EasingFunction: ExponentialEase;
  45277. /**
  45278. * The easing mode used by animations
  45279. */
  45280. static EasingMode: number;
  45281. /**
  45282. * Sets the current mode used by the behavior
  45283. */
  45284. set mode(mode: number);
  45285. /**
  45286. * Gets current mode used by the behavior.
  45287. */
  45288. get mode(): number;
  45289. /**
  45290. * Sets the scale applied to the radius (1 by default)
  45291. */
  45292. set radiusScale(radius: number);
  45293. /**
  45294. * Gets the scale applied to the radius
  45295. */
  45296. get radiusScale(): number;
  45297. /**
  45298. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45299. */
  45300. set positionScale(scale: number);
  45301. /**
  45302. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45303. */
  45304. get positionScale(): number;
  45305. /**
  45306. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45307. * behaviour is triggered, in radians.
  45308. */
  45309. set defaultElevation(elevation: number);
  45310. /**
  45311. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45312. * behaviour is triggered, in radians.
  45313. */
  45314. get defaultElevation(): number;
  45315. /**
  45316. * Sets the time (in milliseconds) taken to return to the default beta position.
  45317. * Negative value indicates camera should not return to default.
  45318. */
  45319. set elevationReturnTime(speed: number);
  45320. /**
  45321. * Gets the time (in milliseconds) taken to return to the default beta position.
  45322. * Negative value indicates camera should not return to default.
  45323. */
  45324. get elevationReturnTime(): number;
  45325. /**
  45326. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45327. */
  45328. set elevationReturnWaitTime(time: number);
  45329. /**
  45330. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45331. */
  45332. get elevationReturnWaitTime(): number;
  45333. /**
  45334. * Sets the flag that indicates if user zooming should stop animation.
  45335. */
  45336. set zoomStopsAnimation(flag: boolean);
  45337. /**
  45338. * Gets the flag that indicates if user zooming should stop animation.
  45339. */
  45340. get zoomStopsAnimation(): boolean;
  45341. /**
  45342. * Sets the transition time when framing the mesh, in milliseconds
  45343. */
  45344. set framingTime(time: number);
  45345. /**
  45346. * Gets the transition time when framing the mesh, in milliseconds
  45347. */
  45348. get framingTime(): number;
  45349. /**
  45350. * Define if the behavior should automatically change the configured
  45351. * camera limits and sensibilities.
  45352. */
  45353. autoCorrectCameraLimitsAndSensibility: boolean;
  45354. private _onPrePointerObservableObserver;
  45355. private _onAfterCheckInputsObserver;
  45356. private _onMeshTargetChangedObserver;
  45357. private _attachedCamera;
  45358. private _isPointerDown;
  45359. private _lastInteractionTime;
  45360. /**
  45361. * Initializes the behavior.
  45362. */
  45363. init(): void;
  45364. /**
  45365. * Attaches the behavior to its arc rotate camera.
  45366. * @param camera Defines the camera to attach the behavior to
  45367. */
  45368. attach(camera: ArcRotateCamera): void;
  45369. /**
  45370. * Detaches the behavior from its current arc rotate camera.
  45371. */
  45372. detach(): void;
  45373. private _animatables;
  45374. private _betaIsAnimating;
  45375. private _betaTransition;
  45376. private _radiusTransition;
  45377. private _vectorTransition;
  45378. /**
  45379. * Targets the given mesh and updates zoom level accordingly.
  45380. * @param mesh The mesh to target.
  45381. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45382. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45383. */
  45384. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45385. /**
  45386. * Targets the given mesh with its children and updates zoom level accordingly.
  45387. * @param mesh The mesh to target.
  45388. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45389. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45390. */
  45391. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45392. /**
  45393. * Targets the given meshes with their children and updates zoom level accordingly.
  45394. * @param meshes The mesh to target.
  45395. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45396. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45397. */
  45398. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45399. /**
  45400. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45401. * @param minimumWorld Determines the smaller position of the bounding box extend
  45402. * @param maximumWorld Determines the bigger position of the bounding box extend
  45403. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45404. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45405. */
  45406. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45407. /**
  45408. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45409. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45410. * frustum width.
  45411. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45412. * to fully enclose the mesh in the viewing frustum.
  45413. */
  45414. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45415. /**
  45416. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45417. * is automatically returned to its default position (expected to be above ground plane).
  45418. */
  45419. private _maintainCameraAboveGround;
  45420. /**
  45421. * Returns the frustum slope based on the canvas ratio and camera FOV
  45422. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45423. */
  45424. private _getFrustumSlope;
  45425. /**
  45426. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45427. */
  45428. private _clearAnimationLocks;
  45429. /**
  45430. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45431. */
  45432. private _applyUserInteraction;
  45433. /**
  45434. * Stops and removes all animations that have been applied to the camera
  45435. */
  45436. stopAllAnimations(): void;
  45437. /**
  45438. * Gets a value indicating if the user is moving the camera
  45439. */
  45440. get isUserIsMoving(): boolean;
  45441. /**
  45442. * The camera can move all the way towards the mesh.
  45443. */
  45444. static IgnoreBoundsSizeMode: number;
  45445. /**
  45446. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45447. */
  45448. static FitFrustumSidesMode: number;
  45449. }
  45450. }
  45451. declare module BABYLON {
  45452. /**
  45453. * Base class for Camera Pointer Inputs.
  45454. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45455. * for example usage.
  45456. */
  45457. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45458. /**
  45459. * Defines the camera the input is attached to.
  45460. */
  45461. abstract camera: Camera;
  45462. /**
  45463. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45464. */
  45465. protected _altKey: boolean;
  45466. protected _ctrlKey: boolean;
  45467. protected _metaKey: boolean;
  45468. protected _shiftKey: boolean;
  45469. /**
  45470. * Which mouse buttons were pressed at time of last mouse event.
  45471. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45472. */
  45473. protected _buttonsPressed: number;
  45474. /**
  45475. * Defines the buttons associated with the input to handle camera move.
  45476. */
  45477. buttons: number[];
  45478. /**
  45479. * Attach the input controls to a specific dom element to get the input from.
  45480. * @param element Defines the element the controls should be listened from
  45481. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45482. */
  45483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45484. /**
  45485. * Detach the current controls from the specified dom element.
  45486. * @param element Defines the element to stop listening the inputs from
  45487. */
  45488. detachControl(element: Nullable<HTMLElement>): void;
  45489. /**
  45490. * Gets the class name of the current input.
  45491. * @returns the class name
  45492. */
  45493. getClassName(): string;
  45494. /**
  45495. * Get the friendly name associated with the input class.
  45496. * @returns the input friendly name
  45497. */
  45498. getSimpleName(): string;
  45499. /**
  45500. * Called on pointer POINTERDOUBLETAP event.
  45501. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45502. */
  45503. protected onDoubleTap(type: string): void;
  45504. /**
  45505. * Called on pointer POINTERMOVE event if only a single touch is active.
  45506. * Override this method to provide functionality.
  45507. */
  45508. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45509. /**
  45510. * Called on pointer POINTERMOVE event if multiple touches are active.
  45511. * Override this method to provide functionality.
  45512. */
  45513. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45514. /**
  45515. * Called on JS contextmenu event.
  45516. * Override this method to provide functionality.
  45517. */
  45518. protected onContextMenu(evt: PointerEvent): void;
  45519. /**
  45520. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45521. * press.
  45522. * Override this method to provide functionality.
  45523. */
  45524. protected onButtonDown(evt: PointerEvent): void;
  45525. /**
  45526. * Called each time a new POINTERUP event occurs. Ie, for each button
  45527. * release.
  45528. * Override this method to provide functionality.
  45529. */
  45530. protected onButtonUp(evt: PointerEvent): void;
  45531. /**
  45532. * Called when window becomes inactive.
  45533. * Override this method to provide functionality.
  45534. */
  45535. protected onLostFocus(): void;
  45536. private _pointerInput;
  45537. private _observer;
  45538. private _onLostFocus;
  45539. private pointA;
  45540. private pointB;
  45541. }
  45542. }
  45543. declare module BABYLON {
  45544. /**
  45545. * Manage the pointers inputs to control an arc rotate camera.
  45546. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45547. */
  45548. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45549. /**
  45550. * Defines the camera the input is attached to.
  45551. */
  45552. camera: ArcRotateCamera;
  45553. /**
  45554. * Gets the class name of the current input.
  45555. * @returns the class name
  45556. */
  45557. getClassName(): string;
  45558. /**
  45559. * Defines the buttons associated with the input to handle camera move.
  45560. */
  45561. buttons: number[];
  45562. /**
  45563. * Defines the pointer angular sensibility along the X axis or how fast is
  45564. * the camera rotating.
  45565. */
  45566. angularSensibilityX: number;
  45567. /**
  45568. * Defines the pointer angular sensibility along the Y axis or how fast is
  45569. * the camera rotating.
  45570. */
  45571. angularSensibilityY: number;
  45572. /**
  45573. * Defines the pointer pinch precision or how fast is the camera zooming.
  45574. */
  45575. pinchPrecision: number;
  45576. /**
  45577. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45578. * from 0.
  45579. * It defines the percentage of current camera.radius to use as delta when
  45580. * pinch zoom is used.
  45581. */
  45582. pinchDeltaPercentage: number;
  45583. /**
  45584. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  45585. * that any object in the plane at the camera's target point will scale
  45586. * perfectly with finger motion.
  45587. * Overrides pinchDeltaPercentage and pinchPrecision.
  45588. */
  45589. useNaturalPinchZoom: boolean;
  45590. /**
  45591. * Defines the pointer panning sensibility or how fast is the camera moving.
  45592. */
  45593. panningSensibility: number;
  45594. /**
  45595. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  45596. */
  45597. multiTouchPanning: boolean;
  45598. /**
  45599. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  45600. * zoom (pinch) through multitouch.
  45601. */
  45602. multiTouchPanAndZoom: boolean;
  45603. /**
  45604. * Revers pinch action direction.
  45605. */
  45606. pinchInwards: boolean;
  45607. private _isPanClick;
  45608. private _twoFingerActivityCount;
  45609. private _isPinching;
  45610. /**
  45611. * Called on pointer POINTERMOVE event if only a single touch is active.
  45612. */
  45613. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45614. /**
  45615. * Called on pointer POINTERDOUBLETAP event.
  45616. */
  45617. protected onDoubleTap(type: string): void;
  45618. /**
  45619. * Called on pointer POINTERMOVE event if multiple touches are active.
  45620. */
  45621. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45622. /**
  45623. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45624. * press.
  45625. */
  45626. protected onButtonDown(evt: PointerEvent): void;
  45627. /**
  45628. * Called each time a new POINTERUP event occurs. Ie, for each button
  45629. * release.
  45630. */
  45631. protected onButtonUp(evt: PointerEvent): void;
  45632. /**
  45633. * Called when window becomes inactive.
  45634. */
  45635. protected onLostFocus(): void;
  45636. }
  45637. }
  45638. declare module BABYLON {
  45639. /**
  45640. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  45641. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45642. */
  45643. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  45644. /**
  45645. * Defines the camera the input is attached to.
  45646. */
  45647. camera: ArcRotateCamera;
  45648. /**
  45649. * Defines the list of key codes associated with the up action (increase alpha)
  45650. */
  45651. keysUp: number[];
  45652. /**
  45653. * Defines the list of key codes associated with the down action (decrease alpha)
  45654. */
  45655. keysDown: number[];
  45656. /**
  45657. * Defines the list of key codes associated with the left action (increase beta)
  45658. */
  45659. keysLeft: number[];
  45660. /**
  45661. * Defines the list of key codes associated with the right action (decrease beta)
  45662. */
  45663. keysRight: number[];
  45664. /**
  45665. * Defines the list of key codes associated with the reset action.
  45666. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  45667. */
  45668. keysReset: number[];
  45669. /**
  45670. * Defines the panning sensibility of the inputs.
  45671. * (How fast is the camera panning)
  45672. */
  45673. panningSensibility: number;
  45674. /**
  45675. * Defines the zooming sensibility of the inputs.
  45676. * (How fast is the camera zooming)
  45677. */
  45678. zoomingSensibility: number;
  45679. /**
  45680. * Defines whether maintaining the alt key down switch the movement mode from
  45681. * orientation to zoom.
  45682. */
  45683. useAltToZoom: boolean;
  45684. /**
  45685. * Rotation speed of the camera
  45686. */
  45687. angularSpeed: number;
  45688. private _keys;
  45689. private _ctrlPressed;
  45690. private _altPressed;
  45691. private _onCanvasBlurObserver;
  45692. private _onKeyboardObserver;
  45693. private _engine;
  45694. private _scene;
  45695. /**
  45696. * Attach the input controls to a specific dom element to get the input from.
  45697. * @param element Defines the element the controls should be listened from
  45698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45699. */
  45700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45701. /**
  45702. * Detach the current controls from the specified dom element.
  45703. * @param element Defines the element to stop listening the inputs from
  45704. */
  45705. detachControl(element: Nullable<HTMLElement>): void;
  45706. /**
  45707. * Update the current camera state depending on the inputs that have been used this frame.
  45708. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45709. */
  45710. checkInputs(): void;
  45711. /**
  45712. * Gets the class name of the current intput.
  45713. * @returns the class name
  45714. */
  45715. getClassName(): string;
  45716. /**
  45717. * Get the friendly name associated with the input class.
  45718. * @returns the input friendly name
  45719. */
  45720. getSimpleName(): string;
  45721. }
  45722. }
  45723. declare module BABYLON {
  45724. /**
  45725. * Manage the mouse wheel inputs to control an arc rotate camera.
  45726. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45727. */
  45728. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  45729. /**
  45730. * Defines the camera the input is attached to.
  45731. */
  45732. camera: ArcRotateCamera;
  45733. /**
  45734. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  45735. */
  45736. wheelPrecision: number;
  45737. /**
  45738. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45739. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45740. */
  45741. wheelDeltaPercentage: number;
  45742. private _wheel;
  45743. private _observer;
  45744. private computeDeltaFromMouseWheelLegacyEvent;
  45745. /**
  45746. * Attach the input controls to a specific dom element to get the input from.
  45747. * @param element Defines the element the controls should be listened from
  45748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45749. */
  45750. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45751. /**
  45752. * Detach the current controls from the specified dom element.
  45753. * @param element Defines the element to stop listening the inputs from
  45754. */
  45755. detachControl(element: Nullable<HTMLElement>): void;
  45756. /**
  45757. * Gets the class name of the current intput.
  45758. * @returns the class name
  45759. */
  45760. getClassName(): string;
  45761. /**
  45762. * Get the friendly name associated with the input class.
  45763. * @returns the input friendly name
  45764. */
  45765. getSimpleName(): string;
  45766. }
  45767. }
  45768. declare module BABYLON {
  45769. /**
  45770. * Default Inputs manager for the ArcRotateCamera.
  45771. * It groups all the default supported inputs for ease of use.
  45772. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45773. */
  45774. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  45775. /**
  45776. * Instantiates a new ArcRotateCameraInputsManager.
  45777. * @param camera Defines the camera the inputs belong to
  45778. */
  45779. constructor(camera: ArcRotateCamera);
  45780. /**
  45781. * Add mouse wheel input support to the input manager.
  45782. * @returns the current input manager
  45783. */
  45784. addMouseWheel(): ArcRotateCameraInputsManager;
  45785. /**
  45786. * Add pointers input support to the input manager.
  45787. * @returns the current input manager
  45788. */
  45789. addPointers(): ArcRotateCameraInputsManager;
  45790. /**
  45791. * Add keyboard input support to the input manager.
  45792. * @returns the current input manager
  45793. */
  45794. addKeyboard(): ArcRotateCameraInputsManager;
  45795. }
  45796. }
  45797. declare module BABYLON {
  45798. /**
  45799. * This represents an orbital type of camera.
  45800. *
  45801. * 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.
  45802. * 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.
  45803. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  45804. */
  45805. export class ArcRotateCamera extends TargetCamera {
  45806. /**
  45807. * Defines the rotation angle of the camera along the longitudinal axis.
  45808. */
  45809. alpha: number;
  45810. /**
  45811. * Defines the rotation angle of the camera along the latitudinal axis.
  45812. */
  45813. beta: number;
  45814. /**
  45815. * Defines the radius of the camera from it s target point.
  45816. */
  45817. radius: number;
  45818. protected _target: Vector3;
  45819. protected _targetHost: Nullable<AbstractMesh>;
  45820. /**
  45821. * Defines the target point of the camera.
  45822. * The camera looks towards it form the radius distance.
  45823. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  45824. */
  45825. get target(): Vector3;
  45826. set target(value: Vector3);
  45827. /**
  45828. * Define the current local position of the camera in the scene
  45829. */
  45830. get position(): Vector3;
  45831. set position(newPosition: Vector3);
  45832. protected _upToYMatrix: Matrix;
  45833. protected _YToUpMatrix: Matrix;
  45834. /**
  45835. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  45836. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  45837. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  45838. */
  45839. set upVector(vec: Vector3);
  45840. get upVector(): Vector3;
  45841. /**
  45842. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  45843. */
  45844. setMatUp(): void;
  45845. /**
  45846. * Current inertia value on the longitudinal axis.
  45847. * The bigger this number the longer it will take for the camera to stop.
  45848. */
  45849. inertialAlphaOffset: number;
  45850. /**
  45851. * Current inertia value on the latitudinal axis.
  45852. * The bigger this number the longer it will take for the camera to stop.
  45853. */
  45854. inertialBetaOffset: number;
  45855. /**
  45856. * Current inertia value on the radius axis.
  45857. * The bigger this number the longer it will take for the camera to stop.
  45858. */
  45859. inertialRadiusOffset: number;
  45860. /**
  45861. * Minimum allowed angle on the longitudinal axis.
  45862. * This can help limiting how the Camera is able to move in the scene.
  45863. */
  45864. lowerAlphaLimit: Nullable<number>;
  45865. /**
  45866. * Maximum allowed angle on the longitudinal axis.
  45867. * This can help limiting how the Camera is able to move in the scene.
  45868. */
  45869. upperAlphaLimit: Nullable<number>;
  45870. /**
  45871. * Minimum allowed angle on the latitudinal axis.
  45872. * This can help limiting how the Camera is able to move in the scene.
  45873. */
  45874. lowerBetaLimit: number;
  45875. /**
  45876. * Maximum allowed angle on the latitudinal axis.
  45877. * This can help limiting how the Camera is able to move in the scene.
  45878. */
  45879. upperBetaLimit: number;
  45880. /**
  45881. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  45882. * This can help limiting how the Camera is able to move in the scene.
  45883. */
  45884. lowerRadiusLimit: Nullable<number>;
  45885. /**
  45886. * Maximum allowed distance of the camera to the target (The camera can not get further).
  45887. * This can help limiting how the Camera is able to move in the scene.
  45888. */
  45889. upperRadiusLimit: Nullable<number>;
  45890. /**
  45891. * Defines the current inertia value used during panning of the camera along the X axis.
  45892. */
  45893. inertialPanningX: number;
  45894. /**
  45895. * Defines the current inertia value used during panning of the camera along the Y axis.
  45896. */
  45897. inertialPanningY: number;
  45898. /**
  45899. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  45900. * Basically if your fingers moves away from more than this distance you will be considered
  45901. * in pinch mode.
  45902. */
  45903. pinchToPanMaxDistance: number;
  45904. /**
  45905. * Defines the maximum distance the camera can pan.
  45906. * This could help keeping the cammera always in your scene.
  45907. */
  45908. panningDistanceLimit: Nullable<number>;
  45909. /**
  45910. * Defines the target of the camera before paning.
  45911. */
  45912. panningOriginTarget: Vector3;
  45913. /**
  45914. * Defines the value of the inertia used during panning.
  45915. * 0 would mean stop inertia and one would mean no decelleration at all.
  45916. */
  45917. panningInertia: number;
  45918. /**
  45919. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  45920. */
  45921. get angularSensibilityX(): number;
  45922. set angularSensibilityX(value: number);
  45923. /**
  45924. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  45925. */
  45926. get angularSensibilityY(): number;
  45927. set angularSensibilityY(value: number);
  45928. /**
  45929. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  45930. */
  45931. get pinchPrecision(): number;
  45932. set pinchPrecision(value: number);
  45933. /**
  45934. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  45935. * It will be used instead of pinchDeltaPrecision if different from 0.
  45936. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  45937. */
  45938. get pinchDeltaPercentage(): number;
  45939. set pinchDeltaPercentage(value: number);
  45940. /**
  45941. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  45942. * and pinch delta percentage.
  45943. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  45944. * that any object in the plane at the camera's target point will scale
  45945. * perfectly with finger motion.
  45946. */
  45947. get useNaturalPinchZoom(): boolean;
  45948. set useNaturalPinchZoom(value: boolean);
  45949. /**
  45950. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  45951. */
  45952. get panningSensibility(): number;
  45953. set panningSensibility(value: number);
  45954. /**
  45955. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  45956. */
  45957. get keysUp(): number[];
  45958. set keysUp(value: number[]);
  45959. /**
  45960. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  45961. */
  45962. get keysDown(): number[];
  45963. set keysDown(value: number[]);
  45964. /**
  45965. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  45966. */
  45967. get keysLeft(): number[];
  45968. set keysLeft(value: number[]);
  45969. /**
  45970. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  45971. */
  45972. get keysRight(): number[];
  45973. set keysRight(value: number[]);
  45974. /**
  45975. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  45976. */
  45977. get wheelPrecision(): number;
  45978. set wheelPrecision(value: number);
  45979. /**
  45980. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  45981. * It will be used instead of pinchDeltaPrecision if different from 0.
  45982. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  45983. */
  45984. get wheelDeltaPercentage(): number;
  45985. set wheelDeltaPercentage(value: number);
  45986. /**
  45987. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  45988. */
  45989. zoomOnFactor: number;
  45990. /**
  45991. * Defines a screen offset for the camera position.
  45992. */
  45993. targetScreenOffset: Vector2;
  45994. /**
  45995. * Allows the camera to be completely reversed.
  45996. * If false the camera can not arrive upside down.
  45997. */
  45998. allowUpsideDown: boolean;
  45999. /**
  46000. * Define if double tap/click is used to restore the previously saved state of the camera.
  46001. */
  46002. useInputToRestoreState: boolean;
  46003. /** @hidden */
  46004. _viewMatrix: Matrix;
  46005. /** @hidden */
  46006. _useCtrlForPanning: boolean;
  46007. /** @hidden */
  46008. _panningMouseButton: number;
  46009. /**
  46010. * Defines the input associated to the camera.
  46011. */
  46012. inputs: ArcRotateCameraInputsManager;
  46013. /** @hidden */
  46014. _reset: () => void;
  46015. /**
  46016. * Defines the allowed panning axis.
  46017. */
  46018. panningAxis: Vector3;
  46019. protected _localDirection: Vector3;
  46020. protected _transformedDirection: Vector3;
  46021. private _bouncingBehavior;
  46022. /**
  46023. * Gets the bouncing behavior of the camera if it has been enabled.
  46024. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46025. */
  46026. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46027. /**
  46028. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46029. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46030. */
  46031. get useBouncingBehavior(): boolean;
  46032. set useBouncingBehavior(value: boolean);
  46033. private _framingBehavior;
  46034. /**
  46035. * Gets the framing behavior of the camera if it has been enabled.
  46036. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46037. */
  46038. get framingBehavior(): Nullable<FramingBehavior>;
  46039. /**
  46040. * Defines if the framing behavior of the camera is enabled on the camera.
  46041. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46042. */
  46043. get useFramingBehavior(): boolean;
  46044. set useFramingBehavior(value: boolean);
  46045. private _autoRotationBehavior;
  46046. /**
  46047. * Gets the auto rotation behavior of the camera if it has been enabled.
  46048. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46049. */
  46050. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46051. /**
  46052. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46053. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46054. */
  46055. get useAutoRotationBehavior(): boolean;
  46056. set useAutoRotationBehavior(value: boolean);
  46057. /**
  46058. * Observable triggered when the mesh target has been changed on the camera.
  46059. */
  46060. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46061. /**
  46062. * Event raised when the camera is colliding with a mesh.
  46063. */
  46064. onCollide: (collidedMesh: AbstractMesh) => void;
  46065. /**
  46066. * Defines whether the camera should check collision with the objects oh the scene.
  46067. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46068. */
  46069. checkCollisions: boolean;
  46070. /**
  46071. * Defines the collision radius of the camera.
  46072. * This simulates a sphere around the camera.
  46073. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46074. */
  46075. collisionRadius: Vector3;
  46076. protected _collider: Collider;
  46077. protected _previousPosition: Vector3;
  46078. protected _collisionVelocity: Vector3;
  46079. protected _newPosition: Vector3;
  46080. protected _previousAlpha: number;
  46081. protected _previousBeta: number;
  46082. protected _previousRadius: number;
  46083. protected _collisionTriggered: boolean;
  46084. protected _targetBoundingCenter: Nullable<Vector3>;
  46085. private _computationVector;
  46086. /**
  46087. * Instantiates a new ArcRotateCamera in a given scene
  46088. * @param name Defines the name of the camera
  46089. * @param alpha Defines the camera rotation along the logitudinal axis
  46090. * @param beta Defines the camera rotation along the latitudinal axis
  46091. * @param radius Defines the camera distance from its target
  46092. * @param target Defines the camera target
  46093. * @param scene Defines the scene the camera belongs to
  46094. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46095. */
  46096. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46097. /** @hidden */
  46098. _initCache(): void;
  46099. /** @hidden */
  46100. _updateCache(ignoreParentClass?: boolean): void;
  46101. protected _getTargetPosition(): Vector3;
  46102. private _storedAlpha;
  46103. private _storedBeta;
  46104. private _storedRadius;
  46105. private _storedTarget;
  46106. private _storedTargetScreenOffset;
  46107. /**
  46108. * Stores the current state of the camera (alpha, beta, radius and target)
  46109. * @returns the camera itself
  46110. */
  46111. storeState(): Camera;
  46112. /**
  46113. * @hidden
  46114. * Restored camera state. You must call storeState() first
  46115. */
  46116. _restoreStateValues(): boolean;
  46117. /** @hidden */
  46118. _isSynchronizedViewMatrix(): boolean;
  46119. /**
  46120. * Attached controls to the current camera.
  46121. * @param element Defines the element the controls should be listened from
  46122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46123. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46124. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46125. */
  46126. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  46127. /**
  46128. * Detach the current controls from the camera.
  46129. * The camera will stop reacting to inputs.
  46130. * @param element Defines the element to stop listening the inputs from
  46131. */
  46132. detachControl(element: HTMLElement): void;
  46133. /** @hidden */
  46134. _checkInputs(): void;
  46135. protected _checkLimits(): void;
  46136. /**
  46137. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46138. */
  46139. rebuildAnglesAndRadius(): void;
  46140. /**
  46141. * Use a position to define the current camera related information like alpha, beta and radius
  46142. * @param position Defines the position to set the camera at
  46143. */
  46144. setPosition(position: Vector3): void;
  46145. /**
  46146. * Defines the target the camera should look at.
  46147. * This will automatically adapt alpha beta and radius to fit within the new target.
  46148. * @param target Defines the new target as a Vector or a mesh
  46149. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46150. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46151. */
  46152. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46153. /** @hidden */
  46154. _getViewMatrix(): Matrix;
  46155. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46156. /**
  46157. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46158. * @param meshes Defines the mesh to zoom on
  46159. * @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)
  46160. */
  46161. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46162. /**
  46163. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46164. * The target will be changed but the radius
  46165. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46166. * @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)
  46167. */
  46168. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46169. min: Vector3;
  46170. max: Vector3;
  46171. distance: number;
  46172. }, doNotUpdateMaxZ?: boolean): void;
  46173. /**
  46174. * @override
  46175. * Override Camera.createRigCamera
  46176. */
  46177. createRigCamera(name: string, cameraIndex: number): Camera;
  46178. /**
  46179. * @hidden
  46180. * @override
  46181. * Override Camera._updateRigCameras
  46182. */
  46183. _updateRigCameras(): void;
  46184. /**
  46185. * Destroy the camera and release the current resources hold by it.
  46186. */
  46187. dispose(): void;
  46188. /**
  46189. * Gets the current object class name.
  46190. * @return the class name
  46191. */
  46192. getClassName(): string;
  46193. }
  46194. }
  46195. declare module BABYLON {
  46196. /**
  46197. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46198. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46199. */
  46200. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46201. /**
  46202. * Gets the name of the behavior.
  46203. */
  46204. get name(): string;
  46205. private _zoomStopsAnimation;
  46206. private _idleRotationSpeed;
  46207. private _idleRotationWaitTime;
  46208. private _idleRotationSpinupTime;
  46209. /**
  46210. * Sets the flag that indicates if user zooming should stop animation.
  46211. */
  46212. set zoomStopsAnimation(flag: boolean);
  46213. /**
  46214. * Gets the flag that indicates if user zooming should stop animation.
  46215. */
  46216. get zoomStopsAnimation(): boolean;
  46217. /**
  46218. * Sets the default speed at which the camera rotates around the model.
  46219. */
  46220. set idleRotationSpeed(speed: number);
  46221. /**
  46222. * Gets the default speed at which the camera rotates around the model.
  46223. */
  46224. get idleRotationSpeed(): number;
  46225. /**
  46226. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46227. */
  46228. set idleRotationWaitTime(time: number);
  46229. /**
  46230. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46231. */
  46232. get idleRotationWaitTime(): number;
  46233. /**
  46234. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46235. */
  46236. set idleRotationSpinupTime(time: number);
  46237. /**
  46238. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46239. */
  46240. get idleRotationSpinupTime(): number;
  46241. /**
  46242. * Gets a value indicating if the camera is currently rotating because of this behavior
  46243. */
  46244. get rotationInProgress(): boolean;
  46245. private _onPrePointerObservableObserver;
  46246. private _onAfterCheckInputsObserver;
  46247. private _attachedCamera;
  46248. private _isPointerDown;
  46249. private _lastFrameTime;
  46250. private _lastInteractionTime;
  46251. private _cameraRotationSpeed;
  46252. /**
  46253. * Initializes the behavior.
  46254. */
  46255. init(): void;
  46256. /**
  46257. * Attaches the behavior to its arc rotate camera.
  46258. * @param camera Defines the camera to attach the behavior to
  46259. */
  46260. attach(camera: ArcRotateCamera): void;
  46261. /**
  46262. * Detaches the behavior from its current arc rotate camera.
  46263. */
  46264. detach(): void;
  46265. /**
  46266. * Returns true if user is scrolling.
  46267. * @return true if user is scrolling.
  46268. */
  46269. private _userIsZooming;
  46270. private _lastFrameRadius;
  46271. private _shouldAnimationStopForInteraction;
  46272. /**
  46273. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46274. */
  46275. private _applyUserInteraction;
  46276. private _userIsMoving;
  46277. }
  46278. }
  46279. declare module BABYLON {
  46280. /**
  46281. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46282. */
  46283. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46284. private ui;
  46285. /**
  46286. * The name of the behavior
  46287. */
  46288. name: string;
  46289. /**
  46290. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46291. */
  46292. distanceAwayFromFace: number;
  46293. /**
  46294. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46295. */
  46296. distanceAwayFromBottomOfFace: number;
  46297. private _faceVectors;
  46298. private _target;
  46299. private _scene;
  46300. private _onRenderObserver;
  46301. private _tmpMatrix;
  46302. private _tmpVector;
  46303. /**
  46304. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46305. * @param ui The transform node that should be attched to the mesh
  46306. */
  46307. constructor(ui: TransformNode);
  46308. /**
  46309. * Initializes the behavior
  46310. */
  46311. init(): void;
  46312. private _closestFace;
  46313. private _zeroVector;
  46314. private _lookAtTmpMatrix;
  46315. private _lookAtToRef;
  46316. /**
  46317. * Attaches the AttachToBoxBehavior to the passed in mesh
  46318. * @param target The mesh that the specified node will be attached to
  46319. */
  46320. attach(target: Mesh): void;
  46321. /**
  46322. * Detaches the behavior from the mesh
  46323. */
  46324. detach(): void;
  46325. }
  46326. }
  46327. declare module BABYLON {
  46328. /**
  46329. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46330. */
  46331. export class FadeInOutBehavior implements Behavior<Mesh> {
  46332. /**
  46333. * Time in milliseconds to delay before fading in (Default: 0)
  46334. */
  46335. delay: number;
  46336. /**
  46337. * Time in milliseconds for the mesh to fade in (Default: 300)
  46338. */
  46339. fadeInTime: number;
  46340. private _millisecondsPerFrame;
  46341. private _hovered;
  46342. private _hoverValue;
  46343. private _ownerNode;
  46344. /**
  46345. * Instatiates the FadeInOutBehavior
  46346. */
  46347. constructor();
  46348. /**
  46349. * The name of the behavior
  46350. */
  46351. get name(): string;
  46352. /**
  46353. * Initializes the behavior
  46354. */
  46355. init(): void;
  46356. /**
  46357. * Attaches the fade behavior on the passed in mesh
  46358. * @param ownerNode The mesh that will be faded in/out once attached
  46359. */
  46360. attach(ownerNode: Mesh): void;
  46361. /**
  46362. * Detaches the behavior from the mesh
  46363. */
  46364. detach(): void;
  46365. /**
  46366. * Triggers the mesh to begin fading in or out
  46367. * @param value if the object should fade in or out (true to fade in)
  46368. */
  46369. fadeIn(value: boolean): void;
  46370. private _update;
  46371. private _setAllVisibility;
  46372. }
  46373. }
  46374. declare module BABYLON {
  46375. /**
  46376. * Class containing a set of static utilities functions for managing Pivots
  46377. * @hidden
  46378. */
  46379. export class PivotTools {
  46380. private static _PivotCached;
  46381. private static _OldPivotPoint;
  46382. private static _PivotTranslation;
  46383. private static _PivotTmpVector;
  46384. private static _PivotPostMultiplyPivotMatrix;
  46385. /** @hidden */
  46386. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46387. /** @hidden */
  46388. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46389. }
  46390. }
  46391. declare module BABYLON {
  46392. /**
  46393. * Class containing static functions to help procedurally build meshes
  46394. */
  46395. export class PlaneBuilder {
  46396. /**
  46397. * Creates a plane mesh
  46398. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46399. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46400. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46402. * * 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
  46403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46404. * @param name defines the name of the mesh
  46405. * @param options defines the options used to create the mesh
  46406. * @param scene defines the hosting scene
  46407. * @returns the plane mesh
  46408. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46409. */
  46410. static CreatePlane(name: string, options: {
  46411. size?: number;
  46412. width?: number;
  46413. height?: number;
  46414. sideOrientation?: number;
  46415. frontUVs?: Vector4;
  46416. backUVs?: Vector4;
  46417. updatable?: boolean;
  46418. sourcePlane?: Plane;
  46419. }, scene?: Nullable<Scene>): Mesh;
  46420. }
  46421. }
  46422. declare module BABYLON {
  46423. /**
  46424. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46425. */
  46426. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46427. private static _AnyMouseID;
  46428. /**
  46429. * Abstract mesh the behavior is set on
  46430. */
  46431. attachedNode: AbstractMesh;
  46432. private _dragPlane;
  46433. private _scene;
  46434. private _pointerObserver;
  46435. private _beforeRenderObserver;
  46436. private static _planeScene;
  46437. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46438. /**
  46439. * 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)
  46440. */
  46441. maxDragAngle: number;
  46442. /**
  46443. * @hidden
  46444. */
  46445. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46446. /**
  46447. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46448. */
  46449. currentDraggingPointerID: number;
  46450. /**
  46451. * The last position where the pointer hit the drag plane in world space
  46452. */
  46453. lastDragPosition: Vector3;
  46454. /**
  46455. * If the behavior is currently in a dragging state
  46456. */
  46457. dragging: boolean;
  46458. /**
  46459. * 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)
  46460. */
  46461. dragDeltaRatio: number;
  46462. /**
  46463. * If the drag plane orientation should be updated during the dragging (Default: true)
  46464. */
  46465. updateDragPlane: boolean;
  46466. private _debugMode;
  46467. private _moving;
  46468. /**
  46469. * Fires each time the attached mesh is dragged with the pointer
  46470. * * delta between last drag position and current drag position in world space
  46471. * * dragDistance along the drag axis
  46472. * * dragPlaneNormal normal of the current drag plane used during the drag
  46473. * * dragPlanePoint in world space where the drag intersects the drag plane
  46474. */
  46475. onDragObservable: Observable<{
  46476. delta: Vector3;
  46477. dragPlanePoint: Vector3;
  46478. dragPlaneNormal: Vector3;
  46479. dragDistance: number;
  46480. pointerId: number;
  46481. }>;
  46482. /**
  46483. * Fires each time a drag begins (eg. mouse down on mesh)
  46484. */
  46485. onDragStartObservable: Observable<{
  46486. dragPlanePoint: Vector3;
  46487. pointerId: number;
  46488. }>;
  46489. /**
  46490. * Fires each time a drag ends (eg. mouse release after drag)
  46491. */
  46492. onDragEndObservable: Observable<{
  46493. dragPlanePoint: Vector3;
  46494. pointerId: number;
  46495. }>;
  46496. /**
  46497. * If the attached mesh should be moved when dragged
  46498. */
  46499. moveAttached: boolean;
  46500. /**
  46501. * If the drag behavior will react to drag events (Default: true)
  46502. */
  46503. enabled: boolean;
  46504. /**
  46505. * If pointer events should start and release the drag (Default: true)
  46506. */
  46507. startAndReleaseDragOnPointerEvents: boolean;
  46508. /**
  46509. * If camera controls should be detached during the drag
  46510. */
  46511. detachCameraControls: boolean;
  46512. /**
  46513. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46514. */
  46515. useObjectOrientationForDragging: boolean;
  46516. private _options;
  46517. /**
  46518. * Gets the options used by the behavior
  46519. */
  46520. get options(): {
  46521. dragAxis?: Vector3;
  46522. dragPlaneNormal?: Vector3;
  46523. };
  46524. /**
  46525. * Sets the options used by the behavior
  46526. */
  46527. set options(options: {
  46528. dragAxis?: Vector3;
  46529. dragPlaneNormal?: Vector3;
  46530. });
  46531. /**
  46532. * Creates a pointer drag behavior that can be attached to a mesh
  46533. * @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)
  46534. */
  46535. constructor(options?: {
  46536. dragAxis?: Vector3;
  46537. dragPlaneNormal?: Vector3;
  46538. });
  46539. /**
  46540. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46541. */
  46542. validateDrag: (targetPosition: Vector3) => boolean;
  46543. /**
  46544. * The name of the behavior
  46545. */
  46546. get name(): string;
  46547. /**
  46548. * Initializes the behavior
  46549. */
  46550. init(): void;
  46551. private _tmpVector;
  46552. private _alternatePickedPoint;
  46553. private _worldDragAxis;
  46554. private _targetPosition;
  46555. private _attachedElement;
  46556. /**
  46557. * Attaches the drag behavior the passed in mesh
  46558. * @param ownerNode The mesh that will be dragged around once attached
  46559. * @param predicate Predicate to use for pick filtering
  46560. */
  46561. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  46562. /**
  46563. * Force relase the drag action by code.
  46564. */
  46565. releaseDrag(): void;
  46566. private _startDragRay;
  46567. private _lastPointerRay;
  46568. /**
  46569. * Simulates the start of a pointer drag event on the behavior
  46570. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  46571. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  46572. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  46573. */
  46574. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46575. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46576. private _dragDelta;
  46577. protected _moveDrag(ray: Ray): void;
  46578. private _pickWithRayOnDragPlane;
  46579. private _pointA;
  46580. private _pointC;
  46581. private _localAxis;
  46582. private _lookAt;
  46583. private _updateDragPlanePosition;
  46584. /**
  46585. * Detaches the behavior from the mesh
  46586. */
  46587. detach(): void;
  46588. }
  46589. }
  46590. declare module BABYLON {
  46591. /**
  46592. * A behavior that when attached to a mesh will allow the mesh to be scaled
  46593. */
  46594. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  46595. private _dragBehaviorA;
  46596. private _dragBehaviorB;
  46597. private _startDistance;
  46598. private _initialScale;
  46599. private _targetScale;
  46600. private _ownerNode;
  46601. private _sceneRenderObserver;
  46602. /**
  46603. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  46604. */
  46605. constructor();
  46606. /**
  46607. * The name of the behavior
  46608. */
  46609. get name(): string;
  46610. /**
  46611. * Initializes the behavior
  46612. */
  46613. init(): void;
  46614. private _getCurrentDistance;
  46615. /**
  46616. * Attaches the scale behavior the passed in mesh
  46617. * @param ownerNode The mesh that will be scaled around once attached
  46618. */
  46619. attach(ownerNode: Mesh): void;
  46620. /**
  46621. * Detaches the behavior from the mesh
  46622. */
  46623. detach(): void;
  46624. }
  46625. }
  46626. declare module BABYLON {
  46627. /**
  46628. * 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
  46629. */
  46630. export class SixDofDragBehavior implements Behavior<Mesh> {
  46631. private static _virtualScene;
  46632. private _ownerNode;
  46633. private _sceneRenderObserver;
  46634. private _scene;
  46635. private _targetPosition;
  46636. private _virtualOriginMesh;
  46637. private _virtualDragMesh;
  46638. private _pointerObserver;
  46639. private _moving;
  46640. private _startingOrientation;
  46641. private _attachedElement;
  46642. /**
  46643. * 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)
  46644. */
  46645. private zDragFactor;
  46646. /**
  46647. * If the object should rotate to face the drag origin
  46648. */
  46649. rotateDraggedObject: boolean;
  46650. /**
  46651. * If the behavior is currently in a dragging state
  46652. */
  46653. dragging: boolean;
  46654. /**
  46655. * 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)
  46656. */
  46657. dragDeltaRatio: number;
  46658. /**
  46659. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46660. */
  46661. currentDraggingPointerID: number;
  46662. /**
  46663. * If camera controls should be detached during the drag
  46664. */
  46665. detachCameraControls: boolean;
  46666. /**
  46667. * Fires each time a drag starts
  46668. */
  46669. onDragStartObservable: Observable<{}>;
  46670. /**
  46671. * Fires each time a drag ends (eg. mouse release after drag)
  46672. */
  46673. onDragEndObservable: Observable<{}>;
  46674. /**
  46675. * 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
  46676. */
  46677. constructor();
  46678. /**
  46679. * The name of the behavior
  46680. */
  46681. get name(): string;
  46682. /**
  46683. * Initializes the behavior
  46684. */
  46685. init(): void;
  46686. /**
  46687. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  46688. */
  46689. private get _pointerCamera();
  46690. /**
  46691. * Attaches the scale behavior the passed in mesh
  46692. * @param ownerNode The mesh that will be scaled around once attached
  46693. */
  46694. attach(ownerNode: Mesh): void;
  46695. /**
  46696. * Detaches the behavior from the mesh
  46697. */
  46698. detach(): void;
  46699. }
  46700. }
  46701. declare module BABYLON {
  46702. /**
  46703. * Class used to apply inverse kinematics to bones
  46704. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  46705. */
  46706. export class BoneIKController {
  46707. private static _tmpVecs;
  46708. private static _tmpQuat;
  46709. private static _tmpMats;
  46710. /**
  46711. * Gets or sets the target mesh
  46712. */
  46713. targetMesh: AbstractMesh;
  46714. /** Gets or sets the mesh used as pole */
  46715. poleTargetMesh: AbstractMesh;
  46716. /**
  46717. * Gets or sets the bone used as pole
  46718. */
  46719. poleTargetBone: Nullable<Bone>;
  46720. /**
  46721. * Gets or sets the target position
  46722. */
  46723. targetPosition: Vector3;
  46724. /**
  46725. * Gets or sets the pole target position
  46726. */
  46727. poleTargetPosition: Vector3;
  46728. /**
  46729. * Gets or sets the pole target local offset
  46730. */
  46731. poleTargetLocalOffset: Vector3;
  46732. /**
  46733. * Gets or sets the pole angle
  46734. */
  46735. poleAngle: number;
  46736. /**
  46737. * Gets or sets the mesh associated with the controller
  46738. */
  46739. mesh: AbstractMesh;
  46740. /**
  46741. * 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)
  46742. */
  46743. slerpAmount: number;
  46744. private _bone1Quat;
  46745. private _bone1Mat;
  46746. private _bone2Ang;
  46747. private _bone1;
  46748. private _bone2;
  46749. private _bone1Length;
  46750. private _bone2Length;
  46751. private _maxAngle;
  46752. private _maxReach;
  46753. private _rightHandedSystem;
  46754. private _bendAxis;
  46755. private _slerping;
  46756. private _adjustRoll;
  46757. /**
  46758. * Gets or sets maximum allowed angle
  46759. */
  46760. get maxAngle(): number;
  46761. set maxAngle(value: number);
  46762. /**
  46763. * Creates a new BoneIKController
  46764. * @param mesh defines the mesh to control
  46765. * @param bone defines the bone to control
  46766. * @param options defines options to set up the controller
  46767. */
  46768. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  46769. targetMesh?: AbstractMesh;
  46770. poleTargetMesh?: AbstractMesh;
  46771. poleTargetBone?: Bone;
  46772. poleTargetLocalOffset?: Vector3;
  46773. poleAngle?: number;
  46774. bendAxis?: Vector3;
  46775. maxAngle?: number;
  46776. slerpAmount?: number;
  46777. });
  46778. private _setMaxAngle;
  46779. /**
  46780. * Force the controller to update the bones
  46781. */
  46782. update(): void;
  46783. }
  46784. }
  46785. declare module BABYLON {
  46786. /**
  46787. * Class used to make a bone look toward a point in space
  46788. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  46789. */
  46790. export class BoneLookController {
  46791. private static _tmpVecs;
  46792. private static _tmpQuat;
  46793. private static _tmpMats;
  46794. /**
  46795. * The target Vector3 that the bone will look at
  46796. */
  46797. target: Vector3;
  46798. /**
  46799. * The mesh that the bone is attached to
  46800. */
  46801. mesh: AbstractMesh;
  46802. /**
  46803. * The bone that will be looking to the target
  46804. */
  46805. bone: Bone;
  46806. /**
  46807. * The up axis of the coordinate system that is used when the bone is rotated
  46808. */
  46809. upAxis: Vector3;
  46810. /**
  46811. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  46812. */
  46813. upAxisSpace: Space;
  46814. /**
  46815. * Used to make an adjustment to the yaw of the bone
  46816. */
  46817. adjustYaw: number;
  46818. /**
  46819. * Used to make an adjustment to the pitch of the bone
  46820. */
  46821. adjustPitch: number;
  46822. /**
  46823. * Used to make an adjustment to the roll of the bone
  46824. */
  46825. adjustRoll: number;
  46826. /**
  46827. * 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)
  46828. */
  46829. slerpAmount: number;
  46830. private _minYaw;
  46831. private _maxYaw;
  46832. private _minPitch;
  46833. private _maxPitch;
  46834. private _minYawSin;
  46835. private _minYawCos;
  46836. private _maxYawSin;
  46837. private _maxYawCos;
  46838. private _midYawConstraint;
  46839. private _minPitchTan;
  46840. private _maxPitchTan;
  46841. private _boneQuat;
  46842. private _slerping;
  46843. private _transformYawPitch;
  46844. private _transformYawPitchInv;
  46845. private _firstFrameSkipped;
  46846. private _yawRange;
  46847. private _fowardAxis;
  46848. /**
  46849. * Gets or sets the minimum yaw angle that the bone can look to
  46850. */
  46851. get minYaw(): number;
  46852. set minYaw(value: number);
  46853. /**
  46854. * Gets or sets the maximum yaw angle that the bone can look to
  46855. */
  46856. get maxYaw(): number;
  46857. set maxYaw(value: number);
  46858. /**
  46859. * Gets or sets the minimum pitch angle that the bone can look to
  46860. */
  46861. get minPitch(): number;
  46862. set minPitch(value: number);
  46863. /**
  46864. * Gets or sets the maximum pitch angle that the bone can look to
  46865. */
  46866. get maxPitch(): number;
  46867. set maxPitch(value: number);
  46868. /**
  46869. * Create a BoneLookController
  46870. * @param mesh the mesh that the bone belongs to
  46871. * @param bone the bone that will be looking to the target
  46872. * @param target the target Vector3 to look at
  46873. * @param options optional settings:
  46874. * * maxYaw: the maximum angle the bone will yaw to
  46875. * * minYaw: the minimum angle the bone will yaw to
  46876. * * maxPitch: the maximum angle the bone will pitch to
  46877. * * minPitch: the minimum angle the bone will yaw to
  46878. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  46879. * * upAxis: the up axis of the coordinate system
  46880. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  46881. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  46882. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  46883. * * adjustYaw: used to make an adjustment to the yaw of the bone
  46884. * * adjustPitch: used to make an adjustment to the pitch of the bone
  46885. * * adjustRoll: used to make an adjustment to the roll of the bone
  46886. **/
  46887. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  46888. maxYaw?: number;
  46889. minYaw?: number;
  46890. maxPitch?: number;
  46891. minPitch?: number;
  46892. slerpAmount?: number;
  46893. upAxis?: Vector3;
  46894. upAxisSpace?: Space;
  46895. yawAxis?: Vector3;
  46896. pitchAxis?: Vector3;
  46897. adjustYaw?: number;
  46898. adjustPitch?: number;
  46899. adjustRoll?: number;
  46900. });
  46901. /**
  46902. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  46903. */
  46904. update(): void;
  46905. private _getAngleDiff;
  46906. private _getAngleBetween;
  46907. private _isAngleBetween;
  46908. }
  46909. }
  46910. declare module BABYLON {
  46911. /**
  46912. * Manage the gamepad inputs to control an arc rotate camera.
  46913. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46914. */
  46915. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  46916. /**
  46917. * Defines the camera the input is attached to.
  46918. */
  46919. camera: ArcRotateCamera;
  46920. /**
  46921. * Defines the gamepad the input is gathering event from.
  46922. */
  46923. gamepad: Nullable<Gamepad>;
  46924. /**
  46925. * Defines the gamepad rotation sensiblity.
  46926. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46927. */
  46928. gamepadRotationSensibility: number;
  46929. /**
  46930. * Defines the gamepad move sensiblity.
  46931. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46932. */
  46933. gamepadMoveSensibility: number;
  46934. private _yAxisScale;
  46935. /**
  46936. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46937. */
  46938. get invertYAxis(): boolean;
  46939. set invertYAxis(value: boolean);
  46940. private _onGamepadConnectedObserver;
  46941. private _onGamepadDisconnectedObserver;
  46942. /**
  46943. * Attach the input controls to a specific dom element to get the input from.
  46944. * @param element Defines the element the controls should be listened from
  46945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46946. */
  46947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46948. /**
  46949. * Detach the current controls from the specified dom element.
  46950. * @param element Defines the element to stop listening the inputs from
  46951. */
  46952. detachControl(element: Nullable<HTMLElement>): void;
  46953. /**
  46954. * Update the current camera state depending on the inputs that have been used this frame.
  46955. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46956. */
  46957. checkInputs(): void;
  46958. /**
  46959. * Gets the class name of the current intput.
  46960. * @returns the class name
  46961. */
  46962. getClassName(): string;
  46963. /**
  46964. * Get the friendly name associated with the input class.
  46965. * @returns the input friendly name
  46966. */
  46967. getSimpleName(): string;
  46968. }
  46969. }
  46970. declare module BABYLON {
  46971. interface ArcRotateCameraInputsManager {
  46972. /**
  46973. * Add orientation input support to the input manager.
  46974. * @returns the current input manager
  46975. */
  46976. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  46977. }
  46978. /**
  46979. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  46980. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46981. */
  46982. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  46983. /**
  46984. * Defines the camera the input is attached to.
  46985. */
  46986. camera: ArcRotateCamera;
  46987. /**
  46988. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  46989. */
  46990. alphaCorrection: number;
  46991. /**
  46992. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  46993. */
  46994. gammaCorrection: number;
  46995. private _alpha;
  46996. private _gamma;
  46997. private _dirty;
  46998. private _deviceOrientationHandler;
  46999. /**
  47000. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47001. */
  47002. constructor();
  47003. /**
  47004. * Attach the input controls to a specific dom element to get the input from.
  47005. * @param element Defines the element the controls should be listened from
  47006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47007. */
  47008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47009. /** @hidden */
  47010. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47011. /**
  47012. * Update the current camera state depending on the inputs that have been used this frame.
  47013. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47014. */
  47015. checkInputs(): void;
  47016. /**
  47017. * Detach the current controls from the specified dom element.
  47018. * @param element Defines the element to stop listening the inputs from
  47019. */
  47020. detachControl(element: Nullable<HTMLElement>): void;
  47021. /**
  47022. * Gets the class name of the current intput.
  47023. * @returns the class name
  47024. */
  47025. getClassName(): string;
  47026. /**
  47027. * Get the friendly name associated with the input class.
  47028. * @returns the input friendly name
  47029. */
  47030. getSimpleName(): string;
  47031. }
  47032. }
  47033. declare module BABYLON {
  47034. /**
  47035. * Listen to mouse events to control the camera.
  47036. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47037. */
  47038. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47039. /**
  47040. * Defines the camera the input is attached to.
  47041. */
  47042. camera: FlyCamera;
  47043. /**
  47044. * Defines if touch is enabled. (Default is true.)
  47045. */
  47046. touchEnabled: boolean;
  47047. /**
  47048. * Defines the buttons associated with the input to handle camera rotation.
  47049. */
  47050. buttons: number[];
  47051. /**
  47052. * Assign buttons for Yaw control.
  47053. */
  47054. buttonsYaw: number[];
  47055. /**
  47056. * Assign buttons for Pitch control.
  47057. */
  47058. buttonsPitch: number[];
  47059. /**
  47060. * Assign buttons for Roll control.
  47061. */
  47062. buttonsRoll: number[];
  47063. /**
  47064. * Detect if any button is being pressed while mouse is moved.
  47065. * -1 = Mouse locked.
  47066. * 0 = Left button.
  47067. * 1 = Middle Button.
  47068. * 2 = Right Button.
  47069. */
  47070. activeButton: number;
  47071. /**
  47072. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47073. * Higher values reduce its sensitivity.
  47074. */
  47075. angularSensibility: number;
  47076. private _observer;
  47077. private _rollObserver;
  47078. private previousPosition;
  47079. private noPreventDefault;
  47080. private element;
  47081. /**
  47082. * Listen to mouse events to control the camera.
  47083. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47084. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47085. */
  47086. constructor(touchEnabled?: boolean);
  47087. /**
  47088. * Attach the mouse control to the HTML DOM element.
  47089. * @param element Defines the element that listens to the input events.
  47090. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47091. */
  47092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47093. /**
  47094. * Detach the current controls from the specified dom element.
  47095. * @param element Defines the element to stop listening the inputs from
  47096. */
  47097. detachControl(element: Nullable<HTMLElement>): void;
  47098. /**
  47099. * Gets the class name of the current input.
  47100. * @returns the class name.
  47101. */
  47102. getClassName(): string;
  47103. /**
  47104. * Get the friendly name associated with the input class.
  47105. * @returns the input's friendly name.
  47106. */
  47107. getSimpleName(): string;
  47108. private _pointerInput;
  47109. private _onMouseMove;
  47110. /**
  47111. * Rotate camera by mouse offset.
  47112. */
  47113. private rotateCamera;
  47114. }
  47115. }
  47116. declare module BABYLON {
  47117. /**
  47118. * Default Inputs manager for the FlyCamera.
  47119. * It groups all the default supported inputs for ease of use.
  47120. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47121. */
  47122. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47123. /**
  47124. * Instantiates a new FlyCameraInputsManager.
  47125. * @param camera Defines the camera the inputs belong to.
  47126. */
  47127. constructor(camera: FlyCamera);
  47128. /**
  47129. * Add keyboard input support to the input manager.
  47130. * @returns the new FlyCameraKeyboardMoveInput().
  47131. */
  47132. addKeyboard(): FlyCameraInputsManager;
  47133. /**
  47134. * Add mouse input support to the input manager.
  47135. * @param touchEnabled Enable touch screen support.
  47136. * @returns the new FlyCameraMouseInput().
  47137. */
  47138. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47139. }
  47140. }
  47141. declare module BABYLON {
  47142. /**
  47143. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47144. * such as in a 3D Space Shooter or a Flight Simulator.
  47145. */
  47146. export class FlyCamera extends TargetCamera {
  47147. /**
  47148. * Define the collision ellipsoid of the camera.
  47149. * This is helpful for simulating a camera body, like a player's body.
  47150. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47151. */
  47152. ellipsoid: Vector3;
  47153. /**
  47154. * Define an offset for the position of the ellipsoid around the camera.
  47155. * This can be helpful if the camera is attached away from the player's body center,
  47156. * such as at its head.
  47157. */
  47158. ellipsoidOffset: Vector3;
  47159. /**
  47160. * Enable or disable collisions of the camera with the rest of the scene objects.
  47161. */
  47162. checkCollisions: boolean;
  47163. /**
  47164. * Enable or disable gravity on the camera.
  47165. */
  47166. applyGravity: boolean;
  47167. /**
  47168. * Define the current direction the camera is moving to.
  47169. */
  47170. cameraDirection: Vector3;
  47171. /**
  47172. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47173. * This overrides and empties cameraRotation.
  47174. */
  47175. rotationQuaternion: Quaternion;
  47176. /**
  47177. * Track Roll to maintain the wanted Rolling when looking around.
  47178. */
  47179. _trackRoll: number;
  47180. /**
  47181. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47182. */
  47183. rollCorrect: number;
  47184. /**
  47185. * Mimic a banked turn, Rolling the camera when Yawing.
  47186. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47187. */
  47188. bankedTurn: boolean;
  47189. /**
  47190. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47191. */
  47192. bankedTurnLimit: number;
  47193. /**
  47194. * Value of 0 disables the banked Roll.
  47195. * Value of 1 is equal to the Yaw angle in radians.
  47196. */
  47197. bankedTurnMultiplier: number;
  47198. /**
  47199. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47200. */
  47201. inputs: FlyCameraInputsManager;
  47202. /**
  47203. * Gets the input sensibility for mouse input.
  47204. * Higher values reduce sensitivity.
  47205. */
  47206. get angularSensibility(): number;
  47207. /**
  47208. * Sets the input sensibility for a mouse input.
  47209. * Higher values reduce sensitivity.
  47210. */
  47211. set angularSensibility(value: number);
  47212. /**
  47213. * Get the keys for camera movement forward.
  47214. */
  47215. get keysForward(): number[];
  47216. /**
  47217. * Set the keys for camera movement forward.
  47218. */
  47219. set keysForward(value: number[]);
  47220. /**
  47221. * Get the keys for camera movement backward.
  47222. */
  47223. get keysBackward(): number[];
  47224. set keysBackward(value: number[]);
  47225. /**
  47226. * Get the keys for camera movement up.
  47227. */
  47228. get keysUp(): number[];
  47229. /**
  47230. * Set the keys for camera movement up.
  47231. */
  47232. set keysUp(value: number[]);
  47233. /**
  47234. * Get the keys for camera movement down.
  47235. */
  47236. get keysDown(): number[];
  47237. /**
  47238. * Set the keys for camera movement down.
  47239. */
  47240. set keysDown(value: number[]);
  47241. /**
  47242. * Get the keys for camera movement left.
  47243. */
  47244. get keysLeft(): number[];
  47245. /**
  47246. * Set the keys for camera movement left.
  47247. */
  47248. set keysLeft(value: number[]);
  47249. /**
  47250. * Set the keys for camera movement right.
  47251. */
  47252. get keysRight(): number[];
  47253. /**
  47254. * Set the keys for camera movement right.
  47255. */
  47256. set keysRight(value: number[]);
  47257. /**
  47258. * Event raised when the camera collides with a mesh in the scene.
  47259. */
  47260. onCollide: (collidedMesh: AbstractMesh) => void;
  47261. private _collider;
  47262. private _needMoveForGravity;
  47263. private _oldPosition;
  47264. private _diffPosition;
  47265. private _newPosition;
  47266. /** @hidden */
  47267. _localDirection: Vector3;
  47268. /** @hidden */
  47269. _transformedDirection: Vector3;
  47270. /**
  47271. * Instantiates a FlyCamera.
  47272. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47273. * such as in a 3D Space Shooter or a Flight Simulator.
  47274. * @param name Define the name of the camera in the scene.
  47275. * @param position Define the starting position of the camera in the scene.
  47276. * @param scene Define the scene the camera belongs to.
  47277. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47278. */
  47279. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47280. /**
  47281. * Attach a control to the HTML DOM element.
  47282. * @param element Defines the element that listens to the input events.
  47283. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47284. */
  47285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47286. /**
  47287. * Detach a control from the HTML DOM element.
  47288. * The camera will stop reacting to that input.
  47289. * @param element Defines the element that listens to the input events.
  47290. */
  47291. detachControl(element: HTMLElement): void;
  47292. private _collisionMask;
  47293. /**
  47294. * Get the mask that the camera ignores in collision events.
  47295. */
  47296. get collisionMask(): number;
  47297. /**
  47298. * Set the mask that the camera ignores in collision events.
  47299. */
  47300. set collisionMask(mask: number);
  47301. /** @hidden */
  47302. _collideWithWorld(displacement: Vector3): void;
  47303. /** @hidden */
  47304. private _onCollisionPositionChange;
  47305. /** @hidden */
  47306. _checkInputs(): void;
  47307. /** @hidden */
  47308. _decideIfNeedsToMove(): boolean;
  47309. /** @hidden */
  47310. _updatePosition(): void;
  47311. /**
  47312. * Restore the Roll to its target value at the rate specified.
  47313. * @param rate - Higher means slower restoring.
  47314. * @hidden
  47315. */
  47316. restoreRoll(rate: number): void;
  47317. /**
  47318. * Destroy the camera and release the current resources held by it.
  47319. */
  47320. dispose(): void;
  47321. /**
  47322. * Get the current object class name.
  47323. * @returns the class name.
  47324. */
  47325. getClassName(): string;
  47326. }
  47327. }
  47328. declare module BABYLON {
  47329. /**
  47330. * Listen to keyboard events to control the camera.
  47331. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47332. */
  47333. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47334. /**
  47335. * Defines the camera the input is attached to.
  47336. */
  47337. camera: FlyCamera;
  47338. /**
  47339. * The list of keyboard keys used to control the forward move of the camera.
  47340. */
  47341. keysForward: number[];
  47342. /**
  47343. * The list of keyboard keys used to control the backward move of the camera.
  47344. */
  47345. keysBackward: number[];
  47346. /**
  47347. * The list of keyboard keys used to control the forward move of the camera.
  47348. */
  47349. keysUp: number[];
  47350. /**
  47351. * The list of keyboard keys used to control the backward move of the camera.
  47352. */
  47353. keysDown: number[];
  47354. /**
  47355. * The list of keyboard keys used to control the right strafe move of the camera.
  47356. */
  47357. keysRight: number[];
  47358. /**
  47359. * The list of keyboard keys used to control the left strafe move of the camera.
  47360. */
  47361. keysLeft: number[];
  47362. private _keys;
  47363. private _onCanvasBlurObserver;
  47364. private _onKeyboardObserver;
  47365. private _engine;
  47366. private _scene;
  47367. /**
  47368. * Attach the input controls to a specific dom element to get the input from.
  47369. * @param element Defines the element the controls should be listened from
  47370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47371. */
  47372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47373. /**
  47374. * Detach the current controls from the specified dom element.
  47375. * @param element Defines the element to stop listening the inputs from
  47376. */
  47377. detachControl(element: Nullable<HTMLElement>): void;
  47378. /**
  47379. * Gets the class name of the current intput.
  47380. * @returns the class name
  47381. */
  47382. getClassName(): string;
  47383. /** @hidden */
  47384. _onLostFocus(e: FocusEvent): void;
  47385. /**
  47386. * Get the friendly name associated with the input class.
  47387. * @returns the input friendly name
  47388. */
  47389. getSimpleName(): string;
  47390. /**
  47391. * Update the current camera state depending on the inputs that have been used this frame.
  47392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47393. */
  47394. checkInputs(): void;
  47395. }
  47396. }
  47397. declare module BABYLON {
  47398. /**
  47399. * Manage the mouse wheel inputs to control a follow camera.
  47400. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47401. */
  47402. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47403. /**
  47404. * Defines the camera the input is attached to.
  47405. */
  47406. camera: FollowCamera;
  47407. /**
  47408. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47409. */
  47410. axisControlRadius: boolean;
  47411. /**
  47412. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47413. */
  47414. axisControlHeight: boolean;
  47415. /**
  47416. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47417. */
  47418. axisControlRotation: boolean;
  47419. /**
  47420. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47421. * relation to mouseWheel events.
  47422. */
  47423. wheelPrecision: number;
  47424. /**
  47425. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47426. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47427. */
  47428. wheelDeltaPercentage: number;
  47429. private _wheel;
  47430. private _observer;
  47431. /**
  47432. * Attach the input controls to a specific dom element to get the input from.
  47433. * @param element Defines the element the controls should be listened from
  47434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47435. */
  47436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47437. /**
  47438. * Detach the current controls from the specified dom element.
  47439. * @param element Defines the element to stop listening the inputs from
  47440. */
  47441. detachControl(element: Nullable<HTMLElement>): void;
  47442. /**
  47443. * Gets the class name of the current intput.
  47444. * @returns the class name
  47445. */
  47446. getClassName(): string;
  47447. /**
  47448. * Get the friendly name associated with the input class.
  47449. * @returns the input friendly name
  47450. */
  47451. getSimpleName(): string;
  47452. }
  47453. }
  47454. declare module BABYLON {
  47455. /**
  47456. * Manage the pointers inputs to control an follow camera.
  47457. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47458. */
  47459. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47460. /**
  47461. * Defines the camera the input is attached to.
  47462. */
  47463. camera: FollowCamera;
  47464. /**
  47465. * Gets the class name of the current input.
  47466. * @returns the class name
  47467. */
  47468. getClassName(): string;
  47469. /**
  47470. * Defines the pointer angular sensibility along the X axis or how fast is
  47471. * the camera rotating.
  47472. * A negative number will reverse the axis direction.
  47473. */
  47474. angularSensibilityX: number;
  47475. /**
  47476. * Defines the pointer angular sensibility along the Y axis or how fast is
  47477. * the camera rotating.
  47478. * A negative number will reverse the axis direction.
  47479. */
  47480. angularSensibilityY: number;
  47481. /**
  47482. * Defines the pointer pinch precision or how fast is the camera zooming.
  47483. * A negative number will reverse the axis direction.
  47484. */
  47485. pinchPrecision: number;
  47486. /**
  47487. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47488. * from 0.
  47489. * It defines the percentage of current camera.radius to use as delta when
  47490. * pinch zoom is used.
  47491. */
  47492. pinchDeltaPercentage: number;
  47493. /**
  47494. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47495. */
  47496. axisXControlRadius: boolean;
  47497. /**
  47498. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47499. */
  47500. axisXControlHeight: boolean;
  47501. /**
  47502. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47503. */
  47504. axisXControlRotation: boolean;
  47505. /**
  47506. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47507. */
  47508. axisYControlRadius: boolean;
  47509. /**
  47510. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47511. */
  47512. axisYControlHeight: boolean;
  47513. /**
  47514. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47515. */
  47516. axisYControlRotation: boolean;
  47517. /**
  47518. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47519. */
  47520. axisPinchControlRadius: boolean;
  47521. /**
  47522. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47523. */
  47524. axisPinchControlHeight: boolean;
  47525. /**
  47526. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47527. */
  47528. axisPinchControlRotation: boolean;
  47529. /**
  47530. * Log error messages if basic misconfiguration has occurred.
  47531. */
  47532. warningEnable: boolean;
  47533. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47534. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47535. private _warningCounter;
  47536. private _warning;
  47537. }
  47538. }
  47539. declare module BABYLON {
  47540. /**
  47541. * Default Inputs manager for the FollowCamera.
  47542. * It groups all the default supported inputs for ease of use.
  47543. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47544. */
  47545. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47546. /**
  47547. * Instantiates a new FollowCameraInputsManager.
  47548. * @param camera Defines the camera the inputs belong to
  47549. */
  47550. constructor(camera: FollowCamera);
  47551. /**
  47552. * Add keyboard input support to the input manager.
  47553. * @returns the current input manager
  47554. */
  47555. addKeyboard(): FollowCameraInputsManager;
  47556. /**
  47557. * Add mouse wheel input support to the input manager.
  47558. * @returns the current input manager
  47559. */
  47560. addMouseWheel(): FollowCameraInputsManager;
  47561. /**
  47562. * Add pointers input support to the input manager.
  47563. * @returns the current input manager
  47564. */
  47565. addPointers(): FollowCameraInputsManager;
  47566. /**
  47567. * Add orientation input support to the input manager.
  47568. * @returns the current input manager
  47569. */
  47570. addVRDeviceOrientation(): FollowCameraInputsManager;
  47571. }
  47572. }
  47573. declare module BABYLON {
  47574. /**
  47575. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  47576. * an arc rotate version arcFollowCamera are available.
  47577. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47578. */
  47579. export class FollowCamera extends TargetCamera {
  47580. /**
  47581. * Distance the follow camera should follow an object at
  47582. */
  47583. radius: number;
  47584. /**
  47585. * Minimum allowed distance of the camera to the axis of rotation
  47586. * (The camera can not get closer).
  47587. * This can help limiting how the Camera is able to move in the scene.
  47588. */
  47589. lowerRadiusLimit: Nullable<number>;
  47590. /**
  47591. * Maximum allowed distance of the camera to the axis of rotation
  47592. * (The camera can not get further).
  47593. * This can help limiting how the Camera is able to move in the scene.
  47594. */
  47595. upperRadiusLimit: Nullable<number>;
  47596. /**
  47597. * Define a rotation offset between the camera and the object it follows
  47598. */
  47599. rotationOffset: number;
  47600. /**
  47601. * Minimum allowed angle to camera position relative to target object.
  47602. * This can help limiting how the Camera is able to move in the scene.
  47603. */
  47604. lowerRotationOffsetLimit: Nullable<number>;
  47605. /**
  47606. * Maximum allowed angle to camera position relative to target object.
  47607. * This can help limiting how the Camera is able to move in the scene.
  47608. */
  47609. upperRotationOffsetLimit: Nullable<number>;
  47610. /**
  47611. * Define a height offset between the camera and the object it follows.
  47612. * It can help following an object from the top (like a car chaing a plane)
  47613. */
  47614. heightOffset: number;
  47615. /**
  47616. * Minimum allowed height of camera position relative to target object.
  47617. * This can help limiting how the Camera is able to move in the scene.
  47618. */
  47619. lowerHeightOffsetLimit: Nullable<number>;
  47620. /**
  47621. * Maximum allowed height of camera position relative to target object.
  47622. * This can help limiting how the Camera is able to move in the scene.
  47623. */
  47624. upperHeightOffsetLimit: Nullable<number>;
  47625. /**
  47626. * Define how fast the camera can accelerate to follow it s target.
  47627. */
  47628. cameraAcceleration: number;
  47629. /**
  47630. * Define the speed limit of the camera following an object.
  47631. */
  47632. maxCameraSpeed: number;
  47633. /**
  47634. * Define the target of the camera.
  47635. */
  47636. lockedTarget: Nullable<AbstractMesh>;
  47637. /**
  47638. * Defines the input associated with the camera.
  47639. */
  47640. inputs: FollowCameraInputsManager;
  47641. /**
  47642. * Instantiates the follow camera.
  47643. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47644. * @param name Define the name of the camera in the scene
  47645. * @param position Define the position of the camera
  47646. * @param scene Define the scene the camera belong to
  47647. * @param lockedTarget Define the target of the camera
  47648. */
  47649. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  47650. private _follow;
  47651. /**
  47652. * Attached controls to the current camera.
  47653. * @param element Defines the element the controls should be listened from
  47654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47655. */
  47656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47657. /**
  47658. * Detach the current controls from the camera.
  47659. * The camera will stop reacting to inputs.
  47660. * @param element Defines the element to stop listening the inputs from
  47661. */
  47662. detachControl(element: HTMLElement): void;
  47663. /** @hidden */
  47664. _checkInputs(): void;
  47665. private _checkLimits;
  47666. /**
  47667. * Gets the camera class name.
  47668. * @returns the class name
  47669. */
  47670. getClassName(): string;
  47671. }
  47672. /**
  47673. * Arc Rotate version of the follow camera.
  47674. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  47675. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47676. */
  47677. export class ArcFollowCamera extends TargetCamera {
  47678. /** The longitudinal angle of the camera */
  47679. alpha: number;
  47680. /** The latitudinal angle of the camera */
  47681. beta: number;
  47682. /** The radius of the camera from its target */
  47683. radius: number;
  47684. private _cartesianCoordinates;
  47685. /** Define the camera target (the mesh it should follow) */
  47686. private _meshTarget;
  47687. /**
  47688. * Instantiates a new ArcFollowCamera
  47689. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47690. * @param name Define the name of the camera
  47691. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  47692. * @param beta Define the rotation angle of the camera around the elevation axis
  47693. * @param radius Define the radius of the camera from its target point
  47694. * @param target Define the target of the camera
  47695. * @param scene Define the scene the camera belongs to
  47696. */
  47697. constructor(name: string,
  47698. /** The longitudinal angle of the camera */
  47699. alpha: number,
  47700. /** The latitudinal angle of the camera */
  47701. beta: number,
  47702. /** The radius of the camera from its target */
  47703. radius: number,
  47704. /** Define the camera target (the mesh it should follow) */
  47705. target: Nullable<AbstractMesh>, scene: Scene);
  47706. private _follow;
  47707. /** @hidden */
  47708. _checkInputs(): void;
  47709. /**
  47710. * Returns the class name of the object.
  47711. * It is mostly used internally for serialization purposes.
  47712. */
  47713. getClassName(): string;
  47714. }
  47715. }
  47716. declare module BABYLON {
  47717. /**
  47718. * Manage the keyboard inputs to control the movement of a follow camera.
  47719. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47720. */
  47721. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  47722. /**
  47723. * Defines the camera the input is attached to.
  47724. */
  47725. camera: FollowCamera;
  47726. /**
  47727. * Defines the list of key codes associated with the up action (increase heightOffset)
  47728. */
  47729. keysHeightOffsetIncr: number[];
  47730. /**
  47731. * Defines the list of key codes associated with the down action (decrease heightOffset)
  47732. */
  47733. keysHeightOffsetDecr: number[];
  47734. /**
  47735. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  47736. */
  47737. keysHeightOffsetModifierAlt: boolean;
  47738. /**
  47739. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  47740. */
  47741. keysHeightOffsetModifierCtrl: boolean;
  47742. /**
  47743. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  47744. */
  47745. keysHeightOffsetModifierShift: boolean;
  47746. /**
  47747. * Defines the list of key codes associated with the left action (increase rotationOffset)
  47748. */
  47749. keysRotationOffsetIncr: number[];
  47750. /**
  47751. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  47752. */
  47753. keysRotationOffsetDecr: number[];
  47754. /**
  47755. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  47756. */
  47757. keysRotationOffsetModifierAlt: boolean;
  47758. /**
  47759. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  47760. */
  47761. keysRotationOffsetModifierCtrl: boolean;
  47762. /**
  47763. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  47764. */
  47765. keysRotationOffsetModifierShift: boolean;
  47766. /**
  47767. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  47768. */
  47769. keysRadiusIncr: number[];
  47770. /**
  47771. * Defines the list of key codes associated with the zoom-out action (increase radius)
  47772. */
  47773. keysRadiusDecr: number[];
  47774. /**
  47775. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  47776. */
  47777. keysRadiusModifierAlt: boolean;
  47778. /**
  47779. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  47780. */
  47781. keysRadiusModifierCtrl: boolean;
  47782. /**
  47783. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  47784. */
  47785. keysRadiusModifierShift: boolean;
  47786. /**
  47787. * Defines the rate of change of heightOffset.
  47788. */
  47789. heightSensibility: number;
  47790. /**
  47791. * Defines the rate of change of rotationOffset.
  47792. */
  47793. rotationSensibility: number;
  47794. /**
  47795. * Defines the rate of change of radius.
  47796. */
  47797. radiusSensibility: number;
  47798. private _keys;
  47799. private _ctrlPressed;
  47800. private _altPressed;
  47801. private _shiftPressed;
  47802. private _onCanvasBlurObserver;
  47803. private _onKeyboardObserver;
  47804. private _engine;
  47805. private _scene;
  47806. /**
  47807. * Attach the input controls to a specific dom element to get the input from.
  47808. * @param element Defines the element the controls should be listened from
  47809. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47810. */
  47811. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47812. /**
  47813. * Detach the current controls from the specified dom element.
  47814. * @param element Defines the element to stop listening the inputs from
  47815. */
  47816. detachControl(element: Nullable<HTMLElement>): void;
  47817. /**
  47818. * Update the current camera state depending on the inputs that have been used this frame.
  47819. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47820. */
  47821. checkInputs(): void;
  47822. /**
  47823. * Gets the class name of the current input.
  47824. * @returns the class name
  47825. */
  47826. getClassName(): string;
  47827. /**
  47828. * Get the friendly name associated with the input class.
  47829. * @returns the input friendly name
  47830. */
  47831. getSimpleName(): string;
  47832. /**
  47833. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47834. * allow modification of the heightOffset value.
  47835. */
  47836. private _modifierHeightOffset;
  47837. /**
  47838. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47839. * allow modification of the rotationOffset value.
  47840. */
  47841. private _modifierRotationOffset;
  47842. /**
  47843. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47844. * allow modification of the radius value.
  47845. */
  47846. private _modifierRadius;
  47847. }
  47848. }
  47849. declare module BABYLON {
  47850. interface FreeCameraInputsManager {
  47851. /**
  47852. * @hidden
  47853. */
  47854. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  47855. /**
  47856. * Add orientation input support to the input manager.
  47857. * @returns the current input manager
  47858. */
  47859. addDeviceOrientation(): FreeCameraInputsManager;
  47860. }
  47861. /**
  47862. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  47863. * Screen rotation is taken into account.
  47864. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47865. */
  47866. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  47867. private _camera;
  47868. private _screenOrientationAngle;
  47869. private _constantTranform;
  47870. private _screenQuaternion;
  47871. private _alpha;
  47872. private _beta;
  47873. private _gamma;
  47874. /**
  47875. * Can be used to detect if a device orientation sensor is available on a device
  47876. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  47877. * @returns a promise that will resolve on orientation change
  47878. */
  47879. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  47880. /**
  47881. * @hidden
  47882. */
  47883. _onDeviceOrientationChangedObservable: Observable<void>;
  47884. /**
  47885. * Instantiates a new input
  47886. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47887. */
  47888. constructor();
  47889. /**
  47890. * Define the camera controlled by the input.
  47891. */
  47892. get camera(): FreeCamera;
  47893. set camera(camera: FreeCamera);
  47894. /**
  47895. * Attach the input controls to a specific dom element to get the input from.
  47896. * @param element Defines the element the controls should be listened from
  47897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47898. */
  47899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47900. private _orientationChanged;
  47901. private _deviceOrientation;
  47902. /**
  47903. * Detach the current controls from the specified dom element.
  47904. * @param element Defines the element to stop listening the inputs from
  47905. */
  47906. detachControl(element: Nullable<HTMLElement>): void;
  47907. /**
  47908. * Update the current camera state depending on the inputs that have been used this frame.
  47909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47910. */
  47911. checkInputs(): void;
  47912. /**
  47913. * Gets the class name of the current intput.
  47914. * @returns the class name
  47915. */
  47916. getClassName(): string;
  47917. /**
  47918. * Get the friendly name associated with the input class.
  47919. * @returns the input friendly name
  47920. */
  47921. getSimpleName(): string;
  47922. }
  47923. }
  47924. declare module BABYLON {
  47925. /**
  47926. * Manage the gamepad inputs to control a free camera.
  47927. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47928. */
  47929. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  47930. /**
  47931. * Define the camera the input is attached to.
  47932. */
  47933. camera: FreeCamera;
  47934. /**
  47935. * Define the Gamepad controlling the input
  47936. */
  47937. gamepad: Nullable<Gamepad>;
  47938. /**
  47939. * Defines the gamepad rotation sensiblity.
  47940. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47941. */
  47942. gamepadAngularSensibility: number;
  47943. /**
  47944. * Defines the gamepad move sensiblity.
  47945. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47946. */
  47947. gamepadMoveSensibility: number;
  47948. private _yAxisScale;
  47949. /**
  47950. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47951. */
  47952. get invertYAxis(): boolean;
  47953. set invertYAxis(value: boolean);
  47954. private _onGamepadConnectedObserver;
  47955. private _onGamepadDisconnectedObserver;
  47956. private _cameraTransform;
  47957. private _deltaTransform;
  47958. private _vector3;
  47959. private _vector2;
  47960. /**
  47961. * Attach the input controls to a specific dom element to get the input from.
  47962. * @param element Defines the element the controls should be listened from
  47963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47964. */
  47965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47966. /**
  47967. * Detach the current controls from the specified dom element.
  47968. * @param element Defines the element to stop listening the inputs from
  47969. */
  47970. detachControl(element: Nullable<HTMLElement>): void;
  47971. /**
  47972. * Update the current camera state depending on the inputs that have been used this frame.
  47973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47974. */
  47975. checkInputs(): void;
  47976. /**
  47977. * Gets the class name of the current intput.
  47978. * @returns the class name
  47979. */
  47980. getClassName(): string;
  47981. /**
  47982. * Get the friendly name associated with the input class.
  47983. * @returns the input friendly name
  47984. */
  47985. getSimpleName(): string;
  47986. }
  47987. }
  47988. declare module BABYLON {
  47989. /**
  47990. * Defines the potential axis of a Joystick
  47991. */
  47992. export enum JoystickAxis {
  47993. /** X axis */
  47994. X = 0,
  47995. /** Y axis */
  47996. Y = 1,
  47997. /** Z axis */
  47998. Z = 2
  47999. }
  48000. /**
  48001. * Represents the different customization options available
  48002. * for VirtualJoystick
  48003. */
  48004. interface VirtualJoystickCustomizations {
  48005. /**
  48006. * Size of the joystick's puck
  48007. */
  48008. puckSize: number;
  48009. /**
  48010. * Size of the joystick's container
  48011. */
  48012. containerSize: number;
  48013. /**
  48014. * Color of the joystick && puck
  48015. */
  48016. color: string;
  48017. /**
  48018. * Image URL for the joystick's puck
  48019. */
  48020. puckImage?: string;
  48021. /**
  48022. * Image URL for the joystick's container
  48023. */
  48024. containerImage?: string;
  48025. /**
  48026. * Defines the unmoving position of the joystick container
  48027. */
  48028. position?: {
  48029. x: number;
  48030. y: number;
  48031. };
  48032. /**
  48033. * Defines whether or not the joystick container is always visible
  48034. */
  48035. alwaysVisible: boolean;
  48036. /**
  48037. * Defines whether or not to limit the movement of the puck to the joystick's container
  48038. */
  48039. limitToContainer: boolean;
  48040. }
  48041. /**
  48042. * Class used to define virtual joystick (used in touch mode)
  48043. */
  48044. export class VirtualJoystick {
  48045. /**
  48046. * Gets or sets a boolean indicating that left and right values must be inverted
  48047. */
  48048. reverseLeftRight: boolean;
  48049. /**
  48050. * Gets or sets a boolean indicating that up and down values must be inverted
  48051. */
  48052. reverseUpDown: boolean;
  48053. /**
  48054. * Gets the offset value for the position (ie. the change of the position value)
  48055. */
  48056. deltaPosition: Vector3;
  48057. /**
  48058. * Gets a boolean indicating if the virtual joystick was pressed
  48059. */
  48060. pressed: boolean;
  48061. /**
  48062. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48063. */
  48064. static Canvas: Nullable<HTMLCanvasElement>;
  48065. /**
  48066. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48067. */
  48068. limitToContainer: boolean;
  48069. private static _globalJoystickIndex;
  48070. private static _alwaysVisibleSticks;
  48071. private static vjCanvasContext;
  48072. private static vjCanvasWidth;
  48073. private static vjCanvasHeight;
  48074. private static halfWidth;
  48075. private static _GetDefaultOptions;
  48076. private _action;
  48077. private _axisTargetedByLeftAndRight;
  48078. private _axisTargetedByUpAndDown;
  48079. private _joystickSensibility;
  48080. private _inversedSensibility;
  48081. private _joystickPointerID;
  48082. private _joystickColor;
  48083. private _joystickPointerPos;
  48084. private _joystickPreviousPointerPos;
  48085. private _joystickPointerStartPos;
  48086. private _deltaJoystickVector;
  48087. private _leftJoystick;
  48088. private _touches;
  48089. private _joystickPosition;
  48090. private _alwaysVisible;
  48091. private _puckImage;
  48092. private _containerImage;
  48093. private _joystickPuckSize;
  48094. private _joystickContainerSize;
  48095. private _clearPuckSize;
  48096. private _clearContainerSize;
  48097. private _clearPuckSizeOffset;
  48098. private _clearContainerSizeOffset;
  48099. private _onPointerDownHandlerRef;
  48100. private _onPointerMoveHandlerRef;
  48101. private _onPointerUpHandlerRef;
  48102. private _onResize;
  48103. /**
  48104. * Creates a new virtual joystick
  48105. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48106. * @param customizations Defines the options we want to customize the VirtualJoystick
  48107. */
  48108. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48109. /**
  48110. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48111. * @param newJoystickSensibility defines the new sensibility
  48112. */
  48113. setJoystickSensibility(newJoystickSensibility: number): void;
  48114. private _onPointerDown;
  48115. private _onPointerMove;
  48116. private _onPointerUp;
  48117. /**
  48118. * Change the color of the virtual joystick
  48119. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48120. */
  48121. setJoystickColor(newColor: string): void;
  48122. /**
  48123. * Size of the joystick's container
  48124. */
  48125. set containerSize(newSize: number);
  48126. get containerSize(): number;
  48127. /**
  48128. * Size of the joystick's puck
  48129. */
  48130. set puckSize(newSize: number);
  48131. get puckSize(): number;
  48132. /**
  48133. * Clears the set position of the joystick
  48134. */
  48135. clearPosition(): void;
  48136. /**
  48137. * Defines whether or not the joystick container is always visible
  48138. */
  48139. set alwaysVisible(value: boolean);
  48140. get alwaysVisible(): boolean;
  48141. /**
  48142. * Sets the constant position of the Joystick container
  48143. * @param x X axis coordinate
  48144. * @param y Y axis coordinate
  48145. */
  48146. setPosition(x: number, y: number): void;
  48147. /**
  48148. * Defines a callback to call when the joystick is touched
  48149. * @param action defines the callback
  48150. */
  48151. setActionOnTouch(action: () => any): void;
  48152. /**
  48153. * Defines which axis you'd like to control for left & right
  48154. * @param axis defines the axis to use
  48155. */
  48156. setAxisForLeftRight(axis: JoystickAxis): void;
  48157. /**
  48158. * Defines which axis you'd like to control for up & down
  48159. * @param axis defines the axis to use
  48160. */
  48161. setAxisForUpDown(axis: JoystickAxis): void;
  48162. /**
  48163. * Clears the canvas from the previous puck / container draw
  48164. */
  48165. private _clearPreviousDraw;
  48166. /**
  48167. * Loads `urlPath` to be used for the container's image
  48168. * @param urlPath defines the urlPath of an image to use
  48169. */
  48170. setContainerImage(urlPath: string): void;
  48171. /**
  48172. * Loads `urlPath` to be used for the puck's image
  48173. * @param urlPath defines the urlPath of an image to use
  48174. */
  48175. setPuckImage(urlPath: string): void;
  48176. /**
  48177. * Draws the Virtual Joystick's container
  48178. */
  48179. private _drawContainer;
  48180. /**
  48181. * Draws the Virtual Joystick's puck
  48182. */
  48183. private _drawPuck;
  48184. private _drawVirtualJoystick;
  48185. /**
  48186. * Release internal HTML canvas
  48187. */
  48188. releaseCanvas(): void;
  48189. }
  48190. }
  48191. declare module BABYLON {
  48192. interface FreeCameraInputsManager {
  48193. /**
  48194. * Add virtual joystick input support to the input manager.
  48195. * @returns the current input manager
  48196. */
  48197. addVirtualJoystick(): FreeCameraInputsManager;
  48198. }
  48199. /**
  48200. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48201. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48202. */
  48203. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48204. /**
  48205. * Defines the camera the input is attached to.
  48206. */
  48207. camera: FreeCamera;
  48208. private _leftjoystick;
  48209. private _rightjoystick;
  48210. /**
  48211. * Gets the left stick of the virtual joystick.
  48212. * @returns The virtual Joystick
  48213. */
  48214. getLeftJoystick(): VirtualJoystick;
  48215. /**
  48216. * Gets the right stick of the virtual joystick.
  48217. * @returns The virtual Joystick
  48218. */
  48219. getRightJoystick(): VirtualJoystick;
  48220. /**
  48221. * Update the current camera state depending on the inputs that have been used this frame.
  48222. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48223. */
  48224. checkInputs(): void;
  48225. /**
  48226. * Attach the input controls to a specific dom element to get the input from.
  48227. * @param element Defines the element the controls should be listened from
  48228. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48229. */
  48230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48231. /**
  48232. * Detach the current controls from the specified dom element.
  48233. * @param element Defines the element to stop listening the inputs from
  48234. */
  48235. detachControl(element: Nullable<HTMLElement>): void;
  48236. /**
  48237. * Gets the class name of the current intput.
  48238. * @returns the class name
  48239. */
  48240. getClassName(): string;
  48241. /**
  48242. * Get the friendly name associated with the input class.
  48243. * @returns the input friendly name
  48244. */
  48245. getSimpleName(): string;
  48246. }
  48247. }
  48248. declare module BABYLON {
  48249. /**
  48250. * This represents a FPS type of camera controlled by touch.
  48251. * This is like a universal camera minus the Gamepad controls.
  48252. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48253. */
  48254. export class TouchCamera extends FreeCamera {
  48255. /**
  48256. * Defines the touch sensibility for rotation.
  48257. * The higher the faster.
  48258. */
  48259. get touchAngularSensibility(): number;
  48260. set touchAngularSensibility(value: number);
  48261. /**
  48262. * Defines the touch sensibility for move.
  48263. * The higher the faster.
  48264. */
  48265. get touchMoveSensibility(): number;
  48266. set touchMoveSensibility(value: number);
  48267. /**
  48268. * Instantiates a new touch camera.
  48269. * This represents a FPS type of camera controlled by touch.
  48270. * This is like a universal camera minus the Gamepad controls.
  48271. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48272. * @param name Define the name of the camera in the scene
  48273. * @param position Define the start position of the camera in the scene
  48274. * @param scene Define the scene the camera belongs to
  48275. */
  48276. constructor(name: string, position: Vector3, scene: Scene);
  48277. /**
  48278. * Gets the current object class name.
  48279. * @return the class name
  48280. */
  48281. getClassName(): string;
  48282. /** @hidden */
  48283. _setupInputs(): void;
  48284. }
  48285. }
  48286. declare module BABYLON {
  48287. /**
  48288. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48289. * being tilted forward or back and left or right.
  48290. */
  48291. export class DeviceOrientationCamera extends FreeCamera {
  48292. private _initialQuaternion;
  48293. private _quaternionCache;
  48294. private _tmpDragQuaternion;
  48295. private _disablePointerInputWhenUsingDeviceOrientation;
  48296. /**
  48297. * Creates a new device orientation camera
  48298. * @param name The name of the camera
  48299. * @param position The start position camera
  48300. * @param scene The scene the camera belongs to
  48301. */
  48302. constructor(name: string, position: Vector3, scene: Scene);
  48303. /**
  48304. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48305. */
  48306. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48307. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48308. private _dragFactor;
  48309. /**
  48310. * Enabled turning on the y axis when the orientation sensor is active
  48311. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48312. */
  48313. enableHorizontalDragging(dragFactor?: number): void;
  48314. /**
  48315. * Gets the current instance class name ("DeviceOrientationCamera").
  48316. * This helps avoiding instanceof at run time.
  48317. * @returns the class name
  48318. */
  48319. getClassName(): string;
  48320. /**
  48321. * @hidden
  48322. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48323. */
  48324. _checkInputs(): void;
  48325. /**
  48326. * Reset the camera to its default orientation on the specified axis only.
  48327. * @param axis The axis to reset
  48328. */
  48329. resetToCurrentRotation(axis?: Axis): void;
  48330. }
  48331. }
  48332. declare module BABYLON {
  48333. /**
  48334. * Defines supported buttons for XBox360 compatible gamepads
  48335. */
  48336. export enum Xbox360Button {
  48337. /** A */
  48338. A = 0,
  48339. /** B */
  48340. B = 1,
  48341. /** X */
  48342. X = 2,
  48343. /** Y */
  48344. Y = 3,
  48345. /** Left button */
  48346. LB = 4,
  48347. /** Right button */
  48348. RB = 5,
  48349. /** Back */
  48350. Back = 8,
  48351. /** Start */
  48352. Start = 9,
  48353. /** Left stick */
  48354. LeftStick = 10,
  48355. /** Right stick */
  48356. RightStick = 11
  48357. }
  48358. /** Defines values for XBox360 DPad */
  48359. export enum Xbox360Dpad {
  48360. /** Up */
  48361. Up = 12,
  48362. /** Down */
  48363. Down = 13,
  48364. /** Left */
  48365. Left = 14,
  48366. /** Right */
  48367. Right = 15
  48368. }
  48369. /**
  48370. * Defines a XBox360 gamepad
  48371. */
  48372. export class Xbox360Pad extends Gamepad {
  48373. private _leftTrigger;
  48374. private _rightTrigger;
  48375. private _onlefttriggerchanged;
  48376. private _onrighttriggerchanged;
  48377. private _onbuttondown;
  48378. private _onbuttonup;
  48379. private _ondpaddown;
  48380. private _ondpadup;
  48381. /** Observable raised when a button is pressed */
  48382. onButtonDownObservable: Observable<Xbox360Button>;
  48383. /** Observable raised when a button is released */
  48384. onButtonUpObservable: Observable<Xbox360Button>;
  48385. /** Observable raised when a pad is pressed */
  48386. onPadDownObservable: Observable<Xbox360Dpad>;
  48387. /** Observable raised when a pad is released */
  48388. onPadUpObservable: Observable<Xbox360Dpad>;
  48389. private _buttonA;
  48390. private _buttonB;
  48391. private _buttonX;
  48392. private _buttonY;
  48393. private _buttonBack;
  48394. private _buttonStart;
  48395. private _buttonLB;
  48396. private _buttonRB;
  48397. private _buttonLeftStick;
  48398. private _buttonRightStick;
  48399. private _dPadUp;
  48400. private _dPadDown;
  48401. private _dPadLeft;
  48402. private _dPadRight;
  48403. private _isXboxOnePad;
  48404. /**
  48405. * Creates a new XBox360 gamepad object
  48406. * @param id defines the id of this gamepad
  48407. * @param index defines its index
  48408. * @param gamepad defines the internal HTML gamepad object
  48409. * @param xboxOne defines if it is a XBox One gamepad
  48410. */
  48411. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48412. /**
  48413. * Defines the callback to call when left trigger is pressed
  48414. * @param callback defines the callback to use
  48415. */
  48416. onlefttriggerchanged(callback: (value: number) => void): void;
  48417. /**
  48418. * Defines the callback to call when right trigger is pressed
  48419. * @param callback defines the callback to use
  48420. */
  48421. onrighttriggerchanged(callback: (value: number) => void): void;
  48422. /**
  48423. * Gets the left trigger value
  48424. */
  48425. get leftTrigger(): number;
  48426. /**
  48427. * Sets the left trigger value
  48428. */
  48429. set leftTrigger(newValue: number);
  48430. /**
  48431. * Gets the right trigger value
  48432. */
  48433. get rightTrigger(): number;
  48434. /**
  48435. * Sets the right trigger value
  48436. */
  48437. set rightTrigger(newValue: number);
  48438. /**
  48439. * Defines the callback to call when a button is pressed
  48440. * @param callback defines the callback to use
  48441. */
  48442. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48443. /**
  48444. * Defines the callback to call when a button is released
  48445. * @param callback defines the callback to use
  48446. */
  48447. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48448. /**
  48449. * Defines the callback to call when a pad is pressed
  48450. * @param callback defines the callback to use
  48451. */
  48452. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48453. /**
  48454. * Defines the callback to call when a pad is released
  48455. * @param callback defines the callback to use
  48456. */
  48457. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48458. private _setButtonValue;
  48459. private _setDPadValue;
  48460. /**
  48461. * Gets the value of the `A` button
  48462. */
  48463. get buttonA(): number;
  48464. /**
  48465. * Sets the value of the `A` button
  48466. */
  48467. set buttonA(value: number);
  48468. /**
  48469. * Gets the value of the `B` button
  48470. */
  48471. get buttonB(): number;
  48472. /**
  48473. * Sets the value of the `B` button
  48474. */
  48475. set buttonB(value: number);
  48476. /**
  48477. * Gets the value of the `X` button
  48478. */
  48479. get buttonX(): number;
  48480. /**
  48481. * Sets the value of the `X` button
  48482. */
  48483. set buttonX(value: number);
  48484. /**
  48485. * Gets the value of the `Y` button
  48486. */
  48487. get buttonY(): number;
  48488. /**
  48489. * Sets the value of the `Y` button
  48490. */
  48491. set buttonY(value: number);
  48492. /**
  48493. * Gets the value of the `Start` button
  48494. */
  48495. get buttonStart(): number;
  48496. /**
  48497. * Sets the value of the `Start` button
  48498. */
  48499. set buttonStart(value: number);
  48500. /**
  48501. * Gets the value of the `Back` button
  48502. */
  48503. get buttonBack(): number;
  48504. /**
  48505. * Sets the value of the `Back` button
  48506. */
  48507. set buttonBack(value: number);
  48508. /**
  48509. * Gets the value of the `Left` button
  48510. */
  48511. get buttonLB(): number;
  48512. /**
  48513. * Sets the value of the `Left` button
  48514. */
  48515. set buttonLB(value: number);
  48516. /**
  48517. * Gets the value of the `Right` button
  48518. */
  48519. get buttonRB(): number;
  48520. /**
  48521. * Sets the value of the `Right` button
  48522. */
  48523. set buttonRB(value: number);
  48524. /**
  48525. * Gets the value of the Left joystick
  48526. */
  48527. get buttonLeftStick(): number;
  48528. /**
  48529. * Sets the value of the Left joystick
  48530. */
  48531. set buttonLeftStick(value: number);
  48532. /**
  48533. * Gets the value of the Right joystick
  48534. */
  48535. get buttonRightStick(): number;
  48536. /**
  48537. * Sets the value of the Right joystick
  48538. */
  48539. set buttonRightStick(value: number);
  48540. /**
  48541. * Gets the value of D-pad up
  48542. */
  48543. get dPadUp(): number;
  48544. /**
  48545. * Sets the value of D-pad up
  48546. */
  48547. set dPadUp(value: number);
  48548. /**
  48549. * Gets the value of D-pad down
  48550. */
  48551. get dPadDown(): number;
  48552. /**
  48553. * Sets the value of D-pad down
  48554. */
  48555. set dPadDown(value: number);
  48556. /**
  48557. * Gets the value of D-pad left
  48558. */
  48559. get dPadLeft(): number;
  48560. /**
  48561. * Sets the value of D-pad left
  48562. */
  48563. set dPadLeft(value: number);
  48564. /**
  48565. * Gets the value of D-pad right
  48566. */
  48567. get dPadRight(): number;
  48568. /**
  48569. * Sets the value of D-pad right
  48570. */
  48571. set dPadRight(value: number);
  48572. /**
  48573. * Force the gamepad to synchronize with device values
  48574. */
  48575. update(): void;
  48576. /**
  48577. * Disposes the gamepad
  48578. */
  48579. dispose(): void;
  48580. }
  48581. }
  48582. declare module BABYLON {
  48583. /**
  48584. * Defines supported buttons for DualShock compatible gamepads
  48585. */
  48586. export enum DualShockButton {
  48587. /** Cross */
  48588. Cross = 0,
  48589. /** Circle */
  48590. Circle = 1,
  48591. /** Square */
  48592. Square = 2,
  48593. /** Triangle */
  48594. Triangle = 3,
  48595. /** L1 */
  48596. L1 = 4,
  48597. /** R1 */
  48598. R1 = 5,
  48599. /** Share */
  48600. Share = 8,
  48601. /** Options */
  48602. Options = 9,
  48603. /** Left stick */
  48604. LeftStick = 10,
  48605. /** Right stick */
  48606. RightStick = 11
  48607. }
  48608. /** Defines values for DualShock DPad */
  48609. export enum DualShockDpad {
  48610. /** Up */
  48611. Up = 12,
  48612. /** Down */
  48613. Down = 13,
  48614. /** Left */
  48615. Left = 14,
  48616. /** Right */
  48617. Right = 15
  48618. }
  48619. /**
  48620. * Defines a DualShock gamepad
  48621. */
  48622. export class DualShockPad extends Gamepad {
  48623. private _leftTrigger;
  48624. private _rightTrigger;
  48625. private _onlefttriggerchanged;
  48626. private _onrighttriggerchanged;
  48627. private _onbuttondown;
  48628. private _onbuttonup;
  48629. private _ondpaddown;
  48630. private _ondpadup;
  48631. /** Observable raised when a button is pressed */
  48632. onButtonDownObservable: Observable<DualShockButton>;
  48633. /** Observable raised when a button is released */
  48634. onButtonUpObservable: Observable<DualShockButton>;
  48635. /** Observable raised when a pad is pressed */
  48636. onPadDownObservable: Observable<DualShockDpad>;
  48637. /** Observable raised when a pad is released */
  48638. onPadUpObservable: Observable<DualShockDpad>;
  48639. private _buttonCross;
  48640. private _buttonCircle;
  48641. private _buttonSquare;
  48642. private _buttonTriangle;
  48643. private _buttonShare;
  48644. private _buttonOptions;
  48645. private _buttonL1;
  48646. private _buttonR1;
  48647. private _buttonLeftStick;
  48648. private _buttonRightStick;
  48649. private _dPadUp;
  48650. private _dPadDown;
  48651. private _dPadLeft;
  48652. private _dPadRight;
  48653. /**
  48654. * Creates a new DualShock gamepad object
  48655. * @param id defines the id of this gamepad
  48656. * @param index defines its index
  48657. * @param gamepad defines the internal HTML gamepad object
  48658. */
  48659. constructor(id: string, index: number, gamepad: any);
  48660. /**
  48661. * Defines the callback to call when left trigger is pressed
  48662. * @param callback defines the callback to use
  48663. */
  48664. onlefttriggerchanged(callback: (value: number) => void): void;
  48665. /**
  48666. * Defines the callback to call when right trigger is pressed
  48667. * @param callback defines the callback to use
  48668. */
  48669. onrighttriggerchanged(callback: (value: number) => void): void;
  48670. /**
  48671. * Gets the left trigger value
  48672. */
  48673. get leftTrigger(): number;
  48674. /**
  48675. * Sets the left trigger value
  48676. */
  48677. set leftTrigger(newValue: number);
  48678. /**
  48679. * Gets the right trigger value
  48680. */
  48681. get rightTrigger(): number;
  48682. /**
  48683. * Sets the right trigger value
  48684. */
  48685. set rightTrigger(newValue: number);
  48686. /**
  48687. * Defines the callback to call when a button is pressed
  48688. * @param callback defines the callback to use
  48689. */
  48690. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  48691. /**
  48692. * Defines the callback to call when a button is released
  48693. * @param callback defines the callback to use
  48694. */
  48695. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  48696. /**
  48697. * Defines the callback to call when a pad is pressed
  48698. * @param callback defines the callback to use
  48699. */
  48700. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  48701. /**
  48702. * Defines the callback to call when a pad is released
  48703. * @param callback defines the callback to use
  48704. */
  48705. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  48706. private _setButtonValue;
  48707. private _setDPadValue;
  48708. /**
  48709. * Gets the value of the `Cross` button
  48710. */
  48711. get buttonCross(): number;
  48712. /**
  48713. * Sets the value of the `Cross` button
  48714. */
  48715. set buttonCross(value: number);
  48716. /**
  48717. * Gets the value of the `Circle` button
  48718. */
  48719. get buttonCircle(): number;
  48720. /**
  48721. * Sets the value of the `Circle` button
  48722. */
  48723. set buttonCircle(value: number);
  48724. /**
  48725. * Gets the value of the `Square` button
  48726. */
  48727. get buttonSquare(): number;
  48728. /**
  48729. * Sets the value of the `Square` button
  48730. */
  48731. set buttonSquare(value: number);
  48732. /**
  48733. * Gets the value of the `Triangle` button
  48734. */
  48735. get buttonTriangle(): number;
  48736. /**
  48737. * Sets the value of the `Triangle` button
  48738. */
  48739. set buttonTriangle(value: number);
  48740. /**
  48741. * Gets the value of the `Options` button
  48742. */
  48743. get buttonOptions(): number;
  48744. /**
  48745. * Sets the value of the `Options` button
  48746. */
  48747. set buttonOptions(value: number);
  48748. /**
  48749. * Gets the value of the `Share` button
  48750. */
  48751. get buttonShare(): number;
  48752. /**
  48753. * Sets the value of the `Share` button
  48754. */
  48755. set buttonShare(value: number);
  48756. /**
  48757. * Gets the value of the `L1` button
  48758. */
  48759. get buttonL1(): number;
  48760. /**
  48761. * Sets the value of the `L1` button
  48762. */
  48763. set buttonL1(value: number);
  48764. /**
  48765. * Gets the value of the `R1` button
  48766. */
  48767. get buttonR1(): number;
  48768. /**
  48769. * Sets the value of the `R1` button
  48770. */
  48771. set buttonR1(value: number);
  48772. /**
  48773. * Gets the value of the Left joystick
  48774. */
  48775. get buttonLeftStick(): number;
  48776. /**
  48777. * Sets the value of the Left joystick
  48778. */
  48779. set buttonLeftStick(value: number);
  48780. /**
  48781. * Gets the value of the Right joystick
  48782. */
  48783. get buttonRightStick(): number;
  48784. /**
  48785. * Sets the value of the Right joystick
  48786. */
  48787. set buttonRightStick(value: number);
  48788. /**
  48789. * Gets the value of D-pad up
  48790. */
  48791. get dPadUp(): number;
  48792. /**
  48793. * Sets the value of D-pad up
  48794. */
  48795. set dPadUp(value: number);
  48796. /**
  48797. * Gets the value of D-pad down
  48798. */
  48799. get dPadDown(): number;
  48800. /**
  48801. * Sets the value of D-pad down
  48802. */
  48803. set dPadDown(value: number);
  48804. /**
  48805. * Gets the value of D-pad left
  48806. */
  48807. get dPadLeft(): number;
  48808. /**
  48809. * Sets the value of D-pad left
  48810. */
  48811. set dPadLeft(value: number);
  48812. /**
  48813. * Gets the value of D-pad right
  48814. */
  48815. get dPadRight(): number;
  48816. /**
  48817. * Sets the value of D-pad right
  48818. */
  48819. set dPadRight(value: number);
  48820. /**
  48821. * Force the gamepad to synchronize with device values
  48822. */
  48823. update(): void;
  48824. /**
  48825. * Disposes the gamepad
  48826. */
  48827. dispose(): void;
  48828. }
  48829. }
  48830. declare module BABYLON {
  48831. /**
  48832. * Manager for handling gamepads
  48833. */
  48834. export class GamepadManager {
  48835. private _scene?;
  48836. private _babylonGamepads;
  48837. private _oneGamepadConnected;
  48838. /** @hidden */
  48839. _isMonitoring: boolean;
  48840. private _gamepadEventSupported;
  48841. private _gamepadSupport?;
  48842. /**
  48843. * observable to be triggered when the gamepad controller has been connected
  48844. */
  48845. onGamepadConnectedObservable: Observable<Gamepad>;
  48846. /**
  48847. * observable to be triggered when the gamepad controller has been disconnected
  48848. */
  48849. onGamepadDisconnectedObservable: Observable<Gamepad>;
  48850. private _onGamepadConnectedEvent;
  48851. private _onGamepadDisconnectedEvent;
  48852. /**
  48853. * Initializes the gamepad manager
  48854. * @param _scene BabylonJS scene
  48855. */
  48856. constructor(_scene?: Scene | undefined);
  48857. /**
  48858. * The gamepads in the game pad manager
  48859. */
  48860. get gamepads(): Gamepad[];
  48861. /**
  48862. * Get the gamepad controllers based on type
  48863. * @param type The type of gamepad controller
  48864. * @returns Nullable gamepad
  48865. */
  48866. getGamepadByType(type?: number): Nullable<Gamepad>;
  48867. /**
  48868. * Disposes the gamepad manager
  48869. */
  48870. dispose(): void;
  48871. private _addNewGamepad;
  48872. private _startMonitoringGamepads;
  48873. private _stopMonitoringGamepads;
  48874. /** @hidden */
  48875. _checkGamepadsStatus(): void;
  48876. private _updateGamepadObjects;
  48877. }
  48878. }
  48879. declare module BABYLON {
  48880. interface Scene {
  48881. /** @hidden */
  48882. _gamepadManager: Nullable<GamepadManager>;
  48883. /**
  48884. * Gets the gamepad manager associated with the scene
  48885. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  48886. */
  48887. gamepadManager: GamepadManager;
  48888. }
  48889. /**
  48890. * Interface representing a free camera inputs manager
  48891. */
  48892. interface FreeCameraInputsManager {
  48893. /**
  48894. * Adds gamepad input support to the FreeCameraInputsManager.
  48895. * @returns the FreeCameraInputsManager
  48896. */
  48897. addGamepad(): FreeCameraInputsManager;
  48898. }
  48899. /**
  48900. * Interface representing an arc rotate camera inputs manager
  48901. */
  48902. interface ArcRotateCameraInputsManager {
  48903. /**
  48904. * Adds gamepad input support to the ArcRotateCamera InputManager.
  48905. * @returns the camera inputs manager
  48906. */
  48907. addGamepad(): ArcRotateCameraInputsManager;
  48908. }
  48909. /**
  48910. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  48911. */
  48912. export class GamepadSystemSceneComponent implements ISceneComponent {
  48913. /**
  48914. * The component name helpfull to identify the component in the list of scene components.
  48915. */
  48916. readonly name: string;
  48917. /**
  48918. * The scene the component belongs to.
  48919. */
  48920. scene: Scene;
  48921. /**
  48922. * Creates a new instance of the component for the given scene
  48923. * @param scene Defines the scene to register the component in
  48924. */
  48925. constructor(scene: Scene);
  48926. /**
  48927. * Registers the component in a given scene
  48928. */
  48929. register(): void;
  48930. /**
  48931. * Rebuilds the elements related to this component in case of
  48932. * context lost for instance.
  48933. */
  48934. rebuild(): void;
  48935. /**
  48936. * Disposes the component and the associated ressources
  48937. */
  48938. dispose(): void;
  48939. private _beforeCameraUpdate;
  48940. }
  48941. }
  48942. declare module BABYLON {
  48943. /**
  48944. * 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,
  48945. * which still works and will still be found in many Playgrounds.
  48946. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48947. */
  48948. export class UniversalCamera extends TouchCamera {
  48949. /**
  48950. * Defines the gamepad rotation sensiblity.
  48951. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48952. */
  48953. get gamepadAngularSensibility(): number;
  48954. set gamepadAngularSensibility(value: number);
  48955. /**
  48956. * Defines the gamepad move sensiblity.
  48957. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48958. */
  48959. get gamepadMoveSensibility(): number;
  48960. set gamepadMoveSensibility(value: number);
  48961. /**
  48962. * 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,
  48963. * which still works and will still be found in many Playgrounds.
  48964. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48965. * @param name Define the name of the camera in the scene
  48966. * @param position Define the start position of the camera in the scene
  48967. * @param scene Define the scene the camera belongs to
  48968. */
  48969. constructor(name: string, position: Vector3, scene: Scene);
  48970. /**
  48971. * Gets the current object class name.
  48972. * @return the class name
  48973. */
  48974. getClassName(): string;
  48975. }
  48976. }
  48977. declare module BABYLON {
  48978. /**
  48979. * This represents a FPS type of camera. This is only here for back compat purpose.
  48980. * Please use the UniversalCamera instead as both are identical.
  48981. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48982. */
  48983. export class GamepadCamera extends UniversalCamera {
  48984. /**
  48985. * Instantiates a new Gamepad Camera
  48986. * This represents a FPS type of camera. This is only here for back compat purpose.
  48987. * Please use the UniversalCamera instead as both are identical.
  48988. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48989. * @param name Define the name of the camera in the scene
  48990. * @param position Define the start position of the camera in the scene
  48991. * @param scene Define the scene the camera belongs to
  48992. */
  48993. constructor(name: string, position: Vector3, scene: Scene);
  48994. /**
  48995. * Gets the current object class name.
  48996. * @return the class name
  48997. */
  48998. getClassName(): string;
  48999. }
  49000. }
  49001. declare module BABYLON {
  49002. /** @hidden */
  49003. export var passPixelShader: {
  49004. name: string;
  49005. shader: string;
  49006. };
  49007. }
  49008. declare module BABYLON {
  49009. /** @hidden */
  49010. export var passCubePixelShader: {
  49011. name: string;
  49012. shader: string;
  49013. };
  49014. }
  49015. declare module BABYLON {
  49016. /**
  49017. * PassPostProcess which produces an output the same as it's input
  49018. */
  49019. export class PassPostProcess extends PostProcess {
  49020. /**
  49021. * Gets a string identifying the name of the class
  49022. * @returns "PassPostProcess" string
  49023. */
  49024. getClassName(): string;
  49025. /**
  49026. * Creates the PassPostProcess
  49027. * @param name The name of the effect.
  49028. * @param options The required width/height ratio to downsize to before computing the render pass.
  49029. * @param camera The camera to apply the render pass to.
  49030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49031. * @param engine The engine which the post process will be applied. (default: current engine)
  49032. * @param reusable If the post process can be reused on the same frame. (default: false)
  49033. * @param textureType The type of texture to be used when performing the post processing.
  49034. * @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)
  49035. */
  49036. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49037. /** @hidden */
  49038. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49039. }
  49040. /**
  49041. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49042. */
  49043. export class PassCubePostProcess extends PostProcess {
  49044. private _face;
  49045. /**
  49046. * Gets or sets the cube face to display.
  49047. * * 0 is +X
  49048. * * 1 is -X
  49049. * * 2 is +Y
  49050. * * 3 is -Y
  49051. * * 4 is +Z
  49052. * * 5 is -Z
  49053. */
  49054. get face(): number;
  49055. set face(value: number);
  49056. /**
  49057. * Gets a string identifying the name of the class
  49058. * @returns "PassCubePostProcess" string
  49059. */
  49060. getClassName(): string;
  49061. /**
  49062. * Creates the PassCubePostProcess
  49063. * @param name The name of the effect.
  49064. * @param options The required width/height ratio to downsize to before computing the render pass.
  49065. * @param camera The camera to apply the render pass to.
  49066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49067. * @param engine The engine which the post process will be applied. (default: current engine)
  49068. * @param reusable If the post process can be reused on the same frame. (default: false)
  49069. * @param textureType The type of texture to be used when performing the post processing.
  49070. * @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)
  49071. */
  49072. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49073. /** @hidden */
  49074. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49075. }
  49076. }
  49077. declare module BABYLON {
  49078. /** @hidden */
  49079. export var anaglyphPixelShader: {
  49080. name: string;
  49081. shader: string;
  49082. };
  49083. }
  49084. declare module BABYLON {
  49085. /**
  49086. * Postprocess used to generate anaglyphic rendering
  49087. */
  49088. export class AnaglyphPostProcess extends PostProcess {
  49089. private _passedProcess;
  49090. /**
  49091. * Gets a string identifying the name of the class
  49092. * @returns "AnaglyphPostProcess" string
  49093. */
  49094. getClassName(): string;
  49095. /**
  49096. * Creates a new AnaglyphPostProcess
  49097. * @param name defines postprocess name
  49098. * @param options defines creation options or target ratio scale
  49099. * @param rigCameras defines cameras using this postprocess
  49100. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49101. * @param engine defines hosting engine
  49102. * @param reusable defines if the postprocess will be reused multiple times per frame
  49103. */
  49104. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49105. }
  49106. }
  49107. declare module BABYLON {
  49108. /**
  49109. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49110. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49111. */
  49112. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49113. /**
  49114. * Creates a new AnaglyphArcRotateCamera
  49115. * @param name defines camera name
  49116. * @param alpha defines alpha angle (in radians)
  49117. * @param beta defines beta angle (in radians)
  49118. * @param radius defines radius
  49119. * @param target defines camera target
  49120. * @param interaxialDistance defines distance between each color axis
  49121. * @param scene defines the hosting scene
  49122. */
  49123. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49124. /**
  49125. * Gets camera class name
  49126. * @returns AnaglyphArcRotateCamera
  49127. */
  49128. getClassName(): string;
  49129. }
  49130. }
  49131. declare module BABYLON {
  49132. /**
  49133. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49134. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49135. */
  49136. export class AnaglyphFreeCamera extends FreeCamera {
  49137. /**
  49138. * Creates a new AnaglyphFreeCamera
  49139. * @param name defines camera name
  49140. * @param position defines initial position
  49141. * @param interaxialDistance defines distance between each color axis
  49142. * @param scene defines the hosting scene
  49143. */
  49144. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49145. /**
  49146. * Gets camera class name
  49147. * @returns AnaglyphFreeCamera
  49148. */
  49149. getClassName(): string;
  49150. }
  49151. }
  49152. declare module BABYLON {
  49153. /**
  49154. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49155. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49156. */
  49157. export class AnaglyphGamepadCamera extends GamepadCamera {
  49158. /**
  49159. * Creates a new AnaglyphGamepadCamera
  49160. * @param name defines camera name
  49161. * @param position defines initial position
  49162. * @param interaxialDistance defines distance between each color axis
  49163. * @param scene defines the hosting scene
  49164. */
  49165. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49166. /**
  49167. * Gets camera class name
  49168. * @returns AnaglyphGamepadCamera
  49169. */
  49170. getClassName(): string;
  49171. }
  49172. }
  49173. declare module BABYLON {
  49174. /**
  49175. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49176. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49177. */
  49178. export class AnaglyphUniversalCamera extends UniversalCamera {
  49179. /**
  49180. * Creates a new AnaglyphUniversalCamera
  49181. * @param name defines camera name
  49182. * @param position defines initial position
  49183. * @param interaxialDistance defines distance between each color axis
  49184. * @param scene defines the hosting scene
  49185. */
  49186. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49187. /**
  49188. * Gets camera class name
  49189. * @returns AnaglyphUniversalCamera
  49190. */
  49191. getClassName(): string;
  49192. }
  49193. }
  49194. declare module BABYLON {
  49195. /**
  49196. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49197. * @see https://doc.babylonjs.com/features/cameras
  49198. */
  49199. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49200. /**
  49201. * Creates a new StereoscopicArcRotateCamera
  49202. * @param name defines camera name
  49203. * @param alpha defines alpha angle (in radians)
  49204. * @param beta defines beta angle (in radians)
  49205. * @param radius defines radius
  49206. * @param target defines camera target
  49207. * @param interaxialDistance defines distance between each color axis
  49208. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49209. * @param scene defines the hosting scene
  49210. */
  49211. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49212. /**
  49213. * Gets camera class name
  49214. * @returns StereoscopicArcRotateCamera
  49215. */
  49216. getClassName(): string;
  49217. }
  49218. }
  49219. declare module BABYLON {
  49220. /**
  49221. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49222. * @see https://doc.babylonjs.com/features/cameras
  49223. */
  49224. export class StereoscopicFreeCamera extends FreeCamera {
  49225. /**
  49226. * Creates a new StereoscopicFreeCamera
  49227. * @param name defines camera name
  49228. * @param position defines initial position
  49229. * @param interaxialDistance defines distance between each color axis
  49230. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49231. * @param scene defines the hosting scene
  49232. */
  49233. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49234. /**
  49235. * Gets camera class name
  49236. * @returns StereoscopicFreeCamera
  49237. */
  49238. getClassName(): string;
  49239. }
  49240. }
  49241. declare module BABYLON {
  49242. /**
  49243. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49244. * @see https://doc.babylonjs.com/features/cameras
  49245. */
  49246. export class StereoscopicGamepadCamera extends GamepadCamera {
  49247. /**
  49248. * Creates a new StereoscopicGamepadCamera
  49249. * @param name defines camera name
  49250. * @param position defines initial position
  49251. * @param interaxialDistance defines distance between each color axis
  49252. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49253. * @param scene defines the hosting scene
  49254. */
  49255. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49256. /**
  49257. * Gets camera class name
  49258. * @returns StereoscopicGamepadCamera
  49259. */
  49260. getClassName(): string;
  49261. }
  49262. }
  49263. declare module BABYLON {
  49264. /**
  49265. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49266. * @see https://doc.babylonjs.com/features/cameras
  49267. */
  49268. export class StereoscopicUniversalCamera extends UniversalCamera {
  49269. /**
  49270. * Creates a new StereoscopicUniversalCamera
  49271. * @param name defines camera name
  49272. * @param position defines initial position
  49273. * @param interaxialDistance defines distance between each color axis
  49274. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49275. * @param scene defines the hosting scene
  49276. */
  49277. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49278. /**
  49279. * Gets camera class name
  49280. * @returns StereoscopicUniversalCamera
  49281. */
  49282. getClassName(): string;
  49283. }
  49284. }
  49285. declare module BABYLON {
  49286. /**
  49287. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49288. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49289. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49290. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49291. */
  49292. export class VirtualJoysticksCamera extends FreeCamera {
  49293. /**
  49294. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49295. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49296. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49297. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49298. * @param name Define the name of the camera in the scene
  49299. * @param position Define the start position of the camera in the scene
  49300. * @param scene Define the scene the camera belongs to
  49301. */
  49302. constructor(name: string, position: Vector3, scene: Scene);
  49303. /**
  49304. * Gets the current object class name.
  49305. * @return the class name
  49306. */
  49307. getClassName(): string;
  49308. }
  49309. }
  49310. declare module BABYLON {
  49311. /**
  49312. * This represents all the required metrics to create a VR camera.
  49313. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49314. */
  49315. export class VRCameraMetrics {
  49316. /**
  49317. * Define the horizontal resolution off the screen.
  49318. */
  49319. hResolution: number;
  49320. /**
  49321. * Define the vertical resolution off the screen.
  49322. */
  49323. vResolution: number;
  49324. /**
  49325. * Define the horizontal screen size.
  49326. */
  49327. hScreenSize: number;
  49328. /**
  49329. * Define the vertical screen size.
  49330. */
  49331. vScreenSize: number;
  49332. /**
  49333. * Define the vertical screen center position.
  49334. */
  49335. vScreenCenter: number;
  49336. /**
  49337. * Define the distance of the eyes to the screen.
  49338. */
  49339. eyeToScreenDistance: number;
  49340. /**
  49341. * Define the distance between both lenses
  49342. */
  49343. lensSeparationDistance: number;
  49344. /**
  49345. * Define the distance between both viewer's eyes.
  49346. */
  49347. interpupillaryDistance: number;
  49348. /**
  49349. * Define the distortion factor of the VR postprocess.
  49350. * Please, touch with care.
  49351. */
  49352. distortionK: number[];
  49353. /**
  49354. * Define the chromatic aberration correction factors for the VR post process.
  49355. */
  49356. chromaAbCorrection: number[];
  49357. /**
  49358. * Define the scale factor of the post process.
  49359. * The smaller the better but the slower.
  49360. */
  49361. postProcessScaleFactor: number;
  49362. /**
  49363. * Define an offset for the lens center.
  49364. */
  49365. lensCenterOffset: number;
  49366. /**
  49367. * Define if the current vr camera should compensate the distortion of the lense or not.
  49368. */
  49369. compensateDistortion: boolean;
  49370. /**
  49371. * Defines if multiview should be enabled when rendering (Default: false)
  49372. */
  49373. multiviewEnabled: boolean;
  49374. /**
  49375. * Gets the rendering aspect ratio based on the provided resolutions.
  49376. */
  49377. get aspectRatio(): number;
  49378. /**
  49379. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49380. */
  49381. get aspectRatioFov(): number;
  49382. /**
  49383. * @hidden
  49384. */
  49385. get leftHMatrix(): Matrix;
  49386. /**
  49387. * @hidden
  49388. */
  49389. get rightHMatrix(): Matrix;
  49390. /**
  49391. * @hidden
  49392. */
  49393. get leftPreViewMatrix(): Matrix;
  49394. /**
  49395. * @hidden
  49396. */
  49397. get rightPreViewMatrix(): Matrix;
  49398. /**
  49399. * Get the default VRMetrics based on the most generic setup.
  49400. * @returns the default vr metrics
  49401. */
  49402. static GetDefault(): VRCameraMetrics;
  49403. }
  49404. }
  49405. declare module BABYLON {
  49406. /** @hidden */
  49407. export var vrDistortionCorrectionPixelShader: {
  49408. name: string;
  49409. shader: string;
  49410. };
  49411. }
  49412. declare module BABYLON {
  49413. /**
  49414. * VRDistortionCorrectionPostProcess used for mobile VR
  49415. */
  49416. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49417. private _isRightEye;
  49418. private _distortionFactors;
  49419. private _postProcessScaleFactor;
  49420. private _lensCenterOffset;
  49421. private _scaleIn;
  49422. private _scaleFactor;
  49423. private _lensCenter;
  49424. /**
  49425. * Gets a string identifying the name of the class
  49426. * @returns "VRDistortionCorrectionPostProcess" string
  49427. */
  49428. getClassName(): string;
  49429. /**
  49430. * Initializes the VRDistortionCorrectionPostProcess
  49431. * @param name The name of the effect.
  49432. * @param camera The camera to apply the render pass to.
  49433. * @param isRightEye If this is for the right eye distortion
  49434. * @param vrMetrics All the required metrics for the VR camera
  49435. */
  49436. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49437. }
  49438. }
  49439. declare module BABYLON {
  49440. /**
  49441. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49442. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49443. */
  49444. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49445. /**
  49446. * Creates a new VRDeviceOrientationArcRotateCamera
  49447. * @param name defines camera name
  49448. * @param alpha defines the camera rotation along the logitudinal axis
  49449. * @param beta defines the camera rotation along the latitudinal axis
  49450. * @param radius defines the camera distance from its target
  49451. * @param target defines the camera target
  49452. * @param scene defines the scene the camera belongs to
  49453. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49454. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49455. */
  49456. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49457. /**
  49458. * Gets camera class name
  49459. * @returns VRDeviceOrientationArcRotateCamera
  49460. */
  49461. getClassName(): string;
  49462. }
  49463. }
  49464. declare module BABYLON {
  49465. /**
  49466. * Camera used to simulate VR rendering (based on FreeCamera)
  49467. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49468. */
  49469. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49470. /**
  49471. * Creates a new VRDeviceOrientationFreeCamera
  49472. * @param name defines camera name
  49473. * @param position defines the start position of the camera
  49474. * @param scene defines the scene the camera belongs to
  49475. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49476. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49477. */
  49478. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49479. /**
  49480. * Gets camera class name
  49481. * @returns VRDeviceOrientationFreeCamera
  49482. */
  49483. getClassName(): string;
  49484. }
  49485. }
  49486. declare module BABYLON {
  49487. /**
  49488. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49489. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49490. */
  49491. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49492. /**
  49493. * Creates a new VRDeviceOrientationGamepadCamera
  49494. * @param name defines camera name
  49495. * @param position defines the start position of the camera
  49496. * @param scene defines the scene the camera belongs to
  49497. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49498. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49499. */
  49500. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49501. /**
  49502. * Gets camera class name
  49503. * @returns VRDeviceOrientationGamepadCamera
  49504. */
  49505. getClassName(): string;
  49506. }
  49507. }
  49508. declare module BABYLON {
  49509. /**
  49510. * A class extending Texture allowing drawing on a texture
  49511. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49512. */
  49513. export class DynamicTexture extends Texture {
  49514. private _generateMipMaps;
  49515. private _canvas;
  49516. private _context;
  49517. /**
  49518. * Creates a DynamicTexture
  49519. * @param name defines the name of the texture
  49520. * @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
  49521. * @param scene defines the scene where you want the texture
  49522. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49523. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49524. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49525. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49526. */
  49527. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49528. /**
  49529. * Get the current class name of the texture useful for serialization or dynamic coding.
  49530. * @returns "DynamicTexture"
  49531. */
  49532. getClassName(): string;
  49533. /**
  49534. * Gets the current state of canRescale
  49535. */
  49536. get canRescale(): boolean;
  49537. private _recreate;
  49538. /**
  49539. * Scales the texture
  49540. * @param ratio the scale factor to apply to both width and height
  49541. */
  49542. scale(ratio: number): void;
  49543. /**
  49544. * Resizes the texture
  49545. * @param width the new width
  49546. * @param height the new height
  49547. */
  49548. scaleTo(width: number, height: number): void;
  49549. /**
  49550. * Gets the context of the canvas used by the texture
  49551. * @returns the canvas context of the dynamic texture
  49552. */
  49553. getContext(): CanvasRenderingContext2D;
  49554. /**
  49555. * Clears the texture
  49556. */
  49557. clear(): void;
  49558. /**
  49559. * Updates the texture
  49560. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49561. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49562. */
  49563. update(invertY?: boolean, premulAlpha?: boolean): void;
  49564. /**
  49565. * Draws text onto the texture
  49566. * @param text defines the text to be drawn
  49567. * @param x defines the placement of the text from the left
  49568. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49569. * @param font defines the font to be used with font-style, font-size, font-name
  49570. * @param color defines the color used for the text
  49571. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49572. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49573. * @param update defines whether texture is immediately update (default is true)
  49574. */
  49575. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49576. /**
  49577. * Clones the texture
  49578. * @returns the clone of the texture.
  49579. */
  49580. clone(): DynamicTexture;
  49581. /**
  49582. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49583. * @returns a serialized dynamic texture object
  49584. */
  49585. serialize(): any;
  49586. private _IsCanvasElement;
  49587. /** @hidden */
  49588. _rebuild(): void;
  49589. }
  49590. }
  49591. declare module BABYLON {
  49592. /**
  49593. * Class containing static functions to help procedurally build meshes
  49594. */
  49595. export class GroundBuilder {
  49596. /**
  49597. * Creates a ground mesh
  49598. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49599. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49601. * @param name defines the name of the mesh
  49602. * @param options defines the options used to create the mesh
  49603. * @param scene defines the hosting scene
  49604. * @returns the ground mesh
  49605. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49606. */
  49607. static CreateGround(name: string, options: {
  49608. width?: number;
  49609. height?: number;
  49610. subdivisions?: number;
  49611. subdivisionsX?: number;
  49612. subdivisionsY?: number;
  49613. updatable?: boolean;
  49614. }, scene: any): Mesh;
  49615. /**
  49616. * Creates a tiled ground mesh
  49617. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49618. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49619. * * 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
  49620. * * 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
  49621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49622. * @param name defines the name of the mesh
  49623. * @param options defines the options used to create the mesh
  49624. * @param scene defines the hosting scene
  49625. * @returns the tiled ground mesh
  49626. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49627. */
  49628. static CreateTiledGround(name: string, options: {
  49629. xmin: number;
  49630. zmin: number;
  49631. xmax: number;
  49632. zmax: number;
  49633. subdivisions?: {
  49634. w: number;
  49635. h: number;
  49636. };
  49637. precision?: {
  49638. w: number;
  49639. h: number;
  49640. };
  49641. updatable?: boolean;
  49642. }, scene?: Nullable<Scene>): Mesh;
  49643. /**
  49644. * Creates a ground mesh from a height map
  49645. * * The parameter `url` sets the URL of the height map image resource.
  49646. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49647. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49648. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49649. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49650. * * 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.
  49651. * * 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).
  49652. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49654. * @param name defines the name of the mesh
  49655. * @param url defines the url to the height map
  49656. * @param options defines the options used to create the mesh
  49657. * @param scene defines the hosting scene
  49658. * @returns the ground mesh
  49659. * @see https://doc.babylonjs.com/babylon101/height_map
  49660. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49661. */
  49662. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49663. width?: number;
  49664. height?: number;
  49665. subdivisions?: number;
  49666. minHeight?: number;
  49667. maxHeight?: number;
  49668. colorFilter?: Color3;
  49669. alphaFilter?: number;
  49670. updatable?: boolean;
  49671. onReady?: (mesh: GroundMesh) => void;
  49672. }, scene?: Nullable<Scene>): GroundMesh;
  49673. }
  49674. }
  49675. declare module BABYLON {
  49676. /**
  49677. * Class containing static functions to help procedurally build meshes
  49678. */
  49679. export class TorusBuilder {
  49680. /**
  49681. * Creates a torus mesh
  49682. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49683. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49684. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49686. * * 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
  49687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49688. * @param name defines the name of the mesh
  49689. * @param options defines the options used to create the mesh
  49690. * @param scene defines the hosting scene
  49691. * @returns the torus mesh
  49692. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49693. */
  49694. static CreateTorus(name: string, options: {
  49695. diameter?: number;
  49696. thickness?: number;
  49697. tessellation?: number;
  49698. updatable?: boolean;
  49699. sideOrientation?: number;
  49700. frontUVs?: Vector4;
  49701. backUVs?: Vector4;
  49702. }, scene: any): Mesh;
  49703. }
  49704. }
  49705. declare module BABYLON {
  49706. /**
  49707. * Class containing static functions to help procedurally build meshes
  49708. */
  49709. export class CylinderBuilder {
  49710. /**
  49711. * Creates a cylinder or a cone mesh
  49712. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49713. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49714. * * 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.
  49715. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49716. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49717. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49718. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49719. * * 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).
  49720. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49721. * * 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).
  49722. * * 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
  49723. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49724. * * 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
  49725. * * 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.
  49726. * * If `enclose` is false, a ring surface is one element.
  49727. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49728. * * 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
  49729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49730. * * 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
  49731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49732. * @param name defines the name of the mesh
  49733. * @param options defines the options used to create the mesh
  49734. * @param scene defines the hosting scene
  49735. * @returns the cylinder mesh
  49736. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49737. */
  49738. static CreateCylinder(name: string, options: {
  49739. height?: number;
  49740. diameterTop?: number;
  49741. diameterBottom?: number;
  49742. diameter?: number;
  49743. tessellation?: number;
  49744. subdivisions?: number;
  49745. arc?: number;
  49746. faceColors?: Color4[];
  49747. faceUV?: Vector4[];
  49748. updatable?: boolean;
  49749. hasRings?: boolean;
  49750. enclose?: boolean;
  49751. cap?: number;
  49752. sideOrientation?: number;
  49753. frontUVs?: Vector4;
  49754. backUVs?: Vector4;
  49755. }, scene: any): Mesh;
  49756. }
  49757. }
  49758. declare module BABYLON {
  49759. /**
  49760. * States of the webXR experience
  49761. */
  49762. export enum WebXRState {
  49763. /**
  49764. * Transitioning to being in XR mode
  49765. */
  49766. ENTERING_XR = 0,
  49767. /**
  49768. * Transitioning to non XR mode
  49769. */
  49770. EXITING_XR = 1,
  49771. /**
  49772. * In XR mode and presenting
  49773. */
  49774. IN_XR = 2,
  49775. /**
  49776. * Not entered XR mode
  49777. */
  49778. NOT_IN_XR = 3
  49779. }
  49780. /**
  49781. * Abstraction of the XR render target
  49782. */
  49783. export interface WebXRRenderTarget extends IDisposable {
  49784. /**
  49785. * xrpresent context of the canvas which can be used to display/mirror xr content
  49786. */
  49787. canvasContext: WebGLRenderingContext;
  49788. /**
  49789. * xr layer for the canvas
  49790. */
  49791. xrLayer: Nullable<XRWebGLLayer>;
  49792. /**
  49793. * Initializes the xr layer for the session
  49794. * @param xrSession xr session
  49795. * @returns a promise that will resolve once the XR Layer has been created
  49796. */
  49797. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49798. }
  49799. }
  49800. declare module BABYLON {
  49801. /**
  49802. * COnfiguration object for WebXR output canvas
  49803. */
  49804. export class WebXRManagedOutputCanvasOptions {
  49805. /**
  49806. * An optional canvas in case you wish to create it yourself and provide it here.
  49807. * If not provided, a new canvas will be created
  49808. */
  49809. canvasElement?: HTMLCanvasElement;
  49810. /**
  49811. * Options for this XR Layer output
  49812. */
  49813. canvasOptions?: XRWebGLLayerOptions;
  49814. /**
  49815. * CSS styling for a newly created canvas (if not provided)
  49816. */
  49817. newCanvasCssStyle?: string;
  49818. /**
  49819. * Get the default values of the configuration object
  49820. * @param engine defines the engine to use (can be null)
  49821. * @returns default values of this configuration object
  49822. */
  49823. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  49824. }
  49825. /**
  49826. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  49827. */
  49828. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  49829. private _options;
  49830. private _canvas;
  49831. private _engine;
  49832. private _originalCanvasSize;
  49833. /**
  49834. * Rendering context of the canvas which can be used to display/mirror xr content
  49835. */
  49836. canvasContext: WebGLRenderingContext;
  49837. /**
  49838. * xr layer for the canvas
  49839. */
  49840. xrLayer: Nullable<XRWebGLLayer>;
  49841. /**
  49842. * Obseervers registered here will be triggered when the xr layer was initialized
  49843. */
  49844. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  49845. /**
  49846. * Initializes the canvas to be added/removed upon entering/exiting xr
  49847. * @param _xrSessionManager The XR Session manager
  49848. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  49849. */
  49850. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  49851. /**
  49852. * Disposes of the object
  49853. */
  49854. dispose(): void;
  49855. /**
  49856. * Initializes the xr layer for the session
  49857. * @param xrSession xr session
  49858. * @returns a promise that will resolve once the XR Layer has been created
  49859. */
  49860. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49861. private _addCanvas;
  49862. private _removeCanvas;
  49863. private _setCanvasSize;
  49864. private _setManagedOutputCanvas;
  49865. }
  49866. }
  49867. declare module BABYLON {
  49868. /**
  49869. * Manages an XRSession to work with Babylon's engine
  49870. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  49871. */
  49872. export class WebXRSessionManager implements IDisposable {
  49873. /** The scene which the session should be created for */
  49874. scene: Scene;
  49875. private _referenceSpace;
  49876. private _rttProvider;
  49877. private _sessionEnded;
  49878. private _xrNavigator;
  49879. private baseLayer;
  49880. /**
  49881. * The base reference space from which the session started. good if you want to reset your
  49882. * reference space
  49883. */
  49884. baseReferenceSpace: XRReferenceSpace;
  49885. /**
  49886. * Current XR frame
  49887. */
  49888. currentFrame: Nullable<XRFrame>;
  49889. /** WebXR timestamp updated every frame */
  49890. currentTimestamp: number;
  49891. /**
  49892. * Used just in case of a failure to initialize an immersive session.
  49893. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  49894. */
  49895. defaultHeightCompensation: number;
  49896. /**
  49897. * Fires every time a new xrFrame arrives which can be used to update the camera
  49898. */
  49899. onXRFrameObservable: Observable<XRFrame>;
  49900. /**
  49901. * Fires when the reference space changed
  49902. */
  49903. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  49904. /**
  49905. * Fires when the xr session is ended either by the device or manually done
  49906. */
  49907. onXRSessionEnded: Observable<any>;
  49908. /**
  49909. * Fires when the xr session is ended either by the device or manually done
  49910. */
  49911. onXRSessionInit: Observable<XRSession>;
  49912. /**
  49913. * Underlying xr session
  49914. */
  49915. session: XRSession;
  49916. /**
  49917. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  49918. * or get the offset the player is currently at.
  49919. */
  49920. viewerReferenceSpace: XRReferenceSpace;
  49921. /**
  49922. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  49923. * @param scene The scene which the session should be created for
  49924. */
  49925. constructor(
  49926. /** The scene which the session should be created for */
  49927. scene: Scene);
  49928. /**
  49929. * The current reference space used in this session. This reference space can constantly change!
  49930. * It is mainly used to offset the camera's position.
  49931. */
  49932. get referenceSpace(): XRReferenceSpace;
  49933. /**
  49934. * Set a new reference space and triggers the observable
  49935. */
  49936. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  49937. /**
  49938. * Disposes of the session manager
  49939. */
  49940. dispose(): void;
  49941. /**
  49942. * Stops the xrSession and restores the render loop
  49943. * @returns Promise which resolves after it exits XR
  49944. */
  49945. exitXRAsync(): Promise<void>;
  49946. /**
  49947. * Gets the correct render target texture to be rendered this frame for this eye
  49948. * @param eye the eye for which to get the render target
  49949. * @returns the render target for the specified eye
  49950. */
  49951. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  49952. /**
  49953. * Creates a WebXRRenderTarget object for the XR session
  49954. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  49955. * @param options optional options to provide when creating a new render target
  49956. * @returns a WebXR render target to which the session can render
  49957. */
  49958. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  49959. /**
  49960. * Initializes the manager
  49961. * After initialization enterXR can be called to start an XR session
  49962. * @returns Promise which resolves after it is initialized
  49963. */
  49964. initializeAsync(): Promise<void>;
  49965. /**
  49966. * Initializes an xr session
  49967. * @param xrSessionMode mode to initialize
  49968. * @param xrSessionInit defines optional and required values to pass to the session builder
  49969. * @returns a promise which will resolve once the session has been initialized
  49970. */
  49971. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  49972. /**
  49973. * Checks if a session would be supported for the creation options specified
  49974. * @param sessionMode session mode to check if supported eg. immersive-vr
  49975. * @returns A Promise that resolves to true if supported and false if not
  49976. */
  49977. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  49978. /**
  49979. * Resets the reference space to the one started the session
  49980. */
  49981. resetReferenceSpace(): void;
  49982. /**
  49983. * Starts rendering to the xr layer
  49984. */
  49985. runXRRenderLoop(): void;
  49986. /**
  49987. * Sets the reference space on the xr session
  49988. * @param referenceSpaceType space to set
  49989. * @returns a promise that will resolve once the reference space has been set
  49990. */
  49991. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  49992. /**
  49993. * Updates the render state of the session
  49994. * @param state state to set
  49995. * @returns a promise that resolves once the render state has been updated
  49996. */
  49997. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  49998. /**
  49999. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50000. * @param sessionMode defines the session to test
  50001. * @returns a promise with boolean as final value
  50002. */
  50003. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50004. private _createRenderTargetTexture;
  50005. }
  50006. }
  50007. declare module BABYLON {
  50008. /**
  50009. * WebXR Camera which holds the views for the xrSession
  50010. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50011. */
  50012. export class WebXRCamera extends FreeCamera {
  50013. private _xrSessionManager;
  50014. private _firstFrame;
  50015. private _referenceQuaternion;
  50016. private _referencedPosition;
  50017. private _xrInvPositionCache;
  50018. private _xrInvQuaternionCache;
  50019. /**
  50020. * Observable raised before camera teleportation
  50021. */
  50022. onBeforeCameraTeleport: Observable<Vector3>;
  50023. /**
  50024. * Observable raised after camera teleportation
  50025. */
  50026. onAfterCameraTeleport: Observable<Vector3>;
  50027. /**
  50028. * Should position compensation execute on first frame.
  50029. * This is used when copying the position from a native (non XR) camera
  50030. */
  50031. compensateOnFirstFrame: boolean;
  50032. /**
  50033. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50034. * @param name the name of the camera
  50035. * @param scene the scene to add the camera to
  50036. * @param _xrSessionManager a constructed xr session manager
  50037. */
  50038. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50039. /**
  50040. * Return the user's height, unrelated to the current ground.
  50041. * This will be the y position of this camera, when ground level is 0.
  50042. */
  50043. get realWorldHeight(): number;
  50044. /** @hidden */
  50045. _updateForDualEyeDebugging(): void;
  50046. /**
  50047. * Sets this camera's transformation based on a non-vr camera
  50048. * @param otherCamera the non-vr camera to copy the transformation from
  50049. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50050. */
  50051. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50052. /**
  50053. * Gets the current instance class name ("WebXRCamera").
  50054. * @returns the class name
  50055. */
  50056. getClassName(): string;
  50057. private _rotate180;
  50058. private _updateFromXRSession;
  50059. private _updateNumberOfRigCameras;
  50060. private _updateReferenceSpace;
  50061. private _updateReferenceSpaceOffset;
  50062. }
  50063. }
  50064. declare module BABYLON {
  50065. /**
  50066. * Defining the interface required for a (webxr) feature
  50067. */
  50068. export interface IWebXRFeature extends IDisposable {
  50069. /**
  50070. * Is this feature attached
  50071. */
  50072. attached: boolean;
  50073. /**
  50074. * Should auto-attach be disabled?
  50075. */
  50076. disableAutoAttach: boolean;
  50077. /**
  50078. * Attach the feature to the session
  50079. * Will usually be called by the features manager
  50080. *
  50081. * @param force should attachment be forced (even when already attached)
  50082. * @returns true if successful.
  50083. */
  50084. attach(force?: boolean): boolean;
  50085. /**
  50086. * Detach the feature from the session
  50087. * Will usually be called by the features manager
  50088. *
  50089. * @returns true if successful.
  50090. */
  50091. detach(): boolean;
  50092. /**
  50093. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50094. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50095. *
  50096. * @returns whether or not the feature is compatible in this environment
  50097. */
  50098. isCompatible(): boolean;
  50099. /**
  50100. * Was this feature disposed;
  50101. */
  50102. isDisposed: boolean;
  50103. /**
  50104. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50105. */
  50106. xrNativeFeatureName?: string;
  50107. /**
  50108. * A list of (Babylon WebXR) features this feature depends on
  50109. */
  50110. dependsOn?: string[];
  50111. }
  50112. /**
  50113. * A list of the currently available features without referencing them
  50114. */
  50115. export class WebXRFeatureName {
  50116. /**
  50117. * The name of the anchor system feature
  50118. */
  50119. static readonly ANCHOR_SYSTEM: string;
  50120. /**
  50121. * The name of the background remover feature
  50122. */
  50123. static readonly BACKGROUND_REMOVER: string;
  50124. /**
  50125. * The name of the hit test feature
  50126. */
  50127. static readonly HIT_TEST: string;
  50128. /**
  50129. * physics impostors for xr controllers feature
  50130. */
  50131. static readonly PHYSICS_CONTROLLERS: string;
  50132. /**
  50133. * The name of the plane detection feature
  50134. */
  50135. static readonly PLANE_DETECTION: string;
  50136. /**
  50137. * The name of the pointer selection feature
  50138. */
  50139. static readonly POINTER_SELECTION: string;
  50140. /**
  50141. * The name of the teleportation feature
  50142. */
  50143. static readonly TELEPORTATION: string;
  50144. /**
  50145. * The name of the feature points feature.
  50146. */
  50147. static readonly FEATURE_POINTS: string;
  50148. /**
  50149. * The name of the hand tracking feature.
  50150. */
  50151. static readonly HAND_TRACKING: string;
  50152. }
  50153. /**
  50154. * Defining the constructor of a feature. Used to register the modules.
  50155. */
  50156. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50157. /**
  50158. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50159. * It is mainly used in AR sessions.
  50160. *
  50161. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50162. */
  50163. export class WebXRFeaturesManager implements IDisposable {
  50164. private _xrSessionManager;
  50165. private static readonly _AvailableFeatures;
  50166. private _features;
  50167. /**
  50168. * constructs a new features manages.
  50169. *
  50170. * @param _xrSessionManager an instance of WebXRSessionManager
  50171. */
  50172. constructor(_xrSessionManager: WebXRSessionManager);
  50173. /**
  50174. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50175. * Mainly used internally.
  50176. *
  50177. * @param featureName the name of the feature to register
  50178. * @param constructorFunction the function used to construct the module
  50179. * @param version the (babylon) version of the module
  50180. * @param stable is that a stable version of this module
  50181. */
  50182. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50183. /**
  50184. * Returns a constructor of a specific feature.
  50185. *
  50186. * @param featureName the name of the feature to construct
  50187. * @param version the version of the feature to load
  50188. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50189. * @param options optional options provided to the module.
  50190. * @returns a function that, when called, will return a new instance of this feature
  50191. */
  50192. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50193. /**
  50194. * Can be used to return the list of features currently registered
  50195. *
  50196. * @returns an Array of available features
  50197. */
  50198. static GetAvailableFeatures(): string[];
  50199. /**
  50200. * Gets the versions available for a specific feature
  50201. * @param featureName the name of the feature
  50202. * @returns an array with the available versions
  50203. */
  50204. static GetAvailableVersions(featureName: string): string[];
  50205. /**
  50206. * Return the latest unstable version of this feature
  50207. * @param featureName the name of the feature to search
  50208. * @returns the version number. if not found will return -1
  50209. */
  50210. static GetLatestVersionOfFeature(featureName: string): number;
  50211. /**
  50212. * Return the latest stable version of this feature
  50213. * @param featureName the name of the feature to search
  50214. * @returns the version number. if not found will return -1
  50215. */
  50216. static GetStableVersionOfFeature(featureName: string): number;
  50217. /**
  50218. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50219. * Can be used during a session to start a feature
  50220. * @param featureName the name of feature to attach
  50221. */
  50222. attachFeature(featureName: string): void;
  50223. /**
  50224. * Can be used inside a session or when the session ends to detach a specific feature
  50225. * @param featureName the name of the feature to detach
  50226. */
  50227. detachFeature(featureName: string): void;
  50228. /**
  50229. * Used to disable an already-enabled feature
  50230. * The feature will be disposed and will be recreated once enabled.
  50231. * @param featureName the feature to disable
  50232. * @returns true if disable was successful
  50233. */
  50234. disableFeature(featureName: string | {
  50235. Name: string;
  50236. }): boolean;
  50237. /**
  50238. * dispose this features manager
  50239. */
  50240. dispose(): void;
  50241. /**
  50242. * 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.
  50243. * 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.
  50244. *
  50245. * @param featureName the name of the feature to load or the class of the feature
  50246. * @param version optional version to load. if not provided the latest version will be enabled
  50247. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50248. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50249. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50250. * @returns a new constructed feature or throws an error if feature not found.
  50251. */
  50252. enableFeature(featureName: string | {
  50253. Name: string;
  50254. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50255. /**
  50256. * get the implementation of an enabled feature.
  50257. * @param featureName the name of the feature to load
  50258. * @returns the feature class, if found
  50259. */
  50260. getEnabledFeature(featureName: string): IWebXRFeature;
  50261. /**
  50262. * Get the list of enabled features
  50263. * @returns an array of enabled features
  50264. */
  50265. getEnabledFeatures(): string[];
  50266. /**
  50267. * This function will exten the session creation configuration object with enabled features.
  50268. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50269. * according to the defined "required" variable, provided during enableFeature call
  50270. * @param xrSessionInit the xr Session init object to extend
  50271. *
  50272. * @returns an extended XRSessionInit object
  50273. */
  50274. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50275. }
  50276. }
  50277. declare module BABYLON {
  50278. /**
  50279. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50280. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50281. */
  50282. export class WebXRExperienceHelper implements IDisposable {
  50283. private scene;
  50284. private _nonVRCamera;
  50285. private _originalSceneAutoClear;
  50286. private _supported;
  50287. /**
  50288. * Camera used to render xr content
  50289. */
  50290. camera: WebXRCamera;
  50291. /** A features manager for this xr session */
  50292. featuresManager: WebXRFeaturesManager;
  50293. /**
  50294. * Observers registered here will be triggered after the camera's initial transformation is set
  50295. * This can be used to set a different ground level or an extra rotation.
  50296. *
  50297. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50298. * to the position set after this observable is done executing.
  50299. */
  50300. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50301. /**
  50302. * Fires when the state of the experience helper has changed
  50303. */
  50304. onStateChangedObservable: Observable<WebXRState>;
  50305. /** Session manager used to keep track of xr session */
  50306. sessionManager: WebXRSessionManager;
  50307. /**
  50308. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50309. */
  50310. state: WebXRState;
  50311. /**
  50312. * Creates a WebXRExperienceHelper
  50313. * @param scene The scene the helper should be created in
  50314. */
  50315. private constructor();
  50316. /**
  50317. * Creates the experience helper
  50318. * @param scene the scene to attach the experience helper to
  50319. * @returns a promise for the experience helper
  50320. */
  50321. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50322. /**
  50323. * Disposes of the experience helper
  50324. */
  50325. dispose(): void;
  50326. /**
  50327. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50328. * @param sessionMode options for the XR session
  50329. * @param referenceSpaceType frame of reference of the XR session
  50330. * @param renderTarget the output canvas that will be used to enter XR mode
  50331. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50332. * @returns promise that resolves after xr mode has entered
  50333. */
  50334. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50335. /**
  50336. * Exits XR mode and returns the scene to its original state
  50337. * @returns promise that resolves after xr mode has exited
  50338. */
  50339. exitXRAsync(): Promise<void>;
  50340. private _nonXRToXRCamera;
  50341. private _setState;
  50342. }
  50343. }
  50344. declare module BABYLON {
  50345. /**
  50346. * X-Y values for axes in WebXR
  50347. */
  50348. export interface IWebXRMotionControllerAxesValue {
  50349. /**
  50350. * The value of the x axis
  50351. */
  50352. x: number;
  50353. /**
  50354. * The value of the y-axis
  50355. */
  50356. y: number;
  50357. }
  50358. /**
  50359. * changed / previous values for the values of this component
  50360. */
  50361. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50362. /**
  50363. * current (this frame) value
  50364. */
  50365. current: T;
  50366. /**
  50367. * previous (last change) value
  50368. */
  50369. previous: T;
  50370. }
  50371. /**
  50372. * Represents changes in the component between current frame and last values recorded
  50373. */
  50374. export interface IWebXRMotionControllerComponentChanges {
  50375. /**
  50376. * will be populated with previous and current values if axes changed
  50377. */
  50378. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50379. /**
  50380. * will be populated with previous and current values if pressed changed
  50381. */
  50382. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50383. /**
  50384. * will be populated with previous and current values if touched changed
  50385. */
  50386. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50387. /**
  50388. * will be populated with previous and current values if value changed
  50389. */
  50390. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50391. }
  50392. /**
  50393. * This class represents a single component (for example button or thumbstick) of a motion controller
  50394. */
  50395. export class WebXRControllerComponent implements IDisposable {
  50396. /**
  50397. * the id of this component
  50398. */
  50399. id: string;
  50400. /**
  50401. * the type of the component
  50402. */
  50403. type: MotionControllerComponentType;
  50404. private _buttonIndex;
  50405. private _axesIndices;
  50406. private _axes;
  50407. private _changes;
  50408. private _currentValue;
  50409. private _hasChanges;
  50410. private _pressed;
  50411. private _touched;
  50412. /**
  50413. * button component type
  50414. */
  50415. static BUTTON_TYPE: MotionControllerComponentType;
  50416. /**
  50417. * squeeze component type
  50418. */
  50419. static SQUEEZE_TYPE: MotionControllerComponentType;
  50420. /**
  50421. * Thumbstick component type
  50422. */
  50423. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50424. /**
  50425. * Touchpad component type
  50426. */
  50427. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50428. /**
  50429. * trigger component type
  50430. */
  50431. static TRIGGER_TYPE: MotionControllerComponentType;
  50432. /**
  50433. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50434. * the axes data changes
  50435. */
  50436. onAxisValueChangedObservable: Observable<{
  50437. x: number;
  50438. y: number;
  50439. }>;
  50440. /**
  50441. * Observers registered here will be triggered when the state of a button changes
  50442. * State change is either pressed / touched / value
  50443. */
  50444. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50445. /**
  50446. * Creates a new component for a motion controller.
  50447. * It is created by the motion controller itself
  50448. *
  50449. * @param id the id of this component
  50450. * @param type the type of the component
  50451. * @param _buttonIndex index in the buttons array of the gamepad
  50452. * @param _axesIndices indices of the values in the axes array of the gamepad
  50453. */
  50454. constructor(
  50455. /**
  50456. * the id of this component
  50457. */
  50458. id: string,
  50459. /**
  50460. * the type of the component
  50461. */
  50462. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50463. /**
  50464. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50465. */
  50466. get axes(): IWebXRMotionControllerAxesValue;
  50467. /**
  50468. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50469. */
  50470. get changes(): IWebXRMotionControllerComponentChanges;
  50471. /**
  50472. * Return whether or not the component changed the last frame
  50473. */
  50474. get hasChanges(): boolean;
  50475. /**
  50476. * is the button currently pressed
  50477. */
  50478. get pressed(): boolean;
  50479. /**
  50480. * is the button currently touched
  50481. */
  50482. get touched(): boolean;
  50483. /**
  50484. * Get the current value of this component
  50485. */
  50486. get value(): number;
  50487. /**
  50488. * Dispose this component
  50489. */
  50490. dispose(): void;
  50491. /**
  50492. * Are there axes correlating to this component
  50493. * @return true is axes data is available
  50494. */
  50495. isAxes(): boolean;
  50496. /**
  50497. * Is this component a button (hence - pressable)
  50498. * @returns true if can be pressed
  50499. */
  50500. isButton(): boolean;
  50501. /**
  50502. * update this component using the gamepad object it is in. Called on every frame
  50503. * @param nativeController the native gamepad controller object
  50504. */
  50505. update(nativeController: IMinimalMotionControllerObject): void;
  50506. }
  50507. }
  50508. declare module BABYLON {
  50509. /**
  50510. * Interface used to represent data loading progression
  50511. */
  50512. export interface ISceneLoaderProgressEvent {
  50513. /**
  50514. * Defines if data length to load can be evaluated
  50515. */
  50516. readonly lengthComputable: boolean;
  50517. /**
  50518. * Defines the loaded data length
  50519. */
  50520. readonly loaded: number;
  50521. /**
  50522. * Defines the data length to load
  50523. */
  50524. readonly total: number;
  50525. }
  50526. /**
  50527. * Interface used by SceneLoader plugins to define supported file extensions
  50528. */
  50529. export interface ISceneLoaderPluginExtensions {
  50530. /**
  50531. * Defines the list of supported extensions
  50532. */
  50533. [extension: string]: {
  50534. isBinary: boolean;
  50535. };
  50536. }
  50537. /**
  50538. * Interface used by SceneLoader plugin factory
  50539. */
  50540. export interface ISceneLoaderPluginFactory {
  50541. /**
  50542. * Defines the name of the factory
  50543. */
  50544. name: string;
  50545. /**
  50546. * Function called to create a new plugin
  50547. * @return the new plugin
  50548. */
  50549. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50550. /**
  50551. * The callback that returns true if the data can be directly loaded.
  50552. * @param data string containing the file data
  50553. * @returns if the data can be loaded directly
  50554. */
  50555. canDirectLoad?(data: string): boolean;
  50556. }
  50557. /**
  50558. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  50559. */
  50560. export interface ISceneLoaderPluginBase {
  50561. /**
  50562. * The friendly name of this plugin.
  50563. */
  50564. name: string;
  50565. /**
  50566. * The file extensions supported by this plugin.
  50567. */
  50568. extensions: string | ISceneLoaderPluginExtensions;
  50569. /**
  50570. * The callback called when loading from a url.
  50571. * @param scene scene loading this url
  50572. * @param url url to load
  50573. * @param onSuccess callback called when the file successfully loads
  50574. * @param onProgress callback called while file is loading (if the server supports this mode)
  50575. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  50576. * @param onError callback called when the file fails to load
  50577. * @returns a file request object
  50578. */
  50579. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50580. /**
  50581. * The callback called when loading from a file object.
  50582. * @param scene scene loading this file
  50583. * @param file defines the file to load
  50584. * @param onSuccess defines the callback to call when data is loaded
  50585. * @param onProgress defines the callback to call during loading process
  50586. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  50587. * @param onError defines the callback to call when an error occurs
  50588. * @returns a file request object
  50589. */
  50590. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50591. /**
  50592. * The callback that returns true if the data can be directly loaded.
  50593. * @param data string containing the file data
  50594. * @returns if the data can be loaded directly
  50595. */
  50596. canDirectLoad?(data: string): boolean;
  50597. /**
  50598. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  50599. * @param scene scene loading this data
  50600. * @param data string containing the data
  50601. * @returns data to pass to the plugin
  50602. */
  50603. directLoad?(scene: Scene, data: string): any;
  50604. /**
  50605. * The callback that allows custom handling of the root url based on the response url.
  50606. * @param rootUrl the original root url
  50607. * @param responseURL the response url if available
  50608. * @returns the new root url
  50609. */
  50610. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  50611. }
  50612. /**
  50613. * Interface used to define a SceneLoader plugin
  50614. */
  50615. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  50616. /**
  50617. * Import meshes into a scene.
  50618. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50619. * @param scene The scene to import into
  50620. * @param data The data to import
  50621. * @param rootUrl The root url for scene and resources
  50622. * @param meshes The meshes array to import into
  50623. * @param particleSystems The particle systems array to import into
  50624. * @param skeletons The skeletons array to import into
  50625. * @param onError The callback when import fails
  50626. * @returns True if successful or false otherwise
  50627. */
  50628. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  50629. /**
  50630. * Load into a scene.
  50631. * @param scene The scene to load into
  50632. * @param data The data to import
  50633. * @param rootUrl The root url for scene and resources
  50634. * @param onError The callback when import fails
  50635. * @returns True if successful or false otherwise
  50636. */
  50637. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  50638. /**
  50639. * Load into an asset container.
  50640. * @param scene The scene to load into
  50641. * @param data The data to import
  50642. * @param rootUrl The root url for scene and resources
  50643. * @param onError The callback when import fails
  50644. * @returns The loaded asset container
  50645. */
  50646. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  50647. }
  50648. /**
  50649. * Interface used to define an async SceneLoader plugin
  50650. */
  50651. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  50652. /**
  50653. * Import meshes into a scene.
  50654. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50655. * @param scene The scene to import into
  50656. * @param data The data to import
  50657. * @param rootUrl The root url for scene and resources
  50658. * @param onProgress The callback when the load progresses
  50659. * @param fileName Defines the name of the file to load
  50660. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  50661. */
  50662. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  50663. meshes: AbstractMesh[];
  50664. particleSystems: IParticleSystem[];
  50665. skeletons: Skeleton[];
  50666. animationGroups: AnimationGroup[];
  50667. }>;
  50668. /**
  50669. * Load into a scene.
  50670. * @param scene The scene to load into
  50671. * @param data The data to import
  50672. * @param rootUrl The root url for scene and resources
  50673. * @param onProgress The callback when the load progresses
  50674. * @param fileName Defines the name of the file to load
  50675. * @returns Nothing
  50676. */
  50677. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  50678. /**
  50679. * Load into an asset container.
  50680. * @param scene The scene to load into
  50681. * @param data The data to import
  50682. * @param rootUrl The root url for scene and resources
  50683. * @param onProgress The callback when the load progresses
  50684. * @param fileName Defines the name of the file to load
  50685. * @returns The loaded asset container
  50686. */
  50687. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  50688. }
  50689. /**
  50690. * Mode that determines how to handle old animation groups before loading new ones.
  50691. */
  50692. export enum SceneLoaderAnimationGroupLoadingMode {
  50693. /**
  50694. * Reset all old animations to initial state then dispose them.
  50695. */
  50696. Clean = 0,
  50697. /**
  50698. * Stop all old animations.
  50699. */
  50700. Stop = 1,
  50701. /**
  50702. * Restart old animations from first frame.
  50703. */
  50704. Sync = 2,
  50705. /**
  50706. * Old animations remains untouched.
  50707. */
  50708. NoSync = 3
  50709. }
  50710. /**
  50711. * Defines a plugin registered by the SceneLoader
  50712. */
  50713. interface IRegisteredPlugin {
  50714. /**
  50715. * Defines the plugin to use
  50716. */
  50717. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50718. /**
  50719. * Defines if the plugin supports binary data
  50720. */
  50721. isBinary: boolean;
  50722. }
  50723. /**
  50724. * Class used to load scene from various file formats using registered plugins
  50725. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  50726. */
  50727. export class SceneLoader {
  50728. /**
  50729. * No logging while loading
  50730. */
  50731. static readonly NO_LOGGING: number;
  50732. /**
  50733. * Minimal logging while loading
  50734. */
  50735. static readonly MINIMAL_LOGGING: number;
  50736. /**
  50737. * Summary logging while loading
  50738. */
  50739. static readonly SUMMARY_LOGGING: number;
  50740. /**
  50741. * Detailled logging while loading
  50742. */
  50743. static readonly DETAILED_LOGGING: number;
  50744. /**
  50745. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50746. */
  50747. static get ForceFullSceneLoadingForIncremental(): boolean;
  50748. static set ForceFullSceneLoadingForIncremental(value: boolean);
  50749. /**
  50750. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50751. */
  50752. static get ShowLoadingScreen(): boolean;
  50753. static set ShowLoadingScreen(value: boolean);
  50754. /**
  50755. * Defines the current logging level (while loading the scene)
  50756. * @ignorenaming
  50757. */
  50758. static get loggingLevel(): number;
  50759. static set loggingLevel(value: number);
  50760. /**
  50761. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50762. */
  50763. static get CleanBoneMatrixWeights(): boolean;
  50764. static set CleanBoneMatrixWeights(value: boolean);
  50765. /**
  50766. * Event raised when a plugin is used to load a scene
  50767. */
  50768. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  50769. private static _registeredPlugins;
  50770. private static _showingLoadingScreen;
  50771. /**
  50772. * Gets the default plugin (used to load Babylon files)
  50773. * @returns the .babylon plugin
  50774. */
  50775. static GetDefaultPlugin(): IRegisteredPlugin;
  50776. private static _GetPluginForExtension;
  50777. private static _GetPluginForDirectLoad;
  50778. private static _GetPluginForFilename;
  50779. private static _GetDirectLoad;
  50780. private static _LoadData;
  50781. private static _GetFileInfo;
  50782. /**
  50783. * Gets a plugin that can load the given extension
  50784. * @param extension defines the extension to load
  50785. * @returns a plugin or null if none works
  50786. */
  50787. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50788. /**
  50789. * Gets a boolean indicating that the given extension can be loaded
  50790. * @param extension defines the extension to load
  50791. * @returns true if the extension is supported
  50792. */
  50793. static IsPluginForExtensionAvailable(extension: string): boolean;
  50794. /**
  50795. * Adds a new plugin to the list of registered plugins
  50796. * @param plugin defines the plugin to add
  50797. */
  50798. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  50799. /**
  50800. * Import meshes into a scene
  50801. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50802. * @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)
  50803. * @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)
  50804. * @param scene the instance of BABYLON.Scene to append to
  50805. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  50806. * @param onProgress a callback with a progress event for each file being loaded
  50807. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50808. * @param pluginExtension the extension used to determine the plugin
  50809. * @returns The loaded plugin
  50810. */
  50811. 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>;
  50812. /**
  50813. * Import meshes into a scene
  50814. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50815. * @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)
  50816. * @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)
  50817. * @param scene the instance of BABYLON.Scene to append to
  50818. * @param onProgress a callback with a progress event for each file being loaded
  50819. * @param pluginExtension the extension used to determine the plugin
  50820. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  50821. */
  50822. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  50823. meshes: AbstractMesh[];
  50824. particleSystems: IParticleSystem[];
  50825. skeletons: Skeleton[];
  50826. animationGroups: AnimationGroup[];
  50827. }>;
  50828. /**
  50829. * Load a scene
  50830. * @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)
  50831. * @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)
  50832. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50833. * @param onSuccess a callback with the scene when import succeeds
  50834. * @param onProgress a callback with a progress event for each file being loaded
  50835. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50836. * @param pluginExtension the extension used to determine the plugin
  50837. * @returns The loaded plugin
  50838. */
  50839. 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>;
  50840. /**
  50841. * Load a scene
  50842. * @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)
  50843. * @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)
  50844. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50845. * @param onProgress a callback with a progress event for each file being loaded
  50846. * @param pluginExtension the extension used to determine the plugin
  50847. * @returns The loaded scene
  50848. */
  50849. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  50850. /**
  50851. * Append a scene
  50852. * @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)
  50853. * @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)
  50854. * @param scene is the instance of BABYLON.Scene to append to
  50855. * @param onSuccess a callback with the scene when import succeeds
  50856. * @param onProgress a callback with a progress event for each file being loaded
  50857. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50858. * @param pluginExtension the extension used to determine the plugin
  50859. * @returns The loaded plugin
  50860. */
  50861. 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>;
  50862. /**
  50863. * Append a scene
  50864. * @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)
  50865. * @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)
  50866. * @param scene is the instance of BABYLON.Scene to append to
  50867. * @param onProgress a callback with a progress event for each file being loaded
  50868. * @param pluginExtension the extension used to determine the plugin
  50869. * @returns The given scene
  50870. */
  50871. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  50872. /**
  50873. * Load a scene into an asset container
  50874. * @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)
  50875. * @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)
  50876. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50877. * @param onSuccess a callback with the scene when import succeeds
  50878. * @param onProgress a callback with a progress event for each file being loaded
  50879. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50880. * @param pluginExtension the extension used to determine the plugin
  50881. * @returns The loaded plugin
  50882. */
  50883. 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>;
  50884. /**
  50885. * Load a scene into an asset container
  50886. * @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)
  50887. * @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)
  50888. * @param scene is the instance of Scene to append to
  50889. * @param onProgress a callback with a progress event for each file being loaded
  50890. * @param pluginExtension the extension used to determine the plugin
  50891. * @returns The loaded asset container
  50892. */
  50893. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  50894. /**
  50895. * Import animations from a file into a scene
  50896. * @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)
  50897. * @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)
  50898. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50899. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  50900. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  50901. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  50902. * @param onSuccess a callback with the scene when import succeeds
  50903. * @param onProgress a callback with a progress event for each file being loaded
  50904. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50905. * @param pluginExtension the extension used to determine the plugin
  50906. */
  50907. 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;
  50908. /**
  50909. * Import animations from a file into a scene
  50910. * @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)
  50911. * @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)
  50912. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50913. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  50914. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  50915. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  50916. * @param onSuccess a callback with the scene when import succeeds
  50917. * @param onProgress a callback with a progress event for each file being loaded
  50918. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50919. * @param pluginExtension the extension used to determine the plugin
  50920. * @returns the updated scene with imported animations
  50921. */
  50922. 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>;
  50923. }
  50924. }
  50925. declare module BABYLON {
  50926. /**
  50927. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  50928. */
  50929. export type MotionControllerHandedness = "none" | "left" | "right";
  50930. /**
  50931. * The type of components available in motion controllers.
  50932. * This is not the name of the component.
  50933. */
  50934. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  50935. /**
  50936. * The state of a controller component
  50937. */
  50938. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  50939. /**
  50940. * The schema of motion controller layout.
  50941. * No object will be initialized using this interface
  50942. * This is used just to define the profile.
  50943. */
  50944. export interface IMotionControllerLayout {
  50945. /**
  50946. * Path to load the assets. Usually relative to the base path
  50947. */
  50948. assetPath: string;
  50949. /**
  50950. * Available components (unsorted)
  50951. */
  50952. components: {
  50953. /**
  50954. * A map of component Ids
  50955. */
  50956. [componentId: string]: {
  50957. /**
  50958. * The type of input the component outputs
  50959. */
  50960. type: MotionControllerComponentType;
  50961. /**
  50962. * The indices of this component in the gamepad object
  50963. */
  50964. gamepadIndices: {
  50965. /**
  50966. * Index of button
  50967. */
  50968. button?: number;
  50969. /**
  50970. * If available, index of x-axis
  50971. */
  50972. xAxis?: number;
  50973. /**
  50974. * If available, index of y-axis
  50975. */
  50976. yAxis?: number;
  50977. };
  50978. /**
  50979. * The mesh's root node name
  50980. */
  50981. rootNodeName: string;
  50982. /**
  50983. * Animation definitions for this model
  50984. */
  50985. visualResponses: {
  50986. [stateKey: string]: {
  50987. /**
  50988. * What property will be animated
  50989. */
  50990. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  50991. /**
  50992. * What states influence this visual response
  50993. */
  50994. states: MotionControllerComponentStateType[];
  50995. /**
  50996. * Type of animation - movement or visibility
  50997. */
  50998. valueNodeProperty: "transform" | "visibility";
  50999. /**
  51000. * Base node name to move. Its position will be calculated according to the min and max nodes
  51001. */
  51002. valueNodeName?: string;
  51003. /**
  51004. * Minimum movement node
  51005. */
  51006. minNodeName?: string;
  51007. /**
  51008. * Max movement node
  51009. */
  51010. maxNodeName?: string;
  51011. };
  51012. };
  51013. /**
  51014. * If touch enabled, what is the name of node to display user feedback
  51015. */
  51016. touchPointNodeName?: string;
  51017. };
  51018. };
  51019. /**
  51020. * Is it xr standard mapping or not
  51021. */
  51022. gamepadMapping: "" | "xr-standard";
  51023. /**
  51024. * Base root node of this entire model
  51025. */
  51026. rootNodeName: string;
  51027. /**
  51028. * Defines the main button component id
  51029. */
  51030. selectComponentId: string;
  51031. }
  51032. /**
  51033. * A definition for the layout map in the input profile
  51034. */
  51035. export interface IMotionControllerLayoutMap {
  51036. /**
  51037. * Layouts with handedness type as a key
  51038. */
  51039. [handedness: string]: IMotionControllerLayout;
  51040. }
  51041. /**
  51042. * The XR Input profile schema
  51043. * Profiles can be found here:
  51044. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51045. */
  51046. export interface IMotionControllerProfile {
  51047. /**
  51048. * fallback profiles for this profileId
  51049. */
  51050. fallbackProfileIds: string[];
  51051. /**
  51052. * The layout map, with handedness as key
  51053. */
  51054. layouts: IMotionControllerLayoutMap;
  51055. /**
  51056. * The id of this profile
  51057. * correlates to the profile(s) in the xrInput.profiles array
  51058. */
  51059. profileId: string;
  51060. }
  51061. /**
  51062. * A helper-interface for the 3 meshes needed for controller button animation
  51063. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51064. */
  51065. export interface IMotionControllerButtonMeshMap {
  51066. /**
  51067. * the mesh that defines the pressed value mesh position.
  51068. * This is used to find the max-position of this button
  51069. */
  51070. pressedMesh: AbstractMesh;
  51071. /**
  51072. * the mesh that defines the unpressed value mesh position.
  51073. * This is used to find the min (or initial) position of this button
  51074. */
  51075. unpressedMesh: AbstractMesh;
  51076. /**
  51077. * The mesh that will be changed when value changes
  51078. */
  51079. valueMesh: AbstractMesh;
  51080. }
  51081. /**
  51082. * A helper-interface for the 3 meshes needed for controller axis animation.
  51083. * This will be expanded when touchpad animations are fully supported
  51084. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51085. */
  51086. export interface IMotionControllerMeshMap {
  51087. /**
  51088. * the mesh that defines the maximum value mesh position.
  51089. */
  51090. maxMesh?: AbstractMesh;
  51091. /**
  51092. * the mesh that defines the minimum value mesh position.
  51093. */
  51094. minMesh?: AbstractMesh;
  51095. /**
  51096. * The mesh that will be changed when axis value changes
  51097. */
  51098. valueMesh?: AbstractMesh;
  51099. }
  51100. /**
  51101. * The elements needed for change-detection of the gamepad objects in motion controllers
  51102. */
  51103. export interface IMinimalMotionControllerObject {
  51104. /**
  51105. * Available axes of this controller
  51106. */
  51107. axes: number[];
  51108. /**
  51109. * An array of available buttons
  51110. */
  51111. buttons: Array<{
  51112. /**
  51113. * Value of the button/trigger
  51114. */
  51115. value: number;
  51116. /**
  51117. * If the button/trigger is currently touched
  51118. */
  51119. touched: boolean;
  51120. /**
  51121. * If the button/trigger is currently pressed
  51122. */
  51123. pressed: boolean;
  51124. }>;
  51125. /**
  51126. * EXPERIMENTAL haptic support.
  51127. */
  51128. hapticActuators?: Array<{
  51129. pulse: (value: number, duration: number) => Promise<boolean>;
  51130. }>;
  51131. }
  51132. /**
  51133. * An Abstract Motion controller
  51134. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51135. * Each component has an observable to check for changes in value and state
  51136. */
  51137. export abstract class WebXRAbstractMotionController implements IDisposable {
  51138. protected scene: Scene;
  51139. protected layout: IMotionControllerLayout;
  51140. /**
  51141. * The gamepad object correlating to this controller
  51142. */
  51143. gamepadObject: IMinimalMotionControllerObject;
  51144. /**
  51145. * handedness (left/right/none) of this controller
  51146. */
  51147. handedness: MotionControllerHandedness;
  51148. private _initComponent;
  51149. private _modelReady;
  51150. /**
  51151. * A map of components (WebXRControllerComponent) in this motion controller
  51152. * Components have a ComponentType and can also have both button and axis definitions
  51153. */
  51154. readonly components: {
  51155. [id: string]: WebXRControllerComponent;
  51156. };
  51157. /**
  51158. * Disable the model's animation. Can be set at any time.
  51159. */
  51160. disableAnimation: boolean;
  51161. /**
  51162. * Observers registered here will be triggered when the model of this controller is done loading
  51163. */
  51164. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51165. /**
  51166. * The profile id of this motion controller
  51167. */
  51168. abstract profileId: string;
  51169. /**
  51170. * The root mesh of the model. It is null if the model was not yet initialized
  51171. */
  51172. rootMesh: Nullable<AbstractMesh>;
  51173. /**
  51174. * constructs a new abstract motion controller
  51175. * @param scene the scene to which the model of the controller will be added
  51176. * @param layout The profile layout to load
  51177. * @param gamepadObject The gamepad object correlating to this controller
  51178. * @param handedness handedness (left/right/none) of this controller
  51179. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51180. */
  51181. constructor(scene: Scene, layout: IMotionControllerLayout,
  51182. /**
  51183. * The gamepad object correlating to this controller
  51184. */
  51185. gamepadObject: IMinimalMotionControllerObject,
  51186. /**
  51187. * handedness (left/right/none) of this controller
  51188. */
  51189. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51190. /**
  51191. * Dispose this controller, the model mesh and all its components
  51192. */
  51193. dispose(): void;
  51194. /**
  51195. * Returns all components of specific type
  51196. * @param type the type to search for
  51197. * @return an array of components with this type
  51198. */
  51199. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51200. /**
  51201. * get a component based an its component id as defined in layout.components
  51202. * @param id the id of the component
  51203. * @returns the component correlates to the id or undefined if not found
  51204. */
  51205. getComponent(id: string): WebXRControllerComponent;
  51206. /**
  51207. * Get the list of components available in this motion controller
  51208. * @returns an array of strings correlating to available components
  51209. */
  51210. getComponentIds(): string[];
  51211. /**
  51212. * Get the first component of specific type
  51213. * @param type type of component to find
  51214. * @return a controller component or null if not found
  51215. */
  51216. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51217. /**
  51218. * Get the main (Select) component of this controller as defined in the layout
  51219. * @returns the main component of this controller
  51220. */
  51221. getMainComponent(): WebXRControllerComponent;
  51222. /**
  51223. * Loads the model correlating to this controller
  51224. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51225. * @returns A promise fulfilled with the result of the model loading
  51226. */
  51227. loadModel(): Promise<boolean>;
  51228. /**
  51229. * Update this model using the current XRFrame
  51230. * @param xrFrame the current xr frame to use and update the model
  51231. */
  51232. updateFromXRFrame(xrFrame: XRFrame): void;
  51233. /**
  51234. * Backwards compatibility due to a deeply-integrated typo
  51235. */
  51236. get handness(): XREye;
  51237. /**
  51238. * Pulse (vibrate) this controller
  51239. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51240. * Consecutive calls to this function will cancel the last pulse call
  51241. *
  51242. * @param value the strength of the pulse in 0.0...1.0 range
  51243. * @param duration Duration of the pulse in milliseconds
  51244. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51245. * @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
  51246. */
  51247. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51248. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51249. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51250. /**
  51251. * Moves the axis on the controller mesh based on its current state
  51252. * @param axis the index of the axis
  51253. * @param axisValue the value of the axis which determines the meshes new position
  51254. * @hidden
  51255. */
  51256. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51257. /**
  51258. * Update the model itself with the current frame data
  51259. * @param xrFrame the frame to use for updating the model mesh
  51260. */
  51261. protected updateModel(xrFrame: XRFrame): void;
  51262. /**
  51263. * Get the filename and path for this controller's model
  51264. * @returns a map of filename and path
  51265. */
  51266. protected abstract _getFilenameAndPath(): {
  51267. filename: string;
  51268. path: string;
  51269. };
  51270. /**
  51271. * This function is called before the mesh is loaded. It checks for loading constraints.
  51272. * For example, this function can check if the GLB loader is available
  51273. * If this function returns false, the generic controller will be loaded instead
  51274. * @returns Is the client ready to load the mesh
  51275. */
  51276. protected abstract _getModelLoadingConstraints(): boolean;
  51277. /**
  51278. * This function will be called after the model was successfully loaded and can be used
  51279. * for mesh transformations before it is available for the user
  51280. * @param meshes the loaded meshes
  51281. */
  51282. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51283. /**
  51284. * Set the root mesh for this controller. Important for the WebXR controller class
  51285. * @param meshes the loaded meshes
  51286. */
  51287. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51288. /**
  51289. * A function executed each frame that updates the mesh (if needed)
  51290. * @param xrFrame the current xrFrame
  51291. */
  51292. protected abstract _updateModel(xrFrame: XRFrame): void;
  51293. private _getGenericFilenameAndPath;
  51294. private _getGenericParentMesh;
  51295. }
  51296. }
  51297. declare module BABYLON {
  51298. /**
  51299. * A generic trigger-only motion controller for WebXR
  51300. */
  51301. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51302. /**
  51303. * Static version of the profile id of this controller
  51304. */
  51305. static ProfileId: string;
  51306. profileId: string;
  51307. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51308. protected _getFilenameAndPath(): {
  51309. filename: string;
  51310. path: string;
  51311. };
  51312. protected _getModelLoadingConstraints(): boolean;
  51313. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51314. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51315. protected _updateModel(): void;
  51316. }
  51317. }
  51318. declare module BABYLON {
  51319. /**
  51320. * Class containing static functions to help procedurally build meshes
  51321. */
  51322. export class SphereBuilder {
  51323. /**
  51324. * Creates a sphere mesh
  51325. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51326. * * 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`)
  51327. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51328. * * 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
  51329. * * 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)
  51330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51331. * * 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
  51332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51333. * @param name defines the name of the mesh
  51334. * @param options defines the options used to create the mesh
  51335. * @param scene defines the hosting scene
  51336. * @returns the sphere mesh
  51337. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51338. */
  51339. static CreateSphere(name: string, options: {
  51340. segments?: number;
  51341. diameter?: number;
  51342. diameterX?: number;
  51343. diameterY?: number;
  51344. diameterZ?: number;
  51345. arc?: number;
  51346. slice?: number;
  51347. sideOrientation?: number;
  51348. frontUVs?: Vector4;
  51349. backUVs?: Vector4;
  51350. updatable?: boolean;
  51351. }, scene?: Nullable<Scene>): Mesh;
  51352. }
  51353. }
  51354. declare module BABYLON {
  51355. /**
  51356. * A profiled motion controller has its profile loaded from an online repository.
  51357. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51358. */
  51359. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51360. private _repositoryUrl;
  51361. private _buttonMeshMapping;
  51362. private _touchDots;
  51363. /**
  51364. * The profile ID of this controller. Will be populated when the controller initializes.
  51365. */
  51366. profileId: string;
  51367. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51368. dispose(): void;
  51369. protected _getFilenameAndPath(): {
  51370. filename: string;
  51371. path: string;
  51372. };
  51373. protected _getModelLoadingConstraints(): boolean;
  51374. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51375. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51376. protected _updateModel(_xrFrame: XRFrame): void;
  51377. }
  51378. }
  51379. declare module BABYLON {
  51380. /**
  51381. * A construction function type to create a new controller based on an xrInput object
  51382. */
  51383. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51384. /**
  51385. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51386. *
  51387. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51388. * it should be replaced with auto-loaded controllers.
  51389. *
  51390. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51391. */
  51392. export class WebXRMotionControllerManager {
  51393. private static _AvailableControllers;
  51394. private static _Fallbacks;
  51395. private static _ProfileLoadingPromises;
  51396. private static _ProfilesList;
  51397. /**
  51398. * The base URL of the online controller repository. Can be changed at any time.
  51399. */
  51400. static BaseRepositoryUrl: string;
  51401. /**
  51402. * Which repository gets priority - local or online
  51403. */
  51404. static PrioritizeOnlineRepository: boolean;
  51405. /**
  51406. * Use the online repository, or use only locally-defined controllers
  51407. */
  51408. static UseOnlineRepository: boolean;
  51409. /**
  51410. * Clear the cache used for profile loading and reload when requested again
  51411. */
  51412. static ClearProfilesCache(): void;
  51413. /**
  51414. * Register the default fallbacks.
  51415. * This function is called automatically when this file is imported.
  51416. */
  51417. static DefaultFallbacks(): void;
  51418. /**
  51419. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51420. * @param profileId the profile to which a fallback needs to be found
  51421. * @return an array with corresponding fallback profiles
  51422. */
  51423. static FindFallbackWithProfileId(profileId: string): string[];
  51424. /**
  51425. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51426. * The order of search:
  51427. *
  51428. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51429. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51430. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51431. * 4) return the generic trigger controller if none were found
  51432. *
  51433. * @param xrInput the xrInput to which a new controller is initialized
  51434. * @param scene the scene to which the model will be added
  51435. * @param forceProfile force a certain profile for this controller
  51436. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51437. */
  51438. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51439. /**
  51440. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51441. *
  51442. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51443. *
  51444. * @param type the profile type to register
  51445. * @param constructFunction the function to be called when loading this profile
  51446. */
  51447. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51448. /**
  51449. * Register a fallback to a specific profile.
  51450. * @param profileId the profileId that will receive the fallbacks
  51451. * @param fallbacks A list of fallback profiles
  51452. */
  51453. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51454. /**
  51455. * Will update the list of profiles available in the repository
  51456. * @return a promise that resolves to a map of profiles available online
  51457. */
  51458. static UpdateProfilesList(): Promise<{
  51459. [profile: string]: string;
  51460. }>;
  51461. private static _LoadProfileFromRepository;
  51462. private static _LoadProfilesFromAvailableControllers;
  51463. }
  51464. }
  51465. declare module BABYLON {
  51466. /**
  51467. * Configuration options for the WebXR controller creation
  51468. */
  51469. export interface IWebXRControllerOptions {
  51470. /**
  51471. * Should the controller mesh be animated when a user interacts with it
  51472. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51473. */
  51474. disableMotionControllerAnimation?: boolean;
  51475. /**
  51476. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51477. */
  51478. doNotLoadControllerMesh?: boolean;
  51479. /**
  51480. * Force a specific controller type for this controller.
  51481. * This can be used when creating your own profile or when testing different controllers
  51482. */
  51483. forceControllerProfile?: string;
  51484. /**
  51485. * Defines a rendering group ID for meshes that will be loaded.
  51486. * This is for the default controllers only.
  51487. */
  51488. renderingGroupId?: number;
  51489. }
  51490. /**
  51491. * Represents an XR controller
  51492. */
  51493. export class WebXRInputSource {
  51494. private _scene;
  51495. /** The underlying input source for the controller */
  51496. inputSource: XRInputSource;
  51497. private _options;
  51498. private _tmpVector;
  51499. private _uniqueId;
  51500. private _disposed;
  51501. /**
  51502. * 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
  51503. */
  51504. grip?: AbstractMesh;
  51505. /**
  51506. * If available, this is the gamepad object related to this controller.
  51507. * Using this object it is possible to get click events and trackpad changes of the
  51508. * webxr controller that is currently being used.
  51509. */
  51510. motionController?: WebXRAbstractMotionController;
  51511. /**
  51512. * Event that fires when the controller is removed/disposed.
  51513. * The object provided as event data is this controller, after associated assets were disposed.
  51514. * uniqueId is still available.
  51515. */
  51516. onDisposeObservable: Observable<WebXRInputSource>;
  51517. /**
  51518. * Will be triggered when the mesh associated with the motion controller is done loading.
  51519. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51520. * A shortened version of controller -> motion controller -> on mesh loaded.
  51521. */
  51522. onMeshLoadedObservable: Observable<AbstractMesh>;
  51523. /**
  51524. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51525. */
  51526. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51527. /**
  51528. * Pointer which can be used to select objects or attach a visible laser to
  51529. */
  51530. pointer: AbstractMesh;
  51531. /**
  51532. * Creates the input source object
  51533. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51534. * @param _scene the scene which the controller should be associated to
  51535. * @param inputSource the underlying input source for the controller
  51536. * @param _options options for this controller creation
  51537. */
  51538. constructor(_scene: Scene,
  51539. /** The underlying input source for the controller */
  51540. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51541. /**
  51542. * Get this controllers unique id
  51543. */
  51544. get uniqueId(): string;
  51545. /**
  51546. * Disposes of the object
  51547. */
  51548. dispose(): void;
  51549. /**
  51550. * Gets a world space ray coming from the pointer or grip
  51551. * @param result the resulting ray
  51552. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51553. */
  51554. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51555. /**
  51556. * Updates the controller pose based on the given XRFrame
  51557. * @param xrFrame xr frame to update the pose with
  51558. * @param referenceSpace reference space to use
  51559. */
  51560. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  51561. }
  51562. }
  51563. declare module BABYLON {
  51564. /**
  51565. * The schema for initialization options of the XR Input class
  51566. */
  51567. export interface IWebXRInputOptions {
  51568. /**
  51569. * If set to true no model will be automatically loaded
  51570. */
  51571. doNotLoadControllerMeshes?: boolean;
  51572. /**
  51573. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  51574. * If not found, the xr input profile data will be used.
  51575. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  51576. */
  51577. forceInputProfile?: string;
  51578. /**
  51579. * Do not send a request to the controller repository to load the profile.
  51580. *
  51581. * Instead, use the controllers available in babylon itself.
  51582. */
  51583. disableOnlineControllerRepository?: boolean;
  51584. /**
  51585. * A custom URL for the controllers repository
  51586. */
  51587. customControllersRepositoryURL?: string;
  51588. /**
  51589. * Should the controller model's components not move according to the user input
  51590. */
  51591. disableControllerAnimation?: boolean;
  51592. /**
  51593. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  51594. */
  51595. controllerOptions?: IWebXRControllerOptions;
  51596. }
  51597. /**
  51598. * XR input used to track XR inputs such as controllers/rays
  51599. */
  51600. export class WebXRInput implements IDisposable {
  51601. /**
  51602. * the xr session manager for this session
  51603. */
  51604. xrSessionManager: WebXRSessionManager;
  51605. /**
  51606. * the WebXR camera for this session. Mainly used for teleportation
  51607. */
  51608. xrCamera: WebXRCamera;
  51609. private readonly options;
  51610. /**
  51611. * XR controllers being tracked
  51612. */
  51613. controllers: Array<WebXRInputSource>;
  51614. private _frameObserver;
  51615. private _sessionEndedObserver;
  51616. private _sessionInitObserver;
  51617. /**
  51618. * Event when a controller has been connected/added
  51619. */
  51620. onControllerAddedObservable: Observable<WebXRInputSource>;
  51621. /**
  51622. * Event when a controller has been removed/disconnected
  51623. */
  51624. onControllerRemovedObservable: Observable<WebXRInputSource>;
  51625. /**
  51626. * Initializes the WebXRInput
  51627. * @param xrSessionManager the xr session manager for this session
  51628. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  51629. * @param options = initialization options for this xr input
  51630. */
  51631. constructor(
  51632. /**
  51633. * the xr session manager for this session
  51634. */
  51635. xrSessionManager: WebXRSessionManager,
  51636. /**
  51637. * the WebXR camera for this session. Mainly used for teleportation
  51638. */
  51639. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  51640. private _onInputSourcesChange;
  51641. private _addAndRemoveControllers;
  51642. /**
  51643. * Disposes of the object
  51644. */
  51645. dispose(): void;
  51646. }
  51647. }
  51648. declare module BABYLON {
  51649. /**
  51650. * This is the base class for all WebXR features.
  51651. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  51652. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  51653. */
  51654. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  51655. protected _xrSessionManager: WebXRSessionManager;
  51656. private _attached;
  51657. private _removeOnDetach;
  51658. /**
  51659. * Is this feature disposed?
  51660. */
  51661. isDisposed: boolean;
  51662. /**
  51663. * Should auto-attach be disabled?
  51664. */
  51665. disableAutoAttach: boolean;
  51666. /**
  51667. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  51668. */
  51669. xrNativeFeatureName: string;
  51670. /**
  51671. * Construct a new (abstract) WebXR feature
  51672. * @param _xrSessionManager the xr session manager for this feature
  51673. */
  51674. constructor(_xrSessionManager: WebXRSessionManager);
  51675. /**
  51676. * Is this feature attached
  51677. */
  51678. get attached(): boolean;
  51679. /**
  51680. * attach this feature
  51681. *
  51682. * @param force should attachment be forced (even when already attached)
  51683. * @returns true if successful, false is failed or already attached
  51684. */
  51685. attach(force?: boolean): boolean;
  51686. /**
  51687. * detach this feature.
  51688. *
  51689. * @returns true if successful, false if failed or already detached
  51690. */
  51691. detach(): boolean;
  51692. /**
  51693. * Dispose this feature and all of the resources attached
  51694. */
  51695. dispose(): void;
  51696. /**
  51697. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  51698. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  51699. *
  51700. * @returns whether or not the feature is compatible in this environment
  51701. */
  51702. isCompatible(): boolean;
  51703. /**
  51704. * This is used to register callbacks that will automatically be removed when detach is called.
  51705. * @param observable the observable to which the observer will be attached
  51706. * @param callback the callback to register
  51707. */
  51708. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  51709. /**
  51710. * Code in this function will be executed on each xrFrame received from the browser.
  51711. * This function will not execute after the feature is detached.
  51712. * @param _xrFrame the current frame
  51713. */
  51714. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  51715. }
  51716. }
  51717. declare module BABYLON {
  51718. /**
  51719. * Renders a layer on top of an existing scene
  51720. */
  51721. export class UtilityLayerRenderer implements IDisposable {
  51722. /** the original scene that will be rendered on top of */
  51723. originalScene: Scene;
  51724. private _pointerCaptures;
  51725. private _lastPointerEvents;
  51726. private static _DefaultUtilityLayer;
  51727. private static _DefaultKeepDepthUtilityLayer;
  51728. private _sharedGizmoLight;
  51729. private _renderCamera;
  51730. /**
  51731. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  51732. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  51733. * @returns the camera that is used when rendering the utility layer
  51734. */
  51735. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  51736. /**
  51737. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  51738. * @param cam the camera that should be used when rendering the utility layer
  51739. */
  51740. setRenderCamera(cam: Nullable<Camera>): void;
  51741. /**
  51742. * @hidden
  51743. * Light which used by gizmos to get light shading
  51744. */
  51745. _getSharedGizmoLight(): HemisphericLight;
  51746. /**
  51747. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  51748. */
  51749. pickUtilitySceneFirst: boolean;
  51750. /**
  51751. * 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)
  51752. */
  51753. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  51754. /**
  51755. * 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)
  51756. */
  51757. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  51758. /**
  51759. * The scene that is rendered on top of the original scene
  51760. */
  51761. utilityLayerScene: Scene;
  51762. /**
  51763. * If the utility layer should automatically be rendered on top of existing scene
  51764. */
  51765. shouldRender: boolean;
  51766. /**
  51767. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  51768. */
  51769. onlyCheckPointerDownEvents: boolean;
  51770. /**
  51771. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  51772. */
  51773. processAllEvents: boolean;
  51774. /**
  51775. * Observable raised when the pointer move from the utility layer scene to the main scene
  51776. */
  51777. onPointerOutObservable: Observable<number>;
  51778. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  51779. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  51780. private _afterRenderObserver;
  51781. private _sceneDisposeObserver;
  51782. private _originalPointerObserver;
  51783. /**
  51784. * Instantiates a UtilityLayerRenderer
  51785. * @param originalScene the original scene that will be rendered on top of
  51786. * @param handleEvents boolean indicating if the utility layer should handle events
  51787. */
  51788. constructor(
  51789. /** the original scene that will be rendered on top of */
  51790. originalScene: Scene, handleEvents?: boolean);
  51791. private _notifyObservers;
  51792. /**
  51793. * Renders the utility layers scene on top of the original scene
  51794. */
  51795. render(): void;
  51796. /**
  51797. * Disposes of the renderer
  51798. */
  51799. dispose(): void;
  51800. private _updateCamera;
  51801. }
  51802. }
  51803. declare module BABYLON {
  51804. /**
  51805. * Options interface for the pointer selection module
  51806. */
  51807. export interface IWebXRControllerPointerSelectionOptions {
  51808. /**
  51809. * if provided, this scene will be used to render meshes.
  51810. */
  51811. customUtilityLayerScene?: Scene;
  51812. /**
  51813. * 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)
  51814. * If not disabled, the last picked point will be used to execute a pointer up event
  51815. * If disabled, pointer up event will be triggered right after the pointer down event.
  51816. * Used in screen and gaze target ray mode only
  51817. */
  51818. disablePointerUpOnTouchOut: boolean;
  51819. /**
  51820. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  51821. */
  51822. forceGazeMode: boolean;
  51823. /**
  51824. * 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
  51825. * to start a new countdown to the pointer down event.
  51826. * Defaults to 1.
  51827. */
  51828. gazeModePointerMovedFactor?: number;
  51829. /**
  51830. * Different button type to use instead of the main component
  51831. */
  51832. overrideButtonId?: string;
  51833. /**
  51834. * use this rendering group id for the meshes (optional)
  51835. */
  51836. renderingGroupId?: number;
  51837. /**
  51838. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  51839. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  51840. * 3000 means 3 seconds between pointing at something and selecting it
  51841. */
  51842. timeToSelect?: number;
  51843. /**
  51844. * Should meshes created here be added to a utility layer or the main scene
  51845. */
  51846. useUtilityLayer?: boolean;
  51847. /**
  51848. * Optional WebXR camera to be used for gaze selection
  51849. */
  51850. gazeCamera?: WebXRCamera;
  51851. /**
  51852. * the xr input to use with this pointer selection
  51853. */
  51854. xrInput: WebXRInput;
  51855. }
  51856. /**
  51857. * A module that will enable pointer selection for motion controllers of XR Input Sources
  51858. */
  51859. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  51860. private readonly _options;
  51861. private static _idCounter;
  51862. private _attachController;
  51863. private _controllers;
  51864. private _scene;
  51865. private _tmpVectorForPickCompare;
  51866. /**
  51867. * The module's name
  51868. */
  51869. static readonly Name: string;
  51870. /**
  51871. * The (Babylon) version of this module.
  51872. * This is an integer representing the implementation version.
  51873. * This number does not correspond to the WebXR specs version
  51874. */
  51875. static readonly Version: number;
  51876. /**
  51877. * Disable lighting on the laser pointer (so it will always be visible)
  51878. */
  51879. disablePointerLighting: boolean;
  51880. /**
  51881. * Disable lighting on the selection mesh (so it will always be visible)
  51882. */
  51883. disableSelectionMeshLighting: boolean;
  51884. /**
  51885. * Should the laser pointer be displayed
  51886. */
  51887. displayLaserPointer: boolean;
  51888. /**
  51889. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  51890. */
  51891. displaySelectionMesh: boolean;
  51892. /**
  51893. * This color will be set to the laser pointer when selection is triggered
  51894. */
  51895. laserPointerPickedColor: Color3;
  51896. /**
  51897. * Default color of the laser pointer
  51898. */
  51899. laserPointerDefaultColor: Color3;
  51900. /**
  51901. * default color of the selection ring
  51902. */
  51903. selectionMeshDefaultColor: Color3;
  51904. /**
  51905. * This color will be applied to the selection ring when selection is triggered
  51906. */
  51907. selectionMeshPickedColor: Color3;
  51908. /**
  51909. * Optional filter to be used for ray selection. This predicate shares behavior with
  51910. * scene.pointerMovePredicate which takes priority if it is also assigned.
  51911. */
  51912. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51913. /**
  51914. * constructs a new background remover module
  51915. * @param _xrSessionManager the session manager for this module
  51916. * @param _options read-only options to be used in this module
  51917. */
  51918. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  51919. /**
  51920. * attach this feature
  51921. * Will usually be called by the features manager
  51922. *
  51923. * @returns true if successful.
  51924. */
  51925. attach(): boolean;
  51926. /**
  51927. * detach this feature.
  51928. * Will usually be called by the features manager
  51929. *
  51930. * @returns true if successful.
  51931. */
  51932. detach(): boolean;
  51933. /**
  51934. * Will get the mesh under a specific pointer.
  51935. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  51936. * @param controllerId the controllerId to check
  51937. * @returns The mesh under pointer or null if no mesh is under the pointer
  51938. */
  51939. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  51940. /**
  51941. * Get the xr controller that correlates to the pointer id in the pointer event
  51942. *
  51943. * @param id the pointer id to search for
  51944. * @returns the controller that correlates to this id or null if not found
  51945. */
  51946. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  51947. protected _onXRFrame(_xrFrame: XRFrame): void;
  51948. private _attachGazeMode;
  51949. private _attachScreenRayMode;
  51950. private _attachTrackedPointerRayMode;
  51951. private _convertNormalToDirectionOfRay;
  51952. private _detachController;
  51953. private _generateNewMeshPair;
  51954. private _pickingMoved;
  51955. private _updatePointerDistance;
  51956. /** @hidden */
  51957. get lasterPointerDefaultColor(): Color3;
  51958. }
  51959. }
  51960. declare module BABYLON {
  51961. /**
  51962. * Button which can be used to enter a different mode of XR
  51963. */
  51964. export class WebXREnterExitUIButton {
  51965. /** button element */
  51966. element: HTMLElement;
  51967. /** XR initialization options for the button */
  51968. sessionMode: XRSessionMode;
  51969. /** Reference space type */
  51970. referenceSpaceType: XRReferenceSpaceType;
  51971. /**
  51972. * Creates a WebXREnterExitUIButton
  51973. * @param element button element
  51974. * @param sessionMode XR initialization session mode
  51975. * @param referenceSpaceType the type of reference space to be used
  51976. */
  51977. constructor(
  51978. /** button element */
  51979. element: HTMLElement,
  51980. /** XR initialization options for the button */
  51981. sessionMode: XRSessionMode,
  51982. /** Reference space type */
  51983. referenceSpaceType: XRReferenceSpaceType);
  51984. /**
  51985. * Extendable function which can be used to update the button's visuals when the state changes
  51986. * @param activeButton the current active button in the UI
  51987. */
  51988. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  51989. }
  51990. /**
  51991. * Options to create the webXR UI
  51992. */
  51993. export class WebXREnterExitUIOptions {
  51994. /**
  51995. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  51996. */
  51997. customButtons?: Array<WebXREnterExitUIButton>;
  51998. /**
  51999. * A reference space type to use when creating the default button.
  52000. * Default is local-floor
  52001. */
  52002. referenceSpaceType?: XRReferenceSpaceType;
  52003. /**
  52004. * Context to enter xr with
  52005. */
  52006. renderTarget?: Nullable<WebXRRenderTarget>;
  52007. /**
  52008. * A session mode to use when creating the default button.
  52009. * Default is immersive-vr
  52010. */
  52011. sessionMode?: XRSessionMode;
  52012. /**
  52013. * A list of optional features to init the session with
  52014. */
  52015. optionalFeatures?: string[];
  52016. /**
  52017. * A list of optional features to init the session with
  52018. */
  52019. requiredFeatures?: string[];
  52020. }
  52021. /**
  52022. * UI to allow the user to enter/exit XR mode
  52023. */
  52024. export class WebXREnterExitUI implements IDisposable {
  52025. private scene;
  52026. /** version of the options passed to this UI */
  52027. options: WebXREnterExitUIOptions;
  52028. private _activeButton;
  52029. private _buttons;
  52030. /**
  52031. * The HTML Div Element to which buttons are added.
  52032. */
  52033. readonly overlay: HTMLDivElement;
  52034. /**
  52035. * Fired every time the active button is changed.
  52036. *
  52037. * When xr is entered via a button that launches xr that button will be the callback parameter
  52038. *
  52039. * When exiting xr the callback parameter will be null)
  52040. */
  52041. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52042. /**
  52043. *
  52044. * @param scene babylon scene object to use
  52045. * @param options (read-only) version of the options passed to this UI
  52046. */
  52047. private constructor();
  52048. /**
  52049. * Creates UI to allow the user to enter/exit XR mode
  52050. * @param scene the scene to add the ui to
  52051. * @param helper the xr experience helper to enter/exit xr with
  52052. * @param options options to configure the UI
  52053. * @returns the created ui
  52054. */
  52055. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52056. /**
  52057. * Disposes of the XR UI component
  52058. */
  52059. dispose(): void;
  52060. private _updateButtons;
  52061. }
  52062. }
  52063. declare module BABYLON {
  52064. /**
  52065. * Class containing static functions to help procedurally build meshes
  52066. */
  52067. export class LinesBuilder {
  52068. /**
  52069. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52070. * * 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
  52071. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52072. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52073. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52074. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52075. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52076. * * 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
  52077. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52079. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52080. * @param name defines the name of the new line system
  52081. * @param options defines the options used to create the line system
  52082. * @param scene defines the hosting scene
  52083. * @returns a new line system mesh
  52084. */
  52085. static CreateLineSystem(name: string, options: {
  52086. lines: Vector3[][];
  52087. updatable?: boolean;
  52088. instance?: Nullable<LinesMesh>;
  52089. colors?: Nullable<Color4[][]>;
  52090. useVertexAlpha?: boolean;
  52091. }, scene: Nullable<Scene>): LinesMesh;
  52092. /**
  52093. * Creates a line mesh
  52094. * 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
  52095. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52096. * * The parameter `points` is an array successive Vector3
  52097. * * 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
  52098. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52099. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52100. * * When updating an instance, remember that only point positions can change, not the number of points
  52101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52103. * @param name defines the name of the new line system
  52104. * @param options defines the options used to create the line system
  52105. * @param scene defines the hosting scene
  52106. * @returns a new line mesh
  52107. */
  52108. static CreateLines(name: string, options: {
  52109. points: Vector3[];
  52110. updatable?: boolean;
  52111. instance?: Nullable<LinesMesh>;
  52112. colors?: Color4[];
  52113. useVertexAlpha?: boolean;
  52114. }, scene?: Nullable<Scene>): LinesMesh;
  52115. /**
  52116. * Creates a dashed line mesh
  52117. * * 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
  52118. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52119. * * The parameter `points` is an array successive Vector3
  52120. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52121. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52122. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52123. * * 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
  52124. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52125. * * When updating an instance, remember that only point positions can change, not the number of points
  52126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52127. * @param name defines the name of the mesh
  52128. * @param options defines the options used to create the mesh
  52129. * @param scene defines the hosting scene
  52130. * @returns the dashed line mesh
  52131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52132. */
  52133. static CreateDashedLines(name: string, options: {
  52134. points: Vector3[];
  52135. dashSize?: number;
  52136. gapSize?: number;
  52137. dashNb?: number;
  52138. updatable?: boolean;
  52139. instance?: LinesMesh;
  52140. useVertexAlpha?: boolean;
  52141. }, scene?: Nullable<Scene>): LinesMesh;
  52142. }
  52143. }
  52144. declare module BABYLON {
  52145. /**
  52146. * Construction options for a timer
  52147. */
  52148. export interface ITimerOptions<T> {
  52149. /**
  52150. * Time-to-end
  52151. */
  52152. timeout: number;
  52153. /**
  52154. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52155. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52156. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52157. */
  52158. contextObservable: Observable<T>;
  52159. /**
  52160. * Optional parameters when adding an observer to the observable
  52161. */
  52162. observableParameters?: {
  52163. mask?: number;
  52164. insertFirst?: boolean;
  52165. scope?: any;
  52166. };
  52167. /**
  52168. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52169. */
  52170. breakCondition?: (data?: ITimerData<T>) => boolean;
  52171. /**
  52172. * Will be triggered when the time condition has met
  52173. */
  52174. onEnded?: (data: ITimerData<any>) => void;
  52175. /**
  52176. * Will be triggered when the break condition has met (prematurely ended)
  52177. */
  52178. onAborted?: (data: ITimerData<any>) => void;
  52179. /**
  52180. * Optional function to execute on each tick (or count)
  52181. */
  52182. onTick?: (data: ITimerData<any>) => void;
  52183. }
  52184. /**
  52185. * An interface defining the data sent by the timer
  52186. */
  52187. export interface ITimerData<T> {
  52188. /**
  52189. * When did it start
  52190. */
  52191. startTime: number;
  52192. /**
  52193. * Time now
  52194. */
  52195. currentTime: number;
  52196. /**
  52197. * Time passed since started
  52198. */
  52199. deltaTime: number;
  52200. /**
  52201. * How much is completed, in [0.0...1.0].
  52202. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52203. */
  52204. completeRate: number;
  52205. /**
  52206. * What the registered observable sent in the last count
  52207. */
  52208. payload: T;
  52209. }
  52210. /**
  52211. * The current state of the timer
  52212. */
  52213. export enum TimerState {
  52214. /**
  52215. * Timer initialized, not yet started
  52216. */
  52217. INIT = 0,
  52218. /**
  52219. * Timer started and counting
  52220. */
  52221. STARTED = 1,
  52222. /**
  52223. * Timer ended (whether aborted or time reached)
  52224. */
  52225. ENDED = 2
  52226. }
  52227. /**
  52228. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52229. *
  52230. * @param options options with which to initialize this timer
  52231. */
  52232. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52233. /**
  52234. * An advanced implementation of a timer class
  52235. */
  52236. export class AdvancedTimer<T = any> implements IDisposable {
  52237. /**
  52238. * Will notify each time the timer calculates the remaining time
  52239. */
  52240. onEachCountObservable: Observable<ITimerData<T>>;
  52241. /**
  52242. * Will trigger when the timer was aborted due to the break condition
  52243. */
  52244. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52245. /**
  52246. * Will trigger when the timer ended successfully
  52247. */
  52248. onTimerEndedObservable: Observable<ITimerData<T>>;
  52249. /**
  52250. * Will trigger when the timer state has changed
  52251. */
  52252. onStateChangedObservable: Observable<TimerState>;
  52253. private _observer;
  52254. private _contextObservable;
  52255. private _observableParameters;
  52256. private _startTime;
  52257. private _timer;
  52258. private _state;
  52259. private _breakCondition;
  52260. private _timeToEnd;
  52261. private _breakOnNextTick;
  52262. /**
  52263. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52264. * @param options construction options for this advanced timer
  52265. */
  52266. constructor(options: ITimerOptions<T>);
  52267. /**
  52268. * set a breaking condition for this timer. Default is to never break during count
  52269. * @param predicate the new break condition. Returns true to break, false otherwise
  52270. */
  52271. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52272. /**
  52273. * Reset ALL associated observables in this advanced timer
  52274. */
  52275. clearObservables(): void;
  52276. /**
  52277. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52278. *
  52279. * @param timeToEnd how much time to measure until timer ended
  52280. */
  52281. start(timeToEnd?: number): void;
  52282. /**
  52283. * Will force a stop on the next tick.
  52284. */
  52285. stop(): void;
  52286. /**
  52287. * Dispose this timer, clearing all resources
  52288. */
  52289. dispose(): void;
  52290. private _setState;
  52291. private _tick;
  52292. private _stop;
  52293. }
  52294. }
  52295. declare module BABYLON {
  52296. /**
  52297. * The options container for the teleportation module
  52298. */
  52299. export interface IWebXRTeleportationOptions {
  52300. /**
  52301. * if provided, this scene will be used to render meshes.
  52302. */
  52303. customUtilityLayerScene?: Scene;
  52304. /**
  52305. * Values to configure the default target mesh
  52306. */
  52307. defaultTargetMeshOptions?: {
  52308. /**
  52309. * Fill color of the teleportation area
  52310. */
  52311. teleportationFillColor?: string;
  52312. /**
  52313. * Border color for the teleportation area
  52314. */
  52315. teleportationBorderColor?: string;
  52316. /**
  52317. * Disable the mesh's animation sequence
  52318. */
  52319. disableAnimation?: boolean;
  52320. /**
  52321. * Disable lighting on the material or the ring and arrow
  52322. */
  52323. disableLighting?: boolean;
  52324. /**
  52325. * Override the default material of the torus and arrow
  52326. */
  52327. torusArrowMaterial?: Material;
  52328. };
  52329. /**
  52330. * A list of meshes to use as floor meshes.
  52331. * Meshes can be added and removed after initializing the feature using the
  52332. * addFloorMesh and removeFloorMesh functions
  52333. * If empty, rotation will still work
  52334. */
  52335. floorMeshes?: AbstractMesh[];
  52336. /**
  52337. * use this rendering group id for the meshes (optional)
  52338. */
  52339. renderingGroupId?: number;
  52340. /**
  52341. * Should teleportation move only to snap points
  52342. */
  52343. snapPointsOnly?: boolean;
  52344. /**
  52345. * An array of points to which the teleportation will snap to.
  52346. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52347. */
  52348. snapPositions?: Vector3[];
  52349. /**
  52350. * How close should the teleportation ray be in order to snap to position.
  52351. * Default to 0.8 units (meters)
  52352. */
  52353. snapToPositionRadius?: number;
  52354. /**
  52355. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52356. * If you want to support rotation, make sure your mesh has a direction indicator.
  52357. *
  52358. * When left untouched, the default mesh will be initialized.
  52359. */
  52360. teleportationTargetMesh?: AbstractMesh;
  52361. /**
  52362. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52363. */
  52364. timeToTeleport?: number;
  52365. /**
  52366. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52367. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52368. */
  52369. useMainComponentOnly?: boolean;
  52370. /**
  52371. * Should meshes created here be added to a utility layer or the main scene
  52372. */
  52373. useUtilityLayer?: boolean;
  52374. /**
  52375. * Babylon XR Input class for controller
  52376. */
  52377. xrInput: WebXRInput;
  52378. /**
  52379. * Meshes that the teleportation ray cannot go through
  52380. */
  52381. pickBlockerMeshes?: AbstractMesh[];
  52382. }
  52383. /**
  52384. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52385. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52386. * the input of the attached controllers.
  52387. */
  52388. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52389. private _options;
  52390. private _controllers;
  52391. private _currentTeleportationControllerId;
  52392. private _floorMeshes;
  52393. private _quadraticBezierCurve;
  52394. private _selectionFeature;
  52395. private _snapToPositions;
  52396. private _snappedToPoint;
  52397. private _teleportationRingMaterial?;
  52398. private _tmpRay;
  52399. private _tmpVector;
  52400. private _tmpQuaternion;
  52401. /**
  52402. * The module's name
  52403. */
  52404. static readonly Name: string;
  52405. /**
  52406. * The (Babylon) version of this module.
  52407. * This is an integer representing the implementation version.
  52408. * This number does not correspond to the webxr specs version
  52409. */
  52410. static readonly Version: number;
  52411. /**
  52412. * Is movement backwards enabled
  52413. */
  52414. backwardsMovementEnabled: boolean;
  52415. /**
  52416. * Distance to travel when moving backwards
  52417. */
  52418. backwardsTeleportationDistance: number;
  52419. /**
  52420. * The distance from the user to the inspection point in the direction of the controller
  52421. * A higher number will allow the user to move further
  52422. * defaults to 5 (meters, in xr units)
  52423. */
  52424. parabolicCheckRadius: number;
  52425. /**
  52426. * Should the module support parabolic ray on top of direct ray
  52427. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52428. * Very helpful when moving between floors / different heights
  52429. */
  52430. parabolicRayEnabled: boolean;
  52431. /**
  52432. * How much rotation should be applied when rotating right and left
  52433. */
  52434. rotationAngle: number;
  52435. /**
  52436. * Is rotation enabled when moving forward?
  52437. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52438. */
  52439. rotationEnabled: boolean;
  52440. /**
  52441. * constructs a new anchor system
  52442. * @param _xrSessionManager an instance of WebXRSessionManager
  52443. * @param _options configuration object for this feature
  52444. */
  52445. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52446. /**
  52447. * Get the snapPointsOnly flag
  52448. */
  52449. get snapPointsOnly(): boolean;
  52450. /**
  52451. * Sets the snapPointsOnly flag
  52452. * @param snapToPoints should teleportation be exclusively to snap points
  52453. */
  52454. set snapPointsOnly(snapToPoints: boolean);
  52455. /**
  52456. * Add a new mesh to the floor meshes array
  52457. * @param mesh the mesh to use as floor mesh
  52458. */
  52459. addFloorMesh(mesh: AbstractMesh): void;
  52460. /**
  52461. * Add a new snap-to point to fix teleportation to this position
  52462. * @param newSnapPoint The new Snap-To point
  52463. */
  52464. addSnapPoint(newSnapPoint: Vector3): void;
  52465. attach(): boolean;
  52466. detach(): boolean;
  52467. dispose(): void;
  52468. /**
  52469. * Remove a mesh from the floor meshes array
  52470. * @param mesh the mesh to remove
  52471. */
  52472. removeFloorMesh(mesh: AbstractMesh): void;
  52473. /**
  52474. * Remove a mesh from the floor meshes array using its name
  52475. * @param name the mesh name to remove
  52476. */
  52477. removeFloorMeshByName(name: string): void;
  52478. /**
  52479. * 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
  52480. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52481. * @returns was the point found and removed or not
  52482. */
  52483. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52484. /**
  52485. * This function sets a selection feature that will be disabled when
  52486. * the forward ray is shown and will be reattached when hidden.
  52487. * This is used to remove the selection rays when moving.
  52488. * @param selectionFeature the feature to disable when forward movement is enabled
  52489. */
  52490. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52491. protected _onXRFrame(_xrFrame: XRFrame): void;
  52492. private _attachController;
  52493. private _createDefaultTargetMesh;
  52494. private _detachController;
  52495. private _findClosestSnapPointWithRadius;
  52496. private _setTargetMeshPosition;
  52497. private _setTargetMeshVisibility;
  52498. private _showParabolicPath;
  52499. private _teleportForward;
  52500. }
  52501. }
  52502. declare module BABYLON {
  52503. /**
  52504. * Options for the default xr helper
  52505. */
  52506. export class WebXRDefaultExperienceOptions {
  52507. /**
  52508. * Enable or disable default UI to enter XR
  52509. */
  52510. disableDefaultUI?: boolean;
  52511. /**
  52512. * Should teleportation not initialize. defaults to false.
  52513. */
  52514. disableTeleportation?: boolean;
  52515. /**
  52516. * Floor meshes that will be used for teleport
  52517. */
  52518. floorMeshes?: Array<AbstractMesh>;
  52519. /**
  52520. * If set to true, the first frame will not be used to reset position
  52521. * The first frame is mainly used when copying transformation from the old camera
  52522. * Mainly used in AR
  52523. */
  52524. ignoreNativeCameraTransformation?: boolean;
  52525. /**
  52526. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  52527. */
  52528. inputOptions?: IWebXRInputOptions;
  52529. /**
  52530. * optional configuration for the output canvas
  52531. */
  52532. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  52533. /**
  52534. * optional UI options. This can be used among other to change session mode and reference space type
  52535. */
  52536. uiOptions?: WebXREnterExitUIOptions;
  52537. /**
  52538. * When loading teleportation and pointer select, use stable versions instead of latest.
  52539. */
  52540. useStablePlugins?: boolean;
  52541. /**
  52542. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  52543. */
  52544. renderingGroupId?: number;
  52545. /**
  52546. * A list of optional features to init the session with
  52547. * If set to true, all features we support will be added
  52548. */
  52549. optionalFeatures?: boolean | string[];
  52550. }
  52551. /**
  52552. * Default experience which provides a similar setup to the previous webVRExperience
  52553. */
  52554. export class WebXRDefaultExperience {
  52555. /**
  52556. * Base experience
  52557. */
  52558. baseExperience: WebXRExperienceHelper;
  52559. /**
  52560. * Enables ui for entering/exiting xr
  52561. */
  52562. enterExitUI: WebXREnterExitUI;
  52563. /**
  52564. * Input experience extension
  52565. */
  52566. input: WebXRInput;
  52567. /**
  52568. * Enables laser pointer and selection
  52569. */
  52570. pointerSelection: WebXRControllerPointerSelection;
  52571. /**
  52572. * Default target xr should render to
  52573. */
  52574. renderTarget: WebXRRenderTarget;
  52575. /**
  52576. * Enables teleportation
  52577. */
  52578. teleportation: WebXRMotionControllerTeleportation;
  52579. private constructor();
  52580. /**
  52581. * Creates the default xr experience
  52582. * @param scene scene
  52583. * @param options options for basic configuration
  52584. * @returns resulting WebXRDefaultExperience
  52585. */
  52586. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52587. /**
  52588. * DIsposes of the experience helper
  52589. */
  52590. dispose(): void;
  52591. }
  52592. }
  52593. declare module BABYLON {
  52594. /**
  52595. * Options to modify the vr teleportation behavior.
  52596. */
  52597. export interface VRTeleportationOptions {
  52598. /**
  52599. * The name of the mesh which should be used as the teleportation floor. (default: null)
  52600. */
  52601. floorMeshName?: string;
  52602. /**
  52603. * A list of meshes to be used as the teleportation floor. (default: empty)
  52604. */
  52605. floorMeshes?: Mesh[];
  52606. /**
  52607. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  52608. */
  52609. teleportationMode?: number;
  52610. /**
  52611. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  52612. */
  52613. teleportationTime?: number;
  52614. /**
  52615. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  52616. */
  52617. teleportationSpeed?: number;
  52618. /**
  52619. * The easing function used in the animation or null for Linear. (default CircleEase)
  52620. */
  52621. easingFunction?: EasingFunction;
  52622. }
  52623. /**
  52624. * Options to modify the vr experience helper's behavior.
  52625. */
  52626. export interface VRExperienceHelperOptions extends WebVROptions {
  52627. /**
  52628. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  52629. */
  52630. createDeviceOrientationCamera?: boolean;
  52631. /**
  52632. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  52633. */
  52634. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  52635. /**
  52636. * Uses the main button on the controller to toggle the laser casted. (default: true)
  52637. */
  52638. laserToggle?: boolean;
  52639. /**
  52640. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  52641. */
  52642. floorMeshes?: Mesh[];
  52643. /**
  52644. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  52645. */
  52646. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  52647. /**
  52648. * Defines if WebXR should be used instead of WebVR (if available)
  52649. */
  52650. useXR?: boolean;
  52651. }
  52652. /**
  52653. * Event containing information after VR has been entered
  52654. */
  52655. export class OnAfterEnteringVRObservableEvent {
  52656. /**
  52657. * If entering vr was successful
  52658. */
  52659. success: boolean;
  52660. }
  52661. /**
  52662. * Helps to quickly add VR support to an existing scene.
  52663. * See https://doc.babylonjs.com/how_to/webvr_helper
  52664. */
  52665. export class VRExperienceHelper {
  52666. /** Options to modify the vr experience helper's behavior. */
  52667. webVROptions: VRExperienceHelperOptions;
  52668. private _scene;
  52669. private _position;
  52670. private _btnVR;
  52671. private _btnVRDisplayed;
  52672. private _webVRsupported;
  52673. private _webVRready;
  52674. private _webVRrequesting;
  52675. private _webVRpresenting;
  52676. private _hasEnteredVR;
  52677. private _fullscreenVRpresenting;
  52678. private _inputElement;
  52679. private _webVRCamera;
  52680. private _vrDeviceOrientationCamera;
  52681. private _deviceOrientationCamera;
  52682. private _existingCamera;
  52683. private _onKeyDown;
  52684. private _onVrDisplayPresentChange;
  52685. private _onVRDisplayChanged;
  52686. private _onVRRequestPresentStart;
  52687. private _onVRRequestPresentComplete;
  52688. /**
  52689. * 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)
  52690. */
  52691. enableGazeEvenWhenNoPointerLock: boolean;
  52692. /**
  52693. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  52694. */
  52695. exitVROnDoubleTap: boolean;
  52696. /**
  52697. * Observable raised right before entering VR.
  52698. */
  52699. onEnteringVRObservable: Observable<VRExperienceHelper>;
  52700. /**
  52701. * Observable raised when entering VR has completed.
  52702. */
  52703. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  52704. /**
  52705. * Observable raised when exiting VR.
  52706. */
  52707. onExitingVRObservable: Observable<VRExperienceHelper>;
  52708. /**
  52709. * Observable raised when controller mesh is loaded.
  52710. */
  52711. onControllerMeshLoadedObservable: Observable<WebVRController>;
  52712. /** Return this.onEnteringVRObservable
  52713. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  52714. */
  52715. get onEnteringVR(): Observable<VRExperienceHelper>;
  52716. /** Return this.onExitingVRObservable
  52717. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  52718. */
  52719. get onExitingVR(): Observable<VRExperienceHelper>;
  52720. /** Return this.onControllerMeshLoadedObservable
  52721. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  52722. */
  52723. get onControllerMeshLoaded(): Observable<WebVRController>;
  52724. private _rayLength;
  52725. private _useCustomVRButton;
  52726. private _teleportationRequested;
  52727. private _teleportActive;
  52728. private _floorMeshName;
  52729. private _floorMeshesCollection;
  52730. private _teleportationMode;
  52731. private _teleportationTime;
  52732. private _teleportationSpeed;
  52733. private _teleportationEasing;
  52734. private _rotationAllowed;
  52735. private _teleportBackwardsVector;
  52736. private _teleportationTarget;
  52737. private _isDefaultTeleportationTarget;
  52738. private _postProcessMove;
  52739. private _teleportationFillColor;
  52740. private _teleportationBorderColor;
  52741. private _rotationAngle;
  52742. private _haloCenter;
  52743. private _cameraGazer;
  52744. private _padSensibilityUp;
  52745. private _padSensibilityDown;
  52746. private _leftController;
  52747. private _rightController;
  52748. private _gazeColor;
  52749. private _laserColor;
  52750. private _pickedLaserColor;
  52751. private _pickedGazeColor;
  52752. /**
  52753. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  52754. */
  52755. onNewMeshSelected: Observable<AbstractMesh>;
  52756. /**
  52757. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  52758. * This observable will provide the mesh and the controller used to select the mesh
  52759. */
  52760. onMeshSelectedWithController: Observable<{
  52761. mesh: AbstractMesh;
  52762. controller: WebVRController;
  52763. }>;
  52764. /**
  52765. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  52766. */
  52767. onNewMeshPicked: Observable<PickingInfo>;
  52768. private _circleEase;
  52769. /**
  52770. * Observable raised before camera teleportation
  52771. */
  52772. onBeforeCameraTeleport: Observable<Vector3>;
  52773. /**
  52774. * Observable raised after camera teleportation
  52775. */
  52776. onAfterCameraTeleport: Observable<Vector3>;
  52777. /**
  52778. * Observable raised when current selected mesh gets unselected
  52779. */
  52780. onSelectedMeshUnselected: Observable<AbstractMesh>;
  52781. private _raySelectionPredicate;
  52782. /**
  52783. * To be optionaly changed by user to define custom ray selection
  52784. */
  52785. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52786. /**
  52787. * To be optionaly changed by user to define custom selection logic (after ray selection)
  52788. */
  52789. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52790. /**
  52791. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  52792. */
  52793. teleportationEnabled: boolean;
  52794. private _defaultHeight;
  52795. private _teleportationInitialized;
  52796. private _interactionsEnabled;
  52797. private _interactionsRequested;
  52798. private _displayGaze;
  52799. private _displayLaserPointer;
  52800. /**
  52801. * The mesh used to display where the user is going to teleport.
  52802. */
  52803. get teleportationTarget(): Mesh;
  52804. /**
  52805. * Sets the mesh to be used to display where the user is going to teleport.
  52806. */
  52807. set teleportationTarget(value: Mesh);
  52808. /**
  52809. * 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
  52810. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  52811. * See https://doc.babylonjs.com/resources/baking_transformations
  52812. */
  52813. get gazeTrackerMesh(): Mesh;
  52814. set gazeTrackerMesh(value: Mesh);
  52815. /**
  52816. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  52817. */
  52818. updateGazeTrackerScale: boolean;
  52819. /**
  52820. * If the gaze trackers color should be updated when selecting meshes
  52821. */
  52822. updateGazeTrackerColor: boolean;
  52823. /**
  52824. * If the controller laser color should be updated when selecting meshes
  52825. */
  52826. updateControllerLaserColor: boolean;
  52827. /**
  52828. * The gaze tracking mesh corresponding to the left controller
  52829. */
  52830. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  52831. /**
  52832. * The gaze tracking mesh corresponding to the right controller
  52833. */
  52834. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  52835. /**
  52836. * If the ray of the gaze should be displayed.
  52837. */
  52838. get displayGaze(): boolean;
  52839. /**
  52840. * Sets if the ray of the gaze should be displayed.
  52841. */
  52842. set displayGaze(value: boolean);
  52843. /**
  52844. * If the ray of the LaserPointer should be displayed.
  52845. */
  52846. get displayLaserPointer(): boolean;
  52847. /**
  52848. * Sets if the ray of the LaserPointer should be displayed.
  52849. */
  52850. set displayLaserPointer(value: boolean);
  52851. /**
  52852. * The deviceOrientationCamera used as the camera when not in VR.
  52853. */
  52854. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  52855. /**
  52856. * Based on the current WebVR support, returns the current VR camera used.
  52857. */
  52858. get currentVRCamera(): Nullable<Camera>;
  52859. /**
  52860. * The webVRCamera which is used when in VR.
  52861. */
  52862. get webVRCamera(): WebVRFreeCamera;
  52863. /**
  52864. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  52865. */
  52866. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  52867. /**
  52868. * The html button that is used to trigger entering into VR.
  52869. */
  52870. get vrButton(): Nullable<HTMLButtonElement>;
  52871. private get _teleportationRequestInitiated();
  52872. /**
  52873. * Defines whether or not Pointer lock should be requested when switching to
  52874. * full screen.
  52875. */
  52876. requestPointerLockOnFullScreen: boolean;
  52877. /**
  52878. * If asking to force XR, this will be populated with the default xr experience
  52879. */
  52880. xr: WebXRDefaultExperience;
  52881. /**
  52882. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  52883. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  52884. */
  52885. xrTestDone: boolean;
  52886. /**
  52887. * Instantiates a VRExperienceHelper.
  52888. * Helps to quickly add VR support to an existing scene.
  52889. * @param scene The scene the VRExperienceHelper belongs to.
  52890. * @param webVROptions Options to modify the vr experience helper's behavior.
  52891. */
  52892. constructor(scene: Scene,
  52893. /** Options to modify the vr experience helper's behavior. */
  52894. webVROptions?: VRExperienceHelperOptions);
  52895. private completeVRInit;
  52896. private _onDefaultMeshLoaded;
  52897. private _onResize;
  52898. private _onFullscreenChange;
  52899. /**
  52900. * Gets a value indicating if we are currently in VR mode.
  52901. */
  52902. get isInVRMode(): boolean;
  52903. private onVrDisplayPresentChange;
  52904. private onVRDisplayChanged;
  52905. private moveButtonToBottomRight;
  52906. private displayVRButton;
  52907. private updateButtonVisibility;
  52908. private _cachedAngularSensibility;
  52909. /**
  52910. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  52911. * Otherwise, will use the fullscreen API.
  52912. */
  52913. enterVR(): void;
  52914. /**
  52915. * Attempt to exit VR, or fullscreen.
  52916. */
  52917. exitVR(): void;
  52918. /**
  52919. * The position of the vr experience helper.
  52920. */
  52921. get position(): Vector3;
  52922. /**
  52923. * Sets the position of the vr experience helper.
  52924. */
  52925. set position(value: Vector3);
  52926. /**
  52927. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  52928. */
  52929. enableInteractions(): void;
  52930. private get _noControllerIsActive();
  52931. private beforeRender;
  52932. private _isTeleportationFloor;
  52933. /**
  52934. * Adds a floor mesh to be used for teleportation.
  52935. * @param floorMesh the mesh to be used for teleportation.
  52936. */
  52937. addFloorMesh(floorMesh: Mesh): void;
  52938. /**
  52939. * Removes a floor mesh from being used for teleportation.
  52940. * @param floorMesh the mesh to be removed.
  52941. */
  52942. removeFloorMesh(floorMesh: Mesh): void;
  52943. /**
  52944. * Enables interactions and teleportation using the VR controllers and gaze.
  52945. * @param vrTeleportationOptions options to modify teleportation behavior.
  52946. */
  52947. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  52948. private _onNewGamepadConnected;
  52949. private _tryEnableInteractionOnController;
  52950. private _onNewGamepadDisconnected;
  52951. private _enableInteractionOnController;
  52952. private _checkTeleportWithRay;
  52953. private _checkRotate;
  52954. private _checkTeleportBackwards;
  52955. private _enableTeleportationOnController;
  52956. private _createTeleportationCircles;
  52957. private _displayTeleportationTarget;
  52958. private _hideTeleportationTarget;
  52959. private _rotateCamera;
  52960. private _moveTeleportationSelectorTo;
  52961. private _workingVector;
  52962. private _workingQuaternion;
  52963. private _workingMatrix;
  52964. /**
  52965. * Time Constant Teleportation Mode
  52966. */
  52967. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52968. /**
  52969. * Speed Constant Teleportation Mode
  52970. */
  52971. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52972. /**
  52973. * Teleports the users feet to the desired location
  52974. * @param location The location where the user's feet should be placed
  52975. */
  52976. teleportCamera(location: Vector3): void;
  52977. private _convertNormalToDirectionOfRay;
  52978. private _castRayAndSelectObject;
  52979. private _notifySelectedMeshUnselected;
  52980. /**
  52981. * Permanently set new colors for the laser pointer
  52982. * @param color the new laser color
  52983. * @param pickedColor the new laser color when picked mesh detected
  52984. */
  52985. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52986. /**
  52987. * Set lighting enabled / disabled on the laser pointer of both controllers
  52988. * @param enabled should the lighting be enabled on the laser pointer
  52989. */
  52990. setLaserLightingState(enabled?: boolean): void;
  52991. /**
  52992. * Permanently set new colors for the gaze pointer
  52993. * @param color the new gaze color
  52994. * @param pickedColor the new gaze color when picked mesh detected
  52995. */
  52996. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52997. /**
  52998. * Sets the color of the laser ray from the vr controllers.
  52999. * @param color new color for the ray.
  53000. */
  53001. changeLaserColor(color: Color3): void;
  53002. /**
  53003. * Sets the color of the ray from the vr headsets gaze.
  53004. * @param color new color for the ray.
  53005. */
  53006. changeGazeColor(color: Color3): void;
  53007. /**
  53008. * Exits VR and disposes of the vr experience helper
  53009. */
  53010. dispose(): void;
  53011. /**
  53012. * Gets the name of the VRExperienceHelper class
  53013. * @returns "VRExperienceHelper"
  53014. */
  53015. getClassName(): string;
  53016. }
  53017. }
  53018. declare module BABYLON {
  53019. /**
  53020. * Contains an array of blocks representing the octree
  53021. */
  53022. export interface IOctreeContainer<T> {
  53023. /**
  53024. * Blocks within the octree
  53025. */
  53026. blocks: Array<OctreeBlock<T>>;
  53027. }
  53028. /**
  53029. * Class used to store a cell in an octree
  53030. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53031. */
  53032. export class OctreeBlock<T> {
  53033. /**
  53034. * Gets the content of the current block
  53035. */
  53036. entries: T[];
  53037. /**
  53038. * Gets the list of block children
  53039. */
  53040. blocks: Array<OctreeBlock<T>>;
  53041. private _depth;
  53042. private _maxDepth;
  53043. private _capacity;
  53044. private _minPoint;
  53045. private _maxPoint;
  53046. private _boundingVectors;
  53047. private _creationFunc;
  53048. /**
  53049. * Creates a new block
  53050. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53051. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53052. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53053. * @param depth defines the current depth of this block in the octree
  53054. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53055. * @param creationFunc defines a callback to call when an element is added to the block
  53056. */
  53057. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53058. /**
  53059. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53060. */
  53061. get capacity(): number;
  53062. /**
  53063. * Gets the minimum vector (in world space) of the block's bounding box
  53064. */
  53065. get minPoint(): Vector3;
  53066. /**
  53067. * Gets the maximum vector (in world space) of the block's bounding box
  53068. */
  53069. get maxPoint(): Vector3;
  53070. /**
  53071. * Add a new element to this block
  53072. * @param entry defines the element to add
  53073. */
  53074. addEntry(entry: T): void;
  53075. /**
  53076. * Remove an element from this block
  53077. * @param entry defines the element to remove
  53078. */
  53079. removeEntry(entry: T): void;
  53080. /**
  53081. * Add an array of elements to this block
  53082. * @param entries defines the array of elements to add
  53083. */
  53084. addEntries(entries: T[]): void;
  53085. /**
  53086. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53087. * @param frustumPlanes defines the frustum planes to test
  53088. * @param selection defines the array to store current content if selection is positive
  53089. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53090. */
  53091. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53092. /**
  53093. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53094. * @param sphereCenter defines the bounding sphere center
  53095. * @param sphereRadius defines the bounding sphere radius
  53096. * @param selection defines the array to store current content if selection is positive
  53097. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53098. */
  53099. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53100. /**
  53101. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53102. * @param ray defines the ray to test with
  53103. * @param selection defines the array to store current content if selection is positive
  53104. */
  53105. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53106. /**
  53107. * Subdivide the content into child blocks (this block will then be empty)
  53108. */
  53109. createInnerBlocks(): void;
  53110. /**
  53111. * @hidden
  53112. */
  53113. 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;
  53114. }
  53115. }
  53116. declare module BABYLON {
  53117. /**
  53118. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53119. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53120. */
  53121. export class Octree<T> {
  53122. /** 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.) */
  53123. maxDepth: number;
  53124. /**
  53125. * Blocks within the octree containing objects
  53126. */
  53127. blocks: Array<OctreeBlock<T>>;
  53128. /**
  53129. * Content stored in the octree
  53130. */
  53131. dynamicContent: T[];
  53132. private _maxBlockCapacity;
  53133. private _selectionContent;
  53134. private _creationFunc;
  53135. /**
  53136. * Creates a octree
  53137. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53138. * @param creationFunc function to be used to instatiate the octree
  53139. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53140. * @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.)
  53141. */
  53142. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53143. /** 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.) */
  53144. maxDepth?: number);
  53145. /**
  53146. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53147. * @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);
  53148. * @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);
  53149. * @param entries meshes to be added to the octree blocks
  53150. */
  53151. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53152. /**
  53153. * Adds a mesh to the octree
  53154. * @param entry Mesh to add to the octree
  53155. */
  53156. addMesh(entry: T): void;
  53157. /**
  53158. * Remove an element from the octree
  53159. * @param entry defines the element to remove
  53160. */
  53161. removeMesh(entry: T): void;
  53162. /**
  53163. * Selects an array of meshes within the frustum
  53164. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53165. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53166. * @returns array of meshes within the frustum
  53167. */
  53168. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53169. /**
  53170. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53171. * @param sphereCenter defines the bounding sphere center
  53172. * @param sphereRadius defines the bounding sphere radius
  53173. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53174. * @returns an array of objects that intersect the sphere
  53175. */
  53176. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53177. /**
  53178. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53179. * @param ray defines the ray to test with
  53180. * @returns array of intersected objects
  53181. */
  53182. intersectsRay(ray: Ray): SmartArray<T>;
  53183. /**
  53184. * Adds a mesh into the octree block if it intersects the block
  53185. */
  53186. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53187. /**
  53188. * Adds a submesh into the octree block if it intersects the block
  53189. */
  53190. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53191. }
  53192. }
  53193. declare module BABYLON {
  53194. interface Scene {
  53195. /**
  53196. * @hidden
  53197. * Backing Filed
  53198. */
  53199. _selectionOctree: Octree<AbstractMesh>;
  53200. /**
  53201. * Gets the octree used to boost mesh selection (picking)
  53202. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53203. */
  53204. selectionOctree: Octree<AbstractMesh>;
  53205. /**
  53206. * Creates or updates the octree used to boost selection (picking)
  53207. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53208. * @param maxCapacity defines the maximum capacity per leaf
  53209. * @param maxDepth defines the maximum depth of the octree
  53210. * @returns an octree of AbstractMesh
  53211. */
  53212. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53213. }
  53214. interface AbstractMesh {
  53215. /**
  53216. * @hidden
  53217. * Backing Field
  53218. */
  53219. _submeshesOctree: Octree<SubMesh>;
  53220. /**
  53221. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53222. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53223. * @param maxCapacity defines the maximum size of each block (64 by default)
  53224. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53225. * @returns the new octree
  53226. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53227. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53228. */
  53229. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53230. }
  53231. /**
  53232. * Defines the octree scene component responsible to manage any octrees
  53233. * in a given scene.
  53234. */
  53235. export class OctreeSceneComponent {
  53236. /**
  53237. * The component name help to identify the component in the list of scene components.
  53238. */
  53239. readonly name: string;
  53240. /**
  53241. * The scene the component belongs to.
  53242. */
  53243. scene: Scene;
  53244. /**
  53245. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53246. */
  53247. readonly checksIsEnabled: boolean;
  53248. /**
  53249. * Creates a new instance of the component for the given scene
  53250. * @param scene Defines the scene to register the component in
  53251. */
  53252. constructor(scene: Scene);
  53253. /**
  53254. * Registers the component in a given scene
  53255. */
  53256. register(): void;
  53257. /**
  53258. * Return the list of active meshes
  53259. * @returns the list of active meshes
  53260. */
  53261. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53262. /**
  53263. * Return the list of active sub meshes
  53264. * @param mesh The mesh to get the candidates sub meshes from
  53265. * @returns the list of active sub meshes
  53266. */
  53267. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53268. private _tempRay;
  53269. /**
  53270. * Return the list of sub meshes intersecting with a given local ray
  53271. * @param mesh defines the mesh to find the submesh for
  53272. * @param localRay defines the ray in local space
  53273. * @returns the list of intersecting sub meshes
  53274. */
  53275. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53276. /**
  53277. * Return the list of sub meshes colliding with a collider
  53278. * @param mesh defines the mesh to find the submesh for
  53279. * @param collider defines the collider to evaluate the collision against
  53280. * @returns the list of colliding sub meshes
  53281. */
  53282. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53283. /**
  53284. * Rebuilds the elements related to this component in case of
  53285. * context lost for instance.
  53286. */
  53287. rebuild(): void;
  53288. /**
  53289. * Disposes the component and the associated ressources.
  53290. */
  53291. dispose(): void;
  53292. }
  53293. }
  53294. declare module BABYLON {
  53295. /**
  53296. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53297. */
  53298. export class Gizmo implements IDisposable {
  53299. /** The utility layer the gizmo will be added to */
  53300. gizmoLayer: UtilityLayerRenderer;
  53301. /**
  53302. * The root mesh of the gizmo
  53303. */
  53304. _rootMesh: Mesh;
  53305. private _attachedMesh;
  53306. private _attachedNode;
  53307. /**
  53308. * Ratio for the scale of the gizmo (Default: 1)
  53309. */
  53310. protected _scaleRatio: number;
  53311. /**
  53312. * boolean updated by pointermove when a gizmo mesh is hovered
  53313. */
  53314. protected _isHovered: boolean;
  53315. /**
  53316. * Ratio for the scale of the gizmo (Default: 1)
  53317. */
  53318. set scaleRatio(value: number);
  53319. get scaleRatio(): number;
  53320. /**
  53321. * True when the mouse pointer is hovered a gizmo mesh
  53322. */
  53323. get isHovered(): boolean;
  53324. /**
  53325. * If a custom mesh has been set (Default: false)
  53326. */
  53327. protected _customMeshSet: boolean;
  53328. /**
  53329. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53330. * * When set, interactions will be enabled
  53331. */
  53332. get attachedMesh(): Nullable<AbstractMesh>;
  53333. set attachedMesh(value: Nullable<AbstractMesh>);
  53334. /**
  53335. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53336. * * When set, interactions will be enabled
  53337. */
  53338. get attachedNode(): Nullable<Node>;
  53339. set attachedNode(value: Nullable<Node>);
  53340. /**
  53341. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53342. * @param mesh The mesh to replace the default mesh of the gizmo
  53343. */
  53344. setCustomMesh(mesh: Mesh): void;
  53345. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53346. /**
  53347. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53348. */
  53349. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53350. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53351. /**
  53352. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53353. */
  53354. updateGizmoPositionToMatchAttachedMesh: boolean;
  53355. /**
  53356. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53357. */
  53358. updateScale: boolean;
  53359. protected _interactionsEnabled: boolean;
  53360. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53361. private _beforeRenderObserver;
  53362. private _tempQuaternion;
  53363. private _tempVector;
  53364. private _tempVector2;
  53365. private _tempMatrix1;
  53366. private _tempMatrix2;
  53367. private _rightHandtoLeftHandMatrix;
  53368. /**
  53369. * Creates a gizmo
  53370. * @param gizmoLayer The utility layer the gizmo will be added to
  53371. */
  53372. constructor(
  53373. /** The utility layer the gizmo will be added to */
  53374. gizmoLayer?: UtilityLayerRenderer);
  53375. /**
  53376. * Updates the gizmo to match the attached mesh's position/rotation
  53377. */
  53378. protected _update(): void;
  53379. /**
  53380. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53381. * @param value Node, TransformNode or mesh
  53382. */
  53383. protected _matrixChanged(): void;
  53384. /**
  53385. * Disposes of the gizmo
  53386. */
  53387. dispose(): void;
  53388. }
  53389. }
  53390. declare module BABYLON {
  53391. /**
  53392. * Single plane drag gizmo
  53393. */
  53394. export class PlaneDragGizmo extends Gizmo {
  53395. /**
  53396. * Drag behavior responsible for the gizmos dragging interactions
  53397. */
  53398. dragBehavior: PointerDragBehavior;
  53399. private _pointerObserver;
  53400. /**
  53401. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53402. */
  53403. snapDistance: number;
  53404. /**
  53405. * Event that fires each time the gizmo snaps to a new location.
  53406. * * snapDistance is the the change in distance
  53407. */
  53408. onSnapObservable: Observable<{
  53409. snapDistance: number;
  53410. }>;
  53411. private _plane;
  53412. private _coloredMaterial;
  53413. private _hoverMaterial;
  53414. private _isEnabled;
  53415. private _parent;
  53416. /** @hidden */
  53417. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53418. /** @hidden */
  53419. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53420. /**
  53421. * Creates a PlaneDragGizmo
  53422. * @param gizmoLayer The utility layer the gizmo will be added to
  53423. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53424. * @param color The color of the gizmo
  53425. */
  53426. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53427. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53428. /**
  53429. * If the gizmo is enabled
  53430. */
  53431. set isEnabled(value: boolean);
  53432. get isEnabled(): boolean;
  53433. /**
  53434. * Disposes of the gizmo
  53435. */
  53436. dispose(): void;
  53437. }
  53438. }
  53439. declare module BABYLON {
  53440. /**
  53441. * Gizmo that enables dragging a mesh along 3 axis
  53442. */
  53443. export class PositionGizmo extends Gizmo {
  53444. /**
  53445. * Internal gizmo used for interactions on the x axis
  53446. */
  53447. xGizmo: AxisDragGizmo;
  53448. /**
  53449. * Internal gizmo used for interactions on the y axis
  53450. */
  53451. yGizmo: AxisDragGizmo;
  53452. /**
  53453. * Internal gizmo used for interactions on the z axis
  53454. */
  53455. zGizmo: AxisDragGizmo;
  53456. /**
  53457. * Internal gizmo used for interactions on the yz plane
  53458. */
  53459. xPlaneGizmo: PlaneDragGizmo;
  53460. /**
  53461. * Internal gizmo used for interactions on the xz plane
  53462. */
  53463. yPlaneGizmo: PlaneDragGizmo;
  53464. /**
  53465. * Internal gizmo used for interactions on the xy plane
  53466. */
  53467. zPlaneGizmo: PlaneDragGizmo;
  53468. /**
  53469. * private variables
  53470. */
  53471. private _meshAttached;
  53472. private _nodeAttached;
  53473. private _snapDistance;
  53474. /** Fires an event when any of it's sub gizmos are dragged */
  53475. onDragStartObservable: Observable<unknown>;
  53476. /** Fires an event when any of it's sub gizmos are released from dragging */
  53477. onDragEndObservable: Observable<unknown>;
  53478. /**
  53479. * If set to true, planar drag is enabled
  53480. */
  53481. private _planarGizmoEnabled;
  53482. get attachedMesh(): Nullable<AbstractMesh>;
  53483. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53484. get attachedNode(): Nullable<Node>;
  53485. set attachedNode(node: Nullable<Node>);
  53486. /**
  53487. * True when the mouse pointer is hovering a gizmo mesh
  53488. */
  53489. get isHovered(): boolean;
  53490. /**
  53491. * Creates a PositionGizmo
  53492. * @param gizmoLayer The utility layer the gizmo will be added to
  53493. @param thickness display gizmo axis thickness
  53494. */
  53495. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53496. /**
  53497. * If the planar drag gizmo is enabled
  53498. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53499. */
  53500. set planarGizmoEnabled(value: boolean);
  53501. get planarGizmoEnabled(): boolean;
  53502. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53503. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53504. /**
  53505. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53506. */
  53507. set snapDistance(value: number);
  53508. get snapDistance(): number;
  53509. /**
  53510. * Ratio for the scale of the gizmo (Default: 1)
  53511. */
  53512. set scaleRatio(value: number);
  53513. get scaleRatio(): number;
  53514. /**
  53515. * Disposes of the gizmo
  53516. */
  53517. dispose(): void;
  53518. /**
  53519. * CustomMeshes are not supported by this gizmo
  53520. * @param mesh The mesh to replace the default mesh of the gizmo
  53521. */
  53522. setCustomMesh(mesh: Mesh): void;
  53523. }
  53524. }
  53525. declare module BABYLON {
  53526. /**
  53527. * Single axis drag gizmo
  53528. */
  53529. export class AxisDragGizmo extends Gizmo {
  53530. /**
  53531. * Drag behavior responsible for the gizmos dragging interactions
  53532. */
  53533. dragBehavior: PointerDragBehavior;
  53534. private _pointerObserver;
  53535. /**
  53536. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53537. */
  53538. snapDistance: number;
  53539. /**
  53540. * Event that fires each time the gizmo snaps to a new location.
  53541. * * snapDistance is the the change in distance
  53542. */
  53543. onSnapObservable: Observable<{
  53544. snapDistance: number;
  53545. }>;
  53546. private _isEnabled;
  53547. private _parent;
  53548. private _arrow;
  53549. private _coloredMaterial;
  53550. private _hoverMaterial;
  53551. /** @hidden */
  53552. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  53553. /** @hidden */
  53554. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53555. /**
  53556. * Creates an AxisDragGizmo
  53557. * @param gizmoLayer The utility layer the gizmo will be added to
  53558. * @param dragAxis The axis which the gizmo will be able to drag on
  53559. * @param color The color of the gizmo
  53560. * @param thickness display gizmo axis thickness
  53561. */
  53562. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  53563. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53564. /**
  53565. * If the gizmo is enabled
  53566. */
  53567. set isEnabled(value: boolean);
  53568. get isEnabled(): boolean;
  53569. /**
  53570. * Disposes of the gizmo
  53571. */
  53572. dispose(): void;
  53573. }
  53574. }
  53575. declare module BABYLON.Debug {
  53576. /**
  53577. * The Axes viewer will show 3 axes in a specific point in space
  53578. */
  53579. export class AxesViewer {
  53580. private _xAxis;
  53581. private _yAxis;
  53582. private _zAxis;
  53583. private _scaleLinesFactor;
  53584. private _instanced;
  53585. /**
  53586. * Gets the hosting scene
  53587. */
  53588. scene: Nullable<Scene>;
  53589. /**
  53590. * Gets or sets a number used to scale line length
  53591. */
  53592. scaleLines: number;
  53593. /** Gets the node hierarchy used to render x-axis */
  53594. get xAxis(): TransformNode;
  53595. /** Gets the node hierarchy used to render y-axis */
  53596. get yAxis(): TransformNode;
  53597. /** Gets the node hierarchy used to render z-axis */
  53598. get zAxis(): TransformNode;
  53599. /**
  53600. * Creates a new AxesViewer
  53601. * @param scene defines the hosting scene
  53602. * @param scaleLines defines a number used to scale line length (1 by default)
  53603. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  53604. * @param xAxis defines the node hierarchy used to render the x-axis
  53605. * @param yAxis defines the node hierarchy used to render the y-axis
  53606. * @param zAxis defines the node hierarchy used to render the z-axis
  53607. */
  53608. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  53609. /**
  53610. * Force the viewer to update
  53611. * @param position defines the position of the viewer
  53612. * @param xaxis defines the x axis of the viewer
  53613. * @param yaxis defines the y axis of the viewer
  53614. * @param zaxis defines the z axis of the viewer
  53615. */
  53616. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  53617. /**
  53618. * Creates an instance of this axes viewer.
  53619. * @returns a new axes viewer with instanced meshes
  53620. */
  53621. createInstance(): AxesViewer;
  53622. /** Releases resources */
  53623. dispose(): void;
  53624. private static _SetRenderingGroupId;
  53625. }
  53626. }
  53627. declare module BABYLON.Debug {
  53628. /**
  53629. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  53630. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  53631. */
  53632. export class BoneAxesViewer extends AxesViewer {
  53633. /**
  53634. * Gets or sets the target mesh where to display the axes viewer
  53635. */
  53636. mesh: Nullable<Mesh>;
  53637. /**
  53638. * Gets or sets the target bone where to display the axes viewer
  53639. */
  53640. bone: Nullable<Bone>;
  53641. /** Gets current position */
  53642. pos: Vector3;
  53643. /** Gets direction of X axis */
  53644. xaxis: Vector3;
  53645. /** Gets direction of Y axis */
  53646. yaxis: Vector3;
  53647. /** Gets direction of Z axis */
  53648. zaxis: Vector3;
  53649. /**
  53650. * Creates a new BoneAxesViewer
  53651. * @param scene defines the hosting scene
  53652. * @param bone defines the target bone
  53653. * @param mesh defines the target mesh
  53654. * @param scaleLines defines a scaling factor for line length (1 by default)
  53655. */
  53656. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  53657. /**
  53658. * Force the viewer to update
  53659. */
  53660. update(): void;
  53661. /** Releases resources */
  53662. dispose(): void;
  53663. }
  53664. }
  53665. declare module BABYLON {
  53666. /**
  53667. * Interface used to define scene explorer extensibility option
  53668. */
  53669. export interface IExplorerExtensibilityOption {
  53670. /**
  53671. * Define the option label
  53672. */
  53673. label: string;
  53674. /**
  53675. * Defines the action to execute on click
  53676. */
  53677. action: (entity: any) => void;
  53678. }
  53679. /**
  53680. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  53681. */
  53682. export interface IExplorerExtensibilityGroup {
  53683. /**
  53684. * Defines a predicate to test if a given type mut be extended
  53685. */
  53686. predicate: (entity: any) => boolean;
  53687. /**
  53688. * Gets the list of options added to a type
  53689. */
  53690. entries: IExplorerExtensibilityOption[];
  53691. }
  53692. /**
  53693. * Interface used to define the options to use to create the Inspector
  53694. */
  53695. export interface IInspectorOptions {
  53696. /**
  53697. * Display in overlay mode (default: false)
  53698. */
  53699. overlay?: boolean;
  53700. /**
  53701. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  53702. */
  53703. globalRoot?: HTMLElement;
  53704. /**
  53705. * Display the Scene explorer
  53706. */
  53707. showExplorer?: boolean;
  53708. /**
  53709. * Display the property inspector
  53710. */
  53711. showInspector?: boolean;
  53712. /**
  53713. * Display in embed mode (both panes on the right)
  53714. */
  53715. embedMode?: boolean;
  53716. /**
  53717. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  53718. */
  53719. handleResize?: boolean;
  53720. /**
  53721. * Allow the panes to popup (default: true)
  53722. */
  53723. enablePopup?: boolean;
  53724. /**
  53725. * Allow the panes to be closed by users (default: true)
  53726. */
  53727. enableClose?: boolean;
  53728. /**
  53729. * Optional list of extensibility entries
  53730. */
  53731. explorerExtensibility?: IExplorerExtensibilityGroup[];
  53732. /**
  53733. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  53734. */
  53735. inspectorURL?: string;
  53736. /**
  53737. * Optional initial tab (default to DebugLayerTab.Properties)
  53738. */
  53739. initialTab?: DebugLayerTab;
  53740. }
  53741. interface Scene {
  53742. /**
  53743. * @hidden
  53744. * Backing field
  53745. */
  53746. _debugLayer: DebugLayer;
  53747. /**
  53748. * Gets the debug layer (aka Inspector) associated with the scene
  53749. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53750. */
  53751. debugLayer: DebugLayer;
  53752. }
  53753. /**
  53754. * Enum of inspector action tab
  53755. */
  53756. export enum DebugLayerTab {
  53757. /**
  53758. * Properties tag (default)
  53759. */
  53760. Properties = 0,
  53761. /**
  53762. * Debug tab
  53763. */
  53764. Debug = 1,
  53765. /**
  53766. * Statistics tab
  53767. */
  53768. Statistics = 2,
  53769. /**
  53770. * Tools tab
  53771. */
  53772. Tools = 3,
  53773. /**
  53774. * Settings tab
  53775. */
  53776. Settings = 4
  53777. }
  53778. /**
  53779. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53780. * what is happening in your scene
  53781. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53782. */
  53783. export class DebugLayer {
  53784. /**
  53785. * Define the url to get the inspector script from.
  53786. * By default it uses the babylonjs CDN.
  53787. * @ignoreNaming
  53788. */
  53789. static InspectorURL: string;
  53790. private _scene;
  53791. private BJSINSPECTOR;
  53792. private _onPropertyChangedObservable?;
  53793. /**
  53794. * Observable triggered when a property is changed through the inspector.
  53795. */
  53796. get onPropertyChangedObservable(): any;
  53797. /**
  53798. * Instantiates a new debug layer.
  53799. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53800. * what is happening in your scene
  53801. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53802. * @param scene Defines the scene to inspect
  53803. */
  53804. constructor(scene: Scene);
  53805. /** Creates the inspector window. */
  53806. private _createInspector;
  53807. /**
  53808. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  53809. * @param entity defines the entity to select
  53810. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  53811. */
  53812. select(entity: any, lineContainerTitles?: string | string[]): void;
  53813. /** Get the inspector from bundle or global */
  53814. private _getGlobalInspector;
  53815. /**
  53816. * Get if the inspector is visible or not.
  53817. * @returns true if visible otherwise, false
  53818. */
  53819. isVisible(): boolean;
  53820. /**
  53821. * Hide the inspector and close its window.
  53822. */
  53823. hide(): void;
  53824. /**
  53825. * Update the scene in the inspector
  53826. */
  53827. setAsActiveScene(): void;
  53828. /**
  53829. * Launch the debugLayer.
  53830. * @param config Define the configuration of the inspector
  53831. * @return a promise fulfilled when the debug layer is visible
  53832. */
  53833. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53834. }
  53835. }
  53836. declare module BABYLON {
  53837. /**
  53838. * Class containing static functions to help procedurally build meshes
  53839. */
  53840. export class BoxBuilder {
  53841. /**
  53842. * Creates a box mesh
  53843. * * The parameter `size` sets the size (float) of each box side (default 1)
  53844. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53845. * * 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)
  53846. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53848. * * 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
  53849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53850. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53851. * @param name defines the name of the mesh
  53852. * @param options defines the options used to create the mesh
  53853. * @param scene defines the hosting scene
  53854. * @returns the box mesh
  53855. */
  53856. static CreateBox(name: string, options: {
  53857. size?: number;
  53858. width?: number;
  53859. height?: number;
  53860. depth?: number;
  53861. faceUV?: Vector4[];
  53862. faceColors?: Color4[];
  53863. sideOrientation?: number;
  53864. frontUVs?: Vector4;
  53865. backUVs?: Vector4;
  53866. wrap?: boolean;
  53867. topBaseAt?: number;
  53868. bottomBaseAt?: number;
  53869. updatable?: boolean;
  53870. }, scene?: Nullable<Scene>): Mesh;
  53871. }
  53872. }
  53873. declare module BABYLON.Debug {
  53874. /**
  53875. * Used to show the physics impostor around the specific mesh
  53876. */
  53877. export class PhysicsViewer {
  53878. /** @hidden */
  53879. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53880. /** @hidden */
  53881. protected _meshes: Array<Nullable<AbstractMesh>>;
  53882. /** @hidden */
  53883. protected _scene: Nullable<Scene>;
  53884. /** @hidden */
  53885. protected _numMeshes: number;
  53886. /** @hidden */
  53887. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53888. private _renderFunction;
  53889. private _utilityLayer;
  53890. private _debugBoxMesh;
  53891. private _debugSphereMesh;
  53892. private _debugCylinderMesh;
  53893. private _debugMaterial;
  53894. private _debugMeshMeshes;
  53895. /**
  53896. * Creates a new PhysicsViewer
  53897. * @param scene defines the hosting scene
  53898. */
  53899. constructor(scene: Scene);
  53900. /** @hidden */
  53901. protected _updateDebugMeshes(): void;
  53902. /**
  53903. * Renders a specified physic impostor
  53904. * @param impostor defines the impostor to render
  53905. * @param targetMesh defines the mesh represented by the impostor
  53906. * @returns the new debug mesh used to render the impostor
  53907. */
  53908. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53909. /**
  53910. * Hides a specified physic impostor
  53911. * @param impostor defines the impostor to hide
  53912. */
  53913. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53914. private _getDebugMaterial;
  53915. private _getDebugBoxMesh;
  53916. private _getDebugSphereMesh;
  53917. private _getDebugCylinderMesh;
  53918. private _getDebugMeshMesh;
  53919. private _getDebugMesh;
  53920. /** Releases all resources */
  53921. dispose(): void;
  53922. }
  53923. }
  53924. declare module BABYLON {
  53925. /**
  53926. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53927. * in order to better appreciate the issue one might have.
  53928. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53929. */
  53930. export class RayHelper {
  53931. /**
  53932. * Defines the ray we are currently tryin to visualize.
  53933. */
  53934. ray: Nullable<Ray>;
  53935. private _renderPoints;
  53936. private _renderLine;
  53937. private _renderFunction;
  53938. private _scene;
  53939. private _onAfterRenderObserver;
  53940. private _onAfterStepObserver;
  53941. private _attachedToMesh;
  53942. private _meshSpaceDirection;
  53943. private _meshSpaceOrigin;
  53944. /**
  53945. * Helper function to create a colored helper in a scene in one line.
  53946. * @param ray Defines the ray we are currently tryin to visualize
  53947. * @param scene Defines the scene the ray is used in
  53948. * @param color Defines the color we want to see the ray in
  53949. * @returns The newly created ray helper.
  53950. */
  53951. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53952. /**
  53953. * Instantiate a new ray helper.
  53954. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53955. * in order to better appreciate the issue one might have.
  53956. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53957. * @param ray Defines the ray we are currently tryin to visualize
  53958. */
  53959. constructor(ray: Ray);
  53960. /**
  53961. * Shows the ray we are willing to debug.
  53962. * @param scene Defines the scene the ray needs to be rendered in
  53963. * @param color Defines the color the ray needs to be rendered in
  53964. */
  53965. show(scene: Scene, color?: Color3): void;
  53966. /**
  53967. * Hides the ray we are debugging.
  53968. */
  53969. hide(): void;
  53970. private _render;
  53971. /**
  53972. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53973. * @param mesh Defines the mesh we want the helper attached to
  53974. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53975. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53976. * @param length Defines the length of the ray
  53977. */
  53978. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53979. /**
  53980. * Detach the ray helper from the mesh it has previously been attached to.
  53981. */
  53982. detachFromMesh(): void;
  53983. private _updateToMesh;
  53984. /**
  53985. * Dispose the helper and release its associated resources.
  53986. */
  53987. dispose(): void;
  53988. }
  53989. }
  53990. declare module BABYLON {
  53991. /**
  53992. * Defines the options associated with the creation of a SkeletonViewer.
  53993. */
  53994. export interface ISkeletonViewerOptions {
  53995. /** Should the system pause animations before building the Viewer? */
  53996. pauseAnimations: boolean;
  53997. /** Should the system return the skeleton to rest before building? */
  53998. returnToRest: boolean;
  53999. /** public Display Mode of the Viewer */
  54000. displayMode: number;
  54001. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54002. displayOptions: ISkeletonViewerDisplayOptions;
  54003. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54004. computeBonesUsingShaders: boolean;
  54005. /** Flag ignore non weighted bones */
  54006. useAllBones: boolean;
  54007. }
  54008. /**
  54009. * Defines how to display the various bone meshes for the viewer.
  54010. */
  54011. export interface ISkeletonViewerDisplayOptions {
  54012. /** How far down to start tapering the bone spurs */
  54013. midStep?: number;
  54014. /** How big is the midStep? */
  54015. midStepFactor?: number;
  54016. /** Base for the Sphere Size */
  54017. sphereBaseSize?: number;
  54018. /** The ratio of the sphere to the longest bone in units */
  54019. sphereScaleUnit?: number;
  54020. /** Ratio for the Sphere Size */
  54021. sphereFactor?: number;
  54022. /** Whether a spur should attach its far end to the child bone position */
  54023. spurFollowsChild?: boolean;
  54024. /** Whether to show local axes or not */
  54025. showLocalAxes?: boolean;
  54026. /** Length of each local axis */
  54027. localAxesSize?: number;
  54028. }
  54029. /**
  54030. * Defines the constructor options for the BoneWeight Shader.
  54031. */
  54032. export interface IBoneWeightShaderOptions {
  54033. /** Skeleton to Map */
  54034. skeleton: Skeleton;
  54035. /** Colors for Uninfluenced bones */
  54036. colorBase?: Color3;
  54037. /** Colors for 0.0-0.25 Weight bones */
  54038. colorZero?: Color3;
  54039. /** Color for 0.25-0.5 Weight Influence */
  54040. colorQuarter?: Color3;
  54041. /** Color for 0.5-0.75 Weight Influence */
  54042. colorHalf?: Color3;
  54043. /** Color for 0.75-1 Weight Influence */
  54044. colorFull?: Color3;
  54045. /** Color for Zero Weight Influence */
  54046. targetBoneIndex?: number;
  54047. }
  54048. /**
  54049. * Simple structure of the gradient steps for the Color Map.
  54050. */
  54051. export interface ISkeletonMapShaderColorMapKnot {
  54052. /** Color of the Knot */
  54053. color: Color3;
  54054. /** Location of the Knot */
  54055. location: number;
  54056. }
  54057. /**
  54058. * Defines the constructor options for the SkeletonMap Shader.
  54059. */
  54060. export interface ISkeletonMapShaderOptions {
  54061. /** Skeleton to Map */
  54062. skeleton: Skeleton;
  54063. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54064. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54065. }
  54066. }
  54067. declare module BABYLON {
  54068. /**
  54069. * Class containing static functions to help procedurally build meshes
  54070. */
  54071. export class RibbonBuilder {
  54072. /**
  54073. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54074. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54075. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54076. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54077. * * 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
  54078. * * 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
  54079. * * 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
  54080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54081. * * 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
  54082. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54083. * * 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
  54084. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54085. * * 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
  54086. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54088. * @param name defines the name of the mesh
  54089. * @param options defines the options used to create the mesh
  54090. * @param scene defines the hosting scene
  54091. * @returns the ribbon mesh
  54092. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54093. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54094. */
  54095. static CreateRibbon(name: string, options: {
  54096. pathArray: Vector3[][];
  54097. closeArray?: boolean;
  54098. closePath?: boolean;
  54099. offset?: number;
  54100. updatable?: boolean;
  54101. sideOrientation?: number;
  54102. frontUVs?: Vector4;
  54103. backUVs?: Vector4;
  54104. instance?: Mesh;
  54105. invertUV?: boolean;
  54106. uvs?: Vector2[];
  54107. colors?: Color4[];
  54108. }, scene?: Nullable<Scene>): Mesh;
  54109. }
  54110. }
  54111. declare module BABYLON {
  54112. /**
  54113. * Class containing static functions to help procedurally build meshes
  54114. */
  54115. export class ShapeBuilder {
  54116. /**
  54117. * 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.
  54118. * * 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.
  54119. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54120. * * 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.
  54121. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54122. * * 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
  54123. * * 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
  54124. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54126. * * 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
  54127. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54129. * @param name defines the name of the mesh
  54130. * @param options defines the options used to create the mesh
  54131. * @param scene defines the hosting scene
  54132. * @returns the extruded shape mesh
  54133. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54134. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54135. */
  54136. static ExtrudeShape(name: string, options: {
  54137. shape: Vector3[];
  54138. path: Vector3[];
  54139. scale?: number;
  54140. rotation?: number;
  54141. cap?: number;
  54142. updatable?: boolean;
  54143. sideOrientation?: number;
  54144. frontUVs?: Vector4;
  54145. backUVs?: Vector4;
  54146. instance?: Mesh;
  54147. invertUV?: boolean;
  54148. }, scene?: Nullable<Scene>): Mesh;
  54149. /**
  54150. * Creates an custom extruded shape mesh.
  54151. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54152. * * 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.
  54153. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54154. * * 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
  54155. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54156. * * 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
  54157. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54158. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54159. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54160. * * 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
  54161. * * 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
  54162. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54164. * * 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
  54165. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54167. * @param name defines the name of the mesh
  54168. * @param options defines the options used to create the mesh
  54169. * @param scene defines the hosting scene
  54170. * @returns the custom extruded shape mesh
  54171. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54172. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54174. */
  54175. static ExtrudeShapeCustom(name: string, options: {
  54176. shape: Vector3[];
  54177. path: Vector3[];
  54178. scaleFunction?: any;
  54179. rotationFunction?: any;
  54180. ribbonCloseArray?: boolean;
  54181. ribbonClosePath?: boolean;
  54182. cap?: number;
  54183. updatable?: boolean;
  54184. sideOrientation?: number;
  54185. frontUVs?: Vector4;
  54186. backUVs?: Vector4;
  54187. instance?: Mesh;
  54188. invertUV?: boolean;
  54189. }, scene?: Nullable<Scene>): Mesh;
  54190. private static _ExtrudeShapeGeneric;
  54191. }
  54192. }
  54193. declare module BABYLON.Debug {
  54194. /**
  54195. * Class used to render a debug view of a given skeleton
  54196. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54197. */
  54198. export class SkeletonViewer {
  54199. /** defines the skeleton to render */
  54200. skeleton: Skeleton;
  54201. /** defines the mesh attached to the skeleton */
  54202. mesh: AbstractMesh;
  54203. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54204. autoUpdateBonesMatrices: boolean;
  54205. /** defines the rendering group id to use with the viewer */
  54206. renderingGroupId: number;
  54207. /** is the options for the viewer */
  54208. options: Partial<ISkeletonViewerOptions>;
  54209. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54210. static readonly DISPLAY_LINES: number;
  54211. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54212. static readonly DISPLAY_SPHERES: number;
  54213. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54214. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54215. /** public static method to create a BoneWeight Shader
  54216. * @param options The constructor options
  54217. * @param scene The scene that the shader is scoped to
  54218. * @returns The created ShaderMaterial
  54219. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54220. */
  54221. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54222. /** public static method to create a BoneWeight Shader
  54223. * @param options The constructor options
  54224. * @param scene The scene that the shader is scoped to
  54225. * @returns The created ShaderMaterial
  54226. */
  54227. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54228. /** private static method to create a BoneWeight Shader
  54229. * @param size The size of the buffer to create (usually the bone count)
  54230. * @param colorMap The gradient data to generate
  54231. * @param scene The scene that the shader is scoped to
  54232. * @returns an Array of floats from the color gradient values
  54233. */
  54234. private static _CreateBoneMapColorBuffer;
  54235. /** If SkeletonViewer scene scope. */
  54236. private _scene;
  54237. /** Gets or sets the color used to render the skeleton */
  54238. color: Color3;
  54239. /** Array of the points of the skeleton fo the line view. */
  54240. private _debugLines;
  54241. /** The SkeletonViewers Mesh. */
  54242. private _debugMesh;
  54243. /** The local axes Meshes. */
  54244. private _localAxes;
  54245. /** If SkeletonViewer is enabled. */
  54246. private _isEnabled;
  54247. /** If SkeletonViewer is ready. */
  54248. private _ready;
  54249. /** SkeletonViewer render observable. */
  54250. private _obs;
  54251. /** The Utility Layer to render the gizmos in. */
  54252. private _utilityLayer;
  54253. private _boneIndices;
  54254. /** Gets the Scene. */
  54255. get scene(): Scene;
  54256. /** Gets the utilityLayer. */
  54257. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54258. /** Checks Ready Status. */
  54259. get isReady(): Boolean;
  54260. /** Sets Ready Status. */
  54261. set ready(value: boolean);
  54262. /** Gets the debugMesh */
  54263. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54264. /** Sets the debugMesh */
  54265. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54266. /** Gets the displayMode */
  54267. get displayMode(): number;
  54268. /** Sets the displayMode */
  54269. set displayMode(value: number);
  54270. /**
  54271. * Creates a new SkeletonViewer
  54272. * @param skeleton defines the skeleton to render
  54273. * @param mesh defines the mesh attached to the skeleton
  54274. * @param scene defines the hosting scene
  54275. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54276. * @param renderingGroupId defines the rendering group id to use with the viewer
  54277. * @param options All of the extra constructor options for the SkeletonViewer
  54278. */
  54279. constructor(
  54280. /** defines the skeleton to render */
  54281. skeleton: Skeleton,
  54282. /** defines the mesh attached to the skeleton */
  54283. mesh: AbstractMesh,
  54284. /** The Scene scope*/
  54285. scene: Scene,
  54286. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54287. autoUpdateBonesMatrices?: boolean,
  54288. /** defines the rendering group id to use with the viewer */
  54289. renderingGroupId?: number,
  54290. /** is the options for the viewer */
  54291. options?: Partial<ISkeletonViewerOptions>);
  54292. /** The Dynamic bindings for the update functions */
  54293. private _bindObs;
  54294. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54295. update(): void;
  54296. /** Gets or sets a boolean indicating if the viewer is enabled */
  54297. set isEnabled(value: boolean);
  54298. get isEnabled(): boolean;
  54299. private _getBonePosition;
  54300. private _getLinesForBonesWithLength;
  54301. private _getLinesForBonesNoLength;
  54302. /** function to revert the mesh and scene back to the initial state. */
  54303. private _revert;
  54304. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54305. private _getAbsoluteBindPoseToRef;
  54306. /** function to build and bind sphere joint points and spur bone representations. */
  54307. private _buildSpheresAndSpurs;
  54308. private _buildLocalAxes;
  54309. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54310. private _displayLinesUpdate;
  54311. /** Changes the displayMode of the skeleton viewer
  54312. * @param mode The displayMode numerical value
  54313. */
  54314. changeDisplayMode(mode: number): void;
  54315. /** Sets a display option of the skeleton viewer
  54316. *
  54317. * | Option | Type | Default | Description |
  54318. * | ---------------- | ------- | ------- | ----------- |
  54319. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54320. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54321. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54322. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54323. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54324. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54325. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54326. *
  54327. * @param option String of the option name
  54328. * @param value The numerical option value
  54329. */
  54330. changeDisplayOptions(option: string, value: number): void;
  54331. /** Release associated resources */
  54332. dispose(): void;
  54333. }
  54334. }
  54335. declare module BABYLON {
  54336. /**
  54337. * Enum for Device Types
  54338. */
  54339. export enum DeviceType {
  54340. /** Generic */
  54341. Generic = 0,
  54342. /** Keyboard */
  54343. Keyboard = 1,
  54344. /** Mouse */
  54345. Mouse = 2,
  54346. /** Touch Pointers */
  54347. Touch = 3,
  54348. /** PS4 Dual Shock */
  54349. DualShock = 4,
  54350. /** Xbox */
  54351. Xbox = 5,
  54352. /** Switch Controller */
  54353. Switch = 6
  54354. }
  54355. /**
  54356. * Enum for All Pointers (Touch/Mouse)
  54357. */
  54358. export enum PointerInput {
  54359. /** Horizontal Axis */
  54360. Horizontal = 0,
  54361. /** Vertical Axis */
  54362. Vertical = 1,
  54363. /** Left Click or Touch */
  54364. LeftClick = 2,
  54365. /** Middle Click */
  54366. MiddleClick = 3,
  54367. /** Right Click */
  54368. RightClick = 4,
  54369. /** Browser Back */
  54370. BrowserBack = 5,
  54371. /** Browser Forward */
  54372. BrowserForward = 6
  54373. }
  54374. /**
  54375. * Enum for Dual Shock Gamepad
  54376. */
  54377. export enum DualShockInput {
  54378. /** Cross */
  54379. Cross = 0,
  54380. /** Circle */
  54381. Circle = 1,
  54382. /** Square */
  54383. Square = 2,
  54384. /** Triangle */
  54385. Triangle = 3,
  54386. /** L1 */
  54387. L1 = 4,
  54388. /** R1 */
  54389. R1 = 5,
  54390. /** L2 */
  54391. L2 = 6,
  54392. /** R2 */
  54393. R2 = 7,
  54394. /** Share */
  54395. Share = 8,
  54396. /** Options */
  54397. Options = 9,
  54398. /** L3 */
  54399. L3 = 10,
  54400. /** R3 */
  54401. R3 = 11,
  54402. /** DPadUp */
  54403. DPadUp = 12,
  54404. /** DPadDown */
  54405. DPadDown = 13,
  54406. /** DPadLeft */
  54407. DPadLeft = 14,
  54408. /** DRight */
  54409. DPadRight = 15,
  54410. /** Home */
  54411. Home = 16,
  54412. /** TouchPad */
  54413. TouchPad = 17,
  54414. /** LStickXAxis */
  54415. LStickXAxis = 18,
  54416. /** LStickYAxis */
  54417. LStickYAxis = 19,
  54418. /** RStickXAxis */
  54419. RStickXAxis = 20,
  54420. /** RStickYAxis */
  54421. RStickYAxis = 21
  54422. }
  54423. /**
  54424. * Enum for Xbox Gamepad
  54425. */
  54426. export enum XboxInput {
  54427. /** A */
  54428. A = 0,
  54429. /** B */
  54430. B = 1,
  54431. /** X */
  54432. X = 2,
  54433. /** Y */
  54434. Y = 3,
  54435. /** LB */
  54436. LB = 4,
  54437. /** RB */
  54438. RB = 5,
  54439. /** LT */
  54440. LT = 6,
  54441. /** RT */
  54442. RT = 7,
  54443. /** Back */
  54444. Back = 8,
  54445. /** Start */
  54446. Start = 9,
  54447. /** LS */
  54448. LS = 10,
  54449. /** RS */
  54450. RS = 11,
  54451. /** DPadUp */
  54452. DPadUp = 12,
  54453. /** DPadDown */
  54454. DPadDown = 13,
  54455. /** DPadLeft */
  54456. DPadLeft = 14,
  54457. /** DRight */
  54458. DPadRight = 15,
  54459. /** Home */
  54460. Home = 16,
  54461. /** LStickXAxis */
  54462. LStickXAxis = 17,
  54463. /** LStickYAxis */
  54464. LStickYAxis = 18,
  54465. /** RStickXAxis */
  54466. RStickXAxis = 19,
  54467. /** RStickYAxis */
  54468. RStickYAxis = 20
  54469. }
  54470. /**
  54471. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54472. */
  54473. export enum SwitchInput {
  54474. /** B */
  54475. B = 0,
  54476. /** A */
  54477. A = 1,
  54478. /** Y */
  54479. Y = 2,
  54480. /** X */
  54481. X = 3,
  54482. /** L */
  54483. L = 4,
  54484. /** R */
  54485. R = 5,
  54486. /** ZL */
  54487. ZL = 6,
  54488. /** ZR */
  54489. ZR = 7,
  54490. /** Minus */
  54491. Minus = 8,
  54492. /** Plus */
  54493. Plus = 9,
  54494. /** LS */
  54495. LS = 10,
  54496. /** RS */
  54497. RS = 11,
  54498. /** DPadUp */
  54499. DPadUp = 12,
  54500. /** DPadDown */
  54501. DPadDown = 13,
  54502. /** DPadLeft */
  54503. DPadLeft = 14,
  54504. /** DRight */
  54505. DPadRight = 15,
  54506. /** Home */
  54507. Home = 16,
  54508. /** Capture */
  54509. Capture = 17,
  54510. /** LStickXAxis */
  54511. LStickXAxis = 18,
  54512. /** LStickYAxis */
  54513. LStickYAxis = 19,
  54514. /** RStickXAxis */
  54515. RStickXAxis = 20,
  54516. /** RStickYAxis */
  54517. RStickYAxis = 21
  54518. }
  54519. }
  54520. declare module BABYLON {
  54521. /**
  54522. * This class will take all inputs from Keyboard, Pointer, and
  54523. * any Gamepads and provide a polling system that all devices
  54524. * will use. This class assumes that there will only be one
  54525. * pointer device and one keyboard.
  54526. */
  54527. export class DeviceInputSystem implements IDisposable {
  54528. /**
  54529. * Callback to be triggered when a device is connected
  54530. */
  54531. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54532. /**
  54533. * Callback to be triggered when a device is disconnected
  54534. */
  54535. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54536. /**
  54537. * Callback to be triggered when event driven input is updated
  54538. */
  54539. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  54540. private _inputs;
  54541. private _gamepads;
  54542. private _keyboardActive;
  54543. private _pointerActive;
  54544. private _elementToAttachTo;
  54545. private _keyboardDownEvent;
  54546. private _keyboardUpEvent;
  54547. private _pointerMoveEvent;
  54548. private _pointerDownEvent;
  54549. private _pointerUpEvent;
  54550. private _gamepadConnectedEvent;
  54551. private _gamepadDisconnectedEvent;
  54552. private static _MAX_KEYCODES;
  54553. private static _MAX_POINTER_INPUTS;
  54554. private constructor();
  54555. /**
  54556. * Creates a new DeviceInputSystem instance
  54557. * @param engine Engine to pull input element from
  54558. * @returns The new instance
  54559. */
  54560. static Create(engine: Engine): DeviceInputSystem;
  54561. /**
  54562. * Checks for current device input value, given an id and input index
  54563. * @param deviceName Id of connected device
  54564. * @param inputIndex Index of device input
  54565. * @returns Current value of input
  54566. */
  54567. /**
  54568. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  54569. * @param deviceType Enum specifiying device type
  54570. * @param deviceSlot "Slot" or index that device is referenced in
  54571. * @param inputIndex Id of input to be checked
  54572. * @returns Current value of input
  54573. */
  54574. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  54575. /**
  54576. * Dispose of all the eventlisteners
  54577. */
  54578. dispose(): void;
  54579. /**
  54580. * Add device and inputs to device array
  54581. * @param deviceType Enum specifiying device type
  54582. * @param deviceSlot "Slot" or index that device is referenced in
  54583. * @param numberOfInputs Number of input entries to create for given device
  54584. */
  54585. private _registerDevice;
  54586. /**
  54587. * Given a specific device name, remove that device from the device map
  54588. * @param deviceType Enum specifiying device type
  54589. * @param deviceSlot "Slot" or index that device is referenced in
  54590. */
  54591. private _unregisterDevice;
  54592. /**
  54593. * Handle all actions that come from keyboard interaction
  54594. */
  54595. private _handleKeyActions;
  54596. /**
  54597. * Handle all actions that come from pointer interaction
  54598. */
  54599. private _handlePointerActions;
  54600. /**
  54601. * Handle all actions that come from gamepad interaction
  54602. */
  54603. private _handleGamepadActions;
  54604. /**
  54605. * Update all non-event based devices with each frame
  54606. * @param deviceType Enum specifiying device type
  54607. * @param deviceSlot "Slot" or index that device is referenced in
  54608. * @param inputIndex Id of input to be checked
  54609. */
  54610. private _updateDevice;
  54611. /**
  54612. * Gets DeviceType from the device name
  54613. * @param deviceName Name of Device from DeviceInputSystem
  54614. * @returns DeviceType enum value
  54615. */
  54616. private _getGamepadDeviceType;
  54617. }
  54618. }
  54619. declare module BABYLON {
  54620. /**
  54621. * Type to handle enforcement of inputs
  54622. */
  54623. 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;
  54624. }
  54625. declare module BABYLON {
  54626. /**
  54627. * Class that handles all input for a specific device
  54628. */
  54629. export class DeviceSource<T extends DeviceType> {
  54630. /** Type of device */
  54631. readonly deviceType: DeviceType;
  54632. /** "Slot" or index that device is referenced in */
  54633. readonly deviceSlot: number;
  54634. /**
  54635. * Observable to handle device input changes per device
  54636. */
  54637. readonly onInputChangedObservable: Observable<{
  54638. inputIndex: DeviceInput<T>;
  54639. previousState: Nullable<number>;
  54640. currentState: Nullable<number>;
  54641. }>;
  54642. private readonly _deviceInputSystem;
  54643. /**
  54644. * Default Constructor
  54645. * @param deviceInputSystem Reference to DeviceInputSystem
  54646. * @param deviceType Type of device
  54647. * @param deviceSlot "Slot" or index that device is referenced in
  54648. */
  54649. constructor(deviceInputSystem: DeviceInputSystem,
  54650. /** Type of device */
  54651. deviceType: DeviceType,
  54652. /** "Slot" or index that device is referenced in */
  54653. deviceSlot?: number);
  54654. /**
  54655. * Get input for specific input
  54656. * @param inputIndex index of specific input on device
  54657. * @returns Input value from DeviceInputSystem
  54658. */
  54659. getInput(inputIndex: DeviceInput<T>): number;
  54660. }
  54661. /**
  54662. * Class to keep track of devices
  54663. */
  54664. export class DeviceSourceManager implements IDisposable {
  54665. /**
  54666. * Observable to be triggered when before a device is connected
  54667. */
  54668. readonly onBeforeDeviceConnectedObservable: Observable<{
  54669. deviceType: DeviceType;
  54670. deviceSlot: number;
  54671. }>;
  54672. /**
  54673. * Observable to be triggered when before a device is disconnected
  54674. */
  54675. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  54676. deviceType: DeviceType;
  54677. deviceSlot: number;
  54678. }>;
  54679. /**
  54680. * Observable to be triggered when after a device is connected
  54681. */
  54682. readonly onAfterDeviceConnectedObservable: Observable<{
  54683. deviceType: DeviceType;
  54684. deviceSlot: number;
  54685. }>;
  54686. /**
  54687. * Observable to be triggered when after a device is disconnected
  54688. */
  54689. readonly onAfterDeviceDisconnectedObservable: Observable<{
  54690. deviceType: DeviceType;
  54691. deviceSlot: number;
  54692. }>;
  54693. private readonly _devices;
  54694. private readonly _firstDevice;
  54695. private readonly _deviceInputSystem;
  54696. /**
  54697. * Default Constructor
  54698. * @param engine engine to pull input element from
  54699. */
  54700. constructor(engine: Engine);
  54701. /**
  54702. * Gets a DeviceSource, given a type and slot
  54703. * @param deviceType Enum specifying device type
  54704. * @param deviceSlot "Slot" or index that device is referenced in
  54705. * @returns DeviceSource object
  54706. */
  54707. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  54708. /**
  54709. * Gets an array of DeviceSource objects for a given device type
  54710. * @param deviceType Enum specifying device type
  54711. * @returns Array of DeviceSource objects
  54712. */
  54713. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  54714. /**
  54715. * Dispose of DeviceInputSystem and other parts
  54716. */
  54717. dispose(): void;
  54718. /**
  54719. * Function to add device name to device list
  54720. * @param deviceType Enum specifying device type
  54721. * @param deviceSlot "Slot" or index that device is referenced in
  54722. */
  54723. private _addDevice;
  54724. /**
  54725. * Function to remove device name to device list
  54726. * @param deviceType Enum specifying device type
  54727. * @param deviceSlot "Slot" or index that device is referenced in
  54728. */
  54729. private _removeDevice;
  54730. /**
  54731. * Updates array storing first connected device of each type
  54732. * @param type Type of Device
  54733. */
  54734. private _updateFirstDevices;
  54735. }
  54736. }
  54737. declare module BABYLON {
  54738. /**
  54739. * Options to create the null engine
  54740. */
  54741. export class NullEngineOptions {
  54742. /**
  54743. * Render width (Default: 512)
  54744. */
  54745. renderWidth: number;
  54746. /**
  54747. * Render height (Default: 256)
  54748. */
  54749. renderHeight: number;
  54750. /**
  54751. * Texture size (Default: 512)
  54752. */
  54753. textureSize: number;
  54754. /**
  54755. * If delta time between frames should be constant
  54756. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54757. */
  54758. deterministicLockstep: boolean;
  54759. /**
  54760. * Maximum about of steps between frames (Default: 4)
  54761. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54762. */
  54763. lockstepMaxSteps: number;
  54764. /**
  54765. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54766. */
  54767. useHighPrecisionMatrix?: boolean;
  54768. }
  54769. /**
  54770. * The null engine class provides support for headless version of babylon.js.
  54771. * This can be used in server side scenario or for testing purposes
  54772. */
  54773. export class NullEngine extends Engine {
  54774. private _options;
  54775. /**
  54776. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54777. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54778. * @returns true if engine is in deterministic lock step mode
  54779. */
  54780. isDeterministicLockStep(): boolean;
  54781. /**
  54782. * Gets the max steps when engine is running in deterministic lock step
  54783. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54784. * @returns the max steps
  54785. */
  54786. getLockstepMaxSteps(): number;
  54787. /**
  54788. * Gets the current hardware scaling level.
  54789. * By default the hardware scaling level is computed from the window device ratio.
  54790. * 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.
  54791. * @returns a number indicating the current hardware scaling level
  54792. */
  54793. getHardwareScalingLevel(): number;
  54794. constructor(options?: NullEngineOptions);
  54795. /**
  54796. * Creates a vertex buffer
  54797. * @param vertices the data for the vertex buffer
  54798. * @returns the new WebGL static buffer
  54799. */
  54800. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54801. /**
  54802. * Creates a new index buffer
  54803. * @param indices defines the content of the index buffer
  54804. * @param updatable defines if the index buffer must be updatable
  54805. * @returns a new webGL buffer
  54806. */
  54807. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54808. /**
  54809. * Clear the current render buffer or the current render target (if any is set up)
  54810. * @param color defines the color to use
  54811. * @param backBuffer defines if the back buffer must be cleared
  54812. * @param depth defines if the depth buffer must be cleared
  54813. * @param stencil defines if the stencil buffer must be cleared
  54814. */
  54815. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54816. /**
  54817. * Gets the current render width
  54818. * @param useScreen defines if screen size must be used (or the current render target if any)
  54819. * @returns a number defining the current render width
  54820. */
  54821. getRenderWidth(useScreen?: boolean): number;
  54822. /**
  54823. * Gets the current render height
  54824. * @param useScreen defines if screen size must be used (or the current render target if any)
  54825. * @returns a number defining the current render height
  54826. */
  54827. getRenderHeight(useScreen?: boolean): number;
  54828. /**
  54829. * Set the WebGL's viewport
  54830. * @param viewport defines the viewport element to be used
  54831. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54832. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54833. */
  54834. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54835. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54836. /**
  54837. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54838. * @param pipelineContext defines the pipeline context to use
  54839. * @param uniformsNames defines the list of uniform names
  54840. * @returns an array of webGL uniform locations
  54841. */
  54842. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54843. /**
  54844. * Gets the lsit of active attributes for a given webGL program
  54845. * @param pipelineContext defines the pipeline context to use
  54846. * @param attributesNames defines the list of attribute names to get
  54847. * @returns an array of indices indicating the offset of each attribute
  54848. */
  54849. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54850. /**
  54851. * Binds an effect to the webGL context
  54852. * @param effect defines the effect to bind
  54853. */
  54854. bindSamplers(effect: Effect): void;
  54855. /**
  54856. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54857. * @param effect defines the effect to activate
  54858. */
  54859. enableEffect(effect: Effect): void;
  54860. /**
  54861. * Set various states to the webGL context
  54862. * @param culling defines backface culling state
  54863. * @param zOffset defines the value to apply to zOffset (0 by default)
  54864. * @param force defines if states must be applied even if cache is up to date
  54865. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54866. */
  54867. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54868. /**
  54869. * Set the value of an uniform to an array of int32
  54870. * @param uniform defines the webGL uniform location where to store the value
  54871. * @param array defines the array of int32 to store
  54872. * @returns true if value was set
  54873. */
  54874. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54875. /**
  54876. * Set the value of an uniform to an array of int32 (stored as vec2)
  54877. * @param uniform defines the webGL uniform location where to store the value
  54878. * @param array defines the array of int32 to store
  54879. * @returns true if value was set
  54880. */
  54881. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54882. /**
  54883. * Set the value of an uniform to an array of int32 (stored as vec3)
  54884. * @param uniform defines the webGL uniform location where to store the value
  54885. * @param array defines the array of int32 to store
  54886. * @returns true if value was set
  54887. */
  54888. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54889. /**
  54890. * Set the value of an uniform to an array of int32 (stored as vec4)
  54891. * @param uniform defines the webGL uniform location where to store the value
  54892. * @param array defines the array of int32 to store
  54893. * @returns true if value was set
  54894. */
  54895. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54896. /**
  54897. * Set the value of an uniform to an array of float32
  54898. * @param uniform defines the webGL uniform location where to store the value
  54899. * @param array defines the array of float32 to store
  54900. * @returns true if value was set
  54901. */
  54902. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54903. /**
  54904. * Set the value of an uniform to an array of float32 (stored as vec2)
  54905. * @param uniform defines the webGL uniform location where to store the value
  54906. * @param array defines the array of float32 to store
  54907. * @returns true if value was set
  54908. */
  54909. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54910. /**
  54911. * Set the value of an uniform to an array of float32 (stored as vec3)
  54912. * @param uniform defines the webGL uniform location where to store the value
  54913. * @param array defines the array of float32 to store
  54914. * @returns true if value was set
  54915. */
  54916. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54917. /**
  54918. * Set the value of an uniform to an array of float32 (stored as vec4)
  54919. * @param uniform defines the webGL uniform location where to store the value
  54920. * @param array defines the array of float32 to store
  54921. * @returns true if value was set
  54922. */
  54923. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54924. /**
  54925. * Set the value of an uniform to an array of number
  54926. * @param uniform defines the webGL uniform location where to store the value
  54927. * @param array defines the array of number to store
  54928. * @returns true if value was set
  54929. */
  54930. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54931. /**
  54932. * Set the value of an uniform to an array of number (stored as vec2)
  54933. * @param uniform defines the webGL uniform location where to store the value
  54934. * @param array defines the array of number to store
  54935. * @returns true if value was set
  54936. */
  54937. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  54938. /**
  54939. * Set the value of an uniform to an array of number (stored as vec3)
  54940. * @param uniform defines the webGL uniform location where to store the value
  54941. * @param array defines the array of number to store
  54942. * @returns true if value was set
  54943. */
  54944. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  54945. /**
  54946. * Set the value of an uniform to an array of number (stored as vec4)
  54947. * @param uniform defines the webGL uniform location where to store the value
  54948. * @param array defines the array of number to store
  54949. * @returns true if value was set
  54950. */
  54951. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  54952. /**
  54953. * Set the value of an uniform to an array of float32 (stored as matrices)
  54954. * @param uniform defines the webGL uniform location where to store the value
  54955. * @param matrices defines the array of float32 to store
  54956. * @returns true if value was set
  54957. */
  54958. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  54959. /**
  54960. * Set the value of an uniform to a matrix (3x3)
  54961. * @param uniform defines the webGL uniform location where to store the value
  54962. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54963. * @returns true if value was set
  54964. */
  54965. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54966. /**
  54967. * Set the value of an uniform to a matrix (2x2)
  54968. * @param uniform defines the webGL uniform location where to store the value
  54969. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54970. * @returns true if value was set
  54971. */
  54972. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54973. /**
  54974. * Set the value of an uniform to a number (float)
  54975. * @param uniform defines the webGL uniform location where to store the value
  54976. * @param value defines the float number to store
  54977. * @returns true if value was set
  54978. */
  54979. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  54980. /**
  54981. * Set the value of an uniform to a vec2
  54982. * @param uniform defines the webGL uniform location where to store the value
  54983. * @param x defines the 1st component of the value
  54984. * @param y defines the 2nd component of the value
  54985. * @returns true if value was set
  54986. */
  54987. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  54988. /**
  54989. * Set the value of an uniform to a vec3
  54990. * @param uniform defines the webGL uniform location where to store the value
  54991. * @param x defines the 1st component of the value
  54992. * @param y defines the 2nd component of the value
  54993. * @param z defines the 3rd component of the value
  54994. * @returns true if value was set
  54995. */
  54996. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  54997. /**
  54998. * Set the value of an uniform to a boolean
  54999. * @param uniform defines the webGL uniform location where to store the value
  55000. * @param bool defines the boolean to store
  55001. * @returns true if value was set
  55002. */
  55003. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55004. /**
  55005. * Set the value of an uniform to a vec4
  55006. * @param uniform defines the webGL uniform location where to store the value
  55007. * @param x defines the 1st component of the value
  55008. * @param y defines the 2nd component of the value
  55009. * @param z defines the 3rd component of the value
  55010. * @param w defines the 4th component of the value
  55011. * @returns true if value was set
  55012. */
  55013. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55014. /**
  55015. * Sets the current alpha mode
  55016. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55017. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55018. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55019. */
  55020. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55021. /**
  55022. * Bind webGl buffers directly to the webGL context
  55023. * @param vertexBuffers defines the vertex buffer to bind
  55024. * @param indexBuffer defines the index buffer to bind
  55025. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55026. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55027. * @param effect defines the effect associated with the vertex buffer
  55028. */
  55029. bindBuffers(vertexBuffers: {
  55030. [key: string]: VertexBuffer;
  55031. }, indexBuffer: DataBuffer, effect: Effect): void;
  55032. /**
  55033. * Force the entire cache to be cleared
  55034. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55035. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55036. */
  55037. wipeCaches(bruteForce?: boolean): void;
  55038. /**
  55039. * Send a draw order
  55040. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55041. * @param indexStart defines the starting index
  55042. * @param indexCount defines the number of index to draw
  55043. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55044. */
  55045. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55046. /**
  55047. * Draw a list of indexed primitives
  55048. * @param fillMode defines the primitive to use
  55049. * @param indexStart defines the starting index
  55050. * @param indexCount defines the number of index to draw
  55051. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55052. */
  55053. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55054. /**
  55055. * Draw a list of unindexed primitives
  55056. * @param fillMode defines the primitive to use
  55057. * @param verticesStart defines the index of first vertex to draw
  55058. * @param verticesCount defines the count of vertices to draw
  55059. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55060. */
  55061. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55062. /** @hidden */
  55063. _createTexture(): WebGLTexture;
  55064. /** @hidden */
  55065. _releaseTexture(texture: InternalTexture): void;
  55066. /**
  55067. * Usually called from Texture.ts.
  55068. * Passed information to create a WebGLTexture
  55069. * @param urlArg defines a value which contains one of the following:
  55070. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55071. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55072. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55073. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55074. * @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)
  55075. * @param scene needed for loading to the correct scene
  55076. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55077. * @param onLoad optional callback to be called upon successful completion
  55078. * @param onError optional callback to be called upon failure
  55079. * @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
  55080. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55081. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55082. * @param forcedExtension defines the extension to use to pick the right loader
  55083. * @param mimeType defines an optional mime type
  55084. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55085. */
  55086. 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;
  55087. /**
  55088. * Creates a new render target texture
  55089. * @param size defines the size of the texture
  55090. * @param options defines the options used to create the texture
  55091. * @returns a new render target texture stored in an InternalTexture
  55092. */
  55093. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55094. /**
  55095. * Update the sampling mode of a given texture
  55096. * @param samplingMode defines the required sampling mode
  55097. * @param texture defines the texture to update
  55098. */
  55099. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55100. /**
  55101. * Binds the frame buffer to the specified texture.
  55102. * @param texture The texture to render to or null for the default canvas
  55103. * @param faceIndex The face of the texture to render to in case of cube texture
  55104. * @param requiredWidth The width of the target to render to
  55105. * @param requiredHeight The height of the target to render to
  55106. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55107. * @param lodLevel defines le lod level to bind to the frame buffer
  55108. */
  55109. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55110. /**
  55111. * Unbind the current render target texture from the webGL context
  55112. * @param texture defines the render target texture to unbind
  55113. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55114. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55115. */
  55116. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55117. /**
  55118. * Creates a dynamic vertex buffer
  55119. * @param vertices the data for the dynamic vertex buffer
  55120. * @returns the new WebGL dynamic buffer
  55121. */
  55122. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55123. /**
  55124. * Update the content of a dynamic texture
  55125. * @param texture defines the texture to update
  55126. * @param canvas defines the canvas containing the source
  55127. * @param invertY defines if data must be stored with Y axis inverted
  55128. * @param premulAlpha defines if alpha is stored as premultiplied
  55129. * @param format defines the format of the data
  55130. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55131. */
  55132. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55133. /**
  55134. * Gets a boolean indicating if all created effects are ready
  55135. * @returns true if all effects are ready
  55136. */
  55137. areAllEffectsReady(): boolean;
  55138. /**
  55139. * @hidden
  55140. * Get the current error code of the webGL context
  55141. * @returns the error code
  55142. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55143. */
  55144. getError(): number;
  55145. /** @hidden */
  55146. _getUnpackAlignement(): number;
  55147. /** @hidden */
  55148. _unpackFlipY(value: boolean): void;
  55149. /**
  55150. * Update a dynamic index buffer
  55151. * @param indexBuffer defines the target index buffer
  55152. * @param indices defines the data to update
  55153. * @param offset defines the offset in the target index buffer where update should start
  55154. */
  55155. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55156. /**
  55157. * Updates a dynamic vertex buffer.
  55158. * @param vertexBuffer the vertex buffer to update
  55159. * @param vertices the data used to update the vertex buffer
  55160. * @param byteOffset the byte offset of the data (optional)
  55161. * @param byteLength the byte length of the data (optional)
  55162. */
  55163. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55164. /** @hidden */
  55165. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55166. /** @hidden */
  55167. _bindTexture(channel: number, texture: InternalTexture): void;
  55168. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55169. /**
  55170. * 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
  55171. */
  55172. releaseEffects(): void;
  55173. displayLoadingUI(): void;
  55174. hideLoadingUI(): void;
  55175. /** @hidden */
  55176. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55177. /** @hidden */
  55178. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55179. /** @hidden */
  55180. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55181. /** @hidden */
  55182. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55183. }
  55184. }
  55185. declare module BABYLON {
  55186. /**
  55187. * @hidden
  55188. **/
  55189. export class _TimeToken {
  55190. _startTimeQuery: Nullable<WebGLQuery>;
  55191. _endTimeQuery: Nullable<WebGLQuery>;
  55192. _timeElapsedQuery: Nullable<WebGLQuery>;
  55193. _timeElapsedQueryEnded: boolean;
  55194. }
  55195. }
  55196. declare module BABYLON {
  55197. /** @hidden */
  55198. export class _OcclusionDataStorage {
  55199. /** @hidden */
  55200. occlusionInternalRetryCounter: number;
  55201. /** @hidden */
  55202. isOcclusionQueryInProgress: boolean;
  55203. /** @hidden */
  55204. isOccluded: boolean;
  55205. /** @hidden */
  55206. occlusionRetryCount: number;
  55207. /** @hidden */
  55208. occlusionType: number;
  55209. /** @hidden */
  55210. occlusionQueryAlgorithmType: number;
  55211. }
  55212. interface Engine {
  55213. /**
  55214. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55215. * @return the new query
  55216. */
  55217. createQuery(): WebGLQuery;
  55218. /**
  55219. * Delete and release a webGL query
  55220. * @param query defines the query to delete
  55221. * @return the current engine
  55222. */
  55223. deleteQuery(query: WebGLQuery): Engine;
  55224. /**
  55225. * Check if a given query has resolved and got its value
  55226. * @param query defines the query to check
  55227. * @returns true if the query got its value
  55228. */
  55229. isQueryResultAvailable(query: WebGLQuery): boolean;
  55230. /**
  55231. * Gets the value of a given query
  55232. * @param query defines the query to check
  55233. * @returns the value of the query
  55234. */
  55235. getQueryResult(query: WebGLQuery): number;
  55236. /**
  55237. * Initiates an occlusion query
  55238. * @param algorithmType defines the algorithm to use
  55239. * @param query defines the query to use
  55240. * @returns the current engine
  55241. * @see https://doc.babylonjs.com/features/occlusionquery
  55242. */
  55243. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55244. /**
  55245. * Ends an occlusion query
  55246. * @see https://doc.babylonjs.com/features/occlusionquery
  55247. * @param algorithmType defines the algorithm to use
  55248. * @returns the current engine
  55249. */
  55250. endOcclusionQuery(algorithmType: number): Engine;
  55251. /**
  55252. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55253. * Please note that only one query can be issued at a time
  55254. * @returns a time token used to track the time span
  55255. */
  55256. startTimeQuery(): Nullable<_TimeToken>;
  55257. /**
  55258. * Ends a time query
  55259. * @param token defines the token used to measure the time span
  55260. * @returns the time spent (in ns)
  55261. */
  55262. endTimeQuery(token: _TimeToken): int;
  55263. /** @hidden */
  55264. _currentNonTimestampToken: Nullable<_TimeToken>;
  55265. /** @hidden */
  55266. _createTimeQuery(): WebGLQuery;
  55267. /** @hidden */
  55268. _deleteTimeQuery(query: WebGLQuery): void;
  55269. /** @hidden */
  55270. _getGlAlgorithmType(algorithmType: number): number;
  55271. /** @hidden */
  55272. _getTimeQueryResult(query: WebGLQuery): any;
  55273. /** @hidden */
  55274. _getTimeQueryAvailability(query: WebGLQuery): any;
  55275. }
  55276. interface AbstractMesh {
  55277. /**
  55278. * Backing filed
  55279. * @hidden
  55280. */
  55281. __occlusionDataStorage: _OcclusionDataStorage;
  55282. /**
  55283. * Access property
  55284. * @hidden
  55285. */
  55286. _occlusionDataStorage: _OcclusionDataStorage;
  55287. /**
  55288. * 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.
  55289. * The default value is -1 which means don't break the query and wait till the result
  55290. * @see https://doc.babylonjs.com/features/occlusionquery
  55291. */
  55292. occlusionRetryCount: number;
  55293. /**
  55294. * 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:
  55295. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55296. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55297. * * 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.
  55298. * @see https://doc.babylonjs.com/features/occlusionquery
  55299. */
  55300. occlusionType: number;
  55301. /**
  55302. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55303. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55304. * * 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.
  55305. * @see https://doc.babylonjs.com/features/occlusionquery
  55306. */
  55307. occlusionQueryAlgorithmType: number;
  55308. /**
  55309. * 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
  55310. * @see https://doc.babylonjs.com/features/occlusionquery
  55311. */
  55312. isOccluded: boolean;
  55313. /**
  55314. * Flag to check the progress status of the query
  55315. * @see https://doc.babylonjs.com/features/occlusionquery
  55316. */
  55317. isOcclusionQueryInProgress: boolean;
  55318. }
  55319. }
  55320. declare module BABYLON {
  55321. /** @hidden */
  55322. export var _forceTransformFeedbackToBundle: boolean;
  55323. interface Engine {
  55324. /**
  55325. * Creates a webGL transform feedback object
  55326. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55327. * @returns the webGL transform feedback object
  55328. */
  55329. createTransformFeedback(): WebGLTransformFeedback;
  55330. /**
  55331. * Delete a webGL transform feedback object
  55332. * @param value defines the webGL transform feedback object to delete
  55333. */
  55334. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55335. /**
  55336. * Bind a webGL transform feedback object to the webgl context
  55337. * @param value defines the webGL transform feedback object to bind
  55338. */
  55339. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55340. /**
  55341. * Begins a transform feedback operation
  55342. * @param usePoints defines if points or triangles must be used
  55343. */
  55344. beginTransformFeedback(usePoints: boolean): void;
  55345. /**
  55346. * Ends a transform feedback operation
  55347. */
  55348. endTransformFeedback(): void;
  55349. /**
  55350. * Specify the varyings to use with transform feedback
  55351. * @param program defines the associated webGL program
  55352. * @param value defines the list of strings representing the varying names
  55353. */
  55354. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55355. /**
  55356. * Bind a webGL buffer for a transform feedback operation
  55357. * @param value defines the webGL buffer to bind
  55358. */
  55359. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55360. }
  55361. }
  55362. declare module BABYLON {
  55363. /**
  55364. * Class used to define an additional view for the engine
  55365. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55366. */
  55367. export class EngineView {
  55368. /** Defines the canvas where to render the view */
  55369. target: HTMLCanvasElement;
  55370. /** Defines an optional camera used to render the view (will use active camera else) */
  55371. camera?: Camera;
  55372. }
  55373. interface Engine {
  55374. /**
  55375. * Gets or sets the HTML element to use for attaching events
  55376. */
  55377. inputElement: Nullable<HTMLElement>;
  55378. /**
  55379. * Gets the current engine view
  55380. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55381. */
  55382. activeView: Nullable<EngineView>;
  55383. /** Gets or sets the list of views */
  55384. views: EngineView[];
  55385. /**
  55386. * Register a new child canvas
  55387. * @param canvas defines the canvas to register
  55388. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55389. * @returns the associated view
  55390. */
  55391. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55392. /**
  55393. * Remove a registered child canvas
  55394. * @param canvas defines the canvas to remove
  55395. * @returns the current engine
  55396. */
  55397. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55398. }
  55399. }
  55400. declare module BABYLON {
  55401. interface Engine {
  55402. /** @hidden */
  55403. _excludedCompressedTextures: string[];
  55404. /** @hidden */
  55405. _textureFormatInUse: string;
  55406. /**
  55407. * Gets the list of texture formats supported
  55408. */
  55409. readonly texturesSupported: Array<string>;
  55410. /**
  55411. * Gets the texture format in use
  55412. */
  55413. readonly textureFormatInUse: Nullable<string>;
  55414. /**
  55415. * Set the compressed texture extensions or file names to skip.
  55416. *
  55417. * @param skippedFiles defines the list of those texture files you want to skip
  55418. * Example: [".dds", ".env", "myfile.png"]
  55419. */
  55420. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55421. /**
  55422. * Set the compressed texture format to use, based on the formats you have, and the formats
  55423. * supported by the hardware / browser.
  55424. *
  55425. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55426. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55427. * to API arguments needed to compressed textures. This puts the burden on the container
  55428. * generator to house the arcane code for determining these for current & future formats.
  55429. *
  55430. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55431. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55432. *
  55433. * Note: The result of this call is not taken into account when a texture is base64.
  55434. *
  55435. * @param formatsAvailable defines the list of those format families you have created
  55436. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55437. *
  55438. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55439. * @returns The extension selected.
  55440. */
  55441. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55442. }
  55443. }
  55444. declare module BABYLON {
  55445. /** @hidden */
  55446. export var rgbdEncodePixelShader: {
  55447. name: string;
  55448. shader: string;
  55449. };
  55450. }
  55451. declare module BABYLON {
  55452. /**
  55453. * Raw texture data and descriptor sufficient for WebGL texture upload
  55454. */
  55455. export interface EnvironmentTextureInfo {
  55456. /**
  55457. * Version of the environment map
  55458. */
  55459. version: number;
  55460. /**
  55461. * Width of image
  55462. */
  55463. width: number;
  55464. /**
  55465. * Irradiance information stored in the file.
  55466. */
  55467. irradiance: any;
  55468. /**
  55469. * Specular information stored in the file.
  55470. */
  55471. specular: any;
  55472. }
  55473. /**
  55474. * Defines One Image in the file. It requires only the position in the file
  55475. * as well as the length.
  55476. */
  55477. interface BufferImageData {
  55478. /**
  55479. * Length of the image data.
  55480. */
  55481. length: number;
  55482. /**
  55483. * Position of the data from the null terminator delimiting the end of the JSON.
  55484. */
  55485. position: number;
  55486. }
  55487. /**
  55488. * Defines the specular data enclosed in the file.
  55489. * This corresponds to the version 1 of the data.
  55490. */
  55491. export interface EnvironmentTextureSpecularInfoV1 {
  55492. /**
  55493. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55494. */
  55495. specularDataPosition?: number;
  55496. /**
  55497. * This contains all the images data needed to reconstruct the cubemap.
  55498. */
  55499. mipmaps: Array<BufferImageData>;
  55500. /**
  55501. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55502. */
  55503. lodGenerationScale: number;
  55504. }
  55505. /**
  55506. * Sets of helpers addressing the serialization and deserialization of environment texture
  55507. * stored in a BabylonJS env file.
  55508. * Those files are usually stored as .env files.
  55509. */
  55510. export class EnvironmentTextureTools {
  55511. /**
  55512. * Magic number identifying the env file.
  55513. */
  55514. private static _MagicBytes;
  55515. /**
  55516. * Gets the environment info from an env file.
  55517. * @param data The array buffer containing the .env bytes.
  55518. * @returns the environment file info (the json header) if successfully parsed.
  55519. */
  55520. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55521. /**
  55522. * Creates an environment texture from a loaded cube texture.
  55523. * @param texture defines the cube texture to convert in env file
  55524. * @return a promise containing the environment data if succesfull.
  55525. */
  55526. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55527. /**
  55528. * Creates a JSON representation of the spherical data.
  55529. * @param texture defines the texture containing the polynomials
  55530. * @return the JSON representation of the spherical info
  55531. */
  55532. private static _CreateEnvTextureIrradiance;
  55533. /**
  55534. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55535. * @param data the image data
  55536. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55537. * @return the views described by info providing access to the underlying buffer
  55538. */
  55539. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55540. /**
  55541. * Uploads the texture info contained in the env file to the GPU.
  55542. * @param texture defines the internal texture to upload to
  55543. * @param data defines the data to load
  55544. * @param info defines the texture info retrieved through the GetEnvInfo method
  55545. * @returns a promise
  55546. */
  55547. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55548. private static _OnImageReadyAsync;
  55549. /**
  55550. * Uploads the levels of image data to the GPU.
  55551. * @param texture defines the internal texture to upload to
  55552. * @param imageData defines the array buffer views of image data [mipmap][face]
  55553. * @returns a promise
  55554. */
  55555. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  55556. /**
  55557. * Uploads spherical polynomials information to the texture.
  55558. * @param texture defines the texture we are trying to upload the information to
  55559. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  55560. */
  55561. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55562. /** @hidden */
  55563. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55564. }
  55565. }
  55566. declare module BABYLON {
  55567. /**
  55568. * Class used to inline functions in shader code
  55569. */
  55570. export class ShaderCodeInliner {
  55571. private static readonly _RegexpFindFunctionNameAndType;
  55572. private _sourceCode;
  55573. private _functionDescr;
  55574. private _numMaxIterations;
  55575. /** Gets or sets the token used to mark the functions to inline */
  55576. inlineToken: string;
  55577. /** Gets or sets the debug mode */
  55578. debug: boolean;
  55579. /** Gets the code after the inlining process */
  55580. get code(): string;
  55581. /**
  55582. * Initializes the inliner
  55583. * @param sourceCode shader code source to inline
  55584. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55585. */
  55586. constructor(sourceCode: string, numMaxIterations?: number);
  55587. /**
  55588. * Start the processing of the shader code
  55589. */
  55590. processCode(): void;
  55591. private _collectFunctions;
  55592. private _processInlining;
  55593. private _extractBetweenMarkers;
  55594. private _skipWhitespaces;
  55595. private _removeComments;
  55596. private _replaceFunctionCallsByCode;
  55597. private _findBackward;
  55598. private _escapeRegExp;
  55599. private _replaceNames;
  55600. }
  55601. }
  55602. declare module BABYLON {
  55603. /**
  55604. * Container for accessors for natively-stored mesh data buffers.
  55605. */
  55606. class NativeDataBuffer extends DataBuffer {
  55607. /**
  55608. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55609. */
  55610. nativeIndexBuffer?: any;
  55611. /**
  55612. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55613. */
  55614. nativeVertexBuffer?: any;
  55615. }
  55616. /** @hidden */
  55617. class NativeTexture extends InternalTexture {
  55618. getInternalTexture(): InternalTexture;
  55619. getViewCount(): number;
  55620. }
  55621. /** @hidden */
  55622. export class NativeEngine extends Engine {
  55623. private readonly _native;
  55624. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55625. private readonly INVALID_HANDLE;
  55626. private _boundBuffersVertexArray;
  55627. private _currentDepthTest;
  55628. getHardwareScalingLevel(): number;
  55629. constructor();
  55630. dispose(): void;
  55631. /**
  55632. * Can be used to override the current requestAnimationFrame requester.
  55633. * @hidden
  55634. */
  55635. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55636. /**
  55637. * Override default engine behavior.
  55638. * @param color
  55639. * @param backBuffer
  55640. * @param depth
  55641. * @param stencil
  55642. */
  55643. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55644. /**
  55645. * Gets host document
  55646. * @returns the host document object
  55647. */
  55648. getHostDocument(): Nullable<Document>;
  55649. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55650. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55651. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55652. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55653. [key: string]: VertexBuffer;
  55654. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55655. bindBuffers(vertexBuffers: {
  55656. [key: string]: VertexBuffer;
  55657. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55658. recordVertexArrayObject(vertexBuffers: {
  55659. [key: string]: VertexBuffer;
  55660. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55661. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55662. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55663. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55664. /**
  55665. * Draw a list of indexed primitives
  55666. * @param fillMode defines the primitive to use
  55667. * @param indexStart defines the starting index
  55668. * @param indexCount defines the number of index to draw
  55669. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55670. */
  55671. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55672. /**
  55673. * Draw a list of unindexed primitives
  55674. * @param fillMode defines the primitive to use
  55675. * @param verticesStart defines the index of first vertex to draw
  55676. * @param verticesCount defines the count of vertices to draw
  55677. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55678. */
  55679. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55680. createPipelineContext(): IPipelineContext;
  55681. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55682. /** @hidden */
  55683. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55684. /** @hidden */
  55685. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55686. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55687. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55688. protected _setProgram(program: WebGLProgram): void;
  55689. _releaseEffect(effect: Effect): void;
  55690. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55691. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55692. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55693. bindSamplers(effect: Effect): void;
  55694. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55695. getRenderWidth(useScreen?: boolean): number;
  55696. getRenderHeight(useScreen?: boolean): number;
  55697. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55698. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55699. /**
  55700. * Set the z offset to apply to current rendering
  55701. * @param value defines the offset to apply
  55702. */
  55703. setZOffset(value: number): void;
  55704. /**
  55705. * Gets the current value of the zOffset
  55706. * @returns the current zOffset state
  55707. */
  55708. getZOffset(): number;
  55709. /**
  55710. * Enable or disable depth buffering
  55711. * @param enable defines the state to set
  55712. */
  55713. setDepthBuffer(enable: boolean): void;
  55714. /**
  55715. * Gets a boolean indicating if depth writing is enabled
  55716. * @returns the current depth writing state
  55717. */
  55718. getDepthWrite(): boolean;
  55719. setDepthFunctionToGreater(): void;
  55720. setDepthFunctionToGreaterOrEqual(): void;
  55721. setDepthFunctionToLess(): void;
  55722. setDepthFunctionToLessOrEqual(): void;
  55723. /**
  55724. * Enable or disable depth writing
  55725. * @param enable defines the state to set
  55726. */
  55727. setDepthWrite(enable: boolean): void;
  55728. /**
  55729. * Enable or disable color writing
  55730. * @param enable defines the state to set
  55731. */
  55732. setColorWrite(enable: boolean): void;
  55733. /**
  55734. * Gets a boolean indicating if color writing is enabled
  55735. * @returns the current color writing state
  55736. */
  55737. getColorWrite(): boolean;
  55738. /**
  55739. * Sets alpha constants used by some alpha blending modes
  55740. * @param r defines the red component
  55741. * @param g defines the green component
  55742. * @param b defines the blue component
  55743. * @param a defines the alpha component
  55744. */
  55745. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55746. /**
  55747. * Sets the current alpha mode
  55748. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55749. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55750. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55751. */
  55752. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55753. /**
  55754. * Gets the current alpha mode
  55755. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55756. * @returns the current alpha mode
  55757. */
  55758. getAlphaMode(): number;
  55759. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55760. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55761. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55762. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55763. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55764. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55765. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55766. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55767. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55768. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55769. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55770. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55771. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55772. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55773. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55774. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55775. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55776. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55777. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55778. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55779. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55780. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55781. wipeCaches(bruteForce?: boolean): void;
  55782. _createTexture(): WebGLTexture;
  55783. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55784. /**
  55785. * Update the content of a dynamic texture
  55786. * @param texture defines the texture to update
  55787. * @param canvas defines the canvas containing the source
  55788. * @param invertY defines if data must be stored with Y axis inverted
  55789. * @param premulAlpha defines if alpha is stored as premultiplied
  55790. * @param format defines the format of the data
  55791. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55792. */
  55793. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55794. /**
  55795. * Usually called from Texture.ts.
  55796. * Passed information to create a WebGLTexture
  55797. * @param url defines a value which contains one of the following:
  55798. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55799. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55800. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55801. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55802. * @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)
  55803. * @param scene needed for loading to the correct scene
  55804. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55805. * @param onLoad optional callback to be called upon successful completion
  55806. * @param onError optional callback to be called upon failure
  55807. * @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
  55808. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55809. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55810. * @param forcedExtension defines the extension to use to pick the right loader
  55811. * @param mimeType defines an optional mime type
  55812. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55813. */
  55814. 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;
  55815. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  55816. _releaseFramebufferObjects(texture: InternalTexture): void;
  55817. /**
  55818. * Creates a cube texture
  55819. * @param rootUrl defines the url where the files to load is located
  55820. * @param scene defines the current scene
  55821. * @param files defines the list of files to load (1 per face)
  55822. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55823. * @param onLoad defines an optional callback raised when the texture is loaded
  55824. * @param onError defines an optional callback raised if there is an issue to load the texture
  55825. * @param format defines the format of the data
  55826. * @param forcedExtension defines the extension to use to pick the right loader
  55827. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55828. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55829. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55830. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55831. * @returns the cube texture as an InternalTexture
  55832. */
  55833. 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;
  55834. createRenderTargetTexture(size: number | {
  55835. width: number;
  55836. height: number;
  55837. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55838. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55839. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55840. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55841. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55842. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55843. /**
  55844. * Updates a dynamic vertex buffer.
  55845. * @param vertexBuffer the vertex buffer to update
  55846. * @param data the data used to update the vertex buffer
  55847. * @param byteOffset the byte offset of the data (optional)
  55848. * @param byteLength the byte length of the data (optional)
  55849. */
  55850. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55851. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55852. private _updateAnisotropicLevel;
  55853. private _getAddressMode;
  55854. /** @hidden */
  55855. _bindTexture(channel: number, texture: InternalTexture): void;
  55856. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55857. releaseEffects(): void;
  55858. /** @hidden */
  55859. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55860. /** @hidden */
  55861. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55862. /** @hidden */
  55863. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55864. /** @hidden */
  55865. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55866. private _getNativeSamplingMode;
  55867. private _getNativeTextureFormat;
  55868. private _getNativeAlphaMode;
  55869. private _getNativeAttribType;
  55870. }
  55871. }
  55872. declare module BABYLON {
  55873. /**
  55874. * Gather the list of clipboard event types as constants.
  55875. */
  55876. export class ClipboardEventTypes {
  55877. /**
  55878. * The clipboard event is fired when a copy command is active (pressed).
  55879. */
  55880. static readonly COPY: number;
  55881. /**
  55882. * The clipboard event is fired when a cut command is active (pressed).
  55883. */
  55884. static readonly CUT: number;
  55885. /**
  55886. * The clipboard event is fired when a paste command is active (pressed).
  55887. */
  55888. static readonly PASTE: number;
  55889. }
  55890. /**
  55891. * This class is used to store clipboard related info for the onClipboardObservable event.
  55892. */
  55893. export class ClipboardInfo {
  55894. /**
  55895. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55896. */
  55897. type: number;
  55898. /**
  55899. * Defines the related dom event
  55900. */
  55901. event: ClipboardEvent;
  55902. /**
  55903. *Creates an instance of ClipboardInfo.
  55904. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55905. * @param event Defines the related dom event
  55906. */
  55907. constructor(
  55908. /**
  55909. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55910. */
  55911. type: number,
  55912. /**
  55913. * Defines the related dom event
  55914. */
  55915. event: ClipboardEvent);
  55916. /**
  55917. * Get the clipboard event's type from the keycode.
  55918. * @param keyCode Defines the keyCode for the current keyboard event.
  55919. * @return {number}
  55920. */
  55921. static GetTypeFromCharacter(keyCode: number): number;
  55922. }
  55923. }
  55924. declare module BABYLON {
  55925. /**
  55926. * Google Daydream controller
  55927. */
  55928. export class DaydreamController extends WebVRController {
  55929. /**
  55930. * Base Url for the controller model.
  55931. */
  55932. static MODEL_BASE_URL: string;
  55933. /**
  55934. * File name for the controller model.
  55935. */
  55936. static MODEL_FILENAME: string;
  55937. /**
  55938. * Gamepad Id prefix used to identify Daydream Controller.
  55939. */
  55940. static readonly GAMEPAD_ID_PREFIX: string;
  55941. /**
  55942. * Creates a new DaydreamController from a gamepad
  55943. * @param vrGamepad the gamepad that the controller should be created from
  55944. */
  55945. constructor(vrGamepad: any);
  55946. /**
  55947. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55948. * @param scene scene in which to add meshes
  55949. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55950. */
  55951. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55952. /**
  55953. * Called once for each button that changed state since the last frame
  55954. * @param buttonIdx Which button index changed
  55955. * @param state New state of the button
  55956. * @param changes Which properties on the state changed since last frame
  55957. */
  55958. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55959. }
  55960. }
  55961. declare module BABYLON {
  55962. /**
  55963. * Gear VR Controller
  55964. */
  55965. export class GearVRController extends WebVRController {
  55966. /**
  55967. * Base Url for the controller model.
  55968. */
  55969. static MODEL_BASE_URL: string;
  55970. /**
  55971. * File name for the controller model.
  55972. */
  55973. static MODEL_FILENAME: string;
  55974. /**
  55975. * Gamepad Id prefix used to identify this controller.
  55976. */
  55977. static readonly GAMEPAD_ID_PREFIX: string;
  55978. private readonly _buttonIndexToObservableNameMap;
  55979. /**
  55980. * Creates a new GearVRController from a gamepad
  55981. * @param vrGamepad the gamepad that the controller should be created from
  55982. */
  55983. constructor(vrGamepad: any);
  55984. /**
  55985. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55986. * @param scene scene in which to add meshes
  55987. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55988. */
  55989. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55990. /**
  55991. * Called once for each button that changed state since the last frame
  55992. * @param buttonIdx Which button index changed
  55993. * @param state New state of the button
  55994. * @param changes Which properties on the state changed since last frame
  55995. */
  55996. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55997. }
  55998. }
  55999. declare module BABYLON {
  56000. /**
  56001. * Generic Controller
  56002. */
  56003. export class GenericController extends WebVRController {
  56004. /**
  56005. * Base Url for the controller model.
  56006. */
  56007. static readonly MODEL_BASE_URL: string;
  56008. /**
  56009. * File name for the controller model.
  56010. */
  56011. static readonly MODEL_FILENAME: string;
  56012. /**
  56013. * Creates a new GenericController from a gamepad
  56014. * @param vrGamepad the gamepad that the controller should be created from
  56015. */
  56016. constructor(vrGamepad: any);
  56017. /**
  56018. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56019. * @param scene scene in which to add meshes
  56020. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56021. */
  56022. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56023. /**
  56024. * Called once for each button that changed state since the last frame
  56025. * @param buttonIdx Which button index changed
  56026. * @param state New state of the button
  56027. * @param changes Which properties on the state changed since last frame
  56028. */
  56029. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56030. }
  56031. }
  56032. declare module BABYLON {
  56033. /**
  56034. * Oculus Touch Controller
  56035. */
  56036. export class OculusTouchController extends WebVRController {
  56037. /**
  56038. * Base Url for the controller model.
  56039. */
  56040. static MODEL_BASE_URL: string;
  56041. /**
  56042. * File name for the left controller model.
  56043. */
  56044. static MODEL_LEFT_FILENAME: string;
  56045. /**
  56046. * File name for the right controller model.
  56047. */
  56048. static MODEL_RIGHT_FILENAME: string;
  56049. /**
  56050. * Base Url for the Quest controller model.
  56051. */
  56052. static QUEST_MODEL_BASE_URL: string;
  56053. /**
  56054. * @hidden
  56055. * If the controllers are running on a device that needs the updated Quest controller models
  56056. */
  56057. static _IsQuest: boolean;
  56058. /**
  56059. * Fired when the secondary trigger on this controller is modified
  56060. */
  56061. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56062. /**
  56063. * Fired when the thumb rest on this controller is modified
  56064. */
  56065. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56066. /**
  56067. * Creates a new OculusTouchController from a gamepad
  56068. * @param vrGamepad the gamepad that the controller should be created from
  56069. */
  56070. constructor(vrGamepad: any);
  56071. /**
  56072. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56073. * @param scene scene in which to add meshes
  56074. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56075. */
  56076. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56077. /**
  56078. * Fired when the A button on this controller is modified
  56079. */
  56080. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56081. /**
  56082. * Fired when the B button on this controller is modified
  56083. */
  56084. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56085. /**
  56086. * Fired when the X button on this controller is modified
  56087. */
  56088. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56089. /**
  56090. * Fired when the Y button on this controller is modified
  56091. */
  56092. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56093. /**
  56094. * Called once for each button that changed state since the last frame
  56095. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56096. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56097. * 2) secondary trigger (same)
  56098. * 3) A (right) X (left), touch, pressed = value
  56099. * 4) B / Y
  56100. * 5) thumb rest
  56101. * @param buttonIdx Which button index changed
  56102. * @param state New state of the button
  56103. * @param changes Which properties on the state changed since last frame
  56104. */
  56105. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56106. }
  56107. }
  56108. declare module BABYLON {
  56109. /**
  56110. * Vive Controller
  56111. */
  56112. export class ViveController extends WebVRController {
  56113. /**
  56114. * Base Url for the controller model.
  56115. */
  56116. static MODEL_BASE_URL: string;
  56117. /**
  56118. * File name for the controller model.
  56119. */
  56120. static MODEL_FILENAME: string;
  56121. /**
  56122. * Creates a new ViveController from a gamepad
  56123. * @param vrGamepad the gamepad that the controller should be created from
  56124. */
  56125. constructor(vrGamepad: any);
  56126. /**
  56127. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56128. * @param scene scene in which to add meshes
  56129. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56130. */
  56131. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56132. /**
  56133. * Fired when the left button on this controller is modified
  56134. */
  56135. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56136. /**
  56137. * Fired when the right button on this controller is modified
  56138. */
  56139. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56140. /**
  56141. * Fired when the menu button on this controller is modified
  56142. */
  56143. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56144. /**
  56145. * Called once for each button that changed state since the last frame
  56146. * Vive mapping:
  56147. * 0: touchpad
  56148. * 1: trigger
  56149. * 2: left AND right buttons
  56150. * 3: menu button
  56151. * @param buttonIdx Which button index changed
  56152. * @param state New state of the button
  56153. * @param changes Which properties on the state changed since last frame
  56154. */
  56155. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56156. }
  56157. }
  56158. declare module BABYLON {
  56159. /**
  56160. * Defines the WindowsMotionController object that the state of the windows motion controller
  56161. */
  56162. export class WindowsMotionController extends WebVRController {
  56163. /**
  56164. * The base url used to load the left and right controller models
  56165. */
  56166. static MODEL_BASE_URL: string;
  56167. /**
  56168. * The name of the left controller model file
  56169. */
  56170. static MODEL_LEFT_FILENAME: string;
  56171. /**
  56172. * The name of the right controller model file
  56173. */
  56174. static MODEL_RIGHT_FILENAME: string;
  56175. /**
  56176. * The controller name prefix for this controller type
  56177. */
  56178. static readonly GAMEPAD_ID_PREFIX: string;
  56179. /**
  56180. * The controller id pattern for this controller type
  56181. */
  56182. private static readonly GAMEPAD_ID_PATTERN;
  56183. private _loadedMeshInfo;
  56184. protected readonly _mapping: {
  56185. buttons: string[];
  56186. buttonMeshNames: {
  56187. trigger: string;
  56188. menu: string;
  56189. grip: string;
  56190. thumbstick: string;
  56191. trackpad: string;
  56192. };
  56193. buttonObservableNames: {
  56194. trigger: string;
  56195. menu: string;
  56196. grip: string;
  56197. thumbstick: string;
  56198. trackpad: string;
  56199. };
  56200. axisMeshNames: string[];
  56201. pointingPoseMeshName: string;
  56202. };
  56203. /**
  56204. * Fired when the trackpad on this controller is clicked
  56205. */
  56206. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56207. /**
  56208. * Fired when the trackpad on this controller is modified
  56209. */
  56210. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56211. /**
  56212. * The current x and y values of this controller's trackpad
  56213. */
  56214. trackpad: StickValues;
  56215. /**
  56216. * Creates a new WindowsMotionController from a gamepad
  56217. * @param vrGamepad the gamepad that the controller should be created from
  56218. */
  56219. constructor(vrGamepad: any);
  56220. /**
  56221. * Fired when the trigger on this controller is modified
  56222. */
  56223. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56224. /**
  56225. * Fired when the menu button on this controller is modified
  56226. */
  56227. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56228. /**
  56229. * Fired when the grip button on this controller is modified
  56230. */
  56231. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56232. /**
  56233. * Fired when the thumbstick button on this controller is modified
  56234. */
  56235. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56236. /**
  56237. * Fired when the touchpad button on this controller is modified
  56238. */
  56239. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56240. /**
  56241. * Fired when the touchpad values on this controller are modified
  56242. */
  56243. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56244. protected _updateTrackpad(): void;
  56245. /**
  56246. * Called once per frame by the engine.
  56247. */
  56248. update(): void;
  56249. /**
  56250. * Called once for each button that changed state since the last frame
  56251. * @param buttonIdx Which button index changed
  56252. * @param state New state of the button
  56253. * @param changes Which properties on the state changed since last frame
  56254. */
  56255. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56256. /**
  56257. * Moves the buttons on the controller mesh based on their current state
  56258. * @param buttonName the name of the button to move
  56259. * @param buttonValue the value of the button which determines the buttons new position
  56260. */
  56261. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56262. /**
  56263. * Moves the axis on the controller mesh based on its current state
  56264. * @param axis the index of the axis
  56265. * @param axisValue the value of the axis which determines the meshes new position
  56266. * @hidden
  56267. */
  56268. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56269. /**
  56270. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56271. * @param scene scene in which to add meshes
  56272. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56273. */
  56274. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56275. /**
  56276. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56277. * can be transformed by button presses and axes values, based on this._mapping.
  56278. *
  56279. * @param scene scene in which the meshes exist
  56280. * @param meshes list of meshes that make up the controller model to process
  56281. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56282. */
  56283. private processModel;
  56284. private createMeshInfo;
  56285. /**
  56286. * Gets the ray of the controller in the direction the controller is pointing
  56287. * @param length the length the resulting ray should be
  56288. * @returns a ray in the direction the controller is pointing
  56289. */
  56290. getForwardRay(length?: number): Ray;
  56291. /**
  56292. * Disposes of the controller
  56293. */
  56294. dispose(): void;
  56295. }
  56296. /**
  56297. * This class represents a new windows motion controller in XR.
  56298. */
  56299. export class XRWindowsMotionController extends WindowsMotionController {
  56300. /**
  56301. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56302. */
  56303. protected readonly _mapping: {
  56304. buttons: string[];
  56305. buttonMeshNames: {
  56306. trigger: string;
  56307. menu: string;
  56308. grip: string;
  56309. thumbstick: string;
  56310. trackpad: string;
  56311. };
  56312. buttonObservableNames: {
  56313. trigger: string;
  56314. menu: string;
  56315. grip: string;
  56316. thumbstick: string;
  56317. trackpad: string;
  56318. };
  56319. axisMeshNames: string[];
  56320. pointingPoseMeshName: string;
  56321. };
  56322. /**
  56323. * Construct a new XR-Based windows motion controller
  56324. *
  56325. * @param gamepadInfo the gamepad object from the browser
  56326. */
  56327. constructor(gamepadInfo: any);
  56328. /**
  56329. * holds the thumbstick values (X,Y)
  56330. */
  56331. thumbstickValues: StickValues;
  56332. /**
  56333. * Fired when the thumbstick on this controller is clicked
  56334. */
  56335. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56336. /**
  56337. * Fired when the thumbstick on this controller is modified
  56338. */
  56339. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56340. /**
  56341. * Fired when the touchpad button on this controller is modified
  56342. */
  56343. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56344. /**
  56345. * Fired when the touchpad values on this controller are modified
  56346. */
  56347. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56348. /**
  56349. * Fired when the thumbstick button on this controller is modified
  56350. * here to prevent breaking changes
  56351. */
  56352. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56353. /**
  56354. * updating the thumbstick(!) and not the trackpad.
  56355. * This is named this way due to the difference between WebVR and XR and to avoid
  56356. * changing the parent class.
  56357. */
  56358. protected _updateTrackpad(): void;
  56359. /**
  56360. * Disposes the class with joy
  56361. */
  56362. dispose(): void;
  56363. }
  56364. }
  56365. declare module BABYLON {
  56366. /**
  56367. * Class containing static functions to help procedurally build meshes
  56368. */
  56369. export class PolyhedronBuilder {
  56370. /**
  56371. * Creates a polyhedron mesh
  56372. * * 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
  56373. * * The parameter `size` (positive float, default 1) sets the polygon size
  56374. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56375. * * 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`
  56376. * * 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
  56377. * * 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)`)
  56378. * * 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
  56379. * * 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
  56380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56381. * * 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
  56382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56383. * @param name defines the name of the mesh
  56384. * @param options defines the options used to create the mesh
  56385. * @param scene defines the hosting scene
  56386. * @returns the polyhedron mesh
  56387. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56388. */
  56389. static CreatePolyhedron(name: string, options: {
  56390. type?: number;
  56391. size?: number;
  56392. sizeX?: number;
  56393. sizeY?: number;
  56394. sizeZ?: number;
  56395. custom?: any;
  56396. faceUV?: Vector4[];
  56397. faceColors?: Color4[];
  56398. flat?: boolean;
  56399. updatable?: boolean;
  56400. sideOrientation?: number;
  56401. frontUVs?: Vector4;
  56402. backUVs?: Vector4;
  56403. }, scene?: Nullable<Scene>): Mesh;
  56404. }
  56405. }
  56406. declare module BABYLON {
  56407. /**
  56408. * Gizmo that enables scaling a mesh along 3 axis
  56409. */
  56410. export class ScaleGizmo extends Gizmo {
  56411. /**
  56412. * Internal gizmo used for interactions on the x axis
  56413. */
  56414. xGizmo: AxisScaleGizmo;
  56415. /**
  56416. * Internal gizmo used for interactions on the y axis
  56417. */
  56418. yGizmo: AxisScaleGizmo;
  56419. /**
  56420. * Internal gizmo used for interactions on the z axis
  56421. */
  56422. zGizmo: AxisScaleGizmo;
  56423. /**
  56424. * Internal gizmo used to scale all axis equally
  56425. */
  56426. uniformScaleGizmo: AxisScaleGizmo;
  56427. private _meshAttached;
  56428. private _nodeAttached;
  56429. private _snapDistance;
  56430. private _uniformScalingMesh;
  56431. private _octahedron;
  56432. private _sensitivity;
  56433. /** Fires an event when any of it's sub gizmos are dragged */
  56434. onDragStartObservable: Observable<unknown>;
  56435. /** Fires an event when any of it's sub gizmos are released from dragging */
  56436. onDragEndObservable: Observable<unknown>;
  56437. get attachedMesh(): Nullable<AbstractMesh>;
  56438. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56439. get attachedNode(): Nullable<Node>;
  56440. set attachedNode(node: Nullable<Node>);
  56441. /**
  56442. * True when the mouse pointer is hovering a gizmo mesh
  56443. */
  56444. get isHovered(): boolean;
  56445. /**
  56446. * Creates a ScaleGizmo
  56447. * @param gizmoLayer The utility layer the gizmo will be added to
  56448. * @param thickness display gizmo axis thickness
  56449. */
  56450. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56451. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56452. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56453. /**
  56454. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56455. */
  56456. set snapDistance(value: number);
  56457. get snapDistance(): number;
  56458. /**
  56459. * Ratio for the scale of the gizmo (Default: 1)
  56460. */
  56461. set scaleRatio(value: number);
  56462. get scaleRatio(): number;
  56463. /**
  56464. * Sensitivity factor for dragging (Default: 1)
  56465. */
  56466. set sensitivity(value: number);
  56467. get sensitivity(): number;
  56468. /**
  56469. * Disposes of the gizmo
  56470. */
  56471. dispose(): void;
  56472. }
  56473. }
  56474. declare module BABYLON {
  56475. /**
  56476. * Single axis scale gizmo
  56477. */
  56478. export class AxisScaleGizmo extends Gizmo {
  56479. /**
  56480. * Drag behavior responsible for the gizmos dragging interactions
  56481. */
  56482. dragBehavior: PointerDragBehavior;
  56483. private _pointerObserver;
  56484. /**
  56485. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56486. */
  56487. snapDistance: number;
  56488. /**
  56489. * Event that fires each time the gizmo snaps to a new location.
  56490. * * snapDistance is the the change in distance
  56491. */
  56492. onSnapObservable: Observable<{
  56493. snapDistance: number;
  56494. }>;
  56495. /**
  56496. * If the scaling operation should be done on all axis (default: false)
  56497. */
  56498. uniformScaling: boolean;
  56499. /**
  56500. * Custom sensitivity value for the drag strength
  56501. */
  56502. sensitivity: number;
  56503. private _isEnabled;
  56504. private _parent;
  56505. private _arrow;
  56506. private _coloredMaterial;
  56507. private _hoverMaterial;
  56508. /**
  56509. * Creates an AxisScaleGizmo
  56510. * @param gizmoLayer The utility layer the gizmo will be added to
  56511. * @param dragAxis The axis which the gizmo will be able to scale on
  56512. * @param color The color of the gizmo
  56513. * @param thickness display gizmo axis thickness
  56514. */
  56515. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56516. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56517. /**
  56518. * If the gizmo is enabled
  56519. */
  56520. set isEnabled(value: boolean);
  56521. get isEnabled(): boolean;
  56522. /**
  56523. * Disposes of the gizmo
  56524. */
  56525. dispose(): void;
  56526. /**
  56527. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56528. * @param mesh The mesh to replace the default mesh of the gizmo
  56529. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56530. */
  56531. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56532. }
  56533. }
  56534. declare module BABYLON {
  56535. /**
  56536. * Bounding box gizmo
  56537. */
  56538. export class BoundingBoxGizmo extends Gizmo {
  56539. private _lineBoundingBox;
  56540. private _rotateSpheresParent;
  56541. private _scaleBoxesParent;
  56542. private _boundingDimensions;
  56543. private _renderObserver;
  56544. private _pointerObserver;
  56545. private _scaleDragSpeed;
  56546. private _tmpQuaternion;
  56547. private _tmpVector;
  56548. private _tmpRotationMatrix;
  56549. /**
  56550. * 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)
  56551. */
  56552. ignoreChildren: boolean;
  56553. /**
  56554. * 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)
  56555. */
  56556. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56557. /**
  56558. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56559. */
  56560. rotationSphereSize: number;
  56561. /**
  56562. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56563. */
  56564. scaleBoxSize: number;
  56565. /**
  56566. * 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)
  56567. */
  56568. fixedDragMeshScreenSize: boolean;
  56569. /**
  56570. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56571. */
  56572. fixedDragMeshScreenSizeDistanceFactor: number;
  56573. /**
  56574. * Fired when a rotation sphere or scale box is dragged
  56575. */
  56576. onDragStartObservable: Observable<{}>;
  56577. /**
  56578. * Fired when a scale box is dragged
  56579. */
  56580. onScaleBoxDragObservable: Observable<{}>;
  56581. /**
  56582. * Fired when a scale box drag is ended
  56583. */
  56584. onScaleBoxDragEndObservable: Observable<{}>;
  56585. /**
  56586. * Fired when a rotation sphere is dragged
  56587. */
  56588. onRotationSphereDragObservable: Observable<{}>;
  56589. /**
  56590. * Fired when a rotation sphere drag is ended
  56591. */
  56592. onRotationSphereDragEndObservable: Observable<{}>;
  56593. /**
  56594. * 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)
  56595. */
  56596. scalePivot: Nullable<Vector3>;
  56597. /**
  56598. * Mesh used as a pivot to rotate the attached node
  56599. */
  56600. private _anchorMesh;
  56601. private _existingMeshScale;
  56602. private _dragMesh;
  56603. private pointerDragBehavior;
  56604. private coloredMaterial;
  56605. private hoverColoredMaterial;
  56606. /**
  56607. * Sets the color of the bounding box gizmo
  56608. * @param color the color to set
  56609. */
  56610. setColor(color: Color3): void;
  56611. /**
  56612. * Creates an BoundingBoxGizmo
  56613. * @param gizmoLayer The utility layer the gizmo will be added to
  56614. * @param color The color of the gizmo
  56615. */
  56616. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56617. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56618. private _selectNode;
  56619. /**
  56620. * Updates the bounding box information for the Gizmo
  56621. */
  56622. updateBoundingBox(): void;
  56623. private _updateRotationSpheres;
  56624. private _updateScaleBoxes;
  56625. /**
  56626. * Enables rotation on the specified axis and disables rotation on the others
  56627. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56628. */
  56629. setEnabledRotationAxis(axis: string): void;
  56630. /**
  56631. * Enables/disables scaling
  56632. * @param enable if scaling should be enabled
  56633. * @param homogeneousScaling defines if scaling should only be homogeneous
  56634. */
  56635. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56636. private _updateDummy;
  56637. /**
  56638. * Enables a pointer drag behavior on the bounding box of the gizmo
  56639. */
  56640. enableDragBehavior(): void;
  56641. /**
  56642. * Disposes of the gizmo
  56643. */
  56644. dispose(): void;
  56645. /**
  56646. * 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)
  56647. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56648. * @returns the bounding box mesh with the passed in mesh as a child
  56649. */
  56650. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56651. /**
  56652. * CustomMeshes are not supported by this gizmo
  56653. * @param mesh The mesh to replace the default mesh of the gizmo
  56654. */
  56655. setCustomMesh(mesh: Mesh): void;
  56656. }
  56657. }
  56658. declare module BABYLON {
  56659. /**
  56660. * Single plane rotation gizmo
  56661. */
  56662. export class PlaneRotationGizmo extends Gizmo {
  56663. /**
  56664. * Drag behavior responsible for the gizmos dragging interactions
  56665. */
  56666. dragBehavior: PointerDragBehavior;
  56667. private _pointerObserver;
  56668. /**
  56669. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56670. */
  56671. snapDistance: number;
  56672. /**
  56673. * Event that fires each time the gizmo snaps to a new location.
  56674. * * snapDistance is the the change in distance
  56675. */
  56676. onSnapObservable: Observable<{
  56677. snapDistance: number;
  56678. }>;
  56679. private _isEnabled;
  56680. private _parent;
  56681. /**
  56682. * Creates a PlaneRotationGizmo
  56683. * @param gizmoLayer The utility layer the gizmo will be added to
  56684. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56685. * @param color The color of the gizmo
  56686. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56687. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56688. * @param thickness display gizmo axis thickness
  56689. */
  56690. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56691. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56692. /**
  56693. * If the gizmo is enabled
  56694. */
  56695. set isEnabled(value: boolean);
  56696. get isEnabled(): boolean;
  56697. /**
  56698. * Disposes of the gizmo
  56699. */
  56700. dispose(): void;
  56701. }
  56702. }
  56703. declare module BABYLON {
  56704. /**
  56705. * Gizmo that enables rotating a mesh along 3 axis
  56706. */
  56707. export class RotationGizmo extends Gizmo {
  56708. /**
  56709. * Internal gizmo used for interactions on the x axis
  56710. */
  56711. xGizmo: PlaneRotationGizmo;
  56712. /**
  56713. * Internal gizmo used for interactions on the y axis
  56714. */
  56715. yGizmo: PlaneRotationGizmo;
  56716. /**
  56717. * Internal gizmo used for interactions on the z axis
  56718. */
  56719. zGizmo: PlaneRotationGizmo;
  56720. /** Fires an event when any of it's sub gizmos are dragged */
  56721. onDragStartObservable: Observable<unknown>;
  56722. /** Fires an event when any of it's sub gizmos are released from dragging */
  56723. onDragEndObservable: Observable<unknown>;
  56724. private _meshAttached;
  56725. private _nodeAttached;
  56726. get attachedMesh(): Nullable<AbstractMesh>;
  56727. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56728. get attachedNode(): Nullable<Node>;
  56729. set attachedNode(node: Nullable<Node>);
  56730. /**
  56731. * True when the mouse pointer is hovering a gizmo mesh
  56732. */
  56733. get isHovered(): boolean;
  56734. /**
  56735. * Creates a RotationGizmo
  56736. * @param gizmoLayer The utility layer the gizmo will be added to
  56737. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56738. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56739. * @param thickness display gizmo axis thickness
  56740. */
  56741. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56742. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56743. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56744. /**
  56745. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56746. */
  56747. set snapDistance(value: number);
  56748. get snapDistance(): number;
  56749. /**
  56750. * Ratio for the scale of the gizmo (Default: 1)
  56751. */
  56752. set scaleRatio(value: number);
  56753. get scaleRatio(): number;
  56754. /**
  56755. * Disposes of the gizmo
  56756. */
  56757. dispose(): void;
  56758. /**
  56759. * CustomMeshes are not supported by this gizmo
  56760. * @param mesh The mesh to replace the default mesh of the gizmo
  56761. */
  56762. setCustomMesh(mesh: Mesh): void;
  56763. }
  56764. }
  56765. declare module BABYLON {
  56766. /**
  56767. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56768. */
  56769. export class GizmoManager implements IDisposable {
  56770. private scene;
  56771. /**
  56772. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56773. */
  56774. gizmos: {
  56775. positionGizmo: Nullable<PositionGizmo>;
  56776. rotationGizmo: Nullable<RotationGizmo>;
  56777. scaleGizmo: Nullable<ScaleGizmo>;
  56778. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56779. };
  56780. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56781. clearGizmoOnEmptyPointerEvent: boolean;
  56782. /** Fires an event when the manager is attached to a mesh */
  56783. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56784. /** Fires an event when the manager is attached to a node */
  56785. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56786. private _gizmosEnabled;
  56787. private _pointerObserver;
  56788. private _attachedMesh;
  56789. private _attachedNode;
  56790. private _boundingBoxColor;
  56791. private _defaultUtilityLayer;
  56792. private _defaultKeepDepthUtilityLayer;
  56793. private _thickness;
  56794. /**
  56795. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56796. */
  56797. boundingBoxDragBehavior: SixDofDragBehavior;
  56798. /**
  56799. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56800. */
  56801. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56802. /**
  56803. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56804. */
  56805. attachableNodes: Nullable<Array<Node>>;
  56806. /**
  56807. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56808. */
  56809. usePointerToAttachGizmos: boolean;
  56810. /**
  56811. * Utility layer that the bounding box gizmo belongs to
  56812. */
  56813. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56814. /**
  56815. * Utility layer that all gizmos besides bounding box belong to
  56816. */
  56817. get utilityLayer(): UtilityLayerRenderer;
  56818. /**
  56819. * True when the mouse pointer is hovering a gizmo mesh
  56820. */
  56821. get isHovered(): boolean;
  56822. /**
  56823. * Instatiates a gizmo manager
  56824. * @param scene the scene to overlay the gizmos on top of
  56825. * @param thickness display gizmo axis thickness
  56826. */
  56827. constructor(scene: Scene, thickness?: number);
  56828. /**
  56829. * Attaches a set of gizmos to the specified mesh
  56830. * @param mesh The mesh the gizmo's should be attached to
  56831. */
  56832. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56833. /**
  56834. * Attaches a set of gizmos to the specified node
  56835. * @param node The node the gizmo's should be attached to
  56836. */
  56837. attachToNode(node: Nullable<Node>): void;
  56838. /**
  56839. * If the position gizmo is enabled
  56840. */
  56841. set positionGizmoEnabled(value: boolean);
  56842. get positionGizmoEnabled(): boolean;
  56843. /**
  56844. * If the rotation gizmo is enabled
  56845. */
  56846. set rotationGizmoEnabled(value: boolean);
  56847. get rotationGizmoEnabled(): boolean;
  56848. /**
  56849. * If the scale gizmo is enabled
  56850. */
  56851. set scaleGizmoEnabled(value: boolean);
  56852. get scaleGizmoEnabled(): boolean;
  56853. /**
  56854. * If the boundingBox gizmo is enabled
  56855. */
  56856. set boundingBoxGizmoEnabled(value: boolean);
  56857. get boundingBoxGizmoEnabled(): boolean;
  56858. /**
  56859. * Disposes of the gizmo manager
  56860. */
  56861. dispose(): void;
  56862. }
  56863. }
  56864. declare module BABYLON {
  56865. /**
  56866. * A directional light is defined by a direction (what a surprise!).
  56867. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56868. * 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.
  56869. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56870. */
  56871. export class DirectionalLight extends ShadowLight {
  56872. private _shadowFrustumSize;
  56873. /**
  56874. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56875. */
  56876. get shadowFrustumSize(): number;
  56877. /**
  56878. * Specifies a fix frustum size for the shadow generation.
  56879. */
  56880. set shadowFrustumSize(value: number);
  56881. private _shadowOrthoScale;
  56882. /**
  56883. * Gets the shadow projection scale against the optimal computed one.
  56884. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56885. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56886. */
  56887. get shadowOrthoScale(): number;
  56888. /**
  56889. * Sets the shadow projection scale against the optimal computed one.
  56890. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56891. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56892. */
  56893. set shadowOrthoScale(value: number);
  56894. /**
  56895. * Automatically compute the projection matrix to best fit (including all the casters)
  56896. * on each frame.
  56897. */
  56898. autoUpdateExtends: boolean;
  56899. /**
  56900. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56901. * on each frame. autoUpdateExtends must be set to true for this to work
  56902. */
  56903. autoCalcShadowZBounds: boolean;
  56904. private _orthoLeft;
  56905. private _orthoRight;
  56906. private _orthoTop;
  56907. private _orthoBottom;
  56908. /**
  56909. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56910. * The directional light is emitted from everywhere in the given direction.
  56911. * It can cast shadows.
  56912. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56913. * @param name The friendly name of the light
  56914. * @param direction The direction of the light
  56915. * @param scene The scene the light belongs to
  56916. */
  56917. constructor(name: string, direction: Vector3, scene: Scene);
  56918. /**
  56919. * Returns the string "DirectionalLight".
  56920. * @return The class name
  56921. */
  56922. getClassName(): string;
  56923. /**
  56924. * Returns the integer 1.
  56925. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56926. */
  56927. getTypeID(): number;
  56928. /**
  56929. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56930. * Returns the DirectionalLight Shadow projection matrix.
  56931. */
  56932. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56933. /**
  56934. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56935. * Returns the DirectionalLight Shadow projection matrix.
  56936. */
  56937. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56938. /**
  56939. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56940. * Returns the DirectionalLight Shadow projection matrix.
  56941. */
  56942. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56943. protected _buildUniformLayout(): void;
  56944. /**
  56945. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56946. * @param effect The effect to update
  56947. * @param lightIndex The index of the light in the effect to update
  56948. * @returns The directional light
  56949. */
  56950. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56951. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56952. /**
  56953. * Gets the minZ used for shadow according to both the scene and the light.
  56954. *
  56955. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56956. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56957. * @param activeCamera The camera we are returning the min for
  56958. * @returns the depth min z
  56959. */
  56960. getDepthMinZ(activeCamera: Camera): number;
  56961. /**
  56962. * Gets the maxZ used for shadow according to both the scene and the light.
  56963. *
  56964. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56965. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56966. * @param activeCamera The camera we are returning the max for
  56967. * @returns the depth max z
  56968. */
  56969. getDepthMaxZ(activeCamera: Camera): number;
  56970. /**
  56971. * Prepares the list of defines specific to the light type.
  56972. * @param defines the list of defines
  56973. * @param lightIndex defines the index of the light for the effect
  56974. */
  56975. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56976. }
  56977. }
  56978. declare module BABYLON {
  56979. /**
  56980. * Class containing static functions to help procedurally build meshes
  56981. */
  56982. export class HemisphereBuilder {
  56983. /**
  56984. * Creates a hemisphere mesh
  56985. * @param name defines the name of the mesh
  56986. * @param options defines the options used to create the mesh
  56987. * @param scene defines the hosting scene
  56988. * @returns the hemisphere mesh
  56989. */
  56990. static CreateHemisphere(name: string, options: {
  56991. segments?: number;
  56992. diameter?: number;
  56993. sideOrientation?: number;
  56994. }, scene: any): Mesh;
  56995. }
  56996. }
  56997. declare module BABYLON {
  56998. /**
  56999. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57000. * These values define a cone of light starting from the position, emitting toward the direction.
  57001. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57002. * and the exponent defines the speed of the decay of the light with distance (reach).
  57003. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57004. */
  57005. export class SpotLight extends ShadowLight {
  57006. private _angle;
  57007. private _innerAngle;
  57008. private _cosHalfAngle;
  57009. private _lightAngleScale;
  57010. private _lightAngleOffset;
  57011. /**
  57012. * Gets the cone angle of the spot light in Radians.
  57013. */
  57014. get angle(): number;
  57015. /**
  57016. * Sets the cone angle of the spot light in Radians.
  57017. */
  57018. set angle(value: number);
  57019. /**
  57020. * Only used in gltf falloff mode, this defines the angle where
  57021. * the directional falloff will start before cutting at angle which could be seen
  57022. * as outer angle.
  57023. */
  57024. get innerAngle(): number;
  57025. /**
  57026. * Only used in gltf falloff mode, this defines the angle where
  57027. * the directional falloff will start before cutting at angle which could be seen
  57028. * as outer angle.
  57029. */
  57030. set innerAngle(value: number);
  57031. private _shadowAngleScale;
  57032. /**
  57033. * Allows scaling the angle of the light for shadow generation only.
  57034. */
  57035. get shadowAngleScale(): number;
  57036. /**
  57037. * Allows scaling the angle of the light for shadow generation only.
  57038. */
  57039. set shadowAngleScale(value: number);
  57040. /**
  57041. * The light decay speed with the distance from the emission spot.
  57042. */
  57043. exponent: number;
  57044. private _projectionTextureMatrix;
  57045. /**
  57046. * Allows reading the projecton texture
  57047. */
  57048. get projectionTextureMatrix(): Matrix;
  57049. protected _projectionTextureLightNear: number;
  57050. /**
  57051. * Gets the near clip of the Spotlight for texture projection.
  57052. */
  57053. get projectionTextureLightNear(): number;
  57054. /**
  57055. * Sets the near clip of the Spotlight for texture projection.
  57056. */
  57057. set projectionTextureLightNear(value: number);
  57058. protected _projectionTextureLightFar: number;
  57059. /**
  57060. * Gets the far clip of the Spotlight for texture projection.
  57061. */
  57062. get projectionTextureLightFar(): number;
  57063. /**
  57064. * Sets the far clip of the Spotlight for texture projection.
  57065. */
  57066. set projectionTextureLightFar(value: number);
  57067. protected _projectionTextureUpDirection: Vector3;
  57068. /**
  57069. * Gets the Up vector of the Spotlight for texture projection.
  57070. */
  57071. get projectionTextureUpDirection(): Vector3;
  57072. /**
  57073. * Sets the Up vector of the Spotlight for texture projection.
  57074. */
  57075. set projectionTextureUpDirection(value: Vector3);
  57076. private _projectionTexture;
  57077. /**
  57078. * Gets the projection texture of the light.
  57079. */
  57080. get projectionTexture(): Nullable<BaseTexture>;
  57081. /**
  57082. * Sets the projection texture of the light.
  57083. */
  57084. set projectionTexture(value: Nullable<BaseTexture>);
  57085. private _projectionTextureViewLightDirty;
  57086. private _projectionTextureProjectionLightDirty;
  57087. private _projectionTextureDirty;
  57088. private _projectionTextureViewTargetVector;
  57089. private _projectionTextureViewLightMatrix;
  57090. private _projectionTextureProjectionLightMatrix;
  57091. private _projectionTextureScalingMatrix;
  57092. /**
  57093. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57094. * It can cast shadows.
  57095. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57096. * @param name The light friendly name
  57097. * @param position The position of the spot light in the scene
  57098. * @param direction The direction of the light in the scene
  57099. * @param angle The cone angle of the light in Radians
  57100. * @param exponent The light decay speed with the distance from the emission spot
  57101. * @param scene The scene the lights belongs to
  57102. */
  57103. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57104. /**
  57105. * Returns the string "SpotLight".
  57106. * @returns the class name
  57107. */
  57108. getClassName(): string;
  57109. /**
  57110. * Returns the integer 2.
  57111. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57112. */
  57113. getTypeID(): number;
  57114. /**
  57115. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57116. */
  57117. protected _setDirection(value: Vector3): void;
  57118. /**
  57119. * Overrides the position setter to recompute the projection texture view light Matrix.
  57120. */
  57121. protected _setPosition(value: Vector3): void;
  57122. /**
  57123. * 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.
  57124. * Returns the SpotLight.
  57125. */
  57126. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57127. protected _computeProjectionTextureViewLightMatrix(): void;
  57128. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57129. /**
  57130. * Main function for light texture projection matrix computing.
  57131. */
  57132. protected _computeProjectionTextureMatrix(): void;
  57133. protected _buildUniformLayout(): void;
  57134. private _computeAngleValues;
  57135. /**
  57136. * Sets the passed Effect "effect" with the Light textures.
  57137. * @param effect The effect to update
  57138. * @param lightIndex The index of the light in the effect to update
  57139. * @returns The light
  57140. */
  57141. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57142. /**
  57143. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57144. * @param effect The effect to update
  57145. * @param lightIndex The index of the light in the effect to update
  57146. * @returns The spot light
  57147. */
  57148. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57149. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57150. /**
  57151. * Disposes the light and the associated resources.
  57152. */
  57153. dispose(): void;
  57154. /**
  57155. * Prepares the list of defines specific to the light type.
  57156. * @param defines the list of defines
  57157. * @param lightIndex defines the index of the light for the effect
  57158. */
  57159. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57160. }
  57161. }
  57162. declare module BABYLON {
  57163. /**
  57164. * Gizmo that enables viewing a light
  57165. */
  57166. export class LightGizmo extends Gizmo {
  57167. private _lightMesh;
  57168. private _material;
  57169. private _cachedPosition;
  57170. private _cachedForward;
  57171. private _attachedMeshParent;
  57172. private _pointerObserver;
  57173. /**
  57174. * Event that fires each time the gizmo is clicked
  57175. */
  57176. onClickedObservable: Observable<Light>;
  57177. /**
  57178. * Creates a LightGizmo
  57179. * @param gizmoLayer The utility layer the gizmo will be added to
  57180. */
  57181. constructor(gizmoLayer?: UtilityLayerRenderer);
  57182. private _light;
  57183. /**
  57184. * The light that the gizmo is attached to
  57185. */
  57186. set light(light: Nullable<Light>);
  57187. get light(): Nullable<Light>;
  57188. /**
  57189. * Gets the material used to render the light gizmo
  57190. */
  57191. get material(): StandardMaterial;
  57192. /**
  57193. * @hidden
  57194. * Updates the gizmo to match the attached mesh's position/rotation
  57195. */
  57196. protected _update(): void;
  57197. private static _Scale;
  57198. /**
  57199. * Creates the lines for a light mesh
  57200. */
  57201. private static _CreateLightLines;
  57202. /**
  57203. * Disposes of the light gizmo
  57204. */
  57205. dispose(): void;
  57206. private static _CreateHemisphericLightMesh;
  57207. private static _CreatePointLightMesh;
  57208. private static _CreateSpotLightMesh;
  57209. private static _CreateDirectionalLightMesh;
  57210. }
  57211. }
  57212. declare module BABYLON {
  57213. /**
  57214. * Gizmo that enables viewing a camera
  57215. */
  57216. export class CameraGizmo extends Gizmo {
  57217. private _cameraMesh;
  57218. private _cameraLinesMesh;
  57219. private _material;
  57220. private _pointerObserver;
  57221. /**
  57222. * Event that fires each time the gizmo is clicked
  57223. */
  57224. onClickedObservable: Observable<Camera>;
  57225. /**
  57226. * Creates a CameraGizmo
  57227. * @param gizmoLayer The utility layer the gizmo will be added to
  57228. */
  57229. constructor(gizmoLayer?: UtilityLayerRenderer);
  57230. private _camera;
  57231. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57232. get displayFrustum(): boolean;
  57233. set displayFrustum(value: boolean);
  57234. /**
  57235. * The camera that the gizmo is attached to
  57236. */
  57237. set camera(camera: Nullable<Camera>);
  57238. get camera(): Nullable<Camera>;
  57239. /**
  57240. * Gets the material used to render the camera gizmo
  57241. */
  57242. get material(): StandardMaterial;
  57243. /**
  57244. * @hidden
  57245. * Updates the gizmo to match the attached mesh's position/rotation
  57246. */
  57247. protected _update(): void;
  57248. private static _Scale;
  57249. private _invProjection;
  57250. /**
  57251. * Disposes of the camera gizmo
  57252. */
  57253. dispose(): void;
  57254. private static _CreateCameraMesh;
  57255. private static _CreateCameraFrustum;
  57256. }
  57257. }
  57258. declare module BABYLON {
  57259. /** @hidden */
  57260. export var backgroundFragmentDeclaration: {
  57261. name: string;
  57262. shader: string;
  57263. };
  57264. }
  57265. declare module BABYLON {
  57266. /** @hidden */
  57267. export var backgroundUboDeclaration: {
  57268. name: string;
  57269. shader: string;
  57270. };
  57271. }
  57272. declare module BABYLON {
  57273. /** @hidden */
  57274. export var backgroundPixelShader: {
  57275. name: string;
  57276. shader: string;
  57277. };
  57278. }
  57279. declare module BABYLON {
  57280. /** @hidden */
  57281. export var backgroundVertexDeclaration: {
  57282. name: string;
  57283. shader: string;
  57284. };
  57285. }
  57286. declare module BABYLON {
  57287. /** @hidden */
  57288. export var backgroundVertexShader: {
  57289. name: string;
  57290. shader: string;
  57291. };
  57292. }
  57293. declare module BABYLON {
  57294. /**
  57295. * Background material used to create an efficient environement around your scene.
  57296. */
  57297. export class BackgroundMaterial extends PushMaterial {
  57298. /**
  57299. * Standard reflectance value at parallel view angle.
  57300. */
  57301. static StandardReflectance0: number;
  57302. /**
  57303. * Standard reflectance value at grazing angle.
  57304. */
  57305. static StandardReflectance90: number;
  57306. protected _primaryColor: Color3;
  57307. /**
  57308. * Key light Color (multiply against the environement texture)
  57309. */
  57310. primaryColor: Color3;
  57311. protected __perceptualColor: Nullable<Color3>;
  57312. /**
  57313. * Experimental Internal Use Only.
  57314. *
  57315. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57316. * This acts as a helper to set the primary color to a more "human friendly" value.
  57317. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57318. * output color as close as possible from the chosen value.
  57319. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57320. * part of lighting setup.)
  57321. */
  57322. get _perceptualColor(): Nullable<Color3>;
  57323. set _perceptualColor(value: Nullable<Color3>);
  57324. protected _primaryColorShadowLevel: float;
  57325. /**
  57326. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57327. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57328. */
  57329. get primaryColorShadowLevel(): float;
  57330. set primaryColorShadowLevel(value: float);
  57331. protected _primaryColorHighlightLevel: float;
  57332. /**
  57333. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57334. * The primary color is used at the level chosen to define what the white area would look.
  57335. */
  57336. get primaryColorHighlightLevel(): float;
  57337. set primaryColorHighlightLevel(value: float);
  57338. protected _reflectionTexture: Nullable<BaseTexture>;
  57339. /**
  57340. * Reflection Texture used in the material.
  57341. * Should be author in a specific way for the best result (refer to the documentation).
  57342. */
  57343. reflectionTexture: Nullable<BaseTexture>;
  57344. protected _reflectionBlur: float;
  57345. /**
  57346. * Reflection Texture level of blur.
  57347. *
  57348. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57349. * texture twice.
  57350. */
  57351. reflectionBlur: float;
  57352. protected _diffuseTexture: Nullable<BaseTexture>;
  57353. /**
  57354. * Diffuse Texture used in the material.
  57355. * Should be author in a specific way for the best result (refer to the documentation).
  57356. */
  57357. diffuseTexture: Nullable<BaseTexture>;
  57358. protected _shadowLights: Nullable<IShadowLight[]>;
  57359. /**
  57360. * Specify the list of lights casting shadow on the material.
  57361. * All scene shadow lights will be included if null.
  57362. */
  57363. shadowLights: Nullable<IShadowLight[]>;
  57364. protected _shadowLevel: float;
  57365. /**
  57366. * Helps adjusting the shadow to a softer level if required.
  57367. * 0 means black shadows and 1 means no shadows.
  57368. */
  57369. shadowLevel: float;
  57370. protected _sceneCenter: Vector3;
  57371. /**
  57372. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57373. * It is usually zero but might be interesting to modify according to your setup.
  57374. */
  57375. sceneCenter: Vector3;
  57376. protected _opacityFresnel: boolean;
  57377. /**
  57378. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57379. * This helps ensuring a nice transition when the camera goes under the ground.
  57380. */
  57381. opacityFresnel: boolean;
  57382. protected _reflectionFresnel: boolean;
  57383. /**
  57384. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57385. * This helps adding a mirror texture on the ground.
  57386. */
  57387. reflectionFresnel: boolean;
  57388. protected _reflectionFalloffDistance: number;
  57389. /**
  57390. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57391. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57392. */
  57393. reflectionFalloffDistance: number;
  57394. protected _reflectionAmount: number;
  57395. /**
  57396. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57397. */
  57398. reflectionAmount: number;
  57399. protected _reflectionReflectance0: number;
  57400. /**
  57401. * This specifies the weight of the reflection at grazing angle.
  57402. */
  57403. reflectionReflectance0: number;
  57404. protected _reflectionReflectance90: number;
  57405. /**
  57406. * This specifies the weight of the reflection at a perpendicular point of view.
  57407. */
  57408. reflectionReflectance90: number;
  57409. /**
  57410. * Sets the reflection reflectance fresnel values according to the default standard
  57411. * empirically know to work well :-)
  57412. */
  57413. set reflectionStandardFresnelWeight(value: number);
  57414. protected _useRGBColor: boolean;
  57415. /**
  57416. * Helps to directly use the maps channels instead of their level.
  57417. */
  57418. useRGBColor: boolean;
  57419. protected _enableNoise: boolean;
  57420. /**
  57421. * This helps reducing the banding effect that could occur on the background.
  57422. */
  57423. enableNoise: boolean;
  57424. /**
  57425. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57426. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57427. * Recommended to be keep at 1.0 except for special cases.
  57428. */
  57429. get fovMultiplier(): number;
  57430. set fovMultiplier(value: number);
  57431. private _fovMultiplier;
  57432. /**
  57433. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57434. */
  57435. useEquirectangularFOV: boolean;
  57436. private _maxSimultaneousLights;
  57437. /**
  57438. * Number of Simultaneous lights allowed on the material.
  57439. */
  57440. maxSimultaneousLights: int;
  57441. private _shadowOnly;
  57442. /**
  57443. * Make the material only render shadows
  57444. */
  57445. shadowOnly: boolean;
  57446. /**
  57447. * Default configuration related to image processing available in the Background Material.
  57448. */
  57449. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57450. /**
  57451. * Keep track of the image processing observer to allow dispose and replace.
  57452. */
  57453. private _imageProcessingObserver;
  57454. /**
  57455. * Attaches a new image processing configuration to the PBR Material.
  57456. * @param configuration (if null the scene configuration will be use)
  57457. */
  57458. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57459. /**
  57460. * Gets the image processing configuration used either in this material.
  57461. */
  57462. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57463. /**
  57464. * Sets the Default image processing configuration used either in the this material.
  57465. *
  57466. * If sets to null, the scene one is in use.
  57467. */
  57468. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57469. /**
  57470. * Gets wether the color curves effect is enabled.
  57471. */
  57472. get cameraColorCurvesEnabled(): boolean;
  57473. /**
  57474. * Sets wether the color curves effect is enabled.
  57475. */
  57476. set cameraColorCurvesEnabled(value: boolean);
  57477. /**
  57478. * Gets wether the color grading effect is enabled.
  57479. */
  57480. get cameraColorGradingEnabled(): boolean;
  57481. /**
  57482. * Gets wether the color grading effect is enabled.
  57483. */
  57484. set cameraColorGradingEnabled(value: boolean);
  57485. /**
  57486. * Gets wether tonemapping is enabled or not.
  57487. */
  57488. get cameraToneMappingEnabled(): boolean;
  57489. /**
  57490. * Sets wether tonemapping is enabled or not
  57491. */
  57492. set cameraToneMappingEnabled(value: boolean);
  57493. /**
  57494. * The camera exposure used on this material.
  57495. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57496. * This corresponds to a photographic exposure.
  57497. */
  57498. get cameraExposure(): float;
  57499. /**
  57500. * The camera exposure used on this material.
  57501. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57502. * This corresponds to a photographic exposure.
  57503. */
  57504. set cameraExposure(value: float);
  57505. /**
  57506. * Gets The camera contrast used on this material.
  57507. */
  57508. get cameraContrast(): float;
  57509. /**
  57510. * Sets The camera contrast used on this material.
  57511. */
  57512. set cameraContrast(value: float);
  57513. /**
  57514. * Gets the Color Grading 2D Lookup Texture.
  57515. */
  57516. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57517. /**
  57518. * Sets the Color Grading 2D Lookup Texture.
  57519. */
  57520. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57521. /**
  57522. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57523. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57524. * 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;
  57525. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57526. */
  57527. get cameraColorCurves(): Nullable<ColorCurves>;
  57528. /**
  57529. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57530. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57531. * 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;
  57532. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57533. */
  57534. set cameraColorCurves(value: Nullable<ColorCurves>);
  57535. /**
  57536. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57537. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57538. */
  57539. switchToBGR: boolean;
  57540. private _renderTargets;
  57541. private _reflectionControls;
  57542. private _white;
  57543. private _primaryShadowColor;
  57544. private _primaryHighlightColor;
  57545. /**
  57546. * Instantiates a Background Material in the given scene
  57547. * @param name The friendly name of the material
  57548. * @param scene The scene to add the material to
  57549. */
  57550. constructor(name: string, scene: Scene);
  57551. /**
  57552. * Gets a boolean indicating that current material needs to register RTT
  57553. */
  57554. get hasRenderTargetTextures(): boolean;
  57555. /**
  57556. * The entire material has been created in order to prevent overdraw.
  57557. * @returns false
  57558. */
  57559. needAlphaTesting(): boolean;
  57560. /**
  57561. * The entire material has been created in order to prevent overdraw.
  57562. * @returns true if blending is enable
  57563. */
  57564. needAlphaBlending(): boolean;
  57565. /**
  57566. * Checks wether the material is ready to be rendered for a given mesh.
  57567. * @param mesh The mesh to render
  57568. * @param subMesh The submesh to check against
  57569. * @param useInstances Specify wether or not the material is used with instances
  57570. * @returns true if all the dependencies are ready (Textures, Effects...)
  57571. */
  57572. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57573. /**
  57574. * Compute the primary color according to the chosen perceptual color.
  57575. */
  57576. private _computePrimaryColorFromPerceptualColor;
  57577. /**
  57578. * Compute the highlights and shadow colors according to their chosen levels.
  57579. */
  57580. private _computePrimaryColors;
  57581. /**
  57582. * Build the uniform buffer used in the material.
  57583. */
  57584. buildUniformLayout(): void;
  57585. /**
  57586. * Unbind the material.
  57587. */
  57588. unbind(): void;
  57589. /**
  57590. * Bind only the world matrix to the material.
  57591. * @param world The world matrix to bind.
  57592. */
  57593. bindOnlyWorldMatrix(world: Matrix): void;
  57594. /**
  57595. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57596. * @param world The world matrix to bind.
  57597. * @param subMesh The submesh to bind for.
  57598. */
  57599. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57600. /**
  57601. * Checks to see if a texture is used in the material.
  57602. * @param texture - Base texture to use.
  57603. * @returns - Boolean specifying if a texture is used in the material.
  57604. */
  57605. hasTexture(texture: BaseTexture): boolean;
  57606. /**
  57607. * Dispose the material.
  57608. * @param forceDisposeEffect Force disposal of the associated effect.
  57609. * @param forceDisposeTextures Force disposal of the associated textures.
  57610. */
  57611. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57612. /**
  57613. * Clones the material.
  57614. * @param name The cloned name.
  57615. * @returns The cloned material.
  57616. */
  57617. clone(name: string): BackgroundMaterial;
  57618. /**
  57619. * Serializes the current material to its JSON representation.
  57620. * @returns The JSON representation.
  57621. */
  57622. serialize(): any;
  57623. /**
  57624. * Gets the class name of the material
  57625. * @returns "BackgroundMaterial"
  57626. */
  57627. getClassName(): string;
  57628. /**
  57629. * Parse a JSON input to create back a background material.
  57630. * @param source The JSON data to parse
  57631. * @param scene The scene to create the parsed material in
  57632. * @param rootUrl The root url of the assets the material depends upon
  57633. * @returns the instantiated BackgroundMaterial.
  57634. */
  57635. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57636. }
  57637. }
  57638. declare module BABYLON {
  57639. /**
  57640. * Represents the different options available during the creation of
  57641. * a Environment helper.
  57642. *
  57643. * This can control the default ground, skybox and image processing setup of your scene.
  57644. */
  57645. export interface IEnvironmentHelperOptions {
  57646. /**
  57647. * Specifies whether or not to create a ground.
  57648. * True by default.
  57649. */
  57650. createGround: boolean;
  57651. /**
  57652. * Specifies the ground size.
  57653. * 15 by default.
  57654. */
  57655. groundSize: number;
  57656. /**
  57657. * The texture used on the ground for the main color.
  57658. * Comes from the BabylonJS CDN by default.
  57659. *
  57660. * Remarks: Can be either a texture or a url.
  57661. */
  57662. groundTexture: string | BaseTexture;
  57663. /**
  57664. * The color mixed in the ground texture by default.
  57665. * BabylonJS clearColor by default.
  57666. */
  57667. groundColor: Color3;
  57668. /**
  57669. * Specifies the ground opacity.
  57670. * 1 by default.
  57671. */
  57672. groundOpacity: number;
  57673. /**
  57674. * Enables the ground to receive shadows.
  57675. * True by default.
  57676. */
  57677. enableGroundShadow: boolean;
  57678. /**
  57679. * Helps preventing the shadow to be fully black on the ground.
  57680. * 0.5 by default.
  57681. */
  57682. groundShadowLevel: number;
  57683. /**
  57684. * Creates a mirror texture attach to the ground.
  57685. * false by default.
  57686. */
  57687. enableGroundMirror: boolean;
  57688. /**
  57689. * Specifies the ground mirror size ratio.
  57690. * 0.3 by default as the default kernel is 64.
  57691. */
  57692. groundMirrorSizeRatio: number;
  57693. /**
  57694. * Specifies the ground mirror blur kernel size.
  57695. * 64 by default.
  57696. */
  57697. groundMirrorBlurKernel: number;
  57698. /**
  57699. * Specifies the ground mirror visibility amount.
  57700. * 1 by default
  57701. */
  57702. groundMirrorAmount: number;
  57703. /**
  57704. * Specifies the ground mirror reflectance weight.
  57705. * This uses the standard weight of the background material to setup the fresnel effect
  57706. * of the mirror.
  57707. * 1 by default.
  57708. */
  57709. groundMirrorFresnelWeight: number;
  57710. /**
  57711. * Specifies the ground mirror Falloff distance.
  57712. * This can helps reducing the size of the reflection.
  57713. * 0 by Default.
  57714. */
  57715. groundMirrorFallOffDistance: number;
  57716. /**
  57717. * Specifies the ground mirror texture type.
  57718. * Unsigned Int by Default.
  57719. */
  57720. groundMirrorTextureType: number;
  57721. /**
  57722. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57723. * the shown objects.
  57724. */
  57725. groundYBias: number;
  57726. /**
  57727. * Specifies whether or not to create a skybox.
  57728. * True by default.
  57729. */
  57730. createSkybox: boolean;
  57731. /**
  57732. * Specifies the skybox size.
  57733. * 20 by default.
  57734. */
  57735. skyboxSize: number;
  57736. /**
  57737. * The texture used on the skybox for the main color.
  57738. * Comes from the BabylonJS CDN by default.
  57739. *
  57740. * Remarks: Can be either a texture or a url.
  57741. */
  57742. skyboxTexture: string | BaseTexture;
  57743. /**
  57744. * The color mixed in the skybox texture by default.
  57745. * BabylonJS clearColor by default.
  57746. */
  57747. skyboxColor: Color3;
  57748. /**
  57749. * The background rotation around the Y axis of the scene.
  57750. * This helps aligning the key lights of your scene with the background.
  57751. * 0 by default.
  57752. */
  57753. backgroundYRotation: number;
  57754. /**
  57755. * Compute automatically the size of the elements to best fit with the scene.
  57756. */
  57757. sizeAuto: boolean;
  57758. /**
  57759. * Default position of the rootMesh if autoSize is not true.
  57760. */
  57761. rootPosition: Vector3;
  57762. /**
  57763. * Sets up the image processing in the scene.
  57764. * true by default.
  57765. */
  57766. setupImageProcessing: boolean;
  57767. /**
  57768. * The texture used as your environment texture in the scene.
  57769. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57770. *
  57771. * Remarks: Can be either a texture or a url.
  57772. */
  57773. environmentTexture: string | BaseTexture;
  57774. /**
  57775. * The value of the exposure to apply to the scene.
  57776. * 0.6 by default if setupImageProcessing is true.
  57777. */
  57778. cameraExposure: number;
  57779. /**
  57780. * The value of the contrast to apply to the scene.
  57781. * 1.6 by default if setupImageProcessing is true.
  57782. */
  57783. cameraContrast: number;
  57784. /**
  57785. * Specifies whether or not tonemapping should be enabled in the scene.
  57786. * true by default if setupImageProcessing is true.
  57787. */
  57788. toneMappingEnabled: boolean;
  57789. }
  57790. /**
  57791. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57792. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57793. * It also helps with the default setup of your imageProcessing configuration.
  57794. */
  57795. export class EnvironmentHelper {
  57796. /**
  57797. * Default ground texture URL.
  57798. */
  57799. private static _groundTextureCDNUrl;
  57800. /**
  57801. * Default skybox texture URL.
  57802. */
  57803. private static _skyboxTextureCDNUrl;
  57804. /**
  57805. * Default environment texture URL.
  57806. */
  57807. private static _environmentTextureCDNUrl;
  57808. /**
  57809. * Creates the default options for the helper.
  57810. */
  57811. private static _getDefaultOptions;
  57812. private _rootMesh;
  57813. /**
  57814. * Gets the root mesh created by the helper.
  57815. */
  57816. get rootMesh(): Mesh;
  57817. private _skybox;
  57818. /**
  57819. * Gets the skybox created by the helper.
  57820. */
  57821. get skybox(): Nullable<Mesh>;
  57822. private _skyboxTexture;
  57823. /**
  57824. * Gets the skybox texture created by the helper.
  57825. */
  57826. get skyboxTexture(): Nullable<BaseTexture>;
  57827. private _skyboxMaterial;
  57828. /**
  57829. * Gets the skybox material created by the helper.
  57830. */
  57831. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57832. private _ground;
  57833. /**
  57834. * Gets the ground mesh created by the helper.
  57835. */
  57836. get ground(): Nullable<Mesh>;
  57837. private _groundTexture;
  57838. /**
  57839. * Gets the ground texture created by the helper.
  57840. */
  57841. get groundTexture(): Nullable<BaseTexture>;
  57842. private _groundMirror;
  57843. /**
  57844. * Gets the ground mirror created by the helper.
  57845. */
  57846. get groundMirror(): Nullable<MirrorTexture>;
  57847. /**
  57848. * Gets the ground mirror render list to helps pushing the meshes
  57849. * you wish in the ground reflection.
  57850. */
  57851. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57852. private _groundMaterial;
  57853. /**
  57854. * Gets the ground material created by the helper.
  57855. */
  57856. get groundMaterial(): Nullable<BackgroundMaterial>;
  57857. /**
  57858. * Stores the creation options.
  57859. */
  57860. private readonly _scene;
  57861. private _options;
  57862. /**
  57863. * This observable will be notified with any error during the creation of the environment,
  57864. * mainly texture creation errors.
  57865. */
  57866. onErrorObservable: Observable<{
  57867. message?: string;
  57868. exception?: any;
  57869. }>;
  57870. /**
  57871. * constructor
  57872. * @param options Defines the options we want to customize the helper
  57873. * @param scene The scene to add the material to
  57874. */
  57875. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57876. /**
  57877. * Updates the background according to the new options
  57878. * @param options
  57879. */
  57880. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57881. /**
  57882. * Sets the primary color of all the available elements.
  57883. * @param color the main color to affect to the ground and the background
  57884. */
  57885. setMainColor(color: Color3): void;
  57886. /**
  57887. * Setup the image processing according to the specified options.
  57888. */
  57889. private _setupImageProcessing;
  57890. /**
  57891. * Setup the environment texture according to the specified options.
  57892. */
  57893. private _setupEnvironmentTexture;
  57894. /**
  57895. * Setup the background according to the specified options.
  57896. */
  57897. private _setupBackground;
  57898. /**
  57899. * Get the scene sizes according to the setup.
  57900. */
  57901. private _getSceneSize;
  57902. /**
  57903. * Setup the ground according to the specified options.
  57904. */
  57905. private _setupGround;
  57906. /**
  57907. * Setup the ground material according to the specified options.
  57908. */
  57909. private _setupGroundMaterial;
  57910. /**
  57911. * Setup the ground diffuse texture according to the specified options.
  57912. */
  57913. private _setupGroundDiffuseTexture;
  57914. /**
  57915. * Setup the ground mirror texture according to the specified options.
  57916. */
  57917. private _setupGroundMirrorTexture;
  57918. /**
  57919. * Setup the ground to receive the mirror texture.
  57920. */
  57921. private _setupMirrorInGroundMaterial;
  57922. /**
  57923. * Setup the skybox according to the specified options.
  57924. */
  57925. private _setupSkybox;
  57926. /**
  57927. * Setup the skybox material according to the specified options.
  57928. */
  57929. private _setupSkyboxMaterial;
  57930. /**
  57931. * Setup the skybox reflection texture according to the specified options.
  57932. */
  57933. private _setupSkyboxReflectionTexture;
  57934. private _errorHandler;
  57935. /**
  57936. * Dispose all the elements created by the Helper.
  57937. */
  57938. dispose(): void;
  57939. }
  57940. }
  57941. declare module BABYLON {
  57942. /**
  57943. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57944. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57945. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57946. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57947. */
  57948. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57949. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57950. /**
  57951. * Define the source as a Monoscopic panoramic 360/180.
  57952. */
  57953. static readonly MODE_MONOSCOPIC: number;
  57954. /**
  57955. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57956. */
  57957. static readonly MODE_TOPBOTTOM: number;
  57958. /**
  57959. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57960. */
  57961. static readonly MODE_SIDEBYSIDE: number;
  57962. private _halfDome;
  57963. protected _useDirectMapping: boolean;
  57964. /**
  57965. * The texture being displayed on the sphere
  57966. */
  57967. protected _texture: T;
  57968. /**
  57969. * Gets the texture being displayed on the sphere
  57970. */
  57971. get texture(): T;
  57972. /**
  57973. * Sets the texture being displayed on the sphere
  57974. */
  57975. set texture(newTexture: T);
  57976. /**
  57977. * The skybox material
  57978. */
  57979. protected _material: BackgroundMaterial;
  57980. /**
  57981. * The surface used for the dome
  57982. */
  57983. protected _mesh: Mesh;
  57984. /**
  57985. * Gets the mesh used for the dome.
  57986. */
  57987. get mesh(): Mesh;
  57988. /**
  57989. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57990. */
  57991. private _halfDomeMask;
  57992. /**
  57993. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57994. * Also see the options.resolution property.
  57995. */
  57996. get fovMultiplier(): number;
  57997. set fovMultiplier(value: number);
  57998. protected _textureMode: number;
  57999. /**
  58000. * Gets or set the current texture mode for the texture. It can be:
  58001. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58002. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58003. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58004. */
  58005. get textureMode(): number;
  58006. /**
  58007. * Sets the current texture mode for the texture. It can be:
  58008. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58009. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58010. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58011. */
  58012. set textureMode(value: number);
  58013. /**
  58014. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58015. */
  58016. get halfDome(): boolean;
  58017. /**
  58018. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58019. */
  58020. set halfDome(enabled: boolean);
  58021. /**
  58022. * Oberserver used in Stereoscopic VR Mode.
  58023. */
  58024. private _onBeforeCameraRenderObserver;
  58025. /**
  58026. * Observable raised when an error occured while loading the 360 image
  58027. */
  58028. onLoadErrorObservable: Observable<string>;
  58029. /**
  58030. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58031. * @param name Element's name, child elements will append suffixes for their own names.
  58032. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58033. * @param options An object containing optional or exposed sub element properties
  58034. */
  58035. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58036. resolution?: number;
  58037. clickToPlay?: boolean;
  58038. autoPlay?: boolean;
  58039. loop?: boolean;
  58040. size?: number;
  58041. poster?: string;
  58042. faceForward?: boolean;
  58043. useDirectMapping?: boolean;
  58044. halfDomeMode?: boolean;
  58045. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58046. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58047. protected _changeTextureMode(value: number): void;
  58048. /**
  58049. * Releases resources associated with this node.
  58050. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58051. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58052. */
  58053. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58054. }
  58055. }
  58056. declare module BABYLON {
  58057. /**
  58058. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58059. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58060. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58061. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58062. */
  58063. export class PhotoDome extends TextureDome<Texture> {
  58064. /**
  58065. * Define the image as a Monoscopic panoramic 360 image.
  58066. */
  58067. static readonly MODE_MONOSCOPIC: number;
  58068. /**
  58069. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58070. */
  58071. static readonly MODE_TOPBOTTOM: number;
  58072. /**
  58073. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58074. */
  58075. static readonly MODE_SIDEBYSIDE: number;
  58076. /**
  58077. * Gets or sets the texture being displayed on the sphere
  58078. */
  58079. get photoTexture(): Texture;
  58080. /**
  58081. * sets the texture being displayed on the sphere
  58082. */
  58083. set photoTexture(value: Texture);
  58084. /**
  58085. * Gets the current video mode for the video. It can be:
  58086. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58087. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58088. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58089. */
  58090. get imageMode(): number;
  58091. /**
  58092. * Sets the current video mode for the video. It can be:
  58093. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58094. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58095. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58096. */
  58097. set imageMode(value: number);
  58098. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58099. }
  58100. }
  58101. declare module BABYLON {
  58102. /**
  58103. * Direct draw surface info
  58104. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58105. */
  58106. export interface DDSInfo {
  58107. /**
  58108. * Width of the texture
  58109. */
  58110. width: number;
  58111. /**
  58112. * Width of the texture
  58113. */
  58114. height: number;
  58115. /**
  58116. * Number of Mipmaps for the texture
  58117. * @see https://en.wikipedia.org/wiki/Mipmap
  58118. */
  58119. mipmapCount: number;
  58120. /**
  58121. * If the textures format is a known fourCC format
  58122. * @see https://www.fourcc.org/
  58123. */
  58124. isFourCC: boolean;
  58125. /**
  58126. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58127. */
  58128. isRGB: boolean;
  58129. /**
  58130. * If the texture is a lumincance format
  58131. */
  58132. isLuminance: boolean;
  58133. /**
  58134. * If this is a cube texture
  58135. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58136. */
  58137. isCube: boolean;
  58138. /**
  58139. * If the texture is a compressed format eg. FOURCC_DXT1
  58140. */
  58141. isCompressed: boolean;
  58142. /**
  58143. * The dxgiFormat of the texture
  58144. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58145. */
  58146. dxgiFormat: number;
  58147. /**
  58148. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58149. */
  58150. textureType: number;
  58151. /**
  58152. * Sphericle polynomial created for the dds texture
  58153. */
  58154. sphericalPolynomial?: SphericalPolynomial;
  58155. }
  58156. /**
  58157. * Class used to provide DDS decompression tools
  58158. */
  58159. export class DDSTools {
  58160. /**
  58161. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58162. */
  58163. static StoreLODInAlphaChannel: boolean;
  58164. /**
  58165. * Gets DDS information from an array buffer
  58166. * @param data defines the array buffer view to read data from
  58167. * @returns the DDS information
  58168. */
  58169. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58170. private static _FloatView;
  58171. private static _Int32View;
  58172. private static _ToHalfFloat;
  58173. private static _FromHalfFloat;
  58174. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58175. private static _GetHalfFloatRGBAArrayBuffer;
  58176. private static _GetFloatRGBAArrayBuffer;
  58177. private static _GetFloatAsUIntRGBAArrayBuffer;
  58178. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58179. private static _GetRGBAArrayBuffer;
  58180. private static _ExtractLongWordOrder;
  58181. private static _GetRGBArrayBuffer;
  58182. private static _GetLuminanceArrayBuffer;
  58183. /**
  58184. * Uploads DDS Levels to a Babylon Texture
  58185. * @hidden
  58186. */
  58187. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58188. }
  58189. interface ThinEngine {
  58190. /**
  58191. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58192. * @param rootUrl defines the url where the file to load is located
  58193. * @param scene defines the current scene
  58194. * @param lodScale defines scale to apply to the mip map selection
  58195. * @param lodOffset defines offset to apply to the mip map selection
  58196. * @param onLoad defines an optional callback raised when the texture is loaded
  58197. * @param onError defines an optional callback raised if there is an issue to load the texture
  58198. * @param format defines the format of the data
  58199. * @param forcedExtension defines the extension to use to pick the right loader
  58200. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58201. * @returns the cube texture as an InternalTexture
  58202. */
  58203. 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;
  58204. }
  58205. }
  58206. declare module BABYLON {
  58207. /**
  58208. * Implementation of the DDS Texture Loader.
  58209. * @hidden
  58210. */
  58211. export class _DDSTextureLoader implements IInternalTextureLoader {
  58212. /**
  58213. * Defines wether the loader supports cascade loading the different faces.
  58214. */
  58215. readonly supportCascades: boolean;
  58216. /**
  58217. * This returns if the loader support the current file information.
  58218. * @param extension defines the file extension of the file being loaded
  58219. * @returns true if the loader can load the specified file
  58220. */
  58221. canLoad(extension: string): boolean;
  58222. /**
  58223. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58224. * @param data contains the texture data
  58225. * @param texture defines the BabylonJS internal texture
  58226. * @param createPolynomials will be true if polynomials have been requested
  58227. * @param onLoad defines the callback to trigger once the texture is ready
  58228. * @param onError defines the callback to trigger in case of error
  58229. */
  58230. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58231. /**
  58232. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58233. * @param data contains the texture data
  58234. * @param texture defines the BabylonJS internal texture
  58235. * @param callback defines the method to call once ready to upload
  58236. */
  58237. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58238. }
  58239. }
  58240. declare module BABYLON {
  58241. /**
  58242. * Implementation of the ENV Texture Loader.
  58243. * @hidden
  58244. */
  58245. export class _ENVTextureLoader implements IInternalTextureLoader {
  58246. /**
  58247. * Defines wether the loader supports cascade loading the different faces.
  58248. */
  58249. readonly supportCascades: boolean;
  58250. /**
  58251. * This returns if the loader support the current file information.
  58252. * @param extension defines the file extension of the file being loaded
  58253. * @returns true if the loader can load the specified file
  58254. */
  58255. canLoad(extension: string): boolean;
  58256. /**
  58257. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58258. * @param data contains the texture data
  58259. * @param texture defines the BabylonJS internal texture
  58260. * @param createPolynomials will be true if polynomials have been requested
  58261. * @param onLoad defines the callback to trigger once the texture is ready
  58262. * @param onError defines the callback to trigger in case of error
  58263. */
  58264. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58265. /**
  58266. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58267. * @param data contains the texture data
  58268. * @param texture defines the BabylonJS internal texture
  58269. * @param callback defines the method to call once ready to upload
  58270. */
  58271. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58272. }
  58273. }
  58274. declare module BABYLON {
  58275. /**
  58276. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58277. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58278. */
  58279. export class KhronosTextureContainer {
  58280. /** contents of the KTX container file */
  58281. data: ArrayBufferView;
  58282. private static HEADER_LEN;
  58283. private static COMPRESSED_2D;
  58284. private static COMPRESSED_3D;
  58285. private static TEX_2D;
  58286. private static TEX_3D;
  58287. /**
  58288. * Gets the openGL type
  58289. */
  58290. glType: number;
  58291. /**
  58292. * Gets the openGL type size
  58293. */
  58294. glTypeSize: number;
  58295. /**
  58296. * Gets the openGL format
  58297. */
  58298. glFormat: number;
  58299. /**
  58300. * Gets the openGL internal format
  58301. */
  58302. glInternalFormat: number;
  58303. /**
  58304. * Gets the base internal format
  58305. */
  58306. glBaseInternalFormat: number;
  58307. /**
  58308. * Gets image width in pixel
  58309. */
  58310. pixelWidth: number;
  58311. /**
  58312. * Gets image height in pixel
  58313. */
  58314. pixelHeight: number;
  58315. /**
  58316. * Gets image depth in pixels
  58317. */
  58318. pixelDepth: number;
  58319. /**
  58320. * Gets the number of array elements
  58321. */
  58322. numberOfArrayElements: number;
  58323. /**
  58324. * Gets the number of faces
  58325. */
  58326. numberOfFaces: number;
  58327. /**
  58328. * Gets the number of mipmap levels
  58329. */
  58330. numberOfMipmapLevels: number;
  58331. /**
  58332. * Gets the bytes of key value data
  58333. */
  58334. bytesOfKeyValueData: number;
  58335. /**
  58336. * Gets the load type
  58337. */
  58338. loadType: number;
  58339. /**
  58340. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58341. */
  58342. isInvalid: boolean;
  58343. /**
  58344. * Creates a new KhronosTextureContainer
  58345. * @param data contents of the KTX container file
  58346. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58347. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58348. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58349. */
  58350. constructor(
  58351. /** contents of the KTX container file */
  58352. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58353. /**
  58354. * Uploads KTX content to a Babylon Texture.
  58355. * It is assumed that the texture has already been created & is currently bound
  58356. * @hidden
  58357. */
  58358. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58359. private _upload2DCompressedLevels;
  58360. /**
  58361. * Checks if the given data starts with a KTX file identifier.
  58362. * @param data the data to check
  58363. * @returns true if the data is a KTX file or false otherwise
  58364. */
  58365. static IsValid(data: ArrayBufferView): boolean;
  58366. }
  58367. }
  58368. declare module BABYLON {
  58369. /**
  58370. * Helper class to push actions to a pool of workers.
  58371. */
  58372. export class WorkerPool implements IDisposable {
  58373. private _workerInfos;
  58374. private _pendingActions;
  58375. /**
  58376. * Constructor
  58377. * @param workers Array of workers to use for actions
  58378. */
  58379. constructor(workers: Array<Worker>);
  58380. /**
  58381. * Terminates all workers and clears any pending actions.
  58382. */
  58383. dispose(): void;
  58384. /**
  58385. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58386. * pended until a worker has completed its action.
  58387. * @param action The action to perform. Call onComplete when the action is complete.
  58388. */
  58389. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58390. private _execute;
  58391. }
  58392. }
  58393. declare module BABYLON {
  58394. /**
  58395. * Class for loading KTX2 files
  58396. */
  58397. export class KhronosTextureContainer2 {
  58398. private static _WorkerPoolPromise?;
  58399. private static _Initialized;
  58400. private static _Ktx2Decoder;
  58401. /**
  58402. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58403. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58404. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58405. * Urls you can change:
  58406. * URLConfig.jsDecoderModule
  58407. * URLConfig.wasmUASTCToASTC
  58408. * URLConfig.wasmUASTCToBC7
  58409. * URLConfig.jsMSCTranscoder
  58410. * URLConfig.wasmMSCTranscoder
  58411. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58412. */
  58413. static URLConfig: {
  58414. jsDecoderModule: string;
  58415. wasmUASTCToASTC: null;
  58416. wasmUASTCToBC7: null;
  58417. jsMSCTranscoder: null;
  58418. wasmMSCTranscoder: null;
  58419. };
  58420. /**
  58421. * Default number of workers used to handle data decoding
  58422. */
  58423. static DefaultNumWorkers: number;
  58424. private static GetDefaultNumWorkers;
  58425. private _engine;
  58426. private static _CreateWorkerPool;
  58427. /**
  58428. * Constructor
  58429. * @param engine The engine to use
  58430. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58431. */
  58432. constructor(engine: ThinEngine, numWorkers?: number);
  58433. /** @hidden */
  58434. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58435. /**
  58436. * Stop all async operations and release resources.
  58437. */
  58438. dispose(): void;
  58439. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  58440. /**
  58441. * Checks if the given data starts with a KTX2 file identifier.
  58442. * @param data the data to check
  58443. * @returns true if the data is a KTX2 file or false otherwise
  58444. */
  58445. static IsValid(data: ArrayBufferView): boolean;
  58446. }
  58447. }
  58448. declare module BABYLON {
  58449. /**
  58450. * Implementation of the KTX Texture Loader.
  58451. * @hidden
  58452. */
  58453. export class _KTXTextureLoader implements IInternalTextureLoader {
  58454. /**
  58455. * Defines wether the loader supports cascade loading the different faces.
  58456. */
  58457. readonly supportCascades: boolean;
  58458. /**
  58459. * This returns if the loader support the current file information.
  58460. * @param extension defines the file extension of the file being loaded
  58461. * @param mimeType defines the optional mime type of the file being loaded
  58462. * @returns true if the loader can load the specified file
  58463. */
  58464. canLoad(extension: string, mimeType?: string): boolean;
  58465. /**
  58466. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58467. * @param data contains the texture data
  58468. * @param texture defines the BabylonJS internal texture
  58469. * @param createPolynomials will be true if polynomials have been requested
  58470. * @param onLoad defines the callback to trigger once the texture is ready
  58471. * @param onError defines the callback to trigger in case of error
  58472. */
  58473. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58474. /**
  58475. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58476. * @param data contains the texture data
  58477. * @param texture defines the BabylonJS internal texture
  58478. * @param callback defines the method to call once ready to upload
  58479. */
  58480. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58481. }
  58482. }
  58483. declare module BABYLON {
  58484. /** @hidden */
  58485. export var _forceSceneHelpersToBundle: boolean;
  58486. interface Scene {
  58487. /**
  58488. * Creates a default light for the scene.
  58489. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58490. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58491. */
  58492. createDefaultLight(replace?: boolean): void;
  58493. /**
  58494. * Creates a default camera for the scene.
  58495. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58496. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58497. * @param replace has default false, when true replaces the active camera in the scene
  58498. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58499. */
  58500. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58501. /**
  58502. * Creates a default camera and a default light.
  58503. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58504. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58505. * @param replace has the default false, when true replaces the active camera/light in the scene
  58506. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58507. */
  58508. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58509. /**
  58510. * Creates a new sky box
  58511. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58512. * @param environmentTexture defines the texture to use as environment texture
  58513. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58514. * @param scale defines the overall scale of the skybox
  58515. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58516. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58517. * @returns a new mesh holding the sky box
  58518. */
  58519. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58520. /**
  58521. * Creates a new environment
  58522. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58523. * @param options defines the options you can use to configure the environment
  58524. * @returns the new EnvironmentHelper
  58525. */
  58526. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58527. /**
  58528. * Creates a new VREXperienceHelper
  58529. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58530. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58531. * @returns a new VREXperienceHelper
  58532. */
  58533. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58534. /**
  58535. * Creates a new WebXRDefaultExperience
  58536. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58537. * @param options experience options
  58538. * @returns a promise for a new WebXRDefaultExperience
  58539. */
  58540. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58541. }
  58542. }
  58543. declare module BABYLON {
  58544. /**
  58545. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58546. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58547. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58548. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58549. */
  58550. export class VideoDome extends TextureDome<VideoTexture> {
  58551. /**
  58552. * Define the video source as a Monoscopic panoramic 360 video.
  58553. */
  58554. static readonly MODE_MONOSCOPIC: number;
  58555. /**
  58556. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58557. */
  58558. static readonly MODE_TOPBOTTOM: number;
  58559. /**
  58560. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58561. */
  58562. static readonly MODE_SIDEBYSIDE: number;
  58563. /**
  58564. * Get the video texture associated with this video dome
  58565. */
  58566. get videoTexture(): VideoTexture;
  58567. /**
  58568. * Get the video mode of this dome
  58569. */
  58570. get videoMode(): number;
  58571. /**
  58572. * Set the video mode of this dome.
  58573. * @see textureMode
  58574. */
  58575. set videoMode(value: number);
  58576. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58577. }
  58578. }
  58579. declare module BABYLON {
  58580. /**
  58581. * This class can be used to get instrumentation data from a Babylon engine
  58582. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58583. */
  58584. export class EngineInstrumentation implements IDisposable {
  58585. /**
  58586. * Define the instrumented engine.
  58587. */
  58588. engine: Engine;
  58589. private _captureGPUFrameTime;
  58590. private _gpuFrameTimeToken;
  58591. private _gpuFrameTime;
  58592. private _captureShaderCompilationTime;
  58593. private _shaderCompilationTime;
  58594. private _onBeginFrameObserver;
  58595. private _onEndFrameObserver;
  58596. private _onBeforeShaderCompilationObserver;
  58597. private _onAfterShaderCompilationObserver;
  58598. /**
  58599. * Gets the perf counter used for GPU frame time
  58600. */
  58601. get gpuFrameTimeCounter(): PerfCounter;
  58602. /**
  58603. * Gets the GPU frame time capture status
  58604. */
  58605. get captureGPUFrameTime(): boolean;
  58606. /**
  58607. * Enable or disable the GPU frame time capture
  58608. */
  58609. set captureGPUFrameTime(value: boolean);
  58610. /**
  58611. * Gets the perf counter used for shader compilation time
  58612. */
  58613. get shaderCompilationTimeCounter(): PerfCounter;
  58614. /**
  58615. * Gets the shader compilation time capture status
  58616. */
  58617. get captureShaderCompilationTime(): boolean;
  58618. /**
  58619. * Enable or disable the shader compilation time capture
  58620. */
  58621. set captureShaderCompilationTime(value: boolean);
  58622. /**
  58623. * Instantiates a new engine instrumentation.
  58624. * This class can be used to get instrumentation data from a Babylon engine
  58625. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58626. * @param engine Defines the engine to instrument
  58627. */
  58628. constructor(
  58629. /**
  58630. * Define the instrumented engine.
  58631. */
  58632. engine: Engine);
  58633. /**
  58634. * Dispose and release associated resources.
  58635. */
  58636. dispose(): void;
  58637. }
  58638. }
  58639. declare module BABYLON {
  58640. /**
  58641. * This class can be used to get instrumentation data from a Babylon engine
  58642. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58643. */
  58644. export class SceneInstrumentation implements IDisposable {
  58645. /**
  58646. * Defines the scene to instrument
  58647. */
  58648. scene: Scene;
  58649. private _captureActiveMeshesEvaluationTime;
  58650. private _activeMeshesEvaluationTime;
  58651. private _captureRenderTargetsRenderTime;
  58652. private _renderTargetsRenderTime;
  58653. private _captureFrameTime;
  58654. private _frameTime;
  58655. private _captureRenderTime;
  58656. private _renderTime;
  58657. private _captureInterFrameTime;
  58658. private _interFrameTime;
  58659. private _captureParticlesRenderTime;
  58660. private _particlesRenderTime;
  58661. private _captureSpritesRenderTime;
  58662. private _spritesRenderTime;
  58663. private _capturePhysicsTime;
  58664. private _physicsTime;
  58665. private _captureAnimationsTime;
  58666. private _animationsTime;
  58667. private _captureCameraRenderTime;
  58668. private _cameraRenderTime;
  58669. private _onBeforeActiveMeshesEvaluationObserver;
  58670. private _onAfterActiveMeshesEvaluationObserver;
  58671. private _onBeforeRenderTargetsRenderObserver;
  58672. private _onAfterRenderTargetsRenderObserver;
  58673. private _onAfterRenderObserver;
  58674. private _onBeforeDrawPhaseObserver;
  58675. private _onAfterDrawPhaseObserver;
  58676. private _onBeforeAnimationsObserver;
  58677. private _onBeforeParticlesRenderingObserver;
  58678. private _onAfterParticlesRenderingObserver;
  58679. private _onBeforeSpritesRenderingObserver;
  58680. private _onAfterSpritesRenderingObserver;
  58681. private _onBeforePhysicsObserver;
  58682. private _onAfterPhysicsObserver;
  58683. private _onAfterAnimationsObserver;
  58684. private _onBeforeCameraRenderObserver;
  58685. private _onAfterCameraRenderObserver;
  58686. /**
  58687. * Gets the perf counter used for active meshes evaluation time
  58688. */
  58689. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58690. /**
  58691. * Gets the active meshes evaluation time capture status
  58692. */
  58693. get captureActiveMeshesEvaluationTime(): boolean;
  58694. /**
  58695. * Enable or disable the active meshes evaluation time capture
  58696. */
  58697. set captureActiveMeshesEvaluationTime(value: boolean);
  58698. /**
  58699. * Gets the perf counter used for render targets render time
  58700. */
  58701. get renderTargetsRenderTimeCounter(): PerfCounter;
  58702. /**
  58703. * Gets the render targets render time capture status
  58704. */
  58705. get captureRenderTargetsRenderTime(): boolean;
  58706. /**
  58707. * Enable or disable the render targets render time capture
  58708. */
  58709. set captureRenderTargetsRenderTime(value: boolean);
  58710. /**
  58711. * Gets the perf counter used for particles render time
  58712. */
  58713. get particlesRenderTimeCounter(): PerfCounter;
  58714. /**
  58715. * Gets the particles render time capture status
  58716. */
  58717. get captureParticlesRenderTime(): boolean;
  58718. /**
  58719. * Enable or disable the particles render time capture
  58720. */
  58721. set captureParticlesRenderTime(value: boolean);
  58722. /**
  58723. * Gets the perf counter used for sprites render time
  58724. */
  58725. get spritesRenderTimeCounter(): PerfCounter;
  58726. /**
  58727. * Gets the sprites render time capture status
  58728. */
  58729. get captureSpritesRenderTime(): boolean;
  58730. /**
  58731. * Enable or disable the sprites render time capture
  58732. */
  58733. set captureSpritesRenderTime(value: boolean);
  58734. /**
  58735. * Gets the perf counter used for physics time
  58736. */
  58737. get physicsTimeCounter(): PerfCounter;
  58738. /**
  58739. * Gets the physics time capture status
  58740. */
  58741. get capturePhysicsTime(): boolean;
  58742. /**
  58743. * Enable or disable the physics time capture
  58744. */
  58745. set capturePhysicsTime(value: boolean);
  58746. /**
  58747. * Gets the perf counter used for animations time
  58748. */
  58749. get animationsTimeCounter(): PerfCounter;
  58750. /**
  58751. * Gets the animations time capture status
  58752. */
  58753. get captureAnimationsTime(): boolean;
  58754. /**
  58755. * Enable or disable the animations time capture
  58756. */
  58757. set captureAnimationsTime(value: boolean);
  58758. /**
  58759. * Gets the perf counter used for frame time capture
  58760. */
  58761. get frameTimeCounter(): PerfCounter;
  58762. /**
  58763. * Gets the frame time capture status
  58764. */
  58765. get captureFrameTime(): boolean;
  58766. /**
  58767. * Enable or disable the frame time capture
  58768. */
  58769. set captureFrameTime(value: boolean);
  58770. /**
  58771. * Gets the perf counter used for inter-frames time capture
  58772. */
  58773. get interFrameTimeCounter(): PerfCounter;
  58774. /**
  58775. * Gets the inter-frames time capture status
  58776. */
  58777. get captureInterFrameTime(): boolean;
  58778. /**
  58779. * Enable or disable the inter-frames time capture
  58780. */
  58781. set captureInterFrameTime(value: boolean);
  58782. /**
  58783. * Gets the perf counter used for render time capture
  58784. */
  58785. get renderTimeCounter(): PerfCounter;
  58786. /**
  58787. * Gets the render time capture status
  58788. */
  58789. get captureRenderTime(): boolean;
  58790. /**
  58791. * Enable or disable the render time capture
  58792. */
  58793. set captureRenderTime(value: boolean);
  58794. /**
  58795. * Gets the perf counter used for camera render time capture
  58796. */
  58797. get cameraRenderTimeCounter(): PerfCounter;
  58798. /**
  58799. * Gets the camera render time capture status
  58800. */
  58801. get captureCameraRenderTime(): boolean;
  58802. /**
  58803. * Enable or disable the camera render time capture
  58804. */
  58805. set captureCameraRenderTime(value: boolean);
  58806. /**
  58807. * Gets the perf counter used for draw calls
  58808. */
  58809. get drawCallsCounter(): PerfCounter;
  58810. /**
  58811. * Instantiates a new scene instrumentation.
  58812. * This class can be used to get instrumentation data from a Babylon engine
  58813. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58814. * @param scene Defines the scene to instrument
  58815. */
  58816. constructor(
  58817. /**
  58818. * Defines the scene to instrument
  58819. */
  58820. scene: Scene);
  58821. /**
  58822. * Dispose and release associated resources.
  58823. */
  58824. dispose(): void;
  58825. }
  58826. }
  58827. declare module BABYLON {
  58828. /** @hidden */
  58829. export var glowMapGenerationPixelShader: {
  58830. name: string;
  58831. shader: string;
  58832. };
  58833. }
  58834. declare module BABYLON {
  58835. /** @hidden */
  58836. export var glowMapGenerationVertexShader: {
  58837. name: string;
  58838. shader: string;
  58839. };
  58840. }
  58841. declare module BABYLON {
  58842. /**
  58843. * Effect layer options. This helps customizing the behaviour
  58844. * of the effect layer.
  58845. */
  58846. export interface IEffectLayerOptions {
  58847. /**
  58848. * Multiplication factor apply to the canvas size to compute the render target size
  58849. * used to generated the objects (the smaller the faster).
  58850. */
  58851. mainTextureRatio: number;
  58852. /**
  58853. * Enforces a fixed size texture to ensure effect stability across devices.
  58854. */
  58855. mainTextureFixedSize?: number;
  58856. /**
  58857. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58858. */
  58859. alphaBlendingMode: number;
  58860. /**
  58861. * The camera attached to the layer.
  58862. */
  58863. camera: Nullable<Camera>;
  58864. /**
  58865. * The rendering group to draw the layer in.
  58866. */
  58867. renderingGroupId: number;
  58868. }
  58869. /**
  58870. * The effect layer Helps adding post process effect blended with the main pass.
  58871. *
  58872. * This can be for instance use to generate glow or higlight effects on the scene.
  58873. *
  58874. * The effect layer class can not be used directly and is intented to inherited from to be
  58875. * customized per effects.
  58876. */
  58877. export abstract class EffectLayer {
  58878. private _vertexBuffers;
  58879. private _indexBuffer;
  58880. private _cachedDefines;
  58881. private _effectLayerMapGenerationEffect;
  58882. private _effectLayerOptions;
  58883. private _mergeEffect;
  58884. protected _scene: Scene;
  58885. protected _engine: Engine;
  58886. protected _maxSize: number;
  58887. protected _mainTextureDesiredSize: ISize;
  58888. protected _mainTexture: RenderTargetTexture;
  58889. protected _shouldRender: boolean;
  58890. protected _postProcesses: PostProcess[];
  58891. protected _textures: BaseTexture[];
  58892. protected _emissiveTextureAndColor: {
  58893. texture: Nullable<BaseTexture>;
  58894. color: Color4;
  58895. };
  58896. /**
  58897. * The name of the layer
  58898. */
  58899. name: string;
  58900. /**
  58901. * The clear color of the texture used to generate the glow map.
  58902. */
  58903. neutralColor: Color4;
  58904. /**
  58905. * Specifies whether the highlight layer is enabled or not.
  58906. */
  58907. isEnabled: boolean;
  58908. /**
  58909. * Gets the camera attached to the layer.
  58910. */
  58911. get camera(): Nullable<Camera>;
  58912. /**
  58913. * Gets the rendering group id the layer should render in.
  58914. */
  58915. get renderingGroupId(): number;
  58916. set renderingGroupId(renderingGroupId: number);
  58917. /**
  58918. * An event triggered when the effect layer has been disposed.
  58919. */
  58920. onDisposeObservable: Observable<EffectLayer>;
  58921. /**
  58922. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58923. */
  58924. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58925. /**
  58926. * An event triggered when the generated texture is being merged in the scene.
  58927. */
  58928. onBeforeComposeObservable: Observable<EffectLayer>;
  58929. /**
  58930. * An event triggered when the mesh is rendered into the effect render target.
  58931. */
  58932. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58933. /**
  58934. * An event triggered after the mesh has been rendered into the effect render target.
  58935. */
  58936. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58937. /**
  58938. * An event triggered when the generated texture has been merged in the scene.
  58939. */
  58940. onAfterComposeObservable: Observable<EffectLayer>;
  58941. /**
  58942. * An event triggered when the efffect layer changes its size.
  58943. */
  58944. onSizeChangedObservable: Observable<EffectLayer>;
  58945. /** @hidden */
  58946. static _SceneComponentInitialization: (scene: Scene) => void;
  58947. /**
  58948. * Instantiates a new effect Layer and references it in the scene.
  58949. * @param name The name of the layer
  58950. * @param scene The scene to use the layer in
  58951. */
  58952. constructor(
  58953. /** The Friendly of the effect in the scene */
  58954. name: string, scene: Scene);
  58955. /**
  58956. * Get the effect name of the layer.
  58957. * @return The effect name
  58958. */
  58959. abstract getEffectName(): string;
  58960. /**
  58961. * Checks for the readiness of the element composing the layer.
  58962. * @param subMesh the mesh to check for
  58963. * @param useInstances specify whether or not to use instances to render the mesh
  58964. * @return true if ready otherwise, false
  58965. */
  58966. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58967. /**
  58968. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58969. * @returns true if the effect requires stencil during the main canvas render pass.
  58970. */
  58971. abstract needStencil(): boolean;
  58972. /**
  58973. * Create the merge effect. This is the shader use to blit the information back
  58974. * to the main canvas at the end of the scene rendering.
  58975. * @returns The effect containing the shader used to merge the effect on the main canvas
  58976. */
  58977. protected abstract _createMergeEffect(): Effect;
  58978. /**
  58979. * Creates the render target textures and post processes used in the effect layer.
  58980. */
  58981. protected abstract _createTextureAndPostProcesses(): void;
  58982. /**
  58983. * Implementation specific of rendering the generating effect on the main canvas.
  58984. * @param effect The effect used to render through
  58985. */
  58986. protected abstract _internalRender(effect: Effect): void;
  58987. /**
  58988. * Sets the required values for both the emissive texture and and the main color.
  58989. */
  58990. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58991. /**
  58992. * Free any resources and references associated to a mesh.
  58993. * Internal use
  58994. * @param mesh The mesh to free.
  58995. */
  58996. abstract _disposeMesh(mesh: Mesh): void;
  58997. /**
  58998. * Serializes this layer (Glow or Highlight for example)
  58999. * @returns a serialized layer object
  59000. */
  59001. abstract serialize?(): any;
  59002. /**
  59003. * Initializes the effect layer with the required options.
  59004. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59005. */
  59006. protected _init(options: Partial<IEffectLayerOptions>): void;
  59007. /**
  59008. * Generates the index buffer of the full screen quad blending to the main canvas.
  59009. */
  59010. private _generateIndexBuffer;
  59011. /**
  59012. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59013. */
  59014. private _generateVertexBuffer;
  59015. /**
  59016. * Sets the main texture desired size which is the closest power of two
  59017. * of the engine canvas size.
  59018. */
  59019. private _setMainTextureSize;
  59020. /**
  59021. * Creates the main texture for the effect layer.
  59022. */
  59023. protected _createMainTexture(): void;
  59024. /**
  59025. * Adds specific effects defines.
  59026. * @param defines The defines to add specifics to.
  59027. */
  59028. protected _addCustomEffectDefines(defines: string[]): void;
  59029. /**
  59030. * Checks for the readiness of the element composing the layer.
  59031. * @param subMesh the mesh to check for
  59032. * @param useInstances specify whether or not to use instances to render the mesh
  59033. * @param emissiveTexture the associated emissive texture used to generate the glow
  59034. * @return true if ready otherwise, false
  59035. */
  59036. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59037. /**
  59038. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59039. */
  59040. render(): void;
  59041. /**
  59042. * Determine if a given mesh will be used in the current effect.
  59043. * @param mesh mesh to test
  59044. * @returns true if the mesh will be used
  59045. */
  59046. hasMesh(mesh: AbstractMesh): boolean;
  59047. /**
  59048. * Returns true if the layer contains information to display, otherwise false.
  59049. * @returns true if the glow layer should be rendered
  59050. */
  59051. shouldRender(): boolean;
  59052. /**
  59053. * Returns true if the mesh should render, otherwise false.
  59054. * @param mesh The mesh to render
  59055. * @returns true if it should render otherwise false
  59056. */
  59057. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59058. /**
  59059. * Returns true if the mesh can be rendered, otherwise false.
  59060. * @param mesh The mesh to render
  59061. * @param material The material used on the mesh
  59062. * @returns true if it can be rendered otherwise false
  59063. */
  59064. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59065. /**
  59066. * Returns true if the mesh should render, otherwise false.
  59067. * @param mesh The mesh to render
  59068. * @returns true if it should render otherwise false
  59069. */
  59070. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59071. /**
  59072. * Renders the submesh passed in parameter to the generation map.
  59073. */
  59074. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59075. /**
  59076. * Defines whether the current material of the mesh should be use to render the effect.
  59077. * @param mesh defines the current mesh to render
  59078. */
  59079. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59080. /**
  59081. * Rebuild the required buffers.
  59082. * @hidden Internal use only.
  59083. */
  59084. _rebuild(): void;
  59085. /**
  59086. * Dispose only the render target textures and post process.
  59087. */
  59088. private _disposeTextureAndPostProcesses;
  59089. /**
  59090. * Dispose the highlight layer and free resources.
  59091. */
  59092. dispose(): void;
  59093. /**
  59094. * Gets the class name of the effect layer
  59095. * @returns the string with the class name of the effect layer
  59096. */
  59097. getClassName(): string;
  59098. /**
  59099. * Creates an effect layer from parsed effect layer data
  59100. * @param parsedEffectLayer defines effect layer data
  59101. * @param scene defines the current scene
  59102. * @param rootUrl defines the root URL containing the effect layer information
  59103. * @returns a parsed effect Layer
  59104. */
  59105. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59106. }
  59107. }
  59108. declare module BABYLON {
  59109. interface AbstractScene {
  59110. /**
  59111. * The list of effect layers (highlights/glow) added to the scene
  59112. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59113. * @see https://doc.babylonjs.com/how_to/glow_layer
  59114. */
  59115. effectLayers: Array<EffectLayer>;
  59116. /**
  59117. * Removes the given effect layer from this scene.
  59118. * @param toRemove defines the effect layer to remove
  59119. * @returns the index of the removed effect layer
  59120. */
  59121. removeEffectLayer(toRemove: EffectLayer): number;
  59122. /**
  59123. * Adds the given effect layer to this scene
  59124. * @param newEffectLayer defines the effect layer to add
  59125. */
  59126. addEffectLayer(newEffectLayer: EffectLayer): void;
  59127. }
  59128. /**
  59129. * Defines the layer scene component responsible to manage any effect layers
  59130. * in a given scene.
  59131. */
  59132. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59133. /**
  59134. * The component name helpfull to identify the component in the list of scene components.
  59135. */
  59136. readonly name: string;
  59137. /**
  59138. * The scene the component belongs to.
  59139. */
  59140. scene: Scene;
  59141. private _engine;
  59142. private _renderEffects;
  59143. private _needStencil;
  59144. private _previousStencilState;
  59145. /**
  59146. * Creates a new instance of the component for the given scene
  59147. * @param scene Defines the scene to register the component in
  59148. */
  59149. constructor(scene: Scene);
  59150. /**
  59151. * Registers the component in a given scene
  59152. */
  59153. register(): void;
  59154. /**
  59155. * Rebuilds the elements related to this component in case of
  59156. * context lost for instance.
  59157. */
  59158. rebuild(): void;
  59159. /**
  59160. * Serializes the component data to the specified json object
  59161. * @param serializationObject The object to serialize to
  59162. */
  59163. serialize(serializationObject: any): void;
  59164. /**
  59165. * Adds all the elements from the container to the scene
  59166. * @param container the container holding the elements
  59167. */
  59168. addFromContainer(container: AbstractScene): void;
  59169. /**
  59170. * Removes all the elements in the container from the scene
  59171. * @param container contains the elements to remove
  59172. * @param dispose if the removed element should be disposed (default: false)
  59173. */
  59174. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59175. /**
  59176. * Disposes the component and the associated ressources.
  59177. */
  59178. dispose(): void;
  59179. private _isReadyForMesh;
  59180. private _renderMainTexture;
  59181. private _setStencil;
  59182. private _setStencilBack;
  59183. private _draw;
  59184. private _drawCamera;
  59185. private _drawRenderingGroup;
  59186. }
  59187. }
  59188. declare module BABYLON {
  59189. /** @hidden */
  59190. export var glowMapMergePixelShader: {
  59191. name: string;
  59192. shader: string;
  59193. };
  59194. }
  59195. declare module BABYLON {
  59196. /** @hidden */
  59197. export var glowMapMergeVertexShader: {
  59198. name: string;
  59199. shader: string;
  59200. };
  59201. }
  59202. declare module BABYLON {
  59203. interface AbstractScene {
  59204. /**
  59205. * Return a the first highlight layer of the scene with a given name.
  59206. * @param name The name of the highlight layer to look for.
  59207. * @return The highlight layer if found otherwise null.
  59208. */
  59209. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59210. }
  59211. /**
  59212. * Glow layer options. This helps customizing the behaviour
  59213. * of the glow layer.
  59214. */
  59215. export interface IGlowLayerOptions {
  59216. /**
  59217. * Multiplication factor apply to the canvas size to compute the render target size
  59218. * used to generated the glowing objects (the smaller the faster).
  59219. */
  59220. mainTextureRatio: number;
  59221. /**
  59222. * Enforces a fixed size texture to ensure resize independant blur.
  59223. */
  59224. mainTextureFixedSize?: number;
  59225. /**
  59226. * How big is the kernel of the blur texture.
  59227. */
  59228. blurKernelSize: number;
  59229. /**
  59230. * The camera attached to the layer.
  59231. */
  59232. camera: Nullable<Camera>;
  59233. /**
  59234. * Enable MSAA by chosing the number of samples.
  59235. */
  59236. mainTextureSamples?: number;
  59237. /**
  59238. * The rendering group to draw the layer in.
  59239. */
  59240. renderingGroupId: number;
  59241. }
  59242. /**
  59243. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59244. *
  59245. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59246. *
  59247. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59248. */
  59249. export class GlowLayer extends EffectLayer {
  59250. /**
  59251. * Effect Name of the layer.
  59252. */
  59253. static readonly EffectName: string;
  59254. /**
  59255. * The default blur kernel size used for the glow.
  59256. */
  59257. static DefaultBlurKernelSize: number;
  59258. /**
  59259. * The default texture size ratio used for the glow.
  59260. */
  59261. static DefaultTextureRatio: number;
  59262. /**
  59263. * Sets the kernel size of the blur.
  59264. */
  59265. set blurKernelSize(value: number);
  59266. /**
  59267. * Gets the kernel size of the blur.
  59268. */
  59269. get blurKernelSize(): number;
  59270. /**
  59271. * Sets the glow intensity.
  59272. */
  59273. set intensity(value: number);
  59274. /**
  59275. * Gets the glow intensity.
  59276. */
  59277. get intensity(): number;
  59278. private _options;
  59279. private _intensity;
  59280. private _horizontalBlurPostprocess1;
  59281. private _verticalBlurPostprocess1;
  59282. private _horizontalBlurPostprocess2;
  59283. private _verticalBlurPostprocess2;
  59284. private _blurTexture1;
  59285. private _blurTexture2;
  59286. private _postProcesses1;
  59287. private _postProcesses2;
  59288. private _includedOnlyMeshes;
  59289. private _excludedMeshes;
  59290. private _meshesUsingTheirOwnMaterials;
  59291. /**
  59292. * Callback used to let the user override the color selection on a per mesh basis
  59293. */
  59294. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59295. /**
  59296. * Callback used to let the user override the texture selection on a per mesh basis
  59297. */
  59298. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59299. /**
  59300. * Instantiates a new glow Layer and references it to the scene.
  59301. * @param name The name of the layer
  59302. * @param scene The scene to use the layer in
  59303. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59304. */
  59305. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59306. /**
  59307. * Get the effect name of the layer.
  59308. * @return The effect name
  59309. */
  59310. getEffectName(): string;
  59311. /**
  59312. * Create the merge effect. This is the shader use to blit the information back
  59313. * to the main canvas at the end of the scene rendering.
  59314. */
  59315. protected _createMergeEffect(): Effect;
  59316. /**
  59317. * Creates the render target textures and post processes used in the glow layer.
  59318. */
  59319. protected _createTextureAndPostProcesses(): void;
  59320. /**
  59321. * Checks for the readiness of the element composing the layer.
  59322. * @param subMesh the mesh to check for
  59323. * @param useInstances specify wether or not to use instances to render the mesh
  59324. * @param emissiveTexture the associated emissive texture used to generate the glow
  59325. * @return true if ready otherwise, false
  59326. */
  59327. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59328. /**
  59329. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59330. */
  59331. needStencil(): boolean;
  59332. /**
  59333. * Returns true if the mesh can be rendered, otherwise false.
  59334. * @param mesh The mesh to render
  59335. * @param material The material used on the mesh
  59336. * @returns true if it can be rendered otherwise false
  59337. */
  59338. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59339. /**
  59340. * Implementation specific of rendering the generating effect on the main canvas.
  59341. * @param effect The effect used to render through
  59342. */
  59343. protected _internalRender(effect: Effect): void;
  59344. /**
  59345. * Sets the required values for both the emissive texture and and the main color.
  59346. */
  59347. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59348. /**
  59349. * Returns true if the mesh should render, otherwise false.
  59350. * @param mesh The mesh to render
  59351. * @returns true if it should render otherwise false
  59352. */
  59353. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59354. /**
  59355. * Adds specific effects defines.
  59356. * @param defines The defines to add specifics to.
  59357. */
  59358. protected _addCustomEffectDefines(defines: string[]): void;
  59359. /**
  59360. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59361. * @param mesh The mesh to exclude from the glow layer
  59362. */
  59363. addExcludedMesh(mesh: Mesh): void;
  59364. /**
  59365. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59366. * @param mesh The mesh to remove
  59367. */
  59368. removeExcludedMesh(mesh: Mesh): void;
  59369. /**
  59370. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59371. * @param mesh The mesh to include in the glow layer
  59372. */
  59373. addIncludedOnlyMesh(mesh: Mesh): void;
  59374. /**
  59375. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59376. * @param mesh The mesh to remove
  59377. */
  59378. removeIncludedOnlyMesh(mesh: Mesh): void;
  59379. /**
  59380. * Determine if a given mesh will be used in the glow layer
  59381. * @param mesh The mesh to test
  59382. * @returns true if the mesh will be highlighted by the current glow layer
  59383. */
  59384. hasMesh(mesh: AbstractMesh): boolean;
  59385. /**
  59386. * Defines whether the current material of the mesh should be use to render the effect.
  59387. * @param mesh defines the current mesh to render
  59388. */
  59389. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59390. /**
  59391. * Add a mesh to be rendered through its own material and not with emissive only.
  59392. * @param mesh The mesh for which we need to use its material
  59393. */
  59394. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59395. /**
  59396. * Remove a mesh from being rendered through its own material and not with emissive only.
  59397. * @param mesh The mesh for which we need to not use its material
  59398. */
  59399. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59400. /**
  59401. * Free any resources and references associated to a mesh.
  59402. * Internal use
  59403. * @param mesh The mesh to free.
  59404. * @hidden
  59405. */
  59406. _disposeMesh(mesh: Mesh): void;
  59407. /**
  59408. * Gets the class name of the effect layer
  59409. * @returns the string with the class name of the effect layer
  59410. */
  59411. getClassName(): string;
  59412. /**
  59413. * Serializes this glow layer
  59414. * @returns a serialized glow layer object
  59415. */
  59416. serialize(): any;
  59417. /**
  59418. * Creates a Glow Layer from parsed glow layer data
  59419. * @param parsedGlowLayer defines glow layer data
  59420. * @param scene defines the current scene
  59421. * @param rootUrl defines the root URL containing the glow layer information
  59422. * @returns a parsed Glow Layer
  59423. */
  59424. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59425. }
  59426. }
  59427. declare module BABYLON {
  59428. /** @hidden */
  59429. export var glowBlurPostProcessPixelShader: {
  59430. name: string;
  59431. shader: string;
  59432. };
  59433. }
  59434. declare module BABYLON {
  59435. interface AbstractScene {
  59436. /**
  59437. * Return a the first highlight layer of the scene with a given name.
  59438. * @param name The name of the highlight layer to look for.
  59439. * @return The highlight layer if found otherwise null.
  59440. */
  59441. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59442. }
  59443. /**
  59444. * Highlight layer options. This helps customizing the behaviour
  59445. * of the highlight layer.
  59446. */
  59447. export interface IHighlightLayerOptions {
  59448. /**
  59449. * Multiplication factor apply to the canvas size to compute the render target size
  59450. * used to generated the glowing objects (the smaller the faster).
  59451. */
  59452. mainTextureRatio: number;
  59453. /**
  59454. * Enforces a fixed size texture to ensure resize independant blur.
  59455. */
  59456. mainTextureFixedSize?: number;
  59457. /**
  59458. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59459. * of the picture to blur (the smaller the faster).
  59460. */
  59461. blurTextureSizeRatio: number;
  59462. /**
  59463. * How big in texel of the blur texture is the vertical blur.
  59464. */
  59465. blurVerticalSize: number;
  59466. /**
  59467. * How big in texel of the blur texture is the horizontal blur.
  59468. */
  59469. blurHorizontalSize: number;
  59470. /**
  59471. * Alpha blending mode used to apply the blur. Default is combine.
  59472. */
  59473. alphaBlendingMode: number;
  59474. /**
  59475. * The camera attached to the layer.
  59476. */
  59477. camera: Nullable<Camera>;
  59478. /**
  59479. * Should we display highlight as a solid stroke?
  59480. */
  59481. isStroke?: boolean;
  59482. /**
  59483. * The rendering group to draw the layer in.
  59484. */
  59485. renderingGroupId: number;
  59486. }
  59487. /**
  59488. * The highlight layer Helps adding a glow effect around a mesh.
  59489. *
  59490. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59491. * glowy meshes to your scene.
  59492. *
  59493. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59494. */
  59495. export class HighlightLayer extends EffectLayer {
  59496. name: string;
  59497. /**
  59498. * Effect Name of the highlight layer.
  59499. */
  59500. static readonly EffectName: string;
  59501. /**
  59502. * The neutral color used during the preparation of the glow effect.
  59503. * This is black by default as the blend operation is a blend operation.
  59504. */
  59505. static NeutralColor: Color4;
  59506. /**
  59507. * Stencil value used for glowing meshes.
  59508. */
  59509. static GlowingMeshStencilReference: number;
  59510. /**
  59511. * Stencil value used for the other meshes in the scene.
  59512. */
  59513. static NormalMeshStencilReference: number;
  59514. /**
  59515. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59516. */
  59517. innerGlow: boolean;
  59518. /**
  59519. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59520. */
  59521. outerGlow: boolean;
  59522. /**
  59523. * Specifies the horizontal size of the blur.
  59524. */
  59525. set blurHorizontalSize(value: number);
  59526. /**
  59527. * Specifies the vertical size of the blur.
  59528. */
  59529. set blurVerticalSize(value: number);
  59530. /**
  59531. * Gets the horizontal size of the blur.
  59532. */
  59533. get blurHorizontalSize(): number;
  59534. /**
  59535. * Gets the vertical size of the blur.
  59536. */
  59537. get blurVerticalSize(): number;
  59538. /**
  59539. * An event triggered when the highlight layer is being blurred.
  59540. */
  59541. onBeforeBlurObservable: Observable<HighlightLayer>;
  59542. /**
  59543. * An event triggered when the highlight layer has been blurred.
  59544. */
  59545. onAfterBlurObservable: Observable<HighlightLayer>;
  59546. private _instanceGlowingMeshStencilReference;
  59547. private _options;
  59548. private _downSamplePostprocess;
  59549. private _horizontalBlurPostprocess;
  59550. private _verticalBlurPostprocess;
  59551. private _blurTexture;
  59552. private _meshes;
  59553. private _excludedMeshes;
  59554. /**
  59555. * Instantiates a new highlight Layer and references it to the scene..
  59556. * @param name The name of the layer
  59557. * @param scene The scene to use the layer in
  59558. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59559. */
  59560. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59561. /**
  59562. * Get the effect name of the layer.
  59563. * @return The effect name
  59564. */
  59565. getEffectName(): string;
  59566. /**
  59567. * Create the merge effect. This is the shader use to blit the information back
  59568. * to the main canvas at the end of the scene rendering.
  59569. */
  59570. protected _createMergeEffect(): Effect;
  59571. /**
  59572. * Creates the render target textures and post processes used in the highlight layer.
  59573. */
  59574. protected _createTextureAndPostProcesses(): void;
  59575. /**
  59576. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59577. */
  59578. needStencil(): boolean;
  59579. /**
  59580. * Checks for the readiness of the element composing the layer.
  59581. * @param subMesh the mesh to check for
  59582. * @param useInstances specify wether or not to use instances to render the mesh
  59583. * @param emissiveTexture the associated emissive texture used to generate the glow
  59584. * @return true if ready otherwise, false
  59585. */
  59586. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59587. /**
  59588. * Implementation specific of rendering the generating effect on the main canvas.
  59589. * @param effect The effect used to render through
  59590. */
  59591. protected _internalRender(effect: Effect): void;
  59592. /**
  59593. * Returns true if the layer contains information to display, otherwise false.
  59594. */
  59595. shouldRender(): boolean;
  59596. /**
  59597. * Returns true if the mesh should render, otherwise false.
  59598. * @param mesh The mesh to render
  59599. * @returns true if it should render otherwise false
  59600. */
  59601. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59602. /**
  59603. * Returns true if the mesh can be rendered, otherwise false.
  59604. * @param mesh The mesh to render
  59605. * @param material The material used on the mesh
  59606. * @returns true if it can be rendered otherwise false
  59607. */
  59608. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59609. /**
  59610. * Adds specific effects defines.
  59611. * @param defines The defines to add specifics to.
  59612. */
  59613. protected _addCustomEffectDefines(defines: string[]): void;
  59614. /**
  59615. * Sets the required values for both the emissive texture and and the main color.
  59616. */
  59617. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59618. /**
  59619. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59620. * @param mesh The mesh to exclude from the highlight layer
  59621. */
  59622. addExcludedMesh(mesh: Mesh): void;
  59623. /**
  59624. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59625. * @param mesh The mesh to highlight
  59626. */
  59627. removeExcludedMesh(mesh: Mesh): void;
  59628. /**
  59629. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59630. * @param mesh mesh to test
  59631. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59632. */
  59633. hasMesh(mesh: AbstractMesh): boolean;
  59634. /**
  59635. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59636. * @param mesh The mesh to highlight
  59637. * @param color The color of the highlight
  59638. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59639. */
  59640. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59641. /**
  59642. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59643. * @param mesh The mesh to highlight
  59644. */
  59645. removeMesh(mesh: Mesh): void;
  59646. /**
  59647. * Remove all the meshes currently referenced in the highlight layer
  59648. */
  59649. removeAllMeshes(): void;
  59650. /**
  59651. * Force the stencil to the normal expected value for none glowing parts
  59652. */
  59653. private _defaultStencilReference;
  59654. /**
  59655. * Free any resources and references associated to a mesh.
  59656. * Internal use
  59657. * @param mesh The mesh to free.
  59658. * @hidden
  59659. */
  59660. _disposeMesh(mesh: Mesh): void;
  59661. /**
  59662. * Dispose the highlight layer and free resources.
  59663. */
  59664. dispose(): void;
  59665. /**
  59666. * Gets the class name of the effect layer
  59667. * @returns the string with the class name of the effect layer
  59668. */
  59669. getClassName(): string;
  59670. /**
  59671. * Serializes this Highlight layer
  59672. * @returns a serialized Highlight layer object
  59673. */
  59674. serialize(): any;
  59675. /**
  59676. * Creates a Highlight layer from parsed Highlight layer data
  59677. * @param parsedHightlightLayer defines the Highlight layer data
  59678. * @param scene defines the current scene
  59679. * @param rootUrl defines the root URL containing the Highlight layer information
  59680. * @returns a parsed Highlight layer
  59681. */
  59682. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59683. }
  59684. }
  59685. declare module BABYLON {
  59686. interface AbstractScene {
  59687. /**
  59688. * The list of layers (background and foreground) of the scene
  59689. */
  59690. layers: Array<Layer>;
  59691. }
  59692. /**
  59693. * Defines the layer scene component responsible to manage any layers
  59694. * in a given scene.
  59695. */
  59696. export class LayerSceneComponent implements ISceneComponent {
  59697. /**
  59698. * The component name helpfull to identify the component in the list of scene components.
  59699. */
  59700. readonly name: string;
  59701. /**
  59702. * The scene the component belongs to.
  59703. */
  59704. scene: Scene;
  59705. private _engine;
  59706. /**
  59707. * Creates a new instance of the component for the given scene
  59708. * @param scene Defines the scene to register the component in
  59709. */
  59710. constructor(scene: Scene);
  59711. /**
  59712. * Registers the component in a given scene
  59713. */
  59714. register(): void;
  59715. /**
  59716. * Rebuilds the elements related to this component in case of
  59717. * context lost for instance.
  59718. */
  59719. rebuild(): void;
  59720. /**
  59721. * Disposes the component and the associated ressources.
  59722. */
  59723. dispose(): void;
  59724. private _draw;
  59725. private _drawCameraPredicate;
  59726. private _drawCameraBackground;
  59727. private _drawCameraForeground;
  59728. private _drawRenderTargetPredicate;
  59729. private _drawRenderTargetBackground;
  59730. private _drawRenderTargetForeground;
  59731. /**
  59732. * Adds all the elements from the container to the scene
  59733. * @param container the container holding the elements
  59734. */
  59735. addFromContainer(container: AbstractScene): void;
  59736. /**
  59737. * Removes all the elements in the container from the scene
  59738. * @param container contains the elements to remove
  59739. * @param dispose if the removed element should be disposed (default: false)
  59740. */
  59741. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59742. }
  59743. }
  59744. declare module BABYLON {
  59745. /** @hidden */
  59746. export var layerPixelShader: {
  59747. name: string;
  59748. shader: string;
  59749. };
  59750. }
  59751. declare module BABYLON {
  59752. /** @hidden */
  59753. export var layerVertexShader: {
  59754. name: string;
  59755. shader: string;
  59756. };
  59757. }
  59758. declare module BABYLON {
  59759. /**
  59760. * This represents a full screen 2d layer.
  59761. * This can be useful to display a picture in the background of your scene for instance.
  59762. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59763. */
  59764. export class Layer {
  59765. /**
  59766. * Define the name of the layer.
  59767. */
  59768. name: string;
  59769. /**
  59770. * Define the texture the layer should display.
  59771. */
  59772. texture: Nullable<Texture>;
  59773. /**
  59774. * Is the layer in background or foreground.
  59775. */
  59776. isBackground: boolean;
  59777. /**
  59778. * Define the color of the layer (instead of texture).
  59779. */
  59780. color: Color4;
  59781. /**
  59782. * Define the scale of the layer in order to zoom in out of the texture.
  59783. */
  59784. scale: Vector2;
  59785. /**
  59786. * Define an offset for the layer in order to shift the texture.
  59787. */
  59788. offset: Vector2;
  59789. /**
  59790. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59791. */
  59792. alphaBlendingMode: number;
  59793. /**
  59794. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59795. * Alpha test will not mix with the background color in case of transparency.
  59796. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59797. */
  59798. alphaTest: boolean;
  59799. /**
  59800. * Define a mask to restrict the layer to only some of the scene cameras.
  59801. */
  59802. layerMask: number;
  59803. /**
  59804. * Define the list of render target the layer is visible into.
  59805. */
  59806. renderTargetTextures: RenderTargetTexture[];
  59807. /**
  59808. * Define if the layer is only used in renderTarget or if it also
  59809. * renders in the main frame buffer of the canvas.
  59810. */
  59811. renderOnlyInRenderTargetTextures: boolean;
  59812. private _scene;
  59813. private _vertexBuffers;
  59814. private _indexBuffer;
  59815. private _effect;
  59816. private _previousDefines;
  59817. /**
  59818. * An event triggered when the layer is disposed.
  59819. */
  59820. onDisposeObservable: Observable<Layer>;
  59821. private _onDisposeObserver;
  59822. /**
  59823. * Back compatibility with callback before the onDisposeObservable existed.
  59824. * The set callback will be triggered when the layer has been disposed.
  59825. */
  59826. set onDispose(callback: () => void);
  59827. /**
  59828. * An event triggered before rendering the scene
  59829. */
  59830. onBeforeRenderObservable: Observable<Layer>;
  59831. private _onBeforeRenderObserver;
  59832. /**
  59833. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59834. * The set callback will be triggered just before rendering the layer.
  59835. */
  59836. set onBeforeRender(callback: () => void);
  59837. /**
  59838. * An event triggered after rendering the scene
  59839. */
  59840. onAfterRenderObservable: Observable<Layer>;
  59841. private _onAfterRenderObserver;
  59842. /**
  59843. * Back compatibility with callback before the onAfterRenderObservable existed.
  59844. * The set callback will be triggered just after rendering the layer.
  59845. */
  59846. set onAfterRender(callback: () => void);
  59847. /**
  59848. * Instantiates a new layer.
  59849. * This represents a full screen 2d layer.
  59850. * This can be useful to display a picture in the background of your scene for instance.
  59851. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59852. * @param name Define the name of the layer in the scene
  59853. * @param imgUrl Define the url of the texture to display in the layer
  59854. * @param scene Define the scene the layer belongs to
  59855. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59856. * @param color Defines a color for the layer
  59857. */
  59858. constructor(
  59859. /**
  59860. * Define the name of the layer.
  59861. */
  59862. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59863. private _createIndexBuffer;
  59864. /** @hidden */
  59865. _rebuild(): void;
  59866. /**
  59867. * Renders the layer in the scene.
  59868. */
  59869. render(): void;
  59870. /**
  59871. * Disposes and releases the associated ressources.
  59872. */
  59873. dispose(): void;
  59874. }
  59875. }
  59876. declare module BABYLON {
  59877. /** @hidden */
  59878. export var lensFlarePixelShader: {
  59879. name: string;
  59880. shader: string;
  59881. };
  59882. }
  59883. declare module BABYLON {
  59884. /** @hidden */
  59885. export var lensFlareVertexShader: {
  59886. name: string;
  59887. shader: string;
  59888. };
  59889. }
  59890. declare module BABYLON {
  59891. /**
  59892. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59893. * It is usually composed of several `lensFlare`.
  59894. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59895. */
  59896. export class LensFlareSystem {
  59897. /**
  59898. * Define the name of the lens flare system
  59899. */
  59900. name: string;
  59901. /**
  59902. * List of lens flares used in this system.
  59903. */
  59904. lensFlares: LensFlare[];
  59905. /**
  59906. * Define a limit from the border the lens flare can be visible.
  59907. */
  59908. borderLimit: number;
  59909. /**
  59910. * Define a viewport border we do not want to see the lens flare in.
  59911. */
  59912. viewportBorder: number;
  59913. /**
  59914. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59915. */
  59916. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59917. /**
  59918. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59919. */
  59920. layerMask: number;
  59921. /**
  59922. * Define the id of the lens flare system in the scene.
  59923. * (equal to name by default)
  59924. */
  59925. id: string;
  59926. private _scene;
  59927. private _emitter;
  59928. private _vertexBuffers;
  59929. private _indexBuffer;
  59930. private _effect;
  59931. private _positionX;
  59932. private _positionY;
  59933. private _isEnabled;
  59934. /** @hidden */
  59935. static _SceneComponentInitialization: (scene: Scene) => void;
  59936. /**
  59937. * Instantiates a lens flare system.
  59938. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59939. * It is usually composed of several `lensFlare`.
  59940. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59941. * @param name Define the name of the lens flare system in the scene
  59942. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59943. * @param scene Define the scene the lens flare system belongs to
  59944. */
  59945. constructor(
  59946. /**
  59947. * Define the name of the lens flare system
  59948. */
  59949. name: string, emitter: any, scene: Scene);
  59950. /**
  59951. * Define if the lens flare system is enabled.
  59952. */
  59953. get isEnabled(): boolean;
  59954. set isEnabled(value: boolean);
  59955. /**
  59956. * Get the scene the effects belongs to.
  59957. * @returns the scene holding the lens flare system
  59958. */
  59959. getScene(): Scene;
  59960. /**
  59961. * Get the emitter of the lens flare system.
  59962. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59963. * @returns the emitter of the lens flare system
  59964. */
  59965. getEmitter(): any;
  59966. /**
  59967. * Set the emitter of the lens flare system.
  59968. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59969. * @param newEmitter Define the new emitter of the system
  59970. */
  59971. setEmitter(newEmitter: any): void;
  59972. /**
  59973. * Get the lens flare system emitter position.
  59974. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59975. * @returns the position
  59976. */
  59977. getEmitterPosition(): Vector3;
  59978. /**
  59979. * @hidden
  59980. */
  59981. computeEffectivePosition(globalViewport: Viewport): boolean;
  59982. /** @hidden */
  59983. _isVisible(): boolean;
  59984. /**
  59985. * @hidden
  59986. */
  59987. render(): boolean;
  59988. /**
  59989. * Dispose and release the lens flare with its associated resources.
  59990. */
  59991. dispose(): void;
  59992. /**
  59993. * Parse a lens flare system from a JSON repressentation
  59994. * @param parsedLensFlareSystem Define the JSON to parse
  59995. * @param scene Define the scene the parsed system should be instantiated in
  59996. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59997. * @returns the parsed system
  59998. */
  59999. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60000. /**
  60001. * Serialize the current Lens Flare System into a JSON representation.
  60002. * @returns the serialized JSON
  60003. */
  60004. serialize(): any;
  60005. }
  60006. }
  60007. declare module BABYLON {
  60008. /**
  60009. * This represents one of the lens effect in a `lensFlareSystem`.
  60010. * It controls one of the indiviual texture used in the effect.
  60011. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60012. */
  60013. export class LensFlare {
  60014. /**
  60015. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60016. */
  60017. size: number;
  60018. /**
  60019. * 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.
  60020. */
  60021. position: number;
  60022. /**
  60023. * Define the lens color.
  60024. */
  60025. color: Color3;
  60026. /**
  60027. * Define the lens texture.
  60028. */
  60029. texture: Nullable<Texture>;
  60030. /**
  60031. * Define the alpha mode to render this particular lens.
  60032. */
  60033. alphaMode: number;
  60034. private _system;
  60035. /**
  60036. * Creates a new Lens Flare.
  60037. * This represents one of the lens effect in a `lensFlareSystem`.
  60038. * It controls one of the indiviual texture used in the effect.
  60039. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60040. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60041. * @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.
  60042. * @param color Define the lens color
  60043. * @param imgUrl Define the lens texture url
  60044. * @param system Define the `lensFlareSystem` this flare is part of
  60045. * @returns The newly created Lens Flare
  60046. */
  60047. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60048. /**
  60049. * Instantiates a new Lens Flare.
  60050. * This represents one of the lens effect in a `lensFlareSystem`.
  60051. * It controls one of the indiviual texture used in the effect.
  60052. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60053. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60054. * @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.
  60055. * @param color Define the lens color
  60056. * @param imgUrl Define the lens texture url
  60057. * @param system Define the `lensFlareSystem` this flare is part of
  60058. */
  60059. constructor(
  60060. /**
  60061. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60062. */
  60063. size: number,
  60064. /**
  60065. * 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.
  60066. */
  60067. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60068. /**
  60069. * Dispose and release the lens flare with its associated resources.
  60070. */
  60071. dispose(): void;
  60072. }
  60073. }
  60074. declare module BABYLON {
  60075. interface AbstractScene {
  60076. /**
  60077. * The list of lens flare system added to the scene
  60078. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60079. */
  60080. lensFlareSystems: Array<LensFlareSystem>;
  60081. /**
  60082. * Removes the given lens flare system from this scene.
  60083. * @param toRemove The lens flare system to remove
  60084. * @returns The index of the removed lens flare system
  60085. */
  60086. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60087. /**
  60088. * Adds the given lens flare system to this scene
  60089. * @param newLensFlareSystem The lens flare system to add
  60090. */
  60091. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60092. /**
  60093. * Gets a lens flare system using its name
  60094. * @param name defines the name to look for
  60095. * @returns the lens flare system or null if not found
  60096. */
  60097. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60098. /**
  60099. * Gets a lens flare system using its id
  60100. * @param id defines the id to look for
  60101. * @returns the lens flare system or null if not found
  60102. */
  60103. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60104. }
  60105. /**
  60106. * Defines the lens flare scene component responsible to manage any lens flares
  60107. * in a given scene.
  60108. */
  60109. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60110. /**
  60111. * The component name helpfull to identify the component in the list of scene components.
  60112. */
  60113. readonly name: string;
  60114. /**
  60115. * The scene the component belongs to.
  60116. */
  60117. scene: Scene;
  60118. /**
  60119. * Creates a new instance of the component for the given scene
  60120. * @param scene Defines the scene to register the component in
  60121. */
  60122. constructor(scene: Scene);
  60123. /**
  60124. * Registers the component in a given scene
  60125. */
  60126. register(): void;
  60127. /**
  60128. * Rebuilds the elements related to this component in case of
  60129. * context lost for instance.
  60130. */
  60131. rebuild(): void;
  60132. /**
  60133. * Adds all the elements from the container to the scene
  60134. * @param container the container holding the elements
  60135. */
  60136. addFromContainer(container: AbstractScene): void;
  60137. /**
  60138. * Removes all the elements in the container from the scene
  60139. * @param container contains the elements to remove
  60140. * @param dispose if the removed element should be disposed (default: false)
  60141. */
  60142. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60143. /**
  60144. * Serializes the component data to the specified json object
  60145. * @param serializationObject The object to serialize to
  60146. */
  60147. serialize(serializationObject: any): void;
  60148. /**
  60149. * Disposes the component and the associated ressources.
  60150. */
  60151. dispose(): void;
  60152. private _draw;
  60153. }
  60154. }
  60155. declare module BABYLON {
  60156. /** @hidden */
  60157. export var depthPixelShader: {
  60158. name: string;
  60159. shader: string;
  60160. };
  60161. }
  60162. declare module BABYLON {
  60163. /** @hidden */
  60164. export var depthVertexShader: {
  60165. name: string;
  60166. shader: string;
  60167. };
  60168. }
  60169. declare module BABYLON {
  60170. /**
  60171. * This represents a depth renderer in Babylon.
  60172. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60173. */
  60174. export class DepthRenderer {
  60175. private _scene;
  60176. private _depthMap;
  60177. private _effect;
  60178. private readonly _storeNonLinearDepth;
  60179. private readonly _clearColor;
  60180. /** Get if the depth renderer is using packed depth or not */
  60181. readonly isPacked: boolean;
  60182. private _cachedDefines;
  60183. private _camera;
  60184. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60185. enabled: boolean;
  60186. /**
  60187. * Specifiess that the depth renderer will only be used within
  60188. * the camera it is created for.
  60189. * This can help forcing its rendering during the camera processing.
  60190. */
  60191. useOnlyInActiveCamera: boolean;
  60192. /** @hidden */
  60193. static _SceneComponentInitialization: (scene: Scene) => void;
  60194. /**
  60195. * Instantiates a depth renderer
  60196. * @param scene The scene the renderer belongs to
  60197. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60198. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60199. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60200. */
  60201. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60202. /**
  60203. * Creates the depth rendering effect and checks if the effect is ready.
  60204. * @param subMesh The submesh to be used to render the depth map of
  60205. * @param useInstances If multiple world instances should be used
  60206. * @returns if the depth renderer is ready to render the depth map
  60207. */
  60208. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60209. /**
  60210. * Gets the texture which the depth map will be written to.
  60211. * @returns The depth map texture
  60212. */
  60213. getDepthMap(): RenderTargetTexture;
  60214. /**
  60215. * Disposes of the depth renderer.
  60216. */
  60217. dispose(): void;
  60218. }
  60219. }
  60220. declare module BABYLON {
  60221. /** @hidden */
  60222. export var minmaxReduxPixelShader: {
  60223. name: string;
  60224. shader: string;
  60225. };
  60226. }
  60227. declare module BABYLON {
  60228. /**
  60229. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60230. * and maximum values from all values of the texture.
  60231. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60232. * The source values are read from the red channel of the texture.
  60233. */
  60234. export class MinMaxReducer {
  60235. /**
  60236. * Observable triggered when the computation has been performed
  60237. */
  60238. onAfterReductionPerformed: Observable<{
  60239. min: number;
  60240. max: number;
  60241. }>;
  60242. protected _camera: Camera;
  60243. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60244. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60245. protected _postProcessManager: PostProcessManager;
  60246. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60247. protected _forceFullscreenViewport: boolean;
  60248. /**
  60249. * Creates a min/max reducer
  60250. * @param camera The camera to use for the post processes
  60251. */
  60252. constructor(camera: Camera);
  60253. /**
  60254. * Gets the texture used to read the values from.
  60255. */
  60256. get sourceTexture(): Nullable<RenderTargetTexture>;
  60257. /**
  60258. * Sets the source texture to read the values from.
  60259. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60260. * because in such textures '1' value must not be taken into account to compute the maximum
  60261. * as this value is used to clear the texture.
  60262. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60263. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60264. * @param depthRedux Indicates if the texture is a depth texture or not
  60265. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60266. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60267. */
  60268. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60269. /**
  60270. * Defines the refresh rate of the computation.
  60271. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60272. */
  60273. get refreshRate(): number;
  60274. set refreshRate(value: number);
  60275. protected _activated: boolean;
  60276. /**
  60277. * Gets the activation status of the reducer
  60278. */
  60279. get activated(): boolean;
  60280. /**
  60281. * Activates the reduction computation.
  60282. * When activated, the observers registered in onAfterReductionPerformed are
  60283. * called after the compuation is performed
  60284. */
  60285. activate(): void;
  60286. /**
  60287. * Deactivates the reduction computation.
  60288. */
  60289. deactivate(): void;
  60290. /**
  60291. * Disposes the min/max reducer
  60292. * @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.
  60293. */
  60294. dispose(disposeAll?: boolean): void;
  60295. }
  60296. }
  60297. declare module BABYLON {
  60298. /**
  60299. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60300. */
  60301. export class DepthReducer extends MinMaxReducer {
  60302. private _depthRenderer;
  60303. private _depthRendererId;
  60304. /**
  60305. * Gets the depth renderer used for the computation.
  60306. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60307. */
  60308. get depthRenderer(): Nullable<DepthRenderer>;
  60309. /**
  60310. * Creates a depth reducer
  60311. * @param camera The camera used to render the depth texture
  60312. */
  60313. constructor(camera: Camera);
  60314. /**
  60315. * Sets the depth renderer to use to generate the depth map
  60316. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60317. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60318. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60319. */
  60320. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60321. /** @hidden */
  60322. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60323. /**
  60324. * Activates the reduction computation.
  60325. * When activated, the observers registered in onAfterReductionPerformed are
  60326. * called after the compuation is performed
  60327. */
  60328. activate(): void;
  60329. /**
  60330. * Deactivates the reduction computation.
  60331. */
  60332. deactivate(): void;
  60333. /**
  60334. * Disposes the depth reducer
  60335. * @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.
  60336. */
  60337. dispose(disposeAll?: boolean): void;
  60338. }
  60339. }
  60340. declare module BABYLON {
  60341. /**
  60342. * A CSM implementation allowing casting shadows on large scenes.
  60343. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60344. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60345. */
  60346. export class CascadedShadowGenerator extends ShadowGenerator {
  60347. private static readonly frustumCornersNDCSpace;
  60348. /**
  60349. * Name of the CSM class
  60350. */
  60351. static CLASSNAME: string;
  60352. /**
  60353. * Defines the default number of cascades used by the CSM.
  60354. */
  60355. static readonly DEFAULT_CASCADES_COUNT: number;
  60356. /**
  60357. * Defines the minimum number of cascades used by the CSM.
  60358. */
  60359. static readonly MIN_CASCADES_COUNT: number;
  60360. /**
  60361. * Defines the maximum number of cascades used by the CSM.
  60362. */
  60363. static readonly MAX_CASCADES_COUNT: number;
  60364. protected _validateFilter(filter: number): number;
  60365. /**
  60366. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60367. */
  60368. penumbraDarkness: number;
  60369. private _numCascades;
  60370. /**
  60371. * Gets or set the number of cascades used by the CSM.
  60372. */
  60373. get numCascades(): number;
  60374. set numCascades(value: number);
  60375. /**
  60376. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60377. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60378. */
  60379. stabilizeCascades: boolean;
  60380. private _freezeShadowCastersBoundingInfo;
  60381. private _freezeShadowCastersBoundingInfoObservable;
  60382. /**
  60383. * Enables or disables the shadow casters bounding info computation.
  60384. * If your shadow casters don't move, you can disable this feature.
  60385. * If it is enabled, the bounding box computation is done every frame.
  60386. */
  60387. get freezeShadowCastersBoundingInfo(): boolean;
  60388. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60389. private _scbiMin;
  60390. private _scbiMax;
  60391. protected _computeShadowCastersBoundingInfo(): void;
  60392. protected _shadowCastersBoundingInfo: BoundingInfo;
  60393. /**
  60394. * Gets or sets the shadow casters bounding info.
  60395. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60396. * so that the system won't overwrite the bounds you provide
  60397. */
  60398. get shadowCastersBoundingInfo(): BoundingInfo;
  60399. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60400. protected _breaksAreDirty: boolean;
  60401. protected _minDistance: number;
  60402. protected _maxDistance: number;
  60403. /**
  60404. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60405. *
  60406. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60407. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60408. * @param min minimal distance for the breaks (default to 0.)
  60409. * @param max maximal distance for the breaks (default to 1.)
  60410. */
  60411. setMinMaxDistance(min: number, max: number): void;
  60412. /** Gets the minimal distance used in the cascade break computation */
  60413. get minDistance(): number;
  60414. /** Gets the maximal distance used in the cascade break computation */
  60415. get maxDistance(): number;
  60416. /**
  60417. * Gets the class name of that object
  60418. * @returns "CascadedShadowGenerator"
  60419. */
  60420. getClassName(): string;
  60421. private _cascadeMinExtents;
  60422. private _cascadeMaxExtents;
  60423. /**
  60424. * Gets a cascade minimum extents
  60425. * @param cascadeIndex index of the cascade
  60426. * @returns the minimum cascade extents
  60427. */
  60428. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60429. /**
  60430. * Gets a cascade maximum extents
  60431. * @param cascadeIndex index of the cascade
  60432. * @returns the maximum cascade extents
  60433. */
  60434. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60435. private _cascades;
  60436. private _currentLayer;
  60437. private _viewSpaceFrustumsZ;
  60438. private _viewMatrices;
  60439. private _projectionMatrices;
  60440. private _transformMatrices;
  60441. private _transformMatricesAsArray;
  60442. private _frustumLengths;
  60443. private _lightSizeUVCorrection;
  60444. private _depthCorrection;
  60445. private _frustumCornersWorldSpace;
  60446. private _frustumCenter;
  60447. private _shadowCameraPos;
  60448. private _shadowMaxZ;
  60449. /**
  60450. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60451. * It defaults to camera.maxZ
  60452. */
  60453. get shadowMaxZ(): number;
  60454. /**
  60455. * Sets the shadow max z distance.
  60456. */
  60457. set shadowMaxZ(value: number);
  60458. protected _debug: boolean;
  60459. /**
  60460. * Gets or sets the debug flag.
  60461. * When enabled, the cascades are materialized by different colors on the screen.
  60462. */
  60463. get debug(): boolean;
  60464. set debug(dbg: boolean);
  60465. private _depthClamp;
  60466. /**
  60467. * Gets or sets the depth clamping value.
  60468. *
  60469. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60470. * to account for the shadow casters far away.
  60471. *
  60472. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60473. */
  60474. get depthClamp(): boolean;
  60475. set depthClamp(value: boolean);
  60476. private _cascadeBlendPercentage;
  60477. /**
  60478. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60479. * It defaults to 0.1 (10% blending).
  60480. */
  60481. get cascadeBlendPercentage(): number;
  60482. set cascadeBlendPercentage(value: number);
  60483. private _lambda;
  60484. /**
  60485. * Gets or set the lambda parameter.
  60486. * This parameter is used to split the camera frustum and create the cascades.
  60487. * 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.
  60488. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60489. */
  60490. get lambda(): number;
  60491. set lambda(value: number);
  60492. /**
  60493. * Gets the view matrix corresponding to a given cascade
  60494. * @param cascadeNum cascade to retrieve the view matrix from
  60495. * @returns the cascade view matrix
  60496. */
  60497. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60498. /**
  60499. * Gets the projection matrix corresponding to a given cascade
  60500. * @param cascadeNum cascade to retrieve the projection matrix from
  60501. * @returns the cascade projection matrix
  60502. */
  60503. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60504. /**
  60505. * Gets the transformation matrix corresponding to a given cascade
  60506. * @param cascadeNum cascade to retrieve the transformation matrix from
  60507. * @returns the cascade transformation matrix
  60508. */
  60509. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60510. private _depthRenderer;
  60511. /**
  60512. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60513. *
  60514. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60515. *
  60516. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60517. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60518. * @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
  60519. */
  60520. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60521. private _depthReducer;
  60522. private _autoCalcDepthBounds;
  60523. /**
  60524. * Gets or sets the autoCalcDepthBounds property.
  60525. *
  60526. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60527. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60528. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60529. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60530. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60531. */
  60532. get autoCalcDepthBounds(): boolean;
  60533. set autoCalcDepthBounds(value: boolean);
  60534. /**
  60535. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60536. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60537. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60538. * for setting the refresh rate on the renderer yourself!
  60539. */
  60540. get autoCalcDepthBoundsRefreshRate(): number;
  60541. set autoCalcDepthBoundsRefreshRate(value: number);
  60542. /**
  60543. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60544. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60545. * you change the camera near/far planes!
  60546. */
  60547. splitFrustum(): void;
  60548. private _splitFrustum;
  60549. private _computeMatrices;
  60550. private _computeFrustumInWorldSpace;
  60551. private _computeCascadeFrustum;
  60552. /**
  60553. * Support test.
  60554. */
  60555. static get IsSupported(): boolean;
  60556. /** @hidden */
  60557. static _SceneComponentInitialization: (scene: Scene) => void;
  60558. /**
  60559. * Creates a Cascaded Shadow Generator object.
  60560. * A ShadowGenerator is the required tool to use the shadows.
  60561. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60562. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60563. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60564. * @param light The directional light object generating the shadows.
  60565. * @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.
  60566. */
  60567. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60568. protected _initializeGenerator(): void;
  60569. protected _createTargetRenderTexture(): void;
  60570. protected _initializeShadowMap(): void;
  60571. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60572. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60573. /**
  60574. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60575. * @param defines Defines of the material we want to update
  60576. * @param lightIndex Index of the light in the enabled light list of the material
  60577. */
  60578. prepareDefines(defines: any, lightIndex: number): void;
  60579. /**
  60580. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60581. * defined in the generator but impacting the effect).
  60582. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60583. * @param effect The effect we are binfing the information for
  60584. */
  60585. bindShadowLight(lightIndex: string, effect: Effect): void;
  60586. /**
  60587. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60588. * (eq to view projection * shadow projection matrices)
  60589. * @returns The transform matrix used to create the shadow map
  60590. */
  60591. getTransformMatrix(): Matrix;
  60592. /**
  60593. * Disposes the ShadowGenerator.
  60594. * Returns nothing.
  60595. */
  60596. dispose(): void;
  60597. /**
  60598. * Serializes the shadow generator setup to a json object.
  60599. * @returns The serialized JSON object
  60600. */
  60601. serialize(): any;
  60602. /**
  60603. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60604. * @param parsedShadowGenerator The JSON object to parse
  60605. * @param scene The scene to create the shadow map for
  60606. * @returns The parsed shadow generator
  60607. */
  60608. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60609. }
  60610. }
  60611. declare module BABYLON {
  60612. /**
  60613. * Defines the shadow generator component responsible to manage any shadow generators
  60614. * in a given scene.
  60615. */
  60616. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60617. /**
  60618. * The component name helpfull to identify the component in the list of scene components.
  60619. */
  60620. readonly name: string;
  60621. /**
  60622. * The scene the component belongs to.
  60623. */
  60624. scene: Scene;
  60625. /**
  60626. * Creates a new instance of the component for the given scene
  60627. * @param scene Defines the scene to register the component in
  60628. */
  60629. constructor(scene: Scene);
  60630. /**
  60631. * Registers the component in a given scene
  60632. */
  60633. register(): void;
  60634. /**
  60635. * Rebuilds the elements related to this component in case of
  60636. * context lost for instance.
  60637. */
  60638. rebuild(): void;
  60639. /**
  60640. * Serializes the component data to the specified json object
  60641. * @param serializationObject The object to serialize to
  60642. */
  60643. serialize(serializationObject: any): void;
  60644. /**
  60645. * Adds all the elements from the container to the scene
  60646. * @param container the container holding the elements
  60647. */
  60648. addFromContainer(container: AbstractScene): void;
  60649. /**
  60650. * Removes all the elements in the container from the scene
  60651. * @param container contains the elements to remove
  60652. * @param dispose if the removed element should be disposed (default: false)
  60653. */
  60654. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60655. /**
  60656. * Rebuilds the elements related to this component in case of
  60657. * context lost for instance.
  60658. */
  60659. dispose(): void;
  60660. private _gatherRenderTargets;
  60661. }
  60662. }
  60663. declare module BABYLON {
  60664. /**
  60665. * A point light is a light defined by an unique point in world space.
  60666. * The light is emitted in every direction from this point.
  60667. * A good example of a point light is a standard light bulb.
  60668. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60669. */
  60670. export class PointLight extends ShadowLight {
  60671. private _shadowAngle;
  60672. /**
  60673. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60674. * This specifies what angle the shadow will use to be created.
  60675. *
  60676. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60677. */
  60678. get shadowAngle(): number;
  60679. /**
  60680. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60681. * This specifies what angle the shadow will use to be created.
  60682. *
  60683. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60684. */
  60685. set shadowAngle(value: number);
  60686. /**
  60687. * Gets the direction if it has been set.
  60688. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60689. */
  60690. get direction(): Vector3;
  60691. /**
  60692. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60693. */
  60694. set direction(value: Vector3);
  60695. /**
  60696. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60697. * A PointLight emits the light in every direction.
  60698. * It can cast shadows.
  60699. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60700. * ```javascript
  60701. * var pointLight = new PointLight("pl", camera.position, scene);
  60702. * ```
  60703. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60704. * @param name The light friendly name
  60705. * @param position The position of the point light in the scene
  60706. * @param scene The scene the lights belongs to
  60707. */
  60708. constructor(name: string, position: Vector3, scene: Scene);
  60709. /**
  60710. * Returns the string "PointLight"
  60711. * @returns the class name
  60712. */
  60713. getClassName(): string;
  60714. /**
  60715. * Returns the integer 0.
  60716. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60717. */
  60718. getTypeID(): number;
  60719. /**
  60720. * Specifies wether or not the shadowmap should be a cube texture.
  60721. * @returns true if the shadowmap needs to be a cube texture.
  60722. */
  60723. needCube(): boolean;
  60724. /**
  60725. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60726. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60727. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60728. */
  60729. getShadowDirection(faceIndex?: number): Vector3;
  60730. /**
  60731. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60732. * - fov = PI / 2
  60733. * - aspect ratio : 1.0
  60734. * - z-near and far equal to the active camera minZ and maxZ.
  60735. * Returns the PointLight.
  60736. */
  60737. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60738. protected _buildUniformLayout(): void;
  60739. /**
  60740. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60741. * @param effect The effect to update
  60742. * @param lightIndex The index of the light in the effect to update
  60743. * @returns The point light
  60744. */
  60745. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60746. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60747. /**
  60748. * Prepares the list of defines specific to the light type.
  60749. * @param defines the list of defines
  60750. * @param lightIndex defines the index of the light for the effect
  60751. */
  60752. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60753. }
  60754. }
  60755. declare module BABYLON {
  60756. /**
  60757. * Header information of HDR texture files.
  60758. */
  60759. export interface HDRInfo {
  60760. /**
  60761. * The height of the texture in pixels.
  60762. */
  60763. height: number;
  60764. /**
  60765. * The width of the texture in pixels.
  60766. */
  60767. width: number;
  60768. /**
  60769. * The index of the beginning of the data in the binary file.
  60770. */
  60771. dataPosition: number;
  60772. }
  60773. /**
  60774. * This groups tools to convert HDR texture to native colors array.
  60775. */
  60776. export class HDRTools {
  60777. private static Ldexp;
  60778. private static Rgbe2float;
  60779. private static readStringLine;
  60780. /**
  60781. * Reads header information from an RGBE texture stored in a native array.
  60782. * More information on this format are available here:
  60783. * https://en.wikipedia.org/wiki/RGBE_image_format
  60784. *
  60785. * @param uint8array The binary file stored in native array.
  60786. * @return The header information.
  60787. */
  60788. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60789. /**
  60790. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60791. * This RGBE texture needs to store the information as a panorama.
  60792. *
  60793. * More information on this format are available here:
  60794. * https://en.wikipedia.org/wiki/RGBE_image_format
  60795. *
  60796. * @param buffer The binary file stored in an array buffer.
  60797. * @param size The expected size of the extracted cubemap.
  60798. * @return The Cube Map information.
  60799. */
  60800. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60801. /**
  60802. * Returns the pixels data extracted from an RGBE texture.
  60803. * This pixels will be stored left to right up to down in the R G B order in one array.
  60804. *
  60805. * More information on this format are available here:
  60806. * https://en.wikipedia.org/wiki/RGBE_image_format
  60807. *
  60808. * @param uint8array The binary file stored in an array buffer.
  60809. * @param hdrInfo The header information of the file.
  60810. * @return The pixels data in RGB right to left up to down order.
  60811. */
  60812. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60813. private static RGBE_ReadPixels_RLE;
  60814. private static RGBE_ReadPixels_NOT_RLE;
  60815. }
  60816. }
  60817. declare module BABYLON {
  60818. /**
  60819. * Effect Render Options
  60820. */
  60821. export interface IEffectRendererOptions {
  60822. /**
  60823. * Defines the vertices positions.
  60824. */
  60825. positions?: number[];
  60826. /**
  60827. * Defines the indices.
  60828. */
  60829. indices?: number[];
  60830. }
  60831. /**
  60832. * Helper class to render one or more effects.
  60833. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60834. */
  60835. export class EffectRenderer {
  60836. private engine;
  60837. private static _DefaultOptions;
  60838. private _vertexBuffers;
  60839. private _indexBuffer;
  60840. private _fullscreenViewport;
  60841. /**
  60842. * Creates an effect renderer
  60843. * @param engine the engine to use for rendering
  60844. * @param options defines the options of the effect renderer
  60845. */
  60846. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60847. /**
  60848. * Sets the current viewport in normalized coordinates 0-1
  60849. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60850. */
  60851. setViewport(viewport?: Viewport): void;
  60852. /**
  60853. * Binds the embedded attributes buffer to the effect.
  60854. * @param effect Defines the effect to bind the attributes for
  60855. */
  60856. bindBuffers(effect: Effect): void;
  60857. /**
  60858. * Sets the current effect wrapper to use during draw.
  60859. * The effect needs to be ready before calling this api.
  60860. * This also sets the default full screen position attribute.
  60861. * @param effectWrapper Defines the effect to draw with
  60862. */
  60863. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60864. /**
  60865. * Restores engine states
  60866. */
  60867. restoreStates(): void;
  60868. /**
  60869. * Draws a full screen quad.
  60870. */
  60871. draw(): void;
  60872. private isRenderTargetTexture;
  60873. /**
  60874. * renders one or more effects to a specified texture
  60875. * @param effectWrapper the effect to renderer
  60876. * @param outputTexture texture to draw to, if null it will render to the screen.
  60877. */
  60878. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60879. /**
  60880. * Disposes of the effect renderer
  60881. */
  60882. dispose(): void;
  60883. }
  60884. /**
  60885. * Options to create an EffectWrapper
  60886. */
  60887. interface EffectWrapperCreationOptions {
  60888. /**
  60889. * Engine to use to create the effect
  60890. */
  60891. engine: ThinEngine;
  60892. /**
  60893. * Fragment shader for the effect
  60894. */
  60895. fragmentShader: string;
  60896. /**
  60897. * Use the shader store instead of direct source code
  60898. */
  60899. useShaderStore?: boolean;
  60900. /**
  60901. * Vertex shader for the effect
  60902. */
  60903. vertexShader?: string;
  60904. /**
  60905. * Attributes to use in the shader
  60906. */
  60907. attributeNames?: Array<string>;
  60908. /**
  60909. * Uniforms to use in the shader
  60910. */
  60911. uniformNames?: Array<string>;
  60912. /**
  60913. * Texture sampler names to use in the shader
  60914. */
  60915. samplerNames?: Array<string>;
  60916. /**
  60917. * Defines to use in the shader
  60918. */
  60919. defines?: Array<string>;
  60920. /**
  60921. * Callback when effect is compiled
  60922. */
  60923. onCompiled?: Nullable<(effect: Effect) => void>;
  60924. /**
  60925. * The friendly name of the effect displayed in Spector.
  60926. */
  60927. name?: string;
  60928. }
  60929. /**
  60930. * Wraps an effect to be used for rendering
  60931. */
  60932. export class EffectWrapper {
  60933. /**
  60934. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60935. */
  60936. onApplyObservable: Observable<{}>;
  60937. /**
  60938. * The underlying effect
  60939. */
  60940. effect: Effect;
  60941. /**
  60942. * Creates an effect to be renderer
  60943. * @param creationOptions options to create the effect
  60944. */
  60945. constructor(creationOptions: EffectWrapperCreationOptions);
  60946. /**
  60947. * Disposes of the effect wrapper
  60948. */
  60949. dispose(): void;
  60950. }
  60951. }
  60952. declare module BABYLON {
  60953. /** @hidden */
  60954. export var hdrFilteringVertexShader: {
  60955. name: string;
  60956. shader: string;
  60957. };
  60958. }
  60959. declare module BABYLON {
  60960. /** @hidden */
  60961. export var hdrFilteringPixelShader: {
  60962. name: string;
  60963. shader: string;
  60964. };
  60965. }
  60966. declare module BABYLON {
  60967. /**
  60968. * Options for texture filtering
  60969. */
  60970. interface IHDRFilteringOptions {
  60971. /**
  60972. * Scales pixel intensity for the input HDR map.
  60973. */
  60974. hdrScale?: number;
  60975. /**
  60976. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60977. */
  60978. quality?: number;
  60979. }
  60980. /**
  60981. * Filters HDR maps to get correct renderings of PBR reflections
  60982. */
  60983. export class HDRFiltering {
  60984. private _engine;
  60985. private _effectRenderer;
  60986. private _effectWrapper;
  60987. private _lodGenerationOffset;
  60988. private _lodGenerationScale;
  60989. /**
  60990. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60991. * you care about baking speed.
  60992. */
  60993. quality: number;
  60994. /**
  60995. * Scales pixel intensity for the input HDR map.
  60996. */
  60997. hdrScale: number;
  60998. /**
  60999. * Instantiates HDR filter for reflection maps
  61000. *
  61001. * @param engine Thin engine
  61002. * @param options Options
  61003. */
  61004. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61005. private _createRenderTarget;
  61006. private _prefilterInternal;
  61007. private _createEffect;
  61008. /**
  61009. * Get a value indicating if the filter is ready to be used
  61010. * @param texture Texture to filter
  61011. * @returns true if the filter is ready
  61012. */
  61013. isReady(texture: BaseTexture): boolean;
  61014. /**
  61015. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61016. * Prefiltering will be invoked at the end of next rendering pass.
  61017. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61018. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61019. * @param texture Texture to filter
  61020. * @param onFinished Callback when filtering is done
  61021. * @return Promise called when prefiltering is done
  61022. */
  61023. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61024. }
  61025. }
  61026. declare module BABYLON {
  61027. /**
  61028. * This represents a texture coming from an HDR input.
  61029. *
  61030. * The only supported format is currently panorama picture stored in RGBE format.
  61031. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61032. */
  61033. export class HDRCubeTexture extends BaseTexture {
  61034. private static _facesMapping;
  61035. private _generateHarmonics;
  61036. private _noMipmap;
  61037. private _prefilterOnLoad;
  61038. private _textureMatrix;
  61039. private _size;
  61040. private _onLoad;
  61041. private _onError;
  61042. /**
  61043. * The texture URL.
  61044. */
  61045. url: string;
  61046. protected _isBlocking: boolean;
  61047. /**
  61048. * Sets wether or not the texture is blocking during loading.
  61049. */
  61050. set isBlocking(value: boolean);
  61051. /**
  61052. * Gets wether or not the texture is blocking during loading.
  61053. */
  61054. get isBlocking(): boolean;
  61055. protected _rotationY: number;
  61056. /**
  61057. * Sets texture matrix rotation angle around Y axis in radians.
  61058. */
  61059. set rotationY(value: number);
  61060. /**
  61061. * Gets texture matrix rotation angle around Y axis radians.
  61062. */
  61063. get rotationY(): number;
  61064. /**
  61065. * Gets or sets the center of the bounding box associated with the cube texture
  61066. * It must define where the camera used to render the texture was set
  61067. */
  61068. boundingBoxPosition: Vector3;
  61069. private _boundingBoxSize;
  61070. /**
  61071. * Gets or sets the size of the bounding box associated with the cube texture
  61072. * When defined, the cubemap will switch to local mode
  61073. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61074. * @example https://www.babylonjs-playground.com/#RNASML
  61075. */
  61076. set boundingBoxSize(value: Vector3);
  61077. get boundingBoxSize(): Vector3;
  61078. /**
  61079. * Instantiates an HDRTexture from the following parameters.
  61080. *
  61081. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61082. * @param sceneOrEngine The scene or engine the texture will be used in
  61083. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61084. * @param noMipmap Forces to not generate the mipmap if true
  61085. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61086. * @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)
  61087. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61088. */
  61089. 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>);
  61090. /**
  61091. * Get the current class name of the texture useful for serialization or dynamic coding.
  61092. * @returns "HDRCubeTexture"
  61093. */
  61094. getClassName(): string;
  61095. /**
  61096. * Occurs when the file is raw .hdr file.
  61097. */
  61098. private loadTexture;
  61099. clone(): HDRCubeTexture;
  61100. delayLoad(): void;
  61101. /**
  61102. * Get the texture reflection matrix used to rotate/transform the reflection.
  61103. * @returns the reflection matrix
  61104. */
  61105. getReflectionTextureMatrix(): Matrix;
  61106. /**
  61107. * Set the texture reflection matrix used to rotate/transform the reflection.
  61108. * @param value Define the reflection matrix to set
  61109. */
  61110. setReflectionTextureMatrix(value: Matrix): void;
  61111. /**
  61112. * Parses a JSON representation of an HDR Texture in order to create the texture
  61113. * @param parsedTexture Define the JSON representation
  61114. * @param scene Define the scene the texture should be created in
  61115. * @param rootUrl Define the root url in case we need to load relative dependencies
  61116. * @returns the newly created texture after parsing
  61117. */
  61118. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61119. serialize(): any;
  61120. }
  61121. }
  61122. declare module BABYLON {
  61123. /**
  61124. * Class used to control physics engine
  61125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61126. */
  61127. export class PhysicsEngine implements IPhysicsEngine {
  61128. private _physicsPlugin;
  61129. /**
  61130. * Global value used to control the smallest number supported by the simulation
  61131. */
  61132. static Epsilon: number;
  61133. private _impostors;
  61134. private _joints;
  61135. private _subTimeStep;
  61136. /**
  61137. * Gets the gravity vector used by the simulation
  61138. */
  61139. gravity: Vector3;
  61140. /**
  61141. * Factory used to create the default physics plugin.
  61142. * @returns The default physics plugin
  61143. */
  61144. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61145. /**
  61146. * Creates a new Physics Engine
  61147. * @param gravity defines the gravity vector used by the simulation
  61148. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61149. */
  61150. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61151. /**
  61152. * Sets the gravity vector used by the simulation
  61153. * @param gravity defines the gravity vector to use
  61154. */
  61155. setGravity(gravity: Vector3): void;
  61156. /**
  61157. * Set the time step of the physics engine.
  61158. * Default is 1/60.
  61159. * To slow it down, enter 1/600 for example.
  61160. * To speed it up, 1/30
  61161. * @param newTimeStep defines the new timestep to apply to this world.
  61162. */
  61163. setTimeStep(newTimeStep?: number): void;
  61164. /**
  61165. * Get the time step of the physics engine.
  61166. * @returns the current time step
  61167. */
  61168. getTimeStep(): number;
  61169. /**
  61170. * Set the sub time step of the physics engine.
  61171. * Default is 0 meaning there is no sub steps
  61172. * To increase physics resolution precision, set a small value (like 1 ms)
  61173. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61174. */
  61175. setSubTimeStep(subTimeStep?: number): void;
  61176. /**
  61177. * Get the sub time step of the physics engine.
  61178. * @returns the current sub time step
  61179. */
  61180. getSubTimeStep(): number;
  61181. /**
  61182. * Release all resources
  61183. */
  61184. dispose(): void;
  61185. /**
  61186. * Gets the name of the current physics plugin
  61187. * @returns the name of the plugin
  61188. */
  61189. getPhysicsPluginName(): string;
  61190. /**
  61191. * Adding a new impostor for the impostor tracking.
  61192. * This will be done by the impostor itself.
  61193. * @param impostor the impostor to add
  61194. */
  61195. addImpostor(impostor: PhysicsImpostor): void;
  61196. /**
  61197. * Remove an impostor from the engine.
  61198. * This impostor and its mesh will not longer be updated by the physics engine.
  61199. * @param impostor the impostor to remove
  61200. */
  61201. removeImpostor(impostor: PhysicsImpostor): void;
  61202. /**
  61203. * Add a joint to the physics engine
  61204. * @param mainImpostor defines the main impostor to which the joint is added.
  61205. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61206. * @param joint defines the joint that will connect both impostors.
  61207. */
  61208. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61209. /**
  61210. * Removes a joint from the simulation
  61211. * @param mainImpostor defines the impostor used with the joint
  61212. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61213. * @param joint defines the joint to remove
  61214. */
  61215. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61216. /**
  61217. * Called by the scene. No need to call it.
  61218. * @param delta defines the timespam between frames
  61219. */
  61220. _step(delta: number): void;
  61221. /**
  61222. * Gets the current plugin used to run the simulation
  61223. * @returns current plugin
  61224. */
  61225. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61226. /**
  61227. * Gets the list of physic impostors
  61228. * @returns an array of PhysicsImpostor
  61229. */
  61230. getImpostors(): Array<PhysicsImpostor>;
  61231. /**
  61232. * Gets the impostor for a physics enabled object
  61233. * @param object defines the object impersonated by the impostor
  61234. * @returns the PhysicsImpostor or null if not found
  61235. */
  61236. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61237. /**
  61238. * Gets the impostor for a physics body object
  61239. * @param body defines physics body used by the impostor
  61240. * @returns the PhysicsImpostor or null if not found
  61241. */
  61242. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61243. /**
  61244. * Does a raycast in the physics world
  61245. * @param from when should the ray start?
  61246. * @param to when should the ray end?
  61247. * @returns PhysicsRaycastResult
  61248. */
  61249. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61250. }
  61251. }
  61252. declare module BABYLON {
  61253. /** @hidden */
  61254. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61255. private _useDeltaForWorldStep;
  61256. world: any;
  61257. name: string;
  61258. private _physicsMaterials;
  61259. private _fixedTimeStep;
  61260. private _cannonRaycastResult;
  61261. private _raycastResult;
  61262. private _physicsBodysToRemoveAfterStep;
  61263. private _firstFrame;
  61264. BJSCANNON: any;
  61265. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61266. setGravity(gravity: Vector3): void;
  61267. setTimeStep(timeStep: number): void;
  61268. getTimeStep(): number;
  61269. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61270. private _removeMarkedPhysicsBodiesFromWorld;
  61271. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61272. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61273. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61274. private _processChildMeshes;
  61275. removePhysicsBody(impostor: PhysicsImpostor): void;
  61276. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61277. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61278. private _addMaterial;
  61279. private _checkWithEpsilon;
  61280. private _createShape;
  61281. private _createHeightmap;
  61282. private _minus90X;
  61283. private _plus90X;
  61284. private _tmpPosition;
  61285. private _tmpDeltaPosition;
  61286. private _tmpUnityRotation;
  61287. private _updatePhysicsBodyTransformation;
  61288. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61289. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61290. isSupported(): boolean;
  61291. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61292. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61293. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61294. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61295. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61296. getBodyMass(impostor: PhysicsImpostor): number;
  61297. getBodyFriction(impostor: PhysicsImpostor): number;
  61298. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61299. getBodyRestitution(impostor: PhysicsImpostor): number;
  61300. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61301. sleepBody(impostor: PhysicsImpostor): void;
  61302. wakeUpBody(impostor: PhysicsImpostor): void;
  61303. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61304. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61305. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61306. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61307. getRadius(impostor: PhysicsImpostor): number;
  61308. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61309. dispose(): void;
  61310. private _extendNamespace;
  61311. /**
  61312. * Does a raycast in the physics world
  61313. * @param from when should the ray start?
  61314. * @param to when should the ray end?
  61315. * @returns PhysicsRaycastResult
  61316. */
  61317. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61318. }
  61319. }
  61320. declare module BABYLON {
  61321. /** @hidden */
  61322. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61323. private _useDeltaForWorldStep;
  61324. world: any;
  61325. name: string;
  61326. BJSOIMO: any;
  61327. private _raycastResult;
  61328. private _fixedTimeStep;
  61329. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61330. setGravity(gravity: Vector3): void;
  61331. setTimeStep(timeStep: number): void;
  61332. getTimeStep(): number;
  61333. private _tmpImpostorsArray;
  61334. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61335. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61336. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61337. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61338. private _tmpPositionVector;
  61339. removePhysicsBody(impostor: PhysicsImpostor): void;
  61340. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61341. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61342. isSupported(): boolean;
  61343. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61344. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61345. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61346. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61347. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61348. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61349. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61350. getBodyMass(impostor: PhysicsImpostor): number;
  61351. getBodyFriction(impostor: PhysicsImpostor): number;
  61352. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61353. getBodyRestitution(impostor: PhysicsImpostor): number;
  61354. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61355. sleepBody(impostor: PhysicsImpostor): void;
  61356. wakeUpBody(impostor: PhysicsImpostor): void;
  61357. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61358. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61359. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61360. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61361. getRadius(impostor: PhysicsImpostor): number;
  61362. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61363. dispose(): void;
  61364. /**
  61365. * Does a raycast in the physics world
  61366. * @param from when should the ray start?
  61367. * @param to when should the ray end?
  61368. * @returns PhysicsRaycastResult
  61369. */
  61370. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61371. }
  61372. }
  61373. declare module BABYLON {
  61374. /**
  61375. * AmmoJS Physics plugin
  61376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61377. * @see https://github.com/kripken/ammo.js/
  61378. */
  61379. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61380. private _useDeltaForWorldStep;
  61381. /**
  61382. * Reference to the Ammo library
  61383. */
  61384. bjsAMMO: any;
  61385. /**
  61386. * Created ammoJS world which physics bodies are added to
  61387. */
  61388. world: any;
  61389. /**
  61390. * Name of the plugin
  61391. */
  61392. name: string;
  61393. private _timeStep;
  61394. private _fixedTimeStep;
  61395. private _maxSteps;
  61396. private _tmpQuaternion;
  61397. private _tmpAmmoTransform;
  61398. private _tmpAmmoQuaternion;
  61399. private _tmpAmmoConcreteContactResultCallback;
  61400. private _collisionConfiguration;
  61401. private _dispatcher;
  61402. private _overlappingPairCache;
  61403. private _solver;
  61404. private _softBodySolver;
  61405. private _tmpAmmoVectorA;
  61406. private _tmpAmmoVectorB;
  61407. private _tmpAmmoVectorC;
  61408. private _tmpAmmoVectorD;
  61409. private _tmpContactCallbackResult;
  61410. private _tmpAmmoVectorRCA;
  61411. private _tmpAmmoVectorRCB;
  61412. private _raycastResult;
  61413. private static readonly DISABLE_COLLISION_FLAG;
  61414. private static readonly KINEMATIC_FLAG;
  61415. private static readonly DISABLE_DEACTIVATION_FLAG;
  61416. /**
  61417. * Initializes the ammoJS plugin
  61418. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61419. * @param ammoInjection can be used to inject your own ammo reference
  61420. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61421. */
  61422. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61423. /**
  61424. * Sets the gravity of the physics world (m/(s^2))
  61425. * @param gravity Gravity to set
  61426. */
  61427. setGravity(gravity: Vector3): void;
  61428. /**
  61429. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61430. * @param timeStep timestep to use in seconds
  61431. */
  61432. setTimeStep(timeStep: number): void;
  61433. /**
  61434. * 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)
  61435. * @param fixedTimeStep fixedTimeStep to use in seconds
  61436. */
  61437. setFixedTimeStep(fixedTimeStep: number): void;
  61438. /**
  61439. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61440. * @param maxSteps the maximum number of steps by the physics engine per frame
  61441. */
  61442. setMaxSteps(maxSteps: number): void;
  61443. /**
  61444. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61445. * @returns the current timestep in seconds
  61446. */
  61447. getTimeStep(): number;
  61448. /**
  61449. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61450. */
  61451. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61452. private _isImpostorInContact;
  61453. private _isImpostorPairInContact;
  61454. private _stepSimulation;
  61455. /**
  61456. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61457. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61458. * After the step the babylon meshes are set to the position of the physics imposters
  61459. * @param delta amount of time to step forward
  61460. * @param impostors array of imposters to update before/after the step
  61461. */
  61462. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61463. /**
  61464. * Update babylon mesh to match physics world object
  61465. * @param impostor imposter to match
  61466. */
  61467. private _afterSoftStep;
  61468. /**
  61469. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61470. * @param impostor imposter to match
  61471. */
  61472. private _ropeStep;
  61473. /**
  61474. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61475. * @param impostor imposter to match
  61476. */
  61477. private _softbodyOrClothStep;
  61478. private _tmpMatrix;
  61479. /**
  61480. * Applies an impulse on the imposter
  61481. * @param impostor imposter to apply impulse to
  61482. * @param force amount of force to be applied to the imposter
  61483. * @param contactPoint the location to apply the impulse on the imposter
  61484. */
  61485. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61486. /**
  61487. * Applies a force on the imposter
  61488. * @param impostor imposter to apply force
  61489. * @param force amount of force to be applied to the imposter
  61490. * @param contactPoint the location to apply the force on the imposter
  61491. */
  61492. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61493. /**
  61494. * Creates a physics body using the plugin
  61495. * @param impostor the imposter to create the physics body on
  61496. */
  61497. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61498. /**
  61499. * Removes the physics body from the imposter and disposes of the body's memory
  61500. * @param impostor imposter to remove the physics body from
  61501. */
  61502. removePhysicsBody(impostor: PhysicsImpostor): void;
  61503. /**
  61504. * Generates a joint
  61505. * @param impostorJoint the imposter joint to create the joint with
  61506. */
  61507. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61508. /**
  61509. * Removes a joint
  61510. * @param impostorJoint the imposter joint to remove the joint from
  61511. */
  61512. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61513. private _addMeshVerts;
  61514. /**
  61515. * Initialise the soft body vertices to match its object's (mesh) vertices
  61516. * Softbody vertices (nodes) are in world space and to match this
  61517. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61518. * @param impostor to create the softbody for
  61519. */
  61520. private _softVertexData;
  61521. /**
  61522. * Create an impostor's soft body
  61523. * @param impostor to create the softbody for
  61524. */
  61525. private _createSoftbody;
  61526. /**
  61527. * Create cloth for an impostor
  61528. * @param impostor to create the softbody for
  61529. */
  61530. private _createCloth;
  61531. /**
  61532. * Create rope for an impostor
  61533. * @param impostor to create the softbody for
  61534. */
  61535. private _createRope;
  61536. /**
  61537. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61538. * @param impostor to create the custom physics shape for
  61539. */
  61540. private _createCustom;
  61541. private _addHullVerts;
  61542. private _createShape;
  61543. /**
  61544. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61545. * @param impostor imposter containing the physics body and babylon object
  61546. */
  61547. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61548. /**
  61549. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61550. * @param impostor imposter containing the physics body and babylon object
  61551. * @param newPosition new position
  61552. * @param newRotation new rotation
  61553. */
  61554. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61555. /**
  61556. * If this plugin is supported
  61557. * @returns true if its supported
  61558. */
  61559. isSupported(): boolean;
  61560. /**
  61561. * Sets the linear velocity of the physics body
  61562. * @param impostor imposter to set the velocity on
  61563. * @param velocity velocity to set
  61564. */
  61565. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61566. /**
  61567. * Sets the angular velocity of the physics body
  61568. * @param impostor imposter to set the velocity on
  61569. * @param velocity velocity to set
  61570. */
  61571. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61572. /**
  61573. * gets the linear velocity
  61574. * @param impostor imposter to get linear velocity from
  61575. * @returns linear velocity
  61576. */
  61577. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61578. /**
  61579. * gets the angular velocity
  61580. * @param impostor imposter to get angular velocity from
  61581. * @returns angular velocity
  61582. */
  61583. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61584. /**
  61585. * Sets the mass of physics body
  61586. * @param impostor imposter to set the mass on
  61587. * @param mass mass to set
  61588. */
  61589. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61590. /**
  61591. * Gets the mass of the physics body
  61592. * @param impostor imposter to get the mass from
  61593. * @returns mass
  61594. */
  61595. getBodyMass(impostor: PhysicsImpostor): number;
  61596. /**
  61597. * Gets friction of the impostor
  61598. * @param impostor impostor to get friction from
  61599. * @returns friction value
  61600. */
  61601. getBodyFriction(impostor: PhysicsImpostor): number;
  61602. /**
  61603. * Sets friction of the impostor
  61604. * @param impostor impostor to set friction on
  61605. * @param friction friction value
  61606. */
  61607. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61608. /**
  61609. * Gets restitution of the impostor
  61610. * @param impostor impostor to get restitution from
  61611. * @returns restitution value
  61612. */
  61613. getBodyRestitution(impostor: PhysicsImpostor): number;
  61614. /**
  61615. * Sets resitution of the impostor
  61616. * @param impostor impostor to set resitution on
  61617. * @param restitution resitution value
  61618. */
  61619. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61620. /**
  61621. * Gets pressure inside the impostor
  61622. * @param impostor impostor to get pressure from
  61623. * @returns pressure value
  61624. */
  61625. getBodyPressure(impostor: PhysicsImpostor): number;
  61626. /**
  61627. * Sets pressure inside a soft body impostor
  61628. * Cloth and rope must remain 0 pressure
  61629. * @param impostor impostor to set pressure on
  61630. * @param pressure pressure value
  61631. */
  61632. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61633. /**
  61634. * Gets stiffness of the impostor
  61635. * @param impostor impostor to get stiffness from
  61636. * @returns pressure value
  61637. */
  61638. getBodyStiffness(impostor: PhysicsImpostor): number;
  61639. /**
  61640. * Sets stiffness of the impostor
  61641. * @param impostor impostor to set stiffness on
  61642. * @param stiffness stiffness value from 0 to 1
  61643. */
  61644. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61645. /**
  61646. * Gets velocityIterations of the impostor
  61647. * @param impostor impostor to get velocity iterations from
  61648. * @returns velocityIterations value
  61649. */
  61650. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61651. /**
  61652. * Sets velocityIterations of the impostor
  61653. * @param impostor impostor to set velocity iterations on
  61654. * @param velocityIterations velocityIterations value
  61655. */
  61656. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61657. /**
  61658. * Gets positionIterations of the impostor
  61659. * @param impostor impostor to get position iterations from
  61660. * @returns positionIterations value
  61661. */
  61662. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61663. /**
  61664. * Sets positionIterations of the impostor
  61665. * @param impostor impostor to set position on
  61666. * @param positionIterations positionIterations value
  61667. */
  61668. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61669. /**
  61670. * Append an anchor to a cloth object
  61671. * @param impostor is the cloth impostor to add anchor to
  61672. * @param otherImpostor is the rigid impostor to anchor to
  61673. * @param width ratio across width from 0 to 1
  61674. * @param height ratio up height from 0 to 1
  61675. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61676. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61677. */
  61678. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61679. /**
  61680. * Append an hook to a rope object
  61681. * @param impostor is the rope impostor to add hook to
  61682. * @param otherImpostor is the rigid impostor to hook to
  61683. * @param length ratio along the rope from 0 to 1
  61684. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61685. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61686. */
  61687. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61688. /**
  61689. * Sleeps the physics body and stops it from being active
  61690. * @param impostor impostor to sleep
  61691. */
  61692. sleepBody(impostor: PhysicsImpostor): void;
  61693. /**
  61694. * Activates the physics body
  61695. * @param impostor impostor to activate
  61696. */
  61697. wakeUpBody(impostor: PhysicsImpostor): void;
  61698. /**
  61699. * Updates the distance parameters of the joint
  61700. * @param joint joint to update
  61701. * @param maxDistance maximum distance of the joint
  61702. * @param minDistance minimum distance of the joint
  61703. */
  61704. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61705. /**
  61706. * Sets a motor on the joint
  61707. * @param joint joint to set motor on
  61708. * @param speed speed of the motor
  61709. * @param maxForce maximum force of the motor
  61710. * @param motorIndex index of the motor
  61711. */
  61712. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61713. /**
  61714. * Sets the motors limit
  61715. * @param joint joint to set limit on
  61716. * @param upperLimit upper limit
  61717. * @param lowerLimit lower limit
  61718. */
  61719. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61720. /**
  61721. * Syncs the position and rotation of a mesh with the impostor
  61722. * @param mesh mesh to sync
  61723. * @param impostor impostor to update the mesh with
  61724. */
  61725. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61726. /**
  61727. * Gets the radius of the impostor
  61728. * @param impostor impostor to get radius from
  61729. * @returns the radius
  61730. */
  61731. getRadius(impostor: PhysicsImpostor): number;
  61732. /**
  61733. * Gets the box size of the impostor
  61734. * @param impostor impostor to get box size from
  61735. * @param result the resulting box size
  61736. */
  61737. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61738. /**
  61739. * Disposes of the impostor
  61740. */
  61741. dispose(): void;
  61742. /**
  61743. * Does a raycast in the physics world
  61744. * @param from when should the ray start?
  61745. * @param to when should the ray end?
  61746. * @returns PhysicsRaycastResult
  61747. */
  61748. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61749. }
  61750. }
  61751. declare module BABYLON {
  61752. interface AbstractScene {
  61753. /**
  61754. * The list of reflection probes added to the scene
  61755. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61756. */
  61757. reflectionProbes: Array<ReflectionProbe>;
  61758. /**
  61759. * Removes the given reflection probe from this scene.
  61760. * @param toRemove The reflection probe to remove
  61761. * @returns The index of the removed reflection probe
  61762. */
  61763. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61764. /**
  61765. * Adds the given reflection probe to this scene.
  61766. * @param newReflectionProbe The reflection probe to add
  61767. */
  61768. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61769. }
  61770. /**
  61771. * Class used to generate realtime reflection / refraction cube textures
  61772. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61773. */
  61774. export class ReflectionProbe {
  61775. /** defines the name of the probe */
  61776. name: string;
  61777. private _scene;
  61778. private _renderTargetTexture;
  61779. private _projectionMatrix;
  61780. private _viewMatrix;
  61781. private _target;
  61782. private _add;
  61783. private _attachedMesh;
  61784. private _invertYAxis;
  61785. /** Gets or sets probe position (center of the cube map) */
  61786. position: Vector3;
  61787. /**
  61788. * Creates a new reflection probe
  61789. * @param name defines the name of the probe
  61790. * @param size defines the texture resolution (for each face)
  61791. * @param scene defines the hosting scene
  61792. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61793. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61794. */
  61795. constructor(
  61796. /** defines the name of the probe */
  61797. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61798. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61799. get samples(): number;
  61800. set samples(value: number);
  61801. /** Gets or sets the refresh rate to use (on every frame by default) */
  61802. get refreshRate(): number;
  61803. set refreshRate(value: number);
  61804. /**
  61805. * Gets the hosting scene
  61806. * @returns a Scene
  61807. */
  61808. getScene(): Scene;
  61809. /** Gets the internal CubeTexture used to render to */
  61810. get cubeTexture(): RenderTargetTexture;
  61811. /** Gets the list of meshes to render */
  61812. get renderList(): Nullable<AbstractMesh[]>;
  61813. /**
  61814. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61815. * @param mesh defines the mesh to attach to
  61816. */
  61817. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61818. /**
  61819. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61820. * @param renderingGroupId The rendering group id corresponding to its index
  61821. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61822. */
  61823. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61824. /**
  61825. * Clean all associated resources
  61826. */
  61827. dispose(): void;
  61828. /**
  61829. * Converts the reflection probe information to a readable string for debug purpose.
  61830. * @param fullDetails Supports for multiple levels of logging within scene loading
  61831. * @returns the human readable reflection probe info
  61832. */
  61833. toString(fullDetails?: boolean): string;
  61834. /**
  61835. * Get the class name of the relfection probe.
  61836. * @returns "ReflectionProbe"
  61837. */
  61838. getClassName(): string;
  61839. /**
  61840. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61841. * @returns The JSON representation of the texture
  61842. */
  61843. serialize(): any;
  61844. /**
  61845. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61846. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61847. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61848. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61849. * @returns The parsed reflection probe if successful
  61850. */
  61851. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61852. }
  61853. }
  61854. declare module BABYLON {
  61855. /** @hidden */
  61856. export var _BabylonLoaderRegistered: boolean;
  61857. /**
  61858. * Helps setting up some configuration for the babylon file loader.
  61859. */
  61860. export class BabylonFileLoaderConfiguration {
  61861. /**
  61862. * The loader does not allow injecting custom physix engine into the plugins.
  61863. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61864. * So you could set this variable to your engine import to make it work.
  61865. */
  61866. static LoaderInjectedPhysicsEngine: any;
  61867. }
  61868. }
  61869. declare module BABYLON {
  61870. /**
  61871. * The Physically based simple base material of BJS.
  61872. *
  61873. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61874. * It is used as the base class for both the specGloss and metalRough conventions.
  61875. */
  61876. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61877. /**
  61878. * Number of Simultaneous lights allowed on the material.
  61879. */
  61880. maxSimultaneousLights: number;
  61881. /**
  61882. * If sets to true, disables all the lights affecting the material.
  61883. */
  61884. disableLighting: boolean;
  61885. /**
  61886. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61887. */
  61888. environmentTexture: BaseTexture;
  61889. /**
  61890. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61891. */
  61892. invertNormalMapX: boolean;
  61893. /**
  61894. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61895. */
  61896. invertNormalMapY: boolean;
  61897. /**
  61898. * Normal map used in the model.
  61899. */
  61900. normalTexture: BaseTexture;
  61901. /**
  61902. * Emissivie color used to self-illuminate the model.
  61903. */
  61904. emissiveColor: Color3;
  61905. /**
  61906. * Emissivie texture used to self-illuminate the model.
  61907. */
  61908. emissiveTexture: BaseTexture;
  61909. /**
  61910. * Occlusion Channel Strenght.
  61911. */
  61912. occlusionStrength: number;
  61913. /**
  61914. * Occlusion Texture of the material (adding extra occlusion effects).
  61915. */
  61916. occlusionTexture: BaseTexture;
  61917. /**
  61918. * Defines the alpha limits in alpha test mode.
  61919. */
  61920. alphaCutOff: number;
  61921. /**
  61922. * Gets the current double sided mode.
  61923. */
  61924. get doubleSided(): boolean;
  61925. /**
  61926. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61927. */
  61928. set doubleSided(value: boolean);
  61929. /**
  61930. * Stores the pre-calculated light information of a mesh in a texture.
  61931. */
  61932. lightmapTexture: BaseTexture;
  61933. /**
  61934. * If true, the light map contains occlusion information instead of lighting info.
  61935. */
  61936. useLightmapAsShadowmap: boolean;
  61937. /**
  61938. * Instantiates a new PBRMaterial instance.
  61939. *
  61940. * @param name The material name
  61941. * @param scene The scene the material will be use in.
  61942. */
  61943. constructor(name: string, scene: Scene);
  61944. getClassName(): string;
  61945. }
  61946. }
  61947. declare module BABYLON {
  61948. /**
  61949. * The PBR material of BJS following the metal roughness convention.
  61950. *
  61951. * This fits to the PBR convention in the GLTF definition:
  61952. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61953. */
  61954. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61955. /**
  61956. * The base color has two different interpretations depending on the value of metalness.
  61957. * When the material is a metal, the base color is the specific measured reflectance value
  61958. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61959. * of the material.
  61960. */
  61961. baseColor: Color3;
  61962. /**
  61963. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61964. * well as opacity information in the alpha channel.
  61965. */
  61966. baseTexture: BaseTexture;
  61967. /**
  61968. * Specifies the metallic scalar value of the material.
  61969. * Can also be used to scale the metalness values of the metallic texture.
  61970. */
  61971. metallic: number;
  61972. /**
  61973. * Specifies the roughness scalar value of the material.
  61974. * Can also be used to scale the roughness values of the metallic texture.
  61975. */
  61976. roughness: number;
  61977. /**
  61978. * Texture containing both the metallic value in the B channel and the
  61979. * roughness value in the G channel to keep better precision.
  61980. */
  61981. metallicRoughnessTexture: BaseTexture;
  61982. /**
  61983. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61984. *
  61985. * @param name The material name
  61986. * @param scene The scene the material will be use in.
  61987. */
  61988. constructor(name: string, scene: Scene);
  61989. /**
  61990. * Return the currrent class name of the material.
  61991. */
  61992. getClassName(): string;
  61993. /**
  61994. * Makes a duplicate of the current material.
  61995. * @param name - name to use for the new material.
  61996. */
  61997. clone(name: string): PBRMetallicRoughnessMaterial;
  61998. /**
  61999. * Serialize the material to a parsable JSON object.
  62000. */
  62001. serialize(): any;
  62002. /**
  62003. * Parses a JSON object correponding to the serialize function.
  62004. */
  62005. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62006. }
  62007. }
  62008. declare module BABYLON {
  62009. /**
  62010. * The PBR material of BJS following the specular glossiness convention.
  62011. *
  62012. * This fits to the PBR convention in the GLTF definition:
  62013. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62014. */
  62015. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62016. /**
  62017. * Specifies the diffuse color of the material.
  62018. */
  62019. diffuseColor: Color3;
  62020. /**
  62021. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62022. * channel.
  62023. */
  62024. diffuseTexture: BaseTexture;
  62025. /**
  62026. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62027. */
  62028. specularColor: Color3;
  62029. /**
  62030. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62031. */
  62032. glossiness: number;
  62033. /**
  62034. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62035. */
  62036. specularGlossinessTexture: BaseTexture;
  62037. /**
  62038. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62039. *
  62040. * @param name The material name
  62041. * @param scene The scene the material will be use in.
  62042. */
  62043. constructor(name: string, scene: Scene);
  62044. /**
  62045. * Return the currrent class name of the material.
  62046. */
  62047. getClassName(): string;
  62048. /**
  62049. * Makes a duplicate of the current material.
  62050. * @param name - name to use for the new material.
  62051. */
  62052. clone(name: string): PBRSpecularGlossinessMaterial;
  62053. /**
  62054. * Serialize the material to a parsable JSON object.
  62055. */
  62056. serialize(): any;
  62057. /**
  62058. * Parses a JSON object correponding to the serialize function.
  62059. */
  62060. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62061. }
  62062. }
  62063. declare module BABYLON {
  62064. /**
  62065. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62066. * It can help converting any input color in a desired output one. This can then be used to create effects
  62067. * from sepia, black and white to sixties or futuristic rendering...
  62068. *
  62069. * The only supported format is currently 3dl.
  62070. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62071. */
  62072. export class ColorGradingTexture extends BaseTexture {
  62073. /**
  62074. * The texture URL.
  62075. */
  62076. url: string;
  62077. /**
  62078. * Empty line regex stored for GC.
  62079. */
  62080. private static _noneEmptyLineRegex;
  62081. private _textureMatrix;
  62082. private _onLoad;
  62083. /**
  62084. * Instantiates a ColorGradingTexture from the following parameters.
  62085. *
  62086. * @param url The location of the color gradind data (currently only supporting 3dl)
  62087. * @param sceneOrEngine The scene or engine the texture will be used in
  62088. * @param onLoad defines a callback triggered when the texture has been loaded
  62089. */
  62090. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62091. /**
  62092. * Fires the onload event from the constructor if requested.
  62093. */
  62094. private _triggerOnLoad;
  62095. /**
  62096. * Returns the texture matrix used in most of the material.
  62097. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62098. */
  62099. getTextureMatrix(): Matrix;
  62100. /**
  62101. * Occurs when the file being loaded is a .3dl LUT file.
  62102. */
  62103. private load3dlTexture;
  62104. /**
  62105. * Starts the loading process of the texture.
  62106. */
  62107. private loadTexture;
  62108. /**
  62109. * Clones the color gradind texture.
  62110. */
  62111. clone(): ColorGradingTexture;
  62112. /**
  62113. * Called during delayed load for textures.
  62114. */
  62115. delayLoad(): void;
  62116. /**
  62117. * Parses a color grading texture serialized by Babylon.
  62118. * @param parsedTexture The texture information being parsedTexture
  62119. * @param scene The scene to load the texture in
  62120. * @param rootUrl The root url of the data assets to load
  62121. * @return A color gradind texture
  62122. */
  62123. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62124. /**
  62125. * Serializes the LUT texture to json format.
  62126. */
  62127. serialize(): any;
  62128. }
  62129. }
  62130. declare module BABYLON {
  62131. /**
  62132. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62133. */
  62134. export class EquiRectangularCubeTexture extends BaseTexture {
  62135. /** The six faces of the cube. */
  62136. private static _FacesMapping;
  62137. private _noMipmap;
  62138. private _onLoad;
  62139. private _onError;
  62140. /** The size of the cubemap. */
  62141. private _size;
  62142. /** The buffer of the image. */
  62143. private _buffer;
  62144. /** The width of the input image. */
  62145. private _width;
  62146. /** The height of the input image. */
  62147. private _height;
  62148. /** The URL to the image. */
  62149. url: string;
  62150. /**
  62151. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62152. * @param url The location of the image
  62153. * @param scene The scene the texture will be used in
  62154. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62155. * @param noMipmap Forces to not generate the mipmap if true
  62156. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62157. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62158. * @param onLoad — defines a callback called when texture is loaded
  62159. * @param onError — defines a callback called if there is an error
  62160. */
  62161. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62162. /**
  62163. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62164. */
  62165. private loadImage;
  62166. /**
  62167. * Convert the image buffer into a cubemap and create a CubeTexture.
  62168. */
  62169. private loadTexture;
  62170. /**
  62171. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62172. * @param buffer The ArrayBuffer that should be converted.
  62173. * @returns The buffer as Float32Array.
  62174. */
  62175. private getFloat32ArrayFromArrayBuffer;
  62176. /**
  62177. * Get the current class name of the texture useful for serialization or dynamic coding.
  62178. * @returns "EquiRectangularCubeTexture"
  62179. */
  62180. getClassName(): string;
  62181. /**
  62182. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62183. * @returns A clone of the current EquiRectangularCubeTexture.
  62184. */
  62185. clone(): EquiRectangularCubeTexture;
  62186. }
  62187. }
  62188. declare module BABYLON {
  62189. /**
  62190. * Defines the options related to the creation of an HtmlElementTexture
  62191. */
  62192. export interface IHtmlElementTextureOptions {
  62193. /**
  62194. * Defines wether mip maps should be created or not.
  62195. */
  62196. generateMipMaps?: boolean;
  62197. /**
  62198. * Defines the sampling mode of the texture.
  62199. */
  62200. samplingMode?: number;
  62201. /**
  62202. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62203. */
  62204. engine: Nullable<ThinEngine>;
  62205. /**
  62206. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62207. */
  62208. scene: Nullable<Scene>;
  62209. }
  62210. /**
  62211. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62212. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62213. * is automatically managed.
  62214. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62215. * in your application.
  62216. *
  62217. * As the update is not automatic, you need to call them manually.
  62218. */
  62219. export class HtmlElementTexture extends BaseTexture {
  62220. /**
  62221. * The texture URL.
  62222. */
  62223. element: HTMLVideoElement | HTMLCanvasElement;
  62224. private static readonly DefaultOptions;
  62225. private _textureMatrix;
  62226. private _isVideo;
  62227. private _generateMipMaps;
  62228. private _samplingMode;
  62229. /**
  62230. * Instantiates a HtmlElementTexture from the following parameters.
  62231. *
  62232. * @param name Defines the name of the texture
  62233. * @param element Defines the video or canvas the texture is filled with
  62234. * @param options Defines the other none mandatory texture creation options
  62235. */
  62236. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62237. private _createInternalTexture;
  62238. /**
  62239. * Returns the texture matrix used in most of the material.
  62240. */
  62241. getTextureMatrix(): Matrix;
  62242. /**
  62243. * Updates the content of the texture.
  62244. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62245. */
  62246. update(invertY?: Nullable<boolean>): void;
  62247. }
  62248. }
  62249. declare module BABYLON {
  62250. /**
  62251. * Based on jsTGALoader - Javascript loader for TGA file
  62252. * By Vincent Thibault
  62253. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62254. */
  62255. export class TGATools {
  62256. private static _TYPE_INDEXED;
  62257. private static _TYPE_RGB;
  62258. private static _TYPE_GREY;
  62259. private static _TYPE_RLE_INDEXED;
  62260. private static _TYPE_RLE_RGB;
  62261. private static _TYPE_RLE_GREY;
  62262. private static _ORIGIN_MASK;
  62263. private static _ORIGIN_SHIFT;
  62264. private static _ORIGIN_BL;
  62265. private static _ORIGIN_BR;
  62266. private static _ORIGIN_UL;
  62267. private static _ORIGIN_UR;
  62268. /**
  62269. * Gets the header of a TGA file
  62270. * @param data defines the TGA data
  62271. * @returns the header
  62272. */
  62273. static GetTGAHeader(data: Uint8Array): any;
  62274. /**
  62275. * Uploads TGA content to a Babylon Texture
  62276. * @hidden
  62277. */
  62278. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62279. /** @hidden */
  62280. 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;
  62281. /** @hidden */
  62282. 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;
  62283. /** @hidden */
  62284. 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;
  62285. /** @hidden */
  62286. 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;
  62287. /** @hidden */
  62288. 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;
  62289. /** @hidden */
  62290. 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;
  62291. }
  62292. }
  62293. declare module BABYLON {
  62294. /**
  62295. * Implementation of the TGA Texture Loader.
  62296. * @hidden
  62297. */
  62298. export class _TGATextureLoader implements IInternalTextureLoader {
  62299. /**
  62300. * Defines wether the loader supports cascade loading the different faces.
  62301. */
  62302. readonly supportCascades: boolean;
  62303. /**
  62304. * This returns if the loader support the current file information.
  62305. * @param extension defines the file extension of the file being loaded
  62306. * @returns true if the loader can load the specified file
  62307. */
  62308. canLoad(extension: string): boolean;
  62309. /**
  62310. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62311. * @param data contains the texture data
  62312. * @param texture defines the BabylonJS internal texture
  62313. * @param createPolynomials will be true if polynomials have been requested
  62314. * @param onLoad defines the callback to trigger once the texture is ready
  62315. * @param onError defines the callback to trigger in case of error
  62316. */
  62317. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62318. /**
  62319. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62320. * @param data contains the texture data
  62321. * @param texture defines the BabylonJS internal texture
  62322. * @param callback defines the method to call once ready to upload
  62323. */
  62324. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62325. }
  62326. }
  62327. declare module BABYLON {
  62328. /**
  62329. * Info about the .basis files
  62330. */
  62331. class BasisFileInfo {
  62332. /**
  62333. * If the file has alpha
  62334. */
  62335. hasAlpha: boolean;
  62336. /**
  62337. * Info about each image of the basis file
  62338. */
  62339. images: Array<{
  62340. levels: Array<{
  62341. width: number;
  62342. height: number;
  62343. transcodedPixels: ArrayBufferView;
  62344. }>;
  62345. }>;
  62346. }
  62347. /**
  62348. * Result of transcoding a basis file
  62349. */
  62350. class TranscodeResult {
  62351. /**
  62352. * Info about the .basis file
  62353. */
  62354. fileInfo: BasisFileInfo;
  62355. /**
  62356. * Format to use when loading the file
  62357. */
  62358. format: number;
  62359. }
  62360. /**
  62361. * Configuration options for the Basis transcoder
  62362. */
  62363. export class BasisTranscodeConfiguration {
  62364. /**
  62365. * Supported compression formats used to determine the supported output format of the transcoder
  62366. */
  62367. supportedCompressionFormats?: {
  62368. /**
  62369. * etc1 compression format
  62370. */
  62371. etc1?: boolean;
  62372. /**
  62373. * s3tc compression format
  62374. */
  62375. s3tc?: boolean;
  62376. /**
  62377. * pvrtc compression format
  62378. */
  62379. pvrtc?: boolean;
  62380. /**
  62381. * etc2 compression format
  62382. */
  62383. etc2?: boolean;
  62384. };
  62385. /**
  62386. * If mipmap levels should be loaded for transcoded images (Default: true)
  62387. */
  62388. loadMipmapLevels?: boolean;
  62389. /**
  62390. * Index of a single image to load (Default: all images)
  62391. */
  62392. loadSingleImage?: number;
  62393. }
  62394. /**
  62395. * Used to load .Basis files
  62396. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62397. */
  62398. export class BasisTools {
  62399. private static _IgnoreSupportedFormats;
  62400. /**
  62401. * URL to use when loading the basis transcoder
  62402. */
  62403. static JSModuleURL: string;
  62404. /**
  62405. * URL to use when loading the wasm module for the transcoder
  62406. */
  62407. static WasmModuleURL: string;
  62408. /**
  62409. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62410. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62411. * @returns internal format corresponding to the Basis format
  62412. */
  62413. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62414. private static _WorkerPromise;
  62415. private static _Worker;
  62416. private static _actionId;
  62417. private static _CreateWorkerAsync;
  62418. /**
  62419. * Transcodes a loaded image file to compressed pixel data
  62420. * @param data image data to transcode
  62421. * @param config configuration options for the transcoding
  62422. * @returns a promise resulting in the transcoded image
  62423. */
  62424. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62425. /**
  62426. * Loads a texture from the transcode result
  62427. * @param texture texture load to
  62428. * @param transcodeResult the result of transcoding the basis file to load from
  62429. */
  62430. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62431. }
  62432. }
  62433. declare module BABYLON {
  62434. /**
  62435. * Loader for .basis file format
  62436. */
  62437. export class _BasisTextureLoader implements IInternalTextureLoader {
  62438. /**
  62439. * Defines whether the loader supports cascade loading the different faces.
  62440. */
  62441. readonly supportCascades: boolean;
  62442. /**
  62443. * This returns if the loader support the current file information.
  62444. * @param extension defines the file extension of the file being loaded
  62445. * @returns true if the loader can load the specified file
  62446. */
  62447. canLoad(extension: string): boolean;
  62448. /**
  62449. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62450. * @param data contains the texture data
  62451. * @param texture defines the BabylonJS internal texture
  62452. * @param createPolynomials will be true if polynomials have been requested
  62453. * @param onLoad defines the callback to trigger once the texture is ready
  62454. * @param onError defines the callback to trigger in case of error
  62455. */
  62456. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62457. /**
  62458. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62459. * @param data contains the texture data
  62460. * @param texture defines the BabylonJS internal texture
  62461. * @param callback defines the method to call once ready to upload
  62462. */
  62463. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62464. }
  62465. }
  62466. declare module BABYLON {
  62467. /**
  62468. * Defines the basic options interface of a TexturePacker Frame
  62469. */
  62470. export interface ITexturePackerFrame {
  62471. /**
  62472. * The frame ID
  62473. */
  62474. id: number;
  62475. /**
  62476. * The frames Scale
  62477. */
  62478. scale: Vector2;
  62479. /**
  62480. * The Frames offset
  62481. */
  62482. offset: Vector2;
  62483. }
  62484. /**
  62485. * This is a support class for frame Data on texture packer sets.
  62486. */
  62487. export class TexturePackerFrame implements ITexturePackerFrame {
  62488. /**
  62489. * The frame ID
  62490. */
  62491. id: number;
  62492. /**
  62493. * The frames Scale
  62494. */
  62495. scale: Vector2;
  62496. /**
  62497. * The Frames offset
  62498. */
  62499. offset: Vector2;
  62500. /**
  62501. * Initializes a texture package frame.
  62502. * @param id The numerical frame identifier
  62503. * @param scale Scalar Vector2 for UV frame
  62504. * @param offset Vector2 for the frame position in UV units.
  62505. * @returns TexturePackerFrame
  62506. */
  62507. constructor(id: number, scale: Vector2, offset: Vector2);
  62508. }
  62509. }
  62510. declare module BABYLON {
  62511. /**
  62512. * Defines the basic options interface of a TexturePacker
  62513. */
  62514. export interface ITexturePackerOptions {
  62515. /**
  62516. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62517. */
  62518. map?: string[];
  62519. /**
  62520. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62521. */
  62522. uvsIn?: string;
  62523. /**
  62524. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62525. */
  62526. uvsOut?: string;
  62527. /**
  62528. * number representing the layout style. Defaults to LAYOUT_STRIP
  62529. */
  62530. layout?: number;
  62531. /**
  62532. * number of columns if using custom column count layout(2). This defaults to 4.
  62533. */
  62534. colnum?: number;
  62535. /**
  62536. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62537. */
  62538. updateInputMeshes?: boolean;
  62539. /**
  62540. * boolean flag to dispose all the source textures. Defaults to true.
  62541. */
  62542. disposeSources?: boolean;
  62543. /**
  62544. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62545. */
  62546. fillBlanks?: boolean;
  62547. /**
  62548. * string value representing the context fill style color. Defaults to 'black'.
  62549. */
  62550. customFillColor?: string;
  62551. /**
  62552. * Width and Height Value of each Frame in the TexturePacker Sets
  62553. */
  62554. frameSize?: number;
  62555. /**
  62556. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62557. */
  62558. paddingRatio?: number;
  62559. /**
  62560. * Number that declares the fill method for the padding gutter.
  62561. */
  62562. paddingMode?: number;
  62563. /**
  62564. * If in SUBUV_COLOR padding mode what color to use.
  62565. */
  62566. paddingColor?: Color3 | Color4;
  62567. }
  62568. /**
  62569. * Defines the basic interface of a TexturePacker JSON File
  62570. */
  62571. export interface ITexturePackerJSON {
  62572. /**
  62573. * The frame ID
  62574. */
  62575. name: string;
  62576. /**
  62577. * The base64 channel data
  62578. */
  62579. sets: any;
  62580. /**
  62581. * The options of the Packer
  62582. */
  62583. options: ITexturePackerOptions;
  62584. /**
  62585. * The frame data of the Packer
  62586. */
  62587. frames: Array<number>;
  62588. }
  62589. /**
  62590. * This is a support class that generates a series of packed texture sets.
  62591. * @see https://doc.babylonjs.com/babylon101/materials
  62592. */
  62593. export class TexturePacker {
  62594. /** Packer Layout Constant 0 */
  62595. static readonly LAYOUT_STRIP: number;
  62596. /** Packer Layout Constant 1 */
  62597. static readonly LAYOUT_POWER2: number;
  62598. /** Packer Layout Constant 2 */
  62599. static readonly LAYOUT_COLNUM: number;
  62600. /** Packer Layout Constant 0 */
  62601. static readonly SUBUV_WRAP: number;
  62602. /** Packer Layout Constant 1 */
  62603. static readonly SUBUV_EXTEND: number;
  62604. /** Packer Layout Constant 2 */
  62605. static readonly SUBUV_COLOR: number;
  62606. /** The Name of the Texture Package */
  62607. name: string;
  62608. /** The scene scope of the TexturePacker */
  62609. scene: Scene;
  62610. /** The Meshes to target */
  62611. meshes: AbstractMesh[];
  62612. /** Arguments passed with the Constructor */
  62613. options: ITexturePackerOptions;
  62614. /** The promise that is started upon initialization */
  62615. promise: Nullable<Promise<TexturePacker | string>>;
  62616. /** The Container object for the channel sets that are generated */
  62617. sets: object;
  62618. /** The Container array for the frames that are generated */
  62619. frames: TexturePackerFrame[];
  62620. /** The expected number of textures the system is parsing. */
  62621. private _expecting;
  62622. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62623. private _paddingValue;
  62624. /**
  62625. * Initializes a texture package series from an array of meshes or a single mesh.
  62626. * @param name The name of the package
  62627. * @param meshes The target meshes to compose the package from
  62628. * @param options The arguments that texture packer should follow while building.
  62629. * @param scene The scene which the textures are scoped to.
  62630. * @returns TexturePacker
  62631. */
  62632. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62633. /**
  62634. * Starts the package process
  62635. * @param resolve The promises resolution function
  62636. * @returns TexturePacker
  62637. */
  62638. private _createFrames;
  62639. /**
  62640. * Calculates the Size of the Channel Sets
  62641. * @returns Vector2
  62642. */
  62643. private _calculateSize;
  62644. /**
  62645. * Calculates the UV data for the frames.
  62646. * @param baseSize the base frameSize
  62647. * @param padding the base frame padding
  62648. * @param dtSize size of the Dynamic Texture for that channel
  62649. * @param dtUnits is 1/dtSize
  62650. * @param update flag to update the input meshes
  62651. */
  62652. private _calculateMeshUVFrames;
  62653. /**
  62654. * Calculates the frames Offset.
  62655. * @param index of the frame
  62656. * @returns Vector2
  62657. */
  62658. private _getFrameOffset;
  62659. /**
  62660. * Updates a Mesh to the frame data
  62661. * @param mesh that is the target
  62662. * @param frameID or the frame index
  62663. */
  62664. private _updateMeshUV;
  62665. /**
  62666. * Updates a Meshes materials to use the texture packer channels
  62667. * @param m is the mesh to target
  62668. * @param force all channels on the packer to be set.
  62669. */
  62670. private _updateTextureReferences;
  62671. /**
  62672. * Public method to set a Mesh to a frame
  62673. * @param m that is the target
  62674. * @param frameID or the frame index
  62675. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62676. */
  62677. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62678. /**
  62679. * Starts the async promise to compile the texture packer.
  62680. * @returns Promise<void>
  62681. */
  62682. processAsync(): Promise<void>;
  62683. /**
  62684. * Disposes all textures associated with this packer
  62685. */
  62686. dispose(): void;
  62687. /**
  62688. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62689. * @param imageType is the image type to use.
  62690. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62691. */
  62692. download(imageType?: string, quality?: number): void;
  62693. /**
  62694. * Public method to load a texturePacker JSON file.
  62695. * @param data of the JSON file in string format.
  62696. */
  62697. updateFromJSON(data: string): void;
  62698. }
  62699. }
  62700. declare module BABYLON {
  62701. /**
  62702. * 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.
  62703. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62704. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62705. */
  62706. export class CustomProceduralTexture extends ProceduralTexture {
  62707. private _animate;
  62708. private _time;
  62709. private _config;
  62710. private _texturePath;
  62711. /**
  62712. * Instantiates a new Custom Procedural Texture.
  62713. * 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.
  62714. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62715. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62716. * @param name Define the name of the texture
  62717. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62718. * @param size Define the size of the texture to create
  62719. * @param scene Define the scene the texture belongs to
  62720. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62721. * @param generateMipMaps Define if the texture should creates mip maps or not
  62722. */
  62723. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62724. private _loadJson;
  62725. /**
  62726. * Is the texture ready to be used ? (rendered at least once)
  62727. * @returns true if ready, otherwise, false.
  62728. */
  62729. isReady(): boolean;
  62730. /**
  62731. * Render the texture to its associated render target.
  62732. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62733. */
  62734. render(useCameraPostProcess?: boolean): void;
  62735. /**
  62736. * Update the list of dependant textures samplers in the shader.
  62737. */
  62738. updateTextures(): void;
  62739. /**
  62740. * Update the uniform values of the procedural texture in the shader.
  62741. */
  62742. updateShaderUniforms(): void;
  62743. /**
  62744. * Define if the texture animates or not.
  62745. */
  62746. get animate(): boolean;
  62747. set animate(value: boolean);
  62748. }
  62749. }
  62750. declare module BABYLON {
  62751. /** @hidden */
  62752. export var noisePixelShader: {
  62753. name: string;
  62754. shader: string;
  62755. };
  62756. }
  62757. declare module BABYLON {
  62758. /**
  62759. * Class used to generate noise procedural textures
  62760. */
  62761. export class NoiseProceduralTexture extends ProceduralTexture {
  62762. /** Gets or sets the start time (default is 0) */
  62763. time: number;
  62764. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62765. brightness: number;
  62766. /** Defines the number of octaves to process */
  62767. octaves: number;
  62768. /** Defines the level of persistence (0.8 by default) */
  62769. persistence: number;
  62770. /** Gets or sets animation speed factor (default is 1) */
  62771. animationSpeedFactor: number;
  62772. /**
  62773. * Creates a new NoiseProceduralTexture
  62774. * @param name defines the name fo the texture
  62775. * @param size defines the size of the texture (default is 256)
  62776. * @param scene defines the hosting scene
  62777. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62778. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62779. */
  62780. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62781. private _updateShaderUniforms;
  62782. protected _getDefines(): string;
  62783. /** Generate the current state of the procedural texture */
  62784. render(useCameraPostProcess?: boolean): void;
  62785. /**
  62786. * Serializes this noise procedural texture
  62787. * @returns a serialized noise procedural texture object
  62788. */
  62789. serialize(): any;
  62790. /**
  62791. * Clone the texture.
  62792. * @returns the cloned texture
  62793. */
  62794. clone(): NoiseProceduralTexture;
  62795. /**
  62796. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62797. * @param parsedTexture defines parsed texture data
  62798. * @param scene defines the current scene
  62799. * @param rootUrl defines the root URL containing noise procedural texture information
  62800. * @returns a parsed NoiseProceduralTexture
  62801. */
  62802. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62803. }
  62804. }
  62805. declare module BABYLON {
  62806. /**
  62807. * Raw cube texture where the raw buffers are passed in
  62808. */
  62809. export class RawCubeTexture extends CubeTexture {
  62810. /**
  62811. * Creates a cube texture where the raw buffers are passed in.
  62812. * @param scene defines the scene the texture is attached to
  62813. * @param data defines the array of data to use to create each face
  62814. * @param size defines the size of the textures
  62815. * @param format defines the format of the data
  62816. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62817. * @param generateMipMaps defines if the engine should generate the mip levels
  62818. * @param invertY defines if data must be stored with Y axis inverted
  62819. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62820. * @param compression defines the compression used (null by default)
  62821. */
  62822. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62823. /**
  62824. * Updates the raw cube texture.
  62825. * @param data defines the data to store
  62826. * @param format defines the data format
  62827. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62828. * @param invertY defines if data must be stored with Y axis inverted
  62829. * @param compression defines the compression used (null by default)
  62830. * @param level defines which level of the texture to update
  62831. */
  62832. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62833. /**
  62834. * Updates a raw cube texture with RGBD encoded data.
  62835. * @param data defines the array of data [mipmap][face] to use to create each face
  62836. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62837. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62838. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62839. * @returns a promsie that resolves when the operation is complete
  62840. */
  62841. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62842. /**
  62843. * Clones the raw cube texture.
  62844. * @return a new cube texture
  62845. */
  62846. clone(): CubeTexture;
  62847. /** @hidden */
  62848. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62849. }
  62850. }
  62851. declare module BABYLON {
  62852. /**
  62853. * Class used to store 2D array textures containing user data
  62854. */
  62855. export class RawTexture2DArray extends Texture {
  62856. /** Gets or sets the texture format to use */
  62857. format: number;
  62858. /**
  62859. * Create a new RawTexture2DArray
  62860. * @param data defines the data of the texture
  62861. * @param width defines the width of the texture
  62862. * @param height defines the height of the texture
  62863. * @param depth defines the number of layers of the texture
  62864. * @param format defines the texture format to use
  62865. * @param scene defines the hosting scene
  62866. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62867. * @param invertY defines if texture must be stored with Y axis inverted
  62868. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62869. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62870. */
  62871. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62872. /** Gets or sets the texture format to use */
  62873. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62874. /**
  62875. * Update the texture with new data
  62876. * @param data defines the data to store in the texture
  62877. */
  62878. update(data: ArrayBufferView): void;
  62879. }
  62880. }
  62881. declare module BABYLON {
  62882. /**
  62883. * Class used to store 3D textures containing user data
  62884. */
  62885. export class RawTexture3D extends Texture {
  62886. /** Gets or sets the texture format to use */
  62887. format: number;
  62888. /**
  62889. * Create a new RawTexture3D
  62890. * @param data defines the data of the texture
  62891. * @param width defines the width of the texture
  62892. * @param height defines the height of the texture
  62893. * @param depth defines the depth of the texture
  62894. * @param format defines the texture format to use
  62895. * @param scene defines the hosting scene
  62896. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62897. * @param invertY defines if texture must be stored with Y axis inverted
  62898. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62899. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62900. */
  62901. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62902. /** Gets or sets the texture format to use */
  62903. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62904. /**
  62905. * Update the texture with new data
  62906. * @param data defines the data to store in the texture
  62907. */
  62908. update(data: ArrayBufferView): void;
  62909. }
  62910. }
  62911. declare module BABYLON {
  62912. /**
  62913. * Creates a refraction texture used by refraction channel of the standard material.
  62914. * It is like a mirror but to see through a material.
  62915. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62916. */
  62917. export class RefractionTexture extends RenderTargetTexture {
  62918. /**
  62919. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62920. * 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.
  62921. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62922. */
  62923. refractionPlane: Plane;
  62924. /**
  62925. * Define how deep under the surface we should see.
  62926. */
  62927. depth: number;
  62928. /**
  62929. * Creates a refraction texture used by refraction channel of the standard material.
  62930. * It is like a mirror but to see through a material.
  62931. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62932. * @param name Define the texture name
  62933. * @param size Define the size of the underlying texture
  62934. * @param scene Define the scene the refraction belongs to
  62935. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62936. */
  62937. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62938. /**
  62939. * Clone the refraction texture.
  62940. * @returns the cloned texture
  62941. */
  62942. clone(): RefractionTexture;
  62943. /**
  62944. * Serialize the texture to a JSON representation you could use in Parse later on
  62945. * @returns the serialized JSON representation
  62946. */
  62947. serialize(): any;
  62948. }
  62949. }
  62950. declare module BABYLON {
  62951. /**
  62952. * Block used to add support for vertex skinning (bones)
  62953. */
  62954. export class BonesBlock extends NodeMaterialBlock {
  62955. /**
  62956. * Creates a new BonesBlock
  62957. * @param name defines the block name
  62958. */
  62959. constructor(name: string);
  62960. /**
  62961. * Initialize the block and prepare the context for build
  62962. * @param state defines the state that will be used for the build
  62963. */
  62964. initialize(state: NodeMaterialBuildState): void;
  62965. /**
  62966. * Gets the current class name
  62967. * @returns the class name
  62968. */
  62969. getClassName(): string;
  62970. /**
  62971. * Gets the matrix indices input component
  62972. */
  62973. get matricesIndices(): NodeMaterialConnectionPoint;
  62974. /**
  62975. * Gets the matrix weights input component
  62976. */
  62977. get matricesWeights(): NodeMaterialConnectionPoint;
  62978. /**
  62979. * Gets the extra matrix indices input component
  62980. */
  62981. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62982. /**
  62983. * Gets the extra matrix weights input component
  62984. */
  62985. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62986. /**
  62987. * Gets the world input component
  62988. */
  62989. get world(): NodeMaterialConnectionPoint;
  62990. /**
  62991. * Gets the output component
  62992. */
  62993. get output(): NodeMaterialConnectionPoint;
  62994. autoConfigure(material: NodeMaterial): void;
  62995. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62996. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62997. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62998. protected _buildBlock(state: NodeMaterialBuildState): this;
  62999. }
  63000. }
  63001. declare module BABYLON {
  63002. /**
  63003. * Block used to add support for instances
  63004. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63005. */
  63006. export class InstancesBlock extends NodeMaterialBlock {
  63007. /**
  63008. * Creates a new InstancesBlock
  63009. * @param name defines the block name
  63010. */
  63011. constructor(name: string);
  63012. /**
  63013. * Gets the current class name
  63014. * @returns the class name
  63015. */
  63016. getClassName(): string;
  63017. /**
  63018. * Gets the first world row input component
  63019. */
  63020. get world0(): NodeMaterialConnectionPoint;
  63021. /**
  63022. * Gets the second world row input component
  63023. */
  63024. get world1(): NodeMaterialConnectionPoint;
  63025. /**
  63026. * Gets the third world row input component
  63027. */
  63028. get world2(): NodeMaterialConnectionPoint;
  63029. /**
  63030. * Gets the forth world row input component
  63031. */
  63032. get world3(): NodeMaterialConnectionPoint;
  63033. /**
  63034. * Gets the world input component
  63035. */
  63036. get world(): NodeMaterialConnectionPoint;
  63037. /**
  63038. * Gets the output component
  63039. */
  63040. get output(): NodeMaterialConnectionPoint;
  63041. /**
  63042. * Gets the isntanceID component
  63043. */
  63044. get instanceID(): NodeMaterialConnectionPoint;
  63045. autoConfigure(material: NodeMaterial): void;
  63046. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63047. protected _buildBlock(state: NodeMaterialBuildState): this;
  63048. }
  63049. }
  63050. declare module BABYLON {
  63051. /**
  63052. * Block used to add morph targets support to vertex shader
  63053. */
  63054. export class MorphTargetsBlock extends NodeMaterialBlock {
  63055. private _repeatableContentAnchor;
  63056. /**
  63057. * Create a new MorphTargetsBlock
  63058. * @param name defines the block name
  63059. */
  63060. constructor(name: string);
  63061. /**
  63062. * Gets the current class name
  63063. * @returns the class name
  63064. */
  63065. getClassName(): string;
  63066. /**
  63067. * Gets the position input component
  63068. */
  63069. get position(): NodeMaterialConnectionPoint;
  63070. /**
  63071. * Gets the normal input component
  63072. */
  63073. get normal(): NodeMaterialConnectionPoint;
  63074. /**
  63075. * Gets the tangent input component
  63076. */
  63077. get tangent(): NodeMaterialConnectionPoint;
  63078. /**
  63079. * Gets the tangent input component
  63080. */
  63081. get uv(): NodeMaterialConnectionPoint;
  63082. /**
  63083. * Gets the position output component
  63084. */
  63085. get positionOutput(): NodeMaterialConnectionPoint;
  63086. /**
  63087. * Gets the normal output component
  63088. */
  63089. get normalOutput(): NodeMaterialConnectionPoint;
  63090. /**
  63091. * Gets the tangent output component
  63092. */
  63093. get tangentOutput(): NodeMaterialConnectionPoint;
  63094. /**
  63095. * Gets the tangent output component
  63096. */
  63097. get uvOutput(): NodeMaterialConnectionPoint;
  63098. initialize(state: NodeMaterialBuildState): void;
  63099. autoConfigure(material: NodeMaterial): void;
  63100. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63102. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63103. protected _buildBlock(state: NodeMaterialBuildState): this;
  63104. }
  63105. }
  63106. declare module BABYLON {
  63107. /**
  63108. * Block used to get data information from a light
  63109. */
  63110. export class LightInformationBlock extends NodeMaterialBlock {
  63111. private _lightDataUniformName;
  63112. private _lightColorUniformName;
  63113. private _lightTypeDefineName;
  63114. /**
  63115. * Gets or sets the light associated with this block
  63116. */
  63117. light: Nullable<Light>;
  63118. /**
  63119. * Creates a new LightInformationBlock
  63120. * @param name defines the block name
  63121. */
  63122. constructor(name: string);
  63123. /**
  63124. * Gets the current class name
  63125. * @returns the class name
  63126. */
  63127. getClassName(): string;
  63128. /**
  63129. * Gets the world position input component
  63130. */
  63131. get worldPosition(): NodeMaterialConnectionPoint;
  63132. /**
  63133. * Gets the direction output component
  63134. */
  63135. get direction(): NodeMaterialConnectionPoint;
  63136. /**
  63137. * Gets the direction output component
  63138. */
  63139. get color(): NodeMaterialConnectionPoint;
  63140. /**
  63141. * Gets the direction output component
  63142. */
  63143. get intensity(): NodeMaterialConnectionPoint;
  63144. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63145. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63146. protected _buildBlock(state: NodeMaterialBuildState): this;
  63147. serialize(): any;
  63148. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63149. }
  63150. }
  63151. declare module BABYLON {
  63152. /**
  63153. * Block used to add image processing support to fragment shader
  63154. */
  63155. export class ImageProcessingBlock extends NodeMaterialBlock {
  63156. /**
  63157. * Create a new ImageProcessingBlock
  63158. * @param name defines the block name
  63159. */
  63160. constructor(name: string);
  63161. /**
  63162. * Gets the current class name
  63163. * @returns the class name
  63164. */
  63165. getClassName(): string;
  63166. /**
  63167. * Gets the color input component
  63168. */
  63169. get color(): NodeMaterialConnectionPoint;
  63170. /**
  63171. * Gets the output component
  63172. */
  63173. get output(): NodeMaterialConnectionPoint;
  63174. /**
  63175. * Initialize the block and prepare the context for build
  63176. * @param state defines the state that will be used for the build
  63177. */
  63178. initialize(state: NodeMaterialBuildState): void;
  63179. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63181. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63182. protected _buildBlock(state: NodeMaterialBuildState): this;
  63183. }
  63184. }
  63185. declare module BABYLON {
  63186. /**
  63187. * Block used to pertub normals based on a normal map
  63188. */
  63189. export class PerturbNormalBlock extends NodeMaterialBlock {
  63190. private _tangentSpaceParameterName;
  63191. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63192. invertX: boolean;
  63193. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63194. invertY: boolean;
  63195. /**
  63196. * Create a new PerturbNormalBlock
  63197. * @param name defines the block name
  63198. */
  63199. constructor(name: string);
  63200. /**
  63201. * Gets the current class name
  63202. * @returns the class name
  63203. */
  63204. getClassName(): string;
  63205. /**
  63206. * Gets the world position input component
  63207. */
  63208. get worldPosition(): NodeMaterialConnectionPoint;
  63209. /**
  63210. * Gets the world normal input component
  63211. */
  63212. get worldNormal(): NodeMaterialConnectionPoint;
  63213. /**
  63214. * Gets the world tangent input component
  63215. */
  63216. get worldTangent(): NodeMaterialConnectionPoint;
  63217. /**
  63218. * Gets the uv input component
  63219. */
  63220. get uv(): NodeMaterialConnectionPoint;
  63221. /**
  63222. * Gets the normal map color input component
  63223. */
  63224. get normalMapColor(): NodeMaterialConnectionPoint;
  63225. /**
  63226. * Gets the strength input component
  63227. */
  63228. get strength(): NodeMaterialConnectionPoint;
  63229. /**
  63230. * Gets the output component
  63231. */
  63232. get output(): NodeMaterialConnectionPoint;
  63233. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63234. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63235. autoConfigure(material: NodeMaterial): void;
  63236. protected _buildBlock(state: NodeMaterialBuildState): this;
  63237. protected _dumpPropertiesCode(): string;
  63238. serialize(): any;
  63239. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63240. }
  63241. }
  63242. declare module BABYLON {
  63243. /**
  63244. * Block used to discard a pixel if a value is smaller than a cutoff
  63245. */
  63246. export class DiscardBlock extends NodeMaterialBlock {
  63247. /**
  63248. * Create a new DiscardBlock
  63249. * @param name defines the block name
  63250. */
  63251. constructor(name: string);
  63252. /**
  63253. * Gets the current class name
  63254. * @returns the class name
  63255. */
  63256. getClassName(): string;
  63257. /**
  63258. * Gets the color input component
  63259. */
  63260. get value(): NodeMaterialConnectionPoint;
  63261. /**
  63262. * Gets the cutoff input component
  63263. */
  63264. get cutoff(): NodeMaterialConnectionPoint;
  63265. protected _buildBlock(state: NodeMaterialBuildState): this;
  63266. }
  63267. }
  63268. declare module BABYLON {
  63269. /**
  63270. * Block used to test if the fragment shader is front facing
  63271. */
  63272. export class FrontFacingBlock extends NodeMaterialBlock {
  63273. /**
  63274. * Creates a new FrontFacingBlock
  63275. * @param name defines the block name
  63276. */
  63277. constructor(name: string);
  63278. /**
  63279. * Gets the current class name
  63280. * @returns the class name
  63281. */
  63282. getClassName(): string;
  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 derivative value on x and y of a given input
  63293. */
  63294. export class DerivativeBlock extends NodeMaterialBlock {
  63295. /**
  63296. * Create a new DerivativeBlock
  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 input component
  63307. */
  63308. get input(): NodeMaterialConnectionPoint;
  63309. /**
  63310. * Gets the derivative output on x
  63311. */
  63312. get dx(): NodeMaterialConnectionPoint;
  63313. /**
  63314. * Gets the derivative output on y
  63315. */
  63316. get dy(): NodeMaterialConnectionPoint;
  63317. protected _buildBlock(state: NodeMaterialBuildState): this;
  63318. }
  63319. }
  63320. declare module BABYLON {
  63321. /**
  63322. * Block used to make gl_FragCoord available
  63323. */
  63324. export class FragCoordBlock extends NodeMaterialBlock {
  63325. /**
  63326. * Creates a new FragCoordBlock
  63327. * @param name defines the block name
  63328. */
  63329. constructor(name: string);
  63330. /**
  63331. * Gets the current class name
  63332. * @returns the class name
  63333. */
  63334. getClassName(): string;
  63335. /**
  63336. * Gets the xy component
  63337. */
  63338. get xy(): NodeMaterialConnectionPoint;
  63339. /**
  63340. * Gets the xyz component
  63341. */
  63342. get xyz(): NodeMaterialConnectionPoint;
  63343. /**
  63344. * Gets the xyzw component
  63345. */
  63346. get xyzw(): NodeMaterialConnectionPoint;
  63347. /**
  63348. * Gets the x component
  63349. */
  63350. get x(): NodeMaterialConnectionPoint;
  63351. /**
  63352. * Gets the y component
  63353. */
  63354. get y(): NodeMaterialConnectionPoint;
  63355. /**
  63356. * Gets the z component
  63357. */
  63358. get z(): NodeMaterialConnectionPoint;
  63359. /**
  63360. * Gets the w component
  63361. */
  63362. get output(): NodeMaterialConnectionPoint;
  63363. protected writeOutputs(state: NodeMaterialBuildState): string;
  63364. protected _buildBlock(state: NodeMaterialBuildState): this;
  63365. }
  63366. }
  63367. declare module BABYLON {
  63368. /**
  63369. * Block used to get the screen sizes
  63370. */
  63371. export class ScreenSizeBlock extends NodeMaterialBlock {
  63372. private _varName;
  63373. private _scene;
  63374. /**
  63375. * Creates a new ScreenSizeBlock
  63376. * @param name defines the block name
  63377. */
  63378. constructor(name: string);
  63379. /**
  63380. * Gets the current class name
  63381. * @returns the class name
  63382. */
  63383. getClassName(): string;
  63384. /**
  63385. * Gets the xy component
  63386. */
  63387. get xy(): NodeMaterialConnectionPoint;
  63388. /**
  63389. * Gets the x component
  63390. */
  63391. get x(): NodeMaterialConnectionPoint;
  63392. /**
  63393. * Gets the y component
  63394. */
  63395. get y(): NodeMaterialConnectionPoint;
  63396. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63397. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63398. protected _buildBlock(state: NodeMaterialBuildState): this;
  63399. }
  63400. }
  63401. declare module BABYLON {
  63402. /**
  63403. * Block used to add support for scene fog
  63404. */
  63405. export class FogBlock extends NodeMaterialBlock {
  63406. private _fogDistanceName;
  63407. private _fogParameters;
  63408. /**
  63409. * Create a new FogBlock
  63410. * @param name defines the block name
  63411. */
  63412. constructor(name: string);
  63413. /**
  63414. * Gets the current class name
  63415. * @returns the class name
  63416. */
  63417. getClassName(): string;
  63418. /**
  63419. * Gets the world position input component
  63420. */
  63421. get worldPosition(): NodeMaterialConnectionPoint;
  63422. /**
  63423. * Gets the view input component
  63424. */
  63425. get view(): NodeMaterialConnectionPoint;
  63426. /**
  63427. * Gets the color input component
  63428. */
  63429. get input(): NodeMaterialConnectionPoint;
  63430. /**
  63431. * Gets the fog color input component
  63432. */
  63433. get fogColor(): NodeMaterialConnectionPoint;
  63434. /**
  63435. * Gets the output component
  63436. */
  63437. get output(): NodeMaterialConnectionPoint;
  63438. autoConfigure(material: NodeMaterial): void;
  63439. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63440. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63441. protected _buildBlock(state: NodeMaterialBuildState): this;
  63442. }
  63443. }
  63444. declare module BABYLON {
  63445. /**
  63446. * Block used to add light in the fragment shader
  63447. */
  63448. export class LightBlock extends NodeMaterialBlock {
  63449. private _lightId;
  63450. /**
  63451. * Gets or sets the light associated with this block
  63452. */
  63453. light: Nullable<Light>;
  63454. /**
  63455. * Create a new LightBlock
  63456. * @param name defines the block name
  63457. */
  63458. constructor(name: string);
  63459. /**
  63460. * Gets the current class name
  63461. * @returns the class name
  63462. */
  63463. getClassName(): string;
  63464. /**
  63465. * Gets the world position input component
  63466. */
  63467. get worldPosition(): NodeMaterialConnectionPoint;
  63468. /**
  63469. * Gets the world normal input component
  63470. */
  63471. get worldNormal(): NodeMaterialConnectionPoint;
  63472. /**
  63473. * Gets the camera (or eye) position component
  63474. */
  63475. get cameraPosition(): NodeMaterialConnectionPoint;
  63476. /**
  63477. * Gets the glossiness component
  63478. */
  63479. get glossiness(): NodeMaterialConnectionPoint;
  63480. /**
  63481. * Gets the glossinness power component
  63482. */
  63483. get glossPower(): NodeMaterialConnectionPoint;
  63484. /**
  63485. * Gets the diffuse color component
  63486. */
  63487. get diffuseColor(): NodeMaterialConnectionPoint;
  63488. /**
  63489. * Gets the specular color component
  63490. */
  63491. get specularColor(): NodeMaterialConnectionPoint;
  63492. /**
  63493. * Gets the diffuse output component
  63494. */
  63495. get diffuseOutput(): NodeMaterialConnectionPoint;
  63496. /**
  63497. * Gets the specular output component
  63498. */
  63499. get specularOutput(): NodeMaterialConnectionPoint;
  63500. /**
  63501. * Gets the shadow output component
  63502. */
  63503. get shadow(): NodeMaterialConnectionPoint;
  63504. autoConfigure(material: NodeMaterial): void;
  63505. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63506. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63507. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63508. private _injectVertexCode;
  63509. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63510. serialize(): any;
  63511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63512. }
  63513. }
  63514. declare module BABYLON {
  63515. /**
  63516. * Block used to read a reflection texture from a sampler
  63517. */
  63518. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63519. /**
  63520. * Create a new ReflectionTextureBlock
  63521. * @param name defines the block name
  63522. */
  63523. constructor(name: string);
  63524. /**
  63525. * Gets the current class name
  63526. * @returns the class name
  63527. */
  63528. getClassName(): string;
  63529. /**
  63530. * Gets the world position input component
  63531. */
  63532. get position(): NodeMaterialConnectionPoint;
  63533. /**
  63534. * Gets the world position input component
  63535. */
  63536. get worldPosition(): NodeMaterialConnectionPoint;
  63537. /**
  63538. * Gets the world normal input component
  63539. */
  63540. get worldNormal(): NodeMaterialConnectionPoint;
  63541. /**
  63542. * Gets the world input component
  63543. */
  63544. get world(): NodeMaterialConnectionPoint;
  63545. /**
  63546. * Gets the camera (or eye) position component
  63547. */
  63548. get cameraPosition(): NodeMaterialConnectionPoint;
  63549. /**
  63550. * Gets the view input component
  63551. */
  63552. get view(): NodeMaterialConnectionPoint;
  63553. /**
  63554. * Gets the rgb output component
  63555. */
  63556. get rgb(): NodeMaterialConnectionPoint;
  63557. /**
  63558. * Gets the rgba output component
  63559. */
  63560. get rgba(): NodeMaterialConnectionPoint;
  63561. /**
  63562. * Gets the r output component
  63563. */
  63564. get r(): NodeMaterialConnectionPoint;
  63565. /**
  63566. * Gets the g output component
  63567. */
  63568. get g(): NodeMaterialConnectionPoint;
  63569. /**
  63570. * Gets the b output component
  63571. */
  63572. get b(): NodeMaterialConnectionPoint;
  63573. /**
  63574. * Gets the a output component
  63575. */
  63576. get a(): NodeMaterialConnectionPoint;
  63577. autoConfigure(material: NodeMaterial): void;
  63578. protected _buildBlock(state: NodeMaterialBuildState): this;
  63579. }
  63580. }
  63581. declare module BABYLON {
  63582. /**
  63583. * Block used to add 2 vectors
  63584. */
  63585. export class AddBlock extends NodeMaterialBlock {
  63586. /**
  63587. * Creates a new AddBlock
  63588. * @param name defines the block name
  63589. */
  63590. constructor(name: string);
  63591. /**
  63592. * Gets the current class name
  63593. * @returns the class name
  63594. */
  63595. getClassName(): string;
  63596. /**
  63597. * Gets the left operand input component
  63598. */
  63599. get left(): NodeMaterialConnectionPoint;
  63600. /**
  63601. * Gets the right operand input component
  63602. */
  63603. get right(): NodeMaterialConnectionPoint;
  63604. /**
  63605. * Gets the output component
  63606. */
  63607. get output(): NodeMaterialConnectionPoint;
  63608. protected _buildBlock(state: NodeMaterialBuildState): this;
  63609. }
  63610. }
  63611. declare module BABYLON {
  63612. /**
  63613. * Block used to scale a vector by a float
  63614. */
  63615. export class ScaleBlock extends NodeMaterialBlock {
  63616. /**
  63617. * Creates a new ScaleBlock
  63618. * @param name defines the block name
  63619. */
  63620. constructor(name: string);
  63621. /**
  63622. * Gets the current class name
  63623. * @returns the class name
  63624. */
  63625. getClassName(): string;
  63626. /**
  63627. * Gets the input component
  63628. */
  63629. get input(): NodeMaterialConnectionPoint;
  63630. /**
  63631. * Gets the factor input component
  63632. */
  63633. get factor(): NodeMaterialConnectionPoint;
  63634. /**
  63635. * Gets the output component
  63636. */
  63637. get output(): NodeMaterialConnectionPoint;
  63638. protected _buildBlock(state: NodeMaterialBuildState): this;
  63639. }
  63640. }
  63641. declare module BABYLON {
  63642. /**
  63643. * Block used to clamp a float
  63644. */
  63645. export class ClampBlock extends NodeMaterialBlock {
  63646. /** Gets or sets the minimum range */
  63647. minimum: number;
  63648. /** Gets or sets the maximum range */
  63649. maximum: number;
  63650. /**
  63651. * Creates a new ClampBlock
  63652. * @param name defines the block name
  63653. */
  63654. constructor(name: string);
  63655. /**
  63656. * Gets the current class name
  63657. * @returns the class name
  63658. */
  63659. getClassName(): string;
  63660. /**
  63661. * Gets the value input component
  63662. */
  63663. get value(): NodeMaterialConnectionPoint;
  63664. /**
  63665. * Gets the output component
  63666. */
  63667. get output(): NodeMaterialConnectionPoint;
  63668. protected _buildBlock(state: NodeMaterialBuildState): this;
  63669. protected _dumpPropertiesCode(): string;
  63670. serialize(): any;
  63671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63672. }
  63673. }
  63674. declare module BABYLON {
  63675. /**
  63676. * Block used to apply a cross product between 2 vectors
  63677. */
  63678. export class CrossBlock extends NodeMaterialBlock {
  63679. /**
  63680. * Creates a new CrossBlock
  63681. * @param name defines the block name
  63682. */
  63683. constructor(name: string);
  63684. /**
  63685. * Gets the current class name
  63686. * @returns the class name
  63687. */
  63688. getClassName(): string;
  63689. /**
  63690. * Gets the left operand input component
  63691. */
  63692. get left(): NodeMaterialConnectionPoint;
  63693. /**
  63694. * Gets the right operand input component
  63695. */
  63696. get right(): NodeMaterialConnectionPoint;
  63697. /**
  63698. * Gets the output component
  63699. */
  63700. get output(): NodeMaterialConnectionPoint;
  63701. protected _buildBlock(state: NodeMaterialBuildState): this;
  63702. }
  63703. }
  63704. declare module BABYLON {
  63705. /**
  63706. * Block used to apply a dot product between 2 vectors
  63707. */
  63708. export class DotBlock extends NodeMaterialBlock {
  63709. /**
  63710. * Creates a new DotBlock
  63711. * @param name defines the block name
  63712. */
  63713. constructor(name: string);
  63714. /**
  63715. * Gets the current class name
  63716. * @returns the class name
  63717. */
  63718. getClassName(): string;
  63719. /**
  63720. * Gets the left operand input component
  63721. */
  63722. get left(): NodeMaterialConnectionPoint;
  63723. /**
  63724. * Gets the right operand input component
  63725. */
  63726. get right(): NodeMaterialConnectionPoint;
  63727. /**
  63728. * Gets the output component
  63729. */
  63730. get output(): NodeMaterialConnectionPoint;
  63731. protected _buildBlock(state: NodeMaterialBuildState): this;
  63732. }
  63733. }
  63734. declare module BABYLON {
  63735. /**
  63736. * Block used to normalize a vector
  63737. */
  63738. export class NormalizeBlock extends NodeMaterialBlock {
  63739. /**
  63740. * Creates a new NormalizeBlock
  63741. * @param name defines the block name
  63742. */
  63743. constructor(name: string);
  63744. /**
  63745. * Gets the current class name
  63746. * @returns the class name
  63747. */
  63748. getClassName(): string;
  63749. /**
  63750. * Gets the input component
  63751. */
  63752. get input(): NodeMaterialConnectionPoint;
  63753. /**
  63754. * Gets the output component
  63755. */
  63756. get output(): NodeMaterialConnectionPoint;
  63757. protected _buildBlock(state: NodeMaterialBuildState): this;
  63758. }
  63759. }
  63760. declare module BABYLON {
  63761. /**
  63762. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63763. */
  63764. export class ColorMergerBlock extends NodeMaterialBlock {
  63765. /**
  63766. * Create a new ColorMergerBlock
  63767. * @param name defines the block name
  63768. */
  63769. constructor(name: string);
  63770. /**
  63771. * Gets the current class name
  63772. * @returns the class name
  63773. */
  63774. getClassName(): string;
  63775. /**
  63776. * Gets the rgb component (input)
  63777. */
  63778. get rgbIn(): NodeMaterialConnectionPoint;
  63779. /**
  63780. * Gets the r component (input)
  63781. */
  63782. get r(): NodeMaterialConnectionPoint;
  63783. /**
  63784. * Gets the g component (input)
  63785. */
  63786. get g(): NodeMaterialConnectionPoint;
  63787. /**
  63788. * Gets the b component (input)
  63789. */
  63790. get b(): NodeMaterialConnectionPoint;
  63791. /**
  63792. * Gets the a component (input)
  63793. */
  63794. get a(): NodeMaterialConnectionPoint;
  63795. /**
  63796. * Gets the rgba component (output)
  63797. */
  63798. get rgba(): NodeMaterialConnectionPoint;
  63799. /**
  63800. * Gets the rgb component (output)
  63801. */
  63802. get rgbOut(): NodeMaterialConnectionPoint;
  63803. /**
  63804. * Gets the rgb component (output)
  63805. * @deprecated Please use rgbOut instead.
  63806. */
  63807. get rgb(): NodeMaterialConnectionPoint;
  63808. protected _buildBlock(state: NodeMaterialBuildState): this;
  63809. }
  63810. }
  63811. declare module BABYLON {
  63812. /**
  63813. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63814. */
  63815. export class VectorSplitterBlock extends NodeMaterialBlock {
  63816. /**
  63817. * Create a new VectorSplitterBlock
  63818. * @param name defines the block name
  63819. */
  63820. constructor(name: string);
  63821. /**
  63822. * Gets the current class name
  63823. * @returns the class name
  63824. */
  63825. getClassName(): string;
  63826. /**
  63827. * Gets the xyzw component (input)
  63828. */
  63829. get xyzw(): NodeMaterialConnectionPoint;
  63830. /**
  63831. * Gets the xyz component (input)
  63832. */
  63833. get xyzIn(): NodeMaterialConnectionPoint;
  63834. /**
  63835. * Gets the xy component (input)
  63836. */
  63837. get xyIn(): NodeMaterialConnectionPoint;
  63838. /**
  63839. * Gets the xyz component (output)
  63840. */
  63841. get xyzOut(): NodeMaterialConnectionPoint;
  63842. /**
  63843. * Gets the xy component (output)
  63844. */
  63845. get xyOut(): NodeMaterialConnectionPoint;
  63846. /**
  63847. * Gets the x component (output)
  63848. */
  63849. get x(): NodeMaterialConnectionPoint;
  63850. /**
  63851. * Gets the y component (output)
  63852. */
  63853. get y(): NodeMaterialConnectionPoint;
  63854. /**
  63855. * Gets the z component (output)
  63856. */
  63857. get z(): NodeMaterialConnectionPoint;
  63858. /**
  63859. * Gets the w component (output)
  63860. */
  63861. get w(): NodeMaterialConnectionPoint;
  63862. protected _inputRename(name: string): string;
  63863. protected _outputRename(name: string): string;
  63864. protected _buildBlock(state: NodeMaterialBuildState): this;
  63865. }
  63866. }
  63867. declare module BABYLON {
  63868. /**
  63869. * Block used to lerp between 2 values
  63870. */
  63871. export class LerpBlock extends NodeMaterialBlock {
  63872. /**
  63873. * Creates a new LerpBlock
  63874. * @param name defines the block name
  63875. */
  63876. constructor(name: string);
  63877. /**
  63878. * Gets the current class name
  63879. * @returns the class name
  63880. */
  63881. getClassName(): string;
  63882. /**
  63883. * Gets the left operand input component
  63884. */
  63885. get left(): NodeMaterialConnectionPoint;
  63886. /**
  63887. * Gets the right operand input component
  63888. */
  63889. get right(): NodeMaterialConnectionPoint;
  63890. /**
  63891. * Gets the gradient operand input component
  63892. */
  63893. get gradient(): NodeMaterialConnectionPoint;
  63894. /**
  63895. * Gets the output component
  63896. */
  63897. get output(): NodeMaterialConnectionPoint;
  63898. protected _buildBlock(state: NodeMaterialBuildState): this;
  63899. }
  63900. }
  63901. declare module BABYLON {
  63902. /**
  63903. * Block used to divide 2 vectors
  63904. */
  63905. export class DivideBlock extends NodeMaterialBlock {
  63906. /**
  63907. * Creates a new DivideBlock
  63908. * @param name defines the block name
  63909. */
  63910. constructor(name: string);
  63911. /**
  63912. * Gets the current class name
  63913. * @returns the class name
  63914. */
  63915. getClassName(): string;
  63916. /**
  63917. * Gets the left operand input component
  63918. */
  63919. get left(): NodeMaterialConnectionPoint;
  63920. /**
  63921. * Gets the right operand input component
  63922. */
  63923. get right(): NodeMaterialConnectionPoint;
  63924. /**
  63925. * Gets the output component
  63926. */
  63927. get output(): NodeMaterialConnectionPoint;
  63928. protected _buildBlock(state: NodeMaterialBuildState): this;
  63929. }
  63930. }
  63931. declare module BABYLON {
  63932. /**
  63933. * Block used to subtract 2 vectors
  63934. */
  63935. export class SubtractBlock extends NodeMaterialBlock {
  63936. /**
  63937. * Creates a new SubtractBlock
  63938. * @param name defines the block name
  63939. */
  63940. constructor(name: string);
  63941. /**
  63942. * Gets the current class name
  63943. * @returns the class name
  63944. */
  63945. getClassName(): string;
  63946. /**
  63947. * Gets the left operand input component
  63948. */
  63949. get left(): NodeMaterialConnectionPoint;
  63950. /**
  63951. * Gets the right operand input component
  63952. */
  63953. get right(): NodeMaterialConnectionPoint;
  63954. /**
  63955. * Gets the output component
  63956. */
  63957. get output(): NodeMaterialConnectionPoint;
  63958. protected _buildBlock(state: NodeMaterialBuildState): this;
  63959. }
  63960. }
  63961. declare module BABYLON {
  63962. /**
  63963. * Block used to step a value
  63964. */
  63965. export class StepBlock extends NodeMaterialBlock {
  63966. /**
  63967. * Creates a new StepBlock
  63968. * @param name defines the block name
  63969. */
  63970. constructor(name: string);
  63971. /**
  63972. * Gets the current class name
  63973. * @returns the class name
  63974. */
  63975. getClassName(): string;
  63976. /**
  63977. * Gets the value operand input component
  63978. */
  63979. get value(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the edge operand input component
  63982. */
  63983. get edge(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the output component
  63986. */
  63987. get output(): NodeMaterialConnectionPoint;
  63988. protected _buildBlock(state: NodeMaterialBuildState): this;
  63989. }
  63990. }
  63991. declare module BABYLON {
  63992. /**
  63993. * Block used to get the opposite (1 - x) of a value
  63994. */
  63995. export class OneMinusBlock extends NodeMaterialBlock {
  63996. /**
  63997. * Creates a new OneMinusBlock
  63998. * @param name defines the block name
  63999. */
  64000. constructor(name: string);
  64001. /**
  64002. * Gets the current class name
  64003. * @returns the class name
  64004. */
  64005. getClassName(): string;
  64006. /**
  64007. * Gets the input component
  64008. */
  64009. get input(): NodeMaterialConnectionPoint;
  64010. /**
  64011. * Gets the output component
  64012. */
  64013. get output(): NodeMaterialConnectionPoint;
  64014. protected _buildBlock(state: NodeMaterialBuildState): this;
  64015. }
  64016. }
  64017. declare module BABYLON {
  64018. /**
  64019. * Block used to get the view direction
  64020. */
  64021. export class ViewDirectionBlock extends NodeMaterialBlock {
  64022. /**
  64023. * Creates a new ViewDirectionBlock
  64024. * @param name defines the block name
  64025. */
  64026. constructor(name: string);
  64027. /**
  64028. * Gets the current class name
  64029. * @returns the class name
  64030. */
  64031. getClassName(): string;
  64032. /**
  64033. * Gets the world position component
  64034. */
  64035. get worldPosition(): NodeMaterialConnectionPoint;
  64036. /**
  64037. * Gets the camera position component
  64038. */
  64039. get cameraPosition(): NodeMaterialConnectionPoint;
  64040. /**
  64041. * Gets the output component
  64042. */
  64043. get output(): NodeMaterialConnectionPoint;
  64044. autoConfigure(material: NodeMaterial): void;
  64045. protected _buildBlock(state: NodeMaterialBuildState): this;
  64046. }
  64047. }
  64048. declare module BABYLON {
  64049. /**
  64050. * Block used to compute fresnel value
  64051. */
  64052. export class FresnelBlock extends NodeMaterialBlock {
  64053. /**
  64054. * Create a new FresnelBlock
  64055. * @param name defines the block name
  64056. */
  64057. constructor(name: string);
  64058. /**
  64059. * Gets the current class name
  64060. * @returns the class name
  64061. */
  64062. getClassName(): string;
  64063. /**
  64064. * Gets the world normal input component
  64065. */
  64066. get worldNormal(): NodeMaterialConnectionPoint;
  64067. /**
  64068. * Gets the view direction input component
  64069. */
  64070. get viewDirection(): NodeMaterialConnectionPoint;
  64071. /**
  64072. * Gets the bias input component
  64073. */
  64074. get bias(): NodeMaterialConnectionPoint;
  64075. /**
  64076. * Gets the camera (or eye) position component
  64077. */
  64078. get power(): NodeMaterialConnectionPoint;
  64079. /**
  64080. * Gets the fresnel output component
  64081. */
  64082. get fresnel(): NodeMaterialConnectionPoint;
  64083. autoConfigure(material: NodeMaterial): void;
  64084. protected _buildBlock(state: NodeMaterialBuildState): this;
  64085. }
  64086. }
  64087. declare module BABYLON {
  64088. /**
  64089. * Block used to get the max of 2 values
  64090. */
  64091. export class MaxBlock extends NodeMaterialBlock {
  64092. /**
  64093. * Creates a new MaxBlock
  64094. * @param name defines the block name
  64095. */
  64096. constructor(name: string);
  64097. /**
  64098. * Gets the current class name
  64099. * @returns the class name
  64100. */
  64101. getClassName(): string;
  64102. /**
  64103. * Gets the left operand input component
  64104. */
  64105. get left(): NodeMaterialConnectionPoint;
  64106. /**
  64107. * Gets the right operand input component
  64108. */
  64109. get right(): NodeMaterialConnectionPoint;
  64110. /**
  64111. * Gets the output component
  64112. */
  64113. get output(): NodeMaterialConnectionPoint;
  64114. protected _buildBlock(state: NodeMaterialBuildState): this;
  64115. }
  64116. }
  64117. declare module BABYLON {
  64118. /**
  64119. * Block used to get the min of 2 values
  64120. */
  64121. export class MinBlock extends NodeMaterialBlock {
  64122. /**
  64123. * Creates a new MinBlock
  64124. * @param name defines the block name
  64125. */
  64126. constructor(name: string);
  64127. /**
  64128. * Gets the current class name
  64129. * @returns the class name
  64130. */
  64131. getClassName(): string;
  64132. /**
  64133. * Gets the left operand input component
  64134. */
  64135. get left(): NodeMaterialConnectionPoint;
  64136. /**
  64137. * Gets the right operand input component
  64138. */
  64139. get right(): NodeMaterialConnectionPoint;
  64140. /**
  64141. * Gets the output component
  64142. */
  64143. get output(): NodeMaterialConnectionPoint;
  64144. protected _buildBlock(state: NodeMaterialBuildState): this;
  64145. }
  64146. }
  64147. declare module BABYLON {
  64148. /**
  64149. * Block used to get the distance between 2 values
  64150. */
  64151. export class DistanceBlock extends NodeMaterialBlock {
  64152. /**
  64153. * Creates a new DistanceBlock
  64154. * @param name defines the block name
  64155. */
  64156. constructor(name: string);
  64157. /**
  64158. * Gets the current class name
  64159. * @returns the class name
  64160. */
  64161. getClassName(): string;
  64162. /**
  64163. * Gets the left operand input component
  64164. */
  64165. get left(): NodeMaterialConnectionPoint;
  64166. /**
  64167. * Gets the right operand input component
  64168. */
  64169. get right(): NodeMaterialConnectionPoint;
  64170. /**
  64171. * Gets the output component
  64172. */
  64173. get output(): NodeMaterialConnectionPoint;
  64174. protected _buildBlock(state: NodeMaterialBuildState): this;
  64175. }
  64176. }
  64177. declare module BABYLON {
  64178. /**
  64179. * Block used to get the length of a vector
  64180. */
  64181. export class LengthBlock extends NodeMaterialBlock {
  64182. /**
  64183. * Creates a new LengthBlock
  64184. * @param name defines the block name
  64185. */
  64186. constructor(name: string);
  64187. /**
  64188. * Gets the current class name
  64189. * @returns the class name
  64190. */
  64191. getClassName(): string;
  64192. /**
  64193. * Gets the value input component
  64194. */
  64195. get value(): NodeMaterialConnectionPoint;
  64196. /**
  64197. * Gets the output component
  64198. */
  64199. get output(): NodeMaterialConnectionPoint;
  64200. protected _buildBlock(state: NodeMaterialBuildState): this;
  64201. }
  64202. }
  64203. declare module BABYLON {
  64204. /**
  64205. * Block used to get negative version of a value (i.e. x * -1)
  64206. */
  64207. export class NegateBlock extends NodeMaterialBlock {
  64208. /**
  64209. * Creates a new NegateBlock
  64210. * @param name defines the block name
  64211. */
  64212. constructor(name: string);
  64213. /**
  64214. * Gets the current class name
  64215. * @returns the class name
  64216. */
  64217. getClassName(): string;
  64218. /**
  64219. * Gets the value input component
  64220. */
  64221. get value(): NodeMaterialConnectionPoint;
  64222. /**
  64223. * Gets the output component
  64224. */
  64225. get output(): NodeMaterialConnectionPoint;
  64226. protected _buildBlock(state: NodeMaterialBuildState): this;
  64227. }
  64228. }
  64229. declare module BABYLON {
  64230. /**
  64231. * Block used to get the value of the first parameter raised to the power of the second
  64232. */
  64233. export class PowBlock extends NodeMaterialBlock {
  64234. /**
  64235. * Creates a new PowBlock
  64236. * @param name defines the block name
  64237. */
  64238. constructor(name: string);
  64239. /**
  64240. * Gets the current class name
  64241. * @returns the class name
  64242. */
  64243. getClassName(): string;
  64244. /**
  64245. * Gets the value operand input component
  64246. */
  64247. get value(): NodeMaterialConnectionPoint;
  64248. /**
  64249. * Gets the power operand input component
  64250. */
  64251. get power(): NodeMaterialConnectionPoint;
  64252. /**
  64253. * Gets the output component
  64254. */
  64255. get output(): NodeMaterialConnectionPoint;
  64256. protected _buildBlock(state: NodeMaterialBuildState): this;
  64257. }
  64258. }
  64259. declare module BABYLON {
  64260. /**
  64261. * Block used to get a random number
  64262. */
  64263. export class RandomNumberBlock extends NodeMaterialBlock {
  64264. /**
  64265. * Creates a new RandomNumberBlock
  64266. * @param name defines the block name
  64267. */
  64268. constructor(name: string);
  64269. /**
  64270. * Gets the current class name
  64271. * @returns the class name
  64272. */
  64273. getClassName(): string;
  64274. /**
  64275. * Gets the seed input component
  64276. */
  64277. get seed(): NodeMaterialConnectionPoint;
  64278. /**
  64279. * Gets the output component
  64280. */
  64281. get output(): NodeMaterialConnectionPoint;
  64282. protected _buildBlock(state: NodeMaterialBuildState): this;
  64283. }
  64284. }
  64285. declare module BABYLON {
  64286. /**
  64287. * Block used to compute arc tangent of 2 values
  64288. */
  64289. export class ArcTan2Block extends NodeMaterialBlock {
  64290. /**
  64291. * Creates a new ArcTan2Block
  64292. * @param name defines the block name
  64293. */
  64294. constructor(name: string);
  64295. /**
  64296. * Gets the current class name
  64297. * @returns the class name
  64298. */
  64299. getClassName(): string;
  64300. /**
  64301. * Gets the x operand input component
  64302. */
  64303. get x(): NodeMaterialConnectionPoint;
  64304. /**
  64305. * Gets the y operand input component
  64306. */
  64307. get y(): NodeMaterialConnectionPoint;
  64308. /**
  64309. * Gets the output component
  64310. */
  64311. get output(): NodeMaterialConnectionPoint;
  64312. protected _buildBlock(state: NodeMaterialBuildState): this;
  64313. }
  64314. }
  64315. declare module BABYLON {
  64316. /**
  64317. * Block used to smooth step a value
  64318. */
  64319. export class SmoothStepBlock extends NodeMaterialBlock {
  64320. /**
  64321. * Creates a new SmoothStepBlock
  64322. * @param name defines the block name
  64323. */
  64324. constructor(name: string);
  64325. /**
  64326. * Gets the current class name
  64327. * @returns the class name
  64328. */
  64329. getClassName(): string;
  64330. /**
  64331. * Gets the value operand input component
  64332. */
  64333. get value(): NodeMaterialConnectionPoint;
  64334. /**
  64335. * Gets the first edge operand input component
  64336. */
  64337. get edge0(): NodeMaterialConnectionPoint;
  64338. /**
  64339. * Gets the second edge operand input component
  64340. */
  64341. get edge1(): NodeMaterialConnectionPoint;
  64342. /**
  64343. * Gets the output component
  64344. */
  64345. get output(): NodeMaterialConnectionPoint;
  64346. protected _buildBlock(state: NodeMaterialBuildState): this;
  64347. }
  64348. }
  64349. declare module BABYLON {
  64350. /**
  64351. * Block used to get the reciprocal (1 / x) of a value
  64352. */
  64353. export class ReciprocalBlock extends NodeMaterialBlock {
  64354. /**
  64355. * Creates a new ReciprocalBlock
  64356. * @param name defines the block name
  64357. */
  64358. constructor(name: string);
  64359. /**
  64360. * Gets the current class name
  64361. * @returns the class name
  64362. */
  64363. getClassName(): string;
  64364. /**
  64365. * Gets the input component
  64366. */
  64367. get input(): NodeMaterialConnectionPoint;
  64368. /**
  64369. * Gets the output component
  64370. */
  64371. get output(): NodeMaterialConnectionPoint;
  64372. protected _buildBlock(state: NodeMaterialBuildState): this;
  64373. }
  64374. }
  64375. declare module BABYLON {
  64376. /**
  64377. * Block used to replace a color by another one
  64378. */
  64379. export class ReplaceColorBlock extends NodeMaterialBlock {
  64380. /**
  64381. * Creates a new ReplaceColorBlock
  64382. * @param name defines the block name
  64383. */
  64384. constructor(name: string);
  64385. /**
  64386. * Gets the current class name
  64387. * @returns the class name
  64388. */
  64389. getClassName(): string;
  64390. /**
  64391. * Gets the value input component
  64392. */
  64393. get value(): NodeMaterialConnectionPoint;
  64394. /**
  64395. * Gets the reference input component
  64396. */
  64397. get reference(): NodeMaterialConnectionPoint;
  64398. /**
  64399. * Gets the distance input component
  64400. */
  64401. get distance(): NodeMaterialConnectionPoint;
  64402. /**
  64403. * Gets the replacement input component
  64404. */
  64405. get replacement(): NodeMaterialConnectionPoint;
  64406. /**
  64407. * Gets the output component
  64408. */
  64409. get output(): NodeMaterialConnectionPoint;
  64410. protected _buildBlock(state: NodeMaterialBuildState): this;
  64411. }
  64412. }
  64413. declare module BABYLON {
  64414. /**
  64415. * Block used to posterize a value
  64416. * @see https://en.wikipedia.org/wiki/Posterization
  64417. */
  64418. export class PosterizeBlock extends NodeMaterialBlock {
  64419. /**
  64420. * Creates a new PosterizeBlock
  64421. * @param name defines the block name
  64422. */
  64423. constructor(name: string);
  64424. /**
  64425. * Gets the current class name
  64426. * @returns the class name
  64427. */
  64428. getClassName(): string;
  64429. /**
  64430. * Gets the value input component
  64431. */
  64432. get value(): NodeMaterialConnectionPoint;
  64433. /**
  64434. * Gets the steps input component
  64435. */
  64436. get steps(): NodeMaterialConnectionPoint;
  64437. /**
  64438. * Gets the output component
  64439. */
  64440. get output(): NodeMaterialConnectionPoint;
  64441. protected _buildBlock(state: NodeMaterialBuildState): this;
  64442. }
  64443. }
  64444. declare module BABYLON {
  64445. /**
  64446. * Operations supported by the Wave block
  64447. */
  64448. export enum WaveBlockKind {
  64449. /** SawTooth */
  64450. SawTooth = 0,
  64451. /** Square */
  64452. Square = 1,
  64453. /** Triangle */
  64454. Triangle = 2
  64455. }
  64456. /**
  64457. * Block used to apply wave operation to floats
  64458. */
  64459. export class WaveBlock extends NodeMaterialBlock {
  64460. /**
  64461. * Gets or sets the kibnd of wave to be applied by the block
  64462. */
  64463. kind: WaveBlockKind;
  64464. /**
  64465. * Creates a new WaveBlock
  64466. * @param name defines the block name
  64467. */
  64468. constructor(name: string);
  64469. /**
  64470. * Gets the current class name
  64471. * @returns the class name
  64472. */
  64473. getClassName(): string;
  64474. /**
  64475. * Gets the input component
  64476. */
  64477. get input(): NodeMaterialConnectionPoint;
  64478. /**
  64479. * Gets the output component
  64480. */
  64481. get output(): NodeMaterialConnectionPoint;
  64482. protected _buildBlock(state: NodeMaterialBuildState): this;
  64483. serialize(): any;
  64484. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64485. }
  64486. }
  64487. declare module BABYLON {
  64488. /**
  64489. * Class used to store a color step for the GradientBlock
  64490. */
  64491. export class GradientBlockColorStep {
  64492. private _step;
  64493. /**
  64494. * Gets value indicating which step this color is associated with (between 0 and 1)
  64495. */
  64496. get step(): number;
  64497. /**
  64498. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64499. */
  64500. set step(val: number);
  64501. private _color;
  64502. /**
  64503. * Gets the color associated with this step
  64504. */
  64505. get color(): Color3;
  64506. /**
  64507. * Sets the color associated with this step
  64508. */
  64509. set color(val: Color3);
  64510. /**
  64511. * Creates a new GradientBlockColorStep
  64512. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64513. * @param color defines the color associated with this step
  64514. */
  64515. constructor(step: number, color: Color3);
  64516. }
  64517. /**
  64518. * Block used to return a color from a gradient based on an input value between 0 and 1
  64519. */
  64520. export class GradientBlock extends NodeMaterialBlock {
  64521. /**
  64522. * Gets or sets the list of color steps
  64523. */
  64524. colorSteps: GradientBlockColorStep[];
  64525. /** Gets an observable raised when the value is changed */
  64526. onValueChangedObservable: Observable<GradientBlock>;
  64527. /** calls observable when the value is changed*/
  64528. colorStepsUpdated(): void;
  64529. /**
  64530. * Creates a new GradientBlock
  64531. * @param name defines the block name
  64532. */
  64533. constructor(name: string);
  64534. /**
  64535. * Gets the current class name
  64536. * @returns the class name
  64537. */
  64538. getClassName(): string;
  64539. /**
  64540. * Gets the gradient input component
  64541. */
  64542. get gradient(): NodeMaterialConnectionPoint;
  64543. /**
  64544. * Gets the output component
  64545. */
  64546. get output(): NodeMaterialConnectionPoint;
  64547. private _writeColorConstant;
  64548. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64549. serialize(): any;
  64550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64551. protected _dumpPropertiesCode(): string;
  64552. }
  64553. }
  64554. declare module BABYLON {
  64555. /**
  64556. * Block used to normalize lerp between 2 values
  64557. */
  64558. export class NLerpBlock extends NodeMaterialBlock {
  64559. /**
  64560. * Creates a new NLerpBlock
  64561. * @param name defines the block name
  64562. */
  64563. constructor(name: string);
  64564. /**
  64565. * Gets the current class name
  64566. * @returns the class name
  64567. */
  64568. getClassName(): string;
  64569. /**
  64570. * Gets the left operand input component
  64571. */
  64572. get left(): NodeMaterialConnectionPoint;
  64573. /**
  64574. * Gets the right operand input component
  64575. */
  64576. get right(): NodeMaterialConnectionPoint;
  64577. /**
  64578. * Gets the gradient operand input component
  64579. */
  64580. get gradient(): NodeMaterialConnectionPoint;
  64581. /**
  64582. * Gets the output component
  64583. */
  64584. get output(): NodeMaterialConnectionPoint;
  64585. protected _buildBlock(state: NodeMaterialBuildState): this;
  64586. }
  64587. }
  64588. declare module BABYLON {
  64589. /**
  64590. * block used to Generate a Worley Noise 3D Noise Pattern
  64591. */
  64592. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64593. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64594. manhattanDistance: boolean;
  64595. /**
  64596. * Creates a new WorleyNoise3DBlock
  64597. * @param name defines the block name
  64598. */
  64599. constructor(name: string);
  64600. /**
  64601. * Gets the current class name
  64602. * @returns the class name
  64603. */
  64604. getClassName(): string;
  64605. /**
  64606. * Gets the seed input component
  64607. */
  64608. get seed(): NodeMaterialConnectionPoint;
  64609. /**
  64610. * Gets the jitter input component
  64611. */
  64612. get jitter(): NodeMaterialConnectionPoint;
  64613. /**
  64614. * Gets the output component
  64615. */
  64616. get output(): NodeMaterialConnectionPoint;
  64617. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64618. /**
  64619. * Exposes the properties to the UI?
  64620. */
  64621. protected _dumpPropertiesCode(): string;
  64622. /**
  64623. * Exposes the properties to the Seralize?
  64624. */
  64625. serialize(): any;
  64626. /**
  64627. * Exposes the properties to the deseralize?
  64628. */
  64629. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64630. }
  64631. }
  64632. declare module BABYLON {
  64633. /**
  64634. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64635. */
  64636. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64637. /**
  64638. * Creates a new SimplexPerlin3DBlock
  64639. * @param name defines the block name
  64640. */
  64641. constructor(name: string);
  64642. /**
  64643. * Gets the current class name
  64644. * @returns the class name
  64645. */
  64646. getClassName(): string;
  64647. /**
  64648. * Gets the seed operand input component
  64649. */
  64650. get seed(): NodeMaterialConnectionPoint;
  64651. /**
  64652. * Gets the output component
  64653. */
  64654. get output(): NodeMaterialConnectionPoint;
  64655. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64656. }
  64657. }
  64658. declare module BABYLON {
  64659. /**
  64660. * Block used to blend normals
  64661. */
  64662. export class NormalBlendBlock extends NodeMaterialBlock {
  64663. /**
  64664. * Creates a new NormalBlendBlock
  64665. * @param name defines the block name
  64666. */
  64667. constructor(name: string);
  64668. /**
  64669. * Gets the current class name
  64670. * @returns the class name
  64671. */
  64672. getClassName(): string;
  64673. /**
  64674. * Gets the first input component
  64675. */
  64676. get normalMap0(): NodeMaterialConnectionPoint;
  64677. /**
  64678. * Gets the second input component
  64679. */
  64680. get normalMap1(): NodeMaterialConnectionPoint;
  64681. /**
  64682. * Gets the output component
  64683. */
  64684. get output(): NodeMaterialConnectionPoint;
  64685. protected _buildBlock(state: NodeMaterialBuildState): this;
  64686. }
  64687. }
  64688. declare module BABYLON {
  64689. /**
  64690. * Block used to rotate a 2d vector by a given angle
  64691. */
  64692. export class Rotate2dBlock extends NodeMaterialBlock {
  64693. /**
  64694. * Creates a new Rotate2dBlock
  64695. * @param name defines the block name
  64696. */
  64697. constructor(name: string);
  64698. /**
  64699. * Gets the current class name
  64700. * @returns the class name
  64701. */
  64702. getClassName(): string;
  64703. /**
  64704. * Gets the input vector
  64705. */
  64706. get input(): NodeMaterialConnectionPoint;
  64707. /**
  64708. * Gets the input angle
  64709. */
  64710. get angle(): NodeMaterialConnectionPoint;
  64711. /**
  64712. * Gets the output component
  64713. */
  64714. get output(): NodeMaterialConnectionPoint;
  64715. autoConfigure(material: NodeMaterial): void;
  64716. protected _buildBlock(state: NodeMaterialBuildState): this;
  64717. }
  64718. }
  64719. declare module BABYLON {
  64720. /**
  64721. * Block used to get the reflected vector from a direction and a normal
  64722. */
  64723. export class ReflectBlock extends NodeMaterialBlock {
  64724. /**
  64725. * Creates a new ReflectBlock
  64726. * @param name defines the block name
  64727. */
  64728. constructor(name: string);
  64729. /**
  64730. * Gets the current class name
  64731. * @returns the class name
  64732. */
  64733. getClassName(): string;
  64734. /**
  64735. * Gets the incident component
  64736. */
  64737. get incident(): NodeMaterialConnectionPoint;
  64738. /**
  64739. * Gets the normal component
  64740. */
  64741. get normal(): NodeMaterialConnectionPoint;
  64742. /**
  64743. * Gets the output component
  64744. */
  64745. get output(): NodeMaterialConnectionPoint;
  64746. protected _buildBlock(state: NodeMaterialBuildState): this;
  64747. }
  64748. }
  64749. declare module BABYLON {
  64750. /**
  64751. * Block used to get the refracted vector from a direction and a normal
  64752. */
  64753. export class RefractBlock extends NodeMaterialBlock {
  64754. /**
  64755. * Creates a new RefractBlock
  64756. * @param name defines the block name
  64757. */
  64758. constructor(name: string);
  64759. /**
  64760. * Gets the current class name
  64761. * @returns the class name
  64762. */
  64763. getClassName(): string;
  64764. /**
  64765. * Gets the incident component
  64766. */
  64767. get incident(): NodeMaterialConnectionPoint;
  64768. /**
  64769. * Gets the normal component
  64770. */
  64771. get normal(): NodeMaterialConnectionPoint;
  64772. /**
  64773. * Gets the index of refraction component
  64774. */
  64775. get ior(): NodeMaterialConnectionPoint;
  64776. /**
  64777. * Gets the output component
  64778. */
  64779. get output(): NodeMaterialConnectionPoint;
  64780. protected _buildBlock(state: NodeMaterialBuildState): this;
  64781. }
  64782. }
  64783. declare module BABYLON {
  64784. /**
  64785. * Block used to desaturate a color
  64786. */
  64787. export class DesaturateBlock extends NodeMaterialBlock {
  64788. /**
  64789. * Creates a new DesaturateBlock
  64790. * @param name defines the block name
  64791. */
  64792. constructor(name: string);
  64793. /**
  64794. * Gets the current class name
  64795. * @returns the class name
  64796. */
  64797. getClassName(): string;
  64798. /**
  64799. * Gets the color operand input component
  64800. */
  64801. get color(): NodeMaterialConnectionPoint;
  64802. /**
  64803. * Gets the level operand input component
  64804. */
  64805. get level(): NodeMaterialConnectionPoint;
  64806. /**
  64807. * Gets the output component
  64808. */
  64809. get output(): NodeMaterialConnectionPoint;
  64810. protected _buildBlock(state: NodeMaterialBuildState): this;
  64811. }
  64812. }
  64813. declare module BABYLON {
  64814. /**
  64815. * Block used to implement the ambient occlusion module of the PBR material
  64816. */
  64817. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64818. /**
  64819. * Create a new AmbientOcclusionBlock
  64820. * @param name defines the block name
  64821. */
  64822. constructor(name: string);
  64823. /**
  64824. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64825. */
  64826. useAmbientInGrayScale: boolean;
  64827. /**
  64828. * Initialize the block and prepare the context for build
  64829. * @param state defines the state that will be used for the build
  64830. */
  64831. initialize(state: NodeMaterialBuildState): void;
  64832. /**
  64833. * Gets the current class name
  64834. * @returns the class name
  64835. */
  64836. getClassName(): string;
  64837. /**
  64838. * Gets the texture input component
  64839. */
  64840. get texture(): NodeMaterialConnectionPoint;
  64841. /**
  64842. * Gets the texture intensity component
  64843. */
  64844. get intensity(): NodeMaterialConnectionPoint;
  64845. /**
  64846. * Gets the direct light intensity input component
  64847. */
  64848. get directLightIntensity(): NodeMaterialConnectionPoint;
  64849. /**
  64850. * Gets the ambient occlusion object output component
  64851. */
  64852. get ambientOcc(): NodeMaterialConnectionPoint;
  64853. /**
  64854. * Gets the main code of the block (fragment side)
  64855. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64856. * @returns the shader code
  64857. */
  64858. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64859. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64860. protected _buildBlock(state: NodeMaterialBuildState): this;
  64861. protected _dumpPropertiesCode(): string;
  64862. serialize(): any;
  64863. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64864. }
  64865. }
  64866. declare module BABYLON {
  64867. /**
  64868. * Block used to implement the reflection module of the PBR material
  64869. */
  64870. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64871. /** @hidden */
  64872. _defineLODReflectionAlpha: string;
  64873. /** @hidden */
  64874. _defineLinearSpecularReflection: string;
  64875. private _vEnvironmentIrradianceName;
  64876. /** @hidden */
  64877. _vReflectionMicrosurfaceInfosName: string;
  64878. /** @hidden */
  64879. _vReflectionInfosName: string;
  64880. /** @hidden */
  64881. _vReflectionFilteringInfoName: string;
  64882. private _scene;
  64883. /**
  64884. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64885. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64886. * It's less burden on the user side in the editor part.
  64887. */
  64888. /** @hidden */
  64889. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64890. /** @hidden */
  64891. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64892. /** @hidden */
  64893. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64894. /**
  64895. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64896. * diffuse part of the IBL.
  64897. */
  64898. useSphericalHarmonics: boolean;
  64899. /**
  64900. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64901. */
  64902. forceIrradianceInFragment: boolean;
  64903. /**
  64904. * Create a new ReflectionBlock
  64905. * @param name defines the block name
  64906. */
  64907. constructor(name: string);
  64908. /**
  64909. * Gets the current class name
  64910. * @returns the class name
  64911. */
  64912. getClassName(): string;
  64913. /**
  64914. * Gets the position input component
  64915. */
  64916. get position(): NodeMaterialConnectionPoint;
  64917. /**
  64918. * Gets the world position input component
  64919. */
  64920. get worldPosition(): NodeMaterialConnectionPoint;
  64921. /**
  64922. * Gets the world normal input component
  64923. */
  64924. get worldNormal(): NodeMaterialConnectionPoint;
  64925. /**
  64926. * Gets the world input component
  64927. */
  64928. get world(): NodeMaterialConnectionPoint;
  64929. /**
  64930. * Gets the camera (or eye) position component
  64931. */
  64932. get cameraPosition(): NodeMaterialConnectionPoint;
  64933. /**
  64934. * Gets the view input component
  64935. */
  64936. get view(): NodeMaterialConnectionPoint;
  64937. /**
  64938. * Gets the color input component
  64939. */
  64940. get color(): NodeMaterialConnectionPoint;
  64941. /**
  64942. * Gets the reflection object output component
  64943. */
  64944. get reflection(): NodeMaterialConnectionPoint;
  64945. /**
  64946. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64947. */
  64948. get hasTexture(): boolean;
  64949. /**
  64950. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64951. */
  64952. get reflectionColor(): string;
  64953. protected _getTexture(): Nullable<BaseTexture>;
  64954. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64955. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64956. /**
  64957. * Gets the code to inject in the vertex shader
  64958. * @param state current state of the node material building
  64959. * @returns the shader code
  64960. */
  64961. handleVertexSide(state: NodeMaterialBuildState): string;
  64962. /**
  64963. * Gets the main code of the block (fragment side)
  64964. * @param state current state of the node material building
  64965. * @param normalVarName name of the existing variable corresponding to the normal
  64966. * @returns the shader code
  64967. */
  64968. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64969. protected _buildBlock(state: NodeMaterialBuildState): this;
  64970. protected _dumpPropertiesCode(): string;
  64971. serialize(): any;
  64972. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64973. }
  64974. }
  64975. declare module BABYLON {
  64976. /**
  64977. * Block used to implement the sheen module of the PBR material
  64978. */
  64979. export class SheenBlock extends NodeMaterialBlock {
  64980. /**
  64981. * Create a new SheenBlock
  64982. * @param name defines the block name
  64983. */
  64984. constructor(name: string);
  64985. /**
  64986. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64987. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64988. * making it easier to setup and tweak the effect
  64989. */
  64990. albedoScaling: boolean;
  64991. /**
  64992. * Defines if the sheen is linked to the sheen color.
  64993. */
  64994. linkSheenWithAlbedo: boolean;
  64995. /**
  64996. * Initialize the block and prepare the context for build
  64997. * @param state defines the state that will be used for the build
  64998. */
  64999. initialize(state: NodeMaterialBuildState): void;
  65000. /**
  65001. * Gets the current class name
  65002. * @returns the class name
  65003. */
  65004. getClassName(): string;
  65005. /**
  65006. * Gets the intensity input component
  65007. */
  65008. get intensity(): NodeMaterialConnectionPoint;
  65009. /**
  65010. * Gets the color input component
  65011. */
  65012. get color(): NodeMaterialConnectionPoint;
  65013. /**
  65014. * Gets the roughness input component
  65015. */
  65016. get roughness(): NodeMaterialConnectionPoint;
  65017. /**
  65018. * Gets the sheen object output component
  65019. */
  65020. get sheen(): NodeMaterialConnectionPoint;
  65021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65022. /**
  65023. * Gets the main code of the block (fragment side)
  65024. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65025. * @returns the shader code
  65026. */
  65027. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65028. protected _buildBlock(state: NodeMaterialBuildState): this;
  65029. protected _dumpPropertiesCode(): string;
  65030. serialize(): any;
  65031. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65032. }
  65033. }
  65034. declare module BABYLON {
  65035. /**
  65036. * Block used to implement the reflectivity module of the PBR material
  65037. */
  65038. export class ReflectivityBlock extends NodeMaterialBlock {
  65039. private _metallicReflectanceColor;
  65040. private _metallicF0Factor;
  65041. /** @hidden */
  65042. _vMetallicReflectanceFactorsName: string;
  65043. /**
  65044. * The property below is set by the main PBR block prior to calling methods of this class.
  65045. */
  65046. /** @hidden */
  65047. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65048. /**
  65049. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65050. */
  65051. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65052. /**
  65053. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65054. */
  65055. useMetallnessFromMetallicTextureBlue: boolean;
  65056. /**
  65057. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65058. */
  65059. useRoughnessFromMetallicTextureAlpha: boolean;
  65060. /**
  65061. * Specifies if the metallic texture contains the roughness information in its green channel.
  65062. */
  65063. useRoughnessFromMetallicTextureGreen: boolean;
  65064. /**
  65065. * Create a new ReflectivityBlock
  65066. * @param name defines the block name
  65067. */
  65068. constructor(name: string);
  65069. /**
  65070. * Initialize the block and prepare the context for build
  65071. * @param state defines the state that will be used for the build
  65072. */
  65073. initialize(state: NodeMaterialBuildState): void;
  65074. /**
  65075. * Gets the current class name
  65076. * @returns the class name
  65077. */
  65078. getClassName(): string;
  65079. /**
  65080. * Gets the metallic input component
  65081. */
  65082. get metallic(): NodeMaterialConnectionPoint;
  65083. /**
  65084. * Gets the roughness input component
  65085. */
  65086. get roughness(): NodeMaterialConnectionPoint;
  65087. /**
  65088. * Gets the texture input component
  65089. */
  65090. get texture(): NodeMaterialConnectionPoint;
  65091. /**
  65092. * Gets the reflectivity object output component
  65093. */
  65094. get reflectivity(): NodeMaterialConnectionPoint;
  65095. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65096. /**
  65097. * Gets the main code of the block (fragment side)
  65098. * @param state current state of the node material building
  65099. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65100. * @returns the shader code
  65101. */
  65102. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65103. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65104. protected _buildBlock(state: NodeMaterialBuildState): this;
  65105. protected _dumpPropertiesCode(): string;
  65106. serialize(): any;
  65107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65108. }
  65109. }
  65110. declare module BABYLON {
  65111. /**
  65112. * Block used to implement the anisotropy module of the PBR material
  65113. */
  65114. export class AnisotropyBlock extends NodeMaterialBlock {
  65115. /**
  65116. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65117. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65118. * It's less burden on the user side in the editor part.
  65119. */
  65120. /** @hidden */
  65121. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65122. /** @hidden */
  65123. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65124. /**
  65125. * Create a new AnisotropyBlock
  65126. * @param name defines the block name
  65127. */
  65128. constructor(name: string);
  65129. /**
  65130. * Initialize the block and prepare the context for build
  65131. * @param state defines the state that will be used for the build
  65132. */
  65133. initialize(state: NodeMaterialBuildState): void;
  65134. /**
  65135. * Gets the current class name
  65136. * @returns the class name
  65137. */
  65138. getClassName(): string;
  65139. /**
  65140. * Gets the intensity input component
  65141. */
  65142. get intensity(): NodeMaterialConnectionPoint;
  65143. /**
  65144. * Gets the direction input component
  65145. */
  65146. get direction(): NodeMaterialConnectionPoint;
  65147. /**
  65148. * Gets the texture input component
  65149. */
  65150. get texture(): NodeMaterialConnectionPoint;
  65151. /**
  65152. * Gets the uv input component
  65153. */
  65154. get uv(): NodeMaterialConnectionPoint;
  65155. /**
  65156. * Gets the worldTangent input component
  65157. */
  65158. get worldTangent(): NodeMaterialConnectionPoint;
  65159. /**
  65160. * Gets the anisotropy object output component
  65161. */
  65162. get anisotropy(): NodeMaterialConnectionPoint;
  65163. private _generateTBNSpace;
  65164. /**
  65165. * Gets the main code of the block (fragment side)
  65166. * @param state current state of the node material building
  65167. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65168. * @returns the shader code
  65169. */
  65170. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65172. protected _buildBlock(state: NodeMaterialBuildState): this;
  65173. }
  65174. }
  65175. declare module BABYLON {
  65176. /**
  65177. * Block used to implement the clear coat module of the PBR material
  65178. */
  65179. export class ClearCoatBlock extends NodeMaterialBlock {
  65180. private _scene;
  65181. /**
  65182. * Create a new ClearCoatBlock
  65183. * @param name defines the block name
  65184. */
  65185. constructor(name: string);
  65186. /**
  65187. * Initialize the block and prepare the context for build
  65188. * @param state defines the state that will be used for the build
  65189. */
  65190. initialize(state: NodeMaterialBuildState): void;
  65191. /**
  65192. * Gets the current class name
  65193. * @returns the class name
  65194. */
  65195. getClassName(): string;
  65196. /**
  65197. * Gets the intensity input component
  65198. */
  65199. get intensity(): NodeMaterialConnectionPoint;
  65200. /**
  65201. * Gets the roughness input component
  65202. */
  65203. get roughness(): NodeMaterialConnectionPoint;
  65204. /**
  65205. * Gets the ior input component
  65206. */
  65207. get ior(): NodeMaterialConnectionPoint;
  65208. /**
  65209. * Gets the texture input component
  65210. */
  65211. get texture(): NodeMaterialConnectionPoint;
  65212. /**
  65213. * Gets the bump texture input component
  65214. */
  65215. get bumpTexture(): NodeMaterialConnectionPoint;
  65216. /**
  65217. * Gets the uv input component
  65218. */
  65219. get uv(): NodeMaterialConnectionPoint;
  65220. /**
  65221. * Gets the tint color input component
  65222. */
  65223. get tintColor(): NodeMaterialConnectionPoint;
  65224. /**
  65225. * Gets the tint "at distance" input component
  65226. */
  65227. get tintAtDistance(): NodeMaterialConnectionPoint;
  65228. /**
  65229. * Gets the tint thickness input component
  65230. */
  65231. get tintThickness(): NodeMaterialConnectionPoint;
  65232. /**
  65233. * Gets the world tangent input component
  65234. */
  65235. get worldTangent(): NodeMaterialConnectionPoint;
  65236. /**
  65237. * Gets the clear coat object output component
  65238. */
  65239. get clearcoat(): NodeMaterialConnectionPoint;
  65240. autoConfigure(material: NodeMaterial): void;
  65241. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65242. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65243. private _generateTBNSpace;
  65244. /**
  65245. * Gets the main code of the block (fragment side)
  65246. * @param state current state of the node material building
  65247. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65248. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65249. * @param worldPosVarName name of the variable holding the world position
  65250. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65251. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65252. * @param worldNormalVarName name of the variable holding the world normal
  65253. * @returns the shader code
  65254. */
  65255. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65256. protected _buildBlock(state: NodeMaterialBuildState): this;
  65257. }
  65258. }
  65259. declare module BABYLON {
  65260. /**
  65261. * Block used to implement the sub surface module of the PBR material
  65262. */
  65263. export class SubSurfaceBlock extends NodeMaterialBlock {
  65264. /**
  65265. * Create a new SubSurfaceBlock
  65266. * @param name defines the block name
  65267. */
  65268. constructor(name: string);
  65269. /**
  65270. * Stores the intensity of the different subsurface effects in the thickness texture.
  65271. * * the green channel is the translucency intensity.
  65272. * * the blue channel is the scattering intensity.
  65273. * * the alpha channel is the refraction intensity.
  65274. */
  65275. useMaskFromThicknessTexture: boolean;
  65276. /**
  65277. * Initialize the block and prepare the context for build
  65278. * @param state defines the state that will be used for the build
  65279. */
  65280. initialize(state: NodeMaterialBuildState): void;
  65281. /**
  65282. * Gets the current class name
  65283. * @returns the class name
  65284. */
  65285. getClassName(): string;
  65286. /**
  65287. * Gets the min thickness input component
  65288. */
  65289. get minThickness(): NodeMaterialConnectionPoint;
  65290. /**
  65291. * Gets the max thickness input component
  65292. */
  65293. get maxThickness(): NodeMaterialConnectionPoint;
  65294. /**
  65295. * Gets the thickness texture component
  65296. */
  65297. get thicknessTexture(): NodeMaterialConnectionPoint;
  65298. /**
  65299. * Gets the tint color input component
  65300. */
  65301. get tintColor(): NodeMaterialConnectionPoint;
  65302. /**
  65303. * Gets the translucency intensity input component
  65304. */
  65305. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65306. /**
  65307. * Gets the translucency diffusion distance input component
  65308. */
  65309. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65310. /**
  65311. * Gets the refraction object parameters
  65312. */
  65313. get refraction(): NodeMaterialConnectionPoint;
  65314. /**
  65315. * Gets the sub surface object output component
  65316. */
  65317. get subsurface(): NodeMaterialConnectionPoint;
  65318. autoConfigure(material: NodeMaterial): void;
  65319. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65320. /**
  65321. * Gets the main code of the block (fragment side)
  65322. * @param state current state of the node material building
  65323. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65324. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65325. * @param worldPosVarName name of the variable holding the world position
  65326. * @returns the shader code
  65327. */
  65328. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65329. protected _buildBlock(state: NodeMaterialBuildState): this;
  65330. }
  65331. }
  65332. declare module BABYLON {
  65333. /**
  65334. * Block used to implement the PBR metallic/roughness model
  65335. */
  65336. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65337. /**
  65338. * Gets or sets the light associated with this block
  65339. */
  65340. light: Nullable<Light>;
  65341. private _lightId;
  65342. private _scene;
  65343. private _environmentBRDFTexture;
  65344. private _environmentBrdfSamplerName;
  65345. private _vNormalWName;
  65346. private _invertNormalName;
  65347. /**
  65348. * Create a new ReflectionBlock
  65349. * @param name defines the block name
  65350. */
  65351. constructor(name: string);
  65352. /**
  65353. * Intensity of the direct lights e.g. the four lights available in your scene.
  65354. * This impacts both the direct diffuse and specular highlights.
  65355. */
  65356. directIntensity: number;
  65357. /**
  65358. * Intensity of the environment e.g. how much the environment will light the object
  65359. * either through harmonics for rough material or through the refelction for shiny ones.
  65360. */
  65361. environmentIntensity: number;
  65362. /**
  65363. * This is a special control allowing the reduction of the specular highlights coming from the
  65364. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65365. */
  65366. specularIntensity: number;
  65367. /**
  65368. * Defines the falloff type used in this material.
  65369. * It by default is Physical.
  65370. */
  65371. lightFalloff: number;
  65372. /**
  65373. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65374. */
  65375. useAlphaFromAlbedoTexture: boolean;
  65376. /**
  65377. * Specifies that alpha test should be used
  65378. */
  65379. useAlphaTest: boolean;
  65380. /**
  65381. * Defines the alpha limits in alpha test mode.
  65382. */
  65383. alphaTestCutoff: number;
  65384. /**
  65385. * Specifies that alpha blending should be used
  65386. */
  65387. useAlphaBlending: boolean;
  65388. /**
  65389. * Defines if the alpha value should be determined via the rgb values.
  65390. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65391. */
  65392. opacityRGB: boolean;
  65393. /**
  65394. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65395. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65396. */
  65397. useRadianceOverAlpha: boolean;
  65398. /**
  65399. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65400. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65401. */
  65402. useSpecularOverAlpha: boolean;
  65403. /**
  65404. * Enables specular anti aliasing in the PBR shader.
  65405. * It will both interacts on the Geometry for analytical and IBL lighting.
  65406. * It also prefilter the roughness map based on the bump values.
  65407. */
  65408. enableSpecularAntiAliasing: boolean;
  65409. /**
  65410. * Enables realtime filtering on the texture.
  65411. */
  65412. realTimeFiltering: boolean;
  65413. /**
  65414. * Quality switch for realtime filtering
  65415. */
  65416. realTimeFilteringQuality: number;
  65417. /**
  65418. * Defines if the material uses energy conservation.
  65419. */
  65420. useEnergyConservation: boolean;
  65421. /**
  65422. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65423. * too much the area relying on ambient texture to define their ambient occlusion.
  65424. */
  65425. useRadianceOcclusion: boolean;
  65426. /**
  65427. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65428. * makes the reflect vector face the model (under horizon).
  65429. */
  65430. useHorizonOcclusion: boolean;
  65431. /**
  65432. * If set to true, no lighting calculations will be applied.
  65433. */
  65434. unlit: boolean;
  65435. /**
  65436. * Force normal to face away from face.
  65437. */
  65438. forceNormalForward: boolean;
  65439. /**
  65440. * Defines the material debug mode.
  65441. * It helps seeing only some components of the material while troubleshooting.
  65442. */
  65443. debugMode: number;
  65444. /**
  65445. * Specify from where on screen the debug mode should start.
  65446. * The value goes from -1 (full screen) to 1 (not visible)
  65447. * It helps with side by side comparison against the final render
  65448. * This defaults to 0
  65449. */
  65450. debugLimit: number;
  65451. /**
  65452. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65453. * You can use the factor to better multiply the final value.
  65454. */
  65455. debugFactor: number;
  65456. /**
  65457. * Initialize the block and prepare the context for build
  65458. * @param state defines the state that will be used for the build
  65459. */
  65460. initialize(state: NodeMaterialBuildState): void;
  65461. /**
  65462. * Gets the current class name
  65463. * @returns the class name
  65464. */
  65465. getClassName(): string;
  65466. /**
  65467. * Gets the world position input component
  65468. */
  65469. get worldPosition(): NodeMaterialConnectionPoint;
  65470. /**
  65471. * Gets the world normal input component
  65472. */
  65473. get worldNormal(): NodeMaterialConnectionPoint;
  65474. /**
  65475. * Gets the perturbed normal input component
  65476. */
  65477. get perturbedNormal(): NodeMaterialConnectionPoint;
  65478. /**
  65479. * Gets the camera position input component
  65480. */
  65481. get cameraPosition(): NodeMaterialConnectionPoint;
  65482. /**
  65483. * Gets the base color input component
  65484. */
  65485. get baseColor(): NodeMaterialConnectionPoint;
  65486. /**
  65487. * Gets the opacity texture input component
  65488. */
  65489. get opacityTexture(): NodeMaterialConnectionPoint;
  65490. /**
  65491. * Gets the ambient color input component
  65492. */
  65493. get ambientColor(): NodeMaterialConnectionPoint;
  65494. /**
  65495. * Gets the reflectivity object parameters
  65496. */
  65497. get reflectivity(): NodeMaterialConnectionPoint;
  65498. /**
  65499. * Gets the ambient occlusion object parameters
  65500. */
  65501. get ambientOcc(): NodeMaterialConnectionPoint;
  65502. /**
  65503. * Gets the reflection object parameters
  65504. */
  65505. get reflection(): NodeMaterialConnectionPoint;
  65506. /**
  65507. * Gets the sheen object parameters
  65508. */
  65509. get sheen(): NodeMaterialConnectionPoint;
  65510. /**
  65511. * Gets the clear coat object parameters
  65512. */
  65513. get clearcoat(): NodeMaterialConnectionPoint;
  65514. /**
  65515. * Gets the sub surface object parameters
  65516. */
  65517. get subsurface(): NodeMaterialConnectionPoint;
  65518. /**
  65519. * Gets the anisotropy object parameters
  65520. */
  65521. get anisotropy(): NodeMaterialConnectionPoint;
  65522. /**
  65523. * Gets the ambient output component
  65524. */
  65525. get ambient(): NodeMaterialConnectionPoint;
  65526. /**
  65527. * Gets the diffuse output component
  65528. */
  65529. get diffuse(): NodeMaterialConnectionPoint;
  65530. /**
  65531. * Gets the specular output component
  65532. */
  65533. get specular(): NodeMaterialConnectionPoint;
  65534. /**
  65535. * Gets the sheen output component
  65536. */
  65537. get sheenDir(): NodeMaterialConnectionPoint;
  65538. /**
  65539. * Gets the clear coat output component
  65540. */
  65541. get clearcoatDir(): NodeMaterialConnectionPoint;
  65542. /**
  65543. * Gets the indirect diffuse output component
  65544. */
  65545. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65546. /**
  65547. * Gets the indirect specular output component
  65548. */
  65549. get specularIndirect(): NodeMaterialConnectionPoint;
  65550. /**
  65551. * Gets the indirect sheen output component
  65552. */
  65553. get sheenIndirect(): NodeMaterialConnectionPoint;
  65554. /**
  65555. * Gets the indirect clear coat output component
  65556. */
  65557. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65558. /**
  65559. * Gets the refraction output component
  65560. */
  65561. get refraction(): NodeMaterialConnectionPoint;
  65562. /**
  65563. * Gets the global lighting output component
  65564. */
  65565. get lighting(): NodeMaterialConnectionPoint;
  65566. /**
  65567. * Gets the shadow output component
  65568. */
  65569. get shadow(): NodeMaterialConnectionPoint;
  65570. /**
  65571. * Gets the alpha output component
  65572. */
  65573. get alpha(): NodeMaterialConnectionPoint;
  65574. autoConfigure(material: NodeMaterial): void;
  65575. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65576. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65578. private _injectVertexCode;
  65579. /**
  65580. * Gets the code corresponding to the albedo/opacity module
  65581. * @returns the shader code
  65582. */
  65583. getAlbedoOpacityCode(): string;
  65584. protected _buildBlock(state: NodeMaterialBuildState): this;
  65585. protected _dumpPropertiesCode(): string;
  65586. serialize(): any;
  65587. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65588. }
  65589. }
  65590. declare module BABYLON {
  65591. /**
  65592. * Block used to compute value of one parameter modulo another
  65593. */
  65594. export class ModBlock extends NodeMaterialBlock {
  65595. /**
  65596. * Creates a new ModBlock
  65597. * @param name defines the block name
  65598. */
  65599. constructor(name: string);
  65600. /**
  65601. * Gets the current class name
  65602. * @returns the class name
  65603. */
  65604. getClassName(): string;
  65605. /**
  65606. * Gets the left operand input component
  65607. */
  65608. get left(): NodeMaterialConnectionPoint;
  65609. /**
  65610. * Gets the right operand input component
  65611. */
  65612. get right(): NodeMaterialConnectionPoint;
  65613. /**
  65614. * Gets the output component
  65615. */
  65616. get output(): NodeMaterialConnectionPoint;
  65617. protected _buildBlock(state: NodeMaterialBuildState): this;
  65618. }
  65619. }
  65620. declare module BABYLON {
  65621. /**
  65622. * Configuration for Draco compression
  65623. */
  65624. export interface IDracoCompressionConfiguration {
  65625. /**
  65626. * Configuration for the decoder.
  65627. */
  65628. decoder: {
  65629. /**
  65630. * The url to the WebAssembly module.
  65631. */
  65632. wasmUrl?: string;
  65633. /**
  65634. * The url to the WebAssembly binary.
  65635. */
  65636. wasmBinaryUrl?: string;
  65637. /**
  65638. * The url to the fallback JavaScript module.
  65639. */
  65640. fallbackUrl?: string;
  65641. };
  65642. }
  65643. /**
  65644. * Draco compression (https://google.github.io/draco/)
  65645. *
  65646. * This class wraps the Draco module.
  65647. *
  65648. * **Encoder**
  65649. *
  65650. * The encoder is not currently implemented.
  65651. *
  65652. * **Decoder**
  65653. *
  65654. * 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.
  65655. *
  65656. * To update the configuration, use the following code:
  65657. * ```javascript
  65658. * DracoCompression.Configuration = {
  65659. * decoder: {
  65660. * wasmUrl: "<url to the WebAssembly library>",
  65661. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65662. * fallbackUrl: "<url to the fallback JavaScript library>",
  65663. * }
  65664. * };
  65665. * ```
  65666. *
  65667. * 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.
  65668. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65669. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65670. *
  65671. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65672. * ```javascript
  65673. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65674. * ```
  65675. *
  65676. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65677. */
  65678. export class DracoCompression implements IDisposable {
  65679. private _workerPoolPromise?;
  65680. private _decoderModulePromise?;
  65681. /**
  65682. * The configuration. Defaults to the following urls:
  65683. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65684. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65685. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65686. */
  65687. static Configuration: IDracoCompressionConfiguration;
  65688. /**
  65689. * Returns true if the decoder configuration is available.
  65690. */
  65691. static get DecoderAvailable(): boolean;
  65692. /**
  65693. * Default number of workers to create when creating the draco compression object.
  65694. */
  65695. static DefaultNumWorkers: number;
  65696. private static GetDefaultNumWorkers;
  65697. private static _Default;
  65698. /**
  65699. * Default instance for the draco compression object.
  65700. */
  65701. static get Default(): DracoCompression;
  65702. /**
  65703. * Constructor
  65704. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65705. */
  65706. constructor(numWorkers?: number);
  65707. /**
  65708. * Stop all async operations and release resources.
  65709. */
  65710. dispose(): void;
  65711. /**
  65712. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65713. * @returns a promise that resolves when ready
  65714. */
  65715. whenReadyAsync(): Promise<void>;
  65716. /**
  65717. * Decode Draco compressed mesh data to vertex data.
  65718. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65719. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65720. * @returns A promise that resolves with the decoded vertex data
  65721. */
  65722. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65723. [kind: string]: number;
  65724. }): Promise<VertexData>;
  65725. }
  65726. }
  65727. declare module BABYLON {
  65728. /**
  65729. * Class for building Constructive Solid Geometry
  65730. */
  65731. export class CSG {
  65732. private polygons;
  65733. /**
  65734. * The world matrix
  65735. */
  65736. matrix: Matrix;
  65737. /**
  65738. * Stores the position
  65739. */
  65740. position: Vector3;
  65741. /**
  65742. * Stores the rotation
  65743. */
  65744. rotation: Vector3;
  65745. /**
  65746. * Stores the rotation quaternion
  65747. */
  65748. rotationQuaternion: Nullable<Quaternion>;
  65749. /**
  65750. * Stores the scaling vector
  65751. */
  65752. scaling: Vector3;
  65753. /**
  65754. * Convert the Mesh to CSG
  65755. * @param mesh The Mesh to convert to CSG
  65756. * @returns A new CSG from the Mesh
  65757. */
  65758. static FromMesh(mesh: Mesh): CSG;
  65759. /**
  65760. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65761. * @param polygons Polygons used to construct a CSG solid
  65762. */
  65763. private static FromPolygons;
  65764. /**
  65765. * Clones, or makes a deep copy, of the CSG
  65766. * @returns A new CSG
  65767. */
  65768. clone(): CSG;
  65769. /**
  65770. * Unions this CSG with another CSG
  65771. * @param csg The CSG to union against this CSG
  65772. * @returns The unioned CSG
  65773. */
  65774. union(csg: CSG): CSG;
  65775. /**
  65776. * Unions this CSG with another CSG in place
  65777. * @param csg The CSG to union against this CSG
  65778. */
  65779. unionInPlace(csg: CSG): void;
  65780. /**
  65781. * Subtracts this CSG with another CSG
  65782. * @param csg The CSG to subtract against this CSG
  65783. * @returns A new CSG
  65784. */
  65785. subtract(csg: CSG): CSG;
  65786. /**
  65787. * Subtracts this CSG with another CSG in place
  65788. * @param csg The CSG to subtact against this CSG
  65789. */
  65790. subtractInPlace(csg: CSG): void;
  65791. /**
  65792. * Intersect this CSG with another CSG
  65793. * @param csg The CSG to intersect against this CSG
  65794. * @returns A new CSG
  65795. */
  65796. intersect(csg: CSG): CSG;
  65797. /**
  65798. * Intersects this CSG with another CSG in place
  65799. * @param csg The CSG to intersect against this CSG
  65800. */
  65801. intersectInPlace(csg: CSG): void;
  65802. /**
  65803. * Return a new CSG solid with solid and empty space switched. This solid is
  65804. * not modified.
  65805. * @returns A new CSG solid with solid and empty space switched
  65806. */
  65807. inverse(): CSG;
  65808. /**
  65809. * Inverses the CSG in place
  65810. */
  65811. inverseInPlace(): void;
  65812. /**
  65813. * This is used to keep meshes transformations so they can be restored
  65814. * when we build back a Babylon Mesh
  65815. * NB : All CSG operations are performed in world coordinates
  65816. * @param csg The CSG to copy the transform attributes from
  65817. * @returns This CSG
  65818. */
  65819. copyTransformAttributes(csg: CSG): CSG;
  65820. /**
  65821. * Build Raw mesh from CSG
  65822. * Coordinates here are in world space
  65823. * @param name The name of the mesh geometry
  65824. * @param scene The Scene
  65825. * @param keepSubMeshes Specifies if the submeshes should be kept
  65826. * @returns A new Mesh
  65827. */
  65828. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65829. /**
  65830. * Build Mesh from CSG taking material and transforms into account
  65831. * @param name The name of the Mesh
  65832. * @param material The material of the Mesh
  65833. * @param scene The Scene
  65834. * @param keepSubMeshes Specifies if submeshes should be kept
  65835. * @returns The new Mesh
  65836. */
  65837. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65838. }
  65839. }
  65840. declare module BABYLON {
  65841. /**
  65842. * Class used to create a trail following a mesh
  65843. */
  65844. export class TrailMesh extends Mesh {
  65845. private _generator;
  65846. private _autoStart;
  65847. private _running;
  65848. private _diameter;
  65849. private _length;
  65850. private _sectionPolygonPointsCount;
  65851. private _sectionVectors;
  65852. private _sectionNormalVectors;
  65853. private _beforeRenderObserver;
  65854. /**
  65855. * @constructor
  65856. * @param name The value used by scene.getMeshByName() to do a lookup.
  65857. * @param generator The mesh or transform node to generate a trail.
  65858. * @param scene The scene to add this mesh to.
  65859. * @param diameter Diameter of trailing mesh. Default is 1.
  65860. * @param length Length of trailing mesh. Default is 60.
  65861. * @param autoStart Automatically start trailing mesh. Default true.
  65862. */
  65863. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65864. /**
  65865. * "TrailMesh"
  65866. * @returns "TrailMesh"
  65867. */
  65868. getClassName(): string;
  65869. private _createMesh;
  65870. /**
  65871. * Start trailing mesh.
  65872. */
  65873. start(): void;
  65874. /**
  65875. * Stop trailing mesh.
  65876. */
  65877. stop(): void;
  65878. /**
  65879. * Update trailing mesh geometry.
  65880. */
  65881. update(): void;
  65882. /**
  65883. * Returns a new TrailMesh object.
  65884. * @param name is a string, the name given to the new mesh
  65885. * @param newGenerator use new generator object for cloned trail mesh
  65886. * @returns a new mesh
  65887. */
  65888. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65889. /**
  65890. * Serializes this trail mesh
  65891. * @param serializationObject object to write serialization to
  65892. */
  65893. serialize(serializationObject: any): void;
  65894. /**
  65895. * Parses a serialized trail mesh
  65896. * @param parsedMesh the serialized mesh
  65897. * @param scene the scene to create the trail mesh in
  65898. * @returns the created trail mesh
  65899. */
  65900. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65901. }
  65902. }
  65903. declare module BABYLON {
  65904. /**
  65905. * Class containing static functions to help procedurally build meshes
  65906. */
  65907. export class TiledBoxBuilder {
  65908. /**
  65909. * Creates a box mesh
  65910. * 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)
  65911. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65913. * * 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
  65914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65915. * @param name defines the name of the mesh
  65916. * @param options defines the options used to create the mesh
  65917. * @param scene defines the hosting scene
  65918. * @returns the box mesh
  65919. */
  65920. static CreateTiledBox(name: string, options: {
  65921. pattern?: number;
  65922. width?: number;
  65923. height?: number;
  65924. depth?: number;
  65925. tileSize?: number;
  65926. tileWidth?: number;
  65927. tileHeight?: number;
  65928. alignHorizontal?: number;
  65929. alignVertical?: number;
  65930. faceUV?: Vector4[];
  65931. faceColors?: Color4[];
  65932. sideOrientation?: number;
  65933. updatable?: boolean;
  65934. }, scene?: Nullable<Scene>): Mesh;
  65935. }
  65936. }
  65937. declare module BABYLON {
  65938. /**
  65939. * Class containing static functions to help procedurally build meshes
  65940. */
  65941. export class TorusKnotBuilder {
  65942. /**
  65943. * Creates a torus knot mesh
  65944. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65945. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65946. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65947. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65949. * * 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
  65950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65951. * @param name defines the name of the mesh
  65952. * @param options defines the options used to create the mesh
  65953. * @param scene defines the hosting scene
  65954. * @returns the torus knot mesh
  65955. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65956. */
  65957. static CreateTorusKnot(name: string, options: {
  65958. radius?: number;
  65959. tube?: number;
  65960. radialSegments?: number;
  65961. tubularSegments?: number;
  65962. p?: number;
  65963. q?: number;
  65964. updatable?: boolean;
  65965. sideOrientation?: number;
  65966. frontUVs?: Vector4;
  65967. backUVs?: Vector4;
  65968. }, scene: any): Mesh;
  65969. }
  65970. }
  65971. declare module BABYLON {
  65972. /**
  65973. * Polygon
  65974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65975. */
  65976. export class Polygon {
  65977. /**
  65978. * Creates a rectangle
  65979. * @param xmin bottom X coord
  65980. * @param ymin bottom Y coord
  65981. * @param xmax top X coord
  65982. * @param ymax top Y coord
  65983. * @returns points that make the resulting rectation
  65984. */
  65985. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65986. /**
  65987. * Creates a circle
  65988. * @param radius radius of circle
  65989. * @param cx scale in x
  65990. * @param cy scale in y
  65991. * @param numberOfSides number of sides that make up the circle
  65992. * @returns points that make the resulting circle
  65993. */
  65994. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65995. /**
  65996. * Creates a polygon from input string
  65997. * @param input Input polygon data
  65998. * @returns the parsed points
  65999. */
  66000. static Parse(input: string): Vector2[];
  66001. /**
  66002. * Starts building a polygon from x and y coordinates
  66003. * @param x x coordinate
  66004. * @param y y coordinate
  66005. * @returns the started path2
  66006. */
  66007. static StartingAt(x: number, y: number): Path2;
  66008. }
  66009. /**
  66010. * Builds a polygon
  66011. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66012. */
  66013. export class PolygonMeshBuilder {
  66014. private _points;
  66015. private _outlinepoints;
  66016. private _holes;
  66017. private _name;
  66018. private _scene;
  66019. private _epoints;
  66020. private _eholes;
  66021. private _addToepoint;
  66022. /**
  66023. * Babylon reference to the earcut plugin.
  66024. */
  66025. bjsEarcut: any;
  66026. /**
  66027. * Creates a PolygonMeshBuilder
  66028. * @param name name of the builder
  66029. * @param contours Path of the polygon
  66030. * @param scene scene to add to when creating the mesh
  66031. * @param earcutInjection can be used to inject your own earcut reference
  66032. */
  66033. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66034. /**
  66035. * Adds a whole within the polygon
  66036. * @param hole Array of points defining the hole
  66037. * @returns this
  66038. */
  66039. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66040. /**
  66041. * Creates the polygon
  66042. * @param updatable If the mesh should be updatable
  66043. * @param depth The depth of the mesh created
  66044. * @returns the created mesh
  66045. */
  66046. build(updatable?: boolean, depth?: number): Mesh;
  66047. /**
  66048. * Creates the polygon
  66049. * @param depth The depth of the mesh created
  66050. * @returns the created VertexData
  66051. */
  66052. buildVertexData(depth?: number): VertexData;
  66053. /**
  66054. * Adds a side to the polygon
  66055. * @param positions points that make the polygon
  66056. * @param normals normals of the polygon
  66057. * @param uvs uvs of the polygon
  66058. * @param indices indices of the polygon
  66059. * @param bounds bounds of the polygon
  66060. * @param points points of the polygon
  66061. * @param depth depth of the polygon
  66062. * @param flip flip of the polygon
  66063. */
  66064. private addSide;
  66065. }
  66066. }
  66067. declare module BABYLON {
  66068. /**
  66069. * Class containing static functions to help procedurally build meshes
  66070. */
  66071. export class PolygonBuilder {
  66072. /**
  66073. * Creates a polygon mesh
  66074. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66075. * * 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
  66076. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66078. * * 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)
  66079. * * Remember you can only change the shape positions, not their number when updating a polygon
  66080. * @param name defines the name of the mesh
  66081. * @param options defines the options used to create the mesh
  66082. * @param scene defines the hosting scene
  66083. * @param earcutInjection can be used to inject your own earcut reference
  66084. * @returns the polygon mesh
  66085. */
  66086. static CreatePolygon(name: string, options: {
  66087. shape: Vector3[];
  66088. holes?: Vector3[][];
  66089. depth?: number;
  66090. faceUV?: Vector4[];
  66091. faceColors?: Color4[];
  66092. updatable?: boolean;
  66093. sideOrientation?: number;
  66094. frontUVs?: Vector4;
  66095. backUVs?: Vector4;
  66096. wrap?: boolean;
  66097. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66098. /**
  66099. * Creates an extruded polygon mesh, with depth in the Y direction.
  66100. * * 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)
  66101. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66102. * @param name defines the name of the mesh
  66103. * @param options defines the options used to create the mesh
  66104. * @param scene defines the hosting scene
  66105. * @param earcutInjection can be used to inject your own earcut reference
  66106. * @returns the polygon mesh
  66107. */
  66108. static ExtrudePolygon(name: string, options: {
  66109. shape: Vector3[];
  66110. holes?: Vector3[][];
  66111. depth?: number;
  66112. faceUV?: Vector4[];
  66113. faceColors?: Color4[];
  66114. updatable?: boolean;
  66115. sideOrientation?: number;
  66116. frontUVs?: Vector4;
  66117. backUVs?: Vector4;
  66118. wrap?: boolean;
  66119. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66120. }
  66121. }
  66122. declare module BABYLON {
  66123. /**
  66124. * Class containing static functions to help procedurally build meshes
  66125. */
  66126. export class LatheBuilder {
  66127. /**
  66128. * Creates lathe mesh.
  66129. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66130. * * 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
  66131. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66132. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66133. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66134. * * 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
  66135. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66136. * * 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
  66137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66138. * * 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
  66139. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66141. * @param name defines the name of the mesh
  66142. * @param options defines the options used to create the mesh
  66143. * @param scene defines the hosting scene
  66144. * @returns the lathe mesh
  66145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66146. */
  66147. static CreateLathe(name: string, options: {
  66148. shape: Vector3[];
  66149. radius?: number;
  66150. tessellation?: number;
  66151. clip?: number;
  66152. arc?: number;
  66153. closed?: boolean;
  66154. updatable?: boolean;
  66155. sideOrientation?: number;
  66156. frontUVs?: Vector4;
  66157. backUVs?: Vector4;
  66158. cap?: number;
  66159. invertUV?: boolean;
  66160. }, scene?: Nullable<Scene>): Mesh;
  66161. }
  66162. }
  66163. declare module BABYLON {
  66164. /**
  66165. * Class containing static functions to help procedurally build meshes
  66166. */
  66167. export class TiledPlaneBuilder {
  66168. /**
  66169. * Creates a tiled plane mesh
  66170. * * The parameter `pattern` will, depending on value, do nothing or
  66171. * * * flip (reflect about central vertical) alternate tiles across and up
  66172. * * * flip every tile on alternate rows
  66173. * * * rotate (180 degs) alternate tiles across and up
  66174. * * * rotate every tile on alternate rows
  66175. * * * flip and rotate alternate tiles across and up
  66176. * * * flip and rotate every tile on alternate rows
  66177. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66178. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66179. * * 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
  66180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66181. * * 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)
  66182. * * 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)
  66183. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66184. * @param name defines the name of the mesh
  66185. * @param options defines the options used to create the mesh
  66186. * @param scene defines the hosting scene
  66187. * @returns the box mesh
  66188. */
  66189. static CreateTiledPlane(name: string, options: {
  66190. pattern?: number;
  66191. tileSize?: number;
  66192. tileWidth?: number;
  66193. tileHeight?: number;
  66194. size?: number;
  66195. width?: number;
  66196. height?: number;
  66197. alignHorizontal?: number;
  66198. alignVertical?: number;
  66199. sideOrientation?: number;
  66200. frontUVs?: Vector4;
  66201. backUVs?: Vector4;
  66202. updatable?: boolean;
  66203. }, scene?: Nullable<Scene>): Mesh;
  66204. }
  66205. }
  66206. declare module BABYLON {
  66207. /**
  66208. * Class containing static functions to help procedurally build meshes
  66209. */
  66210. export class TubeBuilder {
  66211. /**
  66212. * Creates a tube mesh.
  66213. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66214. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66215. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66216. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66217. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66218. * * 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)
  66219. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66220. * * 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
  66221. * * 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
  66222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66223. * * 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
  66224. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66226. * @param name defines the name of the mesh
  66227. * @param options defines the options used to create the mesh
  66228. * @param scene defines the hosting scene
  66229. * @returns the tube mesh
  66230. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66231. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66232. */
  66233. static CreateTube(name: string, options: {
  66234. path: Vector3[];
  66235. radius?: number;
  66236. tessellation?: number;
  66237. radiusFunction?: {
  66238. (i: number, distance: number): number;
  66239. };
  66240. cap?: number;
  66241. arc?: number;
  66242. updatable?: boolean;
  66243. sideOrientation?: number;
  66244. frontUVs?: Vector4;
  66245. backUVs?: Vector4;
  66246. instance?: Mesh;
  66247. invertUV?: boolean;
  66248. }, scene?: Nullable<Scene>): Mesh;
  66249. }
  66250. }
  66251. declare module BABYLON {
  66252. /**
  66253. * Class containing static functions to help procedurally build meshes
  66254. */
  66255. export class IcoSphereBuilder {
  66256. /**
  66257. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66258. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66259. * * 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`)
  66260. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66261. * * 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
  66262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66263. * * 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
  66264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66265. * @param name defines the name of the mesh
  66266. * @param options defines the options used to create the mesh
  66267. * @param scene defines the hosting scene
  66268. * @returns the icosahedron mesh
  66269. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66270. */
  66271. static CreateIcoSphere(name: string, options: {
  66272. radius?: number;
  66273. radiusX?: number;
  66274. radiusY?: number;
  66275. radiusZ?: number;
  66276. flat?: boolean;
  66277. subdivisions?: number;
  66278. sideOrientation?: number;
  66279. frontUVs?: Vector4;
  66280. backUVs?: Vector4;
  66281. updatable?: boolean;
  66282. }, scene?: Nullable<Scene>): Mesh;
  66283. }
  66284. }
  66285. declare module BABYLON {
  66286. /**
  66287. * Class containing static functions to help procedurally build meshes
  66288. */
  66289. export class DecalBuilder {
  66290. /**
  66291. * Creates a decal mesh.
  66292. * 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
  66293. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66294. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66295. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66296. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66297. * @param name defines the name of the mesh
  66298. * @param sourceMesh defines the mesh where the decal must be applied
  66299. * @param options defines the options used to create the mesh
  66300. * @param scene defines the hosting scene
  66301. * @returns the decal mesh
  66302. * @see https://doc.babylonjs.com/how_to/decals
  66303. */
  66304. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66305. position?: Vector3;
  66306. normal?: Vector3;
  66307. size?: Vector3;
  66308. angle?: number;
  66309. }): Mesh;
  66310. }
  66311. }
  66312. declare module BABYLON {
  66313. /**
  66314. * Class containing static functions to help procedurally build meshes
  66315. */
  66316. export class MeshBuilder {
  66317. /**
  66318. * Creates a box mesh
  66319. * * The parameter `size` sets the size (float) of each box side (default 1)
  66320. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66321. * * 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)
  66322. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66324. * * 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
  66325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66326. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66327. * @param name defines the name of the mesh
  66328. * @param options defines the options used to create the mesh
  66329. * @param scene defines the hosting scene
  66330. * @returns the box mesh
  66331. */
  66332. static CreateBox(name: string, options: {
  66333. size?: number;
  66334. width?: number;
  66335. height?: number;
  66336. depth?: number;
  66337. faceUV?: Vector4[];
  66338. faceColors?: Color4[];
  66339. sideOrientation?: number;
  66340. frontUVs?: Vector4;
  66341. backUVs?: Vector4;
  66342. wrap?: boolean;
  66343. topBaseAt?: number;
  66344. bottomBaseAt?: number;
  66345. updatable?: boolean;
  66346. }, scene?: Nullable<Scene>): Mesh;
  66347. /**
  66348. * Creates a tiled box mesh
  66349. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66351. * @param name defines the name of the mesh
  66352. * @param options defines the options used to create the mesh
  66353. * @param scene defines the hosting scene
  66354. * @returns the tiled box mesh
  66355. */
  66356. static CreateTiledBox(name: string, options: {
  66357. pattern?: number;
  66358. size?: number;
  66359. width?: number;
  66360. height?: number;
  66361. depth: number;
  66362. tileSize?: number;
  66363. tileWidth?: number;
  66364. tileHeight?: number;
  66365. faceUV?: Vector4[];
  66366. faceColors?: Color4[];
  66367. alignHorizontal?: number;
  66368. alignVertical?: number;
  66369. sideOrientation?: number;
  66370. updatable?: boolean;
  66371. }, scene?: Nullable<Scene>): Mesh;
  66372. /**
  66373. * Creates a sphere mesh
  66374. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66375. * * 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`)
  66376. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66377. * * 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
  66378. * * 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)
  66379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66380. * * 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
  66381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66382. * @param name defines the name of the mesh
  66383. * @param options defines the options used to create the mesh
  66384. * @param scene defines the hosting scene
  66385. * @returns the sphere mesh
  66386. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66387. */
  66388. static CreateSphere(name: string, options: {
  66389. segments?: number;
  66390. diameter?: number;
  66391. diameterX?: number;
  66392. diameterY?: number;
  66393. diameterZ?: number;
  66394. arc?: number;
  66395. slice?: number;
  66396. sideOrientation?: number;
  66397. frontUVs?: Vector4;
  66398. backUVs?: Vector4;
  66399. updatable?: boolean;
  66400. }, scene?: Nullable<Scene>): Mesh;
  66401. /**
  66402. * Creates a plane polygonal mesh. By default, this is a disc
  66403. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66404. * * 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
  66405. * * 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
  66406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66407. * * 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
  66408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66409. * @param name defines the name of the mesh
  66410. * @param options defines the options used to create the mesh
  66411. * @param scene defines the hosting scene
  66412. * @returns the plane polygonal mesh
  66413. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66414. */
  66415. static CreateDisc(name: string, options: {
  66416. radius?: number;
  66417. tessellation?: number;
  66418. arc?: number;
  66419. updatable?: boolean;
  66420. sideOrientation?: number;
  66421. frontUVs?: Vector4;
  66422. backUVs?: Vector4;
  66423. }, scene?: Nullable<Scene>): Mesh;
  66424. /**
  66425. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66426. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66427. * * 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`)
  66428. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66429. * * 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
  66430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66431. * * 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
  66432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66433. * @param name defines the name of the mesh
  66434. * @param options defines the options used to create the mesh
  66435. * @param scene defines the hosting scene
  66436. * @returns the icosahedron mesh
  66437. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66438. */
  66439. static CreateIcoSphere(name: string, options: {
  66440. radius?: number;
  66441. radiusX?: number;
  66442. radiusY?: number;
  66443. radiusZ?: number;
  66444. flat?: boolean;
  66445. subdivisions?: number;
  66446. sideOrientation?: number;
  66447. frontUVs?: Vector4;
  66448. backUVs?: Vector4;
  66449. updatable?: boolean;
  66450. }, scene?: Nullable<Scene>): Mesh;
  66451. /**
  66452. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66453. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66454. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66455. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66456. * * 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
  66457. * * 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
  66458. * * 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
  66459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66460. * * 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
  66461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66462. * * 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
  66463. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66464. * * 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
  66465. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66467. * @param name defines the name of the mesh
  66468. * @param options defines the options used to create the mesh
  66469. * @param scene defines the hosting scene
  66470. * @returns the ribbon mesh
  66471. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66472. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66473. */
  66474. static CreateRibbon(name: string, options: {
  66475. pathArray: Vector3[][];
  66476. closeArray?: boolean;
  66477. closePath?: boolean;
  66478. offset?: number;
  66479. updatable?: boolean;
  66480. sideOrientation?: number;
  66481. frontUVs?: Vector4;
  66482. backUVs?: Vector4;
  66483. instance?: Mesh;
  66484. invertUV?: boolean;
  66485. uvs?: Vector2[];
  66486. colors?: Color4[];
  66487. }, scene?: Nullable<Scene>): Mesh;
  66488. /**
  66489. * Creates a cylinder or a cone mesh
  66490. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66491. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66492. * * 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.
  66493. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66494. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66495. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66496. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66497. * * 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).
  66498. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66499. * * 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).
  66500. * * 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
  66501. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66502. * * 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
  66503. * * 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.
  66504. * * If `enclose` is false, a ring surface is one element.
  66505. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66506. * * 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
  66507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66508. * * 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
  66509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66510. * @param name defines the name of the mesh
  66511. * @param options defines the options used to create the mesh
  66512. * @param scene defines the hosting scene
  66513. * @returns the cylinder mesh
  66514. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66515. */
  66516. static CreateCylinder(name: string, options: {
  66517. height?: number;
  66518. diameterTop?: number;
  66519. diameterBottom?: number;
  66520. diameter?: number;
  66521. tessellation?: number;
  66522. subdivisions?: number;
  66523. arc?: number;
  66524. faceColors?: Color4[];
  66525. faceUV?: Vector4[];
  66526. updatable?: boolean;
  66527. hasRings?: boolean;
  66528. enclose?: boolean;
  66529. cap?: number;
  66530. sideOrientation?: number;
  66531. frontUVs?: Vector4;
  66532. backUVs?: Vector4;
  66533. }, scene?: Nullable<Scene>): Mesh;
  66534. /**
  66535. * Creates a torus mesh
  66536. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66537. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66538. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66540. * * 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
  66541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66542. * @param name defines the name of the mesh
  66543. * @param options defines the options used to create the mesh
  66544. * @param scene defines the hosting scene
  66545. * @returns the torus mesh
  66546. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66547. */
  66548. static CreateTorus(name: string, options: {
  66549. diameter?: number;
  66550. thickness?: number;
  66551. tessellation?: number;
  66552. updatable?: boolean;
  66553. sideOrientation?: number;
  66554. frontUVs?: Vector4;
  66555. backUVs?: Vector4;
  66556. }, scene?: Nullable<Scene>): Mesh;
  66557. /**
  66558. * Creates a torus knot mesh
  66559. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66560. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66561. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66562. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66564. * * 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
  66565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66566. * @param name defines the name of the mesh
  66567. * @param options defines the options used to create the mesh
  66568. * @param scene defines the hosting scene
  66569. * @returns the torus knot mesh
  66570. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66571. */
  66572. static CreateTorusKnot(name: string, options: {
  66573. radius?: number;
  66574. tube?: number;
  66575. radialSegments?: number;
  66576. tubularSegments?: number;
  66577. p?: number;
  66578. q?: number;
  66579. updatable?: boolean;
  66580. sideOrientation?: number;
  66581. frontUVs?: Vector4;
  66582. backUVs?: Vector4;
  66583. }, scene?: Nullable<Scene>): Mesh;
  66584. /**
  66585. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66586. * * 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
  66587. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66588. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66589. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66590. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66591. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66592. * * 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
  66593. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66595. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66596. * @param name defines the name of the new line system
  66597. * @param options defines the options used to create the line system
  66598. * @param scene defines the hosting scene
  66599. * @returns a new line system mesh
  66600. */
  66601. static CreateLineSystem(name: string, options: {
  66602. lines: Vector3[][];
  66603. updatable?: boolean;
  66604. instance?: Nullable<LinesMesh>;
  66605. colors?: Nullable<Color4[][]>;
  66606. useVertexAlpha?: boolean;
  66607. }, scene: Nullable<Scene>): LinesMesh;
  66608. /**
  66609. * Creates a line mesh
  66610. * 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
  66611. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66612. * * The parameter `points` is an array successive Vector3
  66613. * * 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
  66614. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66615. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66616. * * When updating an instance, remember that only point positions can change, not the number of points
  66617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66619. * @param name defines the name of the new line system
  66620. * @param options defines the options used to create the line system
  66621. * @param scene defines the hosting scene
  66622. * @returns a new line mesh
  66623. */
  66624. static CreateLines(name: string, options: {
  66625. points: Vector3[];
  66626. updatable?: boolean;
  66627. instance?: Nullable<LinesMesh>;
  66628. colors?: Color4[];
  66629. useVertexAlpha?: boolean;
  66630. }, scene?: Nullable<Scene>): LinesMesh;
  66631. /**
  66632. * Creates a dashed line mesh
  66633. * * 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
  66634. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66635. * * The parameter `points` is an array successive Vector3
  66636. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66637. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66638. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66639. * * 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
  66640. * * When updating an instance, remember that only point positions can change, not the number of points
  66641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66642. * @param name defines the name of the mesh
  66643. * @param options defines the options used to create the mesh
  66644. * @param scene defines the hosting scene
  66645. * @returns the dashed line mesh
  66646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66647. */
  66648. static CreateDashedLines(name: string, options: {
  66649. points: Vector3[];
  66650. dashSize?: number;
  66651. gapSize?: number;
  66652. dashNb?: number;
  66653. updatable?: boolean;
  66654. instance?: LinesMesh;
  66655. }, scene?: Nullable<Scene>): LinesMesh;
  66656. /**
  66657. * 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.
  66658. * * 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.
  66659. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66660. * * 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.
  66661. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66662. * * 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
  66663. * * 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
  66664. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66666. * * 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
  66667. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66669. * @param name defines the name of the mesh
  66670. * @param options defines the options used to create the mesh
  66671. * @param scene defines the hosting scene
  66672. * @returns the extruded shape mesh
  66673. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66674. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66675. */
  66676. static ExtrudeShape(name: string, options: {
  66677. shape: Vector3[];
  66678. path: Vector3[];
  66679. scale?: number;
  66680. rotation?: number;
  66681. cap?: number;
  66682. updatable?: boolean;
  66683. sideOrientation?: number;
  66684. frontUVs?: Vector4;
  66685. backUVs?: Vector4;
  66686. instance?: Mesh;
  66687. invertUV?: boolean;
  66688. }, scene?: Nullable<Scene>): Mesh;
  66689. /**
  66690. * Creates an custom extruded shape mesh.
  66691. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66692. * * 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.
  66693. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66694. * * 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
  66695. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66696. * * 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
  66697. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66698. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66699. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66700. * * 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
  66701. * * 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
  66702. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66704. * * 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
  66705. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66707. * @param name defines the name of the mesh
  66708. * @param options defines the options used to create the mesh
  66709. * @param scene defines the hosting scene
  66710. * @returns the custom extruded shape mesh
  66711. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66712. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66714. */
  66715. static ExtrudeShapeCustom(name: string, options: {
  66716. shape: Vector3[];
  66717. path: Vector3[];
  66718. scaleFunction?: any;
  66719. rotationFunction?: any;
  66720. ribbonCloseArray?: boolean;
  66721. ribbonClosePath?: boolean;
  66722. cap?: number;
  66723. updatable?: boolean;
  66724. sideOrientation?: number;
  66725. frontUVs?: Vector4;
  66726. backUVs?: Vector4;
  66727. instance?: Mesh;
  66728. invertUV?: boolean;
  66729. }, scene?: Nullable<Scene>): Mesh;
  66730. /**
  66731. * Creates lathe mesh.
  66732. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66733. * * 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
  66734. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66735. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66736. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66737. * * 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
  66738. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66739. * * 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
  66740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66741. * * 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
  66742. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66744. * @param name defines the name of the mesh
  66745. * @param options defines the options used to create the mesh
  66746. * @param scene defines the hosting scene
  66747. * @returns the lathe mesh
  66748. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66749. */
  66750. static CreateLathe(name: string, options: {
  66751. shape: Vector3[];
  66752. radius?: number;
  66753. tessellation?: number;
  66754. clip?: number;
  66755. arc?: number;
  66756. closed?: boolean;
  66757. updatable?: boolean;
  66758. sideOrientation?: number;
  66759. frontUVs?: Vector4;
  66760. backUVs?: Vector4;
  66761. cap?: number;
  66762. invertUV?: boolean;
  66763. }, scene?: Nullable<Scene>): Mesh;
  66764. /**
  66765. * Creates a tiled plane mesh
  66766. * * You can set a limited pattern arrangement with the tiles
  66767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66768. * * 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
  66769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66770. * @param name defines the name of the mesh
  66771. * @param options defines the options used to create the mesh
  66772. * @param scene defines the hosting scene
  66773. * @returns the plane mesh
  66774. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66775. */
  66776. static CreateTiledPlane(name: string, options: {
  66777. pattern?: number;
  66778. tileSize?: number;
  66779. tileWidth?: number;
  66780. tileHeight?: number;
  66781. size?: number;
  66782. width?: number;
  66783. height?: number;
  66784. alignHorizontal?: number;
  66785. alignVertical?: number;
  66786. sideOrientation?: number;
  66787. frontUVs?: Vector4;
  66788. backUVs?: Vector4;
  66789. updatable?: boolean;
  66790. }, scene?: Nullable<Scene>): Mesh;
  66791. /**
  66792. * Creates a plane mesh
  66793. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66794. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66795. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66797. * * 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
  66798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66799. * @param name defines the name of the mesh
  66800. * @param options defines the options used to create the mesh
  66801. * @param scene defines the hosting scene
  66802. * @returns the plane mesh
  66803. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66804. */
  66805. static CreatePlane(name: string, options: {
  66806. size?: number;
  66807. width?: number;
  66808. height?: number;
  66809. sideOrientation?: number;
  66810. frontUVs?: Vector4;
  66811. backUVs?: Vector4;
  66812. updatable?: boolean;
  66813. sourcePlane?: Plane;
  66814. }, scene?: Nullable<Scene>): Mesh;
  66815. /**
  66816. * Creates a ground mesh
  66817. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66818. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66820. * @param name defines the name of the mesh
  66821. * @param options defines the options used to create the mesh
  66822. * @param scene defines the hosting scene
  66823. * @returns the ground mesh
  66824. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66825. */
  66826. static CreateGround(name: string, options: {
  66827. width?: number;
  66828. height?: number;
  66829. subdivisions?: number;
  66830. subdivisionsX?: number;
  66831. subdivisionsY?: number;
  66832. updatable?: boolean;
  66833. }, scene?: Nullable<Scene>): Mesh;
  66834. /**
  66835. * Creates a tiled ground mesh
  66836. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66837. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66838. * * 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
  66839. * * 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
  66840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66841. * @param name defines the name of the mesh
  66842. * @param options defines the options used to create the mesh
  66843. * @param scene defines the hosting scene
  66844. * @returns the tiled ground mesh
  66845. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66846. */
  66847. static CreateTiledGround(name: string, options: {
  66848. xmin: number;
  66849. zmin: number;
  66850. xmax: number;
  66851. zmax: number;
  66852. subdivisions?: {
  66853. w: number;
  66854. h: number;
  66855. };
  66856. precision?: {
  66857. w: number;
  66858. h: number;
  66859. };
  66860. updatable?: boolean;
  66861. }, scene?: Nullable<Scene>): Mesh;
  66862. /**
  66863. * Creates a ground mesh from a height map
  66864. * * The parameter `url` sets the URL of the height map image resource.
  66865. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66866. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66867. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66868. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66869. * * 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.
  66870. * * 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).
  66871. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66873. * @param name defines the name of the mesh
  66874. * @param url defines the url to the height map
  66875. * @param options defines the options used to create the mesh
  66876. * @param scene defines the hosting scene
  66877. * @returns the ground mesh
  66878. * @see https://doc.babylonjs.com/babylon101/height_map
  66879. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66880. */
  66881. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66882. width?: number;
  66883. height?: number;
  66884. subdivisions?: number;
  66885. minHeight?: number;
  66886. maxHeight?: number;
  66887. colorFilter?: Color3;
  66888. alphaFilter?: number;
  66889. updatable?: boolean;
  66890. onReady?: (mesh: GroundMesh) => void;
  66891. }, scene?: Nullable<Scene>): GroundMesh;
  66892. /**
  66893. * Creates a polygon mesh
  66894. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66895. * * 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
  66896. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66898. * * 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)
  66899. * * Remember you can only change the shape positions, not their number when updating a polygon
  66900. * @param name defines the name of the mesh
  66901. * @param options defines the options used to create the mesh
  66902. * @param scene defines the hosting scene
  66903. * @param earcutInjection can be used to inject your own earcut reference
  66904. * @returns the polygon mesh
  66905. */
  66906. static CreatePolygon(name: string, options: {
  66907. shape: Vector3[];
  66908. holes?: Vector3[][];
  66909. depth?: number;
  66910. faceUV?: Vector4[];
  66911. faceColors?: Color4[];
  66912. updatable?: boolean;
  66913. sideOrientation?: number;
  66914. frontUVs?: Vector4;
  66915. backUVs?: Vector4;
  66916. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66917. /**
  66918. * Creates an extruded polygon mesh, with depth in the Y direction.
  66919. * * 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)
  66920. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66921. * @param name defines the name of the mesh
  66922. * @param options defines the options used to create the mesh
  66923. * @param scene defines the hosting scene
  66924. * @param earcutInjection can be used to inject your own earcut reference
  66925. * @returns the polygon mesh
  66926. */
  66927. static ExtrudePolygon(name: string, options: {
  66928. shape: Vector3[];
  66929. holes?: Vector3[][];
  66930. depth?: number;
  66931. faceUV?: Vector4[];
  66932. faceColors?: Color4[];
  66933. updatable?: boolean;
  66934. sideOrientation?: number;
  66935. frontUVs?: Vector4;
  66936. backUVs?: Vector4;
  66937. wrap?: boolean;
  66938. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66939. /**
  66940. * Creates a tube mesh.
  66941. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66942. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66943. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66944. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66945. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66946. * * 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)
  66947. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66948. * * 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
  66949. * * 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
  66950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66951. * * 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
  66952. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66954. * @param name defines the name of the mesh
  66955. * @param options defines the options used to create the mesh
  66956. * @param scene defines the hosting scene
  66957. * @returns the tube mesh
  66958. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66959. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66960. */
  66961. static CreateTube(name: string, options: {
  66962. path: Vector3[];
  66963. radius?: number;
  66964. tessellation?: number;
  66965. radiusFunction?: {
  66966. (i: number, distance: number): number;
  66967. };
  66968. cap?: number;
  66969. arc?: number;
  66970. updatable?: boolean;
  66971. sideOrientation?: number;
  66972. frontUVs?: Vector4;
  66973. backUVs?: Vector4;
  66974. instance?: Mesh;
  66975. invertUV?: boolean;
  66976. }, scene?: Nullable<Scene>): Mesh;
  66977. /**
  66978. * Creates a polyhedron mesh
  66979. * * 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
  66980. * * The parameter `size` (positive float, default 1) sets the polygon size
  66981. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66982. * * 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`
  66983. * * 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
  66984. * * 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)`)
  66985. * * 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
  66986. * * 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
  66987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66988. * * 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
  66989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66990. * @param name defines the name of the mesh
  66991. * @param options defines the options used to create the mesh
  66992. * @param scene defines the hosting scene
  66993. * @returns the polyhedron mesh
  66994. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66995. */
  66996. static CreatePolyhedron(name: string, options: {
  66997. type?: number;
  66998. size?: number;
  66999. sizeX?: number;
  67000. sizeY?: number;
  67001. sizeZ?: number;
  67002. custom?: any;
  67003. faceUV?: Vector4[];
  67004. faceColors?: Color4[];
  67005. flat?: boolean;
  67006. updatable?: boolean;
  67007. sideOrientation?: number;
  67008. frontUVs?: Vector4;
  67009. backUVs?: Vector4;
  67010. }, scene?: Nullable<Scene>): Mesh;
  67011. /**
  67012. * Creates a decal mesh.
  67013. * 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
  67014. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67015. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67016. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67017. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67018. * @param name defines the name of the mesh
  67019. * @param sourceMesh defines the mesh where the decal must be applied
  67020. * @param options defines the options used to create the mesh
  67021. * @param scene defines the hosting scene
  67022. * @returns the decal mesh
  67023. * @see https://doc.babylonjs.com/how_to/decals
  67024. */
  67025. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67026. position?: Vector3;
  67027. normal?: Vector3;
  67028. size?: Vector3;
  67029. angle?: number;
  67030. }): Mesh;
  67031. /**
  67032. * Creates a Capsule Mesh
  67033. * @param name defines the name of the mesh.
  67034. * @param options the constructors options used to shape the mesh.
  67035. * @param scene defines the scene the mesh is scoped to.
  67036. * @returns the capsule mesh
  67037. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67038. */
  67039. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67040. }
  67041. }
  67042. declare module BABYLON {
  67043. /**
  67044. * A simplifier interface for future simplification implementations
  67045. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67046. */
  67047. export interface ISimplifier {
  67048. /**
  67049. * Simplification of a given mesh according to the given settings.
  67050. * Since this requires computation, it is assumed that the function runs async.
  67051. * @param settings The settings of the simplification, including quality and distance
  67052. * @param successCallback A callback that will be called after the mesh was simplified.
  67053. * @param errorCallback in case of an error, this callback will be called. optional.
  67054. */
  67055. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67056. }
  67057. /**
  67058. * Expected simplification settings.
  67059. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67060. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67061. */
  67062. export interface ISimplificationSettings {
  67063. /**
  67064. * Gets or sets the expected quality
  67065. */
  67066. quality: number;
  67067. /**
  67068. * Gets or sets the distance when this optimized version should be used
  67069. */
  67070. distance: number;
  67071. /**
  67072. * Gets an already optimized mesh
  67073. */
  67074. optimizeMesh?: boolean;
  67075. }
  67076. /**
  67077. * Class used to specify simplification options
  67078. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67079. */
  67080. export class SimplificationSettings implements ISimplificationSettings {
  67081. /** expected quality */
  67082. quality: number;
  67083. /** distance when this optimized version should be used */
  67084. distance: number;
  67085. /** already optimized mesh */
  67086. optimizeMesh?: boolean | undefined;
  67087. /**
  67088. * Creates a SimplificationSettings
  67089. * @param quality expected quality
  67090. * @param distance distance when this optimized version should be used
  67091. * @param optimizeMesh already optimized mesh
  67092. */
  67093. constructor(
  67094. /** expected quality */
  67095. quality: number,
  67096. /** distance when this optimized version should be used */
  67097. distance: number,
  67098. /** already optimized mesh */
  67099. optimizeMesh?: boolean | undefined);
  67100. }
  67101. /**
  67102. * Interface used to define a simplification task
  67103. */
  67104. export interface ISimplificationTask {
  67105. /**
  67106. * Array of settings
  67107. */
  67108. settings: Array<ISimplificationSettings>;
  67109. /**
  67110. * Simplification type
  67111. */
  67112. simplificationType: SimplificationType;
  67113. /**
  67114. * Mesh to simplify
  67115. */
  67116. mesh: Mesh;
  67117. /**
  67118. * Callback called on success
  67119. */
  67120. successCallback?: () => void;
  67121. /**
  67122. * Defines if parallel processing can be used
  67123. */
  67124. parallelProcessing: boolean;
  67125. }
  67126. /**
  67127. * Queue used to order the simplification tasks
  67128. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67129. */
  67130. export class SimplificationQueue {
  67131. private _simplificationArray;
  67132. /**
  67133. * Gets a boolean indicating that the process is still running
  67134. */
  67135. running: boolean;
  67136. /**
  67137. * Creates a new queue
  67138. */
  67139. constructor();
  67140. /**
  67141. * Adds a new simplification task
  67142. * @param task defines a task to add
  67143. */
  67144. addTask(task: ISimplificationTask): void;
  67145. /**
  67146. * Execute next task
  67147. */
  67148. executeNext(): void;
  67149. /**
  67150. * Execute a simplification task
  67151. * @param task defines the task to run
  67152. */
  67153. runSimplification(task: ISimplificationTask): void;
  67154. private getSimplifier;
  67155. }
  67156. /**
  67157. * The implemented types of simplification
  67158. * At the moment only Quadratic Error Decimation is implemented
  67159. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67160. */
  67161. export enum SimplificationType {
  67162. /** Quadratic error decimation */
  67163. QUADRATIC = 0
  67164. }
  67165. /**
  67166. * An implementation of the Quadratic Error simplification algorithm.
  67167. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67168. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67169. * @author RaananW
  67170. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67171. */
  67172. export class QuadraticErrorSimplification implements ISimplifier {
  67173. private _mesh;
  67174. private triangles;
  67175. private vertices;
  67176. private references;
  67177. private _reconstructedMesh;
  67178. /** Gets or sets the number pf sync interations */
  67179. syncIterations: number;
  67180. /** Gets or sets the aggressiveness of the simplifier */
  67181. aggressiveness: number;
  67182. /** Gets or sets the number of allowed iterations for decimation */
  67183. decimationIterations: number;
  67184. /** Gets or sets the espilon to use for bounding box computation */
  67185. boundingBoxEpsilon: number;
  67186. /**
  67187. * Creates a new QuadraticErrorSimplification
  67188. * @param _mesh defines the target mesh
  67189. */
  67190. constructor(_mesh: Mesh);
  67191. /**
  67192. * Simplification of a given mesh according to the given settings.
  67193. * Since this requires computation, it is assumed that the function runs async.
  67194. * @param settings The settings of the simplification, including quality and distance
  67195. * @param successCallback A callback that will be called after the mesh was simplified.
  67196. */
  67197. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67198. private runDecimation;
  67199. private initWithMesh;
  67200. private init;
  67201. private reconstructMesh;
  67202. private initDecimatedMesh;
  67203. private isFlipped;
  67204. private updateTriangles;
  67205. private identifyBorder;
  67206. private updateMesh;
  67207. private vertexError;
  67208. private calculateError;
  67209. }
  67210. }
  67211. declare module BABYLON {
  67212. interface Scene {
  67213. /** @hidden (Backing field) */
  67214. _simplificationQueue: SimplificationQueue;
  67215. /**
  67216. * Gets or sets the simplification queue attached to the scene
  67217. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67218. */
  67219. simplificationQueue: SimplificationQueue;
  67220. }
  67221. interface Mesh {
  67222. /**
  67223. * Simplify the mesh according to the given array of settings.
  67224. * Function will return immediately and will simplify async
  67225. * @param settings a collection of simplification settings
  67226. * @param parallelProcessing should all levels calculate parallel or one after the other
  67227. * @param simplificationType the type of simplification to run
  67228. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67229. * @returns the current mesh
  67230. */
  67231. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67232. }
  67233. /**
  67234. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67235. * created in a scene
  67236. */
  67237. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67238. /**
  67239. * The component name helpfull to identify the component in the list of scene components.
  67240. */
  67241. readonly name: string;
  67242. /**
  67243. * The scene the component belongs to.
  67244. */
  67245. scene: Scene;
  67246. /**
  67247. * Creates a new instance of the component for the given scene
  67248. * @param scene Defines the scene to register the component in
  67249. */
  67250. constructor(scene: Scene);
  67251. /**
  67252. * Registers the component in a given scene
  67253. */
  67254. register(): void;
  67255. /**
  67256. * Rebuilds the elements related to this component in case of
  67257. * context lost for instance.
  67258. */
  67259. rebuild(): void;
  67260. /**
  67261. * Disposes the component and the associated ressources
  67262. */
  67263. dispose(): void;
  67264. private _beforeCameraUpdate;
  67265. }
  67266. }
  67267. declare module BABYLON {
  67268. interface Mesh {
  67269. /**
  67270. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67271. */
  67272. thinInstanceEnablePicking: boolean;
  67273. /**
  67274. * Creates a new thin instance
  67275. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67276. * @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
  67277. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67278. */
  67279. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67280. /**
  67281. * Adds the transformation (matrix) of the current mesh as a thin instance
  67282. * @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
  67283. * @returns the thin instance index number
  67284. */
  67285. thinInstanceAddSelf(refresh: boolean): number;
  67286. /**
  67287. * Registers a custom attribute to be used with thin instances
  67288. * @param kind name of the attribute
  67289. * @param stride size in floats of the attribute
  67290. */
  67291. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67292. /**
  67293. * Sets the matrix of a thin instance
  67294. * @param index index of the thin instance
  67295. * @param matrix matrix to set
  67296. * @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
  67297. */
  67298. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67299. /**
  67300. * Sets the value of a custom attribute for a thin instance
  67301. * @param kind name of the attribute
  67302. * @param index index of the thin instance
  67303. * @param value value to set
  67304. * @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
  67305. */
  67306. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67307. /**
  67308. * 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.
  67309. */
  67310. thinInstanceCount: number;
  67311. /**
  67312. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67313. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67314. * @param buffer buffer to set
  67315. * @param stride size in floats of each value of the buffer
  67316. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67317. */
  67318. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67319. /**
  67320. * Gets the list of world matrices
  67321. * @return an array containing all the world matrices from the thin instances
  67322. */
  67323. thinInstanceGetWorldMatrices(): Matrix[];
  67324. /**
  67325. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67326. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67327. */
  67328. thinInstanceBufferUpdated(kind: string): void;
  67329. /**
  67330. * Applies a partial update to a buffer directly on the GPU
  67331. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  67332. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67333. * @param data the data to set in the GPU buffer
  67334. * @param offset the offset in the GPU buffer where to update the data
  67335. */
  67336. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67337. /**
  67338. * Refreshes the bounding info, taking into account all the thin instances defined
  67339. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67340. */
  67341. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67342. /** @hidden */
  67343. _thinInstanceInitializeUserStorage(): void;
  67344. /** @hidden */
  67345. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67346. /** @hidden */
  67347. _userThinInstanceBuffersStorage: {
  67348. data: {
  67349. [key: string]: Float32Array;
  67350. };
  67351. sizes: {
  67352. [key: string]: number;
  67353. };
  67354. vertexBuffers: {
  67355. [key: string]: Nullable<VertexBuffer>;
  67356. };
  67357. strides: {
  67358. [key: string]: number;
  67359. };
  67360. };
  67361. }
  67362. }
  67363. declare module BABYLON {
  67364. /**
  67365. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67366. */
  67367. export interface INavigationEnginePlugin {
  67368. /**
  67369. * plugin name
  67370. */
  67371. name: string;
  67372. /**
  67373. * Creates a navigation mesh
  67374. * @param meshes array of all the geometry used to compute the navigatio mesh
  67375. * @param parameters bunch of parameters used to filter geometry
  67376. */
  67377. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67378. /**
  67379. * Create a navigation mesh debug mesh
  67380. * @param scene is where the mesh will be added
  67381. * @returns debug display mesh
  67382. */
  67383. createDebugNavMesh(scene: Scene): Mesh;
  67384. /**
  67385. * Get a navigation mesh constrained position, closest to the parameter position
  67386. * @param position world position
  67387. * @returns the closest point to position constrained by the navigation mesh
  67388. */
  67389. getClosestPoint(position: Vector3): Vector3;
  67390. /**
  67391. * Get a navigation mesh constrained position, closest to the parameter position
  67392. * @param position world position
  67393. * @param result output the closest point to position constrained by the navigation mesh
  67394. */
  67395. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67396. /**
  67397. * Get a navigation mesh constrained position, within a particular radius
  67398. * @param position world position
  67399. * @param maxRadius the maximum distance to the constrained world position
  67400. * @returns the closest point to position constrained by the navigation mesh
  67401. */
  67402. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67403. /**
  67404. * Get a navigation mesh constrained position, within a particular radius
  67405. * @param position world position
  67406. * @param maxRadius the maximum distance to the constrained world position
  67407. * @param result output the closest point to position constrained by the navigation mesh
  67408. */
  67409. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67410. /**
  67411. * Compute the final position from a segment made of destination-position
  67412. * @param position world position
  67413. * @param destination world position
  67414. * @returns the resulting point along the navmesh
  67415. */
  67416. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67417. /**
  67418. * Compute the final position from a segment made of destination-position
  67419. * @param position world position
  67420. * @param destination world position
  67421. * @param result output the resulting point along the navmesh
  67422. */
  67423. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67424. /**
  67425. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67426. * @param start world position
  67427. * @param end world position
  67428. * @returns array containing world position composing the path
  67429. */
  67430. computePath(start: Vector3, end: Vector3): Vector3[];
  67431. /**
  67432. * If this plugin is supported
  67433. * @returns true if plugin is supported
  67434. */
  67435. isSupported(): boolean;
  67436. /**
  67437. * Create a new Crowd so you can add agents
  67438. * @param maxAgents the maximum agent count in the crowd
  67439. * @param maxAgentRadius the maximum radius an agent can have
  67440. * @param scene to attach the crowd to
  67441. * @returns the crowd you can add agents to
  67442. */
  67443. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67444. /**
  67445. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67446. * The queries will try to find a solution within those bounds
  67447. * default is (1,1,1)
  67448. * @param extent x,y,z value that define the extent around the queries point of reference
  67449. */
  67450. setDefaultQueryExtent(extent: Vector3): void;
  67451. /**
  67452. * Get the Bounding box extent specified by setDefaultQueryExtent
  67453. * @returns the box extent values
  67454. */
  67455. getDefaultQueryExtent(): Vector3;
  67456. /**
  67457. * build the navmesh from a previously saved state using getNavmeshData
  67458. * @param data the Uint8Array returned by getNavmeshData
  67459. */
  67460. buildFromNavmeshData(data: Uint8Array): void;
  67461. /**
  67462. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67463. * @returns data the Uint8Array that can be saved and reused
  67464. */
  67465. getNavmeshData(): Uint8Array;
  67466. /**
  67467. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67468. * @param result output the box extent values
  67469. */
  67470. getDefaultQueryExtentToRef(result: Vector3): void;
  67471. /**
  67472. * Release all resources
  67473. */
  67474. dispose(): void;
  67475. }
  67476. /**
  67477. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67478. */
  67479. export interface ICrowd {
  67480. /**
  67481. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67482. * You can attach anything to that node. The node position is updated in the scene update tick.
  67483. * @param pos world position that will be constrained by the navigation mesh
  67484. * @param parameters agent parameters
  67485. * @param transform hooked to the agent that will be update by the scene
  67486. * @returns agent index
  67487. */
  67488. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67489. /**
  67490. * Returns the agent position in world space
  67491. * @param index agent index returned by addAgent
  67492. * @returns world space position
  67493. */
  67494. getAgentPosition(index: number): Vector3;
  67495. /**
  67496. * Gets the agent position result in world space
  67497. * @param index agent index returned by addAgent
  67498. * @param result output world space position
  67499. */
  67500. getAgentPositionToRef(index: number, result: Vector3): void;
  67501. /**
  67502. * Gets the agent velocity in world space
  67503. * @param index agent index returned by addAgent
  67504. * @returns world space velocity
  67505. */
  67506. getAgentVelocity(index: number): Vector3;
  67507. /**
  67508. * Gets the agent velocity result in world space
  67509. * @param index agent index returned by addAgent
  67510. * @param result output world space velocity
  67511. */
  67512. getAgentVelocityToRef(index: number, result: Vector3): void;
  67513. /**
  67514. * remove a particular agent previously created
  67515. * @param index agent index returned by addAgent
  67516. */
  67517. removeAgent(index: number): void;
  67518. /**
  67519. * get the list of all agents attached to this crowd
  67520. * @returns list of agent indices
  67521. */
  67522. getAgents(): number[];
  67523. /**
  67524. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67525. * @param deltaTime in seconds
  67526. */
  67527. update(deltaTime: number): void;
  67528. /**
  67529. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67530. * @param index agent index returned by addAgent
  67531. * @param destination targeted world position
  67532. */
  67533. agentGoto(index: number, destination: Vector3): void;
  67534. /**
  67535. * Teleport the agent to a new position
  67536. * @param index agent index returned by addAgent
  67537. * @param destination targeted world position
  67538. */
  67539. agentTeleport(index: number, destination: Vector3): void;
  67540. /**
  67541. * Update agent parameters
  67542. * @param index agent index returned by addAgent
  67543. * @param parameters agent parameters
  67544. */
  67545. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67546. /**
  67547. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67548. * The queries will try to find a solution within those bounds
  67549. * default is (1,1,1)
  67550. * @param extent x,y,z value that define the extent around the queries point of reference
  67551. */
  67552. setDefaultQueryExtent(extent: Vector3): void;
  67553. /**
  67554. * Get the Bounding box extent specified by setDefaultQueryExtent
  67555. * @returns the box extent values
  67556. */
  67557. getDefaultQueryExtent(): Vector3;
  67558. /**
  67559. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67560. * @param result output the box extent values
  67561. */
  67562. getDefaultQueryExtentToRef(result: Vector3): void;
  67563. /**
  67564. * Release all resources
  67565. */
  67566. dispose(): void;
  67567. }
  67568. /**
  67569. * Configures an agent
  67570. */
  67571. export interface IAgentParameters {
  67572. /**
  67573. * Agent radius. [Limit: >= 0]
  67574. */
  67575. radius: number;
  67576. /**
  67577. * Agent height. [Limit: > 0]
  67578. */
  67579. height: number;
  67580. /**
  67581. * Maximum allowed acceleration. [Limit: >= 0]
  67582. */
  67583. maxAcceleration: number;
  67584. /**
  67585. * Maximum allowed speed. [Limit: >= 0]
  67586. */
  67587. maxSpeed: number;
  67588. /**
  67589. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67590. */
  67591. collisionQueryRange: number;
  67592. /**
  67593. * The path visibility optimization range. [Limit: > 0]
  67594. */
  67595. pathOptimizationRange: number;
  67596. /**
  67597. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67598. */
  67599. separationWeight: number;
  67600. }
  67601. /**
  67602. * Configures the navigation mesh creation
  67603. */
  67604. export interface INavMeshParameters {
  67605. /**
  67606. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67607. */
  67608. cs: number;
  67609. /**
  67610. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67611. */
  67612. ch: number;
  67613. /**
  67614. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67615. */
  67616. walkableSlopeAngle: number;
  67617. /**
  67618. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67619. * be considered walkable. [Limit: >= 3] [Units: vx]
  67620. */
  67621. walkableHeight: number;
  67622. /**
  67623. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67624. */
  67625. walkableClimb: number;
  67626. /**
  67627. * The distance to erode/shrink the walkable area of the heightfield away from
  67628. * obstructions. [Limit: >=0] [Units: vx]
  67629. */
  67630. walkableRadius: number;
  67631. /**
  67632. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67633. */
  67634. maxEdgeLen: number;
  67635. /**
  67636. * The maximum distance a simplfied contour's border edges should deviate
  67637. * the original raw contour. [Limit: >=0] [Units: vx]
  67638. */
  67639. maxSimplificationError: number;
  67640. /**
  67641. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67642. */
  67643. minRegionArea: number;
  67644. /**
  67645. * Any regions with a span count smaller than this value will, if possible,
  67646. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67647. */
  67648. mergeRegionArea: number;
  67649. /**
  67650. * The maximum number of vertices allowed for polygons generated during the
  67651. * contour to polygon conversion process. [Limit: >= 3]
  67652. */
  67653. maxVertsPerPoly: number;
  67654. /**
  67655. * Sets the sampling distance to use when generating the detail mesh.
  67656. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67657. */
  67658. detailSampleDist: number;
  67659. /**
  67660. * The maximum distance the detail mesh surface should deviate from heightfield
  67661. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67662. */
  67663. detailSampleMaxError: number;
  67664. }
  67665. }
  67666. declare module BABYLON {
  67667. /**
  67668. * RecastJS navigation plugin
  67669. */
  67670. export class RecastJSPlugin implements INavigationEnginePlugin {
  67671. /**
  67672. * Reference to the Recast library
  67673. */
  67674. bjsRECAST: any;
  67675. /**
  67676. * plugin name
  67677. */
  67678. name: string;
  67679. /**
  67680. * the first navmesh created. We might extend this to support multiple navmeshes
  67681. */
  67682. navMesh: any;
  67683. /**
  67684. * Initializes the recastJS plugin
  67685. * @param recastInjection can be used to inject your own recast reference
  67686. */
  67687. constructor(recastInjection?: any);
  67688. /**
  67689. * Creates a navigation mesh
  67690. * @param meshes array of all the geometry used to compute the navigatio mesh
  67691. * @param parameters bunch of parameters used to filter geometry
  67692. */
  67693. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67694. /**
  67695. * Create a navigation mesh debug mesh
  67696. * @param scene is where the mesh will be added
  67697. * @returns debug display mesh
  67698. */
  67699. createDebugNavMesh(scene: Scene): Mesh;
  67700. /**
  67701. * Get a navigation mesh constrained position, closest to the parameter position
  67702. * @param position world position
  67703. * @returns the closest point to position constrained by the navigation mesh
  67704. */
  67705. getClosestPoint(position: Vector3): Vector3;
  67706. /**
  67707. * Get a navigation mesh constrained position, closest to the parameter position
  67708. * @param position world position
  67709. * @param result output the closest point to position constrained by the navigation mesh
  67710. */
  67711. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67712. /**
  67713. * Get a navigation mesh constrained position, within a particular radius
  67714. * @param position world position
  67715. * @param maxRadius the maximum distance to the constrained world position
  67716. * @returns the closest point to position constrained by the navigation mesh
  67717. */
  67718. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67719. /**
  67720. * Get a navigation mesh constrained position, within a particular radius
  67721. * @param position world position
  67722. * @param maxRadius the maximum distance to the constrained world position
  67723. * @param result output the closest point to position constrained by the navigation mesh
  67724. */
  67725. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67726. /**
  67727. * Compute the final position from a segment made of destination-position
  67728. * @param position world position
  67729. * @param destination world position
  67730. * @returns the resulting point along the navmesh
  67731. */
  67732. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67733. /**
  67734. * Compute the final position from a segment made of destination-position
  67735. * @param position world position
  67736. * @param destination world position
  67737. * @param result output the resulting point along the navmesh
  67738. */
  67739. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67740. /**
  67741. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67742. * @param start world position
  67743. * @param end world position
  67744. * @returns array containing world position composing the path
  67745. */
  67746. computePath(start: Vector3, end: Vector3): Vector3[];
  67747. /**
  67748. * Create a new Crowd so you can add agents
  67749. * @param maxAgents the maximum agent count in the crowd
  67750. * @param maxAgentRadius the maximum radius an agent can have
  67751. * @param scene to attach the crowd to
  67752. * @returns the crowd you can add agents to
  67753. */
  67754. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67755. /**
  67756. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67757. * The queries will try to find a solution within those bounds
  67758. * default is (1,1,1)
  67759. * @param extent x,y,z value that define the extent around the queries point of reference
  67760. */
  67761. setDefaultQueryExtent(extent: Vector3): void;
  67762. /**
  67763. * Get the Bounding box extent specified by setDefaultQueryExtent
  67764. * @returns the box extent values
  67765. */
  67766. getDefaultQueryExtent(): Vector3;
  67767. /**
  67768. * build the navmesh from a previously saved state using getNavmeshData
  67769. * @param data the Uint8Array returned by getNavmeshData
  67770. */
  67771. buildFromNavmeshData(data: Uint8Array): void;
  67772. /**
  67773. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67774. * @returns data the Uint8Array that can be saved and reused
  67775. */
  67776. getNavmeshData(): Uint8Array;
  67777. /**
  67778. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67779. * @param result output the box extent values
  67780. */
  67781. getDefaultQueryExtentToRef(result: Vector3): void;
  67782. /**
  67783. * Disposes
  67784. */
  67785. dispose(): void;
  67786. /**
  67787. * If this plugin is supported
  67788. * @returns true if plugin is supported
  67789. */
  67790. isSupported(): boolean;
  67791. }
  67792. /**
  67793. * Recast detour crowd implementation
  67794. */
  67795. export class RecastJSCrowd implements ICrowd {
  67796. /**
  67797. * Recast/detour plugin
  67798. */
  67799. bjsRECASTPlugin: RecastJSPlugin;
  67800. /**
  67801. * Link to the detour crowd
  67802. */
  67803. recastCrowd: any;
  67804. /**
  67805. * One transform per agent
  67806. */
  67807. transforms: TransformNode[];
  67808. /**
  67809. * All agents created
  67810. */
  67811. agents: number[];
  67812. /**
  67813. * Link to the scene is kept to unregister the crowd from the scene
  67814. */
  67815. private _scene;
  67816. /**
  67817. * Observer for crowd updates
  67818. */
  67819. private _onBeforeAnimationsObserver;
  67820. /**
  67821. * Constructor
  67822. * @param plugin recastJS plugin
  67823. * @param maxAgents the maximum agent count in the crowd
  67824. * @param maxAgentRadius the maximum radius an agent can have
  67825. * @param scene to attach the crowd to
  67826. * @returns the crowd you can add agents to
  67827. */
  67828. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67829. /**
  67830. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67831. * You can attach anything to that node. The node position is updated in the scene update tick.
  67832. * @param pos world position that will be constrained by the navigation mesh
  67833. * @param parameters agent parameters
  67834. * @param transform hooked to the agent that will be update by the scene
  67835. * @returns agent index
  67836. */
  67837. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67838. /**
  67839. * Returns the agent position in world space
  67840. * @param index agent index returned by addAgent
  67841. * @returns world space position
  67842. */
  67843. getAgentPosition(index: number): Vector3;
  67844. /**
  67845. * Returns the agent position result in world space
  67846. * @param index agent index returned by addAgent
  67847. * @param result output world space position
  67848. */
  67849. getAgentPositionToRef(index: number, result: Vector3): void;
  67850. /**
  67851. * Returns the agent velocity in world space
  67852. * @param index agent index returned by addAgent
  67853. * @returns world space velocity
  67854. */
  67855. getAgentVelocity(index: number): Vector3;
  67856. /**
  67857. * Returns the agent velocity result in world space
  67858. * @param index agent index returned by addAgent
  67859. * @param result output world space velocity
  67860. */
  67861. getAgentVelocityToRef(index: number, result: Vector3): void;
  67862. /**
  67863. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67864. * @param index agent index returned by addAgent
  67865. * @param destination targeted world position
  67866. */
  67867. agentGoto(index: number, destination: Vector3): void;
  67868. /**
  67869. * Teleport the agent to a new position
  67870. * @param index agent index returned by addAgent
  67871. * @param destination targeted world position
  67872. */
  67873. agentTeleport(index: number, destination: Vector3): void;
  67874. /**
  67875. * Update agent parameters
  67876. * @param index agent index returned by addAgent
  67877. * @param parameters agent parameters
  67878. */
  67879. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67880. /**
  67881. * remove a particular agent previously created
  67882. * @param index agent index returned by addAgent
  67883. */
  67884. removeAgent(index: number): void;
  67885. /**
  67886. * get the list of all agents attached to this crowd
  67887. * @returns list of agent indices
  67888. */
  67889. getAgents(): number[];
  67890. /**
  67891. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67892. * @param deltaTime in seconds
  67893. */
  67894. update(deltaTime: number): void;
  67895. /**
  67896. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67897. * The queries will try to find a solution within those bounds
  67898. * default is (1,1,1)
  67899. * @param extent x,y,z value that define the extent around the queries point of reference
  67900. */
  67901. setDefaultQueryExtent(extent: Vector3): void;
  67902. /**
  67903. * Get the Bounding box extent specified by setDefaultQueryExtent
  67904. * @returns the box extent values
  67905. */
  67906. getDefaultQueryExtent(): Vector3;
  67907. /**
  67908. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67909. * @param result output the box extent values
  67910. */
  67911. getDefaultQueryExtentToRef(result: Vector3): void;
  67912. /**
  67913. * Release all resources
  67914. */
  67915. dispose(): void;
  67916. }
  67917. }
  67918. declare module BABYLON {
  67919. /**
  67920. * Class used to enable access to IndexedDB
  67921. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67922. */
  67923. export class Database implements IOfflineProvider {
  67924. private _callbackManifestChecked;
  67925. private _currentSceneUrl;
  67926. private _db;
  67927. private _enableSceneOffline;
  67928. private _enableTexturesOffline;
  67929. private _manifestVersionFound;
  67930. private _mustUpdateRessources;
  67931. private _hasReachedQuota;
  67932. private _isSupported;
  67933. private _idbFactory;
  67934. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67935. private static IsUASupportingBlobStorage;
  67936. /**
  67937. * Gets a boolean indicating if Database storate is enabled (off by default)
  67938. */
  67939. static IDBStorageEnabled: boolean;
  67940. /**
  67941. * Gets a boolean indicating if scene must be saved in the database
  67942. */
  67943. get enableSceneOffline(): boolean;
  67944. /**
  67945. * Gets a boolean indicating if textures must be saved in the database
  67946. */
  67947. get enableTexturesOffline(): boolean;
  67948. /**
  67949. * Creates a new Database
  67950. * @param urlToScene defines the url to load the scene
  67951. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67952. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67953. */
  67954. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67955. private static _ParseURL;
  67956. private static _ReturnFullUrlLocation;
  67957. private _checkManifestFile;
  67958. /**
  67959. * Open the database and make it available
  67960. * @param successCallback defines the callback to call on success
  67961. * @param errorCallback defines the callback to call on error
  67962. */
  67963. open(successCallback: () => void, errorCallback: () => void): void;
  67964. /**
  67965. * Loads an image from the database
  67966. * @param url defines the url to load from
  67967. * @param image defines the target DOM image
  67968. */
  67969. loadImage(url: string, image: HTMLImageElement): void;
  67970. private _loadImageFromDBAsync;
  67971. private _saveImageIntoDBAsync;
  67972. private _checkVersionFromDB;
  67973. private _loadVersionFromDBAsync;
  67974. private _saveVersionIntoDBAsync;
  67975. /**
  67976. * Loads a file from database
  67977. * @param url defines the URL to load from
  67978. * @param sceneLoaded defines a callback to call on success
  67979. * @param progressCallBack defines a callback to call when progress changed
  67980. * @param errorCallback defines a callback to call on error
  67981. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67982. */
  67983. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67984. private _loadFileAsync;
  67985. private _saveFileAsync;
  67986. /**
  67987. * Validates if xhr data is correct
  67988. * @param xhr defines the request to validate
  67989. * @param dataType defines the expected data type
  67990. * @returns true if data is correct
  67991. */
  67992. private static _ValidateXHRData;
  67993. }
  67994. }
  67995. declare module BABYLON {
  67996. /** @hidden */
  67997. export var gpuUpdateParticlesPixelShader: {
  67998. name: string;
  67999. shader: string;
  68000. };
  68001. }
  68002. declare module BABYLON {
  68003. /** @hidden */
  68004. export var gpuUpdateParticlesVertexShader: {
  68005. name: string;
  68006. shader: string;
  68007. };
  68008. }
  68009. declare module BABYLON {
  68010. /** @hidden */
  68011. export var clipPlaneFragmentDeclaration2: {
  68012. name: string;
  68013. shader: string;
  68014. };
  68015. }
  68016. declare module BABYLON {
  68017. /** @hidden */
  68018. export var gpuRenderParticlesPixelShader: {
  68019. name: string;
  68020. shader: string;
  68021. };
  68022. }
  68023. declare module BABYLON {
  68024. /** @hidden */
  68025. export var clipPlaneVertexDeclaration2: {
  68026. name: string;
  68027. shader: string;
  68028. };
  68029. }
  68030. declare module BABYLON {
  68031. /** @hidden */
  68032. export var gpuRenderParticlesVertexShader: {
  68033. name: string;
  68034. shader: string;
  68035. };
  68036. }
  68037. declare module BABYLON {
  68038. /**
  68039. * This represents a GPU particle system in Babylon
  68040. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68041. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68042. */
  68043. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68044. /**
  68045. * The layer mask we are rendering the particles through.
  68046. */
  68047. layerMask: number;
  68048. private _capacity;
  68049. private _activeCount;
  68050. private _currentActiveCount;
  68051. private _accumulatedCount;
  68052. private _renderEffect;
  68053. private _updateEffect;
  68054. private _buffer0;
  68055. private _buffer1;
  68056. private _spriteBuffer;
  68057. private _updateVAO;
  68058. private _renderVAO;
  68059. private _targetIndex;
  68060. private _sourceBuffer;
  68061. private _targetBuffer;
  68062. private _currentRenderId;
  68063. private _started;
  68064. private _stopped;
  68065. private _timeDelta;
  68066. private _randomTexture;
  68067. private _randomTexture2;
  68068. private _attributesStrideSize;
  68069. private _updateEffectOptions;
  68070. private _randomTextureSize;
  68071. private _actualFrame;
  68072. private _customEffect;
  68073. private readonly _rawTextureWidth;
  68074. /**
  68075. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68076. */
  68077. static get IsSupported(): boolean;
  68078. /**
  68079. * An event triggered when the system is disposed.
  68080. */
  68081. onDisposeObservable: Observable<IParticleSystem>;
  68082. /**
  68083. * An event triggered when the system is stopped
  68084. */
  68085. onStoppedObservable: Observable<IParticleSystem>;
  68086. /**
  68087. * Gets the maximum number of particles active at the same time.
  68088. * @returns The max number of active particles.
  68089. */
  68090. getCapacity(): number;
  68091. /**
  68092. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68093. * to override the particles.
  68094. */
  68095. forceDepthWrite: boolean;
  68096. /**
  68097. * Gets or set the number of active particles
  68098. */
  68099. get activeParticleCount(): number;
  68100. set activeParticleCount(value: number);
  68101. private _preWarmDone;
  68102. /**
  68103. * Specifies if the particles are updated in emitter local space or world space.
  68104. */
  68105. isLocal: boolean;
  68106. /** Gets or sets a matrix to use to compute projection */
  68107. defaultProjectionMatrix: Matrix;
  68108. /**
  68109. * Is this system ready to be used/rendered
  68110. * @return true if the system is ready
  68111. */
  68112. isReady(): boolean;
  68113. /**
  68114. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68115. * @returns True if it has been started, otherwise false.
  68116. */
  68117. isStarted(): boolean;
  68118. /**
  68119. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68120. * @returns True if it has been stopped, otherwise false.
  68121. */
  68122. isStopped(): boolean;
  68123. /**
  68124. * Gets a boolean indicating that the system is stopping
  68125. * @returns true if the system is currently stopping
  68126. */
  68127. isStopping(): boolean;
  68128. /**
  68129. * Gets the number of particles active at the same time.
  68130. * @returns The number of active particles.
  68131. */
  68132. getActiveCount(): number;
  68133. /**
  68134. * Starts the particle system and begins to emit
  68135. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68136. */
  68137. start(delay?: number): void;
  68138. /**
  68139. * Stops the particle system.
  68140. */
  68141. stop(): void;
  68142. /**
  68143. * Remove all active particles
  68144. */
  68145. reset(): void;
  68146. /**
  68147. * Returns the string "GPUParticleSystem"
  68148. * @returns a string containing the class name
  68149. */
  68150. getClassName(): string;
  68151. /**
  68152. * Gets the custom effect used to render the particles
  68153. * @param blendMode Blend mode for which the effect should be retrieved
  68154. * @returns The effect
  68155. */
  68156. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68157. /**
  68158. * Sets the custom effect used to render the particles
  68159. * @param effect The effect to set
  68160. * @param blendMode Blend mode for which the effect should be set
  68161. */
  68162. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68163. /** @hidden */
  68164. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68165. /**
  68166. * Observable that will be called just before the particles are drawn
  68167. */
  68168. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68169. /**
  68170. * Gets the name of the particle vertex shader
  68171. */
  68172. get vertexShaderName(): string;
  68173. private _colorGradientsTexture;
  68174. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68175. /**
  68176. * Adds a new color gradient
  68177. * @param gradient defines the gradient to use (between 0 and 1)
  68178. * @param color1 defines the color to affect to the specified gradient
  68179. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68180. * @returns the current particle system
  68181. */
  68182. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68183. private _refreshColorGradient;
  68184. /** Force the system to rebuild all gradients that need to be resync */
  68185. forceRefreshGradients(): void;
  68186. /**
  68187. * Remove a specific color gradient
  68188. * @param gradient defines the gradient to remove
  68189. * @returns the current particle system
  68190. */
  68191. removeColorGradient(gradient: number): GPUParticleSystem;
  68192. private _angularSpeedGradientsTexture;
  68193. private _sizeGradientsTexture;
  68194. private _velocityGradientsTexture;
  68195. private _limitVelocityGradientsTexture;
  68196. private _dragGradientsTexture;
  68197. private _addFactorGradient;
  68198. /**
  68199. * Adds a new size gradient
  68200. * @param gradient defines the gradient to use (between 0 and 1)
  68201. * @param factor defines the size factor to affect to the specified gradient
  68202. * @returns the current particle system
  68203. */
  68204. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68205. /**
  68206. * Remove a specific size gradient
  68207. * @param gradient defines the gradient to remove
  68208. * @returns the current particle system
  68209. */
  68210. removeSizeGradient(gradient: number): GPUParticleSystem;
  68211. private _refreshFactorGradient;
  68212. /**
  68213. * Adds a new angular speed gradient
  68214. * @param gradient defines the gradient to use (between 0 and 1)
  68215. * @param factor defines the angular speed to affect to the specified gradient
  68216. * @returns the current particle system
  68217. */
  68218. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68219. /**
  68220. * Remove a specific angular speed gradient
  68221. * @param gradient defines the gradient to remove
  68222. * @returns the current particle system
  68223. */
  68224. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68225. /**
  68226. * Adds a new velocity gradient
  68227. * @param gradient defines the gradient to use (between 0 and 1)
  68228. * @param factor defines the velocity to affect to the specified gradient
  68229. * @returns the current particle system
  68230. */
  68231. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68232. /**
  68233. * Remove a specific velocity gradient
  68234. * @param gradient defines the gradient to remove
  68235. * @returns the current particle system
  68236. */
  68237. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68238. /**
  68239. * Adds a new limit velocity gradient
  68240. * @param gradient defines the gradient to use (between 0 and 1)
  68241. * @param factor defines the limit velocity value to affect to the specified gradient
  68242. * @returns the current particle system
  68243. */
  68244. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68245. /**
  68246. * Remove a specific limit velocity gradient
  68247. * @param gradient defines the gradient to remove
  68248. * @returns the current particle system
  68249. */
  68250. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68251. /**
  68252. * Adds a new drag gradient
  68253. * @param gradient defines the gradient to use (between 0 and 1)
  68254. * @param factor defines the drag value to affect to the specified gradient
  68255. * @returns the current particle system
  68256. */
  68257. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68258. /**
  68259. * Remove a specific drag gradient
  68260. * @param gradient defines the gradient to remove
  68261. * @returns the current particle system
  68262. */
  68263. removeDragGradient(gradient: number): GPUParticleSystem;
  68264. /**
  68265. * Not supported by GPUParticleSystem
  68266. * @param gradient defines the gradient to use (between 0 and 1)
  68267. * @param factor defines the emit rate value to affect to the specified gradient
  68268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68269. * @returns the current particle system
  68270. */
  68271. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68272. /**
  68273. * Not supported by GPUParticleSystem
  68274. * @param gradient defines the gradient to remove
  68275. * @returns the current particle system
  68276. */
  68277. removeEmitRateGradient(gradient: number): IParticleSystem;
  68278. /**
  68279. * Not supported by GPUParticleSystem
  68280. * @param gradient defines the gradient to use (between 0 and 1)
  68281. * @param factor defines the start size value to affect to the specified gradient
  68282. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68283. * @returns the current particle system
  68284. */
  68285. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68286. /**
  68287. * Not supported by GPUParticleSystem
  68288. * @param gradient defines the gradient to remove
  68289. * @returns the current particle system
  68290. */
  68291. removeStartSizeGradient(gradient: number): IParticleSystem;
  68292. /**
  68293. * Not supported by GPUParticleSystem
  68294. * @param gradient defines the gradient to use (between 0 and 1)
  68295. * @param min defines the color remap minimal range
  68296. * @param max defines the color remap maximal range
  68297. * @returns the current particle system
  68298. */
  68299. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68300. /**
  68301. * Not supported by GPUParticleSystem
  68302. * @param gradient defines the gradient to remove
  68303. * @returns the current particle system
  68304. */
  68305. removeColorRemapGradient(): IParticleSystem;
  68306. /**
  68307. * Not supported by GPUParticleSystem
  68308. * @param gradient defines the gradient to use (between 0 and 1)
  68309. * @param min defines the alpha remap minimal range
  68310. * @param max defines the alpha remap maximal range
  68311. * @returns the current particle system
  68312. */
  68313. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68314. /**
  68315. * Not supported by GPUParticleSystem
  68316. * @param gradient defines the gradient to remove
  68317. * @returns the current particle system
  68318. */
  68319. removeAlphaRemapGradient(): IParticleSystem;
  68320. /**
  68321. * Not supported by GPUParticleSystem
  68322. * @param gradient defines the gradient to use (between 0 and 1)
  68323. * @param color defines the color to affect to the specified gradient
  68324. * @returns the current particle system
  68325. */
  68326. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68327. /**
  68328. * Not supported by GPUParticleSystem
  68329. * @param gradient defines the gradient to remove
  68330. * @returns the current particle system
  68331. */
  68332. removeRampGradient(): IParticleSystem;
  68333. /**
  68334. * Not supported by GPUParticleSystem
  68335. * @returns the list of ramp gradients
  68336. */
  68337. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68338. /**
  68339. * Not supported by GPUParticleSystem
  68340. * Gets or sets a boolean indicating that ramp gradients must be used
  68341. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68342. */
  68343. get useRampGradients(): boolean;
  68344. set useRampGradients(value: boolean);
  68345. /**
  68346. * Not supported by GPUParticleSystem
  68347. * @param gradient defines the gradient to use (between 0 and 1)
  68348. * @param factor defines the life time factor to affect to the specified gradient
  68349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68350. * @returns the current particle system
  68351. */
  68352. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68353. /**
  68354. * Not supported by GPUParticleSystem
  68355. * @param gradient defines the gradient to remove
  68356. * @returns the current particle system
  68357. */
  68358. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68359. /**
  68360. * Instantiates a GPU particle system.
  68361. * 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.
  68362. * @param name The name of the particle system
  68363. * @param options The options used to create the system
  68364. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68365. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68366. * @param customEffect a custom effect used to change the way particles are rendered by default
  68367. */
  68368. constructor(name: string, options: Partial<{
  68369. capacity: number;
  68370. randomTextureSize: number;
  68371. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68372. protected _reset(): void;
  68373. private _createUpdateVAO;
  68374. private _createRenderVAO;
  68375. private _initialize;
  68376. /** @hidden */
  68377. _recreateUpdateEffect(): void;
  68378. private _getEffect;
  68379. /**
  68380. * Fill the defines array according to the current settings of the particle system
  68381. * @param defines Array to be updated
  68382. * @param blendMode blend mode to take into account when updating the array
  68383. */
  68384. fillDefines(defines: Array<string>, blendMode?: number): void;
  68385. /**
  68386. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68387. * @param uniforms Uniforms array to fill
  68388. * @param attributes Attributes array to fill
  68389. * @param samplers Samplers array to fill
  68390. */
  68391. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68392. /** @hidden */
  68393. _recreateRenderEffect(): Effect;
  68394. /**
  68395. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68396. * @param preWarm defines if we are in the pre-warmimg phase
  68397. */
  68398. animate(preWarm?: boolean): void;
  68399. private _createFactorGradientTexture;
  68400. private _createSizeGradientTexture;
  68401. private _createAngularSpeedGradientTexture;
  68402. private _createVelocityGradientTexture;
  68403. private _createLimitVelocityGradientTexture;
  68404. private _createDragGradientTexture;
  68405. private _createColorGradientTexture;
  68406. /**
  68407. * Renders the particle system in its current state
  68408. * @param preWarm defines if the system should only update the particles but not render them
  68409. * @returns the current number of particles
  68410. */
  68411. render(preWarm?: boolean): number;
  68412. /**
  68413. * Rebuilds the particle system
  68414. */
  68415. rebuild(): void;
  68416. private _releaseBuffers;
  68417. private _releaseVAOs;
  68418. /**
  68419. * Disposes the particle system and free the associated resources
  68420. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68421. */
  68422. dispose(disposeTexture?: boolean): void;
  68423. /**
  68424. * Clones the particle system.
  68425. * @param name The name of the cloned object
  68426. * @param newEmitter The new emitter to use
  68427. * @returns the cloned particle system
  68428. */
  68429. clone(name: string, newEmitter: any): GPUParticleSystem;
  68430. /**
  68431. * Serializes the particle system to a JSON object
  68432. * @param serializeTexture defines if the texture must be serialized as well
  68433. * @returns the JSON object
  68434. */
  68435. serialize(serializeTexture?: boolean): any;
  68436. /**
  68437. * Parses a JSON object to create a GPU particle system.
  68438. * @param parsedParticleSystem The JSON object to parse
  68439. * @param sceneOrEngine The scene or the engine to create the particle system in
  68440. * @param rootUrl The root url to use to load external dependencies like texture
  68441. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68442. * @returns the parsed GPU particle system
  68443. */
  68444. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68445. }
  68446. }
  68447. declare module BABYLON {
  68448. /**
  68449. * Represents a set of particle systems working together to create a specific effect
  68450. */
  68451. export class ParticleSystemSet implements IDisposable {
  68452. /**
  68453. * Gets or sets base Assets URL
  68454. */
  68455. static BaseAssetsUrl: string;
  68456. private _emitterCreationOptions;
  68457. private _emitterNode;
  68458. /**
  68459. * Gets the particle system list
  68460. */
  68461. systems: IParticleSystem[];
  68462. /**
  68463. * Gets the emitter node used with this set
  68464. */
  68465. get emitterNode(): Nullable<TransformNode>;
  68466. /**
  68467. * Creates a new emitter mesh as a sphere
  68468. * @param options defines the options used to create the sphere
  68469. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68470. * @param scene defines the hosting scene
  68471. */
  68472. setEmitterAsSphere(options: {
  68473. diameter: number;
  68474. segments: number;
  68475. color: Color3;
  68476. }, renderingGroupId: number, scene: Scene): void;
  68477. /**
  68478. * Starts all particle systems of the set
  68479. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68480. */
  68481. start(emitter?: AbstractMesh): void;
  68482. /**
  68483. * Release all associated resources
  68484. */
  68485. dispose(): void;
  68486. /**
  68487. * Serialize the set into a JSON compatible object
  68488. * @param serializeTexture defines if the texture must be serialized as well
  68489. * @returns a JSON compatible representation of the set
  68490. */
  68491. serialize(serializeTexture?: boolean): any;
  68492. /**
  68493. * Parse a new ParticleSystemSet from a serialized source
  68494. * @param data defines a JSON compatible representation of the set
  68495. * @param scene defines the hosting scene
  68496. * @param gpu defines if we want GPU particles or CPU particles
  68497. * @returns a new ParticleSystemSet
  68498. */
  68499. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68500. }
  68501. }
  68502. declare module BABYLON {
  68503. /**
  68504. * This class is made for on one-liner static method to help creating particle system set.
  68505. */
  68506. export class ParticleHelper {
  68507. /**
  68508. * Gets or sets base Assets URL
  68509. */
  68510. static BaseAssetsUrl: string;
  68511. /** Define the Url to load snippets */
  68512. static SnippetUrl: string;
  68513. /**
  68514. * Create a default particle system that you can tweak
  68515. * @param emitter defines the emitter to use
  68516. * @param capacity defines the system capacity (default is 500 particles)
  68517. * @param scene defines the hosting scene
  68518. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68519. * @returns the new Particle system
  68520. */
  68521. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68522. /**
  68523. * This is the main static method (one-liner) of this helper to create different particle systems
  68524. * @param type This string represents the type to the particle system to create
  68525. * @param scene The scene where the particle system should live
  68526. * @param gpu If the system will use gpu
  68527. * @returns the ParticleSystemSet created
  68528. */
  68529. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68530. /**
  68531. * Static function used to export a particle system to a ParticleSystemSet variable.
  68532. * Please note that the emitter shape is not exported
  68533. * @param systems defines the particle systems to export
  68534. * @returns the created particle system set
  68535. */
  68536. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68537. /**
  68538. * Creates a particle system from a snippet saved in a remote file
  68539. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68540. * @param url defines the url to load from
  68541. * @param scene defines the hosting scene
  68542. * @param gpu If the system will use gpu
  68543. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68544. * @returns a promise that will resolve to the new particle system
  68545. */
  68546. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68547. /**
  68548. * Creates a particle system from a snippet saved by the particle system editor
  68549. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68550. * @param scene defines the hosting scene
  68551. * @param gpu If the system will use gpu
  68552. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68553. * @returns a promise that will resolve to the new particle system
  68554. */
  68555. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68556. }
  68557. }
  68558. declare module BABYLON {
  68559. interface Engine {
  68560. /**
  68561. * Create an effect to use with particle systems.
  68562. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68563. * the particle system for which you want to create a custom effect in the last parameter
  68564. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68565. * @param uniformsNames defines a list of attribute names
  68566. * @param samplers defines an array of string used to represent textures
  68567. * @param defines defines the string containing the defines to use to compile the shaders
  68568. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68569. * @param onCompiled defines a function to call when the effect creation is successful
  68570. * @param onError defines a function to call when the effect creation has failed
  68571. * @param particleSystem the particle system you want to create the effect for
  68572. * @returns the new Effect
  68573. */
  68574. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68575. }
  68576. interface Mesh {
  68577. /**
  68578. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68579. * @returns an array of IParticleSystem
  68580. */
  68581. getEmittedParticleSystems(): IParticleSystem[];
  68582. /**
  68583. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68584. * @returns an array of IParticleSystem
  68585. */
  68586. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68587. }
  68588. }
  68589. declare module BABYLON {
  68590. /** Defines the 4 color options */
  68591. export enum PointColor {
  68592. /** color value */
  68593. Color = 2,
  68594. /** uv value */
  68595. UV = 1,
  68596. /** random value */
  68597. Random = 0,
  68598. /** stated value */
  68599. Stated = 3
  68600. }
  68601. /**
  68602. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68603. * 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.
  68604. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68605. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68606. *
  68607. * Full documentation here : TO BE ENTERED
  68608. */
  68609. export class PointsCloudSystem implements IDisposable {
  68610. /**
  68611. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68612. * Example : var p = SPS.particles[i];
  68613. */
  68614. particles: CloudPoint[];
  68615. /**
  68616. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68617. */
  68618. nbParticles: number;
  68619. /**
  68620. * This a counter for your own usage. It's not set by any SPS functions.
  68621. */
  68622. counter: number;
  68623. /**
  68624. * The PCS name. This name is also given to the underlying mesh.
  68625. */
  68626. name: string;
  68627. /**
  68628. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68629. */
  68630. mesh: Mesh;
  68631. /**
  68632. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68633. * Please read :
  68634. */
  68635. vars: any;
  68636. /**
  68637. * @hidden
  68638. */
  68639. _size: number;
  68640. private _scene;
  68641. private _promises;
  68642. private _positions;
  68643. private _indices;
  68644. private _normals;
  68645. private _colors;
  68646. private _uvs;
  68647. private _indices32;
  68648. private _positions32;
  68649. private _colors32;
  68650. private _uvs32;
  68651. private _updatable;
  68652. private _isVisibilityBoxLocked;
  68653. private _alwaysVisible;
  68654. private _groups;
  68655. private _groupCounter;
  68656. private _computeParticleColor;
  68657. private _computeParticleTexture;
  68658. private _computeParticleRotation;
  68659. private _computeBoundingBox;
  68660. private _isReady;
  68661. /**
  68662. * Creates a PCS (Points Cloud System) object
  68663. * @param name (String) is the PCS name, this will be the underlying mesh name
  68664. * @param pointSize (number) is the size for each point
  68665. * @param scene (Scene) is the scene in which the PCS is added
  68666. * @param options defines the options of the PCS e.g.
  68667. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68668. */
  68669. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68670. updatable?: boolean;
  68671. });
  68672. /**
  68673. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68674. * If no points were added to the PCS, the returned mesh is just a single point.
  68675. * @returns a promise for the created mesh
  68676. */
  68677. buildMeshAsync(): Promise<Mesh>;
  68678. /**
  68679. * @hidden
  68680. */
  68681. private _buildMesh;
  68682. private _addParticle;
  68683. private _randomUnitVector;
  68684. private _getColorIndicesForCoord;
  68685. private _setPointsColorOrUV;
  68686. private _colorFromTexture;
  68687. private _calculateDensity;
  68688. /**
  68689. * Adds points to the PCS in random positions within a unit sphere
  68690. * @param nb (positive integer) the number of particles to be created from this model
  68691. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68692. * @returns the number of groups in the system
  68693. */
  68694. addPoints(nb: number, pointFunction?: any): number;
  68695. /**
  68696. * Adds points to the PCS from the surface of the model shape
  68697. * @param mesh is any Mesh object that will be used as a surface model for the points
  68698. * @param nb (positive integer) the number of particles to be created from this model
  68699. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68700. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68701. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68702. * @returns the number of groups in the system
  68703. */
  68704. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68705. /**
  68706. * Adds points to the PCS inside the model shape
  68707. * @param mesh is any Mesh object that will be used as a surface model for the points
  68708. * @param nb (positive integer) the number of particles to be created from this model
  68709. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68710. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68711. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68712. * @returns the number of groups in the system
  68713. */
  68714. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68715. /**
  68716. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68717. * This method calls `updateParticle()` for each particle of the SPS.
  68718. * For an animated SPS, it is usually called within the render loop.
  68719. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68720. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68721. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68722. * @returns the PCS.
  68723. */
  68724. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68725. /**
  68726. * Disposes the PCS.
  68727. */
  68728. dispose(): void;
  68729. /**
  68730. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68731. * doc :
  68732. * @returns the PCS.
  68733. */
  68734. refreshVisibleSize(): PointsCloudSystem;
  68735. /**
  68736. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68737. * @param size the size (float) of the visibility box
  68738. * note : this doesn't lock the PCS mesh bounding box.
  68739. * doc :
  68740. */
  68741. setVisibilityBox(size: number): void;
  68742. /**
  68743. * Gets whether the PCS is always visible or not
  68744. * doc :
  68745. */
  68746. get isAlwaysVisible(): boolean;
  68747. /**
  68748. * Sets the PCS as always visible or not
  68749. * doc :
  68750. */
  68751. set isAlwaysVisible(val: boolean);
  68752. /**
  68753. * Tells to `setParticles()` to compute the particle rotations or not
  68754. * Default value : false. The PCS is faster when it's set to false
  68755. * Note : particle rotations are only applied to parent particles
  68756. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68757. */
  68758. set computeParticleRotation(val: boolean);
  68759. /**
  68760. * Tells to `setParticles()` to compute the particle colors or not.
  68761. * Default value : true. The PCS is faster when it's set to false.
  68762. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68763. */
  68764. set computeParticleColor(val: boolean);
  68765. set computeParticleTexture(val: boolean);
  68766. /**
  68767. * Gets if `setParticles()` computes the particle colors or not.
  68768. * Default value : false. The PCS is faster when it's set to false.
  68769. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68770. */
  68771. get computeParticleColor(): boolean;
  68772. /**
  68773. * Gets if `setParticles()` computes the particle textures or not.
  68774. * Default value : false. The PCS is faster when it's set to false.
  68775. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68776. */
  68777. get computeParticleTexture(): boolean;
  68778. /**
  68779. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68780. */
  68781. set computeBoundingBox(val: boolean);
  68782. /**
  68783. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68784. */
  68785. get computeBoundingBox(): boolean;
  68786. /**
  68787. * This function does nothing. It may be overwritten to set all the particle first values.
  68788. * The PCS doesn't call this function, you may have to call it by your own.
  68789. * doc :
  68790. */
  68791. initParticles(): void;
  68792. /**
  68793. * This function does nothing. It may be overwritten to recycle a particle
  68794. * The PCS doesn't call this function, you can to call it
  68795. * doc :
  68796. * @param particle The particle to recycle
  68797. * @returns the recycled particle
  68798. */
  68799. recycleParticle(particle: CloudPoint): CloudPoint;
  68800. /**
  68801. * Updates a particle : this function should be overwritten by the user.
  68802. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68803. * doc :
  68804. * @example : just set a particle position or velocity and recycle conditions
  68805. * @param particle The particle to update
  68806. * @returns the updated particle
  68807. */
  68808. updateParticle(particle: CloudPoint): CloudPoint;
  68809. /**
  68810. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68811. * This does nothing and may be overwritten by the user.
  68812. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68813. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68814. * @param update the boolean update value actually passed to setParticles()
  68815. */
  68816. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68817. /**
  68818. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68819. * This will be passed three parameters.
  68820. * This does nothing and may be overwritten by the user.
  68821. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68822. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68823. * @param update the boolean update value actually passed to setParticles()
  68824. */
  68825. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68826. }
  68827. }
  68828. declare module BABYLON {
  68829. /**
  68830. * Represents one particle of a points cloud system.
  68831. */
  68832. export class CloudPoint {
  68833. /**
  68834. * particle global index
  68835. */
  68836. idx: number;
  68837. /**
  68838. * The color of the particle
  68839. */
  68840. color: Nullable<Color4>;
  68841. /**
  68842. * The world space position of the particle.
  68843. */
  68844. position: Vector3;
  68845. /**
  68846. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68847. */
  68848. rotation: Vector3;
  68849. /**
  68850. * The world space rotation quaternion of the particle.
  68851. */
  68852. rotationQuaternion: Nullable<Quaternion>;
  68853. /**
  68854. * The uv of the particle.
  68855. */
  68856. uv: Nullable<Vector2>;
  68857. /**
  68858. * The current speed of the particle.
  68859. */
  68860. velocity: Vector3;
  68861. /**
  68862. * The pivot point in the particle local space.
  68863. */
  68864. pivot: Vector3;
  68865. /**
  68866. * Must the particle be translated from its pivot point in its local space ?
  68867. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68868. * Default : false
  68869. */
  68870. translateFromPivot: boolean;
  68871. /**
  68872. * Index of this particle in the global "positions" array (Internal use)
  68873. * @hidden
  68874. */
  68875. _pos: number;
  68876. /**
  68877. * @hidden Index of this particle in the global "indices" array (Internal use)
  68878. */
  68879. _ind: number;
  68880. /**
  68881. * Group this particle belongs to
  68882. */
  68883. _group: PointsGroup;
  68884. /**
  68885. * Group id of this particle
  68886. */
  68887. groupId: number;
  68888. /**
  68889. * Index of the particle in its group id (Internal use)
  68890. */
  68891. idxInGroup: number;
  68892. /**
  68893. * @hidden Particle BoundingInfo object (Internal use)
  68894. */
  68895. _boundingInfo: BoundingInfo;
  68896. /**
  68897. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68898. */
  68899. _pcs: PointsCloudSystem;
  68900. /**
  68901. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68902. */
  68903. _stillInvisible: boolean;
  68904. /**
  68905. * @hidden Last computed particle rotation matrix
  68906. */
  68907. _rotationMatrix: number[];
  68908. /**
  68909. * Parent particle Id, if any.
  68910. * Default null.
  68911. */
  68912. parentId: Nullable<number>;
  68913. /**
  68914. * @hidden Internal global position in the PCS.
  68915. */
  68916. _globalPosition: Vector3;
  68917. /**
  68918. * Creates a Point Cloud object.
  68919. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68920. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68921. * @param group (PointsGroup) is the group the particle belongs to
  68922. * @param groupId (integer) is the group identifier in the PCS.
  68923. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68924. * @param pcs defines the PCS it is associated to
  68925. */
  68926. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68927. /**
  68928. * get point size
  68929. */
  68930. get size(): Vector3;
  68931. /**
  68932. * Set point size
  68933. */
  68934. set size(scale: Vector3);
  68935. /**
  68936. * Legacy support, changed quaternion to rotationQuaternion
  68937. */
  68938. get quaternion(): Nullable<Quaternion>;
  68939. /**
  68940. * Legacy support, changed quaternion to rotationQuaternion
  68941. */
  68942. set quaternion(q: Nullable<Quaternion>);
  68943. /**
  68944. * Returns a boolean. True if the particle intersects a mesh, else false
  68945. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68946. * @param target is the object (point or mesh) what the intersection is computed against
  68947. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68948. * @returns true if it intersects
  68949. */
  68950. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68951. /**
  68952. * get the rotation matrix of the particle
  68953. * @hidden
  68954. */
  68955. getRotationMatrix(m: Matrix): void;
  68956. }
  68957. /**
  68958. * Represents a group of points in a points cloud system
  68959. * * PCS internal tool, don't use it manually.
  68960. */
  68961. export class PointsGroup {
  68962. /**
  68963. * The group id
  68964. * @hidden
  68965. */
  68966. groupID: number;
  68967. /**
  68968. * image data for group (internal use)
  68969. * @hidden
  68970. */
  68971. _groupImageData: Nullable<ArrayBufferView>;
  68972. /**
  68973. * Image Width (internal use)
  68974. * @hidden
  68975. */
  68976. _groupImgWidth: number;
  68977. /**
  68978. * Image Height (internal use)
  68979. * @hidden
  68980. */
  68981. _groupImgHeight: number;
  68982. /**
  68983. * Custom position function (internal use)
  68984. * @hidden
  68985. */
  68986. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68987. /**
  68988. * density per facet for surface points
  68989. * @hidden
  68990. */
  68991. _groupDensity: number[];
  68992. /**
  68993. * Only when points are colored by texture carries pointer to texture list array
  68994. * @hidden
  68995. */
  68996. _textureNb: number;
  68997. /**
  68998. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68999. * PCS internal tool, don't use it manually.
  69000. * @hidden
  69001. */
  69002. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69003. }
  69004. }
  69005. declare module BABYLON {
  69006. interface Scene {
  69007. /** @hidden (Backing field) */
  69008. _physicsEngine: Nullable<IPhysicsEngine>;
  69009. /** @hidden */
  69010. _physicsTimeAccumulator: number;
  69011. /**
  69012. * Gets the current physics engine
  69013. * @returns a IPhysicsEngine or null if none attached
  69014. */
  69015. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69016. /**
  69017. * Enables physics to the current scene
  69018. * @param gravity defines the scene's gravity for the physics engine
  69019. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69020. * @return a boolean indicating if the physics engine was initialized
  69021. */
  69022. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69023. /**
  69024. * Disables and disposes the physics engine associated with the scene
  69025. */
  69026. disablePhysicsEngine(): void;
  69027. /**
  69028. * Gets a boolean indicating if there is an active physics engine
  69029. * @returns a boolean indicating if there is an active physics engine
  69030. */
  69031. isPhysicsEnabled(): boolean;
  69032. /**
  69033. * Deletes a physics compound impostor
  69034. * @param compound defines the compound to delete
  69035. */
  69036. deleteCompoundImpostor(compound: any): void;
  69037. /**
  69038. * An event triggered when physic simulation is about to be run
  69039. */
  69040. onBeforePhysicsObservable: Observable<Scene>;
  69041. /**
  69042. * An event triggered when physic simulation has been done
  69043. */
  69044. onAfterPhysicsObservable: Observable<Scene>;
  69045. }
  69046. interface AbstractMesh {
  69047. /** @hidden */
  69048. _physicsImpostor: Nullable<PhysicsImpostor>;
  69049. /**
  69050. * Gets or sets impostor used for physic simulation
  69051. * @see https://doc.babylonjs.com/features/physics_engine
  69052. */
  69053. physicsImpostor: Nullable<PhysicsImpostor>;
  69054. /**
  69055. * Gets the current physics impostor
  69056. * @see https://doc.babylonjs.com/features/physics_engine
  69057. * @returns a physics impostor or null
  69058. */
  69059. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69060. /** Apply a physic impulse to the mesh
  69061. * @param force defines the force to apply
  69062. * @param contactPoint defines where to apply the force
  69063. * @returns the current mesh
  69064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69065. */
  69066. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69067. /**
  69068. * Creates a physic joint between two meshes
  69069. * @param otherMesh defines the other mesh to use
  69070. * @param pivot1 defines the pivot to use on this mesh
  69071. * @param pivot2 defines the pivot to use on the other mesh
  69072. * @param options defines additional options (can be plugin dependent)
  69073. * @returns the current mesh
  69074. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69075. */
  69076. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69077. /** @hidden */
  69078. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69079. }
  69080. /**
  69081. * Defines the physics engine scene component responsible to manage a physics engine
  69082. */
  69083. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69084. /**
  69085. * The component name helpful to identify the component in the list of scene components.
  69086. */
  69087. readonly name: string;
  69088. /**
  69089. * The scene the component belongs to.
  69090. */
  69091. scene: Scene;
  69092. /**
  69093. * Creates a new instance of the component for the given scene
  69094. * @param scene Defines the scene to register the component in
  69095. */
  69096. constructor(scene: Scene);
  69097. /**
  69098. * Registers the component in a given scene
  69099. */
  69100. register(): void;
  69101. /**
  69102. * Rebuilds the elements related to this component in case of
  69103. * context lost for instance.
  69104. */
  69105. rebuild(): void;
  69106. /**
  69107. * Disposes the component and the associated ressources
  69108. */
  69109. dispose(): void;
  69110. }
  69111. }
  69112. declare module BABYLON {
  69113. /**
  69114. * A helper for physics simulations
  69115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69116. */
  69117. export class PhysicsHelper {
  69118. private _scene;
  69119. private _physicsEngine;
  69120. /**
  69121. * Initializes the Physics helper
  69122. * @param scene Babylon.js scene
  69123. */
  69124. constructor(scene: Scene);
  69125. /**
  69126. * Applies a radial explosion impulse
  69127. * @param origin the origin of the explosion
  69128. * @param radiusOrEventOptions the radius or the options of radial explosion
  69129. * @param strength the explosion strength
  69130. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69131. * @returns A physics radial explosion event, or null
  69132. */
  69133. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69134. /**
  69135. * Applies a radial explosion force
  69136. * @param origin the origin of the explosion
  69137. * @param radiusOrEventOptions the radius or the options of radial explosion
  69138. * @param strength the explosion strength
  69139. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69140. * @returns A physics radial explosion event, or null
  69141. */
  69142. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69143. /**
  69144. * Creates a gravitational field
  69145. * @param origin the origin of the explosion
  69146. * @param radiusOrEventOptions the radius or the options of radial explosion
  69147. * @param strength the explosion strength
  69148. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69149. * @returns A physics gravitational field event, or null
  69150. */
  69151. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69152. /**
  69153. * Creates a physics updraft event
  69154. * @param origin the origin of the updraft
  69155. * @param radiusOrEventOptions the radius or the options of the updraft
  69156. * @param strength the strength of the updraft
  69157. * @param height the height of the updraft
  69158. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69159. * @returns A physics updraft event, or null
  69160. */
  69161. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69162. /**
  69163. * Creates a physics vortex event
  69164. * @param origin the of the vortex
  69165. * @param radiusOrEventOptions the radius or the options of the vortex
  69166. * @param strength the strength of the vortex
  69167. * @param height the height of the vortex
  69168. * @returns a Physics vortex event, or null
  69169. * A physics vortex event or null
  69170. */
  69171. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69172. }
  69173. /**
  69174. * Represents a physics radial explosion event
  69175. */
  69176. class PhysicsRadialExplosionEvent {
  69177. private _scene;
  69178. private _options;
  69179. private _sphere;
  69180. private _dataFetched;
  69181. /**
  69182. * Initializes a radial explosioin event
  69183. * @param _scene BabylonJS scene
  69184. * @param _options The options for the vortex event
  69185. */
  69186. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69187. /**
  69188. * Returns the data related to the radial explosion event (sphere).
  69189. * @returns The radial explosion event data
  69190. */
  69191. getData(): PhysicsRadialExplosionEventData;
  69192. /**
  69193. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69194. * @param impostor A physics imposter
  69195. * @param origin the origin of the explosion
  69196. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69197. */
  69198. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69199. /**
  69200. * Triggers affecterd impostors callbacks
  69201. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69202. */
  69203. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69204. /**
  69205. * Disposes the sphere.
  69206. * @param force Specifies if the sphere should be disposed by force
  69207. */
  69208. dispose(force?: boolean): void;
  69209. /*** Helpers ***/
  69210. private _prepareSphere;
  69211. private _intersectsWithSphere;
  69212. }
  69213. /**
  69214. * Represents a gravitational field event
  69215. */
  69216. class PhysicsGravitationalFieldEvent {
  69217. private _physicsHelper;
  69218. private _scene;
  69219. private _origin;
  69220. private _options;
  69221. private _tickCallback;
  69222. private _sphere;
  69223. private _dataFetched;
  69224. /**
  69225. * Initializes the physics gravitational field event
  69226. * @param _physicsHelper A physics helper
  69227. * @param _scene BabylonJS scene
  69228. * @param _origin The origin position of the gravitational field event
  69229. * @param _options The options for the vortex event
  69230. */
  69231. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69232. /**
  69233. * Returns the data related to the gravitational field event (sphere).
  69234. * @returns A gravitational field event
  69235. */
  69236. getData(): PhysicsGravitationalFieldEventData;
  69237. /**
  69238. * Enables the gravitational field.
  69239. */
  69240. enable(): void;
  69241. /**
  69242. * Disables the gravitational field.
  69243. */
  69244. disable(): void;
  69245. /**
  69246. * Disposes the sphere.
  69247. * @param force The force to dispose from the gravitational field event
  69248. */
  69249. dispose(force?: boolean): void;
  69250. private _tick;
  69251. }
  69252. /**
  69253. * Represents a physics updraft event
  69254. */
  69255. class PhysicsUpdraftEvent {
  69256. private _scene;
  69257. private _origin;
  69258. private _options;
  69259. private _physicsEngine;
  69260. private _originTop;
  69261. private _originDirection;
  69262. private _tickCallback;
  69263. private _cylinder;
  69264. private _cylinderPosition;
  69265. private _dataFetched;
  69266. /**
  69267. * Initializes the physics updraft event
  69268. * @param _scene BabylonJS scene
  69269. * @param _origin The origin position of the updraft
  69270. * @param _options The options for the updraft event
  69271. */
  69272. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69273. /**
  69274. * Returns the data related to the updraft event (cylinder).
  69275. * @returns A physics updraft event
  69276. */
  69277. getData(): PhysicsUpdraftEventData;
  69278. /**
  69279. * Enables the updraft.
  69280. */
  69281. enable(): void;
  69282. /**
  69283. * Disables the updraft.
  69284. */
  69285. disable(): void;
  69286. /**
  69287. * Disposes the cylinder.
  69288. * @param force Specifies if the updraft should be disposed by force
  69289. */
  69290. dispose(force?: boolean): void;
  69291. private getImpostorHitData;
  69292. private _tick;
  69293. /*** Helpers ***/
  69294. private _prepareCylinder;
  69295. private _intersectsWithCylinder;
  69296. }
  69297. /**
  69298. * Represents a physics vortex event
  69299. */
  69300. class PhysicsVortexEvent {
  69301. private _scene;
  69302. private _origin;
  69303. private _options;
  69304. private _physicsEngine;
  69305. private _originTop;
  69306. private _tickCallback;
  69307. private _cylinder;
  69308. private _cylinderPosition;
  69309. private _dataFetched;
  69310. /**
  69311. * Initializes the physics vortex event
  69312. * @param _scene The BabylonJS scene
  69313. * @param _origin The origin position of the vortex
  69314. * @param _options The options for the vortex event
  69315. */
  69316. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69317. /**
  69318. * Returns the data related to the vortex event (cylinder).
  69319. * @returns The physics vortex event data
  69320. */
  69321. getData(): PhysicsVortexEventData;
  69322. /**
  69323. * Enables the vortex.
  69324. */
  69325. enable(): void;
  69326. /**
  69327. * Disables the cortex.
  69328. */
  69329. disable(): void;
  69330. /**
  69331. * Disposes the sphere.
  69332. * @param force
  69333. */
  69334. dispose(force?: boolean): void;
  69335. private getImpostorHitData;
  69336. private _tick;
  69337. /*** Helpers ***/
  69338. private _prepareCylinder;
  69339. private _intersectsWithCylinder;
  69340. }
  69341. /**
  69342. * Options fot the radial explosion event
  69343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69344. */
  69345. export class PhysicsRadialExplosionEventOptions {
  69346. /**
  69347. * The radius of the sphere for the radial explosion.
  69348. */
  69349. radius: number;
  69350. /**
  69351. * The strenth of the explosion.
  69352. */
  69353. strength: number;
  69354. /**
  69355. * The strenght of the force in correspondence to the distance of the affected object
  69356. */
  69357. falloff: PhysicsRadialImpulseFalloff;
  69358. /**
  69359. * Sphere options for the radial explosion.
  69360. */
  69361. sphere: {
  69362. segments: number;
  69363. diameter: number;
  69364. };
  69365. /**
  69366. * Sphere options for the radial explosion.
  69367. */
  69368. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69369. }
  69370. /**
  69371. * Options fot the updraft event
  69372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69373. */
  69374. export class PhysicsUpdraftEventOptions {
  69375. /**
  69376. * The radius of the cylinder for the vortex
  69377. */
  69378. radius: number;
  69379. /**
  69380. * The strenth of the updraft.
  69381. */
  69382. strength: number;
  69383. /**
  69384. * The height of the cylinder for the updraft.
  69385. */
  69386. height: number;
  69387. /**
  69388. * The mode for the the updraft.
  69389. */
  69390. updraftMode: PhysicsUpdraftMode;
  69391. }
  69392. /**
  69393. * Options fot the vortex event
  69394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69395. */
  69396. export class PhysicsVortexEventOptions {
  69397. /**
  69398. * The radius of the cylinder for the vortex
  69399. */
  69400. radius: number;
  69401. /**
  69402. * The strenth of the vortex.
  69403. */
  69404. strength: number;
  69405. /**
  69406. * The height of the cylinder for the vortex.
  69407. */
  69408. height: number;
  69409. /**
  69410. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69411. */
  69412. centripetalForceThreshold: number;
  69413. /**
  69414. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69415. */
  69416. centripetalForceMultiplier: number;
  69417. /**
  69418. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69419. */
  69420. centrifugalForceMultiplier: number;
  69421. /**
  69422. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69423. */
  69424. updraftForceMultiplier: number;
  69425. }
  69426. /**
  69427. * The strenght of the force in correspondence to the distance of the affected object
  69428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69429. */
  69430. export enum PhysicsRadialImpulseFalloff {
  69431. /** Defines that impulse is constant in strength across it's whole radius */
  69432. Constant = 0,
  69433. /** Defines that impulse gets weaker if it's further from the origin */
  69434. Linear = 1
  69435. }
  69436. /**
  69437. * The strength of the force in correspondence to the distance of the affected object
  69438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69439. */
  69440. export enum PhysicsUpdraftMode {
  69441. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69442. Center = 0,
  69443. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69444. Perpendicular = 1
  69445. }
  69446. /**
  69447. * Interface for a physics hit data
  69448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69449. */
  69450. export interface PhysicsHitData {
  69451. /**
  69452. * The force applied at the contact point
  69453. */
  69454. force: Vector3;
  69455. /**
  69456. * The contact point
  69457. */
  69458. contactPoint: Vector3;
  69459. /**
  69460. * The distance from the origin to the contact point
  69461. */
  69462. distanceFromOrigin: number;
  69463. }
  69464. /**
  69465. * Interface for radial explosion event data
  69466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69467. */
  69468. export interface PhysicsRadialExplosionEventData {
  69469. /**
  69470. * A sphere used for the radial explosion event
  69471. */
  69472. sphere: Mesh;
  69473. }
  69474. /**
  69475. * Interface for gravitational field event data
  69476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69477. */
  69478. export interface PhysicsGravitationalFieldEventData {
  69479. /**
  69480. * A sphere mesh used for the gravitational field event
  69481. */
  69482. sphere: Mesh;
  69483. }
  69484. /**
  69485. * Interface for updraft event data
  69486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69487. */
  69488. export interface PhysicsUpdraftEventData {
  69489. /**
  69490. * A cylinder used for the updraft event
  69491. */
  69492. cylinder: Mesh;
  69493. }
  69494. /**
  69495. * Interface for vortex event data
  69496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69497. */
  69498. export interface PhysicsVortexEventData {
  69499. /**
  69500. * A cylinder used for the vortex event
  69501. */
  69502. cylinder: Mesh;
  69503. }
  69504. /**
  69505. * Interface for an affected physics impostor
  69506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69507. */
  69508. export interface PhysicsAffectedImpostorWithData {
  69509. /**
  69510. * The impostor affected by the effect
  69511. */
  69512. impostor: PhysicsImpostor;
  69513. /**
  69514. * The data about the hit/horce from the explosion
  69515. */
  69516. hitData: PhysicsHitData;
  69517. }
  69518. }
  69519. declare module BABYLON {
  69520. /** @hidden */
  69521. export var blackAndWhitePixelShader: {
  69522. name: string;
  69523. shader: string;
  69524. };
  69525. }
  69526. declare module BABYLON {
  69527. /**
  69528. * Post process used to render in black and white
  69529. */
  69530. export class BlackAndWhitePostProcess extends PostProcess {
  69531. /**
  69532. * Linear about to convert he result to black and white (default: 1)
  69533. */
  69534. degree: number;
  69535. /**
  69536. * Gets a string identifying the name of the class
  69537. * @returns "BlackAndWhitePostProcess" string
  69538. */
  69539. getClassName(): string;
  69540. /**
  69541. * Creates a black and white post process
  69542. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69543. * @param name The name of the effect.
  69544. * @param options The required width/height ratio to downsize to before computing the render pass.
  69545. * @param camera The camera to apply the render pass to.
  69546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69547. * @param engine The engine which the post process will be applied. (default: current engine)
  69548. * @param reusable If the post process can be reused on the same frame. (default: false)
  69549. */
  69550. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69551. /** @hidden */
  69552. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69553. }
  69554. }
  69555. declare module BABYLON {
  69556. /**
  69557. * This represents a set of one or more post processes in Babylon.
  69558. * A post process can be used to apply a shader to a texture after it is rendered.
  69559. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69560. */
  69561. export class PostProcessRenderEffect {
  69562. private _postProcesses;
  69563. private _getPostProcesses;
  69564. private _singleInstance;
  69565. private _cameras;
  69566. private _indicesForCamera;
  69567. /**
  69568. * Name of the effect
  69569. * @hidden
  69570. */
  69571. _name: string;
  69572. /**
  69573. * Instantiates a post process render effect.
  69574. * A post process can be used to apply a shader to a texture after it is rendered.
  69575. * @param engine The engine the effect is tied to
  69576. * @param name The name of the effect
  69577. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69578. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69579. */
  69580. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69581. /**
  69582. * Checks if all the post processes in the effect are supported.
  69583. */
  69584. get isSupported(): boolean;
  69585. /**
  69586. * Updates the current state of the effect
  69587. * @hidden
  69588. */
  69589. _update(): void;
  69590. /**
  69591. * Attaches the effect on cameras
  69592. * @param cameras The camera to attach to.
  69593. * @hidden
  69594. */
  69595. _attachCameras(cameras: Camera): void;
  69596. /**
  69597. * Attaches the effect on cameras
  69598. * @param cameras The camera to attach to.
  69599. * @hidden
  69600. */
  69601. _attachCameras(cameras: Camera[]): void;
  69602. /**
  69603. * Detaches the effect on cameras
  69604. * @param cameras The camera to detatch from.
  69605. * @hidden
  69606. */
  69607. _detachCameras(cameras: Camera): void;
  69608. /**
  69609. * Detatches the effect on cameras
  69610. * @param cameras The camera to detatch from.
  69611. * @hidden
  69612. */
  69613. _detachCameras(cameras: Camera[]): void;
  69614. /**
  69615. * Enables the effect on given cameras
  69616. * @param cameras The camera to enable.
  69617. * @hidden
  69618. */
  69619. _enable(cameras: Camera): void;
  69620. /**
  69621. * Enables the effect on given cameras
  69622. * @param cameras The camera to enable.
  69623. * @hidden
  69624. */
  69625. _enable(cameras: Nullable<Camera[]>): void;
  69626. /**
  69627. * Disables the effect on the given cameras
  69628. * @param cameras The camera to disable.
  69629. * @hidden
  69630. */
  69631. _disable(cameras: Camera): void;
  69632. /**
  69633. * Disables the effect on the given cameras
  69634. * @param cameras The camera to disable.
  69635. * @hidden
  69636. */
  69637. _disable(cameras: Nullable<Camera[]>): void;
  69638. /**
  69639. * Gets a list of the post processes contained in the effect.
  69640. * @param camera The camera to get the post processes on.
  69641. * @returns The list of the post processes in the effect.
  69642. */
  69643. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69644. }
  69645. }
  69646. declare module BABYLON {
  69647. /** @hidden */
  69648. export var extractHighlightsPixelShader: {
  69649. name: string;
  69650. shader: string;
  69651. };
  69652. }
  69653. declare module BABYLON {
  69654. /**
  69655. * 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.
  69656. */
  69657. export class ExtractHighlightsPostProcess extends PostProcess {
  69658. /**
  69659. * The luminance threshold, pixels below this value will be set to black.
  69660. */
  69661. threshold: number;
  69662. /** @hidden */
  69663. _exposure: number;
  69664. /**
  69665. * Post process which has the input texture to be used when performing highlight extraction
  69666. * @hidden
  69667. */
  69668. _inputPostProcess: Nullable<PostProcess>;
  69669. /**
  69670. * Gets a string identifying the name of the class
  69671. * @returns "ExtractHighlightsPostProcess" string
  69672. */
  69673. getClassName(): string;
  69674. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69675. }
  69676. }
  69677. declare module BABYLON {
  69678. /** @hidden */
  69679. export var bloomMergePixelShader: {
  69680. name: string;
  69681. shader: string;
  69682. };
  69683. }
  69684. declare module BABYLON {
  69685. /**
  69686. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69687. */
  69688. export class BloomMergePostProcess extends PostProcess {
  69689. /** Weight of the bloom to be added to the original input. */
  69690. weight: number;
  69691. /**
  69692. * Gets a string identifying the name of the class
  69693. * @returns "BloomMergePostProcess" string
  69694. */
  69695. getClassName(): string;
  69696. /**
  69697. * Creates a new instance of @see BloomMergePostProcess
  69698. * @param name The name of the effect.
  69699. * @param originalFromInput Post process which's input will be used for the merge.
  69700. * @param blurred Blurred highlights post process which's output will be used.
  69701. * @param weight Weight of the bloom to be added to the original input.
  69702. * @param options The required width/height ratio to downsize to before computing the render pass.
  69703. * @param camera The camera to apply the render pass to.
  69704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69705. * @param engine The engine which the post process will be applied. (default: current engine)
  69706. * @param reusable If the post process can be reused on the same frame. (default: false)
  69707. * @param textureType Type of textures used when performing the post process. (default: 0)
  69708. * @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)
  69709. */
  69710. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69711. /** Weight of the bloom to be added to the original input. */
  69712. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69713. }
  69714. }
  69715. declare module BABYLON {
  69716. /**
  69717. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69718. */
  69719. export class BloomEffect extends PostProcessRenderEffect {
  69720. private bloomScale;
  69721. /**
  69722. * @hidden Internal
  69723. */
  69724. _effects: Array<PostProcess>;
  69725. /**
  69726. * @hidden Internal
  69727. */
  69728. _downscale: ExtractHighlightsPostProcess;
  69729. private _blurX;
  69730. private _blurY;
  69731. private _merge;
  69732. /**
  69733. * The luminance threshold to find bright areas of the image to bloom.
  69734. */
  69735. get threshold(): number;
  69736. set threshold(value: number);
  69737. /**
  69738. * The strength of the bloom.
  69739. */
  69740. get weight(): number;
  69741. set weight(value: number);
  69742. /**
  69743. * Specifies the size of the bloom blur kernel, relative to the final output size
  69744. */
  69745. get kernel(): number;
  69746. set kernel(value: number);
  69747. /**
  69748. * Creates a new instance of @see BloomEffect
  69749. * @param scene The scene the effect belongs to.
  69750. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69751. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69752. * @param bloomWeight The the strength of bloom.
  69753. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69754. * @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)
  69755. */
  69756. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69757. /**
  69758. * Disposes each of the internal effects for a given camera.
  69759. * @param camera The camera to dispose the effect on.
  69760. */
  69761. disposeEffects(camera: Camera): void;
  69762. /**
  69763. * @hidden Internal
  69764. */
  69765. _updateEffects(): void;
  69766. /**
  69767. * Internal
  69768. * @returns if all the contained post processes are ready.
  69769. * @hidden
  69770. */
  69771. _isReady(): boolean;
  69772. }
  69773. }
  69774. declare module BABYLON {
  69775. /** @hidden */
  69776. export var chromaticAberrationPixelShader: {
  69777. name: string;
  69778. shader: string;
  69779. };
  69780. }
  69781. declare module BABYLON {
  69782. /**
  69783. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69784. */
  69785. export class ChromaticAberrationPostProcess extends PostProcess {
  69786. /**
  69787. * The amount of seperation of rgb channels (default: 30)
  69788. */
  69789. aberrationAmount: number;
  69790. /**
  69791. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69792. */
  69793. radialIntensity: number;
  69794. /**
  69795. * 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))
  69796. */
  69797. direction: Vector2;
  69798. /**
  69799. * 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))
  69800. */
  69801. centerPosition: Vector2;
  69802. /** The width of the screen to apply the effect on */
  69803. screenWidth: number;
  69804. /** The height of the screen to apply the effect on */
  69805. screenHeight: number;
  69806. /**
  69807. * Gets a string identifying the name of the class
  69808. * @returns "ChromaticAberrationPostProcess" string
  69809. */
  69810. getClassName(): string;
  69811. /**
  69812. * Creates a new instance ChromaticAberrationPostProcess
  69813. * @param name The name of the effect.
  69814. * @param screenWidth The width of the screen to apply the effect on.
  69815. * @param screenHeight The height of the screen to apply the effect on.
  69816. * @param options The required width/height ratio to downsize to before computing the render pass.
  69817. * @param camera The camera to apply the render pass to.
  69818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69819. * @param engine The engine which the post process will be applied. (default: current engine)
  69820. * @param reusable If the post process can be reused on the same frame. (default: false)
  69821. * @param textureType Type of textures used when performing the post process. (default: 0)
  69822. * @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)
  69823. */
  69824. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69825. /** @hidden */
  69826. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69827. }
  69828. }
  69829. declare module BABYLON {
  69830. /** @hidden */
  69831. export var circleOfConfusionPixelShader: {
  69832. name: string;
  69833. shader: string;
  69834. };
  69835. }
  69836. declare module BABYLON {
  69837. /**
  69838. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69839. */
  69840. export class CircleOfConfusionPostProcess extends PostProcess {
  69841. /**
  69842. * 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.
  69843. */
  69844. lensSize: number;
  69845. /**
  69846. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69847. */
  69848. fStop: number;
  69849. /**
  69850. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69851. */
  69852. focusDistance: number;
  69853. /**
  69854. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69855. */
  69856. focalLength: number;
  69857. /**
  69858. * Gets a string identifying the name of the class
  69859. * @returns "CircleOfConfusionPostProcess" string
  69860. */
  69861. getClassName(): string;
  69862. private _depthTexture;
  69863. /**
  69864. * Creates a new instance CircleOfConfusionPostProcess
  69865. * @param name The name of the effect.
  69866. * @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.
  69867. * @param options The required width/height ratio to downsize to before computing the render pass.
  69868. * @param camera The camera to apply the render pass to.
  69869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69870. * @param engine The engine which the post process will be applied. (default: current engine)
  69871. * @param reusable If the post process can be reused on the same frame. (default: false)
  69872. * @param textureType Type of textures used when performing the post process. (default: 0)
  69873. * @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)
  69874. */
  69875. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69876. /**
  69877. * 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.
  69878. */
  69879. set depthTexture(value: RenderTargetTexture);
  69880. }
  69881. }
  69882. declare module BABYLON {
  69883. /** @hidden */
  69884. export var colorCorrectionPixelShader: {
  69885. name: string;
  69886. shader: string;
  69887. };
  69888. }
  69889. declare module BABYLON {
  69890. /**
  69891. *
  69892. * This post-process allows the modification of rendered colors by using
  69893. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69894. *
  69895. * The object needs to be provided an url to a texture containing the color
  69896. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69897. * Use an image editing software to tweak the LUT to match your needs.
  69898. *
  69899. * For an example of a color LUT, see here:
  69900. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69901. * For explanations on color grading, see here:
  69902. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69903. *
  69904. */
  69905. export class ColorCorrectionPostProcess extends PostProcess {
  69906. private _colorTableTexture;
  69907. /**
  69908. * Gets the color table url used to create the LUT texture
  69909. */
  69910. colorTableUrl: string;
  69911. /**
  69912. * Gets a string identifying the name of the class
  69913. * @returns "ColorCorrectionPostProcess" string
  69914. */
  69915. getClassName(): string;
  69916. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69917. /** @hidden */
  69918. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69919. }
  69920. }
  69921. declare module BABYLON {
  69922. /** @hidden */
  69923. export var convolutionPixelShader: {
  69924. name: string;
  69925. shader: string;
  69926. };
  69927. }
  69928. declare module BABYLON {
  69929. /**
  69930. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69931. * input texture to perform effects such as edge detection or sharpening
  69932. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69933. */
  69934. export class ConvolutionPostProcess extends PostProcess {
  69935. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69936. kernel: number[];
  69937. /**
  69938. * Gets a string identifying the name of the class
  69939. * @returns "ConvolutionPostProcess" string
  69940. */
  69941. getClassName(): string;
  69942. /**
  69943. * Creates a new instance ConvolutionPostProcess
  69944. * @param name The name of the effect.
  69945. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69946. * @param options The required width/height ratio to downsize to before computing the render pass.
  69947. * @param camera The camera to apply the render pass to.
  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. * @param textureType Type of textures used when performing the post process. (default: 0)
  69952. */
  69953. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69954. /** @hidden */
  69955. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69956. /**
  69957. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69958. */
  69959. static EdgeDetect0Kernel: number[];
  69960. /**
  69961. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69962. */
  69963. static EdgeDetect1Kernel: number[];
  69964. /**
  69965. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69966. */
  69967. static EdgeDetect2Kernel: number[];
  69968. /**
  69969. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69970. */
  69971. static SharpenKernel: number[];
  69972. /**
  69973. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69974. */
  69975. static EmbossKernel: number[];
  69976. /**
  69977. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69978. */
  69979. static GaussianKernel: number[];
  69980. }
  69981. }
  69982. declare module BABYLON {
  69983. /**
  69984. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69985. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69986. * based on samples that have a large difference in distance than the center pixel.
  69987. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69988. */
  69989. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69990. /**
  69991. * The direction the blur should be applied
  69992. */
  69993. direction: Vector2;
  69994. /**
  69995. * Gets a string identifying the name of the class
  69996. * @returns "DepthOfFieldBlurPostProcess" string
  69997. */
  69998. getClassName(): string;
  69999. /**
  70000. * Creates a new instance CircleOfConfusionPostProcess
  70001. * @param name The name of the effect.
  70002. * @param scene The scene the effect belongs to.
  70003. * @param direction The direction the blur should be applied.
  70004. * @param kernel The size of the kernel used to blur.
  70005. * @param options The required width/height ratio to downsize to before computing the render pass.
  70006. * @param camera The camera to apply the render pass to.
  70007. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70008. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70010. * @param engine The engine which the post process will be applied. (default: current engine)
  70011. * @param reusable If the post process can be reused on the same frame. (default: false)
  70012. * @param textureType Type of textures used when performing the post process. (default: 0)
  70013. * @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)
  70014. */
  70015. 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);
  70016. }
  70017. }
  70018. declare module BABYLON {
  70019. /** @hidden */
  70020. export var depthOfFieldMergePixelShader: {
  70021. name: string;
  70022. shader: string;
  70023. };
  70024. }
  70025. declare module BABYLON {
  70026. /**
  70027. * Options to be set when merging outputs from the default pipeline.
  70028. */
  70029. export class DepthOfFieldMergePostProcessOptions {
  70030. /**
  70031. * The original image to merge on top of
  70032. */
  70033. originalFromInput: PostProcess;
  70034. /**
  70035. * Parameters to perform the merge of the depth of field effect
  70036. */
  70037. depthOfField?: {
  70038. circleOfConfusion: PostProcess;
  70039. blurSteps: Array<PostProcess>;
  70040. };
  70041. /**
  70042. * Parameters to perform the merge of bloom effect
  70043. */
  70044. bloom?: {
  70045. blurred: PostProcess;
  70046. weight: number;
  70047. };
  70048. }
  70049. /**
  70050. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70051. */
  70052. export class DepthOfFieldMergePostProcess extends PostProcess {
  70053. private blurSteps;
  70054. /**
  70055. * Gets a string identifying the name of the class
  70056. * @returns "DepthOfFieldMergePostProcess" string
  70057. */
  70058. getClassName(): string;
  70059. /**
  70060. * Creates a new instance of DepthOfFieldMergePostProcess
  70061. * @param name The name of the effect.
  70062. * @param originalFromInput Post process which's input will be used for the merge.
  70063. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70064. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70065. * @param options The required width/height ratio to downsize to before computing the render pass.
  70066. * @param camera The camera to apply the render pass to.
  70067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70068. * @param engine The engine which the post process will be applied. (default: current engine)
  70069. * @param reusable If the post process can be reused on the same frame. (default: false)
  70070. * @param textureType Type of textures used when performing the post process. (default: 0)
  70071. * @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)
  70072. */
  70073. 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);
  70074. /**
  70075. * Updates the effect with the current post process compile time values and recompiles the shader.
  70076. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70077. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70078. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70079. * @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
  70080. * @param onCompiled Called when the shader has been compiled.
  70081. * @param onError Called if there is an error when compiling a shader.
  70082. */
  70083. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70084. }
  70085. }
  70086. declare module BABYLON {
  70087. /**
  70088. * Specifies the level of max blur that should be applied when using the depth of field effect
  70089. */
  70090. export enum DepthOfFieldEffectBlurLevel {
  70091. /**
  70092. * Subtle blur
  70093. */
  70094. Low = 0,
  70095. /**
  70096. * Medium blur
  70097. */
  70098. Medium = 1,
  70099. /**
  70100. * Large blur
  70101. */
  70102. High = 2
  70103. }
  70104. /**
  70105. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70106. */
  70107. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70108. private _circleOfConfusion;
  70109. /**
  70110. * @hidden Internal, blurs from high to low
  70111. */
  70112. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70113. private _depthOfFieldBlurY;
  70114. private _dofMerge;
  70115. /**
  70116. * @hidden Internal post processes in depth of field effect
  70117. */
  70118. _effects: Array<PostProcess>;
  70119. /**
  70120. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70121. */
  70122. set focalLength(value: number);
  70123. get focalLength(): number;
  70124. /**
  70125. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70126. */
  70127. set fStop(value: number);
  70128. get fStop(): number;
  70129. /**
  70130. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70131. */
  70132. set focusDistance(value: number);
  70133. get focusDistance(): number;
  70134. /**
  70135. * 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.
  70136. */
  70137. set lensSize(value: number);
  70138. get lensSize(): number;
  70139. /**
  70140. * Creates a new instance DepthOfFieldEffect
  70141. * @param scene The scene the effect belongs to.
  70142. * @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.
  70143. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70144. * @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)
  70145. */
  70146. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70147. /**
  70148. * Get the current class name of the current effet
  70149. * @returns "DepthOfFieldEffect"
  70150. */
  70151. getClassName(): string;
  70152. /**
  70153. * 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.
  70154. */
  70155. set depthTexture(value: RenderTargetTexture);
  70156. /**
  70157. * Disposes each of the internal effects for a given camera.
  70158. * @param camera The camera to dispose the effect on.
  70159. */
  70160. disposeEffects(camera: Camera): void;
  70161. /**
  70162. * @hidden Internal
  70163. */
  70164. _updateEffects(): void;
  70165. /**
  70166. * Internal
  70167. * @returns if all the contained post processes are ready.
  70168. * @hidden
  70169. */
  70170. _isReady(): boolean;
  70171. }
  70172. }
  70173. declare module BABYLON {
  70174. /** @hidden */
  70175. export var displayPassPixelShader: {
  70176. name: string;
  70177. shader: string;
  70178. };
  70179. }
  70180. declare module BABYLON {
  70181. /**
  70182. * DisplayPassPostProcess which produces an output the same as it's input
  70183. */
  70184. export class DisplayPassPostProcess extends PostProcess {
  70185. /**
  70186. * Gets a string identifying the name of the class
  70187. * @returns "DisplayPassPostProcess" string
  70188. */
  70189. getClassName(): string;
  70190. /**
  70191. * Creates the DisplayPassPostProcess
  70192. * @param name The name of the effect.
  70193. * @param options The required width/height ratio to downsize to before computing the render pass.
  70194. * @param camera The camera to apply the render pass to.
  70195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70196. * @param engine The engine which the post process will be applied. (default: current engine)
  70197. * @param reusable If the post process can be reused on the same frame. (default: false)
  70198. */
  70199. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70200. /** @hidden */
  70201. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70202. }
  70203. }
  70204. declare module BABYLON {
  70205. /** @hidden */
  70206. export var filterPixelShader: {
  70207. name: string;
  70208. shader: string;
  70209. };
  70210. }
  70211. declare module BABYLON {
  70212. /**
  70213. * Applies a kernel filter to the image
  70214. */
  70215. export class FilterPostProcess extends PostProcess {
  70216. /** The matrix to be applied to the image */
  70217. kernelMatrix: Matrix;
  70218. /**
  70219. * Gets a string identifying the name of the class
  70220. * @returns "FilterPostProcess" string
  70221. */
  70222. getClassName(): string;
  70223. /**
  70224. *
  70225. * @param name The name of the effect.
  70226. * @param kernelMatrix The matrix to be applied to the image
  70227. * @param options The required width/height ratio to downsize to before computing the render pass.
  70228. * @param camera The camera to apply the render pass to.
  70229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70230. * @param engine The engine which the post process will be applied. (default: current engine)
  70231. * @param reusable If the post process can be reused on the same frame. (default: false)
  70232. */
  70233. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70234. /** @hidden */
  70235. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70236. }
  70237. }
  70238. declare module BABYLON {
  70239. /** @hidden */
  70240. export var fxaaPixelShader: {
  70241. name: string;
  70242. shader: string;
  70243. };
  70244. }
  70245. declare module BABYLON {
  70246. /** @hidden */
  70247. export var fxaaVertexShader: {
  70248. name: string;
  70249. shader: string;
  70250. };
  70251. }
  70252. declare module BABYLON {
  70253. /**
  70254. * Fxaa post process
  70255. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70256. */
  70257. export class FxaaPostProcess extends PostProcess {
  70258. /**
  70259. * Gets a string identifying the name of the class
  70260. * @returns "FxaaPostProcess" string
  70261. */
  70262. getClassName(): string;
  70263. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70264. private _getDefines;
  70265. /** @hidden */
  70266. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70267. }
  70268. }
  70269. declare module BABYLON {
  70270. /** @hidden */
  70271. export var grainPixelShader: {
  70272. name: string;
  70273. shader: string;
  70274. };
  70275. }
  70276. declare module BABYLON {
  70277. /**
  70278. * The GrainPostProcess adds noise to the image at mid luminance levels
  70279. */
  70280. export class GrainPostProcess extends PostProcess {
  70281. /**
  70282. * The intensity of the grain added (default: 30)
  70283. */
  70284. intensity: number;
  70285. /**
  70286. * If the grain should be randomized on every frame
  70287. */
  70288. animated: boolean;
  70289. /**
  70290. * Gets a string identifying the name of the class
  70291. * @returns "GrainPostProcess" string
  70292. */
  70293. getClassName(): string;
  70294. /**
  70295. * Creates a new instance of @see GrainPostProcess
  70296. * @param name The name of the effect.
  70297. * @param options The required width/height ratio to downsize to before computing the render pass.
  70298. * @param camera The camera to apply the render pass to.
  70299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70300. * @param engine The engine which the post process will be applied. (default: current engine)
  70301. * @param reusable If the post process can be reused on the same frame. (default: false)
  70302. * @param textureType Type of textures used when performing the post process. (default: 0)
  70303. * @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)
  70304. */
  70305. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70306. /** @hidden */
  70307. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70308. }
  70309. }
  70310. declare module BABYLON {
  70311. /** @hidden */
  70312. export var highlightsPixelShader: {
  70313. name: string;
  70314. shader: string;
  70315. };
  70316. }
  70317. declare module BABYLON {
  70318. /**
  70319. * Extracts highlights from the image
  70320. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70321. */
  70322. export class HighlightsPostProcess extends PostProcess {
  70323. /**
  70324. * Gets a string identifying the name of the class
  70325. * @returns "HighlightsPostProcess" string
  70326. */
  70327. getClassName(): string;
  70328. /**
  70329. * Extracts highlights from the image
  70330. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70331. * @param name The name of the effect.
  70332. * @param options The required width/height ratio to downsize to before computing the render pass.
  70333. * @param camera The camera to apply the render pass to.
  70334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70335. * @param engine The engine which the post process will be applied. (default: current engine)
  70336. * @param reusable If the post process can be reused on the same frame. (default: false)
  70337. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70338. */
  70339. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70340. }
  70341. }
  70342. declare module BABYLON {
  70343. /**
  70344. * Contains all parameters needed for the prepass to perform
  70345. * motion blur
  70346. */
  70347. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70348. /**
  70349. * Is motion blur enabled
  70350. */
  70351. enabled: boolean;
  70352. /**
  70353. * Name of the configuration
  70354. */
  70355. name: string;
  70356. /**
  70357. * Textures that should be present in the MRT for this effect to work
  70358. */
  70359. readonly texturesRequired: number[];
  70360. }
  70361. }
  70362. declare module BABYLON {
  70363. interface Scene {
  70364. /** @hidden (Backing field) */
  70365. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70366. /**
  70367. * Gets or Sets the current geometry buffer associated to the scene.
  70368. */
  70369. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70370. /**
  70371. * Enables a GeometryBufferRender and associates it with the scene
  70372. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70373. * @returns the GeometryBufferRenderer
  70374. */
  70375. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70376. /**
  70377. * Disables the GeometryBufferRender associated with the scene
  70378. */
  70379. disableGeometryBufferRenderer(): void;
  70380. }
  70381. /**
  70382. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70383. * in several rendering techniques.
  70384. */
  70385. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70386. /**
  70387. * The component name helpful to identify the component in the list of scene components.
  70388. */
  70389. readonly name: string;
  70390. /**
  70391. * The scene the component belongs to.
  70392. */
  70393. scene: Scene;
  70394. /**
  70395. * Creates a new instance of the component for the given scene
  70396. * @param scene Defines the scene to register the component in
  70397. */
  70398. constructor(scene: Scene);
  70399. /**
  70400. * Registers the component in a given scene
  70401. */
  70402. register(): void;
  70403. /**
  70404. * Rebuilds the elements related to this component in case of
  70405. * context lost for instance.
  70406. */
  70407. rebuild(): void;
  70408. /**
  70409. * Disposes the component and the associated ressources
  70410. */
  70411. dispose(): void;
  70412. private _gatherRenderTargets;
  70413. }
  70414. }
  70415. declare module BABYLON {
  70416. /** @hidden */
  70417. export var motionBlurPixelShader: {
  70418. name: string;
  70419. shader: string;
  70420. };
  70421. }
  70422. declare module BABYLON {
  70423. /**
  70424. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70425. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70426. * As an example, all you have to do is to create the post-process:
  70427. * var mb = new BABYLON.MotionBlurPostProcess(
  70428. * 'mb', // The name of the effect.
  70429. * scene, // The scene containing the objects to blur according to their velocity.
  70430. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70431. * camera // The camera to apply the render pass to.
  70432. * );
  70433. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70434. */
  70435. export class MotionBlurPostProcess extends PostProcess {
  70436. /**
  70437. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70438. */
  70439. motionStrength: number;
  70440. /**
  70441. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70442. */
  70443. get motionBlurSamples(): number;
  70444. /**
  70445. * Sets the number of iterations to be used for motion blur quality
  70446. */
  70447. set motionBlurSamples(samples: number);
  70448. private _motionBlurSamples;
  70449. private _forceGeometryBuffer;
  70450. private _geometryBufferRenderer;
  70451. private _prePassRenderer;
  70452. /**
  70453. * Gets a string identifying the name of the class
  70454. * @returns "MotionBlurPostProcess" string
  70455. */
  70456. getClassName(): string;
  70457. /**
  70458. * Creates a new instance MotionBlurPostProcess
  70459. * @param name The name of the effect.
  70460. * @param scene The scene containing the objects to blur according to their velocity.
  70461. * @param options The required width/height ratio to downsize to before computing the render pass.
  70462. * @param camera The camera to apply the render pass to.
  70463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70464. * @param engine The engine which the post process will be applied. (default: current engine)
  70465. * @param reusable If the post process can be reused on the same frame. (default: false)
  70466. * @param textureType Type of textures used when performing the post process. (default: 0)
  70467. * @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)
  70468. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  70469. */
  70470. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  70471. /**
  70472. * Excludes the given skinned mesh from computing bones velocities.
  70473. * 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.
  70474. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70475. */
  70476. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70477. /**
  70478. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70479. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70480. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70481. */
  70482. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70483. /**
  70484. * Disposes the post process.
  70485. * @param camera The camera to dispose the post process on.
  70486. */
  70487. dispose(camera?: Camera): void;
  70488. /** @hidden */
  70489. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70490. }
  70491. }
  70492. declare module BABYLON {
  70493. /** @hidden */
  70494. export var refractionPixelShader: {
  70495. name: string;
  70496. shader: string;
  70497. };
  70498. }
  70499. declare module BABYLON {
  70500. /**
  70501. * Post process which applies a refractin texture
  70502. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70503. */
  70504. export class RefractionPostProcess extends PostProcess {
  70505. private _refTexture;
  70506. private _ownRefractionTexture;
  70507. /** the base color of the refraction (used to taint the rendering) */
  70508. color: Color3;
  70509. /** simulated refraction depth */
  70510. depth: number;
  70511. /** the coefficient of the base color (0 to remove base color tainting) */
  70512. colorLevel: number;
  70513. /** Gets the url used to load the refraction texture */
  70514. refractionTextureUrl: string;
  70515. /**
  70516. * Gets or sets the refraction texture
  70517. * Please note that you are responsible for disposing the texture if you set it manually
  70518. */
  70519. get refractionTexture(): Texture;
  70520. set refractionTexture(value: Texture);
  70521. /**
  70522. * Gets a string identifying the name of the class
  70523. * @returns "RefractionPostProcess" string
  70524. */
  70525. getClassName(): string;
  70526. /**
  70527. * Initializes the RefractionPostProcess
  70528. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70529. * @param name The name of the effect.
  70530. * @param refractionTextureUrl Url of the refraction texture to use
  70531. * @param color the base color of the refraction (used to taint the rendering)
  70532. * @param depth simulated refraction depth
  70533. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70534. * @param camera The camera to apply the render pass to.
  70535. * @param options The required width/height ratio to downsize to before computing the render pass.
  70536. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70537. * @param engine The engine which the post process will be applied. (default: current engine)
  70538. * @param reusable If the post process can be reused on the same frame. (default: false)
  70539. */
  70540. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70541. /**
  70542. * Disposes of the post process
  70543. * @param camera Camera to dispose post process on
  70544. */
  70545. dispose(camera: Camera): void;
  70546. /** @hidden */
  70547. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70548. }
  70549. }
  70550. declare module BABYLON {
  70551. /** @hidden */
  70552. export var sharpenPixelShader: {
  70553. name: string;
  70554. shader: string;
  70555. };
  70556. }
  70557. declare module BABYLON {
  70558. /**
  70559. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70560. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70561. */
  70562. export class SharpenPostProcess extends PostProcess {
  70563. /**
  70564. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70565. */
  70566. colorAmount: number;
  70567. /**
  70568. * How much sharpness should be applied (default: 0.3)
  70569. */
  70570. edgeAmount: number;
  70571. /**
  70572. * Gets a string identifying the name of the class
  70573. * @returns "SharpenPostProcess" string
  70574. */
  70575. getClassName(): string;
  70576. /**
  70577. * Creates a new instance ConvolutionPostProcess
  70578. * @param name The name of the effect.
  70579. * @param options The required width/height ratio to downsize to before computing the render pass.
  70580. * @param camera The camera to apply the render pass to.
  70581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70582. * @param engine The engine which the post process will be applied. (default: current engine)
  70583. * @param reusable If the post process can be reused on the same frame. (default: false)
  70584. * @param textureType Type of textures used when performing the post process. (default: 0)
  70585. * @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)
  70586. */
  70587. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70588. /** @hidden */
  70589. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70590. }
  70591. }
  70592. declare module BABYLON {
  70593. /**
  70594. * PostProcessRenderPipeline
  70595. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70596. */
  70597. export class PostProcessRenderPipeline {
  70598. private engine;
  70599. private _renderEffects;
  70600. private _renderEffectsForIsolatedPass;
  70601. /**
  70602. * List of inspectable custom properties (used by the Inspector)
  70603. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70604. */
  70605. inspectableCustomProperties: IInspectable[];
  70606. /**
  70607. * @hidden
  70608. */
  70609. protected _cameras: Camera[];
  70610. /** @hidden */
  70611. _name: string;
  70612. /**
  70613. * Gets pipeline name
  70614. */
  70615. get name(): string;
  70616. /** Gets the list of attached cameras */
  70617. get cameras(): Camera[];
  70618. /**
  70619. * Initializes a PostProcessRenderPipeline
  70620. * @param engine engine to add the pipeline to
  70621. * @param name name of the pipeline
  70622. */
  70623. constructor(engine: Engine, name: string);
  70624. /**
  70625. * Gets the class name
  70626. * @returns "PostProcessRenderPipeline"
  70627. */
  70628. getClassName(): string;
  70629. /**
  70630. * If all the render effects in the pipeline are supported
  70631. */
  70632. get isSupported(): boolean;
  70633. /**
  70634. * Adds an effect to the pipeline
  70635. * @param renderEffect the effect to add
  70636. */
  70637. addEffect(renderEffect: PostProcessRenderEffect): void;
  70638. /** @hidden */
  70639. _rebuild(): void;
  70640. /** @hidden */
  70641. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70642. /** @hidden */
  70643. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70644. /** @hidden */
  70645. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70646. /** @hidden */
  70647. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70648. /** @hidden */
  70649. _attachCameras(cameras: Camera, unique: boolean): void;
  70650. /** @hidden */
  70651. _attachCameras(cameras: Camera[], unique: boolean): void;
  70652. /** @hidden */
  70653. _detachCameras(cameras: Camera): void;
  70654. /** @hidden */
  70655. _detachCameras(cameras: Nullable<Camera[]>): void;
  70656. /** @hidden */
  70657. _update(): void;
  70658. /** @hidden */
  70659. _reset(): void;
  70660. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70661. /**
  70662. * Sets the required values to the prepass renderer.
  70663. * @param prePassRenderer defines the prepass renderer to setup.
  70664. * @returns true if the pre pass is needed.
  70665. */
  70666. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70667. /**
  70668. * Disposes of the pipeline
  70669. */
  70670. dispose(): void;
  70671. }
  70672. }
  70673. declare module BABYLON {
  70674. /**
  70675. * PostProcessRenderPipelineManager class
  70676. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70677. */
  70678. export class PostProcessRenderPipelineManager {
  70679. private _renderPipelines;
  70680. /**
  70681. * Initializes a PostProcessRenderPipelineManager
  70682. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70683. */
  70684. constructor();
  70685. /**
  70686. * Gets the list of supported render pipelines
  70687. */
  70688. get supportedPipelines(): PostProcessRenderPipeline[];
  70689. /**
  70690. * Adds a pipeline to the manager
  70691. * @param renderPipeline The pipeline to add
  70692. */
  70693. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70694. /**
  70695. * Attaches a camera to the pipeline
  70696. * @param renderPipelineName The name of the pipeline to attach to
  70697. * @param cameras the camera to attach
  70698. * @param unique if the camera can be attached multiple times to the pipeline
  70699. */
  70700. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70701. /**
  70702. * Detaches a camera from the pipeline
  70703. * @param renderPipelineName The name of the pipeline to detach from
  70704. * @param cameras the camera to detach
  70705. */
  70706. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70707. /**
  70708. * Enables an effect by name on a pipeline
  70709. * @param renderPipelineName the name of the pipeline to enable the effect in
  70710. * @param renderEffectName the name of the effect to enable
  70711. * @param cameras the cameras that the effect should be enabled on
  70712. */
  70713. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70714. /**
  70715. * Disables an effect by name on a pipeline
  70716. * @param renderPipelineName the name of the pipeline to disable the effect in
  70717. * @param renderEffectName the name of the effect to disable
  70718. * @param cameras the cameras that the effect should be disabled on
  70719. */
  70720. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70721. /**
  70722. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70723. */
  70724. update(): void;
  70725. /** @hidden */
  70726. _rebuild(): void;
  70727. /**
  70728. * Disposes of the manager and pipelines
  70729. */
  70730. dispose(): void;
  70731. }
  70732. }
  70733. declare module BABYLON {
  70734. interface Scene {
  70735. /** @hidden (Backing field) */
  70736. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70737. /**
  70738. * Gets the postprocess render pipeline manager
  70739. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70740. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70741. */
  70742. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70743. }
  70744. /**
  70745. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70746. */
  70747. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70748. /**
  70749. * The component name helpfull to identify the component in the list of scene components.
  70750. */
  70751. readonly name: string;
  70752. /**
  70753. * The scene the component belongs to.
  70754. */
  70755. scene: Scene;
  70756. /**
  70757. * Creates a new instance of the component for the given scene
  70758. * @param scene Defines the scene to register the component in
  70759. */
  70760. constructor(scene: Scene);
  70761. /**
  70762. * Registers the component in a given scene
  70763. */
  70764. register(): void;
  70765. /**
  70766. * Rebuilds the elements related to this component in case of
  70767. * context lost for instance.
  70768. */
  70769. rebuild(): void;
  70770. /**
  70771. * Disposes the component and the associated ressources
  70772. */
  70773. dispose(): void;
  70774. private _gatherRenderTargets;
  70775. }
  70776. }
  70777. declare module BABYLON {
  70778. /**
  70779. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70780. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70781. */
  70782. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70783. private _scene;
  70784. private _camerasToBeAttached;
  70785. /**
  70786. * ID of the sharpen post process,
  70787. */
  70788. private readonly SharpenPostProcessId;
  70789. /**
  70790. * @ignore
  70791. * ID of the image processing post process;
  70792. */
  70793. readonly ImageProcessingPostProcessId: string;
  70794. /**
  70795. * @ignore
  70796. * ID of the Fast Approximate Anti-Aliasing post process;
  70797. */
  70798. readonly FxaaPostProcessId: string;
  70799. /**
  70800. * ID of the chromatic aberration post process,
  70801. */
  70802. private readonly ChromaticAberrationPostProcessId;
  70803. /**
  70804. * ID of the grain post process
  70805. */
  70806. private readonly GrainPostProcessId;
  70807. /**
  70808. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70809. */
  70810. sharpen: SharpenPostProcess;
  70811. private _sharpenEffect;
  70812. private bloom;
  70813. /**
  70814. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70815. */
  70816. depthOfField: DepthOfFieldEffect;
  70817. /**
  70818. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70819. */
  70820. fxaa: FxaaPostProcess;
  70821. /**
  70822. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70823. */
  70824. imageProcessing: ImageProcessingPostProcess;
  70825. /**
  70826. * Chromatic aberration post process which will shift rgb colors in the image
  70827. */
  70828. chromaticAberration: ChromaticAberrationPostProcess;
  70829. private _chromaticAberrationEffect;
  70830. /**
  70831. * Grain post process which add noise to the image
  70832. */
  70833. grain: GrainPostProcess;
  70834. private _grainEffect;
  70835. /**
  70836. * Glow post process which adds a glow to emissive areas of the image
  70837. */
  70838. private _glowLayer;
  70839. /**
  70840. * Animations which can be used to tweak settings over a period of time
  70841. */
  70842. animations: Animation[];
  70843. private _imageProcessingConfigurationObserver;
  70844. private _sharpenEnabled;
  70845. private _bloomEnabled;
  70846. private _depthOfFieldEnabled;
  70847. private _depthOfFieldBlurLevel;
  70848. private _fxaaEnabled;
  70849. private _imageProcessingEnabled;
  70850. private _defaultPipelineTextureType;
  70851. private _bloomScale;
  70852. private _chromaticAberrationEnabled;
  70853. private _grainEnabled;
  70854. private _buildAllowed;
  70855. /**
  70856. * Gets active scene
  70857. */
  70858. get scene(): Scene;
  70859. /**
  70860. * Enable or disable the sharpen process from the pipeline
  70861. */
  70862. set sharpenEnabled(enabled: boolean);
  70863. get sharpenEnabled(): boolean;
  70864. private _resizeObserver;
  70865. private _hardwareScaleLevel;
  70866. private _bloomKernel;
  70867. /**
  70868. * Specifies the size of the bloom blur kernel, relative to the final output size
  70869. */
  70870. get bloomKernel(): number;
  70871. set bloomKernel(value: number);
  70872. /**
  70873. * Specifies the weight of the bloom in the final rendering
  70874. */
  70875. private _bloomWeight;
  70876. /**
  70877. * Specifies the luma threshold for the area that will be blurred by the bloom
  70878. */
  70879. private _bloomThreshold;
  70880. private _hdr;
  70881. /**
  70882. * The strength of the bloom.
  70883. */
  70884. set bloomWeight(value: number);
  70885. get bloomWeight(): number;
  70886. /**
  70887. * The strength of the bloom.
  70888. */
  70889. set bloomThreshold(value: number);
  70890. get bloomThreshold(): number;
  70891. /**
  70892. * The scale of the bloom, lower value will provide better performance.
  70893. */
  70894. set bloomScale(value: number);
  70895. get bloomScale(): number;
  70896. /**
  70897. * Enable or disable the bloom from the pipeline
  70898. */
  70899. set bloomEnabled(enabled: boolean);
  70900. get bloomEnabled(): boolean;
  70901. private _rebuildBloom;
  70902. /**
  70903. * If the depth of field is enabled.
  70904. */
  70905. get depthOfFieldEnabled(): boolean;
  70906. set depthOfFieldEnabled(enabled: boolean);
  70907. /**
  70908. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70909. */
  70910. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70911. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70912. /**
  70913. * If the anti aliasing is enabled.
  70914. */
  70915. set fxaaEnabled(enabled: boolean);
  70916. get fxaaEnabled(): boolean;
  70917. private _samples;
  70918. /**
  70919. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70920. */
  70921. set samples(sampleCount: number);
  70922. get samples(): number;
  70923. /**
  70924. * If image processing is enabled.
  70925. */
  70926. set imageProcessingEnabled(enabled: boolean);
  70927. get imageProcessingEnabled(): boolean;
  70928. /**
  70929. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70930. */
  70931. set glowLayerEnabled(enabled: boolean);
  70932. get glowLayerEnabled(): boolean;
  70933. /**
  70934. * Gets the glow layer (or null if not defined)
  70935. */
  70936. get glowLayer(): Nullable<GlowLayer>;
  70937. /**
  70938. * Enable or disable the chromaticAberration process from the pipeline
  70939. */
  70940. set chromaticAberrationEnabled(enabled: boolean);
  70941. get chromaticAberrationEnabled(): boolean;
  70942. /**
  70943. * Enable or disable the grain process from the pipeline
  70944. */
  70945. set grainEnabled(enabled: boolean);
  70946. get grainEnabled(): boolean;
  70947. /**
  70948. * @constructor
  70949. * @param name - The rendering pipeline name (default: "")
  70950. * @param hdr - If high dynamic range textures should be used (default: true)
  70951. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70952. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70953. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70954. */
  70955. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70956. /**
  70957. * Get the class name
  70958. * @returns "DefaultRenderingPipeline"
  70959. */
  70960. getClassName(): string;
  70961. /**
  70962. * Force the compilation of the entire pipeline.
  70963. */
  70964. prepare(): void;
  70965. private _hasCleared;
  70966. private _prevPostProcess;
  70967. private _prevPrevPostProcess;
  70968. private _setAutoClearAndTextureSharing;
  70969. private _depthOfFieldSceneObserver;
  70970. private _buildPipeline;
  70971. private _disposePostProcesses;
  70972. /**
  70973. * Adds a camera to the pipeline
  70974. * @param camera the camera to be added
  70975. */
  70976. addCamera(camera: Camera): void;
  70977. /**
  70978. * Removes a camera from the pipeline
  70979. * @param camera the camera to remove
  70980. */
  70981. removeCamera(camera: Camera): void;
  70982. /**
  70983. * Dispose of the pipeline and stop all post processes
  70984. */
  70985. dispose(): void;
  70986. /**
  70987. * Serialize the rendering pipeline (Used when exporting)
  70988. * @returns the serialized object
  70989. */
  70990. serialize(): any;
  70991. /**
  70992. * Parse the serialized pipeline
  70993. * @param source Source pipeline.
  70994. * @param scene The scene to load the pipeline to.
  70995. * @param rootUrl The URL of the serialized pipeline.
  70996. * @returns An instantiated pipeline from the serialized object.
  70997. */
  70998. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70999. }
  71000. }
  71001. declare module BABYLON {
  71002. /** @hidden */
  71003. export var lensHighlightsPixelShader: {
  71004. name: string;
  71005. shader: string;
  71006. };
  71007. }
  71008. declare module BABYLON {
  71009. /** @hidden */
  71010. export var depthOfFieldPixelShader: {
  71011. name: string;
  71012. shader: string;
  71013. };
  71014. }
  71015. declare module BABYLON {
  71016. /**
  71017. * BABYLON.JS Chromatic Aberration GLSL Shader
  71018. * Author: Olivier Guyot
  71019. * Separates very slightly R, G and B colors on the edges of the screen
  71020. * Inspired by Francois Tarlier & Martins Upitis
  71021. */
  71022. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71023. /**
  71024. * @ignore
  71025. * The chromatic aberration PostProcess id in the pipeline
  71026. */
  71027. LensChromaticAberrationEffect: string;
  71028. /**
  71029. * @ignore
  71030. * The highlights enhancing PostProcess id in the pipeline
  71031. */
  71032. HighlightsEnhancingEffect: string;
  71033. /**
  71034. * @ignore
  71035. * The depth-of-field PostProcess id in the pipeline
  71036. */
  71037. LensDepthOfFieldEffect: string;
  71038. private _scene;
  71039. private _depthTexture;
  71040. private _grainTexture;
  71041. private _chromaticAberrationPostProcess;
  71042. private _highlightsPostProcess;
  71043. private _depthOfFieldPostProcess;
  71044. private _edgeBlur;
  71045. private _grainAmount;
  71046. private _chromaticAberration;
  71047. private _distortion;
  71048. private _highlightsGain;
  71049. private _highlightsThreshold;
  71050. private _dofDistance;
  71051. private _dofAperture;
  71052. private _dofDarken;
  71053. private _dofPentagon;
  71054. private _blurNoise;
  71055. /**
  71056. * @constructor
  71057. *
  71058. * Effect parameters are as follow:
  71059. * {
  71060. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71061. * edge_blur: number; // from 0 to x (1 for realism)
  71062. * distortion: number; // from 0 to x (1 for realism)
  71063. * grain_amount: number; // from 0 to 1
  71064. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71065. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71066. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71067. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71068. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71069. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71070. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71071. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71072. * }
  71073. * Note: if an effect parameter is unset, effect is disabled
  71074. *
  71075. * @param name The rendering pipeline name
  71076. * @param parameters - An object containing all parameters (see above)
  71077. * @param scene The scene linked to this pipeline
  71078. * @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)
  71079. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71080. */
  71081. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71082. /**
  71083. * Get the class name
  71084. * @returns "LensRenderingPipeline"
  71085. */
  71086. getClassName(): string;
  71087. /**
  71088. * Gets associated scene
  71089. */
  71090. get scene(): Scene;
  71091. /**
  71092. * Gets or sets the edge blur
  71093. */
  71094. get edgeBlur(): number;
  71095. set edgeBlur(value: number);
  71096. /**
  71097. * Gets or sets the grain amount
  71098. */
  71099. get grainAmount(): number;
  71100. set grainAmount(value: number);
  71101. /**
  71102. * Gets or sets the chromatic aberration amount
  71103. */
  71104. get chromaticAberration(): number;
  71105. set chromaticAberration(value: number);
  71106. /**
  71107. * Gets or sets the depth of field aperture
  71108. */
  71109. get dofAperture(): number;
  71110. set dofAperture(value: number);
  71111. /**
  71112. * Gets or sets the edge distortion
  71113. */
  71114. get edgeDistortion(): number;
  71115. set edgeDistortion(value: number);
  71116. /**
  71117. * Gets or sets the depth of field distortion
  71118. */
  71119. get dofDistortion(): number;
  71120. set dofDistortion(value: number);
  71121. /**
  71122. * Gets or sets the darken out of focus amount
  71123. */
  71124. get darkenOutOfFocus(): number;
  71125. set darkenOutOfFocus(value: number);
  71126. /**
  71127. * Gets or sets a boolean indicating if blur noise is enabled
  71128. */
  71129. get blurNoise(): boolean;
  71130. set blurNoise(value: boolean);
  71131. /**
  71132. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71133. */
  71134. get pentagonBokeh(): boolean;
  71135. set pentagonBokeh(value: boolean);
  71136. /**
  71137. * Gets or sets the highlight grain amount
  71138. */
  71139. get highlightsGain(): number;
  71140. set highlightsGain(value: number);
  71141. /**
  71142. * Gets or sets the highlight threshold
  71143. */
  71144. get highlightsThreshold(): number;
  71145. set highlightsThreshold(value: number);
  71146. /**
  71147. * Sets the amount of blur at the edges
  71148. * @param amount blur amount
  71149. */
  71150. setEdgeBlur(amount: number): void;
  71151. /**
  71152. * Sets edge blur to 0
  71153. */
  71154. disableEdgeBlur(): void;
  71155. /**
  71156. * Sets the amout of grain
  71157. * @param amount Amount of grain
  71158. */
  71159. setGrainAmount(amount: number): void;
  71160. /**
  71161. * Set grain amount to 0
  71162. */
  71163. disableGrain(): void;
  71164. /**
  71165. * Sets the chromatic aberration amount
  71166. * @param amount amount of chromatic aberration
  71167. */
  71168. setChromaticAberration(amount: number): void;
  71169. /**
  71170. * Sets chromatic aberration amount to 0
  71171. */
  71172. disableChromaticAberration(): void;
  71173. /**
  71174. * Sets the EdgeDistortion amount
  71175. * @param amount amount of EdgeDistortion
  71176. */
  71177. setEdgeDistortion(amount: number): void;
  71178. /**
  71179. * Sets edge distortion to 0
  71180. */
  71181. disableEdgeDistortion(): void;
  71182. /**
  71183. * Sets the FocusDistance amount
  71184. * @param amount amount of FocusDistance
  71185. */
  71186. setFocusDistance(amount: number): void;
  71187. /**
  71188. * Disables depth of field
  71189. */
  71190. disableDepthOfField(): void;
  71191. /**
  71192. * Sets the Aperture amount
  71193. * @param amount amount of Aperture
  71194. */
  71195. setAperture(amount: number): void;
  71196. /**
  71197. * Sets the DarkenOutOfFocus amount
  71198. * @param amount amount of DarkenOutOfFocus
  71199. */
  71200. setDarkenOutOfFocus(amount: number): void;
  71201. private _pentagonBokehIsEnabled;
  71202. /**
  71203. * Creates a pentagon bokeh effect
  71204. */
  71205. enablePentagonBokeh(): void;
  71206. /**
  71207. * Disables the pentagon bokeh effect
  71208. */
  71209. disablePentagonBokeh(): void;
  71210. /**
  71211. * Enables noise blur
  71212. */
  71213. enableNoiseBlur(): void;
  71214. /**
  71215. * Disables noise blur
  71216. */
  71217. disableNoiseBlur(): void;
  71218. /**
  71219. * Sets the HighlightsGain amount
  71220. * @param amount amount of HighlightsGain
  71221. */
  71222. setHighlightsGain(amount: number): void;
  71223. /**
  71224. * Sets the HighlightsThreshold amount
  71225. * @param amount amount of HighlightsThreshold
  71226. */
  71227. setHighlightsThreshold(amount: number): void;
  71228. /**
  71229. * Disables highlights
  71230. */
  71231. disableHighlights(): void;
  71232. /**
  71233. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71234. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71235. */
  71236. dispose(disableDepthRender?: boolean): void;
  71237. private _createChromaticAberrationPostProcess;
  71238. private _createHighlightsPostProcess;
  71239. private _createDepthOfFieldPostProcess;
  71240. private _createGrainTexture;
  71241. }
  71242. }
  71243. declare module BABYLON {
  71244. /**
  71245. * Contains all parameters needed for the prepass to perform
  71246. * screen space subsurface scattering
  71247. */
  71248. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71249. /**
  71250. * Is subsurface enabled
  71251. */
  71252. enabled: boolean;
  71253. /**
  71254. * Name of the configuration
  71255. */
  71256. name: string;
  71257. /**
  71258. * Textures that should be present in the MRT for this effect to work
  71259. */
  71260. readonly texturesRequired: number[];
  71261. }
  71262. }
  71263. declare module BABYLON {
  71264. /** @hidden */
  71265. export var ssao2PixelShader: {
  71266. name: string;
  71267. shader: string;
  71268. };
  71269. }
  71270. declare module BABYLON {
  71271. /** @hidden */
  71272. export var ssaoCombinePixelShader: {
  71273. name: string;
  71274. shader: string;
  71275. };
  71276. }
  71277. declare module BABYLON {
  71278. /**
  71279. * Render pipeline to produce ssao effect
  71280. */
  71281. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71282. /**
  71283. * @ignore
  71284. * The PassPostProcess id in the pipeline that contains the original scene color
  71285. */
  71286. SSAOOriginalSceneColorEffect: string;
  71287. /**
  71288. * @ignore
  71289. * The SSAO PostProcess id in the pipeline
  71290. */
  71291. SSAORenderEffect: string;
  71292. /**
  71293. * @ignore
  71294. * The horizontal blur PostProcess id in the pipeline
  71295. */
  71296. SSAOBlurHRenderEffect: string;
  71297. /**
  71298. * @ignore
  71299. * The vertical blur PostProcess id in the pipeline
  71300. */
  71301. SSAOBlurVRenderEffect: string;
  71302. /**
  71303. * @ignore
  71304. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71305. */
  71306. SSAOCombineRenderEffect: string;
  71307. /**
  71308. * The output strength of the SSAO post-process. Default value is 1.0.
  71309. */
  71310. totalStrength: number;
  71311. /**
  71312. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71313. */
  71314. maxZ: number;
  71315. /**
  71316. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71317. */
  71318. minZAspect: number;
  71319. private _samples;
  71320. /**
  71321. * Number of samples used for the SSAO calculations. Default value is 8
  71322. */
  71323. set samples(n: number);
  71324. get samples(): number;
  71325. private _textureSamples;
  71326. /**
  71327. * Number of samples to use for antialiasing
  71328. */
  71329. set textureSamples(n: number);
  71330. get textureSamples(): number;
  71331. /**
  71332. * Force rendering the geometry through geometry buffer
  71333. */
  71334. private _forceGeometryBuffer;
  71335. /**
  71336. * Ratio object used for SSAO ratio and blur ratio
  71337. */
  71338. private _ratio;
  71339. /**
  71340. * Dynamically generated sphere sampler.
  71341. */
  71342. private _sampleSphere;
  71343. /**
  71344. * Blur filter offsets
  71345. */
  71346. private _samplerOffsets;
  71347. private _expensiveBlur;
  71348. /**
  71349. * If bilateral blur should be used
  71350. */
  71351. set expensiveBlur(b: boolean);
  71352. get expensiveBlur(): boolean;
  71353. /**
  71354. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71355. */
  71356. radius: number;
  71357. /**
  71358. * The base color of the SSAO post-process
  71359. * The final result is "base + ssao" between [0, 1]
  71360. */
  71361. base: number;
  71362. /**
  71363. * Support test.
  71364. */
  71365. static get IsSupported(): boolean;
  71366. private _scene;
  71367. private _randomTexture;
  71368. private _originalColorPostProcess;
  71369. private _ssaoPostProcess;
  71370. private _blurHPostProcess;
  71371. private _blurVPostProcess;
  71372. private _ssaoCombinePostProcess;
  71373. private _prePassRenderer;
  71374. /**
  71375. * Gets active scene
  71376. */
  71377. get scene(): Scene;
  71378. /**
  71379. * @constructor
  71380. * @param name The rendering pipeline name
  71381. * @param scene The scene linked to this pipeline
  71382. * @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 }
  71383. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71384. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71385. */
  71386. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71387. /**
  71388. * Get the class name
  71389. * @returns "SSAO2RenderingPipeline"
  71390. */
  71391. getClassName(): string;
  71392. /**
  71393. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71394. */
  71395. dispose(disableGeometryBufferRenderer?: boolean): void;
  71396. private _createBlurPostProcess;
  71397. /** @hidden */
  71398. _rebuild(): void;
  71399. private _bits;
  71400. private _radicalInverse_VdC;
  71401. private _hammersley;
  71402. private _hemisphereSample_uniform;
  71403. private _generateHemisphere;
  71404. private _getDefinesForSSAO;
  71405. private _createSSAOPostProcess;
  71406. private _createSSAOCombinePostProcess;
  71407. private _createRandomTexture;
  71408. /**
  71409. * Serialize the rendering pipeline (Used when exporting)
  71410. * @returns the serialized object
  71411. */
  71412. serialize(): any;
  71413. /**
  71414. * Parse the serialized pipeline
  71415. * @param source Source pipeline.
  71416. * @param scene The scene to load the pipeline to.
  71417. * @param rootUrl The URL of the serialized pipeline.
  71418. * @returns An instantiated pipeline from the serialized object.
  71419. */
  71420. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71421. }
  71422. }
  71423. declare module BABYLON {
  71424. /** @hidden */
  71425. export var ssaoPixelShader: {
  71426. name: string;
  71427. shader: string;
  71428. };
  71429. }
  71430. declare module BABYLON {
  71431. /**
  71432. * Render pipeline to produce ssao effect
  71433. */
  71434. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71435. /**
  71436. * @ignore
  71437. * The PassPostProcess id in the pipeline that contains the original scene color
  71438. */
  71439. SSAOOriginalSceneColorEffect: string;
  71440. /**
  71441. * @ignore
  71442. * The SSAO PostProcess id in the pipeline
  71443. */
  71444. SSAORenderEffect: string;
  71445. /**
  71446. * @ignore
  71447. * The horizontal blur PostProcess id in the pipeline
  71448. */
  71449. SSAOBlurHRenderEffect: string;
  71450. /**
  71451. * @ignore
  71452. * The vertical blur PostProcess id in the pipeline
  71453. */
  71454. SSAOBlurVRenderEffect: string;
  71455. /**
  71456. * @ignore
  71457. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71458. */
  71459. SSAOCombineRenderEffect: string;
  71460. /**
  71461. * The output strength of the SSAO post-process. Default value is 1.0.
  71462. */
  71463. totalStrength: number;
  71464. /**
  71465. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71466. */
  71467. radius: number;
  71468. /**
  71469. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71470. * Must not be equal to fallOff and superior to fallOff.
  71471. * Default value is 0.0075
  71472. */
  71473. area: number;
  71474. /**
  71475. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71476. * Must not be equal to area and inferior to area.
  71477. * Default value is 0.000001
  71478. */
  71479. fallOff: number;
  71480. /**
  71481. * The base color of the SSAO post-process
  71482. * The final result is "base + ssao" between [0, 1]
  71483. */
  71484. base: number;
  71485. private _scene;
  71486. private _depthTexture;
  71487. private _randomTexture;
  71488. private _originalColorPostProcess;
  71489. private _ssaoPostProcess;
  71490. private _blurHPostProcess;
  71491. private _blurVPostProcess;
  71492. private _ssaoCombinePostProcess;
  71493. private _firstUpdate;
  71494. /**
  71495. * Gets active scene
  71496. */
  71497. get scene(): Scene;
  71498. /**
  71499. * @constructor
  71500. * @param name - The rendering pipeline name
  71501. * @param scene - The scene linked to this pipeline
  71502. * @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 }
  71503. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71504. */
  71505. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71506. /**
  71507. * Get the class name
  71508. * @returns "SSAORenderingPipeline"
  71509. */
  71510. getClassName(): string;
  71511. /**
  71512. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71513. */
  71514. dispose(disableDepthRender?: boolean): void;
  71515. private _createBlurPostProcess;
  71516. /** @hidden */
  71517. _rebuild(): void;
  71518. private _createSSAOPostProcess;
  71519. private _createSSAOCombinePostProcess;
  71520. private _createRandomTexture;
  71521. }
  71522. }
  71523. declare module BABYLON {
  71524. /**
  71525. * Contains all parameters needed for the prepass to perform
  71526. * screen space reflections
  71527. */
  71528. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  71529. /**
  71530. * Is ssr enabled
  71531. */
  71532. enabled: boolean;
  71533. /**
  71534. * Name of the configuration
  71535. */
  71536. name: string;
  71537. /**
  71538. * Textures that should be present in the MRT for this effect to work
  71539. */
  71540. readonly texturesRequired: number[];
  71541. }
  71542. }
  71543. declare module BABYLON {
  71544. /** @hidden */
  71545. export var screenSpaceReflectionPixelShader: {
  71546. name: string;
  71547. shader: string;
  71548. };
  71549. }
  71550. declare module BABYLON {
  71551. /**
  71552. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71553. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71554. */
  71555. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71556. /**
  71557. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71558. */
  71559. threshold: number;
  71560. /**
  71561. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71562. */
  71563. strength: number;
  71564. /**
  71565. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71566. */
  71567. reflectionSpecularFalloffExponent: number;
  71568. /**
  71569. * 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]
  71570. */
  71571. step: number;
  71572. /**
  71573. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71574. */
  71575. roughnessFactor: number;
  71576. private _forceGeometryBuffer;
  71577. private _geometryBufferRenderer;
  71578. private _prePassRenderer;
  71579. private _enableSmoothReflections;
  71580. private _reflectionSamples;
  71581. private _smoothSteps;
  71582. /**
  71583. * Gets a string identifying the name of the class
  71584. * @returns "ScreenSpaceReflectionPostProcess" string
  71585. */
  71586. getClassName(): string;
  71587. /**
  71588. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71589. * @param name The name of the effect.
  71590. * @param scene The scene containing the objects to calculate reflections.
  71591. * @param options The required width/height ratio to downsize to before computing the render pass.
  71592. * @param camera The camera to apply the render pass to.
  71593. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71594. * @param engine The engine which the post process will be applied. (default: current engine)
  71595. * @param reusable If the post process can be reused on the same frame. (default: false)
  71596. * @param textureType Type of textures used when performing the post process. (default: 0)
  71597. * @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)
  71598. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71599. */
  71600. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71601. /**
  71602. * Gets wether or not smoothing reflections is enabled.
  71603. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71604. */
  71605. get enableSmoothReflections(): boolean;
  71606. /**
  71607. * Sets wether or not smoothing reflections is enabled.
  71608. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71609. */
  71610. set enableSmoothReflections(enabled: boolean);
  71611. /**
  71612. * Gets the number of samples taken while computing reflections. More samples count is high,
  71613. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71614. */
  71615. get reflectionSamples(): number;
  71616. /**
  71617. * Sets the number of samples taken while computing reflections. More samples count is high,
  71618. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71619. */
  71620. set reflectionSamples(samples: number);
  71621. /**
  71622. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71623. * more the post-process will require GPU power and can generate a drop in FPS.
  71624. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71625. */
  71626. get smoothSteps(): number;
  71627. set smoothSteps(steps: number);
  71628. private _updateEffectDefines;
  71629. /** @hidden */
  71630. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71631. }
  71632. }
  71633. declare module BABYLON {
  71634. /** @hidden */
  71635. export var standardPixelShader: {
  71636. name: string;
  71637. shader: string;
  71638. };
  71639. }
  71640. declare module BABYLON {
  71641. /**
  71642. * Standard rendering pipeline
  71643. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71644. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71645. */
  71646. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71647. /**
  71648. * Public members
  71649. */
  71650. /**
  71651. * Post-process which contains the original scene color before the pipeline applies all the effects
  71652. */
  71653. originalPostProcess: Nullable<PostProcess>;
  71654. /**
  71655. * Post-process used to down scale an image x4
  71656. */
  71657. downSampleX4PostProcess: Nullable<PostProcess>;
  71658. /**
  71659. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71660. */
  71661. brightPassPostProcess: Nullable<PostProcess>;
  71662. /**
  71663. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71664. */
  71665. blurHPostProcesses: PostProcess[];
  71666. /**
  71667. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71668. */
  71669. blurVPostProcesses: PostProcess[];
  71670. /**
  71671. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71672. */
  71673. textureAdderPostProcess: Nullable<PostProcess>;
  71674. /**
  71675. * Post-process used to create volumetric lighting effect
  71676. */
  71677. volumetricLightPostProcess: Nullable<PostProcess>;
  71678. /**
  71679. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71680. */
  71681. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71682. /**
  71683. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71684. */
  71685. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71686. /**
  71687. * Post-process used to merge the volumetric light effect and the real scene color
  71688. */
  71689. volumetricLightMergePostProces: Nullable<PostProcess>;
  71690. /**
  71691. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71692. */
  71693. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71694. /**
  71695. * Base post-process used to calculate the average luminance of the final image for HDR
  71696. */
  71697. luminancePostProcess: Nullable<PostProcess>;
  71698. /**
  71699. * Post-processes used to create down sample post-processes in order to get
  71700. * the average luminance of the final image for HDR
  71701. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71702. */
  71703. luminanceDownSamplePostProcesses: PostProcess[];
  71704. /**
  71705. * Post-process used to create a HDR effect (light adaptation)
  71706. */
  71707. hdrPostProcess: Nullable<PostProcess>;
  71708. /**
  71709. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71710. */
  71711. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71712. /**
  71713. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71714. */
  71715. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71716. /**
  71717. * Post-process used to merge the final HDR post-process and the real scene color
  71718. */
  71719. hdrFinalPostProcess: Nullable<PostProcess>;
  71720. /**
  71721. * Post-process used to create a lens flare effect
  71722. */
  71723. lensFlarePostProcess: Nullable<PostProcess>;
  71724. /**
  71725. * Post-process that merges the result of the lens flare post-process and the real scene color
  71726. */
  71727. lensFlareComposePostProcess: Nullable<PostProcess>;
  71728. /**
  71729. * Post-process used to create a motion blur effect
  71730. */
  71731. motionBlurPostProcess: Nullable<PostProcess>;
  71732. /**
  71733. * Post-process used to create a depth of field effect
  71734. */
  71735. depthOfFieldPostProcess: Nullable<PostProcess>;
  71736. /**
  71737. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71738. */
  71739. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71740. /**
  71741. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71742. */
  71743. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71744. /**
  71745. * Represents the brightness threshold in order to configure the illuminated surfaces
  71746. */
  71747. brightThreshold: number;
  71748. /**
  71749. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71750. */
  71751. blurWidth: number;
  71752. /**
  71753. * Sets if the blur for highlighted surfaces must be only horizontal
  71754. */
  71755. horizontalBlur: boolean;
  71756. /**
  71757. * Gets the overall exposure used by the pipeline
  71758. */
  71759. get exposure(): number;
  71760. /**
  71761. * Sets the overall exposure used by the pipeline
  71762. */
  71763. set exposure(value: number);
  71764. /**
  71765. * Texture used typically to simulate "dirty" on camera lens
  71766. */
  71767. lensTexture: Nullable<Texture>;
  71768. /**
  71769. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71770. */
  71771. volumetricLightCoefficient: number;
  71772. /**
  71773. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71774. */
  71775. volumetricLightPower: number;
  71776. /**
  71777. * Used the set the blur intensity to smooth the volumetric lights
  71778. */
  71779. volumetricLightBlurScale: number;
  71780. /**
  71781. * Light (spot or directional) used to generate the volumetric lights rays
  71782. * The source light must have a shadow generate so the pipeline can get its
  71783. * depth map
  71784. */
  71785. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71786. /**
  71787. * For eye adaptation, represents the minimum luminance the eye can see
  71788. */
  71789. hdrMinimumLuminance: number;
  71790. /**
  71791. * For eye adaptation, represents the decrease luminance speed
  71792. */
  71793. hdrDecreaseRate: number;
  71794. /**
  71795. * For eye adaptation, represents the increase luminance speed
  71796. */
  71797. hdrIncreaseRate: number;
  71798. /**
  71799. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71800. */
  71801. get hdrAutoExposure(): boolean;
  71802. /**
  71803. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71804. */
  71805. set hdrAutoExposure(value: boolean);
  71806. /**
  71807. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71808. */
  71809. lensColorTexture: Nullable<Texture>;
  71810. /**
  71811. * The overall strengh for the lens flare effect
  71812. */
  71813. lensFlareStrength: number;
  71814. /**
  71815. * Dispersion coefficient for lens flare ghosts
  71816. */
  71817. lensFlareGhostDispersal: number;
  71818. /**
  71819. * Main lens flare halo width
  71820. */
  71821. lensFlareHaloWidth: number;
  71822. /**
  71823. * Based on the lens distortion effect, defines how much the lens flare result
  71824. * is distorted
  71825. */
  71826. lensFlareDistortionStrength: number;
  71827. /**
  71828. * Configures the blur intensity used for for lens flare (halo)
  71829. */
  71830. lensFlareBlurWidth: number;
  71831. /**
  71832. * Lens star texture must be used to simulate rays on the flares and is available
  71833. * in the documentation
  71834. */
  71835. lensStarTexture: Nullable<Texture>;
  71836. /**
  71837. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71838. * flare effect by taking account of the dirt texture
  71839. */
  71840. lensFlareDirtTexture: Nullable<Texture>;
  71841. /**
  71842. * Represents the focal length for the depth of field effect
  71843. */
  71844. depthOfFieldDistance: number;
  71845. /**
  71846. * Represents the blur intensity for the blurred part of the depth of field effect
  71847. */
  71848. depthOfFieldBlurWidth: number;
  71849. /**
  71850. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71851. */
  71852. get motionStrength(): number;
  71853. /**
  71854. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71855. */
  71856. set motionStrength(strength: number);
  71857. /**
  71858. * Gets wether or not the motion blur post-process is object based or screen based.
  71859. */
  71860. get objectBasedMotionBlur(): boolean;
  71861. /**
  71862. * Sets wether or not the motion blur post-process should be object based or screen based
  71863. */
  71864. set objectBasedMotionBlur(value: boolean);
  71865. /**
  71866. * List of animations for the pipeline (IAnimatable implementation)
  71867. */
  71868. animations: Animation[];
  71869. /**
  71870. * Private members
  71871. */
  71872. private _scene;
  71873. private _currentDepthOfFieldSource;
  71874. private _basePostProcess;
  71875. private _fixedExposure;
  71876. private _currentExposure;
  71877. private _hdrAutoExposure;
  71878. private _hdrCurrentLuminance;
  71879. private _motionStrength;
  71880. private _isObjectBasedMotionBlur;
  71881. private _floatTextureType;
  71882. private _camerasToBeAttached;
  71883. private _ratio;
  71884. private _bloomEnabled;
  71885. private _depthOfFieldEnabled;
  71886. private _vlsEnabled;
  71887. private _lensFlareEnabled;
  71888. private _hdrEnabled;
  71889. private _motionBlurEnabled;
  71890. private _fxaaEnabled;
  71891. private _screenSpaceReflectionsEnabled;
  71892. private _motionBlurSamples;
  71893. private _volumetricLightStepsCount;
  71894. private _samples;
  71895. /**
  71896. * @ignore
  71897. * Specifies if the bloom pipeline is enabled
  71898. */
  71899. get BloomEnabled(): boolean;
  71900. set BloomEnabled(enabled: boolean);
  71901. /**
  71902. * @ignore
  71903. * Specifies if the depth of field pipeline is enabed
  71904. */
  71905. get DepthOfFieldEnabled(): boolean;
  71906. set DepthOfFieldEnabled(enabled: boolean);
  71907. /**
  71908. * @ignore
  71909. * Specifies if the lens flare pipeline is enabed
  71910. */
  71911. get LensFlareEnabled(): boolean;
  71912. set LensFlareEnabled(enabled: boolean);
  71913. /**
  71914. * @ignore
  71915. * Specifies if the HDR pipeline is enabled
  71916. */
  71917. get HDREnabled(): boolean;
  71918. set HDREnabled(enabled: boolean);
  71919. /**
  71920. * @ignore
  71921. * Specifies if the volumetric lights scattering effect is enabled
  71922. */
  71923. get VLSEnabled(): boolean;
  71924. set VLSEnabled(enabled: boolean);
  71925. /**
  71926. * @ignore
  71927. * Specifies if the motion blur effect is enabled
  71928. */
  71929. get MotionBlurEnabled(): boolean;
  71930. set MotionBlurEnabled(enabled: boolean);
  71931. /**
  71932. * Specifies if anti-aliasing is enabled
  71933. */
  71934. get fxaaEnabled(): boolean;
  71935. set fxaaEnabled(enabled: boolean);
  71936. /**
  71937. * Specifies if screen space reflections are enabled.
  71938. */
  71939. get screenSpaceReflectionsEnabled(): boolean;
  71940. set screenSpaceReflectionsEnabled(enabled: boolean);
  71941. /**
  71942. * Specifies the number of steps used to calculate the volumetric lights
  71943. * Typically in interval [50, 200]
  71944. */
  71945. get volumetricLightStepsCount(): number;
  71946. set volumetricLightStepsCount(count: number);
  71947. /**
  71948. * Specifies the number of samples used for the motion blur effect
  71949. * Typically in interval [16, 64]
  71950. */
  71951. get motionBlurSamples(): number;
  71952. set motionBlurSamples(samples: number);
  71953. /**
  71954. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71955. */
  71956. get samples(): number;
  71957. set samples(sampleCount: number);
  71958. /**
  71959. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71960. * @constructor
  71961. * @param name The rendering pipeline name
  71962. * @param scene The scene linked to this pipeline
  71963. * @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)
  71964. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71965. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71966. */
  71967. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71968. private _buildPipeline;
  71969. private _createDownSampleX4PostProcess;
  71970. private _createBrightPassPostProcess;
  71971. private _createBlurPostProcesses;
  71972. private _createTextureAdderPostProcess;
  71973. private _createVolumetricLightPostProcess;
  71974. private _createLuminancePostProcesses;
  71975. private _createHdrPostProcess;
  71976. private _createLensFlarePostProcess;
  71977. private _createDepthOfFieldPostProcess;
  71978. private _createMotionBlurPostProcess;
  71979. private _getDepthTexture;
  71980. private _disposePostProcesses;
  71981. /**
  71982. * Dispose of the pipeline and stop all post processes
  71983. */
  71984. dispose(): void;
  71985. /**
  71986. * Serialize the rendering pipeline (Used when exporting)
  71987. * @returns the serialized object
  71988. */
  71989. serialize(): any;
  71990. /**
  71991. * Parse the serialized pipeline
  71992. * @param source Source pipeline.
  71993. * @param scene The scene to load the pipeline to.
  71994. * @param rootUrl The URL of the serialized pipeline.
  71995. * @returns An instantiated pipeline from the serialized object.
  71996. */
  71997. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71998. /**
  71999. * Luminance steps
  72000. */
  72001. static LuminanceSteps: number;
  72002. }
  72003. }
  72004. declare module BABYLON {
  72005. /** @hidden */
  72006. export var stereoscopicInterlacePixelShader: {
  72007. name: string;
  72008. shader: string;
  72009. };
  72010. }
  72011. declare module BABYLON {
  72012. /**
  72013. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72014. */
  72015. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72016. private _stepSize;
  72017. private _passedProcess;
  72018. /**
  72019. * Gets a string identifying the name of the class
  72020. * @returns "StereoscopicInterlacePostProcessI" string
  72021. */
  72022. getClassName(): string;
  72023. /**
  72024. * Initializes a StereoscopicInterlacePostProcessI
  72025. * @param name The name of the effect.
  72026. * @param rigCameras The rig cameras to be appled to the post process
  72027. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72028. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72030. * @param engine The engine which the post process will be applied. (default: current engine)
  72031. * @param reusable If the post process can be reused on the same frame. (default: false)
  72032. */
  72033. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72034. }
  72035. /**
  72036. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72037. */
  72038. export class StereoscopicInterlacePostProcess extends PostProcess {
  72039. private _stepSize;
  72040. private _passedProcess;
  72041. /**
  72042. * Gets a string identifying the name of the class
  72043. * @returns "StereoscopicInterlacePostProcess" string
  72044. */
  72045. getClassName(): string;
  72046. /**
  72047. * Initializes a StereoscopicInterlacePostProcess
  72048. * @param name The name of the effect.
  72049. * @param rigCameras The rig cameras to be appled to the post process
  72050. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72052. * @param engine The engine which the post process will be applied. (default: current engine)
  72053. * @param reusable If the post process can be reused on the same frame. (default: false)
  72054. */
  72055. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72056. }
  72057. }
  72058. declare module BABYLON {
  72059. /** @hidden */
  72060. export var tonemapPixelShader: {
  72061. name: string;
  72062. shader: string;
  72063. };
  72064. }
  72065. declare module BABYLON {
  72066. /** Defines operator used for tonemapping */
  72067. export enum TonemappingOperator {
  72068. /** Hable */
  72069. Hable = 0,
  72070. /** Reinhard */
  72071. Reinhard = 1,
  72072. /** HejiDawson */
  72073. HejiDawson = 2,
  72074. /** Photographic */
  72075. Photographic = 3
  72076. }
  72077. /**
  72078. * Defines a post process to apply tone mapping
  72079. */
  72080. export class TonemapPostProcess extends PostProcess {
  72081. private _operator;
  72082. /** Defines the required exposure adjustement */
  72083. exposureAdjustment: number;
  72084. /**
  72085. * Gets a string identifying the name of the class
  72086. * @returns "TonemapPostProcess" string
  72087. */
  72088. getClassName(): string;
  72089. /**
  72090. * Creates a new TonemapPostProcess
  72091. * @param name defines the name of the postprocess
  72092. * @param _operator defines the operator to use
  72093. * @param exposureAdjustment defines the required exposure adjustement
  72094. * @param camera defines the camera to use (can be null)
  72095. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72096. * @param engine defines the hosting engine (can be ignore if camera is set)
  72097. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72098. */
  72099. constructor(name: string, _operator: TonemappingOperator,
  72100. /** Defines the required exposure adjustement */
  72101. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72102. }
  72103. }
  72104. declare module BABYLON {
  72105. /** @hidden */
  72106. export var volumetricLightScatteringPixelShader: {
  72107. name: string;
  72108. shader: string;
  72109. };
  72110. }
  72111. declare module BABYLON {
  72112. /** @hidden */
  72113. export var volumetricLightScatteringPassVertexShader: {
  72114. name: string;
  72115. shader: string;
  72116. };
  72117. }
  72118. declare module BABYLON {
  72119. /** @hidden */
  72120. export var volumetricLightScatteringPassPixelShader: {
  72121. name: string;
  72122. shader: string;
  72123. };
  72124. }
  72125. declare module BABYLON {
  72126. /**
  72127. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72128. */
  72129. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72130. private _volumetricLightScatteringPass;
  72131. private _volumetricLightScatteringRTT;
  72132. private _viewPort;
  72133. private _screenCoordinates;
  72134. private _cachedDefines;
  72135. /**
  72136. * If not undefined, the mesh position is computed from the attached node position
  72137. */
  72138. attachedNode: {
  72139. position: Vector3;
  72140. };
  72141. /**
  72142. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72143. */
  72144. customMeshPosition: Vector3;
  72145. /**
  72146. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72147. */
  72148. useCustomMeshPosition: boolean;
  72149. /**
  72150. * If the post-process should inverse the light scattering direction
  72151. */
  72152. invert: boolean;
  72153. /**
  72154. * The internal mesh used by the post-process
  72155. */
  72156. mesh: Mesh;
  72157. /**
  72158. * @hidden
  72159. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72160. */
  72161. get useDiffuseColor(): boolean;
  72162. set useDiffuseColor(useDiffuseColor: boolean);
  72163. /**
  72164. * Array containing the excluded meshes not rendered in the internal pass
  72165. */
  72166. excludedMeshes: AbstractMesh[];
  72167. /**
  72168. * Controls the overall intensity of the post-process
  72169. */
  72170. exposure: number;
  72171. /**
  72172. * Dissipates each sample's contribution in range [0, 1]
  72173. */
  72174. decay: number;
  72175. /**
  72176. * Controls the overall intensity of each sample
  72177. */
  72178. weight: number;
  72179. /**
  72180. * Controls the density of each sample
  72181. */
  72182. density: number;
  72183. /**
  72184. * @constructor
  72185. * @param name The post-process name
  72186. * @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)
  72187. * @param camera The camera that the post-process will be attached to
  72188. * @param mesh The mesh used to create the light scattering
  72189. * @param samples The post-process quality, default 100
  72190. * @param samplingModeThe post-process filtering mode
  72191. * @param engine The babylon engine
  72192. * @param reusable If the post-process is reusable
  72193. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72194. */
  72195. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72196. /**
  72197. * Returns the string "VolumetricLightScatteringPostProcess"
  72198. * @returns "VolumetricLightScatteringPostProcess"
  72199. */
  72200. getClassName(): string;
  72201. private _isReady;
  72202. /**
  72203. * Sets the new light position for light scattering effect
  72204. * @param position The new custom light position
  72205. */
  72206. setCustomMeshPosition(position: Vector3): void;
  72207. /**
  72208. * Returns the light position for light scattering effect
  72209. * @return Vector3 The custom light position
  72210. */
  72211. getCustomMeshPosition(): Vector3;
  72212. /**
  72213. * Disposes the internal assets and detaches the post-process from the camera
  72214. */
  72215. dispose(camera: Camera): void;
  72216. /**
  72217. * Returns the render target texture used by the post-process
  72218. * @return the render target texture used by the post-process
  72219. */
  72220. getPass(): RenderTargetTexture;
  72221. private _meshExcluded;
  72222. private _createPass;
  72223. private _updateMeshScreenCoordinates;
  72224. /**
  72225. * Creates a default mesh for the Volumeric Light Scattering post-process
  72226. * @param name The mesh name
  72227. * @param scene The scene where to create the mesh
  72228. * @return the default mesh
  72229. */
  72230. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72231. }
  72232. }
  72233. declare module BABYLON {
  72234. /** @hidden */
  72235. export var screenSpaceCurvaturePixelShader: {
  72236. name: string;
  72237. shader: string;
  72238. };
  72239. }
  72240. declare module BABYLON {
  72241. /**
  72242. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72243. */
  72244. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72245. /**
  72246. * Defines how much ridge the curvature effect displays.
  72247. */
  72248. ridge: number;
  72249. /**
  72250. * Defines how much valley the curvature effect displays.
  72251. */
  72252. valley: number;
  72253. private _geometryBufferRenderer;
  72254. /**
  72255. * Gets a string identifying the name of the class
  72256. * @returns "ScreenSpaceCurvaturePostProcess" string
  72257. */
  72258. getClassName(): string;
  72259. /**
  72260. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72261. * @param name The name of the effect.
  72262. * @param scene The scene containing the objects to blur according to their velocity.
  72263. * @param options The required width/height ratio to downsize to before computing the render pass.
  72264. * @param camera The camera to apply the render pass to.
  72265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72266. * @param engine The engine which the post process will be applied. (default: current engine)
  72267. * @param reusable If the post process can be reused on the same frame. (default: false)
  72268. * @param textureType Type of textures used when performing the post process. (default: 0)
  72269. * @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)
  72270. */
  72271. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72272. /**
  72273. * Support test.
  72274. */
  72275. static get IsSupported(): boolean;
  72276. /** @hidden */
  72277. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72278. }
  72279. }
  72280. declare module BABYLON {
  72281. interface Scene {
  72282. /** @hidden (Backing field) */
  72283. _boundingBoxRenderer: BoundingBoxRenderer;
  72284. /** @hidden (Backing field) */
  72285. _forceShowBoundingBoxes: boolean;
  72286. /**
  72287. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72288. */
  72289. forceShowBoundingBoxes: boolean;
  72290. /**
  72291. * Gets the bounding box renderer associated with the scene
  72292. * @returns a BoundingBoxRenderer
  72293. */
  72294. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72295. }
  72296. interface AbstractMesh {
  72297. /** @hidden (Backing field) */
  72298. _showBoundingBox: boolean;
  72299. /**
  72300. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72301. */
  72302. showBoundingBox: boolean;
  72303. }
  72304. /**
  72305. * Component responsible of rendering the bounding box of the meshes in a scene.
  72306. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72307. */
  72308. export class BoundingBoxRenderer implements ISceneComponent {
  72309. /**
  72310. * The component name helpfull to identify the component in the list of scene components.
  72311. */
  72312. readonly name: string;
  72313. /**
  72314. * The scene the component belongs to.
  72315. */
  72316. scene: Scene;
  72317. /**
  72318. * Color of the bounding box lines placed in front of an object
  72319. */
  72320. frontColor: Color3;
  72321. /**
  72322. * Color of the bounding box lines placed behind an object
  72323. */
  72324. backColor: Color3;
  72325. /**
  72326. * Defines if the renderer should show the back lines or not
  72327. */
  72328. showBackLines: boolean;
  72329. /**
  72330. * Observable raised before rendering a bounding box
  72331. */
  72332. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72333. /**
  72334. * Observable raised after rendering a bounding box
  72335. */
  72336. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72337. /**
  72338. * @hidden
  72339. */
  72340. renderList: SmartArray<BoundingBox>;
  72341. private _colorShader;
  72342. private _vertexBuffers;
  72343. private _indexBuffer;
  72344. private _fillIndexBuffer;
  72345. private _fillIndexData;
  72346. /**
  72347. * Instantiates a new bounding box renderer in a scene.
  72348. * @param scene the scene the renderer renders in
  72349. */
  72350. constructor(scene: Scene);
  72351. /**
  72352. * Registers the component in a given scene
  72353. */
  72354. register(): void;
  72355. private _evaluateSubMesh;
  72356. private _activeMesh;
  72357. private _prepareRessources;
  72358. private _createIndexBuffer;
  72359. /**
  72360. * Rebuilds the elements related to this component in case of
  72361. * context lost for instance.
  72362. */
  72363. rebuild(): void;
  72364. /**
  72365. * @hidden
  72366. */
  72367. reset(): void;
  72368. /**
  72369. * Render the bounding boxes of a specific rendering group
  72370. * @param renderingGroupId defines the rendering group to render
  72371. */
  72372. render(renderingGroupId: number): void;
  72373. /**
  72374. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72375. * @param mesh Define the mesh to render the occlusion bounding box for
  72376. */
  72377. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72378. /**
  72379. * Dispose and release the resources attached to this renderer.
  72380. */
  72381. dispose(): void;
  72382. }
  72383. }
  72384. declare module BABYLON {
  72385. interface Scene {
  72386. /** @hidden (Backing field) */
  72387. _depthRenderer: {
  72388. [id: string]: DepthRenderer;
  72389. };
  72390. /**
  72391. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72392. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72393. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72394. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72395. * @returns the created depth renderer
  72396. */
  72397. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72398. /**
  72399. * Disables a depth renderer for a given camera
  72400. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72401. */
  72402. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72403. }
  72404. /**
  72405. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72406. * in several rendering techniques.
  72407. */
  72408. export class DepthRendererSceneComponent implements ISceneComponent {
  72409. /**
  72410. * The component name helpfull to identify the component in the list of scene components.
  72411. */
  72412. readonly name: string;
  72413. /**
  72414. * The scene the component belongs to.
  72415. */
  72416. scene: Scene;
  72417. /**
  72418. * Creates a new instance of the component for the given scene
  72419. * @param scene Defines the scene to register the component in
  72420. */
  72421. constructor(scene: Scene);
  72422. /**
  72423. * Registers the component in a given scene
  72424. */
  72425. register(): void;
  72426. /**
  72427. * Rebuilds the elements related to this component in case of
  72428. * context lost for instance.
  72429. */
  72430. rebuild(): void;
  72431. /**
  72432. * Disposes the component and the associated ressources
  72433. */
  72434. dispose(): void;
  72435. private _gatherRenderTargets;
  72436. private _gatherActiveCameraRenderTargets;
  72437. }
  72438. }
  72439. declare module BABYLON {
  72440. interface AbstractScene {
  72441. /** @hidden (Backing field) */
  72442. _prePassRenderer: Nullable<PrePassRenderer>;
  72443. /**
  72444. * Gets or Sets the current prepass renderer associated to the scene.
  72445. */
  72446. prePassRenderer: Nullable<PrePassRenderer>;
  72447. /**
  72448. * Enables the prepass and associates it with the scene
  72449. * @returns the PrePassRenderer
  72450. */
  72451. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72452. /**
  72453. * Disables the prepass associated with the scene
  72454. */
  72455. disablePrePassRenderer(): void;
  72456. }
  72457. /**
  72458. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72459. * in several rendering techniques.
  72460. */
  72461. export class PrePassRendererSceneComponent implements ISceneComponent {
  72462. /**
  72463. * The component name helpful to identify the component in the list of scene components.
  72464. */
  72465. readonly name: string;
  72466. /**
  72467. * The scene the component belongs to.
  72468. */
  72469. scene: Scene;
  72470. /**
  72471. * Creates a new instance of the component for the given scene
  72472. * @param scene Defines the scene to register the component in
  72473. */
  72474. constructor(scene: Scene);
  72475. /**
  72476. * Registers the component in a given scene
  72477. */
  72478. register(): void;
  72479. private _beforeCameraDraw;
  72480. private _afterCameraDraw;
  72481. private _beforeClearStage;
  72482. /**
  72483. * Rebuilds the elements related to this component in case of
  72484. * context lost for instance.
  72485. */
  72486. rebuild(): void;
  72487. /**
  72488. * Disposes the component and the associated ressources
  72489. */
  72490. dispose(): void;
  72491. }
  72492. }
  72493. declare module BABYLON {
  72494. /** @hidden */
  72495. export var fibonacci: {
  72496. name: string;
  72497. shader: string;
  72498. };
  72499. }
  72500. declare module BABYLON {
  72501. /** @hidden */
  72502. export var diffusionProfile: {
  72503. name: string;
  72504. shader: string;
  72505. };
  72506. }
  72507. declare module BABYLON {
  72508. /** @hidden */
  72509. export var subSurfaceScatteringPixelShader: {
  72510. name: string;
  72511. shader: string;
  72512. };
  72513. }
  72514. declare module BABYLON {
  72515. /**
  72516. * Sub surface scattering post process
  72517. */
  72518. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72519. /**
  72520. * Gets a string identifying the name of the class
  72521. * @returns "SubSurfaceScatteringPostProcess" string
  72522. */
  72523. getClassName(): string;
  72524. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72525. }
  72526. }
  72527. declare module BABYLON {
  72528. /**
  72529. * Contains all parameters needed for the prepass to perform
  72530. * screen space subsurface scattering
  72531. */
  72532. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72533. /** @hidden */
  72534. static _SceneComponentInitialization: (scene: Scene) => void;
  72535. private _ssDiffusionS;
  72536. private _ssFilterRadii;
  72537. private _ssDiffusionD;
  72538. /**
  72539. * Post process to attach for screen space subsurface scattering
  72540. */
  72541. postProcess: SubSurfaceScatteringPostProcess;
  72542. /**
  72543. * Diffusion profile color for subsurface scattering
  72544. */
  72545. get ssDiffusionS(): number[];
  72546. /**
  72547. * Diffusion profile max color channel value for subsurface scattering
  72548. */
  72549. get ssDiffusionD(): number[];
  72550. /**
  72551. * Diffusion profile filter radius for subsurface scattering
  72552. */
  72553. get ssFilterRadii(): number[];
  72554. /**
  72555. * Is subsurface enabled
  72556. */
  72557. enabled: boolean;
  72558. /**
  72559. * Name of the configuration
  72560. */
  72561. name: string;
  72562. /**
  72563. * Diffusion profile colors for subsurface scattering
  72564. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72565. * See ...
  72566. * Note that you can only store up to 5 of them
  72567. */
  72568. ssDiffusionProfileColors: Color3[];
  72569. /**
  72570. * Defines the ratio real world => scene units.
  72571. * Used for subsurface scattering
  72572. */
  72573. metersPerUnit: number;
  72574. /**
  72575. * Textures that should be present in the MRT for this effect to work
  72576. */
  72577. readonly texturesRequired: number[];
  72578. private _scene;
  72579. /**
  72580. * Builds a subsurface configuration object
  72581. * @param scene The scene
  72582. */
  72583. constructor(scene: Scene);
  72584. /**
  72585. * Adds a new diffusion profile.
  72586. * Useful for more realistic subsurface scattering on diverse materials.
  72587. * @param color The color of the diffusion profile. Should be the average color of the material.
  72588. * @return The index of the diffusion profile for the material subsurface configuration
  72589. */
  72590. addDiffusionProfile(color: Color3): number;
  72591. /**
  72592. * Creates the sss post process
  72593. * @return The created post process
  72594. */
  72595. createPostProcess(): SubSurfaceScatteringPostProcess;
  72596. /**
  72597. * Deletes all diffusion profiles.
  72598. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72599. */
  72600. clearAllDiffusionProfiles(): void;
  72601. /**
  72602. * Disposes this object
  72603. */
  72604. dispose(): void;
  72605. /**
  72606. * @hidden
  72607. * https://zero-radiance.github.io/post/sampling-diffusion/
  72608. *
  72609. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72610. * ------------------------------------------------------------------------------------
  72611. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72612. * PDF[r, phi, s] = r * R[r, phi, s]
  72613. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72614. * ------------------------------------------------------------------------------------
  72615. * We importance sample the color channel with the widest scattering distance.
  72616. */
  72617. getDiffusionProfileParameters(color: Color3): number;
  72618. /**
  72619. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72620. * 'u' is the random number (the value of the CDF): [0, 1).
  72621. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72622. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72623. */
  72624. private _sampleBurleyDiffusionProfile;
  72625. }
  72626. }
  72627. declare module BABYLON {
  72628. interface AbstractScene {
  72629. /** @hidden (Backing field) */
  72630. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72631. /**
  72632. * Gets or Sets the current prepass renderer associated to the scene.
  72633. */
  72634. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72635. /**
  72636. * Enables the subsurface effect for prepass
  72637. * @returns the SubSurfaceConfiguration
  72638. */
  72639. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72640. /**
  72641. * Disables the subsurface effect for prepass
  72642. */
  72643. disableSubSurfaceForPrePass(): void;
  72644. }
  72645. /**
  72646. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72647. * in several rendering techniques.
  72648. */
  72649. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72650. /**
  72651. * The component name helpful to identify the component in the list of scene components.
  72652. */
  72653. readonly name: string;
  72654. /**
  72655. * The scene the component belongs to.
  72656. */
  72657. scene: Scene;
  72658. /**
  72659. * Creates a new instance of the component for the given scene
  72660. * @param scene Defines the scene to register the component in
  72661. */
  72662. constructor(scene: Scene);
  72663. /**
  72664. * Registers the component in a given scene
  72665. */
  72666. register(): void;
  72667. /**
  72668. * Serializes the component data to the specified json object
  72669. * @param serializationObject The object to serialize to
  72670. */
  72671. serialize(serializationObject: any): void;
  72672. /**
  72673. * Adds all the elements from the container to the scene
  72674. * @param container the container holding the elements
  72675. */
  72676. addFromContainer(container: AbstractScene): void;
  72677. /**
  72678. * Removes all the elements in the container from the scene
  72679. * @param container contains the elements to remove
  72680. * @param dispose if the removed element should be disposed (default: false)
  72681. */
  72682. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72683. /**
  72684. * Rebuilds the elements related to this component in case of
  72685. * context lost for instance.
  72686. */
  72687. rebuild(): void;
  72688. /**
  72689. * Disposes the component and the associated ressources
  72690. */
  72691. dispose(): void;
  72692. }
  72693. }
  72694. declare module BABYLON {
  72695. /** @hidden */
  72696. export var outlinePixelShader: {
  72697. name: string;
  72698. shader: string;
  72699. };
  72700. }
  72701. declare module BABYLON {
  72702. /** @hidden */
  72703. export var outlineVertexShader: {
  72704. name: string;
  72705. shader: string;
  72706. };
  72707. }
  72708. declare module BABYLON {
  72709. interface Scene {
  72710. /** @hidden */
  72711. _outlineRenderer: OutlineRenderer;
  72712. /**
  72713. * Gets the outline renderer associated with the scene
  72714. * @returns a OutlineRenderer
  72715. */
  72716. getOutlineRenderer(): OutlineRenderer;
  72717. }
  72718. interface AbstractMesh {
  72719. /** @hidden (Backing field) */
  72720. _renderOutline: boolean;
  72721. /**
  72722. * Gets or sets a boolean indicating if the outline must be rendered as well
  72723. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72724. */
  72725. renderOutline: boolean;
  72726. /** @hidden (Backing field) */
  72727. _renderOverlay: boolean;
  72728. /**
  72729. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72730. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72731. */
  72732. renderOverlay: boolean;
  72733. }
  72734. /**
  72735. * This class is responsible to draw bothe outline/overlay of meshes.
  72736. * It should not be used directly but through the available method on mesh.
  72737. */
  72738. export class OutlineRenderer implements ISceneComponent {
  72739. /**
  72740. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72741. */
  72742. private static _StencilReference;
  72743. /**
  72744. * The name of the component. Each component must have a unique name.
  72745. */
  72746. name: string;
  72747. /**
  72748. * The scene the component belongs to.
  72749. */
  72750. scene: Scene;
  72751. /**
  72752. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72753. */
  72754. zOffset: number;
  72755. private _engine;
  72756. private _effect;
  72757. private _cachedDefines;
  72758. private _savedDepthWrite;
  72759. /**
  72760. * Instantiates a new outline renderer. (There could be only one per scene).
  72761. * @param scene Defines the scene it belongs to
  72762. */
  72763. constructor(scene: Scene);
  72764. /**
  72765. * Register the component to one instance of a scene.
  72766. */
  72767. register(): void;
  72768. /**
  72769. * Rebuilds the elements related to this component in case of
  72770. * context lost for instance.
  72771. */
  72772. rebuild(): void;
  72773. /**
  72774. * Disposes the component and the associated ressources.
  72775. */
  72776. dispose(): void;
  72777. /**
  72778. * Renders the outline in the canvas.
  72779. * @param subMesh Defines the sumesh to render
  72780. * @param batch Defines the batch of meshes in case of instances
  72781. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72782. */
  72783. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72784. /**
  72785. * Returns whether or not the outline renderer is ready for a given submesh.
  72786. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72787. * @param subMesh Defines the submesh to check readyness for
  72788. * @param useInstances Defines wheter wee are trying to render instances or not
  72789. * @returns true if ready otherwise false
  72790. */
  72791. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72792. private _beforeRenderingMesh;
  72793. private _afterRenderingMesh;
  72794. }
  72795. }
  72796. declare module BABYLON {
  72797. /**
  72798. * Defines the basic options interface of a Sprite Frame Source Size.
  72799. */
  72800. export interface ISpriteJSONSpriteSourceSize {
  72801. /**
  72802. * number of the original width of the Frame
  72803. */
  72804. w: number;
  72805. /**
  72806. * number of the original height of the Frame
  72807. */
  72808. h: number;
  72809. }
  72810. /**
  72811. * Defines the basic options interface of a Sprite Frame Data.
  72812. */
  72813. export interface ISpriteJSONSpriteFrameData {
  72814. /**
  72815. * number of the x offset of the Frame
  72816. */
  72817. x: number;
  72818. /**
  72819. * number of the y offset of the Frame
  72820. */
  72821. y: number;
  72822. /**
  72823. * number of the width of the Frame
  72824. */
  72825. w: number;
  72826. /**
  72827. * number of the height of the Frame
  72828. */
  72829. h: number;
  72830. }
  72831. /**
  72832. * Defines the basic options interface of a JSON Sprite.
  72833. */
  72834. export interface ISpriteJSONSprite {
  72835. /**
  72836. * string name of the Frame
  72837. */
  72838. filename: string;
  72839. /**
  72840. * ISpriteJSONSpriteFrame basic object of the frame data
  72841. */
  72842. frame: ISpriteJSONSpriteFrameData;
  72843. /**
  72844. * boolean to flag is the frame was rotated.
  72845. */
  72846. rotated: boolean;
  72847. /**
  72848. * boolean to flag is the frame was trimmed.
  72849. */
  72850. trimmed: boolean;
  72851. /**
  72852. * ISpriteJSONSpriteFrame basic object of the source data
  72853. */
  72854. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72855. /**
  72856. * ISpriteJSONSpriteFrame basic object of the source data
  72857. */
  72858. sourceSize: ISpriteJSONSpriteSourceSize;
  72859. }
  72860. /**
  72861. * Defines the basic options interface of a JSON atlas.
  72862. */
  72863. export interface ISpriteJSONAtlas {
  72864. /**
  72865. * Array of objects that contain the frame data.
  72866. */
  72867. frames: Array<ISpriteJSONSprite>;
  72868. /**
  72869. * object basic object containing the sprite meta data.
  72870. */
  72871. meta?: object;
  72872. }
  72873. }
  72874. declare module BABYLON {
  72875. /** @hidden */
  72876. export var spriteMapPixelShader: {
  72877. name: string;
  72878. shader: string;
  72879. };
  72880. }
  72881. declare module BABYLON {
  72882. /** @hidden */
  72883. export var spriteMapVertexShader: {
  72884. name: string;
  72885. shader: string;
  72886. };
  72887. }
  72888. declare module BABYLON {
  72889. /**
  72890. * Defines the basic options interface of a SpriteMap
  72891. */
  72892. export interface ISpriteMapOptions {
  72893. /**
  72894. * Vector2 of the number of cells in the grid.
  72895. */
  72896. stageSize?: Vector2;
  72897. /**
  72898. * Vector2 of the size of the output plane in World Units.
  72899. */
  72900. outputSize?: Vector2;
  72901. /**
  72902. * Vector3 of the position of the output plane in World Units.
  72903. */
  72904. outputPosition?: Vector3;
  72905. /**
  72906. * Vector3 of the rotation of the output plane.
  72907. */
  72908. outputRotation?: Vector3;
  72909. /**
  72910. * number of layers that the system will reserve in resources.
  72911. */
  72912. layerCount?: number;
  72913. /**
  72914. * number of max animation frames a single cell will reserve in resources.
  72915. */
  72916. maxAnimationFrames?: number;
  72917. /**
  72918. * number cell index of the base tile when the system compiles.
  72919. */
  72920. baseTile?: number;
  72921. /**
  72922. * boolean flip the sprite after its been repositioned by the framing data.
  72923. */
  72924. flipU?: boolean;
  72925. /**
  72926. * Vector3 scalar of the global RGB values of the SpriteMap.
  72927. */
  72928. colorMultiply?: Vector3;
  72929. }
  72930. /**
  72931. * Defines the IDisposable interface in order to be cleanable from resources.
  72932. */
  72933. export interface ISpriteMap extends IDisposable {
  72934. /**
  72935. * String name of the SpriteMap.
  72936. */
  72937. name: string;
  72938. /**
  72939. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72940. */
  72941. atlasJSON: ISpriteJSONAtlas;
  72942. /**
  72943. * Texture of the SpriteMap.
  72944. */
  72945. spriteSheet: Texture;
  72946. /**
  72947. * The parameters to initialize the SpriteMap with.
  72948. */
  72949. options: ISpriteMapOptions;
  72950. }
  72951. /**
  72952. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72953. */
  72954. export class SpriteMap implements ISpriteMap {
  72955. /** The Name of the spriteMap */
  72956. name: string;
  72957. /** The JSON file with the frame and meta data */
  72958. atlasJSON: ISpriteJSONAtlas;
  72959. /** The systems Sprite Sheet Texture */
  72960. spriteSheet: Texture;
  72961. /** Arguments passed with the Constructor */
  72962. options: ISpriteMapOptions;
  72963. /** Public Sprite Storage array, parsed from atlasJSON */
  72964. sprites: Array<ISpriteJSONSprite>;
  72965. /** Returns the Number of Sprites in the System */
  72966. get spriteCount(): number;
  72967. /** Returns the Position of Output Plane*/
  72968. get position(): Vector3;
  72969. /** Returns the Position of Output Plane*/
  72970. set position(v: Vector3);
  72971. /** Returns the Rotation of Output Plane*/
  72972. get rotation(): Vector3;
  72973. /** Returns the Rotation of Output Plane*/
  72974. set rotation(v: Vector3);
  72975. /** Sets the AnimationMap*/
  72976. get animationMap(): RawTexture;
  72977. /** Sets the AnimationMap*/
  72978. set animationMap(v: RawTexture);
  72979. /** Scene that the SpriteMap was created in */
  72980. private _scene;
  72981. /** Texture Buffer of Float32 that holds tile frame data*/
  72982. private _frameMap;
  72983. /** Texture Buffers of Float32 that holds tileMap data*/
  72984. private _tileMaps;
  72985. /** Texture Buffer of Float32 that holds Animation Data*/
  72986. private _animationMap;
  72987. /** Custom ShaderMaterial Central to the System*/
  72988. private _material;
  72989. /** Custom ShaderMaterial Central to the System*/
  72990. private _output;
  72991. /** Systems Time Ticker*/
  72992. private _time;
  72993. /**
  72994. * Creates a new SpriteMap
  72995. * @param name defines the SpriteMaps Name
  72996. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72997. * @param spriteSheet is the Texture that the Sprites are on.
  72998. * @param options a basic deployment configuration
  72999. * @param scene The Scene that the map is deployed on
  73000. */
  73001. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73002. /**
  73003. * Returns tileID location
  73004. * @returns Vector2 the cell position ID
  73005. */
  73006. getTileID(): Vector2;
  73007. /**
  73008. * Gets the UV location of the mouse over the SpriteMap.
  73009. * @returns Vector2 the UV position of the mouse interaction
  73010. */
  73011. getMousePosition(): Vector2;
  73012. /**
  73013. * Creates the "frame" texture Buffer
  73014. * -------------------------------------
  73015. * Structure of frames
  73016. * "filename": "Falling-Water-2.png",
  73017. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73018. * "rotated": true,
  73019. * "trimmed": true,
  73020. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73021. * "sourceSize": {"w":32,"h":32}
  73022. * @returns RawTexture of the frameMap
  73023. */
  73024. private _createFrameBuffer;
  73025. /**
  73026. * Creates the tileMap texture Buffer
  73027. * @param buffer normally and array of numbers, or a false to generate from scratch
  73028. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73029. * @returns RawTexture of the tileMap
  73030. */
  73031. private _createTileBuffer;
  73032. /**
  73033. * Modifies the data of the tileMaps
  73034. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73035. * @param pos is the iVector2 Coordinates of the Tile
  73036. * @param tile The SpriteIndex of the new Tile
  73037. */
  73038. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73039. /**
  73040. * Creates the animationMap texture Buffer
  73041. * @param buffer normally and array of numbers, or a false to generate from scratch
  73042. * @returns RawTexture of the animationMap
  73043. */
  73044. private _createTileAnimationBuffer;
  73045. /**
  73046. * Modifies the data of the animationMap
  73047. * @param cellID is the Index of the Sprite
  73048. * @param _frame is the target Animation frame
  73049. * @param toCell is the Target Index of the next frame of the animation
  73050. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73051. * @param speed is a global scalar of the time variable on the map.
  73052. */
  73053. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73054. /**
  73055. * Exports the .tilemaps file
  73056. */
  73057. saveTileMaps(): void;
  73058. /**
  73059. * Imports the .tilemaps file
  73060. * @param url of the .tilemaps file
  73061. */
  73062. loadTileMaps(url: string): void;
  73063. /**
  73064. * Release associated resources
  73065. */
  73066. dispose(): void;
  73067. }
  73068. }
  73069. declare module BABYLON {
  73070. /**
  73071. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73072. * @see https://doc.babylonjs.com/babylon101/sprites
  73073. */
  73074. export class SpritePackedManager extends SpriteManager {
  73075. /** defines the packed manager's name */
  73076. name: string;
  73077. /**
  73078. * Creates a new sprite manager from a packed sprite sheet
  73079. * @param name defines the manager's name
  73080. * @param imgUrl defines the sprite sheet url
  73081. * @param capacity defines the maximum allowed number of sprites
  73082. * @param scene defines the hosting scene
  73083. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73084. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73085. * @param samplingMode defines the smapling mode to use with spritesheet
  73086. * @param fromPacked set to true; do not alter
  73087. */
  73088. constructor(
  73089. /** defines the packed manager's name */
  73090. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73091. }
  73092. }
  73093. declare module BABYLON {
  73094. /**
  73095. * Defines the list of states available for a task inside a AssetsManager
  73096. */
  73097. export enum AssetTaskState {
  73098. /**
  73099. * Initialization
  73100. */
  73101. INIT = 0,
  73102. /**
  73103. * Running
  73104. */
  73105. RUNNING = 1,
  73106. /**
  73107. * Done
  73108. */
  73109. DONE = 2,
  73110. /**
  73111. * Error
  73112. */
  73113. ERROR = 3
  73114. }
  73115. /**
  73116. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73117. */
  73118. export abstract class AbstractAssetTask {
  73119. /**
  73120. * Task name
  73121. */ name: string;
  73122. /**
  73123. * Callback called when the task is successful
  73124. */
  73125. onSuccess: (task: any) => void;
  73126. /**
  73127. * Callback called when the task is not successful
  73128. */
  73129. onError: (task: any, message?: string, exception?: any) => void;
  73130. /**
  73131. * Creates a new AssetsManager
  73132. * @param name defines the name of the task
  73133. */
  73134. constructor(
  73135. /**
  73136. * Task name
  73137. */ name: string);
  73138. private _isCompleted;
  73139. private _taskState;
  73140. private _errorObject;
  73141. /**
  73142. * Get if the task is completed
  73143. */
  73144. get isCompleted(): boolean;
  73145. /**
  73146. * Gets the current state of the task
  73147. */
  73148. get taskState(): AssetTaskState;
  73149. /**
  73150. * Gets the current error object (if task is in error)
  73151. */
  73152. get errorObject(): {
  73153. message?: string;
  73154. exception?: any;
  73155. };
  73156. /**
  73157. * Internal only
  73158. * @hidden
  73159. */
  73160. _setErrorObject(message?: string, exception?: any): void;
  73161. /**
  73162. * Execute the current task
  73163. * @param scene defines the scene where you want your assets to be loaded
  73164. * @param onSuccess is a callback called when the task is successfully executed
  73165. * @param onError is a callback called if an error occurs
  73166. */
  73167. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73168. /**
  73169. * Execute the current task
  73170. * @param scene defines the scene where you want your assets to be loaded
  73171. * @param onSuccess is a callback called when the task is successfully executed
  73172. * @param onError is a callback called if an error occurs
  73173. */
  73174. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73175. /**
  73176. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73177. * This can be used with failed tasks that have the reason for failure fixed.
  73178. */
  73179. reset(): void;
  73180. private onErrorCallback;
  73181. private onDoneCallback;
  73182. }
  73183. /**
  73184. * Define the interface used by progress events raised during assets loading
  73185. */
  73186. export interface IAssetsProgressEvent {
  73187. /**
  73188. * Defines the number of remaining tasks to process
  73189. */
  73190. remainingCount: number;
  73191. /**
  73192. * Defines the total number of tasks
  73193. */
  73194. totalCount: number;
  73195. /**
  73196. * Defines the task that was just processed
  73197. */
  73198. task: AbstractAssetTask;
  73199. }
  73200. /**
  73201. * Class used to share progress information about assets loading
  73202. */
  73203. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73204. /**
  73205. * Defines the number of remaining tasks to process
  73206. */
  73207. remainingCount: number;
  73208. /**
  73209. * Defines the total number of tasks
  73210. */
  73211. totalCount: number;
  73212. /**
  73213. * Defines the task that was just processed
  73214. */
  73215. task: AbstractAssetTask;
  73216. /**
  73217. * Creates a AssetsProgressEvent
  73218. * @param remainingCount defines the number of remaining tasks to process
  73219. * @param totalCount defines the total number of tasks
  73220. * @param task defines the task that was just processed
  73221. */
  73222. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73223. }
  73224. /**
  73225. * Define a task used by AssetsManager to load assets into a container
  73226. */
  73227. export class ContainerAssetTask extends AbstractAssetTask {
  73228. /**
  73229. * Defines the name of the task
  73230. */
  73231. name: string;
  73232. /**
  73233. * Defines the list of mesh's names you want to load
  73234. */
  73235. meshesNames: any;
  73236. /**
  73237. * Defines the root url to use as a base to load your meshes and associated resources
  73238. */
  73239. rootUrl: string;
  73240. /**
  73241. * Defines the filename or File of the scene to load from
  73242. */
  73243. sceneFilename: string | File;
  73244. /**
  73245. * Get the loaded asset container
  73246. */
  73247. loadedContainer: AssetContainer;
  73248. /**
  73249. * Gets the list of loaded meshes
  73250. */
  73251. loadedMeshes: Array<AbstractMesh>;
  73252. /**
  73253. * Gets the list of loaded particle systems
  73254. */
  73255. loadedParticleSystems: Array<IParticleSystem>;
  73256. /**
  73257. * Gets the list of loaded skeletons
  73258. */
  73259. loadedSkeletons: Array<Skeleton>;
  73260. /**
  73261. * Gets the list of loaded animation groups
  73262. */
  73263. loadedAnimationGroups: Array<AnimationGroup>;
  73264. /**
  73265. * Callback called when the task is successful
  73266. */
  73267. onSuccess: (task: ContainerAssetTask) => void;
  73268. /**
  73269. * Callback called when the task is successful
  73270. */
  73271. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73272. /**
  73273. * Creates a new ContainerAssetTask
  73274. * @param name defines the name of the task
  73275. * @param meshesNames defines the list of mesh's names you want to load
  73276. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73277. * @param sceneFilename defines the filename or File of the scene to load from
  73278. */
  73279. constructor(
  73280. /**
  73281. * Defines the name of the task
  73282. */
  73283. name: string,
  73284. /**
  73285. * Defines the list of mesh's names you want to load
  73286. */
  73287. meshesNames: any,
  73288. /**
  73289. * Defines the root url to use as a base to load your meshes and associated resources
  73290. */
  73291. rootUrl: string,
  73292. /**
  73293. * Defines the filename or File of the scene to load from
  73294. */
  73295. sceneFilename: string | File);
  73296. /**
  73297. * Execute the current task
  73298. * @param scene defines the scene where you want your assets to be loaded
  73299. * @param onSuccess is a callback called when the task is successfully executed
  73300. * @param onError is a callback called if an error occurs
  73301. */
  73302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73303. }
  73304. /**
  73305. * Define a task used by AssetsManager to load meshes
  73306. */
  73307. export class MeshAssetTask extends AbstractAssetTask {
  73308. /**
  73309. * Defines the name of the task
  73310. */
  73311. name: string;
  73312. /**
  73313. * Defines the list of mesh's names you want to load
  73314. */
  73315. meshesNames: any;
  73316. /**
  73317. * Defines the root url to use as a base to load your meshes and associated resources
  73318. */
  73319. rootUrl: string;
  73320. /**
  73321. * Defines the filename or File of the scene to load from
  73322. */
  73323. sceneFilename: string | File;
  73324. /**
  73325. * Gets the list of loaded meshes
  73326. */
  73327. loadedMeshes: Array<AbstractMesh>;
  73328. /**
  73329. * Gets the list of loaded particle systems
  73330. */
  73331. loadedParticleSystems: Array<IParticleSystem>;
  73332. /**
  73333. * Gets the list of loaded skeletons
  73334. */
  73335. loadedSkeletons: Array<Skeleton>;
  73336. /**
  73337. * Gets the list of loaded animation groups
  73338. */
  73339. loadedAnimationGroups: Array<AnimationGroup>;
  73340. /**
  73341. * Callback called when the task is successful
  73342. */
  73343. onSuccess: (task: MeshAssetTask) => void;
  73344. /**
  73345. * Callback called when the task is successful
  73346. */
  73347. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73348. /**
  73349. * Creates a new MeshAssetTask
  73350. * @param name defines the name of the task
  73351. * @param meshesNames defines the list of mesh's names you want to load
  73352. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73353. * @param sceneFilename defines the filename or File of the scene to load from
  73354. */
  73355. constructor(
  73356. /**
  73357. * Defines the name of the task
  73358. */
  73359. name: string,
  73360. /**
  73361. * Defines the list of mesh's names you want to load
  73362. */
  73363. meshesNames: any,
  73364. /**
  73365. * Defines the root url to use as a base to load your meshes and associated resources
  73366. */
  73367. rootUrl: string,
  73368. /**
  73369. * Defines the filename or File of the scene to load from
  73370. */
  73371. sceneFilename: string | File);
  73372. /**
  73373. * Execute the current task
  73374. * @param scene defines the scene where you want your assets to be loaded
  73375. * @param onSuccess is a callback called when the task is successfully executed
  73376. * @param onError is a callback called if an error occurs
  73377. */
  73378. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73379. }
  73380. /**
  73381. * Define a task used by AssetsManager to load text content
  73382. */
  73383. export class TextFileAssetTask extends AbstractAssetTask {
  73384. /**
  73385. * Defines the name of the task
  73386. */
  73387. name: string;
  73388. /**
  73389. * Defines the location of the file to load
  73390. */
  73391. url: string;
  73392. /**
  73393. * Gets the loaded text string
  73394. */
  73395. text: string;
  73396. /**
  73397. * Callback called when the task is successful
  73398. */
  73399. onSuccess: (task: TextFileAssetTask) => void;
  73400. /**
  73401. * Callback called when the task is successful
  73402. */
  73403. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73404. /**
  73405. * Creates a new TextFileAssetTask object
  73406. * @param name defines the name of the task
  73407. * @param url defines the location of the file to load
  73408. */
  73409. constructor(
  73410. /**
  73411. * Defines the name of the task
  73412. */
  73413. name: string,
  73414. /**
  73415. * Defines the location of the file to load
  73416. */
  73417. url: string);
  73418. /**
  73419. * Execute the current task
  73420. * @param scene defines the scene where you want your assets to be loaded
  73421. * @param onSuccess is a callback called when the task is successfully executed
  73422. * @param onError is a callback called if an error occurs
  73423. */
  73424. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73425. }
  73426. /**
  73427. * Define a task used by AssetsManager to load binary data
  73428. */
  73429. export class BinaryFileAssetTask extends AbstractAssetTask {
  73430. /**
  73431. * Defines the name of the task
  73432. */
  73433. name: string;
  73434. /**
  73435. * Defines the location of the file to load
  73436. */
  73437. url: string;
  73438. /**
  73439. * Gets the lodaded data (as an array buffer)
  73440. */
  73441. data: ArrayBuffer;
  73442. /**
  73443. * Callback called when the task is successful
  73444. */
  73445. onSuccess: (task: BinaryFileAssetTask) => void;
  73446. /**
  73447. * Callback called when the task is successful
  73448. */
  73449. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73450. /**
  73451. * Creates a new BinaryFileAssetTask object
  73452. * @param name defines the name of the new task
  73453. * @param url defines the location of the file to load
  73454. */
  73455. constructor(
  73456. /**
  73457. * Defines the name of the task
  73458. */
  73459. name: string,
  73460. /**
  73461. * Defines the location of the file to load
  73462. */
  73463. url: string);
  73464. /**
  73465. * Execute the current task
  73466. * @param scene defines the scene where you want your assets to be loaded
  73467. * @param onSuccess is a callback called when the task is successfully executed
  73468. * @param onError is a callback called if an error occurs
  73469. */
  73470. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73471. }
  73472. /**
  73473. * Define a task used by AssetsManager to load images
  73474. */
  73475. export class ImageAssetTask extends AbstractAssetTask {
  73476. /**
  73477. * Defines the name of the task
  73478. */
  73479. name: string;
  73480. /**
  73481. * Defines the location of the image to load
  73482. */
  73483. url: string;
  73484. /**
  73485. * Gets the loaded images
  73486. */
  73487. image: HTMLImageElement;
  73488. /**
  73489. * Callback called when the task is successful
  73490. */
  73491. onSuccess: (task: ImageAssetTask) => void;
  73492. /**
  73493. * Callback called when the task is successful
  73494. */
  73495. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73496. /**
  73497. * Creates a new ImageAssetTask
  73498. * @param name defines the name of the task
  73499. * @param url defines the location of the image to load
  73500. */
  73501. constructor(
  73502. /**
  73503. * Defines the name of the task
  73504. */
  73505. name: string,
  73506. /**
  73507. * Defines the location of the image to load
  73508. */
  73509. url: string);
  73510. /**
  73511. * Execute the current task
  73512. * @param scene defines the scene where you want your assets to be loaded
  73513. * @param onSuccess is a callback called when the task is successfully executed
  73514. * @param onError is a callback called if an error occurs
  73515. */
  73516. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73517. }
  73518. /**
  73519. * Defines the interface used by texture loading tasks
  73520. */
  73521. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73522. /**
  73523. * Gets the loaded texture
  73524. */
  73525. texture: TEX;
  73526. }
  73527. /**
  73528. * Define a task used by AssetsManager to load 2D textures
  73529. */
  73530. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73531. /**
  73532. * Defines the name of the task
  73533. */
  73534. name: string;
  73535. /**
  73536. * Defines the location of the file to load
  73537. */
  73538. url: string;
  73539. /**
  73540. * Defines if mipmap should not be generated (default is false)
  73541. */
  73542. noMipmap?: boolean | undefined;
  73543. /**
  73544. * Defines if texture must be inverted on Y axis (default is true)
  73545. */
  73546. invertY: boolean;
  73547. /**
  73548. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73549. */
  73550. samplingMode: number;
  73551. /**
  73552. * Gets the loaded texture
  73553. */
  73554. texture: Texture;
  73555. /**
  73556. * Callback called when the task is successful
  73557. */
  73558. onSuccess: (task: TextureAssetTask) => void;
  73559. /**
  73560. * Callback called when the task is successful
  73561. */
  73562. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73563. /**
  73564. * Creates a new TextureAssetTask object
  73565. * @param name defines the name of the task
  73566. * @param url defines the location of the file to load
  73567. * @param noMipmap defines if mipmap should not be generated (default is false)
  73568. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73569. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73570. */
  73571. constructor(
  73572. /**
  73573. * Defines the name of the task
  73574. */
  73575. name: string,
  73576. /**
  73577. * Defines the location of the file to load
  73578. */
  73579. url: string,
  73580. /**
  73581. * Defines if mipmap should not be generated (default is false)
  73582. */
  73583. noMipmap?: boolean | undefined,
  73584. /**
  73585. * Defines if texture must be inverted on Y axis (default is true)
  73586. */
  73587. invertY?: boolean,
  73588. /**
  73589. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73590. */
  73591. samplingMode?: number);
  73592. /**
  73593. * Execute the current task
  73594. * @param scene defines the scene where you want your assets to be loaded
  73595. * @param onSuccess is a callback called when the task is successfully executed
  73596. * @param onError is a callback called if an error occurs
  73597. */
  73598. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73599. }
  73600. /**
  73601. * Define a task used by AssetsManager to load cube textures
  73602. */
  73603. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73604. /**
  73605. * Defines the name of the task
  73606. */
  73607. name: string;
  73608. /**
  73609. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73610. */
  73611. url: string;
  73612. /**
  73613. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73614. */
  73615. extensions?: string[] | undefined;
  73616. /**
  73617. * Defines if mipmaps should not be generated (default is false)
  73618. */
  73619. noMipmap?: boolean | undefined;
  73620. /**
  73621. * Defines the explicit list of files (undefined by default)
  73622. */
  73623. files?: string[] | undefined;
  73624. /**
  73625. * Gets the loaded texture
  73626. */
  73627. texture: CubeTexture;
  73628. /**
  73629. * Callback called when the task is successful
  73630. */
  73631. onSuccess: (task: CubeTextureAssetTask) => void;
  73632. /**
  73633. * Callback called when the task is successful
  73634. */
  73635. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73636. /**
  73637. * Creates a new CubeTextureAssetTask
  73638. * @param name defines the name of the task
  73639. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73640. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73641. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73642. * @param files defines the explicit list of files (undefined by default)
  73643. */
  73644. constructor(
  73645. /**
  73646. * Defines the name of the task
  73647. */
  73648. name: string,
  73649. /**
  73650. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73651. */
  73652. url: string,
  73653. /**
  73654. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73655. */
  73656. extensions?: string[] | undefined,
  73657. /**
  73658. * Defines if mipmaps should not be generated (default is false)
  73659. */
  73660. noMipmap?: boolean | undefined,
  73661. /**
  73662. * Defines the explicit list of files (undefined by default)
  73663. */
  73664. files?: string[] | undefined);
  73665. /**
  73666. * Execute the current task
  73667. * @param scene defines the scene where you want your assets to be loaded
  73668. * @param onSuccess is a callback called when the task is successfully executed
  73669. * @param onError is a callback called if an error occurs
  73670. */
  73671. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73672. }
  73673. /**
  73674. * Define a task used by AssetsManager to load HDR cube textures
  73675. */
  73676. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73677. /**
  73678. * Defines the name of the task
  73679. */
  73680. name: string;
  73681. /**
  73682. * Defines the location of the file to load
  73683. */
  73684. url: string;
  73685. /**
  73686. * Defines the desired size (the more it increases the longer the generation will be)
  73687. */
  73688. size: number;
  73689. /**
  73690. * Defines if mipmaps should not be generated (default is false)
  73691. */
  73692. noMipmap: boolean;
  73693. /**
  73694. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73695. */
  73696. generateHarmonics: boolean;
  73697. /**
  73698. * 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)
  73699. */
  73700. gammaSpace: boolean;
  73701. /**
  73702. * Internal Use Only
  73703. */
  73704. reserved: boolean;
  73705. /**
  73706. * Gets the loaded texture
  73707. */
  73708. texture: HDRCubeTexture;
  73709. /**
  73710. * Callback called when the task is successful
  73711. */
  73712. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73713. /**
  73714. * Callback called when the task is successful
  73715. */
  73716. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73717. /**
  73718. * Creates a new HDRCubeTextureAssetTask object
  73719. * @param name defines the name of the task
  73720. * @param url defines the location of the file to load
  73721. * @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.
  73722. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73723. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73724. * @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)
  73725. * @param reserved Internal use only
  73726. */
  73727. constructor(
  73728. /**
  73729. * Defines the name of the task
  73730. */
  73731. name: string,
  73732. /**
  73733. * Defines the location of the file to load
  73734. */
  73735. url: string,
  73736. /**
  73737. * Defines the desired size (the more it increases the longer the generation will be)
  73738. */
  73739. size: number,
  73740. /**
  73741. * Defines if mipmaps should not be generated (default is false)
  73742. */
  73743. noMipmap?: boolean,
  73744. /**
  73745. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73746. */
  73747. generateHarmonics?: boolean,
  73748. /**
  73749. * 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)
  73750. */
  73751. gammaSpace?: boolean,
  73752. /**
  73753. * Internal Use Only
  73754. */
  73755. reserved?: boolean);
  73756. /**
  73757. * Execute the current task
  73758. * @param scene defines the scene where you want your assets to be loaded
  73759. * @param onSuccess is a callback called when the task is successfully executed
  73760. * @param onError is a callback called if an error occurs
  73761. */
  73762. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73763. }
  73764. /**
  73765. * Define a task used by AssetsManager to load Equirectangular cube textures
  73766. */
  73767. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73768. /**
  73769. * Defines the name of the task
  73770. */
  73771. name: string;
  73772. /**
  73773. * Defines the location of the file to load
  73774. */
  73775. url: string;
  73776. /**
  73777. * Defines the desired size (the more it increases the longer the generation will be)
  73778. */
  73779. size: number;
  73780. /**
  73781. * Defines if mipmaps should not be generated (default is false)
  73782. */
  73783. noMipmap: boolean;
  73784. /**
  73785. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73786. * but the standard material would require them in Gamma space) (default is true)
  73787. */
  73788. gammaSpace: boolean;
  73789. /**
  73790. * Gets the loaded texture
  73791. */
  73792. texture: EquiRectangularCubeTexture;
  73793. /**
  73794. * Callback called when the task is successful
  73795. */
  73796. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73797. /**
  73798. * Callback called when the task is successful
  73799. */
  73800. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73801. /**
  73802. * Creates a new EquiRectangularCubeTextureAssetTask object
  73803. * @param name defines the name of the task
  73804. * @param url defines the location of the file to load
  73805. * @param size defines the desired size (the more it increases the longer the generation will be)
  73806. * If the size is omitted this implies you are using a preprocessed cubemap.
  73807. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73808. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73809. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73810. * (default is true)
  73811. */
  73812. constructor(
  73813. /**
  73814. * Defines the name of the task
  73815. */
  73816. name: string,
  73817. /**
  73818. * Defines the location of the file to load
  73819. */
  73820. url: string,
  73821. /**
  73822. * Defines the desired size (the more it increases the longer the generation will be)
  73823. */
  73824. size: number,
  73825. /**
  73826. * Defines if mipmaps should not be generated (default is false)
  73827. */
  73828. noMipmap?: boolean,
  73829. /**
  73830. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73831. * but the standard material would require them in Gamma space) (default is true)
  73832. */
  73833. gammaSpace?: boolean);
  73834. /**
  73835. * Execute the current task
  73836. * @param scene defines the scene where you want your assets to be loaded
  73837. * @param onSuccess is a callback called when the task is successfully executed
  73838. * @param onError is a callback called if an error occurs
  73839. */
  73840. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73841. }
  73842. /**
  73843. * This class can be used to easily import assets into a scene
  73844. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73845. */
  73846. export class AssetsManager {
  73847. private _scene;
  73848. private _isLoading;
  73849. protected _tasks: AbstractAssetTask[];
  73850. protected _waitingTasksCount: number;
  73851. protected _totalTasksCount: number;
  73852. /**
  73853. * Callback called when all tasks are processed
  73854. */
  73855. onFinish: (tasks: AbstractAssetTask[]) => void;
  73856. /**
  73857. * Callback called when a task is successful
  73858. */
  73859. onTaskSuccess: (task: AbstractAssetTask) => void;
  73860. /**
  73861. * Callback called when a task had an error
  73862. */
  73863. onTaskError: (task: AbstractAssetTask) => void;
  73864. /**
  73865. * Callback called when a task is done (whatever the result is)
  73866. */
  73867. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73868. /**
  73869. * Observable called when all tasks are processed
  73870. */
  73871. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73872. /**
  73873. * Observable called when a task had an error
  73874. */
  73875. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73876. /**
  73877. * Observable called when all tasks were executed
  73878. */
  73879. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73880. /**
  73881. * Observable called when a task is done (whatever the result is)
  73882. */
  73883. onProgressObservable: Observable<IAssetsProgressEvent>;
  73884. /**
  73885. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73886. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73887. */
  73888. useDefaultLoadingScreen: boolean;
  73889. /**
  73890. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73891. * when all assets have been downloaded.
  73892. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73893. */
  73894. autoHideLoadingUI: boolean;
  73895. /**
  73896. * Creates a new AssetsManager
  73897. * @param scene defines the scene to work on
  73898. */
  73899. constructor(scene: Scene);
  73900. /**
  73901. * Add a ContainerAssetTask to the list of active tasks
  73902. * @param taskName defines the name of the new task
  73903. * @param meshesNames defines the name of meshes to load
  73904. * @param rootUrl defines the root url to use to locate files
  73905. * @param sceneFilename defines the filename of the scene file
  73906. * @returns a new ContainerAssetTask object
  73907. */
  73908. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73909. /**
  73910. * Add a MeshAssetTask to the list of active tasks
  73911. * @param taskName defines the name of the new task
  73912. * @param meshesNames defines the name of meshes to load
  73913. * @param rootUrl defines the root url to use to locate files
  73914. * @param sceneFilename defines the filename of the scene file
  73915. * @returns a new MeshAssetTask object
  73916. */
  73917. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73918. /**
  73919. * Add a TextFileAssetTask to the list of active tasks
  73920. * @param taskName defines the name of the new task
  73921. * @param url defines the url of the file to load
  73922. * @returns a new TextFileAssetTask object
  73923. */
  73924. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73925. /**
  73926. * Add a BinaryFileAssetTask to the list of active tasks
  73927. * @param taskName defines the name of the new task
  73928. * @param url defines the url of the file to load
  73929. * @returns a new BinaryFileAssetTask object
  73930. */
  73931. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73932. /**
  73933. * Add a ImageAssetTask to the list of active tasks
  73934. * @param taskName defines the name of the new task
  73935. * @param url defines the url of the file to load
  73936. * @returns a new ImageAssetTask object
  73937. */
  73938. addImageTask(taskName: string, url: string): ImageAssetTask;
  73939. /**
  73940. * Add a TextureAssetTask to the list of active tasks
  73941. * @param taskName defines the name of the new task
  73942. * @param url defines the url of the file to load
  73943. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73944. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73945. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73946. * @returns a new TextureAssetTask object
  73947. */
  73948. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73949. /**
  73950. * Add a CubeTextureAssetTask to the list of active tasks
  73951. * @param taskName defines the name of the new task
  73952. * @param url defines the url of the file to load
  73953. * @param extensions defines the extension to use to load the cube map (can be null)
  73954. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73955. * @param files defines the list of files to load (can be null)
  73956. * @returns a new CubeTextureAssetTask object
  73957. */
  73958. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73959. /**
  73960. *
  73961. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73962. * @param taskName defines the name of the new task
  73963. * @param url defines the url of the file to load
  73964. * @param size defines the size you want for the cubemap (can be null)
  73965. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73966. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73967. * @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)
  73968. * @param reserved Internal use only
  73969. * @returns a new HDRCubeTextureAssetTask object
  73970. */
  73971. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73972. /**
  73973. *
  73974. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73975. * @param taskName defines the name of the new task
  73976. * @param url defines the url of the file to load
  73977. * @param size defines the size you want for the cubemap (can be null)
  73978. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73979. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73980. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73981. * @returns a new EquiRectangularCubeTextureAssetTask object
  73982. */
  73983. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73984. /**
  73985. * Remove a task from the assets manager.
  73986. * @param task the task to remove
  73987. */
  73988. removeTask(task: AbstractAssetTask): void;
  73989. private _decreaseWaitingTasksCount;
  73990. private _runTask;
  73991. /**
  73992. * Reset the AssetsManager and remove all tasks
  73993. * @return the current instance of the AssetsManager
  73994. */
  73995. reset(): AssetsManager;
  73996. /**
  73997. * Start the loading process
  73998. * @return the current instance of the AssetsManager
  73999. */
  74000. load(): AssetsManager;
  74001. /**
  74002. * Start the loading process as an async operation
  74003. * @return a promise returning the list of failed tasks
  74004. */
  74005. loadAsync(): Promise<void>;
  74006. }
  74007. }
  74008. declare module BABYLON {
  74009. /**
  74010. * Wrapper class for promise with external resolve and reject.
  74011. */
  74012. export class Deferred<T> {
  74013. /**
  74014. * The promise associated with this deferred object.
  74015. */
  74016. readonly promise: Promise<T>;
  74017. private _resolve;
  74018. private _reject;
  74019. /**
  74020. * The resolve method of the promise associated with this deferred object.
  74021. */
  74022. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74023. /**
  74024. * The reject method of the promise associated with this deferred object.
  74025. */
  74026. get reject(): (reason?: any) => void;
  74027. /**
  74028. * Constructor for this deferred object.
  74029. */
  74030. constructor();
  74031. }
  74032. }
  74033. declare module BABYLON {
  74034. /**
  74035. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74036. */
  74037. export class MeshExploder {
  74038. private _centerMesh;
  74039. private _meshes;
  74040. private _meshesOrigins;
  74041. private _toCenterVectors;
  74042. private _scaledDirection;
  74043. private _newPosition;
  74044. private _centerPosition;
  74045. /**
  74046. * Explodes meshes from a center mesh.
  74047. * @param meshes The meshes to explode.
  74048. * @param centerMesh The mesh to be center of explosion.
  74049. */
  74050. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74051. private _setCenterMesh;
  74052. /**
  74053. * Get class name
  74054. * @returns "MeshExploder"
  74055. */
  74056. getClassName(): string;
  74057. /**
  74058. * "Exploded meshes"
  74059. * @returns Array of meshes with the centerMesh at index 0.
  74060. */
  74061. getMeshes(): Array<Mesh>;
  74062. /**
  74063. * Explodes meshes giving a specific direction
  74064. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74065. */
  74066. explode(direction?: number): void;
  74067. }
  74068. }
  74069. declare module BABYLON {
  74070. /**
  74071. * Class used to help managing file picking and drag'n'drop
  74072. */
  74073. export class FilesInput {
  74074. /**
  74075. * List of files ready to be loaded
  74076. */
  74077. static get FilesToLoad(): {
  74078. [key: string]: File;
  74079. };
  74080. /**
  74081. * Callback called when a file is processed
  74082. */
  74083. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74084. private _engine;
  74085. private _currentScene;
  74086. private _sceneLoadedCallback;
  74087. private _progressCallback;
  74088. private _additionalRenderLoopLogicCallback;
  74089. private _textureLoadingCallback;
  74090. private _startingProcessingFilesCallback;
  74091. private _onReloadCallback;
  74092. private _errorCallback;
  74093. private _elementToMonitor;
  74094. private _sceneFileToLoad;
  74095. private _filesToLoad;
  74096. /**
  74097. * Creates a new FilesInput
  74098. * @param engine defines the rendering engine
  74099. * @param scene defines the hosting scene
  74100. * @param sceneLoadedCallback callback called when scene is loaded
  74101. * @param progressCallback callback called to track progress
  74102. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74103. * @param textureLoadingCallback callback called when a texture is loading
  74104. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74105. * @param onReloadCallback callback called when a reload is requested
  74106. * @param errorCallback callback call if an error occurs
  74107. */
  74108. 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>);
  74109. private _dragEnterHandler;
  74110. private _dragOverHandler;
  74111. private _dropHandler;
  74112. /**
  74113. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74114. * @param elementToMonitor defines the DOM element to track
  74115. */
  74116. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74117. /** Gets the current list of files to load */
  74118. get filesToLoad(): File[];
  74119. /**
  74120. * Release all associated resources
  74121. */
  74122. dispose(): void;
  74123. private renderFunction;
  74124. private drag;
  74125. private drop;
  74126. private _traverseFolder;
  74127. private _processFiles;
  74128. /**
  74129. * Load files from a drop event
  74130. * @param event defines the drop event to use as source
  74131. */
  74132. loadFiles(event: any): void;
  74133. private _processReload;
  74134. /**
  74135. * Reload the current scene from the loaded files
  74136. */
  74137. reload(): void;
  74138. }
  74139. }
  74140. declare module BABYLON {
  74141. /**
  74142. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74143. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74144. */
  74145. export class SceneOptimization {
  74146. /**
  74147. * Defines the priority of this optimization (0 by default which means first in the list)
  74148. */
  74149. priority: number;
  74150. /**
  74151. * Gets a string describing the action executed by the current optimization
  74152. * @returns description string
  74153. */
  74154. getDescription(): string;
  74155. /**
  74156. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74157. * @param scene defines the current scene where to apply this optimization
  74158. * @param optimizer defines the current optimizer
  74159. * @returns true if everything that can be done was applied
  74160. */
  74161. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74162. /**
  74163. * Creates the SceneOptimization object
  74164. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74165. * @param desc defines the description associated with the optimization
  74166. */
  74167. constructor(
  74168. /**
  74169. * Defines the priority of this optimization (0 by default which means first in the list)
  74170. */
  74171. priority?: number);
  74172. }
  74173. /**
  74174. * Defines an optimization used to reduce the size of render target textures
  74175. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74176. */
  74177. export class TextureOptimization extends SceneOptimization {
  74178. /**
  74179. * Defines the priority of this optimization (0 by default which means first in the list)
  74180. */
  74181. priority: number;
  74182. /**
  74183. * 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
  74184. */
  74185. maximumSize: number;
  74186. /**
  74187. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74188. */
  74189. step: number;
  74190. /**
  74191. * Gets a string describing the action executed by the current optimization
  74192. * @returns description string
  74193. */
  74194. getDescription(): string;
  74195. /**
  74196. * Creates the TextureOptimization object
  74197. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74198. * @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
  74199. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74200. */
  74201. constructor(
  74202. /**
  74203. * Defines the priority of this optimization (0 by default which means first in the list)
  74204. */
  74205. priority?: number,
  74206. /**
  74207. * 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
  74208. */
  74209. maximumSize?: number,
  74210. /**
  74211. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74212. */
  74213. step?: number);
  74214. /**
  74215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74216. * @param scene defines the current scene where to apply this optimization
  74217. * @param optimizer defines the current optimizer
  74218. * @returns true if everything that can be done was applied
  74219. */
  74220. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74221. }
  74222. /**
  74223. * Defines an optimization used to increase or decrease the rendering resolution
  74224. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74225. */
  74226. export class HardwareScalingOptimization extends SceneOptimization {
  74227. /**
  74228. * Defines the priority of this optimization (0 by default which means first in the list)
  74229. */
  74230. priority: number;
  74231. /**
  74232. * Defines the maximum scale to use (2 by default)
  74233. */
  74234. maximumScale: number;
  74235. /**
  74236. * Defines the step to use between two passes (0.5 by default)
  74237. */
  74238. step: number;
  74239. private _currentScale;
  74240. private _directionOffset;
  74241. /**
  74242. * Gets a string describing the action executed by the current optimization
  74243. * @return description string
  74244. */
  74245. getDescription(): string;
  74246. /**
  74247. * Creates the HardwareScalingOptimization object
  74248. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74249. * @param maximumScale defines the maximum scale to use (2 by default)
  74250. * @param step defines the step to use between two passes (0.5 by default)
  74251. */
  74252. constructor(
  74253. /**
  74254. * Defines the priority of this optimization (0 by default which means first in the list)
  74255. */
  74256. priority?: number,
  74257. /**
  74258. * Defines the maximum scale to use (2 by default)
  74259. */
  74260. maximumScale?: number,
  74261. /**
  74262. * Defines the step to use between two passes (0.5 by default)
  74263. */
  74264. step?: number);
  74265. /**
  74266. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74267. * @param scene defines the current scene where to apply this optimization
  74268. * @param optimizer defines the current optimizer
  74269. * @returns true if everything that can be done was applied
  74270. */
  74271. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74272. }
  74273. /**
  74274. * Defines an optimization used to remove shadows
  74275. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74276. */
  74277. export class ShadowsOptimization extends SceneOptimization {
  74278. /**
  74279. * Gets a string describing the action executed by the current optimization
  74280. * @return description string
  74281. */
  74282. getDescription(): string;
  74283. /**
  74284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74285. * @param scene defines the current scene where to apply this optimization
  74286. * @param optimizer defines the current optimizer
  74287. * @returns true if everything that can be done was applied
  74288. */
  74289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74290. }
  74291. /**
  74292. * Defines an optimization used to turn post-processes off
  74293. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74294. */
  74295. export class PostProcessesOptimization extends SceneOptimization {
  74296. /**
  74297. * Gets a string describing the action executed by the current optimization
  74298. * @return description string
  74299. */
  74300. getDescription(): string;
  74301. /**
  74302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74303. * @param scene defines the current scene where to apply this optimization
  74304. * @param optimizer defines the current optimizer
  74305. * @returns true if everything that can be done was applied
  74306. */
  74307. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74308. }
  74309. /**
  74310. * Defines an optimization used to turn lens flares off
  74311. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74312. */
  74313. export class LensFlaresOptimization extends SceneOptimization {
  74314. /**
  74315. * Gets a string describing the action executed by the current optimization
  74316. * @return description string
  74317. */
  74318. getDescription(): string;
  74319. /**
  74320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74321. * @param scene defines the current scene where to apply this optimization
  74322. * @param optimizer defines the current optimizer
  74323. * @returns true if everything that can be done was applied
  74324. */
  74325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74326. }
  74327. /**
  74328. * Defines an optimization based on user defined callback.
  74329. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74330. */
  74331. export class CustomOptimization extends SceneOptimization {
  74332. /**
  74333. * Callback called to apply the custom optimization.
  74334. */
  74335. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74336. /**
  74337. * Callback called to get custom description
  74338. */
  74339. onGetDescription: () => string;
  74340. /**
  74341. * Gets a string describing the action executed by the current optimization
  74342. * @returns description string
  74343. */
  74344. getDescription(): string;
  74345. /**
  74346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74347. * @param scene defines the current scene where to apply this optimization
  74348. * @param optimizer defines the current optimizer
  74349. * @returns true if everything that can be done was applied
  74350. */
  74351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74352. }
  74353. /**
  74354. * Defines an optimization used to turn particles off
  74355. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74356. */
  74357. export class ParticlesOptimization extends SceneOptimization {
  74358. /**
  74359. * Gets a string describing the action executed by the current optimization
  74360. * @return description string
  74361. */
  74362. getDescription(): string;
  74363. /**
  74364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74365. * @param scene defines the current scene where to apply this optimization
  74366. * @param optimizer defines the current optimizer
  74367. * @returns true if everything that can be done was applied
  74368. */
  74369. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74370. }
  74371. /**
  74372. * Defines an optimization used to turn render targets off
  74373. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74374. */
  74375. export class RenderTargetsOptimization extends SceneOptimization {
  74376. /**
  74377. * Gets a string describing the action executed by the current optimization
  74378. * @return description string
  74379. */
  74380. getDescription(): string;
  74381. /**
  74382. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74383. * @param scene defines the current scene where to apply this optimization
  74384. * @param optimizer defines the current optimizer
  74385. * @returns true if everything that can be done was applied
  74386. */
  74387. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74388. }
  74389. /**
  74390. * Defines an optimization used to merge meshes with compatible materials
  74391. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74392. */
  74393. export class MergeMeshesOptimization extends SceneOptimization {
  74394. private static _UpdateSelectionTree;
  74395. /**
  74396. * Gets or sets a boolean which defines if optimization octree has to be updated
  74397. */
  74398. static get UpdateSelectionTree(): boolean;
  74399. /**
  74400. * Gets or sets a boolean which defines if optimization octree has to be updated
  74401. */
  74402. static set UpdateSelectionTree(value: boolean);
  74403. /**
  74404. * Gets a string describing the action executed by the current optimization
  74405. * @return description string
  74406. */
  74407. getDescription(): string;
  74408. private _canBeMerged;
  74409. /**
  74410. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74411. * @param scene defines the current scene where to apply this optimization
  74412. * @param optimizer defines the current optimizer
  74413. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74414. * @returns true if everything that can be done was applied
  74415. */
  74416. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74417. }
  74418. /**
  74419. * Defines a list of options used by SceneOptimizer
  74420. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74421. */
  74422. export class SceneOptimizerOptions {
  74423. /**
  74424. * Defines the target frame rate to reach (60 by default)
  74425. */
  74426. targetFrameRate: number;
  74427. /**
  74428. * Defines the interval between two checkes (2000ms by default)
  74429. */
  74430. trackerDuration: number;
  74431. /**
  74432. * Gets the list of optimizations to apply
  74433. */
  74434. optimizations: SceneOptimization[];
  74435. /**
  74436. * Creates a new list of options used by SceneOptimizer
  74437. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74438. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74439. */
  74440. constructor(
  74441. /**
  74442. * Defines the target frame rate to reach (60 by default)
  74443. */
  74444. targetFrameRate?: number,
  74445. /**
  74446. * Defines the interval between two checkes (2000ms by default)
  74447. */
  74448. trackerDuration?: number);
  74449. /**
  74450. * Add a new optimization
  74451. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74452. * @returns the current SceneOptimizerOptions
  74453. */
  74454. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74455. /**
  74456. * Add a new custom optimization
  74457. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74458. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74459. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74460. * @returns the current SceneOptimizerOptions
  74461. */
  74462. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74463. /**
  74464. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74465. * @param targetFrameRate defines the target frame rate (60 by default)
  74466. * @returns a SceneOptimizerOptions object
  74467. */
  74468. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74469. /**
  74470. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74471. * @param targetFrameRate defines the target frame rate (60 by default)
  74472. * @returns a SceneOptimizerOptions object
  74473. */
  74474. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74475. /**
  74476. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74477. * @param targetFrameRate defines the target frame rate (60 by default)
  74478. * @returns a SceneOptimizerOptions object
  74479. */
  74480. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74481. }
  74482. /**
  74483. * Class used to run optimizations in order to reach a target frame rate
  74484. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74485. */
  74486. export class SceneOptimizer implements IDisposable {
  74487. private _isRunning;
  74488. private _options;
  74489. private _scene;
  74490. private _currentPriorityLevel;
  74491. private _targetFrameRate;
  74492. private _trackerDuration;
  74493. private _currentFrameRate;
  74494. private _sceneDisposeObserver;
  74495. private _improvementMode;
  74496. /**
  74497. * Defines an observable called when the optimizer reaches the target frame rate
  74498. */
  74499. onSuccessObservable: Observable<SceneOptimizer>;
  74500. /**
  74501. * Defines an observable called when the optimizer enables an optimization
  74502. */
  74503. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74504. /**
  74505. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74506. */
  74507. onFailureObservable: Observable<SceneOptimizer>;
  74508. /**
  74509. * Gets a boolean indicating if the optimizer is in improvement mode
  74510. */
  74511. get isInImprovementMode(): boolean;
  74512. /**
  74513. * Gets the current priority level (0 at start)
  74514. */
  74515. get currentPriorityLevel(): number;
  74516. /**
  74517. * Gets the current frame rate checked by the SceneOptimizer
  74518. */
  74519. get currentFrameRate(): number;
  74520. /**
  74521. * Gets or sets the current target frame rate (60 by default)
  74522. */
  74523. get targetFrameRate(): number;
  74524. /**
  74525. * Gets or sets the current target frame rate (60 by default)
  74526. */
  74527. set targetFrameRate(value: number);
  74528. /**
  74529. * Gets or sets the current interval between two checks (every 2000ms by default)
  74530. */
  74531. get trackerDuration(): number;
  74532. /**
  74533. * Gets or sets the current interval between two checks (every 2000ms by default)
  74534. */
  74535. set trackerDuration(value: number);
  74536. /**
  74537. * Gets the list of active optimizations
  74538. */
  74539. get optimizations(): SceneOptimization[];
  74540. /**
  74541. * Creates a new SceneOptimizer
  74542. * @param scene defines the scene to work on
  74543. * @param options defines the options to use with the SceneOptimizer
  74544. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74545. * @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)
  74546. */
  74547. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74548. /**
  74549. * Stops the current optimizer
  74550. */
  74551. stop(): void;
  74552. /**
  74553. * Reset the optimizer to initial step (current priority level = 0)
  74554. */
  74555. reset(): void;
  74556. /**
  74557. * Start the optimizer. By default it will try to reach a specific framerate
  74558. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74559. */
  74560. start(): void;
  74561. private _checkCurrentState;
  74562. /**
  74563. * Release all resources
  74564. */
  74565. dispose(): void;
  74566. /**
  74567. * Helper function to create a SceneOptimizer with one single line of code
  74568. * @param scene defines the scene to work on
  74569. * @param options defines the options to use with the SceneOptimizer
  74570. * @param onSuccess defines a callback to call on success
  74571. * @param onFailure defines a callback to call on failure
  74572. * @returns the new SceneOptimizer object
  74573. */
  74574. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74575. }
  74576. }
  74577. declare module BABYLON {
  74578. /**
  74579. * Class used to serialize a scene into a string
  74580. */
  74581. export class SceneSerializer {
  74582. /**
  74583. * Clear cache used by a previous serialization
  74584. */
  74585. static ClearCache(): void;
  74586. /**
  74587. * Serialize a scene into a JSON compatible object
  74588. * @param scene defines the scene to serialize
  74589. * @returns a JSON compatible object
  74590. */
  74591. static Serialize(scene: Scene): any;
  74592. /**
  74593. * Serialize a mesh into a JSON compatible object
  74594. * @param toSerialize defines the mesh to serialize
  74595. * @param withParents defines if parents must be serialized as well
  74596. * @param withChildren defines if children must be serialized as well
  74597. * @returns a JSON compatible object
  74598. */
  74599. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74600. }
  74601. }
  74602. declare module BABYLON {
  74603. /**
  74604. * Class used to host texture specific utilities
  74605. */
  74606. export class TextureTools {
  74607. /**
  74608. * Uses the GPU to create a copy texture rescaled at a given size
  74609. * @param texture Texture to copy from
  74610. * @param width defines the desired width
  74611. * @param height defines the desired height
  74612. * @param useBilinearMode defines if bilinear mode has to be used
  74613. * @return the generated texture
  74614. */
  74615. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74616. }
  74617. }
  74618. declare module BABYLON {
  74619. /**
  74620. * This represents the different options available for the video capture.
  74621. */
  74622. export interface VideoRecorderOptions {
  74623. /** Defines the mime type of the video. */
  74624. mimeType: string;
  74625. /** Defines the FPS the video should be recorded at. */
  74626. fps: number;
  74627. /** Defines the chunk size for the recording data. */
  74628. recordChunckSize: number;
  74629. /** The audio tracks to attach to the recording. */
  74630. audioTracks?: MediaStreamTrack[];
  74631. }
  74632. /**
  74633. * This can help with recording videos from BabylonJS.
  74634. * This is based on the available WebRTC functionalities of the browser.
  74635. *
  74636. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74637. */
  74638. export class VideoRecorder {
  74639. private static readonly _defaultOptions;
  74640. /**
  74641. * Returns whether or not the VideoRecorder is available in your browser.
  74642. * @param engine Defines the Babylon Engine.
  74643. * @returns true if supported otherwise false.
  74644. */
  74645. static IsSupported(engine: Engine): boolean;
  74646. private readonly _options;
  74647. private _canvas;
  74648. private _mediaRecorder;
  74649. private _recordedChunks;
  74650. private _fileName;
  74651. private _resolve;
  74652. private _reject;
  74653. /**
  74654. * True when a recording is already in progress.
  74655. */
  74656. get isRecording(): boolean;
  74657. /**
  74658. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74659. * @param engine Defines the BabylonJS Engine you wish to record.
  74660. * @param options Defines options that can be used to customize the capture.
  74661. */
  74662. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74663. /**
  74664. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74665. */
  74666. stopRecording(): void;
  74667. /**
  74668. * Starts recording the canvas for a max duration specified in parameters.
  74669. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74670. * If null no automatic download will start and you can rely on the promise to get the data back.
  74671. * @param maxDuration Defines the maximum recording time in seconds.
  74672. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74673. * @return A promise callback at the end of the recording with the video data in Blob.
  74674. */
  74675. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74676. /**
  74677. * Releases internal resources used during the recording.
  74678. */
  74679. dispose(): void;
  74680. private _handleDataAvailable;
  74681. private _handleError;
  74682. private _handleStop;
  74683. }
  74684. }
  74685. declare module BABYLON {
  74686. /**
  74687. * Class containing a set of static utilities functions for screenshots
  74688. */
  74689. export class ScreenshotTools {
  74690. /**
  74691. * Captures a screenshot of the current rendering
  74692. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74693. * @param engine defines the rendering engine
  74694. * @param camera defines the source camera
  74695. * @param size This parameter can be set to a single number or to an object with the
  74696. * following (optional) properties: precision, width, height. If a single number is passed,
  74697. * it will be used for both width and height. If an object is passed, the screenshot size
  74698. * will be derived from the parameters. The precision property is a multiplier allowing
  74699. * rendering at a higher or lower resolution
  74700. * @param successCallback defines the callback receives a single parameter which contains the
  74701. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74702. * src parameter of an <img> to display it
  74703. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74704. * Check your browser for supported MIME types
  74705. */
  74706. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74707. /**
  74708. * Captures a screenshot of the current rendering
  74709. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74710. * @param engine defines the rendering engine
  74711. * @param camera defines the source camera
  74712. * @param size This parameter can be set to a single number or to an object with the
  74713. * following (optional) properties: precision, width, height. If a single number is passed,
  74714. * it will be used for both width and height. If an object is passed, the screenshot size
  74715. * will be derived from the parameters. The precision property is a multiplier allowing
  74716. * rendering at a higher or lower resolution
  74717. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74718. * Check your browser for supported MIME types
  74719. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74720. * to the src parameter of an <img> to display it
  74721. */
  74722. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74723. /**
  74724. * Generates an image screenshot from the specified camera.
  74725. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74726. * @param engine The engine to use for rendering
  74727. * @param camera The camera to use for rendering
  74728. * @param size This parameter can be set to a single number or to an object with the
  74729. * following (optional) properties: precision, width, height. If a single number is passed,
  74730. * it will be used for both width and height. If an object is passed, the screenshot size
  74731. * will be derived from the parameters. The precision property is a multiplier allowing
  74732. * rendering at a higher or lower resolution
  74733. * @param successCallback The callback receives a single parameter which contains the
  74734. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74735. * src parameter of an <img> to display it
  74736. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74737. * Check your browser for supported MIME types
  74738. * @param samples Texture samples (default: 1)
  74739. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74740. * @param fileName A name for for the downloaded file.
  74741. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74742. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74743. */
  74744. 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;
  74745. /**
  74746. * Generates an image screenshot from the specified camera.
  74747. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74748. * @param engine The engine to use for rendering
  74749. * @param camera The camera to use for rendering
  74750. * @param size This parameter can be set to a single number or to an object with the
  74751. * following (optional) properties: precision, width, height. If a single number is passed,
  74752. * it will be used for both width and height. If an object is passed, the screenshot size
  74753. * will be derived from the parameters. The precision property is a multiplier allowing
  74754. * rendering at a higher or lower resolution
  74755. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74756. * Check your browser for supported MIME types
  74757. * @param samples Texture samples (default: 1)
  74758. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74759. * @param fileName A name for for the downloaded file.
  74760. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74761. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74762. * to the src parameter of an <img> to display it
  74763. */
  74764. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74765. /**
  74766. * Gets height and width for screenshot size
  74767. * @private
  74768. */
  74769. private static _getScreenshotSize;
  74770. }
  74771. }
  74772. declare module BABYLON {
  74773. /**
  74774. * Interface for a data buffer
  74775. */
  74776. export interface IDataBuffer {
  74777. /**
  74778. * Reads bytes from the data buffer.
  74779. * @param byteOffset The byte offset to read
  74780. * @param byteLength The byte length to read
  74781. * @returns A promise that resolves when the bytes are read
  74782. */
  74783. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74784. /**
  74785. * The byte length of the buffer.
  74786. */
  74787. readonly byteLength: number;
  74788. }
  74789. /**
  74790. * Utility class for reading from a data buffer
  74791. */
  74792. export class DataReader {
  74793. /**
  74794. * The data buffer associated with this data reader.
  74795. */
  74796. readonly buffer: IDataBuffer;
  74797. /**
  74798. * The current byte offset from the beginning of the data buffer.
  74799. */
  74800. byteOffset: number;
  74801. private _dataView;
  74802. private _dataByteOffset;
  74803. /**
  74804. * Constructor
  74805. * @param buffer The buffer to read
  74806. */
  74807. constructor(buffer: IDataBuffer);
  74808. /**
  74809. * Loads the given byte length.
  74810. * @param byteLength The byte length to load
  74811. * @returns A promise that resolves when the load is complete
  74812. */
  74813. loadAsync(byteLength: number): Promise<void>;
  74814. /**
  74815. * Read a unsigned 32-bit integer from the currently loaded data range.
  74816. * @returns The 32-bit integer read
  74817. */
  74818. readUint32(): number;
  74819. /**
  74820. * Read a byte array from the currently loaded data range.
  74821. * @param byteLength The byte length to read
  74822. * @returns The byte array read
  74823. */
  74824. readUint8Array(byteLength: number): Uint8Array;
  74825. /**
  74826. * Read a string from the currently loaded data range.
  74827. * @param byteLength The byte length to read
  74828. * @returns The string read
  74829. */
  74830. readString(byteLength: number): string;
  74831. /**
  74832. * Skips the given byte length the currently loaded data range.
  74833. * @param byteLength The byte length to skip
  74834. */
  74835. skipBytes(byteLength: number): void;
  74836. }
  74837. }
  74838. declare module BABYLON {
  74839. /**
  74840. * Class for storing data to local storage if available or in-memory storage otherwise
  74841. */
  74842. export class DataStorage {
  74843. private static _Storage;
  74844. private static _GetStorage;
  74845. /**
  74846. * Reads a string from the data storage
  74847. * @param key The key to read
  74848. * @param defaultValue The value if the key doesn't exist
  74849. * @returns The string value
  74850. */
  74851. static ReadString(key: string, defaultValue: string): string;
  74852. /**
  74853. * Writes a string to the data storage
  74854. * @param key The key to write
  74855. * @param value The value to write
  74856. */
  74857. static WriteString(key: string, value: string): void;
  74858. /**
  74859. * Reads a boolean from the data storage
  74860. * @param key The key to read
  74861. * @param defaultValue The value if the key doesn't exist
  74862. * @returns The boolean value
  74863. */
  74864. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74865. /**
  74866. * Writes a boolean to the data storage
  74867. * @param key The key to write
  74868. * @param value The value to write
  74869. */
  74870. static WriteBoolean(key: string, value: boolean): void;
  74871. /**
  74872. * Reads a number from the data storage
  74873. * @param key The key to read
  74874. * @param defaultValue The value if the key doesn't exist
  74875. * @returns The number value
  74876. */
  74877. static ReadNumber(key: string, defaultValue: number): number;
  74878. /**
  74879. * Writes a number to the data storage
  74880. * @param key The key to write
  74881. * @param value The value to write
  74882. */
  74883. static WriteNumber(key: string, value: number): void;
  74884. }
  74885. }
  74886. declare module BABYLON {
  74887. /**
  74888. * Class used to record delta files between 2 scene states
  74889. */
  74890. export class SceneRecorder {
  74891. private _trackedScene;
  74892. private _savedJSON;
  74893. /**
  74894. * Track a given scene. This means the current scene state will be considered the original state
  74895. * @param scene defines the scene to track
  74896. */
  74897. track(scene: Scene): void;
  74898. /**
  74899. * Get the delta between current state and original state
  74900. * @returns a string containing the delta
  74901. */
  74902. getDelta(): any;
  74903. private _compareArray;
  74904. private _compareObjects;
  74905. private _compareCollections;
  74906. private static GetShadowGeneratorById;
  74907. /**
  74908. * Apply a given delta to a given scene
  74909. * @param deltaJSON defines the JSON containing the delta
  74910. * @param scene defines the scene to apply the delta to
  74911. */
  74912. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74913. private static _ApplyPropertiesToEntity;
  74914. private static _ApplyDeltaForEntity;
  74915. }
  74916. }
  74917. declare module BABYLON {
  74918. /**
  74919. * A 3D trajectory consisting of an order list of vectors describing a
  74920. * path of motion through 3D space.
  74921. */
  74922. export class Trajectory {
  74923. private _points;
  74924. private readonly _segmentLength;
  74925. /**
  74926. * Serialize to JSON.
  74927. * @returns serialized JSON string
  74928. */
  74929. serialize(): string;
  74930. /**
  74931. * Deserialize from JSON.
  74932. * @param json serialized JSON string
  74933. * @returns deserialized Trajectory
  74934. */
  74935. static Deserialize(json: string): Trajectory;
  74936. /**
  74937. * Create a new empty Trajectory.
  74938. * @param segmentLength radius of discretization for Trajectory points
  74939. */
  74940. constructor(segmentLength?: number);
  74941. /**
  74942. * Get the length of the Trajectory.
  74943. * @returns length of the Trajectory
  74944. */
  74945. getLength(): number;
  74946. /**
  74947. * Append a new point to the Trajectory.
  74948. * NOTE: This implementation has many allocations.
  74949. * @param point point to append to the Trajectory
  74950. */
  74951. add(point: DeepImmutable<Vector3>): void;
  74952. /**
  74953. * Create a new Trajectory with a segment length chosen to make it
  74954. * probable that the new Trajectory will have a specified number of
  74955. * segments. This operation is imprecise.
  74956. * @param targetResolution number of segments desired
  74957. * @returns new Trajectory with approximately the requested number of segments
  74958. */
  74959. resampleAtTargetResolution(targetResolution: number): Trajectory;
  74960. /**
  74961. * Convert Trajectory segments into tokenized representation. This
  74962. * representation is an array of numbers where each nth number is the
  74963. * index of the token which is most similar to the nth segment of the
  74964. * Trajectory.
  74965. * @param tokens list of vectors which serve as discrete tokens
  74966. * @returns list of indices of most similar token per segment
  74967. */
  74968. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  74969. private static _forwardDir;
  74970. private static _inverseFromVec;
  74971. private static _upDir;
  74972. private static _fromToVec;
  74973. private static _lookMatrix;
  74974. /**
  74975. * Transform the rotation (i.e., direction) of a segment to isolate
  74976. * the relative transformation represented by the segment. This operation
  74977. * may or may not succeed due to singularities in the equations that define
  74978. * motion relativity in this context.
  74979. * @param priorVec the origin of the prior segment
  74980. * @param fromVec the origin of the current segment
  74981. * @param toVec the destination of the current segment
  74982. * @param result reference to output variable
  74983. * @returns whether or not transformation was successful
  74984. */
  74985. private static _transformSegmentDirToRef;
  74986. private static _bestMatch;
  74987. private static _score;
  74988. private static _bestScore;
  74989. /**
  74990. * Determine which token vector is most similar to the
  74991. * segment vector.
  74992. * @param segment segment vector
  74993. * @param tokens token vector list
  74994. * @returns index of the most similar token to the segment
  74995. */
  74996. private static _tokenizeSegment;
  74997. }
  74998. /**
  74999. * Class representing a set of known, named trajectories to which Trajectories can be
  75000. * added and using which Trajectories can be recognized.
  75001. */
  75002. export class TrajectoryClassifier {
  75003. private _maximumAllowableMatchCost;
  75004. private _vector3Alphabet;
  75005. private _levenshteinAlphabet;
  75006. private _nameToDescribedTrajectory;
  75007. /**
  75008. * Serialize to JSON.
  75009. * @returns JSON serialization
  75010. */
  75011. serialize(): string;
  75012. /**
  75013. * Deserialize from JSON.
  75014. * @param json JSON serialization
  75015. * @returns deserialized TrajectorySet
  75016. */
  75017. static Deserialize(json: string): TrajectoryClassifier;
  75018. /**
  75019. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75020. * VERY naive, need to be generating these things from known
  75021. * sets. Better version later, probably eliminating this one.
  75022. * @returns auto-generated TrajectorySet
  75023. */
  75024. static Generate(): TrajectoryClassifier;
  75025. private constructor();
  75026. /**
  75027. * Add a new Trajectory to the set with a given name.
  75028. * @param trajectory new Trajectory to be added
  75029. * @param classification name to which to add the Trajectory
  75030. */
  75031. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75032. /**
  75033. * Remove a known named trajectory and all Trajectories associated with it.
  75034. * @param classification name to remove
  75035. * @returns whether anything was removed
  75036. */
  75037. deleteClassification(classification: string): boolean;
  75038. /**
  75039. * Attempt to recognize a Trajectory from among all the classifications
  75040. * already known to the classifier.
  75041. * @param trajectory Trajectory to be recognized
  75042. * @returns classification of Trajectory if recognized, null otherwise
  75043. */
  75044. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75045. }
  75046. }
  75047. declare module BABYLON {
  75048. /**
  75049. * An interface for all Hit test features
  75050. */
  75051. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75052. /**
  75053. * Triggered when new babylon (transformed) hit test results are available
  75054. */
  75055. onHitTestResultObservable: Observable<T[]>;
  75056. }
  75057. /**
  75058. * Options used for hit testing
  75059. */
  75060. export interface IWebXRLegacyHitTestOptions {
  75061. /**
  75062. * Only test when user interacted with the scene. Default - hit test every frame
  75063. */
  75064. testOnPointerDownOnly?: boolean;
  75065. /**
  75066. * The node to use to transform the local results to world coordinates
  75067. */
  75068. worldParentNode?: TransformNode;
  75069. }
  75070. /**
  75071. * Interface defining the babylon result of raycasting/hit-test
  75072. */
  75073. export interface IWebXRLegacyHitResult {
  75074. /**
  75075. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75076. */
  75077. transformationMatrix: Matrix;
  75078. /**
  75079. * The native hit test result
  75080. */
  75081. xrHitResult: XRHitResult | XRHitTestResult;
  75082. }
  75083. /**
  75084. * The currently-working hit-test module.
  75085. * Hit test (or Ray-casting) is used to interact with the real world.
  75086. * For further information read here - https://github.com/immersive-web/hit-test
  75087. */
  75088. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75089. /**
  75090. * options to use when constructing this feature
  75091. */
  75092. readonly options: IWebXRLegacyHitTestOptions;
  75093. private _direction;
  75094. private _mat;
  75095. private _onSelectEnabled;
  75096. private _origin;
  75097. /**
  75098. * The module's name
  75099. */
  75100. static readonly Name: string;
  75101. /**
  75102. * The (Babylon) version of this module.
  75103. * This is an integer representing the implementation version.
  75104. * This number does not correspond to the WebXR specs version
  75105. */
  75106. static readonly Version: number;
  75107. /**
  75108. * Populated with the last native XR Hit Results
  75109. */
  75110. lastNativeXRHitResults: XRHitResult[];
  75111. /**
  75112. * Triggered when new babylon (transformed) hit test results are available
  75113. */
  75114. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75115. /**
  75116. * Creates a new instance of the (legacy version) hit test feature
  75117. * @param _xrSessionManager an instance of WebXRSessionManager
  75118. * @param options options to use when constructing this feature
  75119. */
  75120. constructor(_xrSessionManager: WebXRSessionManager,
  75121. /**
  75122. * options to use when constructing this feature
  75123. */
  75124. options?: IWebXRLegacyHitTestOptions);
  75125. /**
  75126. * execute a hit test with an XR Ray
  75127. *
  75128. * @param xrSession a native xrSession that will execute this hit test
  75129. * @param xrRay the ray (position and direction) to use for ray-casting
  75130. * @param referenceSpace native XR reference space to use for the hit-test
  75131. * @param filter filter function that will filter the results
  75132. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75133. */
  75134. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75135. /**
  75136. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75137. * @param event the (select) event to use to select with
  75138. * @param referenceSpace the reference space to use for this hit test
  75139. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75140. */
  75141. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75142. /**
  75143. * attach this feature
  75144. * Will usually be called by the features manager
  75145. *
  75146. * @returns true if successful.
  75147. */
  75148. attach(): boolean;
  75149. /**
  75150. * detach this feature.
  75151. * Will usually be called by the features manager
  75152. *
  75153. * @returns true if successful.
  75154. */
  75155. detach(): boolean;
  75156. /**
  75157. * Dispose this feature and all of the resources attached
  75158. */
  75159. dispose(): void;
  75160. protected _onXRFrame(frame: XRFrame): void;
  75161. private _onHitTestResults;
  75162. private _onSelect;
  75163. }
  75164. }
  75165. declare module BABYLON {
  75166. /**
  75167. * Options used for hit testing (version 2)
  75168. */
  75169. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75170. /**
  75171. * Do not create a permanent hit test. Will usually be used when only
  75172. * transient inputs are needed.
  75173. */
  75174. disablePermanentHitTest?: boolean;
  75175. /**
  75176. * Enable transient (for example touch-based) hit test inspections
  75177. */
  75178. enableTransientHitTest?: boolean;
  75179. /**
  75180. * Offset ray for the permanent hit test
  75181. */
  75182. offsetRay?: Vector3;
  75183. /**
  75184. * Offset ray for the transient hit test
  75185. */
  75186. transientOffsetRay?: Vector3;
  75187. /**
  75188. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75189. */
  75190. useReferenceSpace?: boolean;
  75191. /**
  75192. * Override the default entity type(s) of the hit-test result
  75193. */
  75194. entityTypes?: XRHitTestTrackableType[];
  75195. }
  75196. /**
  75197. * Interface defining the babylon result of hit-test
  75198. */
  75199. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75200. /**
  75201. * The input source that generated this hit test (if transient)
  75202. */
  75203. inputSource?: XRInputSource;
  75204. /**
  75205. * Is this a transient hit test
  75206. */
  75207. isTransient?: boolean;
  75208. /**
  75209. * Position of the hit test result
  75210. */
  75211. position: Vector3;
  75212. /**
  75213. * Rotation of the hit test result
  75214. */
  75215. rotationQuaternion: Quaternion;
  75216. /**
  75217. * The native hit test result
  75218. */
  75219. xrHitResult: XRHitTestResult;
  75220. }
  75221. /**
  75222. * The currently-working hit-test module.
  75223. * Hit test (or Ray-casting) is used to interact with the real world.
  75224. * For further information read here - https://github.com/immersive-web/hit-test
  75225. *
  75226. * Tested on chrome (mobile) 80.
  75227. */
  75228. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75229. /**
  75230. * options to use when constructing this feature
  75231. */
  75232. readonly options: IWebXRHitTestOptions;
  75233. private _tmpMat;
  75234. private _tmpPos;
  75235. private _tmpQuat;
  75236. private _transientXrHitTestSource;
  75237. private _xrHitTestSource;
  75238. private initHitTestSource;
  75239. /**
  75240. * The module's name
  75241. */
  75242. static readonly Name: string;
  75243. /**
  75244. * The (Babylon) version of this module.
  75245. * This is an integer representing the implementation version.
  75246. * This number does not correspond to the WebXR specs version
  75247. */
  75248. static readonly Version: number;
  75249. /**
  75250. * When set to true, each hit test will have its own position/rotation objects
  75251. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75252. * the developers will clone them or copy them as they see fit.
  75253. */
  75254. autoCloneTransformation: boolean;
  75255. /**
  75256. * Triggered when new babylon (transformed) hit test results are available
  75257. * Note - this will be called when results come back from the device. It can be an empty array!!
  75258. */
  75259. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75260. /**
  75261. * Use this to temporarily pause hit test checks.
  75262. */
  75263. paused: boolean;
  75264. /**
  75265. * Creates a new instance of the hit test feature
  75266. * @param _xrSessionManager an instance of WebXRSessionManager
  75267. * @param options options to use when constructing this feature
  75268. */
  75269. constructor(_xrSessionManager: WebXRSessionManager,
  75270. /**
  75271. * options to use when constructing this feature
  75272. */
  75273. options?: IWebXRHitTestOptions);
  75274. /**
  75275. * attach this feature
  75276. * Will usually be called by the features manager
  75277. *
  75278. * @returns true if successful.
  75279. */
  75280. attach(): boolean;
  75281. /**
  75282. * detach this feature.
  75283. * Will usually be called by the features manager
  75284. *
  75285. * @returns true if successful.
  75286. */
  75287. detach(): boolean;
  75288. /**
  75289. * Dispose this feature and all of the resources attached
  75290. */
  75291. dispose(): void;
  75292. protected _onXRFrame(frame: XRFrame): void;
  75293. private _processWebXRHitTestResult;
  75294. }
  75295. }
  75296. declare module BABYLON {
  75297. /**
  75298. * Configuration options of the anchor system
  75299. */
  75300. export interface IWebXRAnchorSystemOptions {
  75301. /**
  75302. * a node that will be used to convert local to world coordinates
  75303. */
  75304. worldParentNode?: TransformNode;
  75305. /**
  75306. * If set to true a reference of the created anchors will be kept until the next session starts
  75307. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75308. */
  75309. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75310. }
  75311. /**
  75312. * A babylon container for an XR Anchor
  75313. */
  75314. export interface IWebXRAnchor {
  75315. /**
  75316. * A babylon-assigned ID for this anchor
  75317. */
  75318. id: number;
  75319. /**
  75320. * Transformation matrix to apply to an object attached to this anchor
  75321. */
  75322. transformationMatrix: Matrix;
  75323. /**
  75324. * The native anchor object
  75325. */
  75326. xrAnchor: XRAnchor;
  75327. /**
  75328. * if defined, this object will be constantly updated by the anchor's position and rotation
  75329. */
  75330. attachedNode?: TransformNode;
  75331. }
  75332. /**
  75333. * An implementation of the anchor system for WebXR.
  75334. * For further information see https://github.com/immersive-web/anchors/
  75335. */
  75336. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75337. private _options;
  75338. private _lastFrameDetected;
  75339. private _trackedAnchors;
  75340. private _referenceSpaceForFrameAnchors;
  75341. private _futureAnchors;
  75342. /**
  75343. * The module's name
  75344. */
  75345. static readonly Name: string;
  75346. /**
  75347. * The (Babylon) version of this module.
  75348. * This is an integer representing the implementation version.
  75349. * This number does not correspond to the WebXR specs version
  75350. */
  75351. static readonly Version: number;
  75352. /**
  75353. * Observers registered here will be executed when a new anchor was added to the session
  75354. */
  75355. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75356. /**
  75357. * Observers registered here will be executed when an anchor was removed from the session
  75358. */
  75359. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75360. /**
  75361. * Observers registered here will be executed when an existing anchor updates
  75362. * This can execute N times every frame
  75363. */
  75364. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75365. /**
  75366. * Set the reference space to use for anchor creation, when not using a hit test.
  75367. * Will default to the session's reference space if not defined
  75368. */
  75369. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75370. /**
  75371. * constructs a new anchor system
  75372. * @param _xrSessionManager an instance of WebXRSessionManager
  75373. * @param _options configuration object for this feature
  75374. */
  75375. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75376. private _tmpVector;
  75377. private _tmpQuaternion;
  75378. private _populateTmpTransformation;
  75379. /**
  75380. * Create a new anchor point using a hit test result at a specific point in the scene
  75381. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75382. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75383. *
  75384. * @param hitTestResult The hit test result to use for this anchor creation
  75385. * @param position an optional position offset for this anchor
  75386. * @param rotationQuaternion an optional rotation offset for this anchor
  75387. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75388. */
  75389. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75390. /**
  75391. * Add a new anchor at a specific position and rotation
  75392. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75393. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75394. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75395. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75396. *
  75397. * @param position the position in which to add an anchor
  75398. * @param rotationQuaternion an optional rotation for the anchor transformation
  75399. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75400. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75401. */
  75402. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75403. /**
  75404. * detach this feature.
  75405. * Will usually be called by the features manager
  75406. *
  75407. * @returns true if successful.
  75408. */
  75409. detach(): boolean;
  75410. /**
  75411. * Dispose this feature and all of the resources attached
  75412. */
  75413. dispose(): void;
  75414. protected _onXRFrame(frame: XRFrame): void;
  75415. /**
  75416. * avoiding using Array.find for global support.
  75417. * @param xrAnchor the plane to find in the array
  75418. */
  75419. private _findIndexInAnchorArray;
  75420. private _updateAnchorWithXRFrame;
  75421. private _createAnchorAtTransformation;
  75422. }
  75423. }
  75424. declare module BABYLON {
  75425. /**
  75426. * Options used in the plane detector module
  75427. */
  75428. export interface IWebXRPlaneDetectorOptions {
  75429. /**
  75430. * The node to use to transform the local results to world coordinates
  75431. */
  75432. worldParentNode?: TransformNode;
  75433. /**
  75434. * If set to true a reference of the created planes will be kept until the next session starts
  75435. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75436. */
  75437. doNotRemovePlanesOnSessionEnded?: boolean;
  75438. }
  75439. /**
  75440. * A babylon interface for a WebXR plane.
  75441. * A Plane is actually a polygon, built from N points in space
  75442. *
  75443. * Supported in chrome 79, not supported in canary 81 ATM
  75444. */
  75445. export interface IWebXRPlane {
  75446. /**
  75447. * a babylon-assigned ID for this polygon
  75448. */
  75449. id: number;
  75450. /**
  75451. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75452. */
  75453. polygonDefinition: Array<Vector3>;
  75454. /**
  75455. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75456. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75457. */
  75458. transformationMatrix: Matrix;
  75459. /**
  75460. * the native xr-plane object
  75461. */
  75462. xrPlane: XRPlane;
  75463. }
  75464. /**
  75465. * The plane detector is used to detect planes in the real world when in AR
  75466. * For more information see https://github.com/immersive-web/real-world-geometry/
  75467. */
  75468. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75469. private _options;
  75470. private _detectedPlanes;
  75471. private _enabled;
  75472. private _lastFrameDetected;
  75473. /**
  75474. * The module's name
  75475. */
  75476. static readonly Name: string;
  75477. /**
  75478. * The (Babylon) version of this module.
  75479. * This is an integer representing the implementation version.
  75480. * This number does not correspond to the WebXR specs version
  75481. */
  75482. static readonly Version: number;
  75483. /**
  75484. * Observers registered here will be executed when a new plane was added to the session
  75485. */
  75486. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75487. /**
  75488. * Observers registered here will be executed when a plane is no longer detected in the session
  75489. */
  75490. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75491. /**
  75492. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75493. * This can execute N times every frame
  75494. */
  75495. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75496. /**
  75497. * construct a new Plane Detector
  75498. * @param _xrSessionManager an instance of xr Session manager
  75499. * @param _options configuration to use when constructing this feature
  75500. */
  75501. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75502. /**
  75503. * detach this feature.
  75504. * Will usually be called by the features manager
  75505. *
  75506. * @returns true if successful.
  75507. */
  75508. detach(): boolean;
  75509. /**
  75510. * Dispose this feature and all of the resources attached
  75511. */
  75512. dispose(): void;
  75513. protected _onXRFrame(frame: XRFrame): void;
  75514. private _init;
  75515. private _updatePlaneWithXRPlane;
  75516. /**
  75517. * avoiding using Array.find for global support.
  75518. * @param xrPlane the plane to find in the array
  75519. */
  75520. private findIndexInPlaneArray;
  75521. }
  75522. }
  75523. declare module BABYLON {
  75524. /**
  75525. * Options interface for the background remover plugin
  75526. */
  75527. export interface IWebXRBackgroundRemoverOptions {
  75528. /**
  75529. * Further background meshes to disable when entering AR
  75530. */
  75531. backgroundMeshes?: AbstractMesh[];
  75532. /**
  75533. * flags to configure the removal of the environment helper.
  75534. * If not set, the entire background will be removed. If set, flags should be set as well.
  75535. */
  75536. environmentHelperRemovalFlags?: {
  75537. /**
  75538. * Should the skybox be removed (default false)
  75539. */
  75540. skyBox?: boolean;
  75541. /**
  75542. * Should the ground be removed (default false)
  75543. */
  75544. ground?: boolean;
  75545. };
  75546. /**
  75547. * don't disable the environment helper
  75548. */
  75549. ignoreEnvironmentHelper?: boolean;
  75550. }
  75551. /**
  75552. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75553. */
  75554. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75555. /**
  75556. * read-only options to be used in this module
  75557. */
  75558. readonly options: IWebXRBackgroundRemoverOptions;
  75559. /**
  75560. * The module's name
  75561. */
  75562. static readonly Name: string;
  75563. /**
  75564. * The (Babylon) version of this module.
  75565. * This is an integer representing the implementation version.
  75566. * This number does not correspond to the WebXR specs version
  75567. */
  75568. static readonly Version: number;
  75569. /**
  75570. * registered observers will be triggered when the background state changes
  75571. */
  75572. onBackgroundStateChangedObservable: Observable<boolean>;
  75573. /**
  75574. * constructs a new background remover module
  75575. * @param _xrSessionManager the session manager for this module
  75576. * @param options read-only options to be used in this module
  75577. */
  75578. constructor(_xrSessionManager: WebXRSessionManager,
  75579. /**
  75580. * read-only options to be used in this module
  75581. */
  75582. options?: IWebXRBackgroundRemoverOptions);
  75583. /**
  75584. * attach this feature
  75585. * Will usually be called by the features manager
  75586. *
  75587. * @returns true if successful.
  75588. */
  75589. attach(): boolean;
  75590. /**
  75591. * detach this feature.
  75592. * Will usually be called by the features manager
  75593. *
  75594. * @returns true if successful.
  75595. */
  75596. detach(): boolean;
  75597. /**
  75598. * Dispose this feature and all of the resources attached
  75599. */
  75600. dispose(): void;
  75601. protected _onXRFrame(_xrFrame: XRFrame): void;
  75602. private _setBackgroundState;
  75603. }
  75604. }
  75605. declare module BABYLON {
  75606. /**
  75607. * Options for the controller physics feature
  75608. */
  75609. export class IWebXRControllerPhysicsOptions {
  75610. /**
  75611. * Should the headset get its own impostor
  75612. */
  75613. enableHeadsetImpostor?: boolean;
  75614. /**
  75615. * Optional parameters for the headset impostor
  75616. */
  75617. headsetImpostorParams?: {
  75618. /**
  75619. * The type of impostor to create. Default is sphere
  75620. */
  75621. impostorType: number;
  75622. /**
  75623. * the size of the impostor. Defaults to 10cm
  75624. */
  75625. impostorSize?: number | {
  75626. width: number;
  75627. height: number;
  75628. depth: number;
  75629. };
  75630. /**
  75631. * Friction definitions
  75632. */
  75633. friction?: number;
  75634. /**
  75635. * Restitution
  75636. */
  75637. restitution?: number;
  75638. };
  75639. /**
  75640. * The physics properties of the future impostors
  75641. */
  75642. physicsProperties?: {
  75643. /**
  75644. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75645. * Note that this requires a physics engine that supports mesh impostors!
  75646. */
  75647. useControllerMesh?: boolean;
  75648. /**
  75649. * The type of impostor to create. Default is sphere
  75650. */
  75651. impostorType?: number;
  75652. /**
  75653. * the size of the impostor. Defaults to 10cm
  75654. */
  75655. impostorSize?: number | {
  75656. width: number;
  75657. height: number;
  75658. depth: number;
  75659. };
  75660. /**
  75661. * Friction definitions
  75662. */
  75663. friction?: number;
  75664. /**
  75665. * Restitution
  75666. */
  75667. restitution?: number;
  75668. };
  75669. /**
  75670. * the xr input to use with this pointer selection
  75671. */
  75672. xrInput: WebXRInput;
  75673. }
  75674. /**
  75675. * Add physics impostor to your webxr controllers,
  75676. * including naive calculation of their linear and angular velocity
  75677. */
  75678. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75679. private readonly _options;
  75680. private _attachController;
  75681. private _controllers;
  75682. private _debugMode;
  75683. private _delta;
  75684. private _headsetImpostor?;
  75685. private _headsetMesh?;
  75686. private _lastTimestamp;
  75687. private _tmpQuaternion;
  75688. private _tmpVector;
  75689. /**
  75690. * The module's name
  75691. */
  75692. static readonly Name: string;
  75693. /**
  75694. * The (Babylon) version of this module.
  75695. * This is an integer representing the implementation version.
  75696. * This number does not correspond to the webxr specs version
  75697. */
  75698. static readonly Version: number;
  75699. /**
  75700. * Construct a new Controller Physics Feature
  75701. * @param _xrSessionManager the corresponding xr session manager
  75702. * @param _options options to create this feature with
  75703. */
  75704. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75705. /**
  75706. * @hidden
  75707. * enable debugging - will show console outputs and the impostor mesh
  75708. */
  75709. _enablePhysicsDebug(): void;
  75710. /**
  75711. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75712. * @param xrController the controller to add
  75713. */
  75714. addController(xrController: WebXRInputSource): void;
  75715. /**
  75716. * attach this feature
  75717. * Will usually be called by the features manager
  75718. *
  75719. * @returns true if successful.
  75720. */
  75721. attach(): boolean;
  75722. /**
  75723. * detach this feature.
  75724. * Will usually be called by the features manager
  75725. *
  75726. * @returns true if successful.
  75727. */
  75728. detach(): boolean;
  75729. /**
  75730. * Get the headset impostor, if enabled
  75731. * @returns the impostor
  75732. */
  75733. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75734. /**
  75735. * Get the physics impostor of a specific controller.
  75736. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75737. * @param controller the controller or the controller id of which to get the impostor
  75738. * @returns the impostor or null
  75739. */
  75740. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75741. /**
  75742. * Update the physics properties provided in the constructor
  75743. * @param newProperties the new properties object
  75744. */
  75745. setPhysicsProperties(newProperties: {
  75746. impostorType?: number;
  75747. impostorSize?: number | {
  75748. width: number;
  75749. height: number;
  75750. depth: number;
  75751. };
  75752. friction?: number;
  75753. restitution?: number;
  75754. }): void;
  75755. protected _onXRFrame(_xrFrame: any): void;
  75756. private _detachController;
  75757. }
  75758. }
  75759. declare module BABYLON {
  75760. /**
  75761. * A babylon interface for a "WebXR" feature point.
  75762. * Represents the position and confidence value of a given feature point.
  75763. */
  75764. export interface IWebXRFeaturePoint {
  75765. /**
  75766. * Represents the position of the feature point in world space.
  75767. */
  75768. position: Vector3;
  75769. /**
  75770. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75771. */
  75772. confidenceValue: number;
  75773. }
  75774. /**
  75775. * The feature point system is used to detect feature points from real world geometry.
  75776. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75777. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75778. */
  75779. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75780. private _enabled;
  75781. private _featurePointCloud;
  75782. /**
  75783. * The module's name
  75784. */
  75785. static readonly Name: string;
  75786. /**
  75787. * The (Babylon) version of this module.
  75788. * This is an integer representing the implementation version.
  75789. * This number does not correspond to the WebXR specs version
  75790. */
  75791. static readonly Version: number;
  75792. /**
  75793. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75794. * Will notify the observers about which feature points have been added.
  75795. */
  75796. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75797. /**
  75798. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75799. * Will notify the observers about which feature points have been updated.
  75800. */
  75801. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75802. /**
  75803. * The current feature point cloud maintained across frames.
  75804. */
  75805. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75806. /**
  75807. * construct the feature point system
  75808. * @param _xrSessionManager an instance of xr Session manager
  75809. */
  75810. constructor(_xrSessionManager: WebXRSessionManager);
  75811. /**
  75812. * Detach this feature.
  75813. * Will usually be called by the features manager
  75814. *
  75815. * @returns true if successful.
  75816. */
  75817. detach(): boolean;
  75818. /**
  75819. * Dispose this feature and all of the resources attached
  75820. */
  75821. dispose(): void;
  75822. /**
  75823. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75824. */
  75825. protected _onXRFrame(frame: XRFrame): void;
  75826. /**
  75827. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75828. */
  75829. private _init;
  75830. }
  75831. }
  75832. declare module BABYLON {
  75833. /**
  75834. * Configuration interface for the hand tracking feature
  75835. */
  75836. export interface IWebXRHandTrackingOptions {
  75837. /**
  75838. * The xrInput that will be used as source for new hands
  75839. */
  75840. xrInput: WebXRInput;
  75841. /**
  75842. * Configuration object for the joint meshes
  75843. */
  75844. jointMeshes?: {
  75845. /**
  75846. * Should the meshes created be invisible (defaults to false)
  75847. */
  75848. invisible?: boolean;
  75849. /**
  75850. * A source mesh to be used to create instances. Defaults to a sphere.
  75851. * This mesh will be the source for all other (25) meshes.
  75852. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75853. */
  75854. sourceMesh?: Mesh;
  75855. /**
  75856. * This function will be called after a mesh was created for a specific joint.
  75857. * Using this function you can either manipulate the instance or return a new mesh.
  75858. * When returning a new mesh the instance created before will be disposed
  75859. */
  75860. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  75861. /**
  75862. * Should the source mesh stay visible. Defaults to false
  75863. */
  75864. keepOriginalVisible?: boolean;
  75865. /**
  75866. * Scale factor for all instances (defaults to 2)
  75867. */
  75868. scaleFactor?: number;
  75869. /**
  75870. * Should each instance have its own physics impostor
  75871. */
  75872. enablePhysics?: boolean;
  75873. /**
  75874. * If enabled, override default physics properties
  75875. */
  75876. physicsProps?: {
  75877. friction?: number;
  75878. restitution?: number;
  75879. impostorType?: number;
  75880. };
  75881. /**
  75882. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75883. */
  75884. handMesh?: AbstractMesh;
  75885. };
  75886. }
  75887. /**
  75888. * Parts of the hands divided to writs and finger names
  75889. */
  75890. export const enum HandPart {
  75891. /**
  75892. * HandPart - Wrist
  75893. */
  75894. WRIST = "wrist",
  75895. /**
  75896. * HandPart - The THumb
  75897. */
  75898. THUMB = "thumb",
  75899. /**
  75900. * HandPart - Index finger
  75901. */
  75902. INDEX = "index",
  75903. /**
  75904. * HandPart - Middle finger
  75905. */
  75906. MIDDLE = "middle",
  75907. /**
  75908. * HandPart - Ring finger
  75909. */
  75910. RING = "ring",
  75911. /**
  75912. * HandPart - Little finger
  75913. */
  75914. LITTLE = "little"
  75915. }
  75916. /**
  75917. * Representing a single hand (with its corresponding native XRHand object)
  75918. */
  75919. export class WebXRHand implements IDisposable {
  75920. /** the controller to which the hand correlates */
  75921. readonly xrController: WebXRInputSource;
  75922. /** the meshes to be used to track the hand joints */
  75923. readonly trackedMeshes: AbstractMesh[];
  75924. /**
  75925. * Hand-parts definition (key is HandPart)
  75926. */
  75927. handPartsDefinition: {
  75928. [key: string]: number[];
  75929. };
  75930. /**
  75931. * Populate the HandPartsDefinition object.
  75932. * This is called as a side effect since certain browsers don't have XRHand defined.
  75933. */
  75934. private generateHandPartsDefinition;
  75935. /**
  75936. * Construct a new hand object
  75937. * @param xrController the controller to which the hand correlates
  75938. * @param trackedMeshes the meshes to be used to track the hand joints
  75939. */
  75940. constructor(
  75941. /** the controller to which the hand correlates */
  75942. xrController: WebXRInputSource,
  75943. /** the meshes to be used to track the hand joints */
  75944. trackedMeshes: AbstractMesh[]);
  75945. /**
  75946. * Update this hand from the latest xr frame
  75947. * @param xrFrame xrFrame to update from
  75948. * @param referenceSpace The current viewer reference space
  75949. * @param scaleFactor optional scale factor for the meshes
  75950. */
  75951. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75952. /**
  75953. * Get meshes of part of the hand
  75954. * @param part the part of hand to get
  75955. * @returns An array of meshes that correlate to the hand part requested
  75956. */
  75957. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75958. /**
  75959. * Dispose this Hand object
  75960. */
  75961. dispose(): void;
  75962. }
  75963. /**
  75964. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75965. */
  75966. export class WebXRHandTracking extends WebXRAbstractFeature {
  75967. /**
  75968. * options to use when constructing this feature
  75969. */
  75970. readonly options: IWebXRHandTrackingOptions;
  75971. private static _idCounter;
  75972. /**
  75973. * The module's name
  75974. */
  75975. static readonly Name: string;
  75976. /**
  75977. * The (Babylon) version of this module.
  75978. * This is an integer representing the implementation version.
  75979. * This number does not correspond to the WebXR specs version
  75980. */
  75981. static readonly Version: number;
  75982. /**
  75983. * This observable will notify registered observers when a new hand object was added and initialized
  75984. */
  75985. onHandAddedObservable: Observable<WebXRHand>;
  75986. /**
  75987. * This observable will notify its observers right before the hand object is disposed
  75988. */
  75989. onHandRemovedObservable: Observable<WebXRHand>;
  75990. private _hands;
  75991. /**
  75992. * Creates a new instance of the hit test feature
  75993. * @param _xrSessionManager an instance of WebXRSessionManager
  75994. * @param options options to use when constructing this feature
  75995. */
  75996. constructor(_xrSessionManager: WebXRSessionManager,
  75997. /**
  75998. * options to use when constructing this feature
  75999. */
  76000. options: IWebXRHandTrackingOptions);
  76001. /**
  76002. * Check if the needed objects are defined.
  76003. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76004. */
  76005. isCompatible(): boolean;
  76006. /**
  76007. * attach this feature
  76008. * Will usually be called by the features manager
  76009. *
  76010. * @returns true if successful.
  76011. */
  76012. attach(): boolean;
  76013. /**
  76014. * detach this feature.
  76015. * Will usually be called by the features manager
  76016. *
  76017. * @returns true if successful.
  76018. */
  76019. detach(): boolean;
  76020. /**
  76021. * Dispose this feature and all of the resources attached
  76022. */
  76023. dispose(): void;
  76024. /**
  76025. * Get the hand object according to the controller id
  76026. * @param controllerId the controller id to which we want to get the hand
  76027. * @returns null if not found or the WebXRHand object if found
  76028. */
  76029. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76030. /**
  76031. * Get a hand object according to the requested handedness
  76032. * @param handedness the handedness to request
  76033. * @returns null if not found or the WebXRHand object if found
  76034. */
  76035. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76036. protected _onXRFrame(_xrFrame: XRFrame): void;
  76037. private _attachHand;
  76038. private _detachHand;
  76039. }
  76040. }
  76041. declare module BABYLON {
  76042. /**
  76043. * The motion controller class for all microsoft mixed reality controllers
  76044. */
  76045. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76046. protected readonly _mapping: {
  76047. defaultButton: {
  76048. valueNodeName: string;
  76049. unpressedNodeName: string;
  76050. pressedNodeName: string;
  76051. };
  76052. defaultAxis: {
  76053. valueNodeName: string;
  76054. minNodeName: string;
  76055. maxNodeName: string;
  76056. };
  76057. buttons: {
  76058. "xr-standard-trigger": {
  76059. rootNodeName: string;
  76060. componentProperty: string;
  76061. states: string[];
  76062. };
  76063. "xr-standard-squeeze": {
  76064. rootNodeName: string;
  76065. componentProperty: string;
  76066. states: string[];
  76067. };
  76068. "xr-standard-touchpad": {
  76069. rootNodeName: string;
  76070. labelAnchorNodeName: string;
  76071. touchPointNodeName: string;
  76072. };
  76073. "xr-standard-thumbstick": {
  76074. rootNodeName: string;
  76075. componentProperty: string;
  76076. states: string[];
  76077. };
  76078. };
  76079. axes: {
  76080. "xr-standard-touchpad": {
  76081. "x-axis": {
  76082. rootNodeName: string;
  76083. };
  76084. "y-axis": {
  76085. rootNodeName: string;
  76086. };
  76087. };
  76088. "xr-standard-thumbstick": {
  76089. "x-axis": {
  76090. rootNodeName: string;
  76091. };
  76092. "y-axis": {
  76093. rootNodeName: string;
  76094. };
  76095. };
  76096. };
  76097. };
  76098. /**
  76099. * The base url used to load the left and right controller models
  76100. */
  76101. static MODEL_BASE_URL: string;
  76102. /**
  76103. * The name of the left controller model file
  76104. */
  76105. static MODEL_LEFT_FILENAME: string;
  76106. /**
  76107. * The name of the right controller model file
  76108. */
  76109. static MODEL_RIGHT_FILENAME: string;
  76110. profileId: string;
  76111. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76112. protected _getFilenameAndPath(): {
  76113. filename: string;
  76114. path: string;
  76115. };
  76116. protected _getModelLoadingConstraints(): boolean;
  76117. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76118. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76119. protected _updateModel(): void;
  76120. }
  76121. }
  76122. declare module BABYLON {
  76123. /**
  76124. * The motion controller class for oculus touch (quest, rift).
  76125. * This class supports legacy mapping as well the standard xr mapping
  76126. */
  76127. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76128. private _forceLegacyControllers;
  76129. private _modelRootNode;
  76130. /**
  76131. * The base url used to load the left and right controller models
  76132. */
  76133. static MODEL_BASE_URL: string;
  76134. /**
  76135. * The name of the left controller model file
  76136. */
  76137. static MODEL_LEFT_FILENAME: string;
  76138. /**
  76139. * The name of the right controller model file
  76140. */
  76141. static MODEL_RIGHT_FILENAME: string;
  76142. /**
  76143. * Base Url for the Quest controller model.
  76144. */
  76145. static QUEST_MODEL_BASE_URL: string;
  76146. profileId: string;
  76147. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76148. protected _getFilenameAndPath(): {
  76149. filename: string;
  76150. path: string;
  76151. };
  76152. protected _getModelLoadingConstraints(): boolean;
  76153. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76154. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76155. protected _updateModel(): void;
  76156. /**
  76157. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76158. * between the touch and touch 2.
  76159. */
  76160. private _isQuest;
  76161. }
  76162. }
  76163. declare module BABYLON {
  76164. /**
  76165. * The motion controller class for the standard HTC-Vive controllers
  76166. */
  76167. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76168. private _modelRootNode;
  76169. /**
  76170. * The base url used to load the left and right controller models
  76171. */
  76172. static MODEL_BASE_URL: string;
  76173. /**
  76174. * File name for the controller model.
  76175. */
  76176. static MODEL_FILENAME: string;
  76177. profileId: string;
  76178. /**
  76179. * Create a new Vive motion controller object
  76180. * @param scene the scene to use to create this controller
  76181. * @param gamepadObject the corresponding gamepad object
  76182. * @param handedness the handedness of the controller
  76183. */
  76184. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76185. protected _getFilenameAndPath(): {
  76186. filename: string;
  76187. path: string;
  76188. };
  76189. protected _getModelLoadingConstraints(): boolean;
  76190. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76191. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76192. protected _updateModel(): void;
  76193. }
  76194. }
  76195. declare module BABYLON {
  76196. /**
  76197. * A cursor which tracks a point on a path
  76198. */
  76199. export class PathCursor {
  76200. private path;
  76201. /**
  76202. * Stores path cursor callbacks for when an onchange event is triggered
  76203. */
  76204. private _onchange;
  76205. /**
  76206. * The value of the path cursor
  76207. */
  76208. value: number;
  76209. /**
  76210. * The animation array of the path cursor
  76211. */
  76212. animations: Animation[];
  76213. /**
  76214. * Initializes the path cursor
  76215. * @param path The path to track
  76216. */
  76217. constructor(path: Path2);
  76218. /**
  76219. * Gets the cursor point on the path
  76220. * @returns A point on the path cursor at the cursor location
  76221. */
  76222. getPoint(): Vector3;
  76223. /**
  76224. * Moves the cursor ahead by the step amount
  76225. * @param step The amount to move the cursor forward
  76226. * @returns This path cursor
  76227. */
  76228. moveAhead(step?: number): PathCursor;
  76229. /**
  76230. * Moves the cursor behind by the step amount
  76231. * @param step The amount to move the cursor back
  76232. * @returns This path cursor
  76233. */
  76234. moveBack(step?: number): PathCursor;
  76235. /**
  76236. * Moves the cursor by the step amount
  76237. * If the step amount is greater than one, an exception is thrown
  76238. * @param step The amount to move the cursor
  76239. * @returns This path cursor
  76240. */
  76241. move(step: number): PathCursor;
  76242. /**
  76243. * Ensures that the value is limited between zero and one
  76244. * @returns This path cursor
  76245. */
  76246. private ensureLimits;
  76247. /**
  76248. * Runs onchange callbacks on change (used by the animation engine)
  76249. * @returns This path cursor
  76250. */
  76251. private raiseOnChange;
  76252. /**
  76253. * Executes a function on change
  76254. * @param f A path cursor onchange callback
  76255. * @returns This path cursor
  76256. */
  76257. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76258. }
  76259. }
  76260. declare module BABYLON {
  76261. /** @hidden */
  76262. export var blurPixelShader: {
  76263. name: string;
  76264. shader: string;
  76265. };
  76266. }
  76267. declare module BABYLON {
  76268. /** @hidden */
  76269. export var pointCloudVertexDeclaration: {
  76270. name: string;
  76271. shader: string;
  76272. };
  76273. }
  76274. // Mixins
  76275. interface Window {
  76276. mozIndexedDB: IDBFactory;
  76277. webkitIndexedDB: IDBFactory;
  76278. msIndexedDB: IDBFactory;
  76279. webkitURL: typeof URL;
  76280. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76281. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76282. WebGLRenderingContext: WebGLRenderingContext;
  76283. MSGesture: MSGesture;
  76284. CANNON: any;
  76285. AudioContext: AudioContext;
  76286. webkitAudioContext: AudioContext;
  76287. PointerEvent: any;
  76288. Math: Math;
  76289. Uint8Array: Uint8ArrayConstructor;
  76290. Float32Array: Float32ArrayConstructor;
  76291. mozURL: typeof URL;
  76292. msURL: typeof URL;
  76293. VRFrameData: any; // WebVR, from specs 1.1
  76294. DracoDecoderModule: any;
  76295. setImmediate(handler: (...args: any[]) => void): number;
  76296. }
  76297. interface HTMLCanvasElement {
  76298. requestPointerLock(): void;
  76299. msRequestPointerLock?(): void;
  76300. mozRequestPointerLock?(): void;
  76301. webkitRequestPointerLock?(): void;
  76302. /** Track wether a record is in progress */
  76303. isRecording: boolean;
  76304. /** Capture Stream method defined by some browsers */
  76305. captureStream(fps?: number): MediaStream;
  76306. }
  76307. interface CanvasRenderingContext2D {
  76308. msImageSmoothingEnabled: boolean;
  76309. }
  76310. interface MouseEvent {
  76311. mozMovementX: number;
  76312. mozMovementY: number;
  76313. webkitMovementX: number;
  76314. webkitMovementY: number;
  76315. msMovementX: number;
  76316. msMovementY: number;
  76317. }
  76318. interface Navigator {
  76319. mozGetVRDevices: (any: any) => any;
  76320. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76321. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76322. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76323. webkitGetGamepads(): Gamepad[];
  76324. msGetGamepads(): Gamepad[];
  76325. webkitGamepads(): Gamepad[];
  76326. }
  76327. interface HTMLVideoElement {
  76328. mozSrcObject: any;
  76329. }
  76330. interface Math {
  76331. fround(x: number): number;
  76332. imul(a: number, b: number): number;
  76333. }
  76334. interface WebGLRenderingContext {
  76335. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76336. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76337. vertexAttribDivisor(index: number, divisor: number): void;
  76338. createVertexArray(): any;
  76339. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76340. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76341. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76342. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76343. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76344. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76345. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76346. // Queries
  76347. createQuery(): WebGLQuery;
  76348. deleteQuery(query: WebGLQuery): void;
  76349. beginQuery(target: number, query: WebGLQuery): void;
  76350. endQuery(target: number): void;
  76351. getQueryParameter(query: WebGLQuery, pname: number): any;
  76352. getQuery(target: number, pname: number): any;
  76353. MAX_SAMPLES: number;
  76354. RGBA8: number;
  76355. READ_FRAMEBUFFER: number;
  76356. DRAW_FRAMEBUFFER: number;
  76357. UNIFORM_BUFFER: number;
  76358. HALF_FLOAT_OES: number;
  76359. RGBA16F: number;
  76360. RGBA32F: number;
  76361. R32F: number;
  76362. RG32F: number;
  76363. RGB32F: number;
  76364. R16F: number;
  76365. RG16F: number;
  76366. RGB16F: number;
  76367. RED: number;
  76368. RG: number;
  76369. R8: number;
  76370. RG8: number;
  76371. UNSIGNED_INT_24_8: number;
  76372. DEPTH24_STENCIL8: number;
  76373. MIN: number;
  76374. MAX: number;
  76375. /* Multiple Render Targets */
  76376. drawBuffers(buffers: number[]): void;
  76377. readBuffer(src: number): void;
  76378. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76379. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76380. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76381. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76382. // Occlusion Query
  76383. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76384. ANY_SAMPLES_PASSED: number;
  76385. QUERY_RESULT_AVAILABLE: number;
  76386. QUERY_RESULT: number;
  76387. }
  76388. interface WebGLProgram {
  76389. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76390. }
  76391. interface EXT_disjoint_timer_query {
  76392. QUERY_COUNTER_BITS_EXT: number;
  76393. TIME_ELAPSED_EXT: number;
  76394. TIMESTAMP_EXT: number;
  76395. GPU_DISJOINT_EXT: number;
  76396. QUERY_RESULT_EXT: number;
  76397. QUERY_RESULT_AVAILABLE_EXT: number;
  76398. queryCounterEXT(query: WebGLQuery, target: number): void;
  76399. createQueryEXT(): WebGLQuery;
  76400. beginQueryEXT(target: number, query: WebGLQuery): void;
  76401. endQueryEXT(target: number): void;
  76402. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76403. deleteQueryEXT(query: WebGLQuery): void;
  76404. }
  76405. interface WebGLUniformLocation {
  76406. _currentState: any;
  76407. }
  76408. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76409. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76410. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76411. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76412. interface WebGLRenderingContext {
  76413. readonly RASTERIZER_DISCARD: number;
  76414. readonly DEPTH_COMPONENT24: number;
  76415. readonly TEXTURE_3D: number;
  76416. readonly TEXTURE_2D_ARRAY: number;
  76417. readonly TEXTURE_COMPARE_FUNC: number;
  76418. readonly TEXTURE_COMPARE_MODE: number;
  76419. readonly COMPARE_REF_TO_TEXTURE: number;
  76420. readonly TEXTURE_WRAP_R: number;
  76421. readonly HALF_FLOAT: number;
  76422. readonly RGB8: number;
  76423. readonly RED_INTEGER: number;
  76424. readonly RG_INTEGER: number;
  76425. readonly RGB_INTEGER: number;
  76426. readonly RGBA_INTEGER: number;
  76427. readonly R8_SNORM: number;
  76428. readonly RG8_SNORM: number;
  76429. readonly RGB8_SNORM: number;
  76430. readonly RGBA8_SNORM: number;
  76431. readonly R8I: number;
  76432. readonly RG8I: number;
  76433. readonly RGB8I: number;
  76434. readonly RGBA8I: number;
  76435. readonly R8UI: number;
  76436. readonly RG8UI: number;
  76437. readonly RGB8UI: number;
  76438. readonly RGBA8UI: number;
  76439. readonly R16I: number;
  76440. readonly RG16I: number;
  76441. readonly RGB16I: number;
  76442. readonly RGBA16I: number;
  76443. readonly R16UI: number;
  76444. readonly RG16UI: number;
  76445. readonly RGB16UI: number;
  76446. readonly RGBA16UI: number;
  76447. readonly R32I: number;
  76448. readonly RG32I: number;
  76449. readonly RGB32I: number;
  76450. readonly RGBA32I: number;
  76451. readonly R32UI: number;
  76452. readonly RG32UI: number;
  76453. readonly RGB32UI: number;
  76454. readonly RGBA32UI: number;
  76455. readonly RGB10_A2UI: number;
  76456. readonly R11F_G11F_B10F: number;
  76457. readonly RGB9_E5: number;
  76458. readonly RGB10_A2: number;
  76459. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76460. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76461. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76462. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76463. readonly DEPTH_COMPONENT32F: number;
  76464. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76465. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76466. 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;
  76467. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76468. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76469. readonly TRANSFORM_FEEDBACK: number;
  76470. readonly INTERLEAVED_ATTRIBS: number;
  76471. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76472. createTransformFeedback(): WebGLTransformFeedback;
  76473. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76474. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76475. beginTransformFeedback(primitiveMode: number): void;
  76476. endTransformFeedback(): void;
  76477. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76478. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76479. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76480. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76481. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76482. }
  76483. interface ImageBitmap {
  76484. readonly width: number;
  76485. readonly height: number;
  76486. close(): void;
  76487. }
  76488. interface WebGLQuery extends WebGLObject {
  76489. }
  76490. declare var WebGLQuery: {
  76491. prototype: WebGLQuery;
  76492. new(): WebGLQuery;
  76493. };
  76494. interface WebGLSampler extends WebGLObject {
  76495. }
  76496. declare var WebGLSampler: {
  76497. prototype: WebGLSampler;
  76498. new(): WebGLSampler;
  76499. };
  76500. interface WebGLSync extends WebGLObject {
  76501. }
  76502. declare var WebGLSync: {
  76503. prototype: WebGLSync;
  76504. new(): WebGLSync;
  76505. };
  76506. interface WebGLTransformFeedback extends WebGLObject {
  76507. }
  76508. declare var WebGLTransformFeedback: {
  76509. prototype: WebGLTransformFeedback;
  76510. new(): WebGLTransformFeedback;
  76511. };
  76512. interface WebGLVertexArrayObject extends WebGLObject {
  76513. }
  76514. declare var WebGLVertexArrayObject: {
  76515. prototype: WebGLVertexArrayObject;
  76516. new(): WebGLVertexArrayObject;
  76517. };
  76518. // Type definitions for WebVR API
  76519. // Project: https://w3c.github.io/webvr/
  76520. // Definitions by: six a <https://github.com/lostfictions>
  76521. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76522. interface VRDisplay extends EventTarget {
  76523. /**
  76524. * Dictionary of capabilities describing the VRDisplay.
  76525. */
  76526. readonly capabilities: VRDisplayCapabilities;
  76527. /**
  76528. * z-depth defining the far plane of the eye view frustum
  76529. * enables mapping of values in the render target depth
  76530. * attachment to scene coordinates. Initially set to 10000.0.
  76531. */
  76532. depthFar: number;
  76533. /**
  76534. * z-depth defining the near plane of the eye view frustum
  76535. * enables mapping of values in the render target depth
  76536. * attachment to scene coordinates. Initially set to 0.01.
  76537. */
  76538. depthNear: number;
  76539. /**
  76540. * An identifier for this distinct VRDisplay. Used as an
  76541. * association point in the Gamepad API.
  76542. */
  76543. readonly displayId: number;
  76544. /**
  76545. * A display name, a user-readable name identifying it.
  76546. */
  76547. readonly displayName: string;
  76548. readonly isConnected: boolean;
  76549. readonly isPresenting: boolean;
  76550. /**
  76551. * If this VRDisplay supports room-scale experiences, the optional
  76552. * stage attribute contains details on the room-scale parameters.
  76553. */
  76554. readonly stageParameters: VRStageParameters | null;
  76555. /**
  76556. * Passing the value returned by `requestAnimationFrame` to
  76557. * `cancelAnimationFrame` will unregister the callback.
  76558. * @param handle Define the hanle of the request to cancel
  76559. */
  76560. cancelAnimationFrame(handle: number): void;
  76561. /**
  76562. * Stops presenting to the VRDisplay.
  76563. * @returns a promise to know when it stopped
  76564. */
  76565. exitPresent(): Promise<void>;
  76566. /**
  76567. * Return the current VREyeParameters for the given eye.
  76568. * @param whichEye Define the eye we want the parameter for
  76569. * @returns the eye parameters
  76570. */
  76571. getEyeParameters(whichEye: string): VREyeParameters;
  76572. /**
  76573. * Populates the passed VRFrameData with the information required to render
  76574. * the current frame.
  76575. * @param frameData Define the data structure to populate
  76576. * @returns true if ok otherwise false
  76577. */
  76578. getFrameData(frameData: VRFrameData): boolean;
  76579. /**
  76580. * Get the layers currently being presented.
  76581. * @returns the list of VR layers
  76582. */
  76583. getLayers(): VRLayer[];
  76584. /**
  76585. * Return a VRPose containing the future predicted pose of the VRDisplay
  76586. * when the current frame will be presented. The value returned will not
  76587. * change until JavaScript has returned control to the browser.
  76588. *
  76589. * The VRPose will contain the position, orientation, velocity,
  76590. * and acceleration of each of these properties.
  76591. * @returns the pose object
  76592. */
  76593. getPose(): VRPose;
  76594. /**
  76595. * Return the current instantaneous pose of the VRDisplay, with no
  76596. * prediction applied.
  76597. * @returns the current instantaneous pose
  76598. */
  76599. getImmediatePose(): VRPose;
  76600. /**
  76601. * The callback passed to `requestAnimationFrame` will be called
  76602. * any time a new frame should be rendered. When the VRDisplay is
  76603. * presenting the callback will be called at the native refresh
  76604. * rate of the HMD. When not presenting this function acts
  76605. * identically to how window.requestAnimationFrame acts. Content should
  76606. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76607. * asynchronously from other displays and at differing refresh rates.
  76608. * @param callback Define the eaction to run next frame
  76609. * @returns the request handle it
  76610. */
  76611. requestAnimationFrame(callback: FrameRequestCallback): number;
  76612. /**
  76613. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76614. * Repeat calls while already presenting will update the VRLayers being displayed.
  76615. * @param layers Define the list of layer to present
  76616. * @returns a promise to know when the request has been fulfilled
  76617. */
  76618. requestPresent(layers: VRLayer[]): Promise<void>;
  76619. /**
  76620. * Reset the pose for this display, treating its current position and
  76621. * orientation as the "origin/zero" values. VRPose.position,
  76622. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76623. * updated when calling resetPose(). This should be called in only
  76624. * sitting-space experiences.
  76625. */
  76626. resetPose(): void;
  76627. /**
  76628. * The VRLayer provided to the VRDisplay will be captured and presented
  76629. * in the HMD. Calling this function has the same effect on the source
  76630. * canvas as any other operation that uses its source image, and canvases
  76631. * created without preserveDrawingBuffer set to true will be cleared.
  76632. * @param pose Define the pose to submit
  76633. */
  76634. submitFrame(pose?: VRPose): void;
  76635. }
  76636. declare var VRDisplay: {
  76637. prototype: VRDisplay;
  76638. new(): VRDisplay;
  76639. };
  76640. interface VRLayer {
  76641. leftBounds?: number[] | Float32Array | null;
  76642. rightBounds?: number[] | Float32Array | null;
  76643. source?: HTMLCanvasElement | null;
  76644. }
  76645. interface VRDisplayCapabilities {
  76646. readonly canPresent: boolean;
  76647. readonly hasExternalDisplay: boolean;
  76648. readonly hasOrientation: boolean;
  76649. readonly hasPosition: boolean;
  76650. readonly maxLayers: number;
  76651. }
  76652. interface VREyeParameters {
  76653. /** @deprecated */
  76654. readonly fieldOfView: VRFieldOfView;
  76655. readonly offset: Float32Array;
  76656. readonly renderHeight: number;
  76657. readonly renderWidth: number;
  76658. }
  76659. interface VRFieldOfView {
  76660. readonly downDegrees: number;
  76661. readonly leftDegrees: number;
  76662. readonly rightDegrees: number;
  76663. readonly upDegrees: number;
  76664. }
  76665. interface VRFrameData {
  76666. readonly leftProjectionMatrix: Float32Array;
  76667. readonly leftViewMatrix: Float32Array;
  76668. readonly pose: VRPose;
  76669. readonly rightProjectionMatrix: Float32Array;
  76670. readonly rightViewMatrix: Float32Array;
  76671. readonly timestamp: number;
  76672. }
  76673. interface VRPose {
  76674. readonly angularAcceleration: Float32Array | null;
  76675. readonly angularVelocity: Float32Array | null;
  76676. readonly linearAcceleration: Float32Array | null;
  76677. readonly linearVelocity: Float32Array | null;
  76678. readonly orientation: Float32Array | null;
  76679. readonly position: Float32Array | null;
  76680. readonly timestamp: number;
  76681. }
  76682. interface VRStageParameters {
  76683. sittingToStandingTransform?: Float32Array;
  76684. sizeX?: number;
  76685. sizeY?: number;
  76686. }
  76687. interface Navigator {
  76688. getVRDisplays(): Promise<VRDisplay[]>;
  76689. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76690. }
  76691. interface Window {
  76692. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76693. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76694. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76695. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76696. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76697. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76698. }
  76699. interface Gamepad {
  76700. readonly displayId: number;
  76701. }
  76702. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76703. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76704. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76705. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76706. type XRHandedness = "none" | "left" | "right";
  76707. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76708. type XREye = "none" | "left" | "right";
  76709. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76710. interface XRSpace extends EventTarget {}
  76711. interface XRRenderState {
  76712. depthNear?: number;
  76713. depthFar?: number;
  76714. inlineVerticalFieldOfView?: number;
  76715. baseLayer?: XRWebGLLayer;
  76716. }
  76717. interface XRInputSource {
  76718. handedness: XRHandedness;
  76719. targetRayMode: XRTargetRayMode;
  76720. targetRaySpace: XRSpace;
  76721. gripSpace: XRSpace | undefined;
  76722. gamepad: Gamepad | undefined;
  76723. profiles: Array<string>;
  76724. hand: XRHand | undefined;
  76725. }
  76726. interface XRSessionInit {
  76727. optionalFeatures?: string[];
  76728. requiredFeatures?: string[];
  76729. }
  76730. interface XRSession {
  76731. addEventListener: Function;
  76732. removeEventListener: Function;
  76733. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76734. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76735. requestAnimationFrame: Function;
  76736. end(): Promise<void>;
  76737. renderState: XRRenderState;
  76738. inputSources: Array<XRInputSource>;
  76739. // hit test
  76740. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76741. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76742. // legacy AR hit test
  76743. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76744. // legacy plane detection
  76745. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76746. }
  76747. interface XRReferenceSpace extends XRSpace {
  76748. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76749. onreset: any;
  76750. }
  76751. type XRPlaneSet = Set<XRPlane>;
  76752. type XRAnchorSet = Set<XRAnchor>;
  76753. interface XRFrame {
  76754. session: XRSession;
  76755. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76756. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76757. // AR
  76758. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76759. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76760. // Anchors
  76761. trackedAnchors?: XRAnchorSet;
  76762. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76763. // Planes
  76764. worldInformation: {
  76765. detectedPlanes?: XRPlaneSet;
  76766. };
  76767. // Hand tracking
  76768. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76769. }
  76770. interface XRViewerPose extends XRPose {
  76771. views: Array<XRView>;
  76772. }
  76773. interface XRPose {
  76774. transform: XRRigidTransform;
  76775. emulatedPosition: boolean;
  76776. }
  76777. interface XRWebGLLayerOptions {
  76778. antialias?: boolean;
  76779. depth?: boolean;
  76780. stencil?: boolean;
  76781. alpha?: boolean;
  76782. multiview?: boolean;
  76783. framebufferScaleFactor?: number;
  76784. }
  76785. declare var XRWebGLLayer: {
  76786. prototype: XRWebGLLayer;
  76787. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76788. };
  76789. interface XRWebGLLayer {
  76790. framebuffer: WebGLFramebuffer;
  76791. framebufferWidth: number;
  76792. framebufferHeight: number;
  76793. getViewport: Function;
  76794. }
  76795. declare class XRRigidTransform {
  76796. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76797. position: DOMPointReadOnly;
  76798. orientation: DOMPointReadOnly;
  76799. matrix: Float32Array;
  76800. inverse: XRRigidTransform;
  76801. }
  76802. interface XRView {
  76803. eye: XREye;
  76804. projectionMatrix: Float32Array;
  76805. transform: XRRigidTransform;
  76806. }
  76807. interface XRInputSourceChangeEvent {
  76808. session: XRSession;
  76809. removed: Array<XRInputSource>;
  76810. added: Array<XRInputSource>;
  76811. }
  76812. interface XRInputSourceEvent extends Event {
  76813. readonly frame: XRFrame;
  76814. readonly inputSource: XRInputSource;
  76815. }
  76816. // Experimental(er) features
  76817. declare class XRRay {
  76818. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76819. origin: DOMPointReadOnly;
  76820. direction: DOMPointReadOnly;
  76821. matrix: Float32Array;
  76822. }
  76823. declare enum XRHitTestTrackableType {
  76824. "point",
  76825. "plane",
  76826. "mesh",
  76827. }
  76828. interface XRHitResult {
  76829. hitMatrix: Float32Array;
  76830. }
  76831. interface XRTransientInputHitTestResult {
  76832. readonly inputSource: XRInputSource;
  76833. readonly results: Array<XRHitTestResult>;
  76834. }
  76835. interface XRHitTestResult {
  76836. getPose(baseSpace: XRSpace): XRPose | undefined;
  76837. // When anchor system is enabled
  76838. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76839. }
  76840. interface XRHitTestSource {
  76841. cancel(): void;
  76842. }
  76843. interface XRTransientInputHitTestSource {
  76844. cancel(): void;
  76845. }
  76846. interface XRHitTestOptionsInit {
  76847. space: XRSpace;
  76848. entityTypes?: Array<XRHitTestTrackableType>;
  76849. offsetRay?: XRRay;
  76850. }
  76851. interface XRTransientInputHitTestOptionsInit {
  76852. profile: string;
  76853. entityTypes?: Array<XRHitTestTrackableType>;
  76854. offsetRay?: XRRay;
  76855. }
  76856. interface XRAnchor {
  76857. anchorSpace: XRSpace;
  76858. delete(): void;
  76859. }
  76860. interface XRPlane {
  76861. orientation: "Horizontal" | "Vertical";
  76862. planeSpace: XRSpace;
  76863. polygon: Array<DOMPointReadOnly>;
  76864. lastChangedTime: number;
  76865. }
  76866. interface XRJointSpace extends XRSpace {}
  76867. interface XRJointPose extends XRPose {
  76868. radius: number | undefined;
  76869. }
  76870. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76871. readonly length: number;
  76872. [index: number]: XRJointSpace;
  76873. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76874. readonly WRIST: number;
  76875. readonly THUMB_METACARPAL: number;
  76876. readonly THUMB_PHALANX_PROXIMAL: number;
  76877. readonly THUMB_PHALANX_DISTAL: number;
  76878. readonly THUMB_PHALANX_TIP: number;
  76879. readonly INDEX_METACARPAL: number;
  76880. readonly INDEX_PHALANX_PROXIMAL: number;
  76881. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76882. readonly INDEX_PHALANX_DISTAL: number;
  76883. readonly INDEX_PHALANX_TIP: number;
  76884. readonly MIDDLE_METACARPAL: number;
  76885. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76886. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76887. readonly MIDDLE_PHALANX_DISTAL: number;
  76888. readonly MIDDLE_PHALANX_TIP: number;
  76889. readonly RING_METACARPAL: number;
  76890. readonly RING_PHALANX_PROXIMAL: number;
  76891. readonly RING_PHALANX_INTERMEDIATE: number;
  76892. readonly RING_PHALANX_DISTAL: number;
  76893. readonly RING_PHALANX_TIP: number;
  76894. readonly LITTLE_METACARPAL: number;
  76895. readonly LITTLE_PHALANX_PROXIMAL: number;
  76896. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76897. readonly LITTLE_PHALANX_DISTAL: number;
  76898. readonly LITTLE_PHALANX_TIP: number;
  76899. }
  76900. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76901. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76902. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76903. interface XRSession {
  76904. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76905. }
  76906. interface XRFrame {
  76907. featurePointCloud? : Array<number>;
  76908. }
  76909. /**
  76910. * @ignore
  76911. */
  76912. declare module BABYLON.GLTF2.Exporter {
  76913. }
  76914. /**
  76915. * @ignore
  76916. */
  76917. declare module BABYLON.GLTF1 {
  76918. }
  76919. declare module BABYLON.GUI {
  76920. /**
  76921. * Class used to specific a value and its associated unit
  76922. */
  76923. export class ValueAndUnit {
  76924. /** defines the unit to store */
  76925. unit: number;
  76926. /** defines a boolean indicating if the value can be negative */
  76927. negativeValueAllowed: boolean;
  76928. private _value;
  76929. private _originalUnit;
  76930. /**
  76931. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  76932. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76933. */
  76934. ignoreAdaptiveScaling: boolean;
  76935. /**
  76936. * Creates a new ValueAndUnit
  76937. * @param value defines the value to store
  76938. * @param unit defines the unit to store
  76939. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  76940. */
  76941. constructor(value: number,
  76942. /** defines the unit to store */
  76943. unit?: number,
  76944. /** defines a boolean indicating if the value can be negative */
  76945. negativeValueAllowed?: boolean);
  76946. /** Gets a boolean indicating if the value is a percentage */
  76947. get isPercentage(): boolean;
  76948. /** Gets a boolean indicating if the value is store as pixel */
  76949. get isPixel(): boolean;
  76950. /** Gets direct internal value */
  76951. get internalValue(): number;
  76952. /**
  76953. * Gets value as pixel
  76954. * @param host defines the root host
  76955. * @param refValue defines the reference value for percentages
  76956. * @returns the value as pixel
  76957. */
  76958. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76959. /**
  76960. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76961. * @param value defines the value to store
  76962. * @param unit defines the unit to store
  76963. * @returns the current ValueAndUnit
  76964. */
  76965. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76966. /**
  76967. * Gets the value accordingly to its unit
  76968. * @param host defines the root host
  76969. * @returns the value
  76970. */
  76971. getValue(host: AdvancedDynamicTexture): number;
  76972. /**
  76973. * Gets a string representation of the value
  76974. * @param host defines the root host
  76975. * @param decimals defines an optional number of decimals to display
  76976. * @returns a string
  76977. */
  76978. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76979. /**
  76980. * Store a value parsed from a string
  76981. * @param source defines the source string
  76982. * @returns true if the value was successfully parsed
  76983. */
  76984. fromString(source: string | number): boolean;
  76985. private static _Regex;
  76986. private static _UNITMODE_PERCENTAGE;
  76987. private static _UNITMODE_PIXEL;
  76988. /** UNITMODE_PERCENTAGE */
  76989. static get UNITMODE_PERCENTAGE(): number;
  76990. /** UNITMODE_PIXEL */
  76991. static get UNITMODE_PIXEL(): number;
  76992. }
  76993. }
  76994. declare module BABYLON.GUI {
  76995. /**
  76996. * Define a style used by control to automatically setup properties based on a template.
  76997. * Only support font related properties so far
  76998. */
  76999. export class Style implements BABYLON.IDisposable {
  77000. private _fontFamily;
  77001. private _fontStyle;
  77002. private _fontWeight;
  77003. /** @hidden */
  77004. _host: AdvancedDynamicTexture;
  77005. /** @hidden */
  77006. _fontSize: ValueAndUnit;
  77007. /**
  77008. * BABYLON.Observable raised when the style values are changed
  77009. */
  77010. onChangedObservable: BABYLON.Observable<Style>;
  77011. /**
  77012. * Creates a new style object
  77013. * @param host defines the AdvancedDynamicTexture which hosts this style
  77014. */
  77015. constructor(host: AdvancedDynamicTexture);
  77016. /**
  77017. * Gets or sets the font size
  77018. */
  77019. get fontSize(): string | number;
  77020. set fontSize(value: string | number);
  77021. /**
  77022. * Gets or sets the font family
  77023. */
  77024. get fontFamily(): string;
  77025. set fontFamily(value: string);
  77026. /**
  77027. * Gets or sets the font style
  77028. */
  77029. get fontStyle(): string;
  77030. set fontStyle(value: string);
  77031. /** Gets or sets font weight */
  77032. get fontWeight(): string;
  77033. set fontWeight(value: string);
  77034. /** Dispose all associated resources */
  77035. dispose(): void;
  77036. }
  77037. }
  77038. declare module BABYLON.GUI {
  77039. /**
  77040. * Class used to transport BABYLON.Vector2 information for pointer events
  77041. */
  77042. export class Vector2WithInfo extends BABYLON.Vector2 {
  77043. /** defines the current mouse button index */
  77044. buttonIndex: number;
  77045. /**
  77046. * Creates a new Vector2WithInfo
  77047. * @param source defines the vector2 data to transport
  77048. * @param buttonIndex defines the current mouse button index
  77049. */
  77050. constructor(source: BABYLON.Vector2,
  77051. /** defines the current mouse button index */
  77052. buttonIndex?: number);
  77053. }
  77054. /** Class used to provide 2D matrix features */
  77055. export class Matrix2D {
  77056. /** Gets the internal array of 6 floats used to store matrix data */
  77057. m: Float32Array;
  77058. /**
  77059. * Creates a new matrix
  77060. * @param m00 defines value for (0, 0)
  77061. * @param m01 defines value for (0, 1)
  77062. * @param m10 defines value for (1, 0)
  77063. * @param m11 defines value for (1, 1)
  77064. * @param m20 defines value for (2, 0)
  77065. * @param m21 defines value for (2, 1)
  77066. */
  77067. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77068. /**
  77069. * Fills the matrix from direct values
  77070. * @param m00 defines value for (0, 0)
  77071. * @param m01 defines value for (0, 1)
  77072. * @param m10 defines value for (1, 0)
  77073. * @param m11 defines value for (1, 1)
  77074. * @param m20 defines value for (2, 0)
  77075. * @param m21 defines value for (2, 1)
  77076. * @returns the current modified matrix
  77077. */
  77078. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77079. /**
  77080. * Gets matrix determinant
  77081. * @returns the determinant
  77082. */
  77083. determinant(): number;
  77084. /**
  77085. * Inverses the matrix and stores it in a target matrix
  77086. * @param result defines the target matrix
  77087. * @returns the current matrix
  77088. */
  77089. invertToRef(result: Matrix2D): Matrix2D;
  77090. /**
  77091. * Multiplies the current matrix with another one
  77092. * @param other defines the second operand
  77093. * @param result defines the target matrix
  77094. * @returns the current matrix
  77095. */
  77096. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77097. /**
  77098. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77099. * @param x defines the x coordinate to transform
  77100. * @param y defines the x coordinate to transform
  77101. * @param result defines the target vector2
  77102. * @returns the current matrix
  77103. */
  77104. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77105. /**
  77106. * Creates an identity matrix
  77107. * @returns a new matrix
  77108. */
  77109. static Identity(): Matrix2D;
  77110. /**
  77111. * Creates a translation matrix and stores it in a target matrix
  77112. * @param x defines the x coordinate of the translation
  77113. * @param y defines the y coordinate of the translation
  77114. * @param result defines the target matrix
  77115. */
  77116. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77117. /**
  77118. * Creates a scaling matrix and stores it in a target matrix
  77119. * @param x defines the x coordinate of the scaling
  77120. * @param y defines the y coordinate of the scaling
  77121. * @param result defines the target matrix
  77122. */
  77123. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77124. /**
  77125. * Creates a rotation matrix and stores it in a target matrix
  77126. * @param angle defines the rotation angle
  77127. * @param result defines the target matrix
  77128. */
  77129. static RotationToRef(angle: number, result: Matrix2D): void;
  77130. private static _TempPreTranslationMatrix;
  77131. private static _TempPostTranslationMatrix;
  77132. private static _TempRotationMatrix;
  77133. private static _TempScalingMatrix;
  77134. private static _TempCompose0;
  77135. private static _TempCompose1;
  77136. private static _TempCompose2;
  77137. /**
  77138. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77139. * @param tx defines the x coordinate of the translation
  77140. * @param ty defines the y coordinate of the translation
  77141. * @param angle defines the rotation angle
  77142. * @param scaleX defines the x coordinate of the scaling
  77143. * @param scaleY defines the y coordinate of the scaling
  77144. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77145. * @param result defines the target matrix
  77146. */
  77147. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77148. }
  77149. }
  77150. declare module BABYLON.GUI {
  77151. /**
  77152. * Class used to store 2D control sizes
  77153. */
  77154. export class Measure {
  77155. /** defines left coordinate */
  77156. left: number;
  77157. /** defines top coordinate */
  77158. top: number;
  77159. /** defines width dimension */
  77160. width: number;
  77161. /** defines height dimension */
  77162. height: number;
  77163. /**
  77164. * Creates a new measure
  77165. * @param left defines left coordinate
  77166. * @param top defines top coordinate
  77167. * @param width defines width dimension
  77168. * @param height defines height dimension
  77169. */
  77170. constructor(
  77171. /** defines left coordinate */
  77172. left: number,
  77173. /** defines top coordinate */
  77174. top: number,
  77175. /** defines width dimension */
  77176. width: number,
  77177. /** defines height dimension */
  77178. height: number);
  77179. /**
  77180. * Copy from another measure
  77181. * @param other defines the other measure to copy from
  77182. */
  77183. copyFrom(other: Measure): void;
  77184. /**
  77185. * Copy from a group of 4 floats
  77186. * @param left defines left coordinate
  77187. * @param top defines top coordinate
  77188. * @param width defines width dimension
  77189. * @param height defines height dimension
  77190. */
  77191. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77192. /**
  77193. * Computes the axis aligned bounding box measure for two given measures
  77194. * @param a Input measure
  77195. * @param b Input measure
  77196. * @param result the resulting bounding measure
  77197. */
  77198. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77199. /**
  77200. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77201. * @param transform the matrix to transform the measure before computing the AABB
  77202. * @param addX number to add to left
  77203. * @param addY number to add to top
  77204. * @param addWidth number to add to width
  77205. * @param addHeight number to add to height
  77206. * @param result the resulting AABB
  77207. */
  77208. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77209. /**
  77210. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77211. * @param transform the matrix to transform the measure before computing the AABB
  77212. * @param result the resulting AABB
  77213. */
  77214. transformToRef(transform: Matrix2D, result: Measure): void;
  77215. /**
  77216. * Check equality between this measure and another one
  77217. * @param other defines the other measures
  77218. * @returns true if both measures are equals
  77219. */
  77220. isEqualsTo(other: Measure): boolean;
  77221. /**
  77222. * Creates an empty measure
  77223. * @returns a new measure
  77224. */
  77225. static Empty(): Measure;
  77226. }
  77227. }
  77228. declare module BABYLON.GUI {
  77229. /**
  77230. * Interface used to define a control that can receive focus
  77231. */
  77232. export interface IFocusableControl {
  77233. /**
  77234. * Function called when the control receives the focus
  77235. */
  77236. onFocus(): void;
  77237. /**
  77238. * Function called when the control loses the focus
  77239. */
  77240. onBlur(): void;
  77241. /**
  77242. * Function called to let the control handle keyboard events
  77243. * @param evt defines the current keyboard event
  77244. */
  77245. processKeyboard(evt: KeyboardEvent): void;
  77246. /**
  77247. * Function called to get the list of controls that should not steal the focus from this control
  77248. * @returns an array of controls
  77249. */
  77250. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77251. }
  77252. /**
  77253. * Class used to create texture to support 2D GUI elements
  77254. * @see https://doc.babylonjs.com/how_to/gui
  77255. */
  77256. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77257. private _isDirty;
  77258. private _renderObserver;
  77259. private _resizeObserver;
  77260. private _preKeyboardObserver;
  77261. private _pointerMoveObserver;
  77262. private _pointerObserver;
  77263. private _canvasPointerOutObserver;
  77264. private _canvasBlurObserver;
  77265. private _background;
  77266. /** @hidden */
  77267. _rootContainer: Container;
  77268. /** @hidden */
  77269. _lastPickedControl: Control;
  77270. /** @hidden */
  77271. _lastControlOver: {
  77272. [pointerId: number]: Control;
  77273. };
  77274. /** @hidden */
  77275. _lastControlDown: {
  77276. [pointerId: number]: Control;
  77277. };
  77278. /** @hidden */
  77279. _capturingControl: {
  77280. [pointerId: number]: Control;
  77281. };
  77282. /** @hidden */
  77283. _shouldBlockPointer: boolean;
  77284. /** @hidden */
  77285. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77286. /** @hidden */
  77287. _linkedControls: Control[];
  77288. private _isFullscreen;
  77289. private _fullscreenViewport;
  77290. private _idealWidth;
  77291. private _idealHeight;
  77292. private _useSmallestIdeal;
  77293. private _renderAtIdealSize;
  77294. private _focusedControl;
  77295. private _blockNextFocusCheck;
  77296. private _renderScale;
  77297. private _rootElement;
  77298. private _cursorChanged;
  77299. private _defaultMousePointerId;
  77300. /** @hidden */
  77301. _numLayoutCalls: number;
  77302. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77303. get numLayoutCalls(): number;
  77304. /** @hidden */
  77305. _numRenderCalls: number;
  77306. /** Gets the number of render calls made the last time the ADT has been rendered */
  77307. get numRenderCalls(): number;
  77308. /**
  77309. * Define type to string to ensure compatibility across browsers
  77310. * Safari doesn't support DataTransfer constructor
  77311. */
  77312. private _clipboardData;
  77313. /**
  77314. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77315. */
  77316. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77317. /**
  77318. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77319. */
  77320. onControlPickedObservable: BABYLON.Observable<Control>;
  77321. /**
  77322. * BABYLON.Observable event triggered before layout is evaluated
  77323. */
  77324. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77325. /**
  77326. * BABYLON.Observable event triggered after the layout was evaluated
  77327. */
  77328. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77329. /**
  77330. * BABYLON.Observable event triggered before the texture is rendered
  77331. */
  77332. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77333. /**
  77334. * BABYLON.Observable event triggered after the texture was rendered
  77335. */
  77336. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77337. /**
  77338. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77339. */
  77340. premulAlpha: boolean;
  77341. /**
  77342. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77343. * Useful when you want more antialiasing
  77344. */
  77345. get renderScale(): number;
  77346. set renderScale(value: number);
  77347. /** Gets or sets the background color */
  77348. get background(): string;
  77349. set background(value: string);
  77350. /**
  77351. * Gets or sets the ideal width used to design controls.
  77352. * The GUI will then rescale everything accordingly
  77353. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77354. */
  77355. get idealWidth(): number;
  77356. set idealWidth(value: number);
  77357. /**
  77358. * Gets or sets the ideal height used to design controls.
  77359. * The GUI will then rescale everything accordingly
  77360. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77361. */
  77362. get idealHeight(): number;
  77363. set idealHeight(value: number);
  77364. /**
  77365. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77366. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77367. */
  77368. get useSmallestIdeal(): boolean;
  77369. set useSmallestIdeal(value: boolean);
  77370. /**
  77371. * Gets or sets a boolean indicating if adaptive scaling must be used
  77372. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77373. */
  77374. get renderAtIdealSize(): boolean;
  77375. set renderAtIdealSize(value: boolean);
  77376. /**
  77377. * Gets the ratio used when in "ideal mode"
  77378. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77379. * */
  77380. get idealRatio(): number;
  77381. /**
  77382. * Gets the underlying layer used to render the texture when in fullscreen mode
  77383. */
  77384. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77385. /**
  77386. * Gets the root container control
  77387. */
  77388. get rootContainer(): Container;
  77389. /**
  77390. * Returns an array containing the root container.
  77391. * This is mostly used to let the Inspector introspects the ADT
  77392. * @returns an array containing the rootContainer
  77393. */
  77394. getChildren(): Array<Container>;
  77395. /**
  77396. * Will return all controls that are inside this texture
  77397. * @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
  77398. * @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
  77399. * @return all child controls
  77400. */
  77401. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77402. /**
  77403. * Gets or sets the current focused control
  77404. */
  77405. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77406. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77407. /**
  77408. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77409. */
  77410. get isForeground(): boolean;
  77411. set isForeground(value: boolean);
  77412. /**
  77413. * Gets or set information about clipboardData
  77414. */
  77415. get clipboardData(): string;
  77416. set clipboardData(value: string);
  77417. /**
  77418. * Creates a new AdvancedDynamicTexture
  77419. * @param name defines the name of the texture
  77420. * @param width defines the width of the texture
  77421. * @param height defines the height of the texture
  77422. * @param scene defines the hosting scene
  77423. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77424. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77425. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77426. */
  77427. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  77428. /**
  77429. * Get the current class name of the texture useful for serialization or dynamic coding.
  77430. * @returns "AdvancedDynamicTexture"
  77431. */
  77432. getClassName(): string;
  77433. /**
  77434. * Function used to execute a function on all controls
  77435. * @param func defines the function to execute
  77436. * @param container defines the container where controls belong. If null the root container will be used
  77437. */
  77438. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77439. private _useInvalidateRectOptimization;
  77440. /**
  77441. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77442. */
  77443. get useInvalidateRectOptimization(): boolean;
  77444. set useInvalidateRectOptimization(value: boolean);
  77445. private _invalidatedRectangle;
  77446. /**
  77447. * Invalidates a rectangle area on the gui texture
  77448. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77449. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77450. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77451. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77452. */
  77453. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77454. /**
  77455. * Marks the texture as dirty forcing a complete update
  77456. */
  77457. markAsDirty(): void;
  77458. /**
  77459. * Helper function used to create a new style
  77460. * @returns a new style
  77461. * @see https://doc.babylonjs.com/how_to/gui#styles
  77462. */
  77463. createStyle(): Style;
  77464. /**
  77465. * Adds a new control to the root container
  77466. * @param control defines the control to add
  77467. * @returns the current texture
  77468. */
  77469. addControl(control: Control): AdvancedDynamicTexture;
  77470. /**
  77471. * Removes a control from the root container
  77472. * @param control defines the control to remove
  77473. * @returns the current texture
  77474. */
  77475. removeControl(control: Control): AdvancedDynamicTexture;
  77476. /**
  77477. * Release all resources
  77478. */
  77479. dispose(): void;
  77480. private _onResize;
  77481. /** @hidden */
  77482. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77483. /**
  77484. * Get screen coordinates for a vector3
  77485. * @param position defines the position to project
  77486. * @param worldMatrix defines the world matrix to use
  77487. * @returns the projected position
  77488. */
  77489. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77490. private _checkUpdate;
  77491. private _clearMeasure;
  77492. private _render;
  77493. /** @hidden */
  77494. _changeCursor(cursor: string): void;
  77495. /** @hidden */
  77496. _registerLastControlDown(control: Control, pointerId: number): void;
  77497. private _doPicking;
  77498. /** @hidden */
  77499. _cleanControlAfterRemovalFromList(list: {
  77500. [pointerId: number]: Control;
  77501. }, control: Control): void;
  77502. /** @hidden */
  77503. _cleanControlAfterRemoval(control: Control): void;
  77504. /** Attach to all scene events required to support pointer events */
  77505. attach(): void;
  77506. /** @hidden */
  77507. private onClipboardCopy;
  77508. /** @hidden */
  77509. private onClipboardCut;
  77510. /** @hidden */
  77511. private onClipboardPaste;
  77512. /**
  77513. * Register the clipboard Events onto the canvas
  77514. */
  77515. registerClipboardEvents(): void;
  77516. /**
  77517. * Unregister the clipboard Events from the canvas
  77518. */
  77519. unRegisterClipboardEvents(): void;
  77520. /**
  77521. * Connect the texture to a hosting mesh to enable interactions
  77522. * @param mesh defines the mesh to attach to
  77523. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77524. */
  77525. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77526. /**
  77527. * Move the focus to a specific control
  77528. * @param control defines the control which will receive the focus
  77529. */
  77530. moveFocusToControl(control: IFocusableControl): void;
  77531. private _manageFocus;
  77532. private _attachToOnPointerOut;
  77533. private _attachToOnBlur;
  77534. /**
  77535. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77536. * @param mesh defines the mesh which will receive the texture
  77537. * @param width defines the texture width (1024 by default)
  77538. * @param height defines the texture height (1024 by default)
  77539. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77540. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77541. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77542. * @returns a new AdvancedDynamicTexture
  77543. */
  77544. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  77545. /**
  77546. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77547. * In this mode the texture will rely on a layer for its rendering.
  77548. * This allows it to be treated like any other layer.
  77549. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77550. * LayerMask is set through advancedTexture.layer.layerMask
  77551. * @param name defines name for the texture
  77552. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77553. * @param scene defines the hsoting scene
  77554. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77555. * @returns a new AdvancedDynamicTexture
  77556. */
  77557. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77558. }
  77559. }
  77560. declare module BABYLON.GUI {
  77561. /**
  77562. * Root class used for all 2D controls
  77563. * @see https://doc.babylonjs.com/how_to/gui#controls
  77564. */
  77565. export class Control {
  77566. /** defines the name of the control */
  77567. name?: string | undefined;
  77568. /**
  77569. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77570. */
  77571. static AllowAlphaInheritance: boolean;
  77572. private _alpha;
  77573. private _alphaSet;
  77574. private _zIndex;
  77575. /** @hidden */
  77576. _host: AdvancedDynamicTexture;
  77577. /** Gets or sets the control parent */
  77578. parent: BABYLON.Nullable<Container>;
  77579. /** @hidden */
  77580. _currentMeasure: Measure;
  77581. private _fontFamily;
  77582. private _fontStyle;
  77583. private _fontWeight;
  77584. private _fontSize;
  77585. private _font;
  77586. /** @hidden */
  77587. _width: ValueAndUnit;
  77588. /** @hidden */
  77589. _height: ValueAndUnit;
  77590. /** @hidden */
  77591. protected _fontOffset: {
  77592. ascent: number;
  77593. height: number;
  77594. descent: number;
  77595. };
  77596. private _color;
  77597. private _style;
  77598. private _styleObserver;
  77599. /** @hidden */
  77600. protected _horizontalAlignment: number;
  77601. /** @hidden */
  77602. protected _verticalAlignment: number;
  77603. /** @hidden */
  77604. protected _isDirty: boolean;
  77605. /** @hidden */
  77606. protected _wasDirty: boolean;
  77607. /** @hidden */
  77608. _tempParentMeasure: Measure;
  77609. /** @hidden */
  77610. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77611. /** @hidden */
  77612. protected _cachedParentMeasure: Measure;
  77613. private _paddingLeft;
  77614. private _paddingRight;
  77615. private _paddingTop;
  77616. private _paddingBottom;
  77617. /** @hidden */
  77618. _left: ValueAndUnit;
  77619. /** @hidden */
  77620. _top: ValueAndUnit;
  77621. private _scaleX;
  77622. private _scaleY;
  77623. private _rotation;
  77624. private _transformCenterX;
  77625. private _transformCenterY;
  77626. /** @hidden */
  77627. _transformMatrix: Matrix2D;
  77628. /** @hidden */
  77629. protected _invertTransformMatrix: Matrix2D;
  77630. /** @hidden */
  77631. protected _transformedPosition: BABYLON.Vector2;
  77632. private _isMatrixDirty;
  77633. private _cachedOffsetX;
  77634. private _cachedOffsetY;
  77635. private _isVisible;
  77636. private _isHighlighted;
  77637. /** @hidden */
  77638. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  77639. private _fontSet;
  77640. private _dummyVector2;
  77641. private _downCount;
  77642. private _enterCount;
  77643. private _doNotRender;
  77644. private _downPointerIds;
  77645. protected _isEnabled: boolean;
  77646. protected _disabledColor: string;
  77647. protected _disabledColorItem: string;
  77648. /** @hidden */
  77649. protected _rebuildLayout: boolean;
  77650. /** @hidden */
  77651. _customData: any;
  77652. /** @hidden */
  77653. _isClipped: boolean;
  77654. /** @hidden */
  77655. _automaticSize: boolean;
  77656. /** @hidden */
  77657. _tag: any;
  77658. /**
  77659. * 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
  77660. */
  77661. uniqueId: number;
  77662. /**
  77663. * Gets or sets an object used to store user defined information for the node
  77664. */
  77665. metadata: any;
  77666. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77667. isHitTestVisible: boolean;
  77668. /** Gets or sets a boolean indicating if the control can block pointer events */
  77669. isPointerBlocker: boolean;
  77670. /** Gets or sets a boolean indicating if the control can be focusable */
  77671. isFocusInvisible: boolean;
  77672. /**
  77673. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77674. * 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
  77675. */
  77676. clipChildren: boolean;
  77677. /**
  77678. * Gets or sets a boolean indicating that control content must be clipped
  77679. * 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
  77680. */
  77681. clipContent: boolean;
  77682. /**
  77683. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77684. */
  77685. useBitmapCache: boolean;
  77686. private _cacheData;
  77687. private _shadowOffsetX;
  77688. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77689. get shadowOffsetX(): number;
  77690. set shadowOffsetX(value: number);
  77691. private _shadowOffsetY;
  77692. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77693. get shadowOffsetY(): number;
  77694. set shadowOffsetY(value: number);
  77695. private _shadowBlur;
  77696. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77697. get shadowBlur(): number;
  77698. set shadowBlur(value: number);
  77699. private _shadowColor;
  77700. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77701. get shadowColor(): string;
  77702. set shadowColor(value: string);
  77703. /** Gets or sets the cursor to use when the control is hovered */
  77704. hoverCursor: string;
  77705. /** @hidden */
  77706. protected _linkOffsetX: ValueAndUnit;
  77707. /** @hidden */
  77708. protected _linkOffsetY: ValueAndUnit;
  77709. /** Gets the control type name */
  77710. get typeName(): string;
  77711. /**
  77712. * Get the current class name of the control.
  77713. * @returns current class name
  77714. */
  77715. getClassName(): string;
  77716. /**
  77717. * An event triggered when pointer wheel is scrolled
  77718. */
  77719. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77720. /**
  77721. * An event triggered when the pointer move over the control.
  77722. */
  77723. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77724. /**
  77725. * An event triggered when the pointer move out of the control.
  77726. */
  77727. onPointerOutObservable: BABYLON.Observable<Control>;
  77728. /**
  77729. * An event triggered when the pointer taps the control
  77730. */
  77731. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77732. /**
  77733. * An event triggered when pointer up
  77734. */
  77735. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77736. /**
  77737. * An event triggered when a control is clicked on
  77738. */
  77739. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77740. /**
  77741. * An event triggered when pointer enters the control
  77742. */
  77743. onPointerEnterObservable: BABYLON.Observable<Control>;
  77744. /**
  77745. * An event triggered when the control is marked as dirty
  77746. */
  77747. onDirtyObservable: BABYLON.Observable<Control>;
  77748. /**
  77749. * An event triggered before drawing the control
  77750. */
  77751. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77752. /**
  77753. * An event triggered after the control was drawn
  77754. */
  77755. onAfterDrawObservable: BABYLON.Observable<Control>;
  77756. /**
  77757. * An event triggered when the control has been disposed
  77758. */
  77759. onDisposeObservable: BABYLON.Observable<Control>;
  77760. /**
  77761. * Get the hosting AdvancedDynamicTexture
  77762. */
  77763. get host(): AdvancedDynamicTexture;
  77764. /** Gets or set information about font offsets (used to render and align text) */
  77765. get fontOffset(): {
  77766. ascent: number;
  77767. height: number;
  77768. descent: number;
  77769. };
  77770. set fontOffset(offset: {
  77771. ascent: number;
  77772. height: number;
  77773. descent: number;
  77774. });
  77775. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77776. get alpha(): number;
  77777. set alpha(value: number);
  77778. /**
  77779. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77780. */
  77781. get isHighlighted(): boolean;
  77782. set isHighlighted(value: boolean);
  77783. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77784. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77785. */
  77786. get scaleX(): number;
  77787. set scaleX(value: number);
  77788. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77789. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77790. */
  77791. get scaleY(): number;
  77792. set scaleY(value: number);
  77793. /** Gets or sets the rotation angle (0 by default)
  77794. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77795. */
  77796. get rotation(): number;
  77797. set rotation(value: number);
  77798. /** Gets or sets the transformation center on Y axis (0 by default)
  77799. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77800. */
  77801. get transformCenterY(): number;
  77802. set transformCenterY(value: number);
  77803. /** Gets or sets the transformation center on X axis (0 by default)
  77804. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77805. */
  77806. get transformCenterX(): number;
  77807. set transformCenterX(value: number);
  77808. /**
  77809. * Gets or sets the horizontal alignment
  77810. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77811. */
  77812. get horizontalAlignment(): number;
  77813. set horizontalAlignment(value: number);
  77814. /**
  77815. * Gets or sets the vertical alignment
  77816. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77817. */
  77818. get verticalAlignment(): number;
  77819. set verticalAlignment(value: number);
  77820. /**
  77821. * Gets or sets a fixed ratio for this control.
  77822. * When different from 0, the ratio is used to compute the "second" dimension.
  77823. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77824. * second dimension is computed as first dimension * fixedRatio
  77825. */
  77826. fixedRatio: number;
  77827. private _fixedRatioMasterIsWidth;
  77828. /**
  77829. * Gets or sets control width
  77830. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77831. */
  77832. get width(): string | number;
  77833. set width(value: string | number);
  77834. /**
  77835. * Gets or sets the control width in pixel
  77836. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77837. */
  77838. get widthInPixels(): number;
  77839. set widthInPixels(value: number);
  77840. /**
  77841. * Gets or sets control height
  77842. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77843. */
  77844. get height(): string | number;
  77845. set height(value: string | number);
  77846. /**
  77847. * Gets or sets control height in pixel
  77848. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77849. */
  77850. get heightInPixels(): number;
  77851. set heightInPixels(value: number);
  77852. /** Gets or set font family */
  77853. get fontFamily(): string;
  77854. set fontFamily(value: string);
  77855. /** Gets or sets font style */
  77856. get fontStyle(): string;
  77857. set fontStyle(value: string);
  77858. /** Gets or sets font weight */
  77859. get fontWeight(): string;
  77860. set fontWeight(value: string);
  77861. /**
  77862. * Gets or sets style
  77863. * @see https://doc.babylonjs.com/how_to/gui#styles
  77864. */
  77865. get style(): BABYLON.Nullable<Style>;
  77866. set style(value: BABYLON.Nullable<Style>);
  77867. /** @hidden */
  77868. get _isFontSizeInPercentage(): boolean;
  77869. /** Gets or sets font size in pixels */
  77870. get fontSizeInPixels(): number;
  77871. set fontSizeInPixels(value: number);
  77872. /** Gets or sets font size */
  77873. get fontSize(): string | number;
  77874. set fontSize(value: string | number);
  77875. /** Gets or sets foreground color */
  77876. get color(): string;
  77877. set color(value: string);
  77878. /** Gets or sets z index which is used to reorder controls on the z axis */
  77879. get zIndex(): number;
  77880. set zIndex(value: number);
  77881. /** Gets or sets a boolean indicating if the control can be rendered */
  77882. get notRenderable(): boolean;
  77883. set notRenderable(value: boolean);
  77884. /** Gets or sets a boolean indicating if the control is visible */
  77885. get isVisible(): boolean;
  77886. set isVisible(value: boolean);
  77887. /** Gets a boolean indicating that the control needs to update its rendering */
  77888. get isDirty(): boolean;
  77889. /**
  77890. * Gets the current linked mesh (or null if none)
  77891. */
  77892. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77893. /**
  77894. * Gets or sets a value indicating the padding to use on the left of the control
  77895. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77896. */
  77897. get paddingLeft(): string | number;
  77898. set paddingLeft(value: string | number);
  77899. /**
  77900. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  77901. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77902. */
  77903. get paddingLeftInPixels(): number;
  77904. set paddingLeftInPixels(value: number);
  77905. /**
  77906. * Gets or sets a value indicating the padding to use on the right of the control
  77907. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77908. */
  77909. get paddingRight(): string | number;
  77910. set paddingRight(value: string | number);
  77911. /**
  77912. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  77913. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77914. */
  77915. get paddingRightInPixels(): number;
  77916. set paddingRightInPixels(value: number);
  77917. /**
  77918. * Gets or sets a value indicating the padding to use on the top of the control
  77919. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77920. */
  77921. get paddingTop(): string | number;
  77922. set paddingTop(value: string | number);
  77923. /**
  77924. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  77925. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77926. */
  77927. get paddingTopInPixels(): number;
  77928. set paddingTopInPixels(value: number);
  77929. /**
  77930. * Gets or sets a value indicating the padding to use on the bottom of the control
  77931. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77932. */
  77933. get paddingBottom(): string | number;
  77934. set paddingBottom(value: string | number);
  77935. /**
  77936. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  77937. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77938. */
  77939. get paddingBottomInPixels(): number;
  77940. set paddingBottomInPixels(value: number);
  77941. /**
  77942. * Gets or sets a value indicating the left coordinate of the control
  77943. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77944. */
  77945. get left(): string | number;
  77946. set left(value: string | number);
  77947. /**
  77948. * Gets or sets a value indicating the left coordinate in pixels of the control
  77949. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77950. */
  77951. get leftInPixels(): number;
  77952. set leftInPixels(value: number);
  77953. /**
  77954. * Gets or sets a value indicating the top coordinate of the control
  77955. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77956. */
  77957. get top(): string | number;
  77958. set top(value: string | number);
  77959. /**
  77960. * Gets or sets a value indicating the top coordinate in pixels of the control
  77961. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77962. */
  77963. get topInPixels(): number;
  77964. set topInPixels(value: number);
  77965. /**
  77966. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77967. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77968. */
  77969. get linkOffsetX(): string | number;
  77970. set linkOffsetX(value: string | number);
  77971. /**
  77972. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77973. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77974. */
  77975. get linkOffsetXInPixels(): number;
  77976. set linkOffsetXInPixels(value: number);
  77977. /**
  77978. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77979. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77980. */
  77981. get linkOffsetY(): string | number;
  77982. set linkOffsetY(value: string | number);
  77983. /**
  77984. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77985. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77986. */
  77987. get linkOffsetYInPixels(): number;
  77988. set linkOffsetYInPixels(value: number);
  77989. /** Gets the center coordinate on X axis */
  77990. get centerX(): number;
  77991. /** Gets the center coordinate on Y axis */
  77992. get centerY(): number;
  77993. /** Gets or sets if control is Enabled*/
  77994. get isEnabled(): boolean;
  77995. set isEnabled(value: boolean);
  77996. /** Gets or sets background color of control if it's disabled*/
  77997. get disabledColor(): string;
  77998. set disabledColor(value: string);
  77999. /** Gets or sets front color of control if it's disabled*/
  78000. get disabledColorItem(): string;
  78001. set disabledColorItem(value: string);
  78002. /**
  78003. * Creates a new control
  78004. * @param name defines the name of the control
  78005. */
  78006. constructor(
  78007. /** defines the name of the control */
  78008. name?: string | undefined);
  78009. /** @hidden */
  78010. protected _getTypeName(): string;
  78011. /**
  78012. * Gets the first ascendant in the hierarchy of the given type
  78013. * @param className defines the required type
  78014. * @returns the ascendant or null if not found
  78015. */
  78016. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78017. /** @hidden */
  78018. _resetFontCache(): void;
  78019. /**
  78020. * Determines if a container is an ascendant of the current control
  78021. * @param container defines the container to look for
  78022. * @returns true if the container is one of the ascendant of the control
  78023. */
  78024. isAscendant(container: Control): boolean;
  78025. /**
  78026. * Gets coordinates in local control space
  78027. * @param globalCoordinates defines the coordinates to transform
  78028. * @returns the new coordinates in local space
  78029. */
  78030. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78031. /**
  78032. * Gets coordinates in local control space
  78033. * @param globalCoordinates defines the coordinates to transform
  78034. * @param result defines the target vector2 where to store the result
  78035. * @returns the current control
  78036. */
  78037. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78038. /**
  78039. * Gets coordinates in parent local control space
  78040. * @param globalCoordinates defines the coordinates to transform
  78041. * @returns the new coordinates in parent local space
  78042. */
  78043. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78044. /**
  78045. * Move the current control to a vector3 position projected onto the screen.
  78046. * @param position defines the target position
  78047. * @param scene defines the hosting scene
  78048. */
  78049. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78050. /**
  78051. * Will store all controls that have this control as ascendant in a given array
  78052. * @param results defines the array where to store the descendants
  78053. * @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
  78054. * @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
  78055. */
  78056. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78057. /**
  78058. * Will return all controls that have this control as ascendant
  78059. * @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
  78060. * @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
  78061. * @return all child controls
  78062. */
  78063. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78064. /**
  78065. * Link current control with a target mesh
  78066. * @param mesh defines the mesh to link with
  78067. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78068. */
  78069. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  78070. /** @hidden */
  78071. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78072. /** @hidden */
  78073. _offsetLeft(offset: number): void;
  78074. /** @hidden */
  78075. _offsetTop(offset: number): void;
  78076. /** @hidden */
  78077. _markMatrixAsDirty(): void;
  78078. /** @hidden */
  78079. _flagDescendantsAsMatrixDirty(): void;
  78080. /** @hidden */
  78081. _intersectsRect(rect: Measure): boolean;
  78082. /** @hidden */
  78083. protected invalidateRect(): void;
  78084. /** @hidden */
  78085. _markAsDirty(force?: boolean): void;
  78086. /** @hidden */
  78087. _markAllAsDirty(): void;
  78088. /** @hidden */
  78089. _link(host: AdvancedDynamicTexture): void;
  78090. /** @hidden */
  78091. protected _transform(context?: CanvasRenderingContext2D): void;
  78092. /** @hidden */
  78093. _renderHighlight(context: CanvasRenderingContext2D): void;
  78094. /** @hidden */
  78095. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78096. /** @hidden */
  78097. protected _applyStates(context: CanvasRenderingContext2D): void;
  78098. /** @hidden */
  78099. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78100. /** @hidden */
  78101. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78102. protected _evaluateClippingState(parentMeasure: Measure): void;
  78103. /** @hidden */
  78104. _measure(): void;
  78105. /** @hidden */
  78106. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78107. /** @hidden */
  78108. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78109. /** @hidden */
  78110. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78111. /** @hidden */
  78112. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78113. private static _ClipMeasure;
  78114. private _tmpMeasureA;
  78115. private _clip;
  78116. /** @hidden */
  78117. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78118. /** @hidden */
  78119. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78120. /**
  78121. * Tests if a given coordinates belong to the current control
  78122. * @param x defines x coordinate to test
  78123. * @param y defines y coordinate to test
  78124. * @returns true if the coordinates are inside the control
  78125. */
  78126. contains(x: number, y: number): boolean;
  78127. /** @hidden */
  78128. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78129. /** @hidden */
  78130. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78131. /** @hidden */
  78132. _onPointerEnter(target: Control): boolean;
  78133. /** @hidden */
  78134. _onPointerOut(target: Control, force?: boolean): void;
  78135. /** @hidden */
  78136. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78137. /** @hidden */
  78138. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78139. /** @hidden */
  78140. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78141. /** @hidden */
  78142. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78143. /** @hidden */
  78144. _onCanvasBlur(): void;
  78145. /** @hidden */
  78146. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78147. private _prepareFont;
  78148. /** Releases associated resources */
  78149. dispose(): void;
  78150. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78151. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78152. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78153. private static _VERTICAL_ALIGNMENT_TOP;
  78154. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78155. private static _VERTICAL_ALIGNMENT_CENTER;
  78156. /** HORIZONTAL_ALIGNMENT_LEFT */
  78157. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78158. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78159. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78160. /** HORIZONTAL_ALIGNMENT_CENTER */
  78161. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78162. /** VERTICAL_ALIGNMENT_TOP */
  78163. static get VERTICAL_ALIGNMENT_TOP(): number;
  78164. /** VERTICAL_ALIGNMENT_BOTTOM */
  78165. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78166. /** VERTICAL_ALIGNMENT_CENTER */
  78167. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78168. private static _FontHeightSizes;
  78169. /** @hidden */
  78170. static _GetFontOffset(font: string): {
  78171. ascent: number;
  78172. height: number;
  78173. descent: number;
  78174. };
  78175. /**
  78176. * Creates a stack panel that can be used to render headers
  78177. * @param control defines the control to associate with the header
  78178. * @param text defines the text of the header
  78179. * @param size defines the size of the header
  78180. * @param options defines options used to configure the header
  78181. * @returns a new StackPanel
  78182. * @ignore
  78183. * @hidden
  78184. */
  78185. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78186. isHorizontal: boolean;
  78187. controlFirst: boolean;
  78188. }) => any;
  78189. /** @hidden */
  78190. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78191. }
  78192. }
  78193. declare module BABYLON.GUI {
  78194. /**
  78195. * Root class for 2D containers
  78196. * @see https://doc.babylonjs.com/how_to/gui#containers
  78197. */
  78198. export class Container extends Control {
  78199. name?: string | undefined;
  78200. /** @hidden */
  78201. _children: Control[];
  78202. /** @hidden */
  78203. protected _measureForChildren: Measure;
  78204. /** @hidden */
  78205. protected _background: string;
  78206. /** @hidden */
  78207. protected _adaptWidthToChildren: boolean;
  78208. /** @hidden */
  78209. protected _adaptHeightToChildren: boolean;
  78210. /**
  78211. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78212. */
  78213. logLayoutCycleErrors: boolean;
  78214. /**
  78215. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78216. */
  78217. maxLayoutCycle: number;
  78218. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78219. get adaptHeightToChildren(): boolean;
  78220. set adaptHeightToChildren(value: boolean);
  78221. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78222. get adaptWidthToChildren(): boolean;
  78223. set adaptWidthToChildren(value: boolean);
  78224. /** Gets or sets background color */
  78225. get background(): string;
  78226. set background(value: string);
  78227. /** Gets the list of children */
  78228. get children(): Control[];
  78229. /**
  78230. * Creates a new Container
  78231. * @param name defines the name of the container
  78232. */
  78233. constructor(name?: string | undefined);
  78234. protected _getTypeName(): string;
  78235. _flagDescendantsAsMatrixDirty(): void;
  78236. /**
  78237. * Gets a child using its name
  78238. * @param name defines the child name to look for
  78239. * @returns the child control if found
  78240. */
  78241. getChildByName(name: string): BABYLON.Nullable<Control>;
  78242. /**
  78243. * Gets a child using its type and its name
  78244. * @param name defines the child name to look for
  78245. * @param type defines the child type to look for
  78246. * @returns the child control if found
  78247. */
  78248. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78249. /**
  78250. * Search for a specific control in children
  78251. * @param control defines the control to look for
  78252. * @returns true if the control is in child list
  78253. */
  78254. containsControl(control: Control): boolean;
  78255. /**
  78256. * Adds a new control to the current container
  78257. * @param control defines the control to add
  78258. * @returns the current container
  78259. */
  78260. addControl(control: BABYLON.Nullable<Control>): Container;
  78261. /**
  78262. * Removes all controls from the current container
  78263. * @returns the current container
  78264. */
  78265. clearControls(): Container;
  78266. /**
  78267. * Removes a control from the current container
  78268. * @param control defines the control to remove
  78269. * @returns the current container
  78270. */
  78271. removeControl(control: Control): Container;
  78272. /** @hidden */
  78273. _reOrderControl(control: Control): void;
  78274. /** @hidden */
  78275. _offsetLeft(offset: number): void;
  78276. /** @hidden */
  78277. _offsetTop(offset: number): void;
  78278. /** @hidden */
  78279. _markAllAsDirty(): void;
  78280. /** @hidden */
  78281. protected _localDraw(context: CanvasRenderingContext2D): void;
  78282. /** @hidden */
  78283. _link(host: AdvancedDynamicTexture): void;
  78284. /** @hidden */
  78285. protected _beforeLayout(): void;
  78286. /** @hidden */
  78287. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78288. /** @hidden */
  78289. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78290. protected _postMeasure(): void;
  78291. /** @hidden */
  78292. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78293. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78294. /** @hidden */
  78295. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78296. /** @hidden */
  78297. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78298. /** Releases associated resources */
  78299. dispose(): void;
  78300. }
  78301. }
  78302. declare module BABYLON.GUI {
  78303. /** Class used to create rectangle container */
  78304. export class Rectangle extends Container {
  78305. name?: string | undefined;
  78306. private _thickness;
  78307. private _cornerRadius;
  78308. /** Gets or sets border thickness */
  78309. get thickness(): number;
  78310. set thickness(value: number);
  78311. /** Gets or sets the corner radius angle */
  78312. get cornerRadius(): number;
  78313. set cornerRadius(value: number);
  78314. /**
  78315. * Creates a new Rectangle
  78316. * @param name defines the control name
  78317. */
  78318. constructor(name?: string | undefined);
  78319. protected _getTypeName(): string;
  78320. protected _localDraw(context: CanvasRenderingContext2D): void;
  78321. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78322. private _drawRoundedRect;
  78323. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78324. }
  78325. }
  78326. declare module BABYLON.GUI {
  78327. /**
  78328. * Enum that determines the text-wrapping mode to use.
  78329. */
  78330. export enum TextWrapping {
  78331. /**
  78332. * Clip the text when it's larger than Control.width; this is the default mode.
  78333. */
  78334. Clip = 0,
  78335. /**
  78336. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78337. */
  78338. WordWrap = 1,
  78339. /**
  78340. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78341. */
  78342. Ellipsis = 2
  78343. }
  78344. /**
  78345. * Class used to create text block control
  78346. */
  78347. export class TextBlock extends Control {
  78348. /**
  78349. * Defines the name of the control
  78350. */
  78351. name?: string | undefined;
  78352. private _text;
  78353. private _textWrapping;
  78354. private _textHorizontalAlignment;
  78355. private _textVerticalAlignment;
  78356. private _lines;
  78357. private _resizeToFit;
  78358. private _lineSpacing;
  78359. private _outlineWidth;
  78360. private _outlineColor;
  78361. private _underline;
  78362. private _lineThrough;
  78363. /**
  78364. * An event triggered after the text is changed
  78365. */
  78366. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78367. /**
  78368. * An event triggered after the text was broken up into lines
  78369. */
  78370. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78371. /**
  78372. * Function used to split a string into words. By default, a string is split at each space character found
  78373. */
  78374. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78375. /**
  78376. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78377. */
  78378. get lines(): any[];
  78379. /**
  78380. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78381. */
  78382. get resizeToFit(): boolean;
  78383. /**
  78384. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78385. */
  78386. set resizeToFit(value: boolean);
  78387. /**
  78388. * Gets or sets a boolean indicating if text must be wrapped
  78389. */
  78390. get textWrapping(): TextWrapping | boolean;
  78391. /**
  78392. * Gets or sets a boolean indicating if text must be wrapped
  78393. */
  78394. set textWrapping(value: TextWrapping | boolean);
  78395. /**
  78396. * Gets or sets text to display
  78397. */
  78398. get text(): string;
  78399. /**
  78400. * Gets or sets text to display
  78401. */
  78402. set text(value: string);
  78403. /**
  78404. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78405. */
  78406. get textHorizontalAlignment(): number;
  78407. /**
  78408. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78409. */
  78410. set textHorizontalAlignment(value: number);
  78411. /**
  78412. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78413. */
  78414. get textVerticalAlignment(): number;
  78415. /**
  78416. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78417. */
  78418. set textVerticalAlignment(value: number);
  78419. /**
  78420. * Gets or sets line spacing value
  78421. */
  78422. set lineSpacing(value: string | number);
  78423. /**
  78424. * Gets or sets line spacing value
  78425. */
  78426. get lineSpacing(): string | number;
  78427. /**
  78428. * Gets or sets outlineWidth of the text to display
  78429. */
  78430. get outlineWidth(): number;
  78431. /**
  78432. * Gets or sets outlineWidth of the text to display
  78433. */
  78434. set outlineWidth(value: number);
  78435. /**
  78436. * Gets or sets a boolean indicating that text must have underline
  78437. */
  78438. get underline(): boolean;
  78439. /**
  78440. * Gets or sets a boolean indicating that text must have underline
  78441. */
  78442. set underline(value: boolean);
  78443. /**
  78444. * Gets or sets an boolean indicating that text must be crossed out
  78445. */
  78446. get lineThrough(): boolean;
  78447. /**
  78448. * Gets or sets an boolean indicating that text must be crossed out
  78449. */
  78450. set lineThrough(value: boolean);
  78451. /**
  78452. * Gets or sets outlineColor of the text to display
  78453. */
  78454. get outlineColor(): string;
  78455. /**
  78456. * Gets or sets outlineColor of the text to display
  78457. */
  78458. set outlineColor(value: string);
  78459. /**
  78460. * Creates a new TextBlock object
  78461. * @param name defines the name of the control
  78462. * @param text defines the text to display (emptry string by default)
  78463. */
  78464. constructor(
  78465. /**
  78466. * Defines the name of the control
  78467. */
  78468. name?: string | undefined, text?: string);
  78469. protected _getTypeName(): string;
  78470. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78471. private _drawText;
  78472. /** @hidden */
  78473. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78474. protected _applyStates(context: CanvasRenderingContext2D): void;
  78475. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78476. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78477. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78478. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78479. protected _renderLines(context: CanvasRenderingContext2D): void;
  78480. /**
  78481. * Given a width constraint applied on the text block, find the expected height
  78482. * @returns expected height
  78483. */
  78484. computeExpectedHeight(): number;
  78485. dispose(): void;
  78486. }
  78487. }
  78488. declare module BABYLON.GUI {
  78489. /**
  78490. * Class used to create 2D images
  78491. */
  78492. export class Image extends Control {
  78493. name?: string | undefined;
  78494. private _workingCanvas;
  78495. private _domImage;
  78496. private _imageWidth;
  78497. private _imageHeight;
  78498. private _loaded;
  78499. private _stretch;
  78500. private _source;
  78501. private _autoScale;
  78502. private _sourceLeft;
  78503. private _sourceTop;
  78504. private _sourceWidth;
  78505. private _sourceHeight;
  78506. private _svgAttributesComputationCompleted;
  78507. private _isSVG;
  78508. private _cellWidth;
  78509. private _cellHeight;
  78510. private _cellId;
  78511. private _populateNinePatchSlicesFromImage;
  78512. private _sliceLeft;
  78513. private _sliceRight;
  78514. private _sliceTop;
  78515. private _sliceBottom;
  78516. private _detectPointerOnOpaqueOnly;
  78517. private _imageDataCache;
  78518. /**
  78519. * BABYLON.Observable notified when the content is loaded
  78520. */
  78521. onImageLoadedObservable: BABYLON.Observable<Image>;
  78522. /**
  78523. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78524. */
  78525. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78526. /**
  78527. * Gets a boolean indicating that the content is loaded
  78528. */
  78529. get isLoaded(): boolean;
  78530. /**
  78531. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78532. */
  78533. get populateNinePatchSlicesFromImage(): boolean;
  78534. set populateNinePatchSlicesFromImage(value: boolean);
  78535. /**
  78536. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78537. * Beware using this as this will comsume more memory as the image has to be stored twice
  78538. */
  78539. get detectPointerOnOpaqueOnly(): boolean;
  78540. set detectPointerOnOpaqueOnly(value: boolean);
  78541. /**
  78542. * Gets or sets the left value for slicing (9-patch)
  78543. */
  78544. get sliceLeft(): number;
  78545. set sliceLeft(value: number);
  78546. /**
  78547. * Gets or sets the right value for slicing (9-patch)
  78548. */
  78549. get sliceRight(): number;
  78550. set sliceRight(value: number);
  78551. /**
  78552. * Gets or sets the top value for slicing (9-patch)
  78553. */
  78554. get sliceTop(): number;
  78555. set sliceTop(value: number);
  78556. /**
  78557. * Gets or sets the bottom value for slicing (9-patch)
  78558. */
  78559. get sliceBottom(): number;
  78560. set sliceBottom(value: number);
  78561. /**
  78562. * Gets or sets the left coordinate in the source image
  78563. */
  78564. get sourceLeft(): number;
  78565. set sourceLeft(value: number);
  78566. /**
  78567. * Gets or sets the top coordinate in the source image
  78568. */
  78569. get sourceTop(): number;
  78570. set sourceTop(value: number);
  78571. /**
  78572. * Gets or sets the width to capture in the source image
  78573. */
  78574. get sourceWidth(): number;
  78575. set sourceWidth(value: number);
  78576. /**
  78577. * Gets or sets the height to capture in the source image
  78578. */
  78579. get sourceHeight(): number;
  78580. set sourceHeight(value: number);
  78581. /** Indicates if the format of the image is SVG */
  78582. get isSVG(): boolean;
  78583. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78584. get svgAttributesComputationCompleted(): boolean;
  78585. /**
  78586. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78587. * @see https://doc.babylonjs.com/how_to/gui#image
  78588. */
  78589. get autoScale(): boolean;
  78590. set autoScale(value: boolean);
  78591. /** Gets or sets the streching mode used by the image */
  78592. get stretch(): number;
  78593. set stretch(value: number);
  78594. /** @hidden */
  78595. _rotate90(n: number, preserveProperties?: boolean): Image;
  78596. private _handleRotationForSVGImage;
  78597. private _rotate90SourceProperties;
  78598. /**
  78599. * Gets or sets the internal DOM image used to render the control
  78600. */
  78601. set domImage(value: HTMLImageElement);
  78602. get domImage(): HTMLImageElement;
  78603. private _onImageLoaded;
  78604. private _extractNinePatchSliceDataFromImage;
  78605. /**
  78606. * Gets or sets image source url
  78607. */
  78608. set source(value: BABYLON.Nullable<string>);
  78609. /**
  78610. * Checks for svg document with icon id present
  78611. */
  78612. private _svgCheck;
  78613. /**
  78614. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78615. * given external svg file and icon id
  78616. */
  78617. private _getSVGAttribs;
  78618. /**
  78619. * Gets or sets the cell width to use when animation sheet is enabled
  78620. * @see https://doc.babylonjs.com/how_to/gui#image
  78621. */
  78622. get cellWidth(): number;
  78623. set cellWidth(value: number);
  78624. /**
  78625. * Gets or sets the cell height to use when animation sheet is enabled
  78626. * @see https://doc.babylonjs.com/how_to/gui#image
  78627. */
  78628. get cellHeight(): number;
  78629. set cellHeight(value: number);
  78630. /**
  78631. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78632. * @see https://doc.babylonjs.com/how_to/gui#image
  78633. */
  78634. get cellId(): number;
  78635. set cellId(value: number);
  78636. /**
  78637. * Creates a new Image
  78638. * @param name defines the control name
  78639. * @param url defines the image url
  78640. */
  78641. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78642. /**
  78643. * Tests if a given coordinates belong to the current control
  78644. * @param x defines x coordinate to test
  78645. * @param y defines y coordinate to test
  78646. * @returns true if the coordinates are inside the control
  78647. */
  78648. contains(x: number, y: number): boolean;
  78649. protected _getTypeName(): string;
  78650. /** Force the control to synchronize with its content */
  78651. synchronizeSizeWithContent(): void;
  78652. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78653. private _prepareWorkingCanvasForOpaqueDetection;
  78654. private _drawImage;
  78655. _draw(context: CanvasRenderingContext2D): void;
  78656. private _renderCornerPatch;
  78657. private _renderNinePatch;
  78658. dispose(): void;
  78659. /** STRETCH_NONE */
  78660. static readonly STRETCH_NONE: number;
  78661. /** STRETCH_FILL */
  78662. static readonly STRETCH_FILL: number;
  78663. /** STRETCH_UNIFORM */
  78664. static readonly STRETCH_UNIFORM: number;
  78665. /** STRETCH_EXTEND */
  78666. static readonly STRETCH_EXTEND: number;
  78667. /** NINE_PATCH */
  78668. static readonly STRETCH_NINE_PATCH: number;
  78669. }
  78670. }
  78671. declare module BABYLON.GUI {
  78672. /**
  78673. * Class used to create 2D buttons
  78674. */
  78675. export class Button extends Rectangle {
  78676. name?: string | undefined;
  78677. /**
  78678. * Function called to generate a pointer enter animation
  78679. */
  78680. pointerEnterAnimation: () => void;
  78681. /**
  78682. * Function called to generate a pointer out animation
  78683. */
  78684. pointerOutAnimation: () => void;
  78685. /**
  78686. * Function called to generate a pointer down animation
  78687. */
  78688. pointerDownAnimation: () => void;
  78689. /**
  78690. * Function called to generate a pointer up animation
  78691. */
  78692. pointerUpAnimation: () => void;
  78693. /**
  78694. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78695. */
  78696. delegatePickingToChildren: boolean;
  78697. private _image;
  78698. /**
  78699. * Returns the image part of the button (if any)
  78700. */
  78701. get image(): BABYLON.Nullable<Image>;
  78702. private _textBlock;
  78703. /**
  78704. * Returns the image part of the button (if any)
  78705. */
  78706. get textBlock(): BABYLON.Nullable<TextBlock>;
  78707. /**
  78708. * Creates a new Button
  78709. * @param name defines the name of the button
  78710. */
  78711. constructor(name?: string | undefined);
  78712. protected _getTypeName(): string;
  78713. /** @hidden */
  78714. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78715. /** @hidden */
  78716. _onPointerEnter(target: Control): boolean;
  78717. /** @hidden */
  78718. _onPointerOut(target: Control, force?: boolean): void;
  78719. /** @hidden */
  78720. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78721. /** @hidden */
  78722. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78723. /**
  78724. * Creates a new button made with an image and a text
  78725. * @param name defines the name of the button
  78726. * @param text defines the text of the button
  78727. * @param imageUrl defines the url of the image
  78728. * @returns a new Button
  78729. */
  78730. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78731. /**
  78732. * Creates a new button made with an image
  78733. * @param name defines the name of the button
  78734. * @param imageUrl defines the url of the image
  78735. * @returns a new Button
  78736. */
  78737. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78738. /**
  78739. * Creates a new button made with a text
  78740. * @param name defines the name of the button
  78741. * @param text defines the text of the button
  78742. * @returns a new Button
  78743. */
  78744. static CreateSimpleButton(name: string, text: string): Button;
  78745. /**
  78746. * Creates a new button made with an image and a centered text
  78747. * @param name defines the name of the button
  78748. * @param text defines the text of the button
  78749. * @param imageUrl defines the url of the image
  78750. * @returns a new Button
  78751. */
  78752. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78753. }
  78754. }
  78755. declare module BABYLON.GUI {
  78756. /**
  78757. * Class used to create a 2D stack panel container
  78758. */
  78759. export class StackPanel extends Container {
  78760. name?: string | undefined;
  78761. private _isVertical;
  78762. private _manualWidth;
  78763. private _manualHeight;
  78764. private _doNotTrackManualChanges;
  78765. /**
  78766. * Gets or sets a boolean indicating that layou warnings should be ignored
  78767. */
  78768. ignoreLayoutWarnings: boolean;
  78769. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78770. get isVertical(): boolean;
  78771. set isVertical(value: boolean);
  78772. /**
  78773. * Gets or sets panel width.
  78774. * This value should not be set when in horizontal mode as it will be computed automatically
  78775. */
  78776. set width(value: string | number);
  78777. get width(): string | number;
  78778. /**
  78779. * Gets or sets panel height.
  78780. * This value should not be set when in vertical mode as it will be computed automatically
  78781. */
  78782. set height(value: string | number);
  78783. get height(): string | number;
  78784. /**
  78785. * Creates a new StackPanel
  78786. * @param name defines control name
  78787. */
  78788. constructor(name?: string | undefined);
  78789. protected _getTypeName(): string;
  78790. /** @hidden */
  78791. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78792. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78793. protected _postMeasure(): void;
  78794. }
  78795. }
  78796. declare module BABYLON.GUI {
  78797. /**
  78798. * Class used to represent a 2D checkbox
  78799. */
  78800. export class Checkbox extends Control {
  78801. name?: string | undefined;
  78802. private _isChecked;
  78803. private _background;
  78804. private _checkSizeRatio;
  78805. private _thickness;
  78806. /** Gets or sets border thickness */
  78807. get thickness(): number;
  78808. set thickness(value: number);
  78809. /**
  78810. * BABYLON.Observable raised when isChecked property changes
  78811. */
  78812. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78813. /** Gets or sets a value indicating the ratio between overall size and check size */
  78814. get checkSizeRatio(): number;
  78815. set checkSizeRatio(value: number);
  78816. /** Gets or sets background color */
  78817. get background(): string;
  78818. set background(value: string);
  78819. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78820. get isChecked(): boolean;
  78821. set isChecked(value: boolean);
  78822. /**
  78823. * Creates a new CheckBox
  78824. * @param name defines the control name
  78825. */
  78826. constructor(name?: string | undefined);
  78827. protected _getTypeName(): string;
  78828. /** @hidden */
  78829. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78830. /** @hidden */
  78831. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78832. /**
  78833. * Utility function to easily create a checkbox with a header
  78834. * @param title defines the label to use for the header
  78835. * @param onValueChanged defines the callback to call when value changes
  78836. * @returns a StackPanel containing the checkbox and a textBlock
  78837. */
  78838. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78839. }
  78840. }
  78841. declare module BABYLON.GUI {
  78842. /**
  78843. * Class used to store key control properties
  78844. */
  78845. export class KeyPropertySet {
  78846. /** Width */
  78847. width?: string;
  78848. /** Height */
  78849. height?: string;
  78850. /** Left padding */
  78851. paddingLeft?: string;
  78852. /** Right padding */
  78853. paddingRight?: string;
  78854. /** Top padding */
  78855. paddingTop?: string;
  78856. /** Bottom padding */
  78857. paddingBottom?: string;
  78858. /** Foreground color */
  78859. color?: string;
  78860. /** Background color */
  78861. background?: string;
  78862. }
  78863. /**
  78864. * Class used to create virtual keyboard
  78865. */
  78866. export class VirtualKeyboard extends StackPanel {
  78867. /** BABYLON.Observable raised when a key is pressed */
  78868. onKeyPressObservable: BABYLON.Observable<string>;
  78869. /** Gets or sets default key button width */
  78870. defaultButtonWidth: string;
  78871. /** Gets or sets default key button height */
  78872. defaultButtonHeight: string;
  78873. /** Gets or sets default key button left padding */
  78874. defaultButtonPaddingLeft: string;
  78875. /** Gets or sets default key button right padding */
  78876. defaultButtonPaddingRight: string;
  78877. /** Gets or sets default key button top padding */
  78878. defaultButtonPaddingTop: string;
  78879. /** Gets or sets default key button bottom padding */
  78880. defaultButtonPaddingBottom: string;
  78881. /** Gets or sets default key button foreground color */
  78882. defaultButtonColor: string;
  78883. /** Gets or sets default key button background color */
  78884. defaultButtonBackground: string;
  78885. /** Gets or sets shift button foreground color */
  78886. shiftButtonColor: string;
  78887. /** Gets or sets shift button thickness*/
  78888. selectedShiftThickness: number;
  78889. /** Gets shift key state */
  78890. shiftState: number;
  78891. protected _getTypeName(): string;
  78892. private _createKey;
  78893. /**
  78894. * Adds a new row of keys
  78895. * @param keys defines the list of keys to add
  78896. * @param propertySets defines the associated property sets
  78897. */
  78898. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  78899. /**
  78900. * Set the shift key to a specific state
  78901. * @param shiftState defines the new shift state
  78902. */
  78903. applyShiftState(shiftState: number): void;
  78904. private _currentlyConnectedInputText;
  78905. private _connectedInputTexts;
  78906. private _onKeyPressObserver;
  78907. /** Gets the input text control currently attached to the keyboard */
  78908. get connectedInputText(): BABYLON.Nullable<InputText>;
  78909. /**
  78910. * Connects the keyboard with an input text control
  78911. *
  78912. * @param input defines the target control
  78913. */
  78914. connect(input: InputText): void;
  78915. /**
  78916. * Disconnects the keyboard from connected InputText controls
  78917. *
  78918. * @param input optionally defines a target control, otherwise all are disconnected
  78919. */
  78920. disconnect(input?: InputText): void;
  78921. private _removeConnectedInputObservables;
  78922. /**
  78923. * Release all resources
  78924. */
  78925. dispose(): void;
  78926. /**
  78927. * Creates a new keyboard using a default layout
  78928. *
  78929. * @param name defines control name
  78930. * @returns a new VirtualKeyboard
  78931. */
  78932. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  78933. }
  78934. }
  78935. declare module BABYLON.GUI {
  78936. /**
  78937. * Class used to create input text control
  78938. */
  78939. export class InputText extends Control implements IFocusableControl {
  78940. name?: string | undefined;
  78941. private _text;
  78942. private _placeholderText;
  78943. private _background;
  78944. private _focusedBackground;
  78945. private _focusedColor;
  78946. private _placeholderColor;
  78947. private _thickness;
  78948. private _margin;
  78949. private _autoStretchWidth;
  78950. private _maxWidth;
  78951. private _isFocused;
  78952. private _blinkTimeout;
  78953. private _blinkIsEven;
  78954. private _cursorOffset;
  78955. private _scrollLeft;
  78956. private _textWidth;
  78957. private _clickedCoordinate;
  78958. private _deadKey;
  78959. private _addKey;
  78960. private _currentKey;
  78961. private _isTextHighlightOn;
  78962. private _textHighlightColor;
  78963. private _highligherOpacity;
  78964. private _highlightedText;
  78965. private _startHighlightIndex;
  78966. private _endHighlightIndex;
  78967. private _cursorIndex;
  78968. private _onFocusSelectAll;
  78969. private _isPointerDown;
  78970. private _onClipboardObserver;
  78971. private _onPointerDblTapObserver;
  78972. /** @hidden */
  78973. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78974. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78975. promptMessage: string;
  78976. /** Force disable prompt on mobile device */
  78977. disableMobilePrompt: boolean;
  78978. /** BABYLON.Observable raised when the text changes */
  78979. onTextChangedObservable: BABYLON.Observable<InputText>;
  78980. /** BABYLON.Observable raised just before an entered character is to be added */
  78981. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78982. /** BABYLON.Observable raised when the control gets the focus */
  78983. onFocusObservable: BABYLON.Observable<InputText>;
  78984. /** BABYLON.Observable raised when the control loses the focus */
  78985. onBlurObservable: BABYLON.Observable<InputText>;
  78986. /**Observable raised when the text is highlighted */
  78987. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78988. /**Observable raised when copy event is triggered */
  78989. onTextCopyObservable: BABYLON.Observable<InputText>;
  78990. /** BABYLON.Observable raised when cut event is triggered */
  78991. onTextCutObservable: BABYLON.Observable<InputText>;
  78992. /** BABYLON.Observable raised when paste event is triggered */
  78993. onTextPasteObservable: BABYLON.Observable<InputText>;
  78994. /** BABYLON.Observable raised when a key event was processed */
  78995. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78996. /** Gets or sets the maximum width allowed by the control */
  78997. get maxWidth(): string | number;
  78998. /** Gets the maximum width allowed by the control in pixels */
  78999. get maxWidthInPixels(): number;
  79000. set maxWidth(value: string | number);
  79001. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79002. get highligherOpacity(): number;
  79003. set highligherOpacity(value: number);
  79004. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79005. get onFocusSelectAll(): boolean;
  79006. set onFocusSelectAll(value: boolean);
  79007. /** Gets or sets the text hightlight color */
  79008. get textHighlightColor(): string;
  79009. set textHighlightColor(value: string);
  79010. /** Gets or sets control margin */
  79011. get margin(): string;
  79012. /** Gets control margin in pixels */
  79013. get marginInPixels(): number;
  79014. set margin(value: string);
  79015. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79016. get autoStretchWidth(): boolean;
  79017. set autoStretchWidth(value: boolean);
  79018. /** Gets or sets border thickness */
  79019. get thickness(): number;
  79020. set thickness(value: number);
  79021. /** Gets or sets the background color when focused */
  79022. get focusedBackground(): string;
  79023. set focusedBackground(value: string);
  79024. /** Gets or sets the background color when focused */
  79025. get focusedColor(): string;
  79026. set focusedColor(value: string);
  79027. /** Gets or sets the background color */
  79028. get background(): string;
  79029. set background(value: string);
  79030. /** Gets or sets the placeholder color */
  79031. get placeholderColor(): string;
  79032. set placeholderColor(value: string);
  79033. /** Gets or sets the text displayed when the control is empty */
  79034. get placeholderText(): string;
  79035. set placeholderText(value: string);
  79036. /** Gets or sets the dead key flag */
  79037. get deadKey(): boolean;
  79038. set deadKey(flag: boolean);
  79039. /** Gets or sets the highlight text */
  79040. get highlightedText(): string;
  79041. set highlightedText(text: string);
  79042. /** Gets or sets if the current key should be added */
  79043. get addKey(): boolean;
  79044. set addKey(flag: boolean);
  79045. /** Gets or sets the value of the current key being entered */
  79046. get currentKey(): string;
  79047. set currentKey(key: string);
  79048. /** Gets or sets the text displayed in the control */
  79049. get text(): string;
  79050. set text(value: string);
  79051. /** Gets or sets control width */
  79052. get width(): string | number;
  79053. set width(value: string | number);
  79054. /**
  79055. * Creates a new InputText
  79056. * @param name defines the control name
  79057. * @param text defines the text of the control
  79058. */
  79059. constructor(name?: string | undefined, text?: string);
  79060. /** @hidden */
  79061. onBlur(): void;
  79062. /** @hidden */
  79063. onFocus(): void;
  79064. protected _getTypeName(): string;
  79065. /**
  79066. * Function called to get the list of controls that should not steal the focus from this control
  79067. * @returns an array of controls
  79068. */
  79069. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79070. /** @hidden */
  79071. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79072. /** @hidden */
  79073. private _updateValueFromCursorIndex;
  79074. /** @hidden */
  79075. private _processDblClick;
  79076. /** @hidden */
  79077. private _selectAllText;
  79078. /**
  79079. * Handles the keyboard event
  79080. * @param evt Defines the KeyboardEvent
  79081. */
  79082. processKeyboard(evt: KeyboardEvent): void;
  79083. /** @hidden */
  79084. private _onCopyText;
  79085. /** @hidden */
  79086. private _onCutText;
  79087. /** @hidden */
  79088. private _onPasteText;
  79089. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79090. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79091. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  79092. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79093. protected _beforeRenderText(text: string): string;
  79094. dispose(): void;
  79095. }
  79096. }
  79097. declare module BABYLON.GUI {
  79098. /**
  79099. * Class used to create a 2D grid container
  79100. */
  79101. export class Grid extends Container {
  79102. name?: string | undefined;
  79103. private _rowDefinitions;
  79104. private _columnDefinitions;
  79105. private _cells;
  79106. private _childControls;
  79107. /**
  79108. * Gets the number of columns
  79109. */
  79110. get columnCount(): number;
  79111. /**
  79112. * Gets the number of rows
  79113. */
  79114. get rowCount(): number;
  79115. /** Gets the list of children */
  79116. get children(): Control[];
  79117. /** Gets the list of cells (e.g. the containers) */
  79118. get cells(): {
  79119. [key: string]: Container;
  79120. };
  79121. /**
  79122. * Gets the definition of a specific row
  79123. * @param index defines the index of the row
  79124. * @returns the row definition
  79125. */
  79126. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79127. /**
  79128. * Gets the definition of a specific column
  79129. * @param index defines the index of the column
  79130. * @returns the column definition
  79131. */
  79132. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79133. /**
  79134. * Adds a new row to the grid
  79135. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79136. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79137. * @returns the current grid
  79138. */
  79139. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79140. /**
  79141. * Adds a new column to the grid
  79142. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79143. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79144. * @returns the current grid
  79145. */
  79146. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79147. /**
  79148. * Update a row definition
  79149. * @param index defines the index of the row to update
  79150. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79151. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79152. * @returns the current grid
  79153. */
  79154. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79155. /**
  79156. * Update a column definition
  79157. * @param index defines the index of the column to update
  79158. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79159. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79160. * @returns the current grid
  79161. */
  79162. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79163. /**
  79164. * Gets the list of children stored in a specific cell
  79165. * @param row defines the row to check
  79166. * @param column defines the column to check
  79167. * @returns the list of controls
  79168. */
  79169. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79170. /**
  79171. * Gets a string representing the child cell info (row x column)
  79172. * @param child defines the control to get info from
  79173. * @returns a string containing the child cell info (row x column)
  79174. */
  79175. getChildCellInfo(child: Control): string;
  79176. private _removeCell;
  79177. private _offsetCell;
  79178. /**
  79179. * Remove a column definition at specified index
  79180. * @param index defines the index of the column to remove
  79181. * @returns the current grid
  79182. */
  79183. removeColumnDefinition(index: number): Grid;
  79184. /**
  79185. * Remove a row definition at specified index
  79186. * @param index defines the index of the row to remove
  79187. * @returns the current grid
  79188. */
  79189. removeRowDefinition(index: number): Grid;
  79190. /**
  79191. * Adds a new control to the current grid
  79192. * @param control defines the control to add
  79193. * @param row defines the row where to add the control (0 by default)
  79194. * @param column defines the column where to add the control (0 by default)
  79195. * @returns the current grid
  79196. */
  79197. addControl(control: Control, row?: number, column?: number): Grid;
  79198. /**
  79199. * Removes a control from the current container
  79200. * @param control defines the control to remove
  79201. * @returns the current container
  79202. */
  79203. removeControl(control: Control): Container;
  79204. /**
  79205. * Creates a new Grid
  79206. * @param name defines control name
  79207. */
  79208. constructor(name?: string | undefined);
  79209. protected _getTypeName(): string;
  79210. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79211. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79212. _flagDescendantsAsMatrixDirty(): void;
  79213. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79214. /** Releases associated resources */
  79215. dispose(): void;
  79216. }
  79217. }
  79218. declare module BABYLON.GUI {
  79219. /** Class used to create color pickers */
  79220. export class ColorPicker extends Control {
  79221. name?: string | undefined;
  79222. private static _Epsilon;
  79223. private _colorWheelCanvas;
  79224. private _value;
  79225. private _tmpColor;
  79226. private _pointerStartedOnSquare;
  79227. private _pointerStartedOnWheel;
  79228. private _squareLeft;
  79229. private _squareTop;
  79230. private _squareSize;
  79231. private _h;
  79232. private _s;
  79233. private _v;
  79234. private _lastPointerDownID;
  79235. /**
  79236. * BABYLON.Observable raised when the value changes
  79237. */
  79238. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79239. /** Gets or sets the color of the color picker */
  79240. get value(): BABYLON.Color3;
  79241. set value(value: BABYLON.Color3);
  79242. /**
  79243. * Gets or sets control width
  79244. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79245. */
  79246. get width(): string | number;
  79247. set width(value: string | number);
  79248. /**
  79249. * Gets or sets control height
  79250. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79251. */
  79252. get height(): string | number;
  79253. /** Gets or sets control height */
  79254. set height(value: string | number);
  79255. /** Gets or sets control size */
  79256. get size(): string | number;
  79257. set size(value: string | number);
  79258. /**
  79259. * Creates a new ColorPicker
  79260. * @param name defines the control name
  79261. */
  79262. constructor(name?: string | undefined);
  79263. protected _getTypeName(): string;
  79264. /** @hidden */
  79265. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79266. private _updateSquareProps;
  79267. private _drawGradientSquare;
  79268. private _drawCircle;
  79269. private _createColorWheelCanvas;
  79270. /** @hidden */
  79271. _draw(context: CanvasRenderingContext2D): void;
  79272. private _pointerIsDown;
  79273. private _updateValueFromPointer;
  79274. private _isPointOnSquare;
  79275. private _isPointOnWheel;
  79276. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79277. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  79278. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79279. _onCanvasBlur(): void;
  79280. /**
  79281. * This function expands the color picker by creating a color picker dialog with manual
  79282. * color value input and the ability to save colors into an array to be used later in
  79283. * subsequent launches of the dialogue.
  79284. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79285. * @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.
  79286. * @returns picked color as a hex string and the saved colors array as hex strings.
  79287. */
  79288. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79289. pickerWidth?: string;
  79290. pickerHeight?: string;
  79291. headerHeight?: string;
  79292. lastColor?: string;
  79293. swatchLimit?: number;
  79294. numSwatchesPerLine?: number;
  79295. savedColors?: Array<string>;
  79296. }): Promise<{
  79297. savedColors?: string[];
  79298. pickedColor: string;
  79299. }>;
  79300. }
  79301. }
  79302. declare module BABYLON.GUI {
  79303. /** Class used to create 2D ellipse containers */
  79304. export class Ellipse extends Container {
  79305. name?: string | undefined;
  79306. private _thickness;
  79307. /** Gets or sets border thickness */
  79308. get thickness(): number;
  79309. set thickness(value: number);
  79310. /**
  79311. * Creates a new Ellipse
  79312. * @param name defines the control name
  79313. */
  79314. constructor(name?: string | undefined);
  79315. protected _getTypeName(): string;
  79316. protected _localDraw(context: CanvasRenderingContext2D): void;
  79317. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79318. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79319. }
  79320. }
  79321. declare module BABYLON.GUI {
  79322. /**
  79323. * Class used to create a password control
  79324. */
  79325. export class InputPassword extends InputText {
  79326. protected _beforeRenderText(text: string): string;
  79327. }
  79328. }
  79329. declare module BABYLON.GUI {
  79330. /** Class used to render 2D lines */
  79331. export class Line extends Control {
  79332. name?: string | undefined;
  79333. private _lineWidth;
  79334. private _x1;
  79335. private _y1;
  79336. private _x2;
  79337. private _y2;
  79338. private _dash;
  79339. private _connectedControl;
  79340. private _connectedControlDirtyObserver;
  79341. /** Gets or sets the dash pattern */
  79342. get dash(): Array<number>;
  79343. set dash(value: Array<number>);
  79344. /** Gets or sets the control connected with the line end */
  79345. get connectedControl(): Control;
  79346. set connectedControl(value: Control);
  79347. /** Gets or sets start coordinates on X axis */
  79348. get x1(): string | number;
  79349. set x1(value: string | number);
  79350. /** Gets or sets start coordinates on Y axis */
  79351. get y1(): string | number;
  79352. set y1(value: string | number);
  79353. /** Gets or sets end coordinates on X axis */
  79354. get x2(): string | number;
  79355. set x2(value: string | number);
  79356. /** Gets or sets end coordinates on Y axis */
  79357. get y2(): string | number;
  79358. set y2(value: string | number);
  79359. /** Gets or sets line width */
  79360. get lineWidth(): number;
  79361. set lineWidth(value: number);
  79362. /** Gets or sets horizontal alignment */
  79363. set horizontalAlignment(value: number);
  79364. /** Gets or sets vertical alignment */
  79365. set verticalAlignment(value: number);
  79366. private get _effectiveX2();
  79367. private get _effectiveY2();
  79368. /**
  79369. * Creates a new Line
  79370. * @param name defines the control name
  79371. */
  79372. constructor(name?: string | undefined);
  79373. protected _getTypeName(): string;
  79374. _draw(context: CanvasRenderingContext2D): void;
  79375. _measure(): void;
  79376. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79377. /**
  79378. * Move one end of the line given 3D cartesian coordinates.
  79379. * @param position Targeted world position
  79380. * @param scene BABYLON.Scene
  79381. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79382. */
  79383. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79384. /**
  79385. * Move one end of the line to a position in screen absolute space.
  79386. * @param projectedPosition Position in screen absolute space (X, Y)
  79387. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79388. */
  79389. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79390. }
  79391. }
  79392. declare module BABYLON.GUI {
  79393. /**
  79394. * Class used to store a point for a MultiLine object.
  79395. * The point can be pure 2D coordinates, a mesh or a control
  79396. */
  79397. export class MultiLinePoint {
  79398. private _multiLine;
  79399. private _x;
  79400. private _y;
  79401. private _control;
  79402. private _mesh;
  79403. private _controlObserver;
  79404. private _meshObserver;
  79405. /** @hidden */
  79406. _point: BABYLON.Vector2;
  79407. /**
  79408. * Creates a new MultiLinePoint
  79409. * @param multiLine defines the source MultiLine object
  79410. */
  79411. constructor(multiLine: MultiLine);
  79412. /** Gets or sets x coordinate */
  79413. get x(): string | number;
  79414. set x(value: string | number);
  79415. /** Gets or sets y coordinate */
  79416. get y(): string | number;
  79417. set y(value: string | number);
  79418. /** Gets or sets the control associated with this point */
  79419. get control(): BABYLON.Nullable<Control>;
  79420. set control(value: BABYLON.Nullable<Control>);
  79421. /** Gets or sets the mesh associated with this point */
  79422. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79423. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79424. /** Resets links */
  79425. resetLinks(): void;
  79426. /**
  79427. * Gets a translation vector
  79428. * @returns the translation vector
  79429. */
  79430. translate(): BABYLON.Vector2;
  79431. private _translatePoint;
  79432. /** Release associated resources */
  79433. dispose(): void;
  79434. }
  79435. }
  79436. declare module BABYLON.GUI {
  79437. /**
  79438. * Class used to create multi line control
  79439. */
  79440. export class MultiLine extends Control {
  79441. name?: string | undefined;
  79442. private _lineWidth;
  79443. private _dash;
  79444. private _points;
  79445. private _minX;
  79446. private _minY;
  79447. private _maxX;
  79448. private _maxY;
  79449. /**
  79450. * Creates a new MultiLine
  79451. * @param name defines the control name
  79452. */
  79453. constructor(name?: string | undefined);
  79454. /** Gets or sets dash pattern */
  79455. get dash(): Array<number>;
  79456. set dash(value: Array<number>);
  79457. /**
  79458. * Gets point stored at specified index
  79459. * @param index defines the index to look for
  79460. * @returns the requested point if found
  79461. */
  79462. getAt(index: number): MultiLinePoint;
  79463. /** Function called when a point is updated */
  79464. onPointUpdate: () => void;
  79465. /**
  79466. * Adds new points to the point collection
  79467. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79468. * @returns the list of created MultiLinePoint
  79469. */
  79470. add(...items: (AbstractMesh | Control | {
  79471. x: string | number;
  79472. y: string | number;
  79473. })[]): MultiLinePoint[];
  79474. /**
  79475. * Adds a new point to the point collection
  79476. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79477. * @returns the created MultiLinePoint
  79478. */
  79479. push(item?: (AbstractMesh | Control | {
  79480. x: string | number;
  79481. y: string | number;
  79482. })): MultiLinePoint;
  79483. /**
  79484. * Remove a specific value or point from the active point collection
  79485. * @param value defines the value or point to remove
  79486. */
  79487. remove(value: number | MultiLinePoint): void;
  79488. /**
  79489. * Resets this object to initial state (no point)
  79490. */
  79491. reset(): void;
  79492. /**
  79493. * Resets all links
  79494. */
  79495. resetLinks(): void;
  79496. /** Gets or sets line width */
  79497. get lineWidth(): number;
  79498. set lineWidth(value: number);
  79499. set horizontalAlignment(value: number);
  79500. set verticalAlignment(value: number);
  79501. protected _getTypeName(): string;
  79502. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79503. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79504. _measure(): void;
  79505. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79506. dispose(): void;
  79507. }
  79508. }
  79509. declare module BABYLON.GUI {
  79510. /**
  79511. * Class used to create radio button controls
  79512. */
  79513. export class RadioButton extends Control {
  79514. name?: string | undefined;
  79515. private _isChecked;
  79516. private _background;
  79517. private _checkSizeRatio;
  79518. private _thickness;
  79519. /** Gets or sets border thickness */
  79520. get thickness(): number;
  79521. set thickness(value: number);
  79522. /** Gets or sets group name */
  79523. group: string;
  79524. /** BABYLON.Observable raised when isChecked is changed */
  79525. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79526. /** Gets or sets a value indicating the ratio between overall size and check size */
  79527. get checkSizeRatio(): number;
  79528. set checkSizeRatio(value: number);
  79529. /** Gets or sets background color */
  79530. get background(): string;
  79531. set background(value: string);
  79532. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79533. get isChecked(): boolean;
  79534. set isChecked(value: boolean);
  79535. /**
  79536. * Creates a new RadioButton
  79537. * @param name defines the control name
  79538. */
  79539. constructor(name?: string | undefined);
  79540. protected _getTypeName(): string;
  79541. _draw(context: CanvasRenderingContext2D): void;
  79542. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79543. /**
  79544. * Utility function to easily create a radio button with a header
  79545. * @param title defines the label to use for the header
  79546. * @param group defines the group to use for the radio button
  79547. * @param isChecked defines the initial state of the radio button
  79548. * @param onValueChanged defines the callback to call when value changes
  79549. * @returns a StackPanel containing the radio button and a textBlock
  79550. */
  79551. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79552. }
  79553. }
  79554. declare module BABYLON.GUI {
  79555. /**
  79556. * Class used to create slider controls
  79557. */
  79558. export class BaseSlider extends Control {
  79559. name?: string | undefined;
  79560. protected _thumbWidth: ValueAndUnit;
  79561. private _minimum;
  79562. private _maximum;
  79563. private _value;
  79564. private _isVertical;
  79565. protected _barOffset: ValueAndUnit;
  79566. private _isThumbClamped;
  79567. protected _displayThumb: boolean;
  79568. private _step;
  79569. private _lastPointerDownID;
  79570. protected _effectiveBarOffset: number;
  79571. protected _renderLeft: number;
  79572. protected _renderTop: number;
  79573. protected _renderWidth: number;
  79574. protected _renderHeight: number;
  79575. protected _backgroundBoxLength: number;
  79576. protected _backgroundBoxThickness: number;
  79577. protected _effectiveThumbThickness: number;
  79578. /** BABYLON.Observable raised when the sldier value changes */
  79579. onValueChangedObservable: BABYLON.Observable<number>;
  79580. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79581. get displayThumb(): boolean;
  79582. set displayThumb(value: boolean);
  79583. /** Gets or sets a step to apply to values (0 by default) */
  79584. get step(): number;
  79585. set step(value: number);
  79586. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79587. get barOffset(): string | number;
  79588. /** Gets main bar offset in pixels*/
  79589. get barOffsetInPixels(): number;
  79590. set barOffset(value: string | number);
  79591. /** Gets or sets thumb width */
  79592. get thumbWidth(): string | number;
  79593. /** Gets thumb width in pixels */
  79594. get thumbWidthInPixels(): number;
  79595. set thumbWidth(value: string | number);
  79596. /** Gets or sets minimum value */
  79597. get minimum(): number;
  79598. set minimum(value: number);
  79599. /** Gets or sets maximum value */
  79600. get maximum(): number;
  79601. set maximum(value: number);
  79602. /** Gets or sets current value */
  79603. get value(): number;
  79604. set value(value: number);
  79605. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79606. get isVertical(): boolean;
  79607. set isVertical(value: boolean);
  79608. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79609. get isThumbClamped(): boolean;
  79610. set isThumbClamped(value: boolean);
  79611. /**
  79612. * Creates a new BaseSlider
  79613. * @param name defines the control name
  79614. */
  79615. constructor(name?: string | undefined);
  79616. protected _getTypeName(): string;
  79617. protected _getThumbPosition(): number;
  79618. protected _getThumbThickness(type: string): number;
  79619. protected _prepareRenderingData(type: string): void;
  79620. private _pointerIsDown;
  79621. /** @hidden */
  79622. protected _updateValueFromPointer(x: number, y: number): void;
  79623. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79624. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  79625. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79626. _onCanvasBlur(): void;
  79627. }
  79628. }
  79629. declare module BABYLON.GUI {
  79630. /**
  79631. * Class used to create slider controls
  79632. */
  79633. export class Slider extends BaseSlider {
  79634. name?: string | undefined;
  79635. private _background;
  79636. private _borderColor;
  79637. private _thumbColor;
  79638. private _isThumbCircle;
  79639. protected _displayValueBar: boolean;
  79640. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79641. get displayValueBar(): boolean;
  79642. set displayValueBar(value: boolean);
  79643. /** Gets or sets border color */
  79644. get borderColor(): string;
  79645. set borderColor(value: string);
  79646. /** Gets or sets background color */
  79647. get background(): string;
  79648. set background(value: string);
  79649. /** Gets or sets thumb's color */
  79650. get thumbColor(): string;
  79651. set thumbColor(value: string);
  79652. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79653. get isThumbCircle(): boolean;
  79654. set isThumbCircle(value: boolean);
  79655. /**
  79656. * Creates a new Slider
  79657. * @param name defines the control name
  79658. */
  79659. constructor(name?: string | undefined);
  79660. protected _getTypeName(): string;
  79661. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79662. }
  79663. }
  79664. declare module BABYLON.GUI {
  79665. /** Class used to create a RadioGroup
  79666. * which contains groups of radio buttons
  79667. */
  79668. export class SelectorGroup {
  79669. /** name of SelectorGroup */
  79670. name: string;
  79671. private _groupPanel;
  79672. private _selectors;
  79673. private _groupHeader;
  79674. /**
  79675. * Creates a new SelectorGroup
  79676. * @param name of group, used as a group heading
  79677. */
  79678. constructor(
  79679. /** name of SelectorGroup */
  79680. name: string);
  79681. /** Gets the groupPanel of the SelectorGroup */
  79682. get groupPanel(): StackPanel;
  79683. /** Gets the selectors array */
  79684. get selectors(): StackPanel[];
  79685. /** Gets and sets the group header */
  79686. get header(): string;
  79687. set header(label: string);
  79688. /** @hidden */
  79689. private _addGroupHeader;
  79690. /** @hidden*/
  79691. _getSelector(selectorNb: number): StackPanel | undefined;
  79692. /** Removes the selector at the given position
  79693. * @param selectorNb the position of the selector within the group
  79694. */
  79695. removeSelector(selectorNb: number): void;
  79696. }
  79697. /** Class used to create a CheckboxGroup
  79698. * which contains groups of checkbox buttons
  79699. */
  79700. export class CheckboxGroup extends SelectorGroup {
  79701. /** Adds a checkbox as a control
  79702. * @param text is the label for the selector
  79703. * @param func is the function called when the Selector is checked
  79704. * @param checked is true when Selector is checked
  79705. */
  79706. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79707. /** @hidden */
  79708. _setSelectorLabel(selectorNb: number, label: string): void;
  79709. /** @hidden */
  79710. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79711. /** @hidden */
  79712. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79713. /** @hidden */
  79714. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79715. }
  79716. /** Class used to create a RadioGroup
  79717. * which contains groups of radio buttons
  79718. */
  79719. export class RadioGroup extends SelectorGroup {
  79720. private _selectNb;
  79721. /** Adds a radio button as a control
  79722. * @param label is the label for the selector
  79723. * @param func is the function called when the Selector is checked
  79724. * @param checked is true when Selector is checked
  79725. */
  79726. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79727. /** @hidden */
  79728. _setSelectorLabel(selectorNb: number, label: string): void;
  79729. /** @hidden */
  79730. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79731. /** @hidden */
  79732. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79733. /** @hidden */
  79734. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79735. }
  79736. /** Class used to create a SliderGroup
  79737. * which contains groups of slider buttons
  79738. */
  79739. export class SliderGroup extends SelectorGroup {
  79740. /**
  79741. * Adds a slider to the SelectorGroup
  79742. * @param label is the label for the SliderBar
  79743. * @param func is the function called when the Slider moves
  79744. * @param unit is a string describing the units used, eg degrees or metres
  79745. * @param min is the minimum value for the Slider
  79746. * @param max is the maximum value for the Slider
  79747. * @param value is the start value for the Slider between min and max
  79748. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79749. */
  79750. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79751. /** @hidden */
  79752. _setSelectorLabel(selectorNb: number, label: string): void;
  79753. /** @hidden */
  79754. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79755. /** @hidden */
  79756. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79757. /** @hidden */
  79758. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79759. }
  79760. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79761. * @see https://doc.babylonjs.com/how_to/selector
  79762. */
  79763. export class SelectionPanel extends Rectangle {
  79764. /** name of SelectionPanel */
  79765. name: string;
  79766. /** an array of SelectionGroups */
  79767. groups: SelectorGroup[];
  79768. private _panel;
  79769. private _buttonColor;
  79770. private _buttonBackground;
  79771. private _headerColor;
  79772. private _barColor;
  79773. private _barHeight;
  79774. private _spacerHeight;
  79775. private _labelColor;
  79776. private _groups;
  79777. private _bars;
  79778. /**
  79779. * Creates a new SelectionPanel
  79780. * @param name of SelectionPanel
  79781. * @param groups is an array of SelectionGroups
  79782. */
  79783. constructor(
  79784. /** name of SelectionPanel */
  79785. name: string,
  79786. /** an array of SelectionGroups */
  79787. groups?: SelectorGroup[]);
  79788. protected _getTypeName(): string;
  79789. /** Gets the (stack) panel of the SelectionPanel */
  79790. get panel(): StackPanel;
  79791. /** Gets or sets the headerColor */
  79792. get headerColor(): string;
  79793. set headerColor(color: string);
  79794. private _setHeaderColor;
  79795. /** Gets or sets the button color */
  79796. get buttonColor(): string;
  79797. set buttonColor(color: string);
  79798. private _setbuttonColor;
  79799. /** Gets or sets the label color */
  79800. get labelColor(): string;
  79801. set labelColor(color: string);
  79802. private _setLabelColor;
  79803. /** Gets or sets the button background */
  79804. get buttonBackground(): string;
  79805. set buttonBackground(color: string);
  79806. private _setButtonBackground;
  79807. /** Gets or sets the color of separator bar */
  79808. get barColor(): string;
  79809. set barColor(color: string);
  79810. private _setBarColor;
  79811. /** Gets or sets the height of separator bar */
  79812. get barHeight(): string;
  79813. set barHeight(value: string);
  79814. private _setBarHeight;
  79815. /** Gets or sets the height of spacers*/
  79816. get spacerHeight(): string;
  79817. set spacerHeight(value: string);
  79818. private _setSpacerHeight;
  79819. /** Adds a bar between groups */
  79820. private _addSpacer;
  79821. /** Add a group to the selection panel
  79822. * @param group is the selector group to add
  79823. */
  79824. addGroup(group: SelectorGroup): void;
  79825. /** Remove the group from the given position
  79826. * @param groupNb is the position of the group in the list
  79827. */
  79828. removeGroup(groupNb: number): void;
  79829. /** Change a group header label
  79830. * @param label is the new group header label
  79831. * @param groupNb is the number of the group to relabel
  79832. * */
  79833. setHeaderName(label: string, groupNb: number): void;
  79834. /** Change selector label to the one given
  79835. * @param label is the new selector label
  79836. * @param groupNb is the number of the groupcontaining the selector
  79837. * @param selectorNb is the number of the selector within a group to relabel
  79838. * */
  79839. relabel(label: string, groupNb: number, selectorNb: number): void;
  79840. /** For a given group position remove the selector at the given position
  79841. * @param groupNb is the number of the group to remove the selector from
  79842. * @param selectorNb is the number of the selector within the group
  79843. */
  79844. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79845. /** For a given group position of correct type add a checkbox button
  79846. * @param groupNb is the number of the group to remove the selector from
  79847. * @param label is the label for the selector
  79848. * @param func is the function called when the Selector is checked
  79849. * @param checked is true when Selector is checked
  79850. */
  79851. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79852. /** For a given group position of correct type add a radio button
  79853. * @param groupNb is the number of the group to remove the selector from
  79854. * @param label is the label for the selector
  79855. * @param func is the function called when the Selector is checked
  79856. * @param checked is true when Selector is checked
  79857. */
  79858. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79859. /**
  79860. * For a given slider group add a slider
  79861. * @param groupNb is the number of the group to add the slider to
  79862. * @param label is the label for the Slider
  79863. * @param func is the function called when the Slider moves
  79864. * @param unit is a string describing the units used, eg degrees or metres
  79865. * @param min is the minimum value for the Slider
  79866. * @param max is the maximum value for the Slider
  79867. * @param value is the start value for the Slider between min and max
  79868. * @param onVal is the function used to format the value displayed, eg radians to degrees
  79869. */
  79870. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  79871. }
  79872. }
  79873. declare module BABYLON.GUI {
  79874. /**
  79875. * Class used to hold a the container for ScrollViewer
  79876. * @hidden
  79877. */
  79878. export class _ScrollViewerWindow extends Container {
  79879. parentClientWidth: number;
  79880. parentClientHeight: number;
  79881. private _freezeControls;
  79882. private _parentMeasure;
  79883. private _oldLeft;
  79884. private _oldTop;
  79885. get freezeControls(): boolean;
  79886. set freezeControls(value: boolean);
  79887. private _bucketWidth;
  79888. private _bucketHeight;
  79889. private _buckets;
  79890. private _bucketLen;
  79891. get bucketWidth(): number;
  79892. get bucketHeight(): number;
  79893. setBucketSizes(width: number, height: number): void;
  79894. private _useBuckets;
  79895. private _makeBuckets;
  79896. private _dispatchInBuckets;
  79897. private _updateMeasures;
  79898. private _updateChildrenMeasures;
  79899. private _restoreMeasures;
  79900. /**
  79901. * Creates a new ScrollViewerWindow
  79902. * @param name of ScrollViewerWindow
  79903. */
  79904. constructor(name?: string);
  79905. protected _getTypeName(): string;
  79906. /** @hidden */
  79907. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79908. /** @hidden */
  79909. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79910. private _scrollChildren;
  79911. private _scrollChildrenWithBuckets;
  79912. /** @hidden */
  79913. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79914. protected _postMeasure(): void;
  79915. }
  79916. }
  79917. declare module BABYLON.GUI {
  79918. /**
  79919. * Class used to create slider controls
  79920. */
  79921. export class ScrollBar extends BaseSlider {
  79922. name?: string | undefined;
  79923. private _background;
  79924. private _borderColor;
  79925. private _tempMeasure;
  79926. /** Gets or sets border color */
  79927. get borderColor(): string;
  79928. set borderColor(value: string);
  79929. /** Gets or sets background color */
  79930. get background(): string;
  79931. set background(value: string);
  79932. /**
  79933. * Creates a new Slider
  79934. * @param name defines the control name
  79935. */
  79936. constructor(name?: string | undefined);
  79937. protected _getTypeName(): string;
  79938. protected _getThumbThickness(): number;
  79939. _draw(context: CanvasRenderingContext2D): void;
  79940. private _first;
  79941. private _originX;
  79942. private _originY;
  79943. /** @hidden */
  79944. protected _updateValueFromPointer(x: number, y: number): void;
  79945. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79946. }
  79947. }
  79948. declare module BABYLON.GUI {
  79949. /**
  79950. * Class used to create slider controls
  79951. */
  79952. export class ImageScrollBar extends BaseSlider {
  79953. name?: string | undefined;
  79954. private _backgroundBaseImage;
  79955. private _backgroundImage;
  79956. private _thumbImage;
  79957. private _thumbBaseImage;
  79958. private _thumbLength;
  79959. private _thumbHeight;
  79960. private _barImageHeight;
  79961. private _tempMeasure;
  79962. /** Number of 90° rotation to apply on the images when in vertical mode */
  79963. num90RotationInVerticalMode: number;
  79964. /**
  79965. * Gets or sets the image used to render the background for horizontal bar
  79966. */
  79967. get backgroundImage(): Image;
  79968. set backgroundImage(value: Image);
  79969. /**
  79970. * Gets or sets the image used to render the thumb
  79971. */
  79972. get thumbImage(): Image;
  79973. set thumbImage(value: Image);
  79974. /**
  79975. * Gets or sets the length of the thumb
  79976. */
  79977. get thumbLength(): number;
  79978. set thumbLength(value: number);
  79979. /**
  79980. * Gets or sets the height of the thumb
  79981. */
  79982. get thumbHeight(): number;
  79983. set thumbHeight(value: number);
  79984. /**
  79985. * Gets or sets the height of the bar image
  79986. */
  79987. get barImageHeight(): number;
  79988. set barImageHeight(value: number);
  79989. /**
  79990. * Creates a new ImageScrollBar
  79991. * @param name defines the control name
  79992. */
  79993. constructor(name?: string | undefined);
  79994. protected _getTypeName(): string;
  79995. protected _getThumbThickness(): number;
  79996. _draw(context: CanvasRenderingContext2D): void;
  79997. private _first;
  79998. private _originX;
  79999. private _originY;
  80000. /** @hidden */
  80001. protected _updateValueFromPointer(x: number, y: number): void;
  80002. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  80003. }
  80004. }
  80005. declare module BABYLON.GUI {
  80006. /**
  80007. * Class used to hold a viewer window and sliders in a grid
  80008. */
  80009. export class ScrollViewer extends Rectangle {
  80010. private _grid;
  80011. private _horizontalBarSpace;
  80012. private _verticalBarSpace;
  80013. private _dragSpace;
  80014. private _horizontalBar;
  80015. private _verticalBar;
  80016. private _barColor;
  80017. private _barBackground;
  80018. private _barImage;
  80019. private _horizontalBarImage;
  80020. private _verticalBarImage;
  80021. private _barBackgroundImage;
  80022. private _horizontalBarBackgroundImage;
  80023. private _verticalBarBackgroundImage;
  80024. private _barSize;
  80025. private _window;
  80026. private _pointerIsOver;
  80027. private _wheelPrecision;
  80028. private _onWheelObserver;
  80029. private _clientWidth;
  80030. private _clientHeight;
  80031. private _useImageBar;
  80032. private _thumbLength;
  80033. private _thumbHeight;
  80034. private _barImageHeight;
  80035. private _horizontalBarImageHeight;
  80036. private _verticalBarImageHeight;
  80037. private _oldWindowContentsWidth;
  80038. private _oldWindowContentsHeight;
  80039. /**
  80040. * Gets the horizontal scrollbar
  80041. */
  80042. get horizontalBar(): ScrollBar | ImageScrollBar;
  80043. /**
  80044. * Gets the vertical scrollbar
  80045. */
  80046. get verticalBar(): ScrollBar | ImageScrollBar;
  80047. /**
  80048. * Adds a new control to the current container
  80049. * @param control defines the control to add
  80050. * @returns the current container
  80051. */
  80052. addControl(control: BABYLON.Nullable<Control>): Container;
  80053. /**
  80054. * Removes a control from the current container
  80055. * @param control defines the control to remove
  80056. * @returns the current container
  80057. */
  80058. removeControl(control: Control): Container;
  80059. /** Gets the list of children */
  80060. get children(): Control[];
  80061. _flagDescendantsAsMatrixDirty(): void;
  80062. /**
  80063. * Freezes or unfreezes the controls in the window.
  80064. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80065. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80066. */
  80067. get freezeControls(): boolean;
  80068. set freezeControls(value: boolean);
  80069. /** Gets the bucket width */
  80070. get bucketWidth(): number;
  80071. /** Gets the bucket height */
  80072. get bucketHeight(): number;
  80073. /**
  80074. * Sets the bucket sizes.
  80075. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80076. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80077. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80078. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80079. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80080. * used), that's why it is not enabled by default.
  80081. * @param width width of the bucket
  80082. * @param height height of the bucket
  80083. */
  80084. setBucketSizes(width: number, height: number): void;
  80085. private _forceHorizontalBar;
  80086. private _forceVerticalBar;
  80087. /**
  80088. * Forces the horizontal scroll bar to be displayed
  80089. */
  80090. get forceHorizontalBar(): boolean;
  80091. set forceHorizontalBar(value: boolean);
  80092. /**
  80093. * Forces the vertical scroll bar to be displayed
  80094. */
  80095. get forceVerticalBar(): boolean;
  80096. set forceVerticalBar(value: boolean);
  80097. /**
  80098. * Creates a new ScrollViewer
  80099. * @param name of ScrollViewer
  80100. */
  80101. constructor(name?: string, isImageBased?: boolean);
  80102. /** Reset the scroll viewer window to initial size */
  80103. resetWindow(): void;
  80104. protected _getTypeName(): string;
  80105. private _buildClientSizes;
  80106. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80107. protected _postMeasure(): void;
  80108. /**
  80109. * Gets or sets the mouse wheel precision
  80110. * from 0 to 1 with a default value of 0.05
  80111. * */
  80112. get wheelPrecision(): number;
  80113. set wheelPrecision(value: number);
  80114. /** Gets or sets the scroll bar container background color */
  80115. get scrollBackground(): string;
  80116. set scrollBackground(color: string);
  80117. /** Gets or sets the bar color */
  80118. get barColor(): string;
  80119. set barColor(color: string);
  80120. /** Gets or sets the bar image */
  80121. get thumbImage(): Image;
  80122. set thumbImage(value: Image);
  80123. /** Gets or sets the horizontal bar image */
  80124. get horizontalThumbImage(): Image;
  80125. set horizontalThumbImage(value: Image);
  80126. /** Gets or sets the vertical bar image */
  80127. get verticalThumbImage(): Image;
  80128. set verticalThumbImage(value: Image);
  80129. /** Gets or sets the size of the bar */
  80130. get barSize(): number;
  80131. set barSize(value: number);
  80132. /** Gets or sets the length of the thumb */
  80133. get thumbLength(): number;
  80134. set thumbLength(value: number);
  80135. /** Gets or sets the height of the thumb */
  80136. get thumbHeight(): number;
  80137. set thumbHeight(value: number);
  80138. /** Gets or sets the height of the bar image */
  80139. get barImageHeight(): number;
  80140. set barImageHeight(value: number);
  80141. /** Gets or sets the height of the horizontal bar image */
  80142. get horizontalBarImageHeight(): number;
  80143. set horizontalBarImageHeight(value: number);
  80144. /** Gets or sets the height of the vertical bar image */
  80145. get verticalBarImageHeight(): number;
  80146. set verticalBarImageHeight(value: number);
  80147. /** Gets or sets the bar background */
  80148. get barBackground(): string;
  80149. set barBackground(color: string);
  80150. /** Gets or sets the bar background image */
  80151. get barImage(): Image;
  80152. set barImage(value: Image);
  80153. /** Gets or sets the horizontal bar background image */
  80154. get horizontalBarImage(): Image;
  80155. set horizontalBarImage(value: Image);
  80156. /** Gets or sets the vertical bar background image */
  80157. get verticalBarImage(): Image;
  80158. set verticalBarImage(value: Image);
  80159. private _setWindowPosition;
  80160. /** @hidden */
  80161. private _updateScroller;
  80162. _link(host: AdvancedDynamicTexture): void;
  80163. /** @hidden */
  80164. private _addBar;
  80165. /** @hidden */
  80166. private _attachWheel;
  80167. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80168. /** Releases associated resources */
  80169. dispose(): void;
  80170. }
  80171. }
  80172. declare module BABYLON.GUI {
  80173. /** Class used to render a grid */
  80174. export class DisplayGrid extends Control {
  80175. name?: string | undefined;
  80176. private _cellWidth;
  80177. private _cellHeight;
  80178. private _minorLineTickness;
  80179. private _minorLineColor;
  80180. private _majorLineTickness;
  80181. private _majorLineColor;
  80182. private _majorLineFrequency;
  80183. private _background;
  80184. private _displayMajorLines;
  80185. private _displayMinorLines;
  80186. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80187. get displayMinorLines(): boolean;
  80188. set displayMinorLines(value: boolean);
  80189. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80190. get displayMajorLines(): boolean;
  80191. set displayMajorLines(value: boolean);
  80192. /** Gets or sets background color (Black by default) */
  80193. get background(): string;
  80194. set background(value: string);
  80195. /** Gets or sets the width of each cell (20 by default) */
  80196. get cellWidth(): number;
  80197. set cellWidth(value: number);
  80198. /** Gets or sets the height of each cell (20 by default) */
  80199. get cellHeight(): number;
  80200. set cellHeight(value: number);
  80201. /** Gets or sets the tickness of minor lines (1 by default) */
  80202. get minorLineTickness(): number;
  80203. set minorLineTickness(value: number);
  80204. /** Gets or sets the color of minor lines (DarkGray by default) */
  80205. get minorLineColor(): string;
  80206. set minorLineColor(value: string);
  80207. /** Gets or sets the tickness of major lines (2 by default) */
  80208. get majorLineTickness(): number;
  80209. set majorLineTickness(value: number);
  80210. /** Gets or sets the color of major lines (White by default) */
  80211. get majorLineColor(): string;
  80212. set majorLineColor(value: string);
  80213. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80214. get majorLineFrequency(): number;
  80215. set majorLineFrequency(value: number);
  80216. /**
  80217. * Creates a new GridDisplayRectangle
  80218. * @param name defines the control name
  80219. */
  80220. constructor(name?: string | undefined);
  80221. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80222. protected _getTypeName(): string;
  80223. }
  80224. }
  80225. declare module BABYLON.GUI {
  80226. /**
  80227. * Class used to create slider controls based on images
  80228. */
  80229. export class ImageBasedSlider extends BaseSlider {
  80230. name?: string | undefined;
  80231. private _backgroundImage;
  80232. private _thumbImage;
  80233. private _valueBarImage;
  80234. private _tempMeasure;
  80235. get displayThumb(): boolean;
  80236. set displayThumb(value: boolean);
  80237. /**
  80238. * Gets or sets the image used to render the background
  80239. */
  80240. get backgroundImage(): Image;
  80241. set backgroundImage(value: Image);
  80242. /**
  80243. * Gets or sets the image used to render the value bar
  80244. */
  80245. get valueBarImage(): Image;
  80246. set valueBarImage(value: Image);
  80247. /**
  80248. * Gets or sets the image used to render the thumb
  80249. */
  80250. get thumbImage(): Image;
  80251. set thumbImage(value: Image);
  80252. /**
  80253. * Creates a new ImageBasedSlider
  80254. * @param name defines the control name
  80255. */
  80256. constructor(name?: string | undefined);
  80257. protected _getTypeName(): string;
  80258. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80259. }
  80260. }
  80261. declare module BABYLON.GUI {
  80262. /**
  80263. * Forcing an export so that this code will execute
  80264. * @hidden
  80265. */
  80266. const name = "Statics";
  80267. }
  80268. declare module BABYLON.GUI {
  80269. /**
  80270. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80271. */
  80272. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80273. /**
  80274. * Define the instrumented AdvancedDynamicTexture.
  80275. */
  80276. texture: AdvancedDynamicTexture;
  80277. private _captureRenderTime;
  80278. private _renderTime;
  80279. private _captureLayoutTime;
  80280. private _layoutTime;
  80281. private _onBeginRenderObserver;
  80282. private _onEndRenderObserver;
  80283. private _onBeginLayoutObserver;
  80284. private _onEndLayoutObserver;
  80285. /**
  80286. * Gets the perf counter used to capture render time
  80287. */
  80288. get renderTimeCounter(): BABYLON.PerfCounter;
  80289. /**
  80290. * Gets the perf counter used to capture layout time
  80291. */
  80292. get layoutTimeCounter(): BABYLON.PerfCounter;
  80293. /**
  80294. * Enable or disable the render time capture
  80295. */
  80296. get captureRenderTime(): boolean;
  80297. set captureRenderTime(value: boolean);
  80298. /**
  80299. * Enable or disable the layout time capture
  80300. */
  80301. get captureLayoutTime(): boolean;
  80302. set captureLayoutTime(value: boolean);
  80303. /**
  80304. * Instantiates a new advanced dynamic texture instrumentation.
  80305. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80306. * @param texture Defines the AdvancedDynamicTexture to instrument
  80307. */
  80308. constructor(
  80309. /**
  80310. * Define the instrumented AdvancedDynamicTexture.
  80311. */
  80312. texture: AdvancedDynamicTexture);
  80313. /**
  80314. * Dispose and release associated resources.
  80315. */
  80316. dispose(): void;
  80317. }
  80318. }
  80319. declare module BABYLON.GUI {
  80320. /**
  80321. * Class used to load GUI via XML.
  80322. */
  80323. export class XmlLoader {
  80324. private _nodes;
  80325. private _nodeTypes;
  80326. private _isLoaded;
  80327. private _objectAttributes;
  80328. private _parentClass;
  80329. /**
  80330. * Create a new xml loader
  80331. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80332. */
  80333. constructor(parentClass?: null);
  80334. private _getChainElement;
  80335. private _getClassAttribute;
  80336. private _createGuiElement;
  80337. private _parseGrid;
  80338. private _parseElement;
  80339. private _prepareSourceElement;
  80340. private _parseElementsFromSource;
  80341. private _parseXml;
  80342. /**
  80343. * Gets if the loading has finished.
  80344. * @returns whether the loading has finished or not
  80345. */
  80346. isLoaded(): boolean;
  80347. /**
  80348. * Gets a loaded node / control by id.
  80349. * @param id the Controls id set in the xml
  80350. * @returns element of type Control
  80351. */
  80352. getNodeById(id: string): any;
  80353. /**
  80354. * Gets all loaded nodes / controls
  80355. * @returns Array of controls
  80356. */
  80357. getNodes(): any;
  80358. /**
  80359. * Initiates the xml layout loading
  80360. * @param xmlFile defines the xml layout to load
  80361. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80362. * @param callback defines the callback called on layout load.
  80363. */
  80364. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80365. }
  80366. }
  80367. declare module BABYLON.GUI {
  80368. /**
  80369. * Class used to create containers for controls
  80370. */
  80371. export class Container3D extends Control3D {
  80372. private _blockLayout;
  80373. /**
  80374. * Gets the list of child controls
  80375. */
  80376. protected _children: Control3D[];
  80377. /**
  80378. * Gets the list of child controls
  80379. */
  80380. get children(): Array<Control3D>;
  80381. /**
  80382. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80383. * This is helpful to optimize layout operation when adding multiple children in a row
  80384. */
  80385. get blockLayout(): boolean;
  80386. set blockLayout(value: boolean);
  80387. /**
  80388. * Creates a new container
  80389. * @param name defines the container name
  80390. */
  80391. constructor(name?: string);
  80392. /**
  80393. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80394. * @returns the current container
  80395. */
  80396. updateLayout(): Container3D;
  80397. /**
  80398. * Gets a boolean indicating if the given control is in the children of this control
  80399. * @param control defines the control to check
  80400. * @returns true if the control is in the child list
  80401. */
  80402. containsControl(control: Control3D): boolean;
  80403. /**
  80404. * Adds a control to the children of this control
  80405. * @param control defines the control to add
  80406. * @returns the current container
  80407. */
  80408. addControl(control: Control3D): Container3D;
  80409. /**
  80410. * This function will be called everytime a new control is added
  80411. */
  80412. protected _arrangeChildren(): void;
  80413. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80414. /**
  80415. * Removes a control from the children of this control
  80416. * @param control defines the control to remove
  80417. * @returns the current container
  80418. */
  80419. removeControl(control: Control3D): Container3D;
  80420. protected _getTypeName(): string;
  80421. /**
  80422. * Releases all associated resources
  80423. */
  80424. dispose(): void;
  80425. /** Control rotation will remain unchanged */
  80426. static readonly UNSET_ORIENTATION: number;
  80427. /** Control will rotate to make it look at sphere central axis */
  80428. static readonly FACEORIGIN_ORIENTATION: number;
  80429. /** Control will rotate to make it look back at sphere central axis */
  80430. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80431. /** Control will rotate to look at z axis (0, 0, 1) */
  80432. static readonly FACEFORWARD_ORIENTATION: number;
  80433. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80434. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80435. }
  80436. }
  80437. declare module BABYLON.GUI {
  80438. /**
  80439. * Class used to manage 3D user interface
  80440. * @see https://doc.babylonjs.com/how_to/gui3d
  80441. */
  80442. export class GUI3DManager implements BABYLON.IDisposable {
  80443. private _scene;
  80444. private _sceneDisposeObserver;
  80445. private _utilityLayer;
  80446. private _rootContainer;
  80447. private _pointerObserver;
  80448. private _pointerOutObserver;
  80449. /** @hidden */
  80450. _lastPickedControl: Control3D;
  80451. /** @hidden */
  80452. _lastControlOver: {
  80453. [pointerId: number]: Control3D;
  80454. };
  80455. /** @hidden */
  80456. _lastControlDown: {
  80457. [pointerId: number]: Control3D;
  80458. };
  80459. /**
  80460. * BABYLON.Observable raised when the point picked by the pointer events changed
  80461. */
  80462. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80463. /** @hidden */
  80464. _sharedMaterials: {
  80465. [key: string]: BABYLON.Material;
  80466. };
  80467. /** Gets the hosting scene */
  80468. get scene(): BABYLON.Scene;
  80469. /** Gets associated utility layer */
  80470. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80471. /**
  80472. * Creates a new GUI3DManager
  80473. * @param scene
  80474. */
  80475. constructor(scene?: BABYLON.Scene);
  80476. private _handlePointerOut;
  80477. private _doPicking;
  80478. /**
  80479. * Gets the root container
  80480. */
  80481. get rootContainer(): Container3D;
  80482. /**
  80483. * Gets a boolean indicating if the given control is in the root child list
  80484. * @param control defines the control to check
  80485. * @returns true if the control is in the root child list
  80486. */
  80487. containsControl(control: Control3D): boolean;
  80488. /**
  80489. * Adds a control to the root child list
  80490. * @param control defines the control to add
  80491. * @returns the current manager
  80492. */
  80493. addControl(control: Control3D): GUI3DManager;
  80494. /**
  80495. * Removes a control from the root child list
  80496. * @param control defines the control to remove
  80497. * @returns the current container
  80498. */
  80499. removeControl(control: Control3D): GUI3DManager;
  80500. /**
  80501. * Releases all associated resources
  80502. */
  80503. dispose(): void;
  80504. }
  80505. }
  80506. declare module BABYLON.GUI {
  80507. /**
  80508. * Class used to transport BABYLON.Vector3 information for pointer events
  80509. */
  80510. export class Vector3WithInfo extends BABYLON.Vector3 {
  80511. /** defines the current mouse button index */
  80512. buttonIndex: number;
  80513. /**
  80514. * Creates a new Vector3WithInfo
  80515. * @param source defines the vector3 data to transport
  80516. * @param buttonIndex defines the current mouse button index
  80517. */
  80518. constructor(source: BABYLON.Vector3,
  80519. /** defines the current mouse button index */
  80520. buttonIndex?: number);
  80521. }
  80522. }
  80523. declare module BABYLON.GUI {
  80524. /**
  80525. * Class used as base class for controls
  80526. */
  80527. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80528. /** Defines the control name */
  80529. name?: string | undefined;
  80530. /** @hidden */
  80531. _host: GUI3DManager;
  80532. private _node;
  80533. private _downCount;
  80534. private _enterCount;
  80535. private _downPointerIds;
  80536. private _isVisible;
  80537. /** Gets or sets the control position in world space */
  80538. get position(): BABYLON.Vector3;
  80539. set position(value: BABYLON.Vector3);
  80540. /** Gets or sets the control scaling in world space */
  80541. get scaling(): BABYLON.Vector3;
  80542. set scaling(value: BABYLON.Vector3);
  80543. /** Callback used to start pointer enter animation */
  80544. pointerEnterAnimation: () => void;
  80545. /** Callback used to start pointer out animation */
  80546. pointerOutAnimation: () => void;
  80547. /** Callback used to start pointer down animation */
  80548. pointerDownAnimation: () => void;
  80549. /** Callback used to start pointer up animation */
  80550. pointerUpAnimation: () => void;
  80551. /**
  80552. * An event triggered when the pointer move over the control
  80553. */
  80554. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80555. /**
  80556. * An event triggered when the pointer move out of the control
  80557. */
  80558. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80559. /**
  80560. * An event triggered when the pointer taps the control
  80561. */
  80562. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80563. /**
  80564. * An event triggered when pointer is up
  80565. */
  80566. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80567. /**
  80568. * An event triggered when a control is clicked on (with a mouse)
  80569. */
  80570. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80571. /**
  80572. * An event triggered when pointer enters the control
  80573. */
  80574. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80575. /**
  80576. * Gets or sets the parent container
  80577. */
  80578. parent: BABYLON.Nullable<Container3D>;
  80579. private _behaviors;
  80580. /**
  80581. * Gets the list of attached behaviors
  80582. * @see https://doc.babylonjs.com/features/behaviour
  80583. */
  80584. get behaviors(): BABYLON.Behavior<Control3D>[];
  80585. /**
  80586. * Attach a behavior to the control
  80587. * @see https://doc.babylonjs.com/features/behaviour
  80588. * @param behavior defines the behavior to attach
  80589. * @returns the current control
  80590. */
  80591. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80592. /**
  80593. * Remove an attached behavior
  80594. * @see https://doc.babylonjs.com/features/behaviour
  80595. * @param behavior defines the behavior to attach
  80596. * @returns the current control
  80597. */
  80598. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80599. /**
  80600. * Gets an attached behavior by name
  80601. * @param name defines the name of the behavior to look for
  80602. * @see https://doc.babylonjs.com/features/behaviour
  80603. * @returns null if behavior was not found else the requested behavior
  80604. */
  80605. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80606. /** Gets or sets a boolean indicating if the control is visible */
  80607. get isVisible(): boolean;
  80608. set isVisible(value: boolean);
  80609. /**
  80610. * Creates a new control
  80611. * @param name defines the control name
  80612. */
  80613. constructor(
  80614. /** Defines the control name */
  80615. name?: string | undefined);
  80616. /**
  80617. * Gets a string representing the class name
  80618. */
  80619. get typeName(): string;
  80620. /**
  80621. * Get the current class name of the control.
  80622. * @returns current class name
  80623. */
  80624. getClassName(): string;
  80625. protected _getTypeName(): string;
  80626. /**
  80627. * Gets the transform node used by this control
  80628. */
  80629. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80630. /**
  80631. * Gets the mesh used to render this control
  80632. */
  80633. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80634. /**
  80635. * Link the control as child of the given node
  80636. * @param node defines the node to link to. Use null to unlink the control
  80637. * @returns the current control
  80638. */
  80639. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80640. /** @hidden **/
  80641. _prepareNode(scene: BABYLON.Scene): void;
  80642. /**
  80643. * Node creation.
  80644. * Can be overriden by children
  80645. * @param scene defines the scene where the node must be attached
  80646. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80647. */
  80648. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80649. /**
  80650. * Affect a material to the given mesh
  80651. * @param mesh defines the mesh which will represent the control
  80652. */
  80653. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80654. /** @hidden */
  80655. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80656. /** @hidden */
  80657. _onPointerEnter(target: Control3D): boolean;
  80658. /** @hidden */
  80659. _onPointerOut(target: Control3D): void;
  80660. /** @hidden */
  80661. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80662. /** @hidden */
  80663. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80664. /** @hidden */
  80665. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80666. /** @hidden */
  80667. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80668. /** @hidden */
  80669. _disposeNode(): void;
  80670. /**
  80671. * Releases all associated resources
  80672. */
  80673. dispose(): void;
  80674. }
  80675. }
  80676. declare module BABYLON.GUI {
  80677. /**
  80678. * Class used as a root to all buttons
  80679. */
  80680. export class AbstractButton3D extends Control3D {
  80681. /**
  80682. * Creates a new button
  80683. * @param name defines the control name
  80684. */
  80685. constructor(name?: string);
  80686. protected _getTypeName(): string;
  80687. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80688. }
  80689. }
  80690. declare module BABYLON.GUI {
  80691. /**
  80692. * Class used to create a button in 3D
  80693. */
  80694. export class Button3D extends AbstractButton3D {
  80695. /** @hidden */
  80696. protected _currentMaterial: BABYLON.Material;
  80697. private _facadeTexture;
  80698. private _content;
  80699. private _contentResolution;
  80700. private _contentScaleRatio;
  80701. /**
  80702. * Gets or sets the texture resolution used to render content (512 by default)
  80703. */
  80704. get contentResolution(): BABYLON.int;
  80705. set contentResolution(value: BABYLON.int);
  80706. /**
  80707. * Gets or sets the texture scale ratio used to render content (2 by default)
  80708. */
  80709. get contentScaleRatio(): number;
  80710. set contentScaleRatio(value: number);
  80711. protected _disposeFacadeTexture(): void;
  80712. protected _resetContent(): void;
  80713. /**
  80714. * Creates a new button
  80715. * @param name defines the control name
  80716. */
  80717. constructor(name?: string);
  80718. /**
  80719. * Gets or sets the GUI 2D content used to display the button's facade
  80720. */
  80721. get content(): Control;
  80722. set content(value: Control);
  80723. /**
  80724. * Apply the facade texture (created from the content property).
  80725. * This function can be overloaded by child classes
  80726. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80727. */
  80728. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80729. protected _getTypeName(): string;
  80730. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80731. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80732. /**
  80733. * Releases all associated resources
  80734. */
  80735. dispose(): void;
  80736. }
  80737. }
  80738. declare module BABYLON.GUI {
  80739. /**
  80740. * Abstract class used to create a container panel deployed on the surface of a volume
  80741. */
  80742. export abstract class VolumeBasedPanel extends Container3D {
  80743. private _columns;
  80744. private _rows;
  80745. private _rowThenColum;
  80746. private _orientation;
  80747. protected _cellWidth: number;
  80748. protected _cellHeight: number;
  80749. /**
  80750. * Gets or sets the distance between elements
  80751. */
  80752. margin: number;
  80753. /**
  80754. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80755. * | Value | Type | Description |
  80756. * | ----- | ----------------------------------- | ----------- |
  80757. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80758. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80759. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80760. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80761. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80762. */
  80763. get orientation(): number;
  80764. set orientation(value: number);
  80765. /**
  80766. * Gets or sets the number of columns requested (10 by default).
  80767. * The panel will automatically compute the number of rows based on number of child controls.
  80768. */
  80769. get columns(): BABYLON.int;
  80770. set columns(value: BABYLON.int);
  80771. /**
  80772. * Gets or sets a the number of rows requested.
  80773. * The panel will automatically compute the number of columns based on number of child controls.
  80774. */
  80775. get rows(): BABYLON.int;
  80776. set rows(value: BABYLON.int);
  80777. /**
  80778. * Creates new VolumeBasedPanel
  80779. */
  80780. constructor();
  80781. protected _arrangeChildren(): void;
  80782. /** Child classes must implement this function to provide correct control positioning */
  80783. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80784. /** Child classes can implement this function to provide additional processing */
  80785. protected _finalProcessing(): void;
  80786. }
  80787. }
  80788. declare module BABYLON.GUI {
  80789. /**
  80790. * Class used to create a container panel deployed on the surface of a cylinder
  80791. */
  80792. export class CylinderPanel extends VolumeBasedPanel {
  80793. private _radius;
  80794. /**
  80795. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80796. */
  80797. get radius(): BABYLON.float;
  80798. set radius(value: BABYLON.float);
  80799. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80800. private _cylindricalMapping;
  80801. }
  80802. }
  80803. declare module BABYLON.GUI {
  80804. /** @hidden */
  80805. export var fluentVertexShader: {
  80806. name: string;
  80807. shader: string;
  80808. };
  80809. }
  80810. declare module BABYLON.GUI {
  80811. /** @hidden */
  80812. export var fluentPixelShader: {
  80813. name: string;
  80814. shader: string;
  80815. };
  80816. }
  80817. declare module BABYLON.GUI {
  80818. /** @hidden */
  80819. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80820. INNERGLOW: boolean;
  80821. BORDER: boolean;
  80822. HOVERLIGHT: boolean;
  80823. TEXTURE: boolean;
  80824. constructor();
  80825. }
  80826. /**
  80827. * Class used to render controls with fluent desgin
  80828. */
  80829. export class FluentMaterial extends BABYLON.PushMaterial {
  80830. /**
  80831. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80832. */
  80833. innerGlowColorIntensity: number;
  80834. /**
  80835. * Gets or sets the inner glow color (white by default)
  80836. */
  80837. innerGlowColor: BABYLON.Color3;
  80838. /**
  80839. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80840. */
  80841. albedoColor: BABYLON.Color3;
  80842. /**
  80843. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80844. */
  80845. renderBorders: boolean;
  80846. /**
  80847. * Gets or sets border width (default is 0.5)
  80848. */
  80849. borderWidth: number;
  80850. /**
  80851. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80852. */
  80853. edgeSmoothingValue: number;
  80854. /**
  80855. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  80856. */
  80857. borderMinValue: number;
  80858. /**
  80859. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  80860. */
  80861. renderHoverLight: boolean;
  80862. /**
  80863. * Gets or sets the radius used to render the hover light (default is 1.0)
  80864. */
  80865. hoverRadius: number;
  80866. /**
  80867. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  80868. */
  80869. hoverColor: BABYLON.Color4;
  80870. /**
  80871. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  80872. */
  80873. hoverPosition: BABYLON.Vector3;
  80874. private _albedoTexture;
  80875. /** Gets or sets the texture to use for albedo color */
  80876. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80877. /**
  80878. * Creates a new Fluent material
  80879. * @param name defines the name of the material
  80880. * @param scene defines the hosting scene
  80881. */
  80882. constructor(name: string, scene: BABYLON.Scene);
  80883. needAlphaBlending(): boolean;
  80884. needAlphaTesting(): boolean;
  80885. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80886. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80887. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80888. getActiveTextures(): BABYLON.BaseTexture[];
  80889. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80890. dispose(forceDisposeEffect?: boolean): void;
  80891. clone(name: string): FluentMaterial;
  80892. serialize(): any;
  80893. getClassName(): string;
  80894. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  80895. }
  80896. }
  80897. declare module BABYLON.GUI {
  80898. /**
  80899. * Class used to create a holographic button in 3D
  80900. */
  80901. export class HolographicButton extends Button3D {
  80902. private _backPlate;
  80903. private _textPlate;
  80904. private _frontPlate;
  80905. private _text;
  80906. private _imageUrl;
  80907. private _shareMaterials;
  80908. private _frontMaterial;
  80909. private _backMaterial;
  80910. private _plateMaterial;
  80911. private _pickedPointObserver;
  80912. private _tooltipFade;
  80913. private _tooltipTextBlock;
  80914. private _tooltipTexture;
  80915. private _tooltipMesh;
  80916. private _tooltipHoverObserver;
  80917. private _tooltipOutObserver;
  80918. private _disposeTooltip;
  80919. /**
  80920. * Rendering ground id of all the mesh in the button
  80921. */
  80922. set renderingGroupId(id: number);
  80923. get renderingGroupId(): number;
  80924. /**
  80925. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  80926. */
  80927. set tooltipText(text: BABYLON.Nullable<string>);
  80928. get tooltipText(): BABYLON.Nullable<string>;
  80929. /**
  80930. * Gets or sets text for the button
  80931. */
  80932. get text(): string;
  80933. set text(value: string);
  80934. /**
  80935. * Gets or sets the image url for the button
  80936. */
  80937. get imageUrl(): string;
  80938. set imageUrl(value: string);
  80939. /**
  80940. * Gets the back material used by this button
  80941. */
  80942. get backMaterial(): FluentMaterial;
  80943. /**
  80944. * Gets the front material used by this button
  80945. */
  80946. get frontMaterial(): FluentMaterial;
  80947. /**
  80948. * Gets the plate material used by this button
  80949. */
  80950. get plateMaterial(): BABYLON.StandardMaterial;
  80951. /**
  80952. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  80953. */
  80954. get shareMaterials(): boolean;
  80955. /**
  80956. * Creates a new button
  80957. * @param name defines the control name
  80958. */
  80959. constructor(name?: string, shareMaterials?: boolean);
  80960. protected _getTypeName(): string;
  80961. private _rebuildContent;
  80962. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80963. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80964. private _createBackMaterial;
  80965. private _createFrontMaterial;
  80966. private _createPlateMaterial;
  80967. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80968. /**
  80969. * Releases all associated resources
  80970. */
  80971. dispose(): void;
  80972. }
  80973. }
  80974. declare module BABYLON.GUI {
  80975. /**
  80976. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80977. */
  80978. export class MeshButton3D extends Button3D {
  80979. /** @hidden */
  80980. protected _currentMesh: BABYLON.Mesh;
  80981. /**
  80982. * Creates a new 3D button based on a mesh
  80983. * @param mesh mesh to become a 3D button
  80984. * @param name defines the control name
  80985. */
  80986. constructor(mesh: BABYLON.Mesh, name?: string);
  80987. protected _getTypeName(): string;
  80988. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80989. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80990. }
  80991. }
  80992. declare module BABYLON.GUI {
  80993. /**
  80994. * Class used to create a container panel deployed on the surface of a plane
  80995. */
  80996. export class PlanePanel extends VolumeBasedPanel {
  80997. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80998. }
  80999. }
  81000. declare module BABYLON.GUI {
  81001. /**
  81002. * Class used to create a container panel where items get randomized planar mapping
  81003. */
  81004. export class ScatterPanel extends VolumeBasedPanel {
  81005. private _iteration;
  81006. /**
  81007. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81008. */
  81009. get iteration(): BABYLON.float;
  81010. set iteration(value: BABYLON.float);
  81011. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81012. private _scatterMapping;
  81013. protected _finalProcessing(): void;
  81014. }
  81015. }
  81016. declare module BABYLON.GUI {
  81017. /**
  81018. * Class used to create a container panel deployed on the surface of a sphere
  81019. */
  81020. export class SpherePanel extends VolumeBasedPanel {
  81021. private _radius;
  81022. /**
  81023. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81024. */
  81025. get radius(): BABYLON.float;
  81026. set radius(value: BABYLON.float);
  81027. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81028. private _sphericalMapping;
  81029. }
  81030. }
  81031. declare module BABYLON.GUI {
  81032. /**
  81033. * Class used to create a stack panel in 3D on XY plane
  81034. */
  81035. export class StackPanel3D extends Container3D {
  81036. private _isVertical;
  81037. /**
  81038. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81039. */
  81040. get isVertical(): boolean;
  81041. set isVertical(value: boolean);
  81042. /**
  81043. * Gets or sets the distance between elements
  81044. */
  81045. margin: number;
  81046. /**
  81047. * Creates new StackPanel
  81048. * @param isVertical
  81049. */
  81050. constructor(isVertical?: boolean);
  81051. protected _arrangeChildren(): void;
  81052. }
  81053. }
  81054. declare module BABYLON {
  81055. /**
  81056. * Configuration for glTF validation
  81057. */
  81058. export interface IGLTFValidationConfiguration {
  81059. /**
  81060. * The url of the glTF validator.
  81061. */
  81062. url: string;
  81063. }
  81064. /**
  81065. * glTF validation
  81066. */
  81067. export class GLTFValidation {
  81068. /**
  81069. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81070. */
  81071. static Configuration: IGLTFValidationConfiguration;
  81072. private static _LoadScriptPromise;
  81073. /**
  81074. * Validate a glTF asset using the glTF-Validator.
  81075. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81076. * @param rootUrl The root url for the glTF
  81077. * @param fileName The file name for the glTF
  81078. * @param getExternalResource The callback to get external resources for the glTF validator
  81079. * @returns A promise that resolves with the glTF validation results once complete
  81080. */
  81081. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81082. }
  81083. }
  81084. declare module BABYLON {
  81085. /**
  81086. * Mode that determines the coordinate system to use.
  81087. */
  81088. export enum GLTFLoaderCoordinateSystemMode {
  81089. /**
  81090. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81091. */
  81092. AUTO = 0,
  81093. /**
  81094. * Sets the useRightHandedSystem flag on the scene.
  81095. */
  81096. FORCE_RIGHT_HANDED = 1
  81097. }
  81098. /**
  81099. * Mode that determines what animations will start.
  81100. */
  81101. export enum GLTFLoaderAnimationStartMode {
  81102. /**
  81103. * No animation will start.
  81104. */
  81105. NONE = 0,
  81106. /**
  81107. * The first animation will start.
  81108. */
  81109. FIRST = 1,
  81110. /**
  81111. * All animations will start.
  81112. */
  81113. ALL = 2
  81114. }
  81115. /**
  81116. * Interface that contains the data for the glTF asset.
  81117. */
  81118. export interface IGLTFLoaderData {
  81119. /**
  81120. * The object that represents the glTF JSON.
  81121. */
  81122. json: Object;
  81123. /**
  81124. * The BIN chunk of a binary glTF.
  81125. */
  81126. bin: Nullable<IDataBuffer>;
  81127. }
  81128. /**
  81129. * Interface for extending the loader.
  81130. */
  81131. export interface IGLTFLoaderExtension {
  81132. /**
  81133. * The name of this extension.
  81134. */
  81135. readonly name: string;
  81136. /**
  81137. * Defines whether this extension is enabled.
  81138. */
  81139. enabled: boolean;
  81140. /**
  81141. * Defines the order of this extension.
  81142. * The loader sorts the extensions using these values when loading.
  81143. */
  81144. order?: number;
  81145. }
  81146. /**
  81147. * Loader state.
  81148. */
  81149. export enum GLTFLoaderState {
  81150. /**
  81151. * The asset is loading.
  81152. */
  81153. LOADING = 0,
  81154. /**
  81155. * The asset is ready for rendering.
  81156. */
  81157. READY = 1,
  81158. /**
  81159. * The asset is completely loaded.
  81160. */
  81161. COMPLETE = 2
  81162. }
  81163. /** @hidden */
  81164. export interface IImportMeshAsyncOutput {
  81165. meshes: AbstractMesh[];
  81166. particleSystems: IParticleSystem[];
  81167. skeletons: Skeleton[];
  81168. animationGroups: AnimationGroup[];
  81169. lights: Light[];
  81170. transformNodes: TransformNode[];
  81171. }
  81172. /** @hidden */
  81173. export interface IGLTFLoader extends IDisposable {
  81174. readonly state: Nullable<GLTFLoaderState>;
  81175. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81176. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81177. }
  81178. /**
  81179. * File loader for loading glTF files into a scene.
  81180. */
  81181. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81182. /** @hidden */
  81183. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81184. /** @hidden */
  81185. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81186. /**
  81187. * Raised when the asset has been parsed
  81188. */
  81189. onParsedObservable: Observable<IGLTFLoaderData>;
  81190. private _onParsedObserver;
  81191. /**
  81192. * Raised when the asset has been parsed
  81193. */
  81194. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81195. /**
  81196. * 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.
  81197. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81198. * Defaults to true.
  81199. * @hidden
  81200. */
  81201. static IncrementalLoading: boolean;
  81202. /**
  81203. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81204. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81205. * @hidden
  81206. */
  81207. static HomogeneousCoordinates: boolean;
  81208. /**
  81209. * The coordinate system mode. Defaults to AUTO.
  81210. */
  81211. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81212. /**
  81213. * The animation start mode. Defaults to FIRST.
  81214. */
  81215. animationStartMode: GLTFLoaderAnimationStartMode;
  81216. /**
  81217. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81218. */
  81219. compileMaterials: boolean;
  81220. /**
  81221. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81222. */
  81223. useClipPlane: boolean;
  81224. /**
  81225. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81226. */
  81227. compileShadowGenerators: boolean;
  81228. /**
  81229. * Defines if the Alpha blended materials are only applied as coverage.
  81230. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81231. * If true, no extra effects are applied to transparent pixels.
  81232. */
  81233. transparencyAsCoverage: boolean;
  81234. /**
  81235. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81236. * Enabling will disable offline support and glTF validator.
  81237. * Defaults to false.
  81238. */
  81239. useRangeRequests: boolean;
  81240. /**
  81241. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81242. */
  81243. createInstances: boolean;
  81244. /**
  81245. * 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.
  81246. */
  81247. alwaysComputeBoundingBox: boolean;
  81248. /**
  81249. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81250. */
  81251. loadAllMaterials: boolean;
  81252. /**
  81253. * Function called before loading a url referenced by the asset.
  81254. */
  81255. preprocessUrlAsync: (url: string) => Promise<string>;
  81256. /**
  81257. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81258. * 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, ...)
  81259. */
  81260. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81261. private _onMeshLoadedObserver;
  81262. /**
  81263. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81264. * 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, ...)
  81265. */
  81266. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81267. /**
  81268. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81269. */
  81270. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81271. private _onTextureLoadedObserver;
  81272. /**
  81273. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81274. */
  81275. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81276. /**
  81277. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81278. */
  81279. readonly onMaterialLoadedObservable: Observable<Material>;
  81280. private _onMaterialLoadedObserver;
  81281. /**
  81282. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81283. */
  81284. set onMaterialLoaded(callback: (material: Material) => void);
  81285. /**
  81286. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81287. */
  81288. readonly onCameraLoadedObservable: Observable<Camera>;
  81289. private _onCameraLoadedObserver;
  81290. /**
  81291. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81292. */
  81293. set onCameraLoaded(callback: (camera: Camera) => void);
  81294. /**
  81295. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81296. * For assets with LODs, raised when all of the LODs are complete.
  81297. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81298. */
  81299. readonly onCompleteObservable: Observable<void>;
  81300. private _onCompleteObserver;
  81301. /**
  81302. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81303. * For assets with LODs, raised when all of the LODs are complete.
  81304. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81305. */
  81306. set onComplete(callback: () => void);
  81307. /**
  81308. * Observable raised when an error occurs.
  81309. */
  81310. readonly onErrorObservable: Observable<any>;
  81311. private _onErrorObserver;
  81312. /**
  81313. * Callback raised when an error occurs.
  81314. */
  81315. set onError(callback: (reason: any) => void);
  81316. /**
  81317. * Observable raised after the loader is disposed.
  81318. */
  81319. readonly onDisposeObservable: Observable<void>;
  81320. private _onDisposeObserver;
  81321. /**
  81322. * Callback raised after the loader is disposed.
  81323. */
  81324. set onDispose(callback: () => void);
  81325. /**
  81326. * Observable raised after a loader extension is created.
  81327. * Set additional options for a loader extension in this event.
  81328. */
  81329. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81330. private _onExtensionLoadedObserver;
  81331. /**
  81332. * Callback raised after a loader extension is created.
  81333. */
  81334. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81335. /**
  81336. * Defines if the loader logging is enabled.
  81337. */
  81338. get loggingEnabled(): boolean;
  81339. set loggingEnabled(value: boolean);
  81340. /**
  81341. * Defines if the loader should capture performance counters.
  81342. */
  81343. get capturePerformanceCounters(): boolean;
  81344. set capturePerformanceCounters(value: boolean);
  81345. /**
  81346. * Defines if the loader should validate the asset.
  81347. */
  81348. validate: boolean;
  81349. /**
  81350. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81351. */
  81352. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81353. private _onValidatedObserver;
  81354. /**
  81355. * Callback raised after a loader extension is created.
  81356. */
  81357. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81358. private _loader;
  81359. private _progressCallback?;
  81360. private _requests;
  81361. private static magicBase64Encoded;
  81362. /**
  81363. * Name of the loader ("gltf")
  81364. */
  81365. name: string;
  81366. /** @hidden */
  81367. extensions: ISceneLoaderPluginExtensions;
  81368. /**
  81369. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81370. */
  81371. dispose(): void;
  81372. /** @hidden */
  81373. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81374. /** @hidden */
  81375. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81376. /** @hidden */
  81377. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81378. meshes: AbstractMesh[];
  81379. particleSystems: IParticleSystem[];
  81380. skeletons: Skeleton[];
  81381. animationGroups: AnimationGroup[];
  81382. }>;
  81383. /** @hidden */
  81384. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81385. /** @hidden */
  81386. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81387. /** @hidden */
  81388. canDirectLoad(data: string): boolean;
  81389. /** @hidden */
  81390. directLoad(scene: Scene, data: string): Promise<any>;
  81391. /**
  81392. * The callback that allows custom handling of the root url based on the response url.
  81393. * @param rootUrl the original root url
  81394. * @param responseURL the response url if available
  81395. * @returns the new root url
  81396. */
  81397. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81398. /** @hidden */
  81399. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81400. /**
  81401. * The loader state or null if the loader is not active.
  81402. */
  81403. get loaderState(): Nullable<GLTFLoaderState>;
  81404. /**
  81405. * Returns a promise that resolves when the asset is completely loaded.
  81406. * @returns a promise that resolves when the asset is completely loaded.
  81407. */
  81408. whenCompleteAsync(): Promise<void>;
  81409. /** @hidden */
  81410. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81411. /** @hidden */
  81412. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81413. private _onProgress;
  81414. private _validate;
  81415. private _getLoader;
  81416. private _parseJson;
  81417. private _unpackBinaryAsync;
  81418. private _unpackBinaryV1Async;
  81419. private _unpackBinaryV2Async;
  81420. private static _parseVersion;
  81421. private static _compareVersion;
  81422. private static readonly _logSpaces;
  81423. private _logIndentLevel;
  81424. private _loggingEnabled;
  81425. /** @hidden */
  81426. _log: (message: string) => void;
  81427. /** @hidden */
  81428. _logOpen(message: string): void;
  81429. /** @hidden */
  81430. _logClose(): void;
  81431. private _logEnabled;
  81432. private _logDisabled;
  81433. private _capturePerformanceCounters;
  81434. /** @hidden */
  81435. _startPerformanceCounter: (counterName: string) => void;
  81436. /** @hidden */
  81437. _endPerformanceCounter: (counterName: string) => void;
  81438. private _startPerformanceCounterEnabled;
  81439. private _startPerformanceCounterDisabled;
  81440. private _endPerformanceCounterEnabled;
  81441. private _endPerformanceCounterDisabled;
  81442. }
  81443. }
  81444. declare module BABYLON.GLTF1 {
  81445. /**
  81446. * Enums
  81447. * @hidden
  81448. */
  81449. export enum EComponentType {
  81450. BYTE = 5120,
  81451. UNSIGNED_BYTE = 5121,
  81452. SHORT = 5122,
  81453. UNSIGNED_SHORT = 5123,
  81454. FLOAT = 5126
  81455. }
  81456. /** @hidden */
  81457. export enum EShaderType {
  81458. FRAGMENT = 35632,
  81459. VERTEX = 35633
  81460. }
  81461. /** @hidden */
  81462. export enum EParameterType {
  81463. BYTE = 5120,
  81464. UNSIGNED_BYTE = 5121,
  81465. SHORT = 5122,
  81466. UNSIGNED_SHORT = 5123,
  81467. INT = 5124,
  81468. UNSIGNED_INT = 5125,
  81469. FLOAT = 5126,
  81470. FLOAT_VEC2 = 35664,
  81471. FLOAT_VEC3 = 35665,
  81472. FLOAT_VEC4 = 35666,
  81473. INT_VEC2 = 35667,
  81474. INT_VEC3 = 35668,
  81475. INT_VEC4 = 35669,
  81476. BOOL = 35670,
  81477. BOOL_VEC2 = 35671,
  81478. BOOL_VEC3 = 35672,
  81479. BOOL_VEC4 = 35673,
  81480. FLOAT_MAT2 = 35674,
  81481. FLOAT_MAT3 = 35675,
  81482. FLOAT_MAT4 = 35676,
  81483. SAMPLER_2D = 35678
  81484. }
  81485. /** @hidden */
  81486. export enum ETextureWrapMode {
  81487. CLAMP_TO_EDGE = 33071,
  81488. MIRRORED_REPEAT = 33648,
  81489. REPEAT = 10497
  81490. }
  81491. /** @hidden */
  81492. export enum ETextureFilterType {
  81493. NEAREST = 9728,
  81494. LINEAR = 9728,
  81495. NEAREST_MIPMAP_NEAREST = 9984,
  81496. LINEAR_MIPMAP_NEAREST = 9985,
  81497. NEAREST_MIPMAP_LINEAR = 9986,
  81498. LINEAR_MIPMAP_LINEAR = 9987
  81499. }
  81500. /** @hidden */
  81501. export enum ETextureFormat {
  81502. ALPHA = 6406,
  81503. RGB = 6407,
  81504. RGBA = 6408,
  81505. LUMINANCE = 6409,
  81506. LUMINANCE_ALPHA = 6410
  81507. }
  81508. /** @hidden */
  81509. export enum ECullingType {
  81510. FRONT = 1028,
  81511. BACK = 1029,
  81512. FRONT_AND_BACK = 1032
  81513. }
  81514. /** @hidden */
  81515. export enum EBlendingFunction {
  81516. ZERO = 0,
  81517. ONE = 1,
  81518. SRC_COLOR = 768,
  81519. ONE_MINUS_SRC_COLOR = 769,
  81520. DST_COLOR = 774,
  81521. ONE_MINUS_DST_COLOR = 775,
  81522. SRC_ALPHA = 770,
  81523. ONE_MINUS_SRC_ALPHA = 771,
  81524. DST_ALPHA = 772,
  81525. ONE_MINUS_DST_ALPHA = 773,
  81526. CONSTANT_COLOR = 32769,
  81527. ONE_MINUS_CONSTANT_COLOR = 32770,
  81528. CONSTANT_ALPHA = 32771,
  81529. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81530. SRC_ALPHA_SATURATE = 776
  81531. }
  81532. /** @hidden */
  81533. export interface IGLTFProperty {
  81534. extensions?: {
  81535. [key: string]: any;
  81536. };
  81537. extras?: Object;
  81538. }
  81539. /** @hidden */
  81540. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81541. name?: string;
  81542. }
  81543. /** @hidden */
  81544. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81545. bufferView: string;
  81546. byteOffset: number;
  81547. byteStride: number;
  81548. count: number;
  81549. type: string;
  81550. componentType: EComponentType;
  81551. max?: number[];
  81552. min?: number[];
  81553. name?: string;
  81554. }
  81555. /** @hidden */
  81556. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81557. buffer: string;
  81558. byteOffset: number;
  81559. byteLength: number;
  81560. byteStride: number;
  81561. target?: number;
  81562. }
  81563. /** @hidden */
  81564. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81565. uri: string;
  81566. byteLength?: number;
  81567. type?: string;
  81568. }
  81569. /** @hidden */
  81570. export interface IGLTFShader extends IGLTFChildRootProperty {
  81571. uri: string;
  81572. type: EShaderType;
  81573. }
  81574. /** @hidden */
  81575. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81576. attributes: string[];
  81577. fragmentShader: string;
  81578. vertexShader: string;
  81579. }
  81580. /** @hidden */
  81581. export interface IGLTFTechniqueParameter {
  81582. type: number;
  81583. count?: number;
  81584. semantic?: string;
  81585. node?: string;
  81586. value?: number | boolean | string | Array<any>;
  81587. source?: string;
  81588. babylonValue?: any;
  81589. }
  81590. /** @hidden */
  81591. export interface IGLTFTechniqueCommonProfile {
  81592. lightingModel: string;
  81593. texcoordBindings: Object;
  81594. parameters?: Array<any>;
  81595. }
  81596. /** @hidden */
  81597. export interface IGLTFTechniqueStatesFunctions {
  81598. blendColor?: number[];
  81599. blendEquationSeparate?: number[];
  81600. blendFuncSeparate?: number[];
  81601. colorMask: boolean[];
  81602. cullFace: number[];
  81603. }
  81604. /** @hidden */
  81605. export interface IGLTFTechniqueStates {
  81606. enable: number[];
  81607. functions: IGLTFTechniqueStatesFunctions;
  81608. }
  81609. /** @hidden */
  81610. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81611. parameters: {
  81612. [key: string]: IGLTFTechniqueParameter;
  81613. };
  81614. program: string;
  81615. attributes: {
  81616. [key: string]: string;
  81617. };
  81618. uniforms: {
  81619. [key: string]: string;
  81620. };
  81621. states: IGLTFTechniqueStates;
  81622. }
  81623. /** @hidden */
  81624. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81625. technique?: string;
  81626. values: string[];
  81627. }
  81628. /** @hidden */
  81629. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81630. attributes: {
  81631. [key: string]: string;
  81632. };
  81633. indices: string;
  81634. material: string;
  81635. mode?: number;
  81636. }
  81637. /** @hidden */
  81638. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81639. primitives: IGLTFMeshPrimitive[];
  81640. }
  81641. /** @hidden */
  81642. export interface IGLTFImage extends IGLTFChildRootProperty {
  81643. uri: string;
  81644. }
  81645. /** @hidden */
  81646. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81647. magFilter?: number;
  81648. minFilter?: number;
  81649. wrapS?: number;
  81650. wrapT?: number;
  81651. }
  81652. /** @hidden */
  81653. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81654. sampler: string;
  81655. source: string;
  81656. format?: ETextureFormat;
  81657. internalFormat?: ETextureFormat;
  81658. target?: number;
  81659. type?: number;
  81660. babylonTexture?: Texture;
  81661. }
  81662. /** @hidden */
  81663. export interface IGLTFAmbienLight {
  81664. color?: number[];
  81665. }
  81666. /** @hidden */
  81667. export interface IGLTFDirectionalLight {
  81668. color?: number[];
  81669. }
  81670. /** @hidden */
  81671. export interface IGLTFPointLight {
  81672. color?: number[];
  81673. constantAttenuation?: number;
  81674. linearAttenuation?: number;
  81675. quadraticAttenuation?: number;
  81676. }
  81677. /** @hidden */
  81678. export interface IGLTFSpotLight {
  81679. color?: number[];
  81680. constantAttenuation?: number;
  81681. fallOfAngle?: number;
  81682. fallOffExponent?: number;
  81683. linearAttenuation?: number;
  81684. quadraticAttenuation?: number;
  81685. }
  81686. /** @hidden */
  81687. export interface IGLTFLight extends IGLTFChildRootProperty {
  81688. type: string;
  81689. }
  81690. /** @hidden */
  81691. export interface IGLTFCameraOrthographic {
  81692. xmag: number;
  81693. ymag: number;
  81694. zfar: number;
  81695. znear: number;
  81696. }
  81697. /** @hidden */
  81698. export interface IGLTFCameraPerspective {
  81699. aspectRatio: number;
  81700. yfov: number;
  81701. zfar: number;
  81702. znear: number;
  81703. }
  81704. /** @hidden */
  81705. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81706. type: string;
  81707. }
  81708. /** @hidden */
  81709. export interface IGLTFAnimationChannelTarget {
  81710. id: string;
  81711. path: string;
  81712. }
  81713. /** @hidden */
  81714. export interface IGLTFAnimationChannel {
  81715. sampler: string;
  81716. target: IGLTFAnimationChannelTarget;
  81717. }
  81718. /** @hidden */
  81719. export interface IGLTFAnimationSampler {
  81720. input: string;
  81721. output: string;
  81722. interpolation?: string;
  81723. }
  81724. /** @hidden */
  81725. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81726. channels?: IGLTFAnimationChannel[];
  81727. parameters?: {
  81728. [key: string]: string;
  81729. };
  81730. samplers?: {
  81731. [key: string]: IGLTFAnimationSampler;
  81732. };
  81733. }
  81734. /** @hidden */
  81735. export interface IGLTFNodeInstanceSkin {
  81736. skeletons: string[];
  81737. skin: string;
  81738. meshes: string[];
  81739. }
  81740. /** @hidden */
  81741. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81742. bindShapeMatrix: number[];
  81743. inverseBindMatrices: string;
  81744. jointNames: string[];
  81745. babylonSkeleton?: Skeleton;
  81746. }
  81747. /** @hidden */
  81748. export interface IGLTFNode extends IGLTFChildRootProperty {
  81749. camera?: string;
  81750. children: string[];
  81751. skin?: string;
  81752. jointName?: string;
  81753. light?: string;
  81754. matrix: number[];
  81755. mesh?: string;
  81756. meshes?: string[];
  81757. rotation?: number[];
  81758. scale?: number[];
  81759. translation?: number[];
  81760. babylonNode?: Node;
  81761. }
  81762. /** @hidden */
  81763. export interface IGLTFScene extends IGLTFChildRootProperty {
  81764. nodes: string[];
  81765. }
  81766. /** @hidden */
  81767. export interface IGLTFRuntime {
  81768. extensions: {
  81769. [key: string]: any;
  81770. };
  81771. accessors: {
  81772. [key: string]: IGLTFAccessor;
  81773. };
  81774. buffers: {
  81775. [key: string]: IGLTFBuffer;
  81776. };
  81777. bufferViews: {
  81778. [key: string]: IGLTFBufferView;
  81779. };
  81780. meshes: {
  81781. [key: string]: IGLTFMesh;
  81782. };
  81783. lights: {
  81784. [key: string]: IGLTFLight;
  81785. };
  81786. cameras: {
  81787. [key: string]: IGLTFCamera;
  81788. };
  81789. nodes: {
  81790. [key: string]: IGLTFNode;
  81791. };
  81792. images: {
  81793. [key: string]: IGLTFImage;
  81794. };
  81795. textures: {
  81796. [key: string]: IGLTFTexture;
  81797. };
  81798. shaders: {
  81799. [key: string]: IGLTFShader;
  81800. };
  81801. programs: {
  81802. [key: string]: IGLTFProgram;
  81803. };
  81804. samplers: {
  81805. [key: string]: IGLTFSampler;
  81806. };
  81807. techniques: {
  81808. [key: string]: IGLTFTechnique;
  81809. };
  81810. materials: {
  81811. [key: string]: IGLTFMaterial;
  81812. };
  81813. animations: {
  81814. [key: string]: IGLTFAnimation;
  81815. };
  81816. skins: {
  81817. [key: string]: IGLTFSkins;
  81818. };
  81819. currentScene?: Object;
  81820. scenes: {
  81821. [key: string]: IGLTFScene;
  81822. };
  81823. extensionsUsed: string[];
  81824. extensionsRequired?: string[];
  81825. buffersCount: number;
  81826. shaderscount: number;
  81827. scene: Scene;
  81828. rootUrl: string;
  81829. loadedBufferCount: number;
  81830. loadedBufferViews: {
  81831. [name: string]: ArrayBufferView;
  81832. };
  81833. loadedShaderCount: number;
  81834. importOnlyMeshes: boolean;
  81835. importMeshesNames?: string[];
  81836. dummyNodes: Node[];
  81837. forAssetContainer: boolean;
  81838. }
  81839. /** @hidden */
  81840. export interface INodeToRoot {
  81841. bone: Bone;
  81842. node: IGLTFNode;
  81843. id: string;
  81844. }
  81845. /** @hidden */
  81846. export interface IJointNode {
  81847. node: IGLTFNode;
  81848. id: string;
  81849. }
  81850. }
  81851. declare module BABYLON.GLTF1 {
  81852. /**
  81853. * Utils functions for GLTF
  81854. * @hidden
  81855. */
  81856. export class GLTFUtils {
  81857. /**
  81858. * Sets the given "parameter" matrix
  81859. * @param scene: the Scene object
  81860. * @param source: the source node where to pick the matrix
  81861. * @param parameter: the GLTF technique parameter
  81862. * @param uniformName: the name of the shader's uniform
  81863. * @param shaderMaterial: the shader material
  81864. */
  81865. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  81866. /**
  81867. * Sets the given "parameter" matrix
  81868. * @param shaderMaterial: the shader material
  81869. * @param uniform: the name of the shader's uniform
  81870. * @param value: the value of the uniform
  81871. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  81872. */
  81873. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  81874. /**
  81875. * Returns the wrap mode of the texture
  81876. * @param mode: the mode value
  81877. */
  81878. static GetWrapMode(mode: number): number;
  81879. /**
  81880. * Returns the byte stride giving an accessor
  81881. * @param accessor: the GLTF accessor objet
  81882. */
  81883. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  81884. /**
  81885. * Returns the texture filter mode giving a mode value
  81886. * @param mode: the filter mode value
  81887. */
  81888. static GetTextureFilterMode(mode: number): ETextureFilterType;
  81889. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  81890. /**
  81891. * Returns a buffer from its accessor
  81892. * @param gltfRuntime: the GLTF runtime
  81893. * @param accessor: the GLTF accessor
  81894. */
  81895. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  81896. /**
  81897. * Decodes a buffer view into a string
  81898. * @param view: the buffer view
  81899. */
  81900. static DecodeBufferToText(view: ArrayBufferView): string;
  81901. /**
  81902. * Returns the default material of gltf. Related to
  81903. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  81904. * @param scene: the Babylon.js scene
  81905. */
  81906. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  81907. private static _DefaultMaterial;
  81908. }
  81909. }
  81910. declare module BABYLON.GLTF1 {
  81911. /**
  81912. * Implementation of the base glTF spec
  81913. * @hidden
  81914. */
  81915. export class GLTFLoaderBase {
  81916. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  81917. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81918. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  81919. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81920. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  81921. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81922. }
  81923. /**
  81924. * glTF V1 Loader
  81925. * @hidden
  81926. */
  81927. export class GLTFLoader implements IGLTFLoader {
  81928. static Extensions: {
  81929. [name: string]: GLTFLoaderExtension;
  81930. };
  81931. static RegisterExtension(extension: GLTFLoaderExtension): void;
  81932. state: Nullable<GLTFLoaderState>;
  81933. dispose(): void;
  81934. private _importMeshAsync;
  81935. /**
  81936. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  81937. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81938. * @param scene the scene the meshes should be added to
  81939. * @param forAssetContainer defines if the entities must be stored in the scene
  81940. * @param data gltf data containing information of the meshes in a loaded file
  81941. * @param rootUrl root url to load from
  81942. * @param onProgress event that fires when loading progress has occured
  81943. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81944. */
  81945. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  81946. private _loadAsync;
  81947. /**
  81948. * Imports all objects from a loaded gltf file and adds them to the scene
  81949. * @param scene the scene the objects should be added to
  81950. * @param data gltf data containing information of the meshes in a loaded file
  81951. * @param rootUrl root url to load from
  81952. * @param onProgress event that fires when loading progress has occured
  81953. * @returns a promise which completes when objects have been loaded to the scene
  81954. */
  81955. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  81956. private _loadShadersAsync;
  81957. private _loadBuffersAsync;
  81958. private _createNodes;
  81959. }
  81960. /** @hidden */
  81961. export abstract class GLTFLoaderExtension {
  81962. private _name;
  81963. constructor(name: string);
  81964. get name(): string;
  81965. /**
  81966. * Defines an override for loading the runtime
  81967. * Return true to stop further extensions from loading the runtime
  81968. */
  81969. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81970. /**
  81971. * Defines an onverride for creating gltf runtime
  81972. * Return true to stop further extensions from creating the runtime
  81973. */
  81974. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81975. /**
  81976. * Defines an override for loading buffers
  81977. * Return true to stop further extensions from loading this buffer
  81978. */
  81979. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81980. /**
  81981. * Defines an override for loading texture buffers
  81982. * Return true to stop further extensions from loading this texture data
  81983. */
  81984. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81985. /**
  81986. * Defines an override for creating textures
  81987. * Return true to stop further extensions from loading this texture
  81988. */
  81989. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81990. /**
  81991. * Defines an override for loading shader strings
  81992. * Return true to stop further extensions from loading this shader data
  81993. */
  81994. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81995. /**
  81996. * Defines an override for loading materials
  81997. * Return true to stop further extensions from loading this material
  81998. */
  81999. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82000. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82001. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82002. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82003. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82004. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82005. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82006. private static LoadTextureBufferAsync;
  82007. private static CreateTextureAsync;
  82008. private static ApplyExtensions;
  82009. }
  82010. }
  82011. declare module BABYLON.GLTF1 {
  82012. /** @hidden */
  82013. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82014. private _bin;
  82015. constructor();
  82016. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82017. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82018. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82019. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82020. }
  82021. }
  82022. declare module BABYLON.GLTF1 {
  82023. /** @hidden */
  82024. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82025. constructor();
  82026. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82027. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82028. private _loadTexture;
  82029. }
  82030. }
  82031. declare module BABYLON.GLTF2.Loader {
  82032. /**
  82033. * Loader interface with an index field.
  82034. */
  82035. export interface IArrayItem {
  82036. /**
  82037. * The index of this item in the array.
  82038. */
  82039. index: number;
  82040. }
  82041. /**
  82042. * Loader interface with additional members.
  82043. */
  82044. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82045. /** @hidden */
  82046. _data?: Promise<ArrayBufferView>;
  82047. /** @hidden */
  82048. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82049. }
  82050. /**
  82051. * Loader interface with additional members.
  82052. */
  82053. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82054. }
  82055. /** @hidden */
  82056. export interface _IAnimationSamplerData {
  82057. input: Float32Array;
  82058. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82059. output: Float32Array;
  82060. }
  82061. /**
  82062. * Loader interface with additional members.
  82063. */
  82064. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82065. /** @hidden */
  82066. _data?: Promise<_IAnimationSamplerData>;
  82067. }
  82068. /**
  82069. * Loader interface with additional members.
  82070. */
  82071. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82072. channels: IAnimationChannel[];
  82073. samplers: IAnimationSampler[];
  82074. /** @hidden */
  82075. _babylonAnimationGroup?: AnimationGroup;
  82076. }
  82077. /**
  82078. * Loader interface with additional members.
  82079. */
  82080. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82081. /** @hidden */
  82082. _data?: Promise<ArrayBufferView>;
  82083. }
  82084. /**
  82085. * Loader interface with additional members.
  82086. */
  82087. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82088. /** @hidden */
  82089. _data?: Promise<ArrayBufferView>;
  82090. /** @hidden */
  82091. _babylonBuffer?: Promise<Buffer>;
  82092. }
  82093. /**
  82094. * Loader interface with additional members.
  82095. */
  82096. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82097. }
  82098. /**
  82099. * Loader interface with additional members.
  82100. */
  82101. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82102. /** @hidden */
  82103. _data?: Promise<ArrayBufferView>;
  82104. }
  82105. /**
  82106. * Loader interface with additional members.
  82107. */
  82108. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82109. }
  82110. /**
  82111. * Loader interface with additional members.
  82112. */
  82113. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82114. }
  82115. /**
  82116. * Loader interface with additional members.
  82117. */
  82118. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82119. baseColorTexture?: ITextureInfo;
  82120. metallicRoughnessTexture?: ITextureInfo;
  82121. }
  82122. /**
  82123. * Loader interface with additional members.
  82124. */
  82125. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82126. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82127. normalTexture?: IMaterialNormalTextureInfo;
  82128. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82129. emissiveTexture?: ITextureInfo;
  82130. /** @hidden */
  82131. _data?: {
  82132. [babylonDrawMode: number]: {
  82133. babylonMaterial: Material;
  82134. babylonMeshes: AbstractMesh[];
  82135. promise: Promise<void>;
  82136. };
  82137. };
  82138. }
  82139. /**
  82140. * Loader interface with additional members.
  82141. */
  82142. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82143. primitives: IMeshPrimitive[];
  82144. }
  82145. /**
  82146. * Loader interface with additional members.
  82147. */
  82148. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82149. /** @hidden */
  82150. _instanceData?: {
  82151. babylonSourceMesh: Mesh;
  82152. promise: Promise<any>;
  82153. };
  82154. }
  82155. /**
  82156. * Loader interface with additional members.
  82157. */
  82158. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82159. /**
  82160. * The parent glTF node.
  82161. */
  82162. parent?: INode;
  82163. /** @hidden */
  82164. _babylonTransformNode?: TransformNode;
  82165. /** @hidden */
  82166. _primitiveBabylonMeshes?: AbstractMesh[];
  82167. /** @hidden */
  82168. _babylonBones?: Bone[];
  82169. /** @hidden */
  82170. _numMorphTargets?: number;
  82171. }
  82172. /** @hidden */
  82173. export interface _ISamplerData {
  82174. noMipMaps: boolean;
  82175. samplingMode: number;
  82176. wrapU: number;
  82177. wrapV: number;
  82178. }
  82179. /**
  82180. * Loader interface with additional members.
  82181. */
  82182. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82183. /** @hidden */
  82184. _data?: _ISamplerData;
  82185. }
  82186. /**
  82187. * Loader interface with additional members.
  82188. */
  82189. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82190. }
  82191. /**
  82192. * Loader interface with additional members.
  82193. */
  82194. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82195. /** @hidden */
  82196. _data?: {
  82197. babylonSkeleton: Skeleton;
  82198. promise: Promise<void>;
  82199. };
  82200. }
  82201. /**
  82202. * Loader interface with additional members.
  82203. */
  82204. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82205. }
  82206. /**
  82207. * Loader interface with additional members.
  82208. */
  82209. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82210. }
  82211. /**
  82212. * Loader interface with additional members.
  82213. */
  82214. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82215. accessors?: IAccessor[];
  82216. animations?: IAnimation[];
  82217. buffers?: IBuffer[];
  82218. bufferViews?: IBufferView[];
  82219. cameras?: ICamera[];
  82220. images?: IImage[];
  82221. materials?: IMaterial[];
  82222. meshes?: IMesh[];
  82223. nodes?: INode[];
  82224. samplers?: ISampler[];
  82225. scenes?: IScene[];
  82226. skins?: ISkin[];
  82227. textures?: ITexture[];
  82228. }
  82229. }
  82230. declare module BABYLON.GLTF2 {
  82231. /**
  82232. * Interface for a glTF loader extension.
  82233. */
  82234. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82235. /**
  82236. * Called after the loader state changes to LOADING.
  82237. */
  82238. onLoading?(): void;
  82239. /**
  82240. * Called after the loader state changes to READY.
  82241. */
  82242. onReady?(): void;
  82243. /**
  82244. * Define this method to modify the default behavior when loading scenes.
  82245. * @param context The context when loading the asset
  82246. * @param scene The glTF scene property
  82247. * @returns A promise that resolves when the load is complete or null if not handled
  82248. */
  82249. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82250. /**
  82251. * Define this method to modify the default behavior when loading nodes.
  82252. * @param context The context when loading the asset
  82253. * @param node The glTF node property
  82254. * @param assign A function called synchronously after parsing the glTF properties
  82255. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82256. */
  82257. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82258. /**
  82259. * Define this method to modify the default behavior when loading cameras.
  82260. * @param context The context when loading the asset
  82261. * @param camera The glTF camera property
  82262. * @param assign A function called synchronously after parsing the glTF properties
  82263. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82264. */
  82265. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82266. /**
  82267. * @hidden
  82268. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82269. * @param context The context when loading the asset
  82270. * @param primitive The glTF mesh primitive property
  82271. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82272. */
  82273. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82274. /**
  82275. * @hidden
  82276. * Define this method to modify the default behavior when loading data for mesh primitives.
  82277. * @param context The context when loading the asset
  82278. * @param name The mesh name when loading the asset
  82279. * @param node The glTF node when loading the asset
  82280. * @param mesh The glTF mesh when loading the asset
  82281. * @param primitive The glTF mesh primitive property
  82282. * @param assign A function called synchronously after parsing the glTF properties
  82283. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82284. */
  82285. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82286. /**
  82287. * @hidden
  82288. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82289. * @param context The context when loading the asset
  82290. * @param material The glTF material property
  82291. * @param assign A function called synchronously after parsing the glTF properties
  82292. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82293. */
  82294. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82295. /**
  82296. * Define this method to modify the default behavior when creating materials.
  82297. * @param context The context when loading the asset
  82298. * @param material The glTF material property
  82299. * @param babylonDrawMode The draw mode for the Babylon material
  82300. * @returns The Babylon material or null if not handled
  82301. */
  82302. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82303. /**
  82304. * Define this method to modify the default behavior when loading material properties.
  82305. * @param context The context when loading the asset
  82306. * @param material The glTF material property
  82307. * @param babylonMaterial The Babylon material
  82308. * @returns A promise that resolves when the load is complete or null if not handled
  82309. */
  82310. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82311. /**
  82312. * Define this method to modify the default behavior when loading texture infos.
  82313. * @param context The context when loading the asset
  82314. * @param textureInfo The glTF texture info property
  82315. * @param assign A function called synchronously after parsing the glTF properties
  82316. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82317. */
  82318. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82319. /**
  82320. * @hidden
  82321. * Define this method to modify the default behavior when loading textures.
  82322. * @param context The context when loading the asset
  82323. * @param texture The glTF texture property
  82324. * @param assign A function called synchronously after parsing the glTF properties
  82325. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82326. */
  82327. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82328. /**
  82329. * Define this method to modify the default behavior when loading animations.
  82330. * @param context The context when loading the asset
  82331. * @param animation The glTF animation property
  82332. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82333. */
  82334. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82335. /**
  82336. * @hidden
  82337. * Define this method to modify the default behavior when loading skins.
  82338. * @param context The context when loading the asset
  82339. * @param node The glTF node property
  82340. * @param skin The glTF skin property
  82341. * @returns A promise that resolves when the load is complete or null if not handled
  82342. */
  82343. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82344. /**
  82345. * @hidden
  82346. * Define this method to modify the default behavior when loading uris.
  82347. * @param context The context when loading the asset
  82348. * @param property The glTF property associated with the uri
  82349. * @param uri The uri to load
  82350. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82351. */
  82352. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82353. /**
  82354. * Define this method to modify the default behavior when loading buffer views.
  82355. * @param context The context when loading the asset
  82356. * @param bufferView The glTF buffer view property
  82357. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82358. */
  82359. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82360. /**
  82361. * Define this method to modify the default behavior when loading buffers.
  82362. * @param context The context when loading the asset
  82363. * @param buffer The glTF buffer property
  82364. * @param byteOffset The byte offset to load
  82365. * @param byteLength The byte length to load
  82366. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82367. */
  82368. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82369. }
  82370. }
  82371. declare module BABYLON.GLTF2 {
  82372. /**
  82373. * Helper class for working with arrays when loading the glTF asset
  82374. */
  82375. export class ArrayItem {
  82376. /**
  82377. * Gets an item from the given array.
  82378. * @param context The context when loading the asset
  82379. * @param array The array to get the item from
  82380. * @param index The index to the array
  82381. * @returns The array item
  82382. */
  82383. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82384. /**
  82385. * Assign an `index` field to each item of the given array.
  82386. * @param array The array of items
  82387. */
  82388. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82389. }
  82390. /**
  82391. * The glTF 2.0 loader
  82392. */
  82393. export class GLTFLoader implements IGLTFLoader {
  82394. /** @hidden */
  82395. _completePromises: Promise<any>[];
  82396. /** @hidden */
  82397. _forAssetContainer: boolean;
  82398. /** Storage */
  82399. _babylonLights: Light[];
  82400. /** @hidden */
  82401. _disableInstancedMesh: number;
  82402. private _disposed;
  82403. private _parent;
  82404. private _state;
  82405. private _extensions;
  82406. private _rootUrl;
  82407. private _fileName;
  82408. private _uniqueRootUrl;
  82409. private _gltf;
  82410. private _bin;
  82411. private _babylonScene;
  82412. private _rootBabylonMesh;
  82413. private _defaultBabylonMaterialData;
  82414. private static _RegisteredExtensions;
  82415. /**
  82416. * The default glTF sampler.
  82417. */
  82418. static readonly DefaultSampler: ISampler;
  82419. /**
  82420. * Registers a loader extension.
  82421. * @param name The name of the loader extension.
  82422. * @param factory The factory function that creates the loader extension.
  82423. */
  82424. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82425. /**
  82426. * Unregisters a loader extension.
  82427. * @param name The name of the loader extension.
  82428. * @returns A boolean indicating whether the extension has been unregistered
  82429. */
  82430. static UnregisterExtension(name: string): boolean;
  82431. /**
  82432. * The loader state.
  82433. */
  82434. get state(): Nullable<GLTFLoaderState>;
  82435. /**
  82436. * The object that represents the glTF JSON.
  82437. */
  82438. get gltf(): IGLTF;
  82439. /**
  82440. * The BIN chunk of a binary glTF.
  82441. */
  82442. get bin(): Nullable<IDataBuffer>;
  82443. /**
  82444. * The parent file loader.
  82445. */
  82446. get parent(): GLTFFileLoader;
  82447. /**
  82448. * The Babylon scene when loading the asset.
  82449. */
  82450. get babylonScene(): Scene;
  82451. /**
  82452. * The root Babylon mesh when loading the asset.
  82453. */
  82454. get rootBabylonMesh(): Mesh;
  82455. /** @hidden */
  82456. constructor(parent: GLTFFileLoader);
  82457. /** @hidden */
  82458. dispose(): void;
  82459. /** @hidden */
  82460. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82461. /** @hidden */
  82462. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82463. private _loadAsync;
  82464. private _loadData;
  82465. private _setupData;
  82466. private _loadExtensions;
  82467. private _checkExtensions;
  82468. private _setState;
  82469. private _createRootNode;
  82470. /**
  82471. * Loads a glTF scene.
  82472. * @param context The context when loading the asset
  82473. * @param scene The glTF scene property
  82474. * @returns A promise that resolves when the load is complete
  82475. */
  82476. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82477. private _forEachPrimitive;
  82478. private _getMeshes;
  82479. private _getTransformNodes;
  82480. private _getSkeletons;
  82481. private _getAnimationGroups;
  82482. private _startAnimations;
  82483. /**
  82484. * Loads a glTF node.
  82485. * @param context The context when loading the asset
  82486. * @param node The glTF node property
  82487. * @param assign A function called synchronously after parsing the glTF properties
  82488. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82489. */
  82490. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82491. private _loadMeshAsync;
  82492. /**
  82493. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82494. * @param context The context when loading the asset
  82495. * @param name The mesh name when loading the asset
  82496. * @param node The glTF node when loading the asset
  82497. * @param mesh The glTF mesh when loading the asset
  82498. * @param primitive The glTF mesh primitive property
  82499. * @param assign A function called synchronously after parsing the glTF properties
  82500. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82501. */
  82502. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82503. private _loadVertexDataAsync;
  82504. private _createMorphTargets;
  82505. private _loadMorphTargetsAsync;
  82506. private _loadMorphTargetVertexDataAsync;
  82507. private static _LoadTransform;
  82508. private _loadSkinAsync;
  82509. private _loadBones;
  82510. private _loadBone;
  82511. private _loadSkinInverseBindMatricesDataAsync;
  82512. private _updateBoneMatrices;
  82513. private _getNodeMatrix;
  82514. /**
  82515. * Loads a glTF camera.
  82516. * @param context The context when loading the asset
  82517. * @param camera The glTF camera property
  82518. * @param assign A function called synchronously after parsing the glTF properties
  82519. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82520. */
  82521. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82522. private _loadAnimationsAsync;
  82523. /**
  82524. * Loads a glTF animation.
  82525. * @param context The context when loading the asset
  82526. * @param animation The glTF animation property
  82527. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82528. */
  82529. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82530. /**
  82531. * @hidden Loads a glTF animation channel.
  82532. * @param context The context when loading the asset
  82533. * @param animationContext The context of the animation when loading the asset
  82534. * @param animation The glTF animation property
  82535. * @param channel The glTF animation channel property
  82536. * @param babylonAnimationGroup The babylon animation group property
  82537. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82538. * @returns A void promise when the channel load is complete
  82539. */
  82540. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82541. private _loadAnimationSamplerAsync;
  82542. private _loadBufferAsync;
  82543. /**
  82544. * Loads a glTF buffer view.
  82545. * @param context The context when loading the asset
  82546. * @param bufferView The glTF buffer view property
  82547. * @returns A promise that resolves with the loaded data when the load is complete
  82548. */
  82549. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82550. private _loadAccessorAsync;
  82551. /** @hidden */
  82552. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82553. private _loadIndicesAccessorAsync;
  82554. private _loadVertexBufferViewAsync;
  82555. private _loadVertexAccessorAsync;
  82556. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82557. /** @hidden */
  82558. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82559. private _createDefaultMaterial;
  82560. /**
  82561. * Creates a Babylon material from a glTF material.
  82562. * @param context The context when loading the asset
  82563. * @param material The glTF material property
  82564. * @param babylonDrawMode The draw mode for the Babylon material
  82565. * @returns The Babylon material
  82566. */
  82567. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82568. /**
  82569. * Loads properties from a glTF material into a Babylon material.
  82570. * @param context The context when loading the asset
  82571. * @param material The glTF material property
  82572. * @param babylonMaterial The Babylon material
  82573. * @returns A promise that resolves when the load is complete
  82574. */
  82575. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82576. /**
  82577. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82578. * @param context The context when loading the asset
  82579. * @param material The glTF material property
  82580. * @param babylonMaterial The Babylon material
  82581. * @returns A promise that resolves when the load is complete
  82582. */
  82583. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82584. /**
  82585. * Loads the alpha properties from a glTF material into a Babylon material.
  82586. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82587. * @param context The context when loading the asset
  82588. * @param material The glTF material property
  82589. * @param babylonMaterial The Babylon material
  82590. */
  82591. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82592. /**
  82593. * Loads a glTF texture info.
  82594. * @param context The context when loading the asset
  82595. * @param textureInfo The glTF texture info property
  82596. * @param assign A function called synchronously after parsing the glTF properties
  82597. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82598. */
  82599. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82600. /** @hidden */
  82601. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82602. /** @hidden */
  82603. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82604. private _loadSampler;
  82605. /**
  82606. * Loads a glTF image.
  82607. * @param context The context when loading the asset
  82608. * @param image The glTF image property
  82609. * @returns A promise that resolves with the loaded data when the load is complete
  82610. */
  82611. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82612. /**
  82613. * Loads a glTF uri.
  82614. * @param context The context when loading the asset
  82615. * @param property The glTF property associated with the uri
  82616. * @param uri The base64 or relative uri
  82617. * @returns A promise that resolves with the loaded data when the load is complete
  82618. */
  82619. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82620. /**
  82621. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82622. * @param babylonObject the Babylon object with metadata
  82623. * @param pointer the JSON pointer
  82624. */
  82625. static AddPointerMetadata(babylonObject: {
  82626. metadata: any;
  82627. }, pointer: string): void;
  82628. private static _GetTextureWrapMode;
  82629. private static _GetTextureSamplingMode;
  82630. private static _GetTypedArrayConstructor;
  82631. private static _GetTypedArray;
  82632. private static _GetNumComponents;
  82633. private static _ValidateUri;
  82634. /** @hidden */
  82635. static _GetDrawMode(context: string, mode: number | undefined): number;
  82636. private _compileMaterialsAsync;
  82637. private _compileShadowGeneratorsAsync;
  82638. private _forEachExtensions;
  82639. private _applyExtensions;
  82640. private _extensionsOnLoading;
  82641. private _extensionsOnReady;
  82642. private _extensionsLoadSceneAsync;
  82643. private _extensionsLoadNodeAsync;
  82644. private _extensionsLoadCameraAsync;
  82645. private _extensionsLoadVertexDataAsync;
  82646. private _extensionsLoadMeshPrimitiveAsync;
  82647. private _extensionsLoadMaterialAsync;
  82648. private _extensionsCreateMaterial;
  82649. private _extensionsLoadMaterialPropertiesAsync;
  82650. private _extensionsLoadTextureInfoAsync;
  82651. private _extensionsLoadTextureAsync;
  82652. private _extensionsLoadAnimationAsync;
  82653. private _extensionsLoadSkinAsync;
  82654. private _extensionsLoadUriAsync;
  82655. private _extensionsLoadBufferViewAsync;
  82656. private _extensionsLoadBufferAsync;
  82657. /**
  82658. * Helper method called by a loader extension to load an glTF extension.
  82659. * @param context The context when loading the asset
  82660. * @param property The glTF property to load the extension from
  82661. * @param extensionName The name of the extension to load
  82662. * @param actionAsync The action to run
  82663. * @returns The promise returned by actionAsync or null if the extension does not exist
  82664. */
  82665. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82666. /**
  82667. * Helper method called by a loader extension to load a glTF extra.
  82668. * @param context The context when loading the asset
  82669. * @param property The glTF property to load the extra from
  82670. * @param extensionName The name of the extension to load
  82671. * @param actionAsync The action to run
  82672. * @returns The promise returned by actionAsync or null if the extra does not exist
  82673. */
  82674. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82675. /**
  82676. * Checks for presence of an extension.
  82677. * @param name The name of the extension to check
  82678. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82679. */
  82680. isExtensionUsed(name: string): boolean;
  82681. /**
  82682. * Increments the indentation level and logs a message.
  82683. * @param message The message to log
  82684. */
  82685. logOpen(message: string): void;
  82686. /**
  82687. * Decrements the indentation level.
  82688. */
  82689. logClose(): void;
  82690. /**
  82691. * Logs a message
  82692. * @param message The message to log
  82693. */
  82694. log(message: string): void;
  82695. /**
  82696. * Starts a performance counter.
  82697. * @param counterName The name of the performance counter
  82698. */
  82699. startPerformanceCounter(counterName: string): void;
  82700. /**
  82701. * Ends a performance counter.
  82702. * @param counterName The name of the performance counter
  82703. */
  82704. endPerformanceCounter(counterName: string): void;
  82705. }
  82706. }
  82707. declare module BABYLON.GLTF2.Loader.Extensions {
  82708. /** @hidden */
  82709. interface IEXTLightsImageBased_LightImageBased {
  82710. _babylonTexture?: BaseTexture;
  82711. _loaded?: Promise<void>;
  82712. }
  82713. /**
  82714. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82715. */
  82716. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82717. /**
  82718. * The name of this extension.
  82719. */
  82720. readonly name: string;
  82721. /**
  82722. * Defines whether this extension is enabled.
  82723. */
  82724. enabled: boolean;
  82725. private _loader;
  82726. private _lights?;
  82727. /** @hidden */
  82728. constructor(loader: GLTFLoader);
  82729. /** @hidden */
  82730. dispose(): void;
  82731. /** @hidden */
  82732. onLoading(): void;
  82733. /** @hidden */
  82734. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82735. private _loadLightAsync;
  82736. }
  82737. }
  82738. declare module BABYLON.GLTF2.Loader.Extensions {
  82739. /**
  82740. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82741. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82742. * !!! Experimental Extension Subject to Changes !!!
  82743. */
  82744. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82745. /**
  82746. * The name of this extension.
  82747. */
  82748. readonly name: string;
  82749. /**
  82750. * Defines whether this extension is enabled.
  82751. */
  82752. enabled: boolean;
  82753. private _loader;
  82754. /** @hidden */
  82755. constructor(loader: GLTFLoader);
  82756. /** @hidden */
  82757. dispose(): void;
  82758. /** @hidden */
  82759. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82760. }
  82761. }
  82762. declare module BABYLON.GLTF2.Loader.Extensions {
  82763. /**
  82764. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82765. */
  82766. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82767. /** The name of this extension. */
  82768. readonly name: string;
  82769. /** Defines whether this extension is enabled. */
  82770. enabled: boolean;
  82771. private _loader;
  82772. /** @hidden */
  82773. constructor(loader: GLTFLoader);
  82774. /** @hidden */
  82775. dispose(): void;
  82776. /** @hidden */
  82777. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82778. }
  82779. }
  82780. declare module BABYLON.GLTF2.Loader.Extensions {
  82781. /**
  82782. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82783. */
  82784. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82785. /**
  82786. * The name of this extension.
  82787. */
  82788. readonly name: string;
  82789. /**
  82790. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82791. */
  82792. dracoCompression?: DracoCompression;
  82793. /**
  82794. * Defines whether this extension is enabled.
  82795. */
  82796. enabled: boolean;
  82797. private _loader;
  82798. /** @hidden */
  82799. constructor(loader: GLTFLoader);
  82800. /** @hidden */
  82801. dispose(): void;
  82802. /** @hidden */
  82803. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82804. }
  82805. }
  82806. declare module BABYLON.GLTF2.Loader.Extensions {
  82807. /**
  82808. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82809. */
  82810. export class KHR_lights implements IGLTFLoaderExtension {
  82811. /**
  82812. * The name of this extension.
  82813. */
  82814. readonly name: string;
  82815. /**
  82816. * Defines whether this extension is enabled.
  82817. */
  82818. enabled: boolean;
  82819. private _loader;
  82820. private _lights?;
  82821. /** @hidden */
  82822. constructor(loader: GLTFLoader);
  82823. /** @hidden */
  82824. dispose(): void;
  82825. /** @hidden */
  82826. onLoading(): void;
  82827. /** @hidden */
  82828. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82829. }
  82830. }
  82831. declare module BABYLON.GLTF2.Loader.Extensions {
  82832. /**
  82833. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82834. */
  82835. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82836. /**
  82837. * The name of this extension.
  82838. */
  82839. readonly name: string;
  82840. /**
  82841. * Defines whether this extension is enabled.
  82842. */
  82843. enabled: boolean;
  82844. /**
  82845. * Defines a number that determines the order the extensions are applied.
  82846. */
  82847. order: number;
  82848. private _loader;
  82849. /** @hidden */
  82850. constructor(loader: GLTFLoader);
  82851. /** @hidden */
  82852. dispose(): void;
  82853. /** @hidden */
  82854. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82855. private _loadSpecularGlossinessPropertiesAsync;
  82856. }
  82857. }
  82858. declare module BABYLON.GLTF2.Loader.Extensions {
  82859. /**
  82860. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  82861. */
  82862. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  82863. /**
  82864. * The name of this extension.
  82865. */
  82866. readonly name: string;
  82867. /**
  82868. * Defines whether this extension is enabled.
  82869. */
  82870. enabled: boolean;
  82871. /**
  82872. * Defines a number that determines the order the extensions are applied.
  82873. */
  82874. order: number;
  82875. private _loader;
  82876. /** @hidden */
  82877. constructor(loader: GLTFLoader);
  82878. /** @hidden */
  82879. dispose(): void;
  82880. /** @hidden */
  82881. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82882. private _loadUnlitPropertiesAsync;
  82883. }
  82884. }
  82885. declare module BABYLON.GLTF2.Loader.Extensions {
  82886. /**
  82887. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  82888. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  82889. * !!! Experimental Extension Subject to Changes !!!
  82890. */
  82891. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  82892. /**
  82893. * The name of this extension.
  82894. */
  82895. readonly name: string;
  82896. /**
  82897. * Defines whether this extension is enabled.
  82898. */
  82899. enabled: boolean;
  82900. /**
  82901. * Defines a number that determines the order the extensions are applied.
  82902. */
  82903. order: number;
  82904. private _loader;
  82905. /** @hidden */
  82906. constructor(loader: GLTFLoader);
  82907. /** @hidden */
  82908. dispose(): void;
  82909. /** @hidden */
  82910. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82911. private _loadClearCoatPropertiesAsync;
  82912. }
  82913. }
  82914. declare module BABYLON.GLTF2.Loader.Extensions {
  82915. /**
  82916. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  82917. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  82918. * !!! Experimental Extension Subject to Changes !!!
  82919. */
  82920. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  82921. /**
  82922. * The name of this extension.
  82923. */
  82924. readonly name: string;
  82925. /**
  82926. * Defines whether this extension is enabled.
  82927. */
  82928. enabled: boolean;
  82929. /**
  82930. * Defines a number that determines the order the extensions are applied.
  82931. */
  82932. order: number;
  82933. private _loader;
  82934. /** @hidden */
  82935. constructor(loader: GLTFLoader);
  82936. /** @hidden */
  82937. dispose(): void;
  82938. /** @hidden */
  82939. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82940. private _loadSheenPropertiesAsync;
  82941. }
  82942. }
  82943. declare module BABYLON.GLTF2.Loader.Extensions {
  82944. /**
  82945. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  82946. * !!! Experimental Extension Subject to Changes !!!
  82947. */
  82948. export class KHR_materials_specular implements IGLTFLoaderExtension {
  82949. /**
  82950. * The name of this extension.
  82951. */
  82952. readonly name: string;
  82953. /**
  82954. * Defines whether this extension is enabled.
  82955. */
  82956. enabled: boolean;
  82957. /**
  82958. * Defines a number that determines the order the extensions are applied.
  82959. */
  82960. order: number;
  82961. private _loader;
  82962. /** @hidden */
  82963. constructor(loader: GLTFLoader);
  82964. /** @hidden */
  82965. dispose(): void;
  82966. /** @hidden */
  82967. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82968. private _loadSpecularPropertiesAsync;
  82969. }
  82970. }
  82971. declare module BABYLON.GLTF2.Loader.Extensions {
  82972. /**
  82973. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82974. * !!! Experimental Extension Subject to Changes !!!
  82975. */
  82976. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82977. /**
  82978. * Default ior Value from the spec.
  82979. */
  82980. private static readonly _DEFAULT_IOR;
  82981. /**
  82982. * The name of this extension.
  82983. */
  82984. readonly name: string;
  82985. /**
  82986. * Defines whether this extension is enabled.
  82987. */
  82988. enabled: boolean;
  82989. /**
  82990. * Defines a number that determines the order the extensions are applied.
  82991. */
  82992. order: number;
  82993. private _loader;
  82994. /** @hidden */
  82995. constructor(loader: GLTFLoader);
  82996. /** @hidden */
  82997. dispose(): void;
  82998. /** @hidden */
  82999. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83000. private _loadIorPropertiesAsync;
  83001. }
  83002. }
  83003. declare module BABYLON.GLTF2.Loader.Extensions {
  83004. /**
  83005. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83006. * !!! Experimental Extension Subject to Changes !!!
  83007. */
  83008. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83009. /**
  83010. * The name of this extension.
  83011. */
  83012. readonly name: string;
  83013. /**
  83014. * Defines whether this extension is enabled.
  83015. */
  83016. enabled: boolean;
  83017. private _loader;
  83018. private _variants?;
  83019. /** @hidden */
  83020. constructor(loader: GLTFLoader);
  83021. /** @hidden */
  83022. dispose(): void;
  83023. /**
  83024. * Gets the list of available variant names for this asset.
  83025. * @param rootMesh The glTF root mesh
  83026. * @returns the list of all the variant names for this model
  83027. */
  83028. static GetAvailableVariants(rootMesh: Mesh): string[];
  83029. /**
  83030. * Gets the list of available variant names for this asset.
  83031. * @param rootMesh The glTF root mesh
  83032. * @returns the list of all the variant names for this model
  83033. */
  83034. getAvailableVariants(rootMesh: Mesh): string[];
  83035. /**
  83036. * Select a variant given a variant name or a list of variant names.
  83037. * @param rootMesh The glTF root mesh
  83038. * @param variantName The variant name(s) to select.
  83039. */
  83040. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83041. /**
  83042. * Select a variant given a variant name or a list of variant names.
  83043. * @param rootMesh The glTF root mesh
  83044. * @param variantName The variant name(s) to select.
  83045. */
  83046. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83047. /**
  83048. * Reset back to the original before selecting a variant.
  83049. * @param rootMesh The glTF root mesh
  83050. */
  83051. static Reset(rootMesh: Mesh): void;
  83052. /**
  83053. * Reset back to the original before selecting a variant.
  83054. * @param rootMesh The glTF root mesh
  83055. */
  83056. reset(rootMesh: Mesh): void;
  83057. /**
  83058. * Gets the last selected variant name(s) or null if original.
  83059. * @param rootMesh The glTF root mesh
  83060. * @returns The selected variant name(s).
  83061. */
  83062. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83063. /**
  83064. * Gets the last selected variant name(s) or null if original.
  83065. * @param rootMesh The glTF root mesh
  83066. * @returns The selected variant name(s).
  83067. */
  83068. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83069. private static _GetExtensionMetadata;
  83070. /** @hidden */
  83071. onLoading(): void;
  83072. /** @hidden */
  83073. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83074. }
  83075. }
  83076. declare module BABYLON.GLTF2.Loader.Extensions {
  83077. /**
  83078. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83079. * !!! Experimental Extension Subject to Changes !!!
  83080. */
  83081. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83082. /**
  83083. * The name of this extension.
  83084. */
  83085. readonly name: string;
  83086. /**
  83087. * Defines whether this extension is enabled.
  83088. */
  83089. enabled: boolean;
  83090. /**
  83091. * Defines a number that determines the order the extensions are applied.
  83092. */
  83093. order: number;
  83094. private _loader;
  83095. /** @hidden */
  83096. constructor(loader: GLTFLoader);
  83097. /** @hidden */
  83098. dispose(): void;
  83099. /** @hidden */
  83100. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83101. private _loadTransparentPropertiesAsync;
  83102. }
  83103. }
  83104. declare module BABYLON.GLTF2.Loader.Extensions {
  83105. /**
  83106. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83107. */
  83108. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83109. /**
  83110. * The name of this extension.
  83111. */
  83112. readonly name: string;
  83113. /**
  83114. * Defines whether this extension is enabled.
  83115. */
  83116. enabled: boolean;
  83117. /** @hidden */
  83118. constructor(loader: GLTFLoader);
  83119. /** @hidden */
  83120. dispose(): void;
  83121. }
  83122. }
  83123. declare module BABYLON.GLTF2.Loader.Extensions {
  83124. /**
  83125. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83126. * !!! Experimental Extension Subject to Changes !!!
  83127. */
  83128. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83129. /** The name of this extension. */
  83130. readonly name: string;
  83131. /** Defines whether this extension is enabled. */
  83132. enabled: boolean;
  83133. private _loader;
  83134. /** @hidden */
  83135. constructor(loader: GLTFLoader);
  83136. /** @hidden */
  83137. dispose(): void;
  83138. /** @hidden */
  83139. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83140. }
  83141. }
  83142. declare module BABYLON.GLTF2.Loader.Extensions {
  83143. /**
  83144. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83145. */
  83146. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83147. /**
  83148. * The name of this extension.
  83149. */
  83150. readonly name: string;
  83151. /**
  83152. * Defines whether this extension is enabled.
  83153. */
  83154. enabled: boolean;
  83155. private _loader;
  83156. /** @hidden */
  83157. constructor(loader: GLTFLoader);
  83158. /** @hidden */
  83159. dispose(): void;
  83160. /** @hidden */
  83161. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83162. }
  83163. }
  83164. declare module BABYLON.GLTF2.Loader.Extensions {
  83165. /**
  83166. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83167. * !!! Experimental Extension Subject to Changes !!!
  83168. */
  83169. export class KHR_xmp implements IGLTFLoaderExtension {
  83170. /**
  83171. * The name of this extension.
  83172. */
  83173. readonly name: string;
  83174. /**
  83175. * Defines whether this extension is enabled.
  83176. */
  83177. enabled: boolean;
  83178. /**
  83179. * Defines a number that determines the order the extensions are applied.
  83180. */
  83181. order: number;
  83182. private _loader;
  83183. /** @hidden */
  83184. constructor(loader: GLTFLoader);
  83185. /** @hidden */
  83186. dispose(): void;
  83187. /**
  83188. * Called after the loader state changes to LOADING.
  83189. */
  83190. onLoading(): void;
  83191. }
  83192. }
  83193. declare module BABYLON.GLTF2.Loader.Extensions {
  83194. /**
  83195. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83196. */
  83197. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83198. /**
  83199. * The name of this extension.
  83200. */
  83201. readonly name: string;
  83202. /**
  83203. * Defines whether this extension is enabled.
  83204. */
  83205. enabled: boolean;
  83206. private _loader;
  83207. private _clips;
  83208. private _emitters;
  83209. /** @hidden */
  83210. constructor(loader: GLTFLoader);
  83211. /** @hidden */
  83212. dispose(): void;
  83213. /** @hidden */
  83214. onLoading(): void;
  83215. /** @hidden */
  83216. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83217. /** @hidden */
  83218. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83219. /** @hidden */
  83220. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83221. private _loadClipAsync;
  83222. private _loadEmitterAsync;
  83223. private _getEventAction;
  83224. private _loadAnimationEventAsync;
  83225. }
  83226. }
  83227. declare module BABYLON.GLTF2.Loader.Extensions {
  83228. /**
  83229. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83230. */
  83231. export class MSFT_lod implements IGLTFLoaderExtension {
  83232. /**
  83233. * The name of this extension.
  83234. */
  83235. readonly name: string;
  83236. /**
  83237. * Defines whether this extension is enabled.
  83238. */
  83239. enabled: boolean;
  83240. /**
  83241. * Defines a number that determines the order the extensions are applied.
  83242. */
  83243. order: number;
  83244. /**
  83245. * Maximum number of LODs to load, starting from the lowest LOD.
  83246. */
  83247. maxLODsToLoad: number;
  83248. /**
  83249. * Observable raised when all node LODs of one level are loaded.
  83250. * The event data is the index of the loaded LOD starting from zero.
  83251. * Dispose the loader to cancel the loading of the next level of LODs.
  83252. */
  83253. onNodeLODsLoadedObservable: Observable<number>;
  83254. /**
  83255. * Observable raised when all material LODs of one level are loaded.
  83256. * The event data is the index of the loaded LOD starting from zero.
  83257. * Dispose the loader to cancel the loading of the next level of LODs.
  83258. */
  83259. onMaterialLODsLoadedObservable: Observable<number>;
  83260. private _loader;
  83261. private _bufferLODs;
  83262. private _nodeIndexLOD;
  83263. private _nodeSignalLODs;
  83264. private _nodePromiseLODs;
  83265. private _nodeBufferLODs;
  83266. private _materialIndexLOD;
  83267. private _materialSignalLODs;
  83268. private _materialPromiseLODs;
  83269. private _materialBufferLODs;
  83270. /** @hidden */
  83271. constructor(loader: GLTFLoader);
  83272. /** @hidden */
  83273. dispose(): void;
  83274. /** @hidden */
  83275. onReady(): void;
  83276. /** @hidden */
  83277. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83278. /** @hidden */
  83279. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83280. /** @hidden */
  83281. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83282. /** @hidden */
  83283. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83284. /** @hidden */
  83285. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83286. private _loadBufferLOD;
  83287. /**
  83288. * Gets an array of LOD properties from lowest to highest.
  83289. */
  83290. private _getLODs;
  83291. private _disposeTransformNode;
  83292. private _disposeMaterials;
  83293. }
  83294. }
  83295. declare module BABYLON.GLTF2.Loader.Extensions {
  83296. /** @hidden */
  83297. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83298. readonly name: string;
  83299. enabled: boolean;
  83300. private _loader;
  83301. constructor(loader: GLTFLoader);
  83302. dispose(): void;
  83303. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83304. }
  83305. }
  83306. declare module BABYLON.GLTF2.Loader.Extensions {
  83307. /** @hidden */
  83308. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83309. readonly name: string;
  83310. enabled: boolean;
  83311. private _loader;
  83312. constructor(loader: GLTFLoader);
  83313. dispose(): void;
  83314. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83315. }
  83316. }
  83317. declare module BABYLON.GLTF2.Loader.Extensions {
  83318. /**
  83319. * Store glTF extras (if present) in BJS objects' metadata
  83320. */
  83321. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83322. /**
  83323. * The name of this extension.
  83324. */
  83325. readonly name: string;
  83326. /**
  83327. * Defines whether this extension is enabled.
  83328. */
  83329. enabled: boolean;
  83330. private _loader;
  83331. private _assignExtras;
  83332. /** @hidden */
  83333. constructor(loader: GLTFLoader);
  83334. /** @hidden */
  83335. dispose(): void;
  83336. /** @hidden */
  83337. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83338. /** @hidden */
  83339. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83340. /** @hidden */
  83341. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83342. }
  83343. }
  83344. declare module BABYLON {
  83345. /**
  83346. * Class reading and parsing the MTL file bundled with the obj file.
  83347. */
  83348. export class MTLFileLoader {
  83349. /**
  83350. * Invert Y-Axis of referenced textures on load
  83351. */
  83352. static INVERT_TEXTURE_Y: boolean;
  83353. /**
  83354. * All material loaded from the mtl will be set here
  83355. */
  83356. materials: StandardMaterial[];
  83357. /**
  83358. * This function will read the mtl file and create each material described inside
  83359. * This function could be improve by adding :
  83360. * -some component missing (Ni, Tf...)
  83361. * -including the specific options available
  83362. *
  83363. * @param scene defines the scene the material will be created in
  83364. * @param data defines the mtl data to parse
  83365. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83366. * @param forAssetContainer defines if the material should be registered in the scene
  83367. */
  83368. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83369. /**
  83370. * Gets the texture for the material.
  83371. *
  83372. * If the material is imported from input file,
  83373. * We sanitize the url to ensure it takes the textre from aside the material.
  83374. *
  83375. * @param rootUrl The root url to load from
  83376. * @param value The value stored in the mtl
  83377. * @return The Texture
  83378. */
  83379. private static _getTexture;
  83380. }
  83381. }
  83382. declare module BABYLON {
  83383. /**
  83384. * Options for loading OBJ/MTL files
  83385. */
  83386. type MeshLoadOptions = {
  83387. /**
  83388. * Defines if UVs are optimized by default during load.
  83389. */
  83390. OptimizeWithUV: boolean;
  83391. /**
  83392. * Defines custom scaling of UV coordinates of loaded meshes.
  83393. */
  83394. UVScaling: Vector2;
  83395. /**
  83396. * Invert model on y-axis (does a model scaling inversion)
  83397. */
  83398. InvertY: boolean;
  83399. /**
  83400. * Invert Y-Axis of referenced textures on load
  83401. */
  83402. InvertTextureY: boolean;
  83403. /**
  83404. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83405. */
  83406. ImportVertexColors: boolean;
  83407. /**
  83408. * Compute the normals for the model, even if normals are present in the file.
  83409. */
  83410. ComputeNormals: boolean;
  83411. /**
  83412. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83413. */
  83414. SkipMaterials: boolean;
  83415. /**
  83416. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83417. */
  83418. MaterialLoadingFailsSilently: boolean;
  83419. };
  83420. /**
  83421. * OBJ file type loader.
  83422. * This is a babylon scene loader plugin.
  83423. */
  83424. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83425. /**
  83426. * Defines if UVs are optimized by default during load.
  83427. */
  83428. static OPTIMIZE_WITH_UV: boolean;
  83429. /**
  83430. * Invert model on y-axis (does a model scaling inversion)
  83431. */
  83432. static INVERT_Y: boolean;
  83433. /**
  83434. * Invert Y-Axis of referenced textures on load
  83435. */
  83436. static get INVERT_TEXTURE_Y(): boolean;
  83437. static set INVERT_TEXTURE_Y(value: boolean);
  83438. /**
  83439. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83440. */
  83441. static IMPORT_VERTEX_COLORS: boolean;
  83442. /**
  83443. * Compute the normals for the model, even if normals are present in the file.
  83444. */
  83445. static COMPUTE_NORMALS: boolean;
  83446. /**
  83447. * Defines custom scaling of UV coordinates of loaded meshes.
  83448. */
  83449. static UV_SCALING: Vector2;
  83450. /**
  83451. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83452. */
  83453. static SKIP_MATERIALS: boolean;
  83454. /**
  83455. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83456. *
  83457. * Defaults to true for backwards compatibility.
  83458. */
  83459. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83460. /**
  83461. * Defines the name of the plugin.
  83462. */
  83463. name: string;
  83464. /**
  83465. * Defines the extension the plugin is able to load.
  83466. */
  83467. extensions: string;
  83468. /** @hidden */
  83469. obj: RegExp;
  83470. /** @hidden */
  83471. group: RegExp;
  83472. /** @hidden */
  83473. mtllib: RegExp;
  83474. /** @hidden */
  83475. usemtl: RegExp;
  83476. /** @hidden */
  83477. smooth: RegExp;
  83478. /** @hidden */
  83479. vertexPattern: RegExp;
  83480. /** @hidden */
  83481. normalPattern: RegExp;
  83482. /** @hidden */
  83483. uvPattern: RegExp;
  83484. /** @hidden */
  83485. facePattern1: RegExp;
  83486. /** @hidden */
  83487. facePattern2: RegExp;
  83488. /** @hidden */
  83489. facePattern3: RegExp;
  83490. /** @hidden */
  83491. facePattern4: RegExp;
  83492. /** @hidden */
  83493. facePattern5: RegExp;
  83494. private _forAssetContainer;
  83495. private _meshLoadOptions;
  83496. /**
  83497. * Creates loader for .OBJ files
  83498. *
  83499. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83500. */
  83501. constructor(meshLoadOptions?: MeshLoadOptions);
  83502. private static get currentMeshLoadOptions();
  83503. /**
  83504. * Calls synchronously the MTL file attached to this obj.
  83505. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83506. * Without this function materials are not displayed in the first frame (but displayed after).
  83507. * In consequence it is impossible to get material information in your HTML file
  83508. *
  83509. * @param url The URL of the MTL file
  83510. * @param rootUrl
  83511. * @param onSuccess Callback function to be called when the MTL file is loaded
  83512. * @private
  83513. */
  83514. private _loadMTL;
  83515. /**
  83516. * Instantiates a OBJ file loader plugin.
  83517. * @returns the created plugin
  83518. */
  83519. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83520. /**
  83521. * If the data string can be loaded directly.
  83522. *
  83523. * @param data string containing the file data
  83524. * @returns if the data can be loaded directly
  83525. */
  83526. canDirectLoad(data: string): boolean;
  83527. /**
  83528. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83529. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83530. * @param scene the scene the meshes should be added to
  83531. * @param data the OBJ data to load
  83532. * @param rootUrl root url to load from
  83533. * @param onProgress event that fires when loading progress has occured
  83534. * @param fileName Defines the name of the file to load
  83535. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83536. */
  83537. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83538. meshes: AbstractMesh[];
  83539. particleSystems: IParticleSystem[];
  83540. skeletons: Skeleton[];
  83541. animationGroups: AnimationGroup[];
  83542. }>;
  83543. /**
  83544. * Imports all objects from the loaded OBJ data and adds them to the scene
  83545. * @param scene the scene the objects should be added to
  83546. * @param data the OBJ data to load
  83547. * @param rootUrl root url to load from
  83548. * @param onProgress event that fires when loading progress has occured
  83549. * @param fileName Defines the name of the file to load
  83550. * @returns a promise which completes when objects have been loaded to the scene
  83551. */
  83552. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83553. /**
  83554. * Load into an asset container.
  83555. * @param scene The scene to load into
  83556. * @param data The data to import
  83557. * @param rootUrl The root url for scene and resources
  83558. * @param onProgress The callback when the load progresses
  83559. * @param fileName Defines the name of the file to load
  83560. * @returns The loaded asset container
  83561. */
  83562. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83563. /**
  83564. * Read the OBJ file and create an Array of meshes.
  83565. * Each mesh contains all information given by the OBJ and the MTL file.
  83566. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83567. *
  83568. * @param meshesNames
  83569. * @param scene Scene The scene where are displayed the data
  83570. * @param data String The content of the obj file
  83571. * @param rootUrl String The path to the folder
  83572. * @returns Array<AbstractMesh>
  83573. * @private
  83574. */
  83575. private _parseSolid;
  83576. }
  83577. }
  83578. declare module BABYLON {
  83579. /**
  83580. * STL file type loader.
  83581. * This is a babylon scene loader plugin.
  83582. */
  83583. export class STLFileLoader implements ISceneLoaderPlugin {
  83584. /** @hidden */
  83585. solidPattern: RegExp;
  83586. /** @hidden */
  83587. facetsPattern: RegExp;
  83588. /** @hidden */
  83589. normalPattern: RegExp;
  83590. /** @hidden */
  83591. vertexPattern: RegExp;
  83592. /**
  83593. * Defines the name of the plugin.
  83594. */
  83595. name: string;
  83596. /**
  83597. * Defines the extensions the stl loader is able to load.
  83598. * force data to come in as an ArrayBuffer
  83599. * we'll convert to string if it looks like it's an ASCII .stl
  83600. */
  83601. extensions: ISceneLoaderPluginExtensions;
  83602. /**
  83603. * Import meshes into a scene.
  83604. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83605. * @param scene The scene to import into
  83606. * @param data The data to import
  83607. * @param rootUrl The root url for scene and resources
  83608. * @param meshes The meshes array to import into
  83609. * @param particleSystems The particle systems array to import into
  83610. * @param skeletons The skeletons array to import into
  83611. * @param onError The callback when import fails
  83612. * @returns True if successful or false otherwise
  83613. */
  83614. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83615. /**
  83616. * Load into a scene.
  83617. * @param scene The scene to load into
  83618. * @param data The data to import
  83619. * @param rootUrl The root url for scene and resources
  83620. * @param onError The callback when import fails
  83621. * @returns true if successful or false otherwise
  83622. */
  83623. load(scene: Scene, data: any, rootUrl: string): boolean;
  83624. /**
  83625. * Load into an asset container.
  83626. * @param scene The scene to load into
  83627. * @param data The data to import
  83628. * @param rootUrl The root url for scene and resources
  83629. * @param onError The callback when import fails
  83630. * @returns The loaded asset container
  83631. */
  83632. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83633. private _isBinary;
  83634. private _parseBinary;
  83635. private _parseASCII;
  83636. }
  83637. }
  83638. declare module BABYLON {
  83639. /**
  83640. * Class for generating OBJ data from a Babylon scene.
  83641. */
  83642. export class OBJExport {
  83643. /**
  83644. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83645. * @param mesh defines the list of meshes to serialize
  83646. * @param materials defines if materials should be exported
  83647. * @param matlibname defines the name of the associated mtl file
  83648. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83649. * @returns the OBJ content
  83650. */
  83651. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83652. /**
  83653. * Exports the material(s) of a mesh in .MTL file format (text)
  83654. * @param mesh defines the mesh to extract the material from
  83655. * @returns the mtl content
  83656. */
  83657. static MTL(mesh: Mesh): string;
  83658. }
  83659. }
  83660. declare module BABYLON {
  83661. /** @hidden */
  83662. export var __IGLTFExporterExtension: number;
  83663. /**
  83664. * Interface for extending the exporter
  83665. * @hidden
  83666. */
  83667. export interface IGLTFExporterExtension {
  83668. /**
  83669. * The name of this extension
  83670. */
  83671. readonly name: string;
  83672. /**
  83673. * Defines whether this extension is enabled
  83674. */
  83675. enabled: boolean;
  83676. /**
  83677. * Defines whether this extension is required
  83678. */
  83679. required: boolean;
  83680. }
  83681. }
  83682. declare module BABYLON.GLTF2.Exporter {
  83683. /** @hidden */
  83684. export var __IGLTFExporterExtensionV2: number;
  83685. /**
  83686. * Interface for a glTF exporter extension
  83687. * @hidden
  83688. */
  83689. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83690. /**
  83691. * Define this method to modify the default behavior before exporting a texture
  83692. * @param context The context when loading the asset
  83693. * @param babylonTexture The Babylon.js texture
  83694. * @param mimeType The mime-type of the generated image
  83695. * @returns A promise that resolves with the exported texture
  83696. */
  83697. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83698. /**
  83699. * Define this method to get notified when a texture info is created
  83700. * @param context The context when loading the asset
  83701. * @param textureInfo The glTF texture info
  83702. * @param babylonTexture The Babylon.js texture
  83703. */
  83704. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83705. /**
  83706. * Define this method to modify the default behavior when exporting texture info
  83707. * @param context The context when loading the asset
  83708. * @param meshPrimitive glTF mesh primitive
  83709. * @param babylonSubMesh Babylon submesh
  83710. * @param binaryWriter glTF serializer binary writer instance
  83711. * @returns nullable IMeshPrimitive promise
  83712. */
  83713. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83714. /**
  83715. * Define this method to modify the default behavior when exporting a node
  83716. * @param context The context when exporting the node
  83717. * @param node glTF node
  83718. * @param babylonNode BabylonJS node
  83719. * @returns nullable INode promise
  83720. */
  83721. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83722. [key: number]: number;
  83723. }): Promise<Nullable<INode>>;
  83724. /**
  83725. * Define this method to modify the default behavior when exporting a material
  83726. * @param material glTF material
  83727. * @param babylonMaterial BabylonJS material
  83728. * @returns nullable IMaterial promise
  83729. */
  83730. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83731. /**
  83732. * Define this method to return additional textures to export from a material
  83733. * @param material glTF material
  83734. * @param babylonMaterial BabylonJS material
  83735. * @returns List of textures
  83736. */
  83737. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83738. /** Gets a boolean indicating that this extension was used */
  83739. wasUsed: boolean;
  83740. /** Gets a boolean indicating that this extension is required for the file to work */
  83741. required: boolean;
  83742. /**
  83743. * Called after the exporter state changes to EXPORTING
  83744. */
  83745. onExporting?(): void;
  83746. }
  83747. }
  83748. declare module BABYLON.GLTF2.Exporter {
  83749. /**
  83750. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83751. * @hidden
  83752. */
  83753. export class _GLTFMaterialExporter {
  83754. /**
  83755. * Represents the dielectric specular values for R, G and B
  83756. */
  83757. private static readonly _DielectricSpecular;
  83758. /**
  83759. * Allows the maximum specular power to be defined for material calculations
  83760. */
  83761. private static readonly _MaxSpecularPower;
  83762. /**
  83763. * Mapping to store textures
  83764. */
  83765. private _textureMap;
  83766. /**
  83767. * Numeric tolerance value
  83768. */
  83769. private static readonly _Epsilon;
  83770. /**
  83771. * Reference to the glTF Exporter
  83772. */
  83773. private _exporter;
  83774. constructor(exporter: _Exporter);
  83775. /**
  83776. * Specifies if two colors are approximately equal in value
  83777. * @param color1 first color to compare to
  83778. * @param color2 second color to compare to
  83779. * @param epsilon threshold value
  83780. */
  83781. private static FuzzyEquals;
  83782. /**
  83783. * Gets the materials from a Babylon scene and converts them to glTF materials
  83784. * @param scene babylonjs scene
  83785. * @param mimeType texture mime type
  83786. * @param images array of images
  83787. * @param textures array of textures
  83788. * @param materials array of materials
  83789. * @param imageData mapping of texture names to base64 textures
  83790. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83791. */
  83792. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83793. /**
  83794. * Makes a copy of the glTF material without the texture parameters
  83795. * @param originalMaterial original glTF material
  83796. * @returns glTF material without texture parameters
  83797. */
  83798. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83799. /**
  83800. * Specifies if the material has any texture parameters present
  83801. * @param material glTF Material
  83802. * @returns boolean specifying if texture parameters are present
  83803. */
  83804. _hasTexturesPresent(material: IMaterial): boolean;
  83805. /**
  83806. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83807. * @param babylonStandardMaterial
  83808. * @returns glTF Metallic Roughness Material representation
  83809. */
  83810. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83811. /**
  83812. * Computes the metallic factor
  83813. * @param diffuse diffused value
  83814. * @param specular specular value
  83815. * @param oneMinusSpecularStrength one minus the specular strength
  83816. * @returns metallic value
  83817. */
  83818. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83819. /**
  83820. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83821. * @param glTFMaterial glTF material
  83822. * @param babylonMaterial Babylon material
  83823. */
  83824. private static _SetAlphaMode;
  83825. /**
  83826. * Converts a Babylon Standard Material to a glTF Material
  83827. * @param babylonStandardMaterial BJS Standard Material
  83828. * @param mimeType mime type to use for the textures
  83829. * @param images array of glTF image interfaces
  83830. * @param textures array of glTF texture interfaces
  83831. * @param materials array of glTF material interfaces
  83832. * @param imageData map of image file name to data
  83833. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83834. */
  83835. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83836. private _finishMaterial;
  83837. /**
  83838. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83839. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83840. * @param mimeType mime type to use for the textures
  83841. * @param images array of glTF image interfaces
  83842. * @param textures array of glTF texture interfaces
  83843. * @param materials array of glTF material interfaces
  83844. * @param imageData map of image file name to data
  83845. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83846. */
  83847. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83848. /**
  83849. * Converts an image typed array buffer to a base64 image
  83850. * @param buffer typed array buffer
  83851. * @param width width of the image
  83852. * @param height height of the image
  83853. * @param mimeType mimetype of the image
  83854. * @returns base64 image string
  83855. */
  83856. private _createBase64FromCanvasAsync;
  83857. /**
  83858. * Generates a white texture based on the specified width and height
  83859. * @param width width of the texture in pixels
  83860. * @param height height of the texture in pixels
  83861. * @param scene babylonjs scene
  83862. * @returns white texture
  83863. */
  83864. private _createWhiteTexture;
  83865. /**
  83866. * 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
  83867. * @param texture1 first texture to resize
  83868. * @param texture2 second texture to resize
  83869. * @param scene babylonjs scene
  83870. * @returns resized textures or null
  83871. */
  83872. private _resizeTexturesToSameDimensions;
  83873. /**
  83874. * Converts an array of pixels to a Float32Array
  83875. * Throws an error if the pixel format is not supported
  83876. * @param pixels - array buffer containing pixel values
  83877. * @returns Float32 of pixels
  83878. */
  83879. private _convertPixelArrayToFloat32;
  83880. /**
  83881. * Convert Specular Glossiness Textures to Metallic Roughness
  83882. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  83883. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  83884. * @param diffuseTexture texture used to store diffuse information
  83885. * @param specularGlossinessTexture texture used to store specular and glossiness information
  83886. * @param factors specular glossiness material factors
  83887. * @param mimeType the mime type to use for the texture
  83888. * @returns pbr metallic roughness interface or null
  83889. */
  83890. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  83891. /**
  83892. * Converts specular glossiness material properties to metallic roughness
  83893. * @param specularGlossiness interface with specular glossiness material properties
  83894. * @returns interface with metallic roughness material properties
  83895. */
  83896. private _convertSpecularGlossinessToMetallicRoughness;
  83897. /**
  83898. * Calculates the surface reflectance, independent of lighting conditions
  83899. * @param color Color source to calculate brightness from
  83900. * @returns number representing the perceived brightness, or zero if color is undefined
  83901. */
  83902. private _getPerceivedBrightness;
  83903. /**
  83904. * Returns the maximum color component value
  83905. * @param color
  83906. * @returns maximum color component value, or zero if color is null or undefined
  83907. */
  83908. private _getMaxComponent;
  83909. /**
  83910. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  83911. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83912. * @param mimeType mime type to use for the textures
  83913. * @param images array of glTF image interfaces
  83914. * @param textures array of glTF texture interfaces
  83915. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83916. * @param imageData map of image file name to data
  83917. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83918. * @returns glTF PBR Metallic Roughness factors
  83919. */
  83920. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  83921. private _getGLTFTextureSampler;
  83922. private _getGLTFTextureWrapMode;
  83923. private _getGLTFTextureWrapModesSampler;
  83924. /**
  83925. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  83926. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83927. * @param mimeType mime type to use for the textures
  83928. * @param images array of glTF image interfaces
  83929. * @param textures array of glTF texture interfaces
  83930. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83931. * @param imageData map of image file name to data
  83932. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83933. * @returns glTF PBR Metallic Roughness factors
  83934. */
  83935. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  83936. /**
  83937. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83938. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83939. * @param mimeType mime type to use for the textures
  83940. * @param images array of glTF image interfaces
  83941. * @param textures array of glTF texture interfaces
  83942. * @param materials array of glTF material interfaces
  83943. * @param imageData map of image file name to data
  83944. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83945. */
  83946. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83947. private setMetallicRoughnessPbrMaterial;
  83948. private getPixelsFromTexture;
  83949. /**
  83950. * Extracts a texture from a Babylon texture into file data and glTF data
  83951. * @param babylonTexture Babylon texture to extract
  83952. * @param mimeType Mime Type of the babylonTexture
  83953. * @return glTF texture info, or null if the texture format is not supported
  83954. */
  83955. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83956. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83957. /**
  83958. * Builds a texture from base64 string
  83959. * @param base64Texture base64 texture string
  83960. * @param baseTextureName Name to use for the texture
  83961. * @param mimeType image mime type for the texture
  83962. * @param images array of images
  83963. * @param textures array of textures
  83964. * @param imageData map of image data
  83965. * @returns glTF texture info, or null if the texture format is not supported
  83966. */
  83967. private _getTextureInfoFromBase64;
  83968. }
  83969. }
  83970. declare module BABYLON {
  83971. /**
  83972. * Class for holding and downloading glTF file data
  83973. */
  83974. export class GLTFData {
  83975. /**
  83976. * Object which contains the file name as the key and its data as the value
  83977. */
  83978. glTFFiles: {
  83979. [fileName: string]: string | Blob;
  83980. };
  83981. /**
  83982. * Initializes the glTF file object
  83983. */
  83984. constructor();
  83985. /**
  83986. * Downloads the glTF data as files based on their names and data
  83987. */
  83988. downloadFiles(): void;
  83989. }
  83990. }
  83991. declare module BABYLON {
  83992. /**
  83993. * Holds a collection of exporter options and parameters
  83994. */
  83995. export interface IExportOptions {
  83996. /**
  83997. * Function which indicates whether a babylon node should be exported or not
  83998. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83999. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84000. */
  84001. shouldExportNode?(node: Node): boolean;
  84002. /**
  84003. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84004. * @param metadata source metadata to read from
  84005. * @returns the data to store to glTF node extras
  84006. */
  84007. metadataSelector?(metadata: any): any;
  84008. /**
  84009. * The sample rate to bake animation curves
  84010. */
  84011. animationSampleRate?: number;
  84012. /**
  84013. * Begin serialization without waiting for the scene to be ready
  84014. */
  84015. exportWithoutWaitingForScene?: boolean;
  84016. /**
  84017. * Indicates if coordinate system swapping root nodes should be included in export
  84018. */
  84019. includeCoordinateSystemConversionNodes?: boolean;
  84020. }
  84021. /**
  84022. * Class for generating glTF data from a Babylon scene.
  84023. */
  84024. export class GLTF2Export {
  84025. /**
  84026. * Exports the geometry of the scene to .gltf file format asynchronously
  84027. * @param scene Babylon scene with scene hierarchy information
  84028. * @param filePrefix File prefix to use when generating the glTF file
  84029. * @param options Exporter options
  84030. * @returns Returns an object with a .gltf file and associates texture names
  84031. * as keys and their data and paths as values
  84032. */
  84033. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84034. private static _PreExportAsync;
  84035. private static _PostExportAsync;
  84036. /**
  84037. * Exports the geometry of the scene to .glb file format asychronously
  84038. * @param scene Babylon scene with scene hierarchy information
  84039. * @param filePrefix File prefix to use when generating glb file
  84040. * @param options Exporter options
  84041. * @returns Returns an object with a .glb filename as key and data as value
  84042. */
  84043. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84044. }
  84045. }
  84046. declare module BABYLON.GLTF2.Exporter {
  84047. /**
  84048. * @hidden
  84049. */
  84050. export class _GLTFUtilities {
  84051. /**
  84052. * Creates a buffer view based on the supplied arguments
  84053. * @param bufferIndex index value of the specified buffer
  84054. * @param byteOffset byte offset value
  84055. * @param byteLength byte length of the bufferView
  84056. * @param byteStride byte distance between conequential elements
  84057. * @param name name of the buffer view
  84058. * @returns bufferView for glTF
  84059. */
  84060. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84061. /**
  84062. * Creates an accessor based on the supplied arguments
  84063. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84064. * @param name The name of the accessor
  84065. * @param type The type of the accessor
  84066. * @param componentType The datatype of components in the attribute
  84067. * @param count The number of attributes referenced by this accessor
  84068. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84069. * @param min Minimum value of each component in this attribute
  84070. * @param max Maximum value of each component in this attribute
  84071. * @returns accessor for glTF
  84072. */
  84073. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84074. /**
  84075. * Calculates the minimum and maximum values of an array of position floats
  84076. * @param positions Positions array of a mesh
  84077. * @param vertexStart Starting vertex offset to calculate min and max values
  84078. * @param vertexCount Number of vertices to check for min and max values
  84079. * @returns min number array and max number array
  84080. */
  84081. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84082. min: number[];
  84083. max: number[];
  84084. };
  84085. /**
  84086. * Converts a new right-handed Vector3
  84087. * @param vector vector3 array
  84088. * @returns right-handed Vector3
  84089. */
  84090. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84091. /**
  84092. * Converts a Vector3 to right-handed
  84093. * @param vector Vector3 to convert to right-handed
  84094. */
  84095. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84096. /**
  84097. * Converts a three element number array to right-handed
  84098. * @param vector number array to convert to right-handed
  84099. */
  84100. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84101. /**
  84102. * Converts a new right-handed Vector3
  84103. * @param vector vector3 array
  84104. * @returns right-handed Vector3
  84105. */
  84106. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84107. /**
  84108. * Converts a Vector3 to right-handed
  84109. * @param vector Vector3 to convert to right-handed
  84110. */
  84111. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84112. /**
  84113. * Converts a three element number array to right-handed
  84114. * @param vector number array to convert to right-handed
  84115. */
  84116. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84117. /**
  84118. * Converts a Vector4 to right-handed
  84119. * @param vector Vector4 to convert to right-handed
  84120. */
  84121. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84122. /**
  84123. * Converts a Vector4 to right-handed
  84124. * @param vector Vector4 to convert to right-handed
  84125. */
  84126. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84127. /**
  84128. * Converts a Quaternion to right-handed
  84129. * @param quaternion Source quaternion to convert to right-handed
  84130. */
  84131. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84132. /**
  84133. * Converts a Quaternion to right-handed
  84134. * @param quaternion Source quaternion to convert to right-handed
  84135. */
  84136. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84137. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84138. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84139. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84140. }
  84141. }
  84142. declare module BABYLON.GLTF2.Exporter {
  84143. /**
  84144. * Converts Babylon Scene into glTF 2.0.
  84145. * @hidden
  84146. */
  84147. export class _Exporter {
  84148. /**
  84149. * Stores the glTF to export
  84150. */
  84151. _glTF: IGLTF;
  84152. /**
  84153. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84154. */
  84155. _bufferViews: IBufferView[];
  84156. /**
  84157. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84158. */
  84159. _accessors: IAccessor[];
  84160. /**
  84161. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84162. */
  84163. _nodes: INode[];
  84164. /**
  84165. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84166. */
  84167. private _scenes;
  84168. /**
  84169. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84170. */
  84171. private _meshes;
  84172. /**
  84173. * Stores all the generated material information, which represents the appearance of each primitive
  84174. */
  84175. _materials: IMaterial[];
  84176. _materialMap: {
  84177. [materialID: number]: number;
  84178. };
  84179. /**
  84180. * Stores all the generated texture information, which is referenced by glTF materials
  84181. */
  84182. _textures: ITexture[];
  84183. /**
  84184. * Stores all the generated image information, which is referenced by glTF textures
  84185. */
  84186. _images: IImage[];
  84187. /**
  84188. * Stores all the texture samplers
  84189. */
  84190. _samplers: ISampler[];
  84191. /**
  84192. * Stores all the generated glTF skins
  84193. */
  84194. _skins: ISkin[];
  84195. /**
  84196. * Stores all the generated animation samplers, which is referenced by glTF animations
  84197. */
  84198. /**
  84199. * Stores the animations for glTF models
  84200. */
  84201. private _animations;
  84202. /**
  84203. * Stores the total amount of bytes stored in the glTF buffer
  84204. */
  84205. private _totalByteLength;
  84206. /**
  84207. * Stores a reference to the Babylon scene containing the source geometry and material information
  84208. */
  84209. _babylonScene: Scene;
  84210. /**
  84211. * Stores a map of the image data, where the key is the file name and the value
  84212. * is the image data
  84213. */
  84214. _imageData: {
  84215. [fileName: string]: {
  84216. data: Uint8Array;
  84217. mimeType: ImageMimeType;
  84218. };
  84219. };
  84220. protected _orderedImageData: Array<{
  84221. data: Uint8Array;
  84222. mimeType: ImageMimeType;
  84223. }>;
  84224. /**
  84225. * Stores a map of the unique id of a node to its index in the node array
  84226. */
  84227. _nodeMap: {
  84228. [key: number]: number;
  84229. };
  84230. /**
  84231. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84232. */
  84233. _convertToRightHandedSystem: boolean;
  84234. /**
  84235. * Specifies if a Babylon node should be converted to right-handed on export
  84236. */
  84237. _convertToRightHandedSystemMap: {
  84238. [nodeId: number]: boolean;
  84239. };
  84240. _includeCoordinateSystemConversionNodes: boolean;
  84241. /**
  84242. * Baked animation sample rate
  84243. */
  84244. private _animationSampleRate;
  84245. private _options;
  84246. private _localEngine;
  84247. _glTFMaterialExporter: _GLTFMaterialExporter;
  84248. private _extensions;
  84249. private static _ExtensionNames;
  84250. private static _ExtensionFactories;
  84251. private _applyExtension;
  84252. private _applyExtensions;
  84253. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84254. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84255. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84256. [key: number]: number;
  84257. }): Promise<Nullable<INode>>;
  84258. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84259. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84260. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84261. private _forEachExtensions;
  84262. private _extensionsOnExporting;
  84263. /**
  84264. * Load glTF serializer extensions
  84265. */
  84266. private _loadExtensions;
  84267. /**
  84268. * Creates a glTF Exporter instance, which can accept optional exporter options
  84269. * @param babylonScene Babylon scene object
  84270. * @param options Options to modify the behavior of the exporter
  84271. */
  84272. constructor(babylonScene: Scene, options?: IExportOptions);
  84273. dispose(): void;
  84274. /**
  84275. * Registers a glTF exporter extension
  84276. * @param name Name of the extension to export
  84277. * @param factory The factory function that creates the exporter extension
  84278. */
  84279. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84280. /**
  84281. * Un-registers an exporter extension
  84282. * @param name The name fo the exporter extension
  84283. * @returns A boolean indicating whether the extension has been un-registered
  84284. */
  84285. static UnregisterExtension(name: string): boolean;
  84286. /**
  84287. * Lazy load a local engine
  84288. */
  84289. _getLocalEngine(): Engine;
  84290. private reorderIndicesBasedOnPrimitiveMode;
  84291. /**
  84292. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84293. * clock-wise during export to glTF
  84294. * @param submesh BabylonJS submesh
  84295. * @param primitiveMode Primitive mode of the mesh
  84296. * @param sideOrientation the winding order of the submesh
  84297. * @param vertexBufferKind The type of vertex attribute
  84298. * @param meshAttributeArray The vertex attribute data
  84299. * @param byteOffset The offset to the binary data
  84300. * @param binaryWriter The binary data for the glTF file
  84301. * @param convertToRightHandedSystem Converts the values to right-handed
  84302. */
  84303. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84304. /**
  84305. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84306. * clock-wise during export to glTF
  84307. * @param submesh BabylonJS submesh
  84308. * @param primitiveMode Primitive mode of the mesh
  84309. * @param sideOrientation the winding order of the submesh
  84310. * @param vertexBufferKind The type of vertex attribute
  84311. * @param meshAttributeArray The vertex attribute data
  84312. * @param byteOffset The offset to the binary data
  84313. * @param binaryWriter The binary data for the glTF file
  84314. * @param convertToRightHandedSystem Converts the values to right-handed
  84315. */
  84316. private reorderTriangleFillMode;
  84317. /**
  84318. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84319. * clock-wise during export to glTF
  84320. * @param submesh BabylonJS submesh
  84321. * @param primitiveMode Primitive mode of the mesh
  84322. * @param sideOrientation the winding order of the submesh
  84323. * @param vertexBufferKind The type of vertex attribute
  84324. * @param meshAttributeArray The vertex attribute data
  84325. * @param byteOffset The offset to the binary data
  84326. * @param binaryWriter The binary data for the glTF file
  84327. * @param convertToRightHandedSystem Converts the values to right-handed
  84328. */
  84329. private reorderTriangleStripDrawMode;
  84330. /**
  84331. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84332. * clock-wise during export to glTF
  84333. * @param submesh BabylonJS submesh
  84334. * @param primitiveMode Primitive mode of the mesh
  84335. * @param sideOrientation the winding order of the submesh
  84336. * @param vertexBufferKind The type of vertex attribute
  84337. * @param meshAttributeArray The vertex attribute data
  84338. * @param byteOffset The offset to the binary data
  84339. * @param binaryWriter The binary data for the glTF file
  84340. * @param convertToRightHandedSystem Converts the values to right-handed
  84341. */
  84342. private reorderTriangleFanMode;
  84343. /**
  84344. * Writes the vertex attribute data to binary
  84345. * @param vertices The vertices to write to the binary writer
  84346. * @param byteOffset The offset into the binary writer to overwrite binary data
  84347. * @param vertexAttributeKind The vertex attribute type
  84348. * @param meshAttributeArray The vertex attribute data
  84349. * @param binaryWriter The writer containing the binary data
  84350. * @param convertToRightHandedSystem Converts the values to right-handed
  84351. */
  84352. private writeVertexAttributeData;
  84353. /**
  84354. * Writes mesh attribute data to a data buffer
  84355. * Returns the bytelength of the data
  84356. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84357. * @param meshAttributeArray Array containing the attribute data
  84358. * @param byteStride Specifies the space between data
  84359. * @param binaryWriter The buffer to write the binary data to
  84360. * @param convertToRightHandedSystem Converts the values to right-handed
  84361. */
  84362. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84363. /**
  84364. * Writes mesh attribute data to a data buffer
  84365. * Returns the bytelength of the data
  84366. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84367. * @param meshAttributeArray Array containing the attribute data
  84368. * @param byteStride Specifies the space between data
  84369. * @param binaryWriter The buffer to write the binary data to
  84370. * @param convertToRightHandedSystem Converts the values to right-handed
  84371. */
  84372. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84373. /**
  84374. * Generates glTF json data
  84375. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84376. * @param glTFPrefix Text to use when prefixing a glTF file
  84377. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84378. * @returns json data as string
  84379. */
  84380. private generateJSON;
  84381. /**
  84382. * Generates data for .gltf and .bin files based on the glTF prefix string
  84383. * @param glTFPrefix Text to use when prefixing a glTF file
  84384. * @param dispose Dispose the exporter
  84385. * @returns GLTFData with glTF file data
  84386. */
  84387. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84388. /**
  84389. * Creates a binary buffer for glTF
  84390. * @returns array buffer for binary data
  84391. */
  84392. private _generateBinaryAsync;
  84393. /**
  84394. * Pads the number to a multiple of 4
  84395. * @param num number to pad
  84396. * @returns padded number
  84397. */
  84398. private _getPadding;
  84399. /**
  84400. * @hidden
  84401. */
  84402. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84403. /**
  84404. * Sets the TRS for each node
  84405. * @param node glTF Node for storing the transformation data
  84406. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84407. * @param convertToRightHandedSystem Converts the values to right-handed
  84408. */
  84409. private setNodeTransformation;
  84410. private getVertexBufferFromMesh;
  84411. /**
  84412. * Creates a bufferview based on the vertices type for the Babylon mesh
  84413. * @param kind Indicates the type of vertices data
  84414. * @param componentType Indicates the numerical type used to store the data
  84415. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84416. * @param binaryWriter The buffer to write the bufferview data to
  84417. * @param convertToRightHandedSystem Converts the values to right-handed
  84418. */
  84419. private createBufferViewKind;
  84420. /**
  84421. * Creates a bufferview based on the vertices type for the Babylon mesh
  84422. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84423. * @param babylonMorphTarget the morph target to be exported
  84424. * @param binaryWriter The buffer to write the bufferview data to
  84425. * @param convertToRightHandedSystem Converts the values to right-handed
  84426. */
  84427. private setMorphTargetAttributes;
  84428. /**
  84429. * The primitive mode of the Babylon mesh
  84430. * @param babylonMesh The BabylonJS mesh
  84431. */
  84432. private getMeshPrimitiveMode;
  84433. /**
  84434. * Sets the primitive mode of the glTF mesh primitive
  84435. * @param meshPrimitive glTF mesh primitive
  84436. * @param primitiveMode The primitive mode
  84437. */
  84438. private setPrimitiveMode;
  84439. /**
  84440. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84441. * @param meshPrimitive glTF mesh primitive
  84442. * @param attributeKind vertex attribute
  84443. * @returns boolean specifying if uv coordinates are present
  84444. */
  84445. private setAttributeKind;
  84446. /**
  84447. * Sets data for the primitive attributes of each submesh
  84448. * @param mesh glTF Mesh object to store the primitive attribute information
  84449. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84450. * @param binaryWriter Buffer to write the attribute data to
  84451. * @param convertToRightHandedSystem Converts the values to right-handed
  84452. */
  84453. private setPrimitiveAttributesAsync;
  84454. /**
  84455. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84456. * @param node The node to check
  84457. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84458. */
  84459. private isBabylonCoordinateSystemConvertingNode;
  84460. /**
  84461. * Creates a glTF scene based on the array of meshes
  84462. * Returns the the total byte offset
  84463. * @param babylonScene Babylon scene to get the mesh data from
  84464. * @param binaryWriter Buffer to write binary data to
  84465. */
  84466. private createSceneAsync;
  84467. /**
  84468. * Creates a mapping of Node unique id to node index and handles animations
  84469. * @param babylonScene Babylon Scene
  84470. * @param nodes Babylon transform nodes
  84471. * @param binaryWriter Buffer to write binary data to
  84472. * @returns Node mapping of unique id to index
  84473. */
  84474. private createNodeMapAndAnimationsAsync;
  84475. /**
  84476. * Creates a glTF node from a Babylon mesh
  84477. * @param babylonMesh Source Babylon mesh
  84478. * @param binaryWriter Buffer for storing geometry data
  84479. * @param convertToRightHandedSystem Converts the values to right-handed
  84480. * @param nodeMap Node mapping of unique id to glTF node index
  84481. * @returns glTF node
  84482. */
  84483. private createNodeAsync;
  84484. /**
  84485. * Creates a glTF skin from a Babylon skeleton
  84486. * @param babylonScene Babylon Scene
  84487. * @param nodes Babylon transform nodes
  84488. * @param binaryWriter Buffer to write binary data to
  84489. * @returns Node mapping of unique id to index
  84490. */
  84491. private createSkinsAsync;
  84492. }
  84493. /**
  84494. * @hidden
  84495. *
  84496. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84497. */
  84498. export class _BinaryWriter {
  84499. /**
  84500. * Array buffer which stores all binary data
  84501. */
  84502. private _arrayBuffer;
  84503. /**
  84504. * View of the array buffer
  84505. */
  84506. private _dataView;
  84507. /**
  84508. * byte offset of data in array buffer
  84509. */
  84510. private _byteOffset;
  84511. /**
  84512. * Initialize binary writer with an initial byte length
  84513. * @param byteLength Initial byte length of the array buffer
  84514. */
  84515. constructor(byteLength: number);
  84516. /**
  84517. * Resize the array buffer to the specified byte length
  84518. * @param byteLength
  84519. */
  84520. private resizeBuffer;
  84521. /**
  84522. * Get an array buffer with the length of the byte offset
  84523. * @returns ArrayBuffer resized to the byte offset
  84524. */
  84525. getArrayBuffer(): ArrayBuffer;
  84526. /**
  84527. * Get the byte offset of the array buffer
  84528. * @returns byte offset
  84529. */
  84530. getByteOffset(): number;
  84531. /**
  84532. * Stores an UInt8 in the array buffer
  84533. * @param entry
  84534. * @param byteOffset If defined, specifies where to set the value as an offset.
  84535. */
  84536. setUInt8(entry: number, byteOffset?: number): void;
  84537. /**
  84538. * Stores an UInt16 in the array buffer
  84539. * @param entry
  84540. * @param byteOffset If defined, specifies where to set the value as an offset.
  84541. */
  84542. setUInt16(entry: number, byteOffset?: number): void;
  84543. /**
  84544. * Gets an UInt32 in the array buffer
  84545. * @param entry
  84546. * @param byteOffset If defined, specifies where to set the value as an offset.
  84547. */
  84548. getUInt32(byteOffset: number): number;
  84549. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84550. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84551. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84552. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84553. /**
  84554. * Stores a Float32 in the array buffer
  84555. * @param entry
  84556. */
  84557. setFloat32(entry: number, byteOffset?: number): void;
  84558. /**
  84559. * Stores an UInt32 in the array buffer
  84560. * @param entry
  84561. * @param byteOffset If defined, specifies where to set the value as an offset.
  84562. */
  84563. setUInt32(entry: number, byteOffset?: number): void;
  84564. }
  84565. }
  84566. declare module BABYLON.GLTF2.Exporter {
  84567. /**
  84568. * @hidden
  84569. * Interface to store animation data.
  84570. */
  84571. export interface _IAnimationData {
  84572. /**
  84573. * Keyframe data.
  84574. */
  84575. inputs: number[];
  84576. /**
  84577. * Value data.
  84578. */
  84579. outputs: number[][];
  84580. /**
  84581. * Animation interpolation data.
  84582. */
  84583. samplerInterpolation: AnimationSamplerInterpolation;
  84584. /**
  84585. * Minimum keyframe value.
  84586. */
  84587. inputsMin: number;
  84588. /**
  84589. * Maximum keyframe value.
  84590. */
  84591. inputsMax: number;
  84592. }
  84593. /**
  84594. * @hidden
  84595. */
  84596. export interface _IAnimationInfo {
  84597. /**
  84598. * The target channel for the animation
  84599. */
  84600. animationChannelTargetPath: AnimationChannelTargetPath;
  84601. /**
  84602. * The glTF accessor type for the data.
  84603. */
  84604. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84605. /**
  84606. * Specifies if quaternions should be used.
  84607. */
  84608. useQuaternion: boolean;
  84609. }
  84610. /**
  84611. * @hidden
  84612. * Utility class for generating glTF animation data from BabylonJS.
  84613. */
  84614. export class _GLTFAnimation {
  84615. /**
  84616. * @ignore
  84617. *
  84618. * Creates glTF channel animation from BabylonJS animation.
  84619. * @param babylonTransformNode - BabylonJS mesh.
  84620. * @param animation - animation.
  84621. * @param animationChannelTargetPath - The target animation channel.
  84622. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84623. * @param useQuaternion - Specifies if quaternions are used.
  84624. * @returns nullable IAnimationData
  84625. */
  84626. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84627. private static _DeduceAnimationInfo;
  84628. /**
  84629. * @ignore
  84630. * Create node animations from the transform node animations
  84631. * @param babylonNode
  84632. * @param runtimeGLTFAnimation
  84633. * @param idleGLTFAnimations
  84634. * @param nodeMap
  84635. * @param nodes
  84636. * @param binaryWriter
  84637. * @param bufferViews
  84638. * @param accessors
  84639. * @param convertToRightHandedSystem
  84640. * @param animationSampleRate
  84641. */
  84642. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84643. [key: number]: number;
  84644. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84645. /**
  84646. * @ignore
  84647. * Create individual morph animations from the mesh's morph target animation tracks
  84648. * @param babylonNode
  84649. * @param runtimeGLTFAnimation
  84650. * @param idleGLTFAnimations
  84651. * @param nodeMap
  84652. * @param nodes
  84653. * @param binaryWriter
  84654. * @param bufferViews
  84655. * @param accessors
  84656. * @param convertToRightHandedSystem
  84657. * @param animationSampleRate
  84658. */
  84659. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84660. [key: number]: number;
  84661. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84662. /**
  84663. * @ignore
  84664. * Create node and morph animations from the animation groups
  84665. * @param babylonScene
  84666. * @param glTFAnimations
  84667. * @param nodeMap
  84668. * @param nodes
  84669. * @param binaryWriter
  84670. * @param bufferViews
  84671. * @param accessors
  84672. * @param convertToRightHandedSystemMap
  84673. * @param animationSampleRate
  84674. */
  84675. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84676. [key: number]: number;
  84677. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84678. [nodeId: number]: boolean;
  84679. }, animationSampleRate: number): void;
  84680. private static AddAnimation;
  84681. /**
  84682. * Create a baked animation
  84683. * @param babylonTransformNode BabylonJS mesh
  84684. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84685. * @param animationChannelTargetPath animation target channel
  84686. * @param minFrame minimum animation frame
  84687. * @param maxFrame maximum animation frame
  84688. * @param fps frames per second of the animation
  84689. * @param inputs input key frames of the animation
  84690. * @param outputs output key frame data of the animation
  84691. * @param convertToRightHandedSystem converts the values to right-handed
  84692. * @param useQuaternion specifies if quaternions should be used
  84693. */
  84694. private static _CreateBakedAnimation;
  84695. private static _ConvertFactorToVector3OrQuaternion;
  84696. private static _SetInterpolatedValue;
  84697. /**
  84698. * Creates linear animation from the animation key frames
  84699. * @param babylonTransformNode BabylonJS mesh
  84700. * @param animation BabylonJS animation
  84701. * @param animationChannelTargetPath The target animation channel
  84702. * @param frameDelta The difference between the last and first frame of the animation
  84703. * @param inputs Array to store the key frame times
  84704. * @param outputs Array to store the key frame data
  84705. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84706. * @param useQuaternion Specifies if quaternions are used in the animation
  84707. */
  84708. private static _CreateLinearOrStepAnimation;
  84709. /**
  84710. * Creates cubic spline animation from the animation key frames
  84711. * @param babylonTransformNode BabylonJS mesh
  84712. * @param animation BabylonJS animation
  84713. * @param animationChannelTargetPath The target animation channel
  84714. * @param frameDelta The difference between the last and first frame of the animation
  84715. * @param inputs Array to store the key frame times
  84716. * @param outputs Array to store the key frame data
  84717. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84718. * @param useQuaternion Specifies if quaternions are used in the animation
  84719. */
  84720. private static _CreateCubicSplineAnimation;
  84721. private static _GetBasePositionRotationOrScale;
  84722. /**
  84723. * Adds a key frame value
  84724. * @param keyFrame
  84725. * @param animation
  84726. * @param outputs
  84727. * @param animationChannelTargetPath
  84728. * @param basePositionRotationOrScale
  84729. * @param convertToRightHandedSystem
  84730. * @param useQuaternion
  84731. */
  84732. private static _AddKeyframeValue;
  84733. /**
  84734. * Determine the interpolation based on the key frames
  84735. * @param keyFrames
  84736. * @param animationChannelTargetPath
  84737. * @param useQuaternion
  84738. */
  84739. private static _DeduceInterpolation;
  84740. /**
  84741. * Adds an input tangent or output tangent to the output data
  84742. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84743. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84744. * @param outputs The animation data by keyframe
  84745. * @param animationChannelTargetPath The target animation channel
  84746. * @param interpolation The interpolation type
  84747. * @param keyFrame The key frame with the animation data
  84748. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84749. * @param useQuaternion Specifies if quaternions are used
  84750. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84751. */
  84752. private static AddSplineTangent;
  84753. /**
  84754. * Get the minimum and maximum key frames' frame values
  84755. * @param keyFrames animation key frames
  84756. * @returns the minimum and maximum key frame value
  84757. */
  84758. private static calculateMinMaxKeyFrames;
  84759. }
  84760. }
  84761. declare module BABYLON.GLTF2.Exporter {
  84762. /** @hidden */
  84763. export var textureTransformPixelShader: {
  84764. name: string;
  84765. shader: string;
  84766. };
  84767. }
  84768. declare module BABYLON.GLTF2.Exporter.Extensions {
  84769. /**
  84770. * @hidden
  84771. */
  84772. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84773. private _recordedTextures;
  84774. /** Name of this extension */
  84775. readonly name: string;
  84776. /** Defines whether this extension is enabled */
  84777. enabled: boolean;
  84778. /** Defines whether this extension is required */
  84779. required: boolean;
  84780. /** Reference to the glTF exporter */
  84781. private _wasUsed;
  84782. constructor(exporter: _Exporter);
  84783. dispose(): void;
  84784. /** @hidden */
  84785. get wasUsed(): boolean;
  84786. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84787. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84788. /**
  84789. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84790. * @param babylonTexture
  84791. * @param offset
  84792. * @param rotation
  84793. * @param scale
  84794. * @param scene
  84795. */
  84796. private _textureTransformTextureAsync;
  84797. }
  84798. }
  84799. declare module BABYLON.GLTF2.Exporter.Extensions {
  84800. /**
  84801. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84802. */
  84803. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84804. /** The name of this extension. */
  84805. readonly name: string;
  84806. /** Defines whether this extension is enabled. */
  84807. enabled: boolean;
  84808. /** Defines whether this extension is required */
  84809. required: boolean;
  84810. /** Reference to the glTF exporter */
  84811. private _exporter;
  84812. private _lights;
  84813. /** @hidden */
  84814. constructor(exporter: _Exporter);
  84815. /** @hidden */
  84816. dispose(): void;
  84817. /** @hidden */
  84818. get wasUsed(): boolean;
  84819. /** @hidden */
  84820. onExporting(): void;
  84821. /**
  84822. * Define this method to modify the default behavior when exporting a node
  84823. * @param context The context when exporting the node
  84824. * @param node glTF node
  84825. * @param babylonNode BabylonJS node
  84826. * @param nodeMap Node mapping of unique id to glTF node index
  84827. * @returns nullable INode promise
  84828. */
  84829. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84830. [key: number]: number;
  84831. }): Promise<Nullable<INode>>;
  84832. }
  84833. }
  84834. declare module BABYLON.GLTF2.Exporter.Extensions {
  84835. /**
  84836. * @hidden
  84837. */
  84838. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84839. /** Name of this extension */
  84840. readonly name: string;
  84841. /** Defines whether this extension is enabled */
  84842. enabled: boolean;
  84843. /** Defines whether this extension is required */
  84844. required: boolean;
  84845. /** Reference to the glTF exporter */
  84846. private _textureInfos;
  84847. private _exportedTextures;
  84848. private _wasUsed;
  84849. constructor(exporter: _Exporter);
  84850. dispose(): void;
  84851. /** @hidden */
  84852. get wasUsed(): boolean;
  84853. private _getTextureIndex;
  84854. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84855. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84856. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84857. }
  84858. }
  84859. declare module BABYLON.GLTF2.Exporter.Extensions {
  84860. /**
  84861. * @hidden
  84862. */
  84863. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  84864. /** Name of this extension */
  84865. readonly name: string;
  84866. /** Defines whether this extension is enabled */
  84867. enabled: boolean;
  84868. /** Defines whether this extension is required */
  84869. required: boolean;
  84870. private _wasUsed;
  84871. constructor(exporter: _Exporter);
  84872. /** @hidden */
  84873. get wasUsed(): boolean;
  84874. dispose(): void;
  84875. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84876. }
  84877. }
  84878. declare module BABYLON {
  84879. /**
  84880. * Class for generating STL data from a Babylon scene.
  84881. */
  84882. export class STLExport {
  84883. /**
  84884. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  84885. * @param meshes list defines the mesh to serialize
  84886. * @param download triggers the automatic download of the file.
  84887. * @param fileName changes the downloads fileName.
  84888. * @param binary changes the STL to a binary type.
  84889. * @param isLittleEndian toggle for binary type exporter.
  84890. * @returns the STL as UTF8 string
  84891. */
  84892. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  84893. }
  84894. }
  84895. declare module "babylonjs-gltf2interface" {
  84896. export = BABYLON.GLTF2;
  84897. }
  84898. /**
  84899. * Module for glTF 2.0 Interface
  84900. */
  84901. declare module BABYLON.GLTF2 {
  84902. /**
  84903. * The datatype of the components in the attribute
  84904. */
  84905. const enum AccessorComponentType {
  84906. /**
  84907. * Byte
  84908. */
  84909. BYTE = 5120,
  84910. /**
  84911. * Unsigned Byte
  84912. */
  84913. UNSIGNED_BYTE = 5121,
  84914. /**
  84915. * Short
  84916. */
  84917. SHORT = 5122,
  84918. /**
  84919. * Unsigned Short
  84920. */
  84921. UNSIGNED_SHORT = 5123,
  84922. /**
  84923. * Unsigned Int
  84924. */
  84925. UNSIGNED_INT = 5125,
  84926. /**
  84927. * Float
  84928. */
  84929. FLOAT = 5126,
  84930. }
  84931. /**
  84932. * Specifies if the attirbute is a scalar, vector, or matrix
  84933. */
  84934. const enum AccessorType {
  84935. /**
  84936. * Scalar
  84937. */
  84938. SCALAR = "SCALAR",
  84939. /**
  84940. * Vector2
  84941. */
  84942. VEC2 = "VEC2",
  84943. /**
  84944. * Vector3
  84945. */
  84946. VEC3 = "VEC3",
  84947. /**
  84948. * Vector4
  84949. */
  84950. VEC4 = "VEC4",
  84951. /**
  84952. * Matrix2x2
  84953. */
  84954. MAT2 = "MAT2",
  84955. /**
  84956. * Matrix3x3
  84957. */
  84958. MAT3 = "MAT3",
  84959. /**
  84960. * Matrix4x4
  84961. */
  84962. MAT4 = "MAT4",
  84963. }
  84964. /**
  84965. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84966. */
  84967. const enum AnimationChannelTargetPath {
  84968. /**
  84969. * Translation
  84970. */
  84971. TRANSLATION = "translation",
  84972. /**
  84973. * Rotation
  84974. */
  84975. ROTATION = "rotation",
  84976. /**
  84977. * Scale
  84978. */
  84979. SCALE = "scale",
  84980. /**
  84981. * Weights
  84982. */
  84983. WEIGHTS = "weights",
  84984. }
  84985. /**
  84986. * Interpolation algorithm
  84987. */
  84988. const enum AnimationSamplerInterpolation {
  84989. /**
  84990. * The animated values are linearly interpolated between keyframes
  84991. */
  84992. LINEAR = "LINEAR",
  84993. /**
  84994. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84995. */
  84996. STEP = "STEP",
  84997. /**
  84998. * The animation's interpolation is computed using a cubic spline with specified tangents
  84999. */
  85000. CUBICSPLINE = "CUBICSPLINE",
  85001. }
  85002. /**
  85003. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85004. */
  85005. const enum CameraType {
  85006. /**
  85007. * A perspective camera containing properties to create a perspective projection matrix
  85008. */
  85009. PERSPECTIVE = "perspective",
  85010. /**
  85011. * An orthographic camera containing properties to create an orthographic projection matrix
  85012. */
  85013. ORTHOGRAPHIC = "orthographic",
  85014. }
  85015. /**
  85016. * The mime-type of the image
  85017. */
  85018. const enum ImageMimeType {
  85019. /**
  85020. * JPEG Mime-type
  85021. */
  85022. JPEG = "image/jpeg",
  85023. /**
  85024. * PNG Mime-type
  85025. */
  85026. PNG = "image/png",
  85027. }
  85028. /**
  85029. * The alpha rendering mode of the material
  85030. */
  85031. const enum MaterialAlphaMode {
  85032. /**
  85033. * The alpha value is ignored and the rendered output is fully opaque
  85034. */
  85035. OPAQUE = "OPAQUE",
  85036. /**
  85037. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85038. */
  85039. MASK = "MASK",
  85040. /**
  85041. * 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)
  85042. */
  85043. BLEND = "BLEND",
  85044. }
  85045. /**
  85046. * The type of the primitives to render
  85047. */
  85048. const enum MeshPrimitiveMode {
  85049. /**
  85050. * Points
  85051. */
  85052. POINTS = 0,
  85053. /**
  85054. * Lines
  85055. */
  85056. LINES = 1,
  85057. /**
  85058. * Line Loop
  85059. */
  85060. LINE_LOOP = 2,
  85061. /**
  85062. * Line Strip
  85063. */
  85064. LINE_STRIP = 3,
  85065. /**
  85066. * Triangles
  85067. */
  85068. TRIANGLES = 4,
  85069. /**
  85070. * Triangle Strip
  85071. */
  85072. TRIANGLE_STRIP = 5,
  85073. /**
  85074. * Triangle Fan
  85075. */
  85076. TRIANGLE_FAN = 6,
  85077. }
  85078. /**
  85079. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85080. */
  85081. const enum TextureMagFilter {
  85082. /**
  85083. * Nearest
  85084. */
  85085. NEAREST = 9728,
  85086. /**
  85087. * Linear
  85088. */
  85089. LINEAR = 9729,
  85090. }
  85091. /**
  85092. * Minification filter. All valid values correspond to WebGL enums
  85093. */
  85094. const enum TextureMinFilter {
  85095. /**
  85096. * Nearest
  85097. */
  85098. NEAREST = 9728,
  85099. /**
  85100. * Linear
  85101. */
  85102. LINEAR = 9729,
  85103. /**
  85104. * Nearest Mip-Map Nearest
  85105. */
  85106. NEAREST_MIPMAP_NEAREST = 9984,
  85107. /**
  85108. * Linear Mipmap Nearest
  85109. */
  85110. LINEAR_MIPMAP_NEAREST = 9985,
  85111. /**
  85112. * Nearest Mipmap Linear
  85113. */
  85114. NEAREST_MIPMAP_LINEAR = 9986,
  85115. /**
  85116. * Linear Mipmap Linear
  85117. */
  85118. LINEAR_MIPMAP_LINEAR = 9987,
  85119. }
  85120. /**
  85121. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85122. */
  85123. const enum TextureWrapMode {
  85124. /**
  85125. * Clamp to Edge
  85126. */
  85127. CLAMP_TO_EDGE = 33071,
  85128. /**
  85129. * Mirrored Repeat
  85130. */
  85131. MIRRORED_REPEAT = 33648,
  85132. /**
  85133. * Repeat
  85134. */
  85135. REPEAT = 10497,
  85136. }
  85137. /**
  85138. * glTF Property
  85139. */
  85140. interface IProperty {
  85141. /**
  85142. * Dictionary object with extension-specific objects
  85143. */
  85144. extensions?: {
  85145. [key: string]: any;
  85146. };
  85147. /**
  85148. * Application-Specific data
  85149. */
  85150. extras?: any;
  85151. }
  85152. /**
  85153. * glTF Child of Root Property
  85154. */
  85155. interface IChildRootProperty extends IProperty {
  85156. /**
  85157. * The user-defined name of this object
  85158. */
  85159. name?: string;
  85160. }
  85161. /**
  85162. * Indices of those attributes that deviate from their initialization value
  85163. */
  85164. interface IAccessorSparseIndices extends IProperty {
  85165. /**
  85166. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85167. */
  85168. bufferView: number;
  85169. /**
  85170. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85171. */
  85172. byteOffset?: number;
  85173. /**
  85174. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85175. */
  85176. componentType: AccessorComponentType;
  85177. }
  85178. /**
  85179. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85180. */
  85181. interface IAccessorSparseValues extends IProperty {
  85182. /**
  85183. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85184. */
  85185. bufferView: number;
  85186. /**
  85187. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85188. */
  85189. byteOffset?: number;
  85190. }
  85191. /**
  85192. * Sparse storage of attributes that deviate from their initialization value
  85193. */
  85194. interface IAccessorSparse extends IProperty {
  85195. /**
  85196. * The number of attributes encoded in this sparse accessor
  85197. */
  85198. count: number;
  85199. /**
  85200. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85201. */
  85202. indices: IAccessorSparseIndices;
  85203. /**
  85204. * 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
  85205. */
  85206. values: IAccessorSparseValues;
  85207. }
  85208. /**
  85209. * 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
  85210. */
  85211. interface IAccessor extends IChildRootProperty {
  85212. /**
  85213. * The index of the bufferview
  85214. */
  85215. bufferView?: number;
  85216. /**
  85217. * The offset relative to the start of the bufferView in bytes
  85218. */
  85219. byteOffset?: number;
  85220. /**
  85221. * The datatype of components in the attribute
  85222. */
  85223. componentType: AccessorComponentType;
  85224. /**
  85225. * Specifies whether integer data values should be normalized
  85226. */
  85227. normalized?: boolean;
  85228. /**
  85229. * The number of attributes referenced by this accessor
  85230. */
  85231. count: number;
  85232. /**
  85233. * Specifies if the attribute is a scalar, vector, or matrix
  85234. */
  85235. type: AccessorType;
  85236. /**
  85237. * Maximum value of each component in this attribute
  85238. */
  85239. max?: number[];
  85240. /**
  85241. * Minimum value of each component in this attribute
  85242. */
  85243. min?: number[];
  85244. /**
  85245. * Sparse storage of attributes that deviate from their initialization value
  85246. */
  85247. sparse?: IAccessorSparse;
  85248. }
  85249. /**
  85250. * Targets an animation's sampler at a node's property
  85251. */
  85252. interface IAnimationChannel extends IProperty {
  85253. /**
  85254. * The index of a sampler in this animation used to compute the value for the target
  85255. */
  85256. sampler: number;
  85257. /**
  85258. * The index of the node and TRS property to target
  85259. */
  85260. target: IAnimationChannelTarget;
  85261. }
  85262. /**
  85263. * The index of the node and TRS property that an animation channel targets
  85264. */
  85265. interface IAnimationChannelTarget extends IProperty {
  85266. /**
  85267. * The index of the node to target
  85268. */
  85269. node: number;
  85270. /**
  85271. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85272. */
  85273. path: AnimationChannelTargetPath;
  85274. }
  85275. /**
  85276. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85277. */
  85278. interface IAnimationSampler extends IProperty {
  85279. /**
  85280. * The index of an accessor containing keyframe input values, e.g., time
  85281. */
  85282. input: number;
  85283. /**
  85284. * Interpolation algorithm
  85285. */
  85286. interpolation?: AnimationSamplerInterpolation;
  85287. /**
  85288. * The index of an accessor, containing keyframe output values
  85289. */
  85290. output: number;
  85291. }
  85292. /**
  85293. * A keyframe animation
  85294. */
  85295. interface IAnimation extends IChildRootProperty {
  85296. /**
  85297. * An array of channels, each of which targets an animation's sampler at a node's property
  85298. */
  85299. channels: IAnimationChannel[];
  85300. /**
  85301. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85302. */
  85303. samplers: IAnimationSampler[];
  85304. }
  85305. /**
  85306. * Metadata about the glTF asset
  85307. */
  85308. interface IAsset extends IChildRootProperty {
  85309. /**
  85310. * A copyright message suitable for display to credit the content creator
  85311. */
  85312. copyright?: string;
  85313. /**
  85314. * Tool that generated this glTF model. Useful for debugging
  85315. */
  85316. generator?: string;
  85317. /**
  85318. * The glTF version that this asset targets
  85319. */
  85320. version: string;
  85321. /**
  85322. * The minimum glTF version that this asset targets
  85323. */
  85324. minVersion?: string;
  85325. }
  85326. /**
  85327. * A buffer points to binary geometry, animation, or skins
  85328. */
  85329. interface IBuffer extends IChildRootProperty {
  85330. /**
  85331. * 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
  85332. */
  85333. uri?: string;
  85334. /**
  85335. * The length of the buffer in bytes
  85336. */
  85337. byteLength: number;
  85338. }
  85339. /**
  85340. * A view into a buffer generally representing a subset of the buffer
  85341. */
  85342. interface IBufferView extends IChildRootProperty {
  85343. /**
  85344. * The index of the buffer
  85345. */
  85346. buffer: number;
  85347. /**
  85348. * The offset into the buffer in bytes
  85349. */
  85350. byteOffset?: number;
  85351. /**
  85352. * The lenth of the bufferView in bytes
  85353. */
  85354. byteLength: number;
  85355. /**
  85356. * The stride, in bytes
  85357. */
  85358. byteStride?: number;
  85359. }
  85360. /**
  85361. * An orthographic camera containing properties to create an orthographic projection matrix
  85362. */
  85363. interface ICameraOrthographic extends IProperty {
  85364. /**
  85365. * The floating-point horizontal magnification of the view. Must not be zero
  85366. */
  85367. xmag: number;
  85368. /**
  85369. * The floating-point vertical magnification of the view. Must not be zero
  85370. */
  85371. ymag: number;
  85372. /**
  85373. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85374. */
  85375. zfar: number;
  85376. /**
  85377. * The floating-point distance to the near clipping plane
  85378. */
  85379. znear: number;
  85380. }
  85381. /**
  85382. * A perspective camera containing properties to create a perspective projection matrix
  85383. */
  85384. interface ICameraPerspective extends IProperty {
  85385. /**
  85386. * The floating-point aspect ratio of the field of view
  85387. */
  85388. aspectRatio?: number;
  85389. /**
  85390. * The floating-point vertical field of view in radians
  85391. */
  85392. yfov: number;
  85393. /**
  85394. * The floating-point distance to the far clipping plane
  85395. */
  85396. zfar?: number;
  85397. /**
  85398. * The floating-point distance to the near clipping plane
  85399. */
  85400. znear: number;
  85401. }
  85402. /**
  85403. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85404. */
  85405. interface ICamera extends IChildRootProperty {
  85406. /**
  85407. * An orthographic camera containing properties to create an orthographic projection matrix
  85408. */
  85409. orthographic?: ICameraOrthographic;
  85410. /**
  85411. * A perspective camera containing properties to create a perspective projection matrix
  85412. */
  85413. perspective?: ICameraPerspective;
  85414. /**
  85415. * Specifies if the camera uses a perspective or orthographic projection
  85416. */
  85417. type: CameraType;
  85418. }
  85419. /**
  85420. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85421. */
  85422. interface IImage extends IChildRootProperty {
  85423. /**
  85424. * 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
  85425. */
  85426. uri?: string;
  85427. /**
  85428. * The image's MIME type
  85429. */
  85430. mimeType?: ImageMimeType;
  85431. /**
  85432. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85433. */
  85434. bufferView?: number;
  85435. }
  85436. /**
  85437. * Material Normal Texture Info
  85438. */
  85439. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85440. /**
  85441. * The scalar multiplier applied to each normal vector of the normal texture
  85442. */
  85443. scale?: number;
  85444. }
  85445. /**
  85446. * Material Occlusion Texture Info
  85447. */
  85448. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85449. /**
  85450. * A scalar multiplier controlling the amount of occlusion applied
  85451. */
  85452. strength?: number;
  85453. }
  85454. /**
  85455. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85456. */
  85457. interface IMaterialPbrMetallicRoughness {
  85458. /**
  85459. * The material's base color factor
  85460. */
  85461. baseColorFactor?: number[];
  85462. /**
  85463. * The base color texture
  85464. */
  85465. baseColorTexture?: ITextureInfo;
  85466. /**
  85467. * The metalness of the material
  85468. */
  85469. metallicFactor?: number;
  85470. /**
  85471. * The roughness of the material
  85472. */
  85473. roughnessFactor?: number;
  85474. /**
  85475. * The metallic-roughness texture
  85476. */
  85477. metallicRoughnessTexture?: ITextureInfo;
  85478. }
  85479. /**
  85480. * The material appearance of a primitive
  85481. */
  85482. interface IMaterial extends IChildRootProperty {
  85483. /**
  85484. * 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
  85485. */
  85486. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85487. /**
  85488. * The normal map texture
  85489. */
  85490. normalTexture?: IMaterialNormalTextureInfo;
  85491. /**
  85492. * The occlusion map texture
  85493. */
  85494. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85495. /**
  85496. * The emissive map texture
  85497. */
  85498. emissiveTexture?: ITextureInfo;
  85499. /**
  85500. * 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
  85501. */
  85502. emissiveFactor?: number[];
  85503. /**
  85504. * The alpha rendering mode of the material
  85505. */
  85506. alphaMode?: MaterialAlphaMode;
  85507. /**
  85508. * The alpha cutoff value of the material
  85509. */
  85510. alphaCutoff?: number;
  85511. /**
  85512. * Specifies whether the material is double sided
  85513. */
  85514. doubleSided?: boolean;
  85515. }
  85516. /**
  85517. * Geometry to be rendered with the given material
  85518. */
  85519. interface IMeshPrimitive extends IProperty {
  85520. /**
  85521. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85522. */
  85523. attributes: {
  85524. [name: string]: number;
  85525. };
  85526. /**
  85527. * The index of the accessor that contains the indices
  85528. */
  85529. indices?: number;
  85530. /**
  85531. * The index of the material to apply to this primitive when rendering
  85532. */
  85533. material?: number;
  85534. /**
  85535. * The type of primitives to render. All valid values correspond to WebGL enums
  85536. */
  85537. mode?: MeshPrimitiveMode;
  85538. /**
  85539. * 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
  85540. */
  85541. targets?: {
  85542. [name: string]: number;
  85543. }[];
  85544. }
  85545. /**
  85546. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85547. */
  85548. interface IMesh extends IChildRootProperty {
  85549. /**
  85550. * An array of primitives, each defining geometry to be rendered with a material
  85551. */
  85552. primitives: IMeshPrimitive[];
  85553. /**
  85554. * Array of weights to be applied to the Morph Targets
  85555. */
  85556. weights?: number[];
  85557. }
  85558. /**
  85559. * A node in the node hierarchy
  85560. */
  85561. interface INode extends IChildRootProperty {
  85562. /**
  85563. * The index of the camera referenced by this node
  85564. */
  85565. camera?: number;
  85566. /**
  85567. * The indices of this node's children
  85568. */
  85569. children?: number[];
  85570. /**
  85571. * The index of the skin referenced by this node
  85572. */
  85573. skin?: number;
  85574. /**
  85575. * A floating-point 4x4 transformation matrix stored in column-major order
  85576. */
  85577. matrix?: number[];
  85578. /**
  85579. * The index of the mesh in this node
  85580. */
  85581. mesh?: number;
  85582. /**
  85583. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85584. */
  85585. rotation?: number[];
  85586. /**
  85587. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85588. */
  85589. scale?: number[];
  85590. /**
  85591. * The node's translation along the x, y, and z axes
  85592. */
  85593. translation?: number[];
  85594. /**
  85595. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85596. */
  85597. weights?: number[];
  85598. }
  85599. /**
  85600. * Texture sampler properties for filtering and wrapping modes
  85601. */
  85602. interface ISampler extends IChildRootProperty {
  85603. /**
  85604. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85605. */
  85606. magFilter?: TextureMagFilter;
  85607. /**
  85608. * Minification filter. All valid values correspond to WebGL enums
  85609. */
  85610. minFilter?: TextureMinFilter;
  85611. /**
  85612. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85613. */
  85614. wrapS?: TextureWrapMode;
  85615. /**
  85616. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85617. */
  85618. wrapT?: TextureWrapMode;
  85619. }
  85620. /**
  85621. * The root nodes of a scene
  85622. */
  85623. interface IScene extends IChildRootProperty {
  85624. /**
  85625. * The indices of each root node
  85626. */
  85627. nodes: number[];
  85628. }
  85629. /**
  85630. * Joints and matrices defining a skin
  85631. */
  85632. interface ISkin extends IChildRootProperty {
  85633. /**
  85634. * 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
  85635. */
  85636. inverseBindMatrices?: number;
  85637. /**
  85638. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85639. */
  85640. skeleton?: number;
  85641. /**
  85642. * 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)
  85643. */
  85644. joints: number[];
  85645. }
  85646. /**
  85647. * A texture and its sampler
  85648. */
  85649. interface ITexture extends IChildRootProperty {
  85650. /**
  85651. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85652. */
  85653. sampler?: number;
  85654. /**
  85655. * The index of the image used by this texture
  85656. */
  85657. source: number;
  85658. }
  85659. /**
  85660. * Reference to a texture
  85661. */
  85662. interface ITextureInfo extends IProperty {
  85663. /**
  85664. * The index of the texture
  85665. */
  85666. index: number;
  85667. /**
  85668. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85669. */
  85670. texCoord?: number;
  85671. }
  85672. /**
  85673. * The root object for a glTF asset
  85674. */
  85675. interface IGLTF extends IProperty {
  85676. /**
  85677. * An array of accessors. An accessor is a typed view into a bufferView
  85678. */
  85679. accessors?: IAccessor[];
  85680. /**
  85681. * An array of keyframe animations
  85682. */
  85683. animations?: IAnimation[];
  85684. /**
  85685. * Metadata about the glTF asset
  85686. */
  85687. asset: IAsset;
  85688. /**
  85689. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85690. */
  85691. buffers?: IBuffer[];
  85692. /**
  85693. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85694. */
  85695. bufferViews?: IBufferView[];
  85696. /**
  85697. * An array of cameras
  85698. */
  85699. cameras?: ICamera[];
  85700. /**
  85701. * Names of glTF extensions used somewhere in this asset
  85702. */
  85703. extensionsUsed?: string[];
  85704. /**
  85705. * Names of glTF extensions required to properly load this asset
  85706. */
  85707. extensionsRequired?: string[];
  85708. /**
  85709. * An array of images. An image defines data used to create a texture
  85710. */
  85711. images?: IImage[];
  85712. /**
  85713. * An array of materials. A material defines the appearance of a primitive
  85714. */
  85715. materials?: IMaterial[];
  85716. /**
  85717. * An array of meshes. A mesh is a set of primitives to be rendered
  85718. */
  85719. meshes?: IMesh[];
  85720. /**
  85721. * An array of nodes
  85722. */
  85723. nodes?: INode[];
  85724. /**
  85725. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85726. */
  85727. samplers?: ISampler[];
  85728. /**
  85729. * The index of the default scene
  85730. */
  85731. scene?: number;
  85732. /**
  85733. * An array of scenes
  85734. */
  85735. scenes?: IScene[];
  85736. /**
  85737. * An array of skins. A skin is defined by joints and matrices
  85738. */
  85739. skins?: ISkin[];
  85740. /**
  85741. * An array of textures
  85742. */
  85743. textures?: ITexture[];
  85744. }
  85745. /**
  85746. * The glTF validation results
  85747. * @ignore
  85748. */
  85749. interface IGLTFValidationResults {
  85750. info: {
  85751. generator: string;
  85752. hasAnimations: boolean;
  85753. hasDefaultScene: boolean;
  85754. hasMaterials: boolean;
  85755. hasMorphTargets: boolean;
  85756. hasSkins: boolean;
  85757. hasTextures: boolean;
  85758. maxAttributesUsed: number;
  85759. primitivesCount: number
  85760. };
  85761. issues: {
  85762. messages: Array<string>;
  85763. numErrors: number;
  85764. numHints: number;
  85765. numInfos: number;
  85766. numWarnings: number;
  85767. truncated: boolean
  85768. };
  85769. mimeType: string;
  85770. uri: string;
  85771. validatedAt: string;
  85772. validatorVersion: string;
  85773. }
  85774. /**
  85775. * The glTF validation options
  85776. */
  85777. interface IGLTFValidationOptions {
  85778. /** Uri to use */
  85779. uri?: string;
  85780. /** Function used to load external resources */
  85781. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85782. /** Boolean indicating that we need to validate accessor data */
  85783. validateAccessorData?: boolean;
  85784. /** max number of issues allowed */
  85785. maxIssues?: number;
  85786. /** Ignored issues */
  85787. ignoredIssues?: Array<string>;
  85788. /** Value to override severy settings */
  85789. severityOverrides?: Object;
  85790. }
  85791. /**
  85792. * The glTF validator object
  85793. * @ignore
  85794. */
  85795. interface IGLTFValidator {
  85796. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85797. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85798. }
  85799. /**
  85800. * Interfaces from the EXT_lights_image_based extension
  85801. */
  85802. /** @hidden */
  85803. interface IEXTLightsImageBased_LightReferenceImageBased {
  85804. light: number;
  85805. }
  85806. /** @hidden */
  85807. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85808. intensity: number;
  85809. rotation: number[];
  85810. specularImageSize: number;
  85811. specularImages: number[][];
  85812. irradianceCoefficients: number[][];
  85813. }
  85814. /** @hidden */
  85815. interface IEXTLightsImageBased {
  85816. lights: IEXTLightsImageBased_LightImageBased[];
  85817. }
  85818. /**
  85819. * Interfaces from the EXT_mesh_gpu_instancing extension
  85820. * !!! Experimental Extension Subject to Changes !!!
  85821. */
  85822. /** @hidden */
  85823. interface IEXTMeshGpuInstancing {
  85824. mesh?: number;
  85825. attributes: { [name: string]: number };
  85826. }
  85827. /**
  85828. * Interfaces from the KHR_draco_mesh_compression extension
  85829. */
  85830. /** @hidden */
  85831. interface IKHRDracoMeshCompression {
  85832. bufferView: number;
  85833. attributes: { [name: string]: number };
  85834. }
  85835. /**
  85836. * Interfaces from the KHR_lights_punctual extension
  85837. */
  85838. /** @hidden */
  85839. const enum IKHRLightsPunctual_LightType {
  85840. DIRECTIONAL = "directional",
  85841. POINT = "point",
  85842. SPOT = "spot"
  85843. }
  85844. /** @hidden */
  85845. interface IKHRLightsPunctual_LightReference {
  85846. light: number;
  85847. }
  85848. /** @hidden */
  85849. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85850. type: IKHRLightsPunctual_LightType;
  85851. color?: number[];
  85852. intensity?: number;
  85853. range?: number;
  85854. spot?: {
  85855. innerConeAngle?: number;
  85856. outerConeAngle?: number;
  85857. };
  85858. }
  85859. /** @hidden */
  85860. interface IKHRLightsPunctual {
  85861. lights: IKHRLightsPunctual_Light[];
  85862. }
  85863. /**
  85864. * Interfaces from the KHR_materials_clearcoat extension
  85865. * !!! Experimental Extension Subject to Changes !!!
  85866. */
  85867. /** @hidden */
  85868. interface IKHRMaterialsClearcoat {
  85869. clearcoatFactor: number;
  85870. clearcoatTexture: ITextureInfo;
  85871. clearcoatRoughnessFactor: number;
  85872. clearcoatRoughnessTexture: ITextureInfo;
  85873. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  85874. }
  85875. /**
  85876. * Interfaces from the KHR_materials_ior extension
  85877. * !!! Experimental Extension Subject to Changes !!!
  85878. */
  85879. /** @hidden */
  85880. interface IKHRMaterialsIor {
  85881. ior: number;
  85882. }
  85883. /**
  85884. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  85885. */
  85886. /** @hidden */
  85887. interface IKHRMaterialsPbrSpecularGlossiness {
  85888. diffuseFactor: number[];
  85889. diffuseTexture: ITextureInfo;
  85890. specularFactor: number[];
  85891. glossinessFactor: number;
  85892. specularGlossinessTexture: ITextureInfo;
  85893. }
  85894. /**
  85895. * Interfaces from the KHR_materials_sheen extension
  85896. * !!! Experimental Extension Subject to Changes !!!
  85897. */
  85898. /** @hidden */
  85899. interface IKHRMaterialsSheen {
  85900. sheenColorFactor?: number[];
  85901. sheenTexture?: ITextureInfo;
  85902. sheenRoughnessFactor?: number;
  85903. }
  85904. /**
  85905. * Interfaces from the KHR_materials_specular extension
  85906. * !!! Experimental Extension Subject to Changes !!!
  85907. */
  85908. /** @hidden */
  85909. interface IKHRMaterialsSpecular {
  85910. specularFactor: number;
  85911. specularColorFactor: number[];
  85912. specularTexture: ITextureInfo;
  85913. }
  85914. /**
  85915. * Interfaces from the KHR_materials_transmission extension
  85916. * !!! Experimental Extension Subject to Changes !!!
  85917. */
  85918. /** @hidden */
  85919. interface IKHRMaterialsTransmission {
  85920. transmissionFactor?: number;
  85921. transmissionTexture?: ITextureInfo;
  85922. }
  85923. /**
  85924. * Interfaces from the KHR_materials_variants extension
  85925. * !!! Experimental Extension Subject to Changes !!!
  85926. */
  85927. /** @hidden */
  85928. interface IKHRMaterialVariants_Mapping extends IProperty {
  85929. mappings: Array<{
  85930. variants: number[];
  85931. material: number;
  85932. }>;
  85933. }
  85934. /** @hidden */
  85935. interface IKHRMaterialVariants_Variant extends IProperty {
  85936. name: string;
  85937. }
  85938. /** @hidden */
  85939. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  85940. variants: Array<IKHRMaterialVariants_Variant>;
  85941. }
  85942. /**
  85943. * Interfaces from the KHR_texture_basisu extension
  85944. * !!! Experimental Extension Subject to Changes !!!
  85945. */
  85946. /** @hidden */
  85947. interface IKHRTextureBasisU {
  85948. source: number;
  85949. }
  85950. /**
  85951. * Interfaces from the EXT_texture_webp extension
  85952. */
  85953. /** @hidden */
  85954. interface IEXTTextureWebP {
  85955. source: number;
  85956. }
  85957. /**
  85958. * Interfaces from the KHR_texture_transform extension
  85959. */
  85960. /** @hidden */
  85961. interface IKHRTextureTransform {
  85962. offset?: number[];
  85963. rotation?: number;
  85964. scale?: number[];
  85965. texCoord?: number;
  85966. }
  85967. /**
  85968. * Interfaces from the KHR_xmp extension
  85969. * !!! Experimental Extension Subject to Changes !!!
  85970. */
  85971. /** @hidden */
  85972. interface IKHRXmp_Data {
  85973. [key: string]: unknown;
  85974. }
  85975. /** @hidden */
  85976. interface IKHRXmp_Gltf {
  85977. packets: IKHRXmp_Data[];
  85978. }
  85979. /** @hidden */
  85980. interface IKHRXmp_Node {
  85981. packet: number;
  85982. }
  85983. /**
  85984. * Interfaces from the MSFT_audio_emitter extension
  85985. */
  85986. /** @hidden */
  85987. interface IMSFTAudioEmitter_ClipReference {
  85988. clip: number;
  85989. weight?: number;
  85990. }
  85991. /** @hidden */
  85992. interface IMSFTAudioEmitter_EmittersReference {
  85993. emitters: number[];
  85994. }
  85995. /** @hidden */
  85996. const enum IMSFTAudioEmitter_DistanceModel {
  85997. linear = "linear",
  85998. inverse = "inverse",
  85999. exponential = "exponential",
  86000. }
  86001. /** @hidden */
  86002. interface IMSFTAudioEmitter_Emitter {
  86003. name?: string;
  86004. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86005. refDistance?: number;
  86006. maxDistance?: number;
  86007. rolloffFactor?: number;
  86008. innerAngle?: number;
  86009. outerAngle?: number;
  86010. loop?: boolean;
  86011. volume?: number;
  86012. clips: IMSFTAudioEmitter_ClipReference[];
  86013. }
  86014. /** @hidden */
  86015. const enum IMSFTAudioEmitter_AudioMimeType {
  86016. WAV = "audio/wav",
  86017. }
  86018. /** @hidden */
  86019. interface IMSFTAudioEmitter_Clip extends IProperty {
  86020. uri?: string;
  86021. bufferView?: number;
  86022. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86023. }
  86024. /** @hidden */
  86025. const enum IMSFTAudioEmitter_AnimationEventAction {
  86026. play = "play",
  86027. pause = "pause",
  86028. stop = "stop",
  86029. }
  86030. /** @hidden */
  86031. interface IMSFTAudioEmitter_AnimationEvent {
  86032. action: IMSFTAudioEmitter_AnimationEventAction;
  86033. emitter: number;
  86034. time: number;
  86035. startOffset?: number;
  86036. }
  86037. /**
  86038. * Interfaces from the MSFT_lod extension
  86039. */
  86040. /** @hidden */
  86041. interface IMSFTLOD {
  86042. ids: number[];
  86043. }
  86044. }
  86045. declare module BABYLON {
  86046. /** @hidden */
  86047. export var cellPixelShader: {
  86048. name: string;
  86049. shader: string;
  86050. };
  86051. }
  86052. declare module BABYLON {
  86053. /** @hidden */
  86054. export var cellVertexShader: {
  86055. name: string;
  86056. shader: string;
  86057. };
  86058. }
  86059. declare module BABYLON {
  86060. export class CellMaterial extends BABYLON.PushMaterial {
  86061. private _diffuseTexture;
  86062. diffuseTexture: BABYLON.BaseTexture;
  86063. diffuseColor: BABYLON.Color3;
  86064. _computeHighLevel: boolean;
  86065. computeHighLevel: boolean;
  86066. private _disableLighting;
  86067. disableLighting: boolean;
  86068. private _maxSimultaneousLights;
  86069. maxSimultaneousLights: number;
  86070. constructor(name: string, scene: BABYLON.Scene);
  86071. needAlphaBlending(): boolean;
  86072. needAlphaTesting(): boolean;
  86073. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86074. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86075. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86076. getAnimatables(): BABYLON.IAnimatable[];
  86077. getActiveTextures(): BABYLON.BaseTexture[];
  86078. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86079. dispose(forceDisposeEffect?: boolean): void;
  86080. getClassName(): string;
  86081. clone(name: string): CellMaterial;
  86082. serialize(): any;
  86083. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86084. }
  86085. }
  86086. declare module BABYLON {
  86087. export class CustomShaderStructure {
  86088. FragmentStore: string;
  86089. VertexStore: string;
  86090. constructor();
  86091. }
  86092. export class ShaderSpecialParts {
  86093. constructor();
  86094. Fragment_Begin: string;
  86095. Fragment_Definitions: string;
  86096. Fragment_MainBegin: string;
  86097. Fragment_Custom_Diffuse: string;
  86098. Fragment_Before_Lights: string;
  86099. Fragment_Before_Fog: string;
  86100. Fragment_Custom_Alpha: string;
  86101. Fragment_Before_FragColor: string;
  86102. Vertex_Begin: string;
  86103. Vertex_Definitions: string;
  86104. Vertex_MainBegin: string;
  86105. Vertex_Before_PositionUpdated: string;
  86106. Vertex_Before_NormalUpdated: string;
  86107. Vertex_After_WorldPosComputed: string;
  86108. Vertex_MainEnd: string;
  86109. }
  86110. export class CustomMaterial extends BABYLON.StandardMaterial {
  86111. static ShaderIndexer: number;
  86112. CustomParts: ShaderSpecialParts;
  86113. _isCreatedShader: boolean;
  86114. _createdShaderName: string;
  86115. _customUniform: string[];
  86116. _newUniforms: string[];
  86117. _newUniformInstances: {
  86118. [name: string]: any;
  86119. };
  86120. _newSamplerInstances: {
  86121. [name: string]: BABYLON.Texture;
  86122. };
  86123. _customAttributes: string[];
  86124. FragmentShader: string;
  86125. VertexShader: string;
  86126. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86127. ReviewUniform(name: string, arr: string[]): string[];
  86128. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86129. constructor(name: string, scene: BABYLON.Scene);
  86130. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86131. AddAttribute(name: string): CustomMaterial;
  86132. Fragment_Begin(shaderPart: string): CustomMaterial;
  86133. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86134. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86135. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86136. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86137. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86138. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86139. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86140. Vertex_Begin(shaderPart: string): CustomMaterial;
  86141. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86142. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86143. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86144. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86145. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86146. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86147. }
  86148. }
  86149. declare module BABYLON {
  86150. export class ShaderAlebdoParts {
  86151. constructor();
  86152. Fragment_Begin: string;
  86153. Fragment_Definitions: string;
  86154. Fragment_MainBegin: string;
  86155. Fragment_Custom_Albedo: string;
  86156. Fragment_Before_Lights: string;
  86157. Fragment_Custom_MetallicRoughness: string;
  86158. Fragment_Custom_MicroSurface: string;
  86159. Fragment_Before_Fog: string;
  86160. Fragment_Custom_Alpha: string;
  86161. Fragment_Before_FragColor: string;
  86162. Vertex_Begin: string;
  86163. Vertex_Definitions: string;
  86164. Vertex_MainBegin: string;
  86165. Vertex_Before_PositionUpdated: string;
  86166. Vertex_Before_NormalUpdated: string;
  86167. Vertex_After_WorldPosComputed: string;
  86168. Vertex_MainEnd: string;
  86169. }
  86170. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86171. static ShaderIndexer: number;
  86172. CustomParts: ShaderAlebdoParts;
  86173. _isCreatedShader: boolean;
  86174. _createdShaderName: string;
  86175. _customUniform: string[];
  86176. _newUniforms: string[];
  86177. _newUniformInstances: {
  86178. [name: string]: any;
  86179. };
  86180. _newSamplerInstances: {
  86181. [name: string]: BABYLON.Texture;
  86182. };
  86183. _customAttributes: string[];
  86184. FragmentShader: string;
  86185. VertexShader: string;
  86186. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86187. ReviewUniform(name: string, arr: string[]): string[];
  86188. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86189. constructor(name: string, scene: BABYLON.Scene);
  86190. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86191. AddAttribute(name: string): PBRCustomMaterial;
  86192. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86193. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86194. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86195. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86196. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86197. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86198. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86199. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86200. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86201. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86202. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86203. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86204. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86205. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86206. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86207. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86208. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86209. }
  86210. }
  86211. declare module BABYLON {
  86212. /** @hidden */
  86213. export var firePixelShader: {
  86214. name: string;
  86215. shader: string;
  86216. };
  86217. }
  86218. declare module BABYLON {
  86219. /** @hidden */
  86220. export var fireVertexShader: {
  86221. name: string;
  86222. shader: string;
  86223. };
  86224. }
  86225. declare module BABYLON {
  86226. export class FireMaterial extends BABYLON.PushMaterial {
  86227. private _diffuseTexture;
  86228. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86229. private _distortionTexture;
  86230. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86231. private _opacityTexture;
  86232. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86233. diffuseColor: BABYLON.Color3;
  86234. speed: number;
  86235. private _scaledDiffuse;
  86236. private _lastTime;
  86237. constructor(name: string, scene: BABYLON.Scene);
  86238. needAlphaBlending(): boolean;
  86239. needAlphaTesting(): boolean;
  86240. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86241. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86242. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86243. getAnimatables(): BABYLON.IAnimatable[];
  86244. getActiveTextures(): BABYLON.BaseTexture[];
  86245. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86246. getClassName(): string;
  86247. dispose(forceDisposeEffect?: boolean): void;
  86248. clone(name: string): FireMaterial;
  86249. serialize(): any;
  86250. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86251. }
  86252. }
  86253. declare module BABYLON {
  86254. /** @hidden */
  86255. export var furPixelShader: {
  86256. name: string;
  86257. shader: string;
  86258. };
  86259. }
  86260. declare module BABYLON {
  86261. /** @hidden */
  86262. export var furVertexShader: {
  86263. name: string;
  86264. shader: string;
  86265. };
  86266. }
  86267. declare module BABYLON {
  86268. export class FurMaterial extends BABYLON.PushMaterial {
  86269. private _diffuseTexture;
  86270. diffuseTexture: BABYLON.BaseTexture;
  86271. private _heightTexture;
  86272. heightTexture: BABYLON.BaseTexture;
  86273. diffuseColor: BABYLON.Color3;
  86274. furLength: number;
  86275. furAngle: number;
  86276. furColor: BABYLON.Color3;
  86277. furOffset: number;
  86278. furSpacing: number;
  86279. furGravity: BABYLON.Vector3;
  86280. furSpeed: number;
  86281. furDensity: number;
  86282. furOcclusion: number;
  86283. furTexture: BABYLON.DynamicTexture;
  86284. private _disableLighting;
  86285. disableLighting: boolean;
  86286. private _maxSimultaneousLights;
  86287. maxSimultaneousLights: number;
  86288. highLevelFur: boolean;
  86289. _meshes: BABYLON.AbstractMesh[];
  86290. private _furTime;
  86291. constructor(name: string, scene: BABYLON.Scene);
  86292. get furTime(): number;
  86293. set furTime(furTime: number);
  86294. needAlphaBlending(): boolean;
  86295. needAlphaTesting(): boolean;
  86296. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86297. updateFur(): void;
  86298. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86299. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86300. getAnimatables(): BABYLON.IAnimatable[];
  86301. getActiveTextures(): BABYLON.BaseTexture[];
  86302. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86303. dispose(forceDisposeEffect?: boolean): void;
  86304. clone(name: string): FurMaterial;
  86305. serialize(): any;
  86306. getClassName(): string;
  86307. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86308. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86309. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86310. }
  86311. }
  86312. declare module BABYLON {
  86313. /** @hidden */
  86314. export var gradientPixelShader: {
  86315. name: string;
  86316. shader: string;
  86317. };
  86318. }
  86319. declare module BABYLON {
  86320. /** @hidden */
  86321. export var gradientVertexShader: {
  86322. name: string;
  86323. shader: string;
  86324. };
  86325. }
  86326. declare module BABYLON {
  86327. export class GradientMaterial extends BABYLON.PushMaterial {
  86328. private _maxSimultaneousLights;
  86329. maxSimultaneousLights: number;
  86330. topColor: BABYLON.Color3;
  86331. topColorAlpha: number;
  86332. bottomColor: BABYLON.Color3;
  86333. bottomColorAlpha: number;
  86334. offset: number;
  86335. scale: number;
  86336. smoothness: number;
  86337. private _disableLighting;
  86338. disableLighting: boolean;
  86339. constructor(name: string, scene: BABYLON.Scene);
  86340. needAlphaBlending(): boolean;
  86341. needAlphaTesting(): boolean;
  86342. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86343. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86344. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86345. getAnimatables(): BABYLON.IAnimatable[];
  86346. dispose(forceDisposeEffect?: boolean): void;
  86347. clone(name: string): GradientMaterial;
  86348. serialize(): any;
  86349. getClassName(): string;
  86350. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86351. }
  86352. }
  86353. declare module BABYLON {
  86354. /** @hidden */
  86355. export var gridPixelShader: {
  86356. name: string;
  86357. shader: string;
  86358. };
  86359. }
  86360. declare module BABYLON {
  86361. /** @hidden */
  86362. export var gridVertexShader: {
  86363. name: string;
  86364. shader: string;
  86365. };
  86366. }
  86367. declare module BABYLON {
  86368. /**
  86369. * The grid materials allows you to wrap any shape with a grid.
  86370. * Colors are customizable.
  86371. */
  86372. export class GridMaterial extends BABYLON.PushMaterial {
  86373. /**
  86374. * Main color of the grid (e.g. between lines)
  86375. */
  86376. mainColor: BABYLON.Color3;
  86377. /**
  86378. * Color of the grid lines.
  86379. */
  86380. lineColor: BABYLON.Color3;
  86381. /**
  86382. * The scale of the grid compared to unit.
  86383. */
  86384. gridRatio: number;
  86385. /**
  86386. * Allows setting an offset for the grid lines.
  86387. */
  86388. gridOffset: BABYLON.Vector3;
  86389. /**
  86390. * The frequency of thicker lines.
  86391. */
  86392. majorUnitFrequency: number;
  86393. /**
  86394. * The visibility of minor units in the grid.
  86395. */
  86396. minorUnitVisibility: number;
  86397. /**
  86398. * The grid opacity outside of the lines.
  86399. */
  86400. opacity: number;
  86401. /**
  86402. * Determine RBG output is premultiplied by alpha value.
  86403. */
  86404. preMultiplyAlpha: boolean;
  86405. private _opacityTexture;
  86406. opacityTexture: BABYLON.BaseTexture;
  86407. private _gridControl;
  86408. /**
  86409. * constructor
  86410. * @param name The name given to the material in order to identify it afterwards.
  86411. * @param scene The scene the material is used in.
  86412. */
  86413. constructor(name: string, scene: BABYLON.Scene);
  86414. /**
  86415. * Returns wehter or not the grid requires alpha blending.
  86416. */
  86417. needAlphaBlending(): boolean;
  86418. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86419. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86420. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86421. /**
  86422. * Dispose the material and its associated resources.
  86423. * @param forceDisposeEffect will also dispose the used effect when true
  86424. */
  86425. dispose(forceDisposeEffect?: boolean): void;
  86426. clone(name: string): GridMaterial;
  86427. serialize(): any;
  86428. getClassName(): string;
  86429. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86430. }
  86431. }
  86432. declare module BABYLON {
  86433. /** @hidden */
  86434. export var lavaPixelShader: {
  86435. name: string;
  86436. shader: string;
  86437. };
  86438. }
  86439. declare module BABYLON {
  86440. /** @hidden */
  86441. export var lavaVertexShader: {
  86442. name: string;
  86443. shader: string;
  86444. };
  86445. }
  86446. declare module BABYLON {
  86447. export class LavaMaterial extends BABYLON.PushMaterial {
  86448. private _diffuseTexture;
  86449. diffuseTexture: BABYLON.BaseTexture;
  86450. noiseTexture: BABYLON.BaseTexture;
  86451. fogColor: BABYLON.Color3;
  86452. speed: number;
  86453. movingSpeed: number;
  86454. lowFrequencySpeed: number;
  86455. fogDensity: number;
  86456. private _lastTime;
  86457. diffuseColor: BABYLON.Color3;
  86458. private _disableLighting;
  86459. disableLighting: boolean;
  86460. private _unlit;
  86461. unlit: boolean;
  86462. private _maxSimultaneousLights;
  86463. maxSimultaneousLights: number;
  86464. private _scaledDiffuse;
  86465. constructor(name: string, scene: BABYLON.Scene);
  86466. needAlphaBlending(): boolean;
  86467. needAlphaTesting(): boolean;
  86468. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86469. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86470. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86471. getAnimatables(): BABYLON.IAnimatable[];
  86472. getActiveTextures(): BABYLON.BaseTexture[];
  86473. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86474. dispose(forceDisposeEffect?: boolean): void;
  86475. clone(name: string): LavaMaterial;
  86476. serialize(): any;
  86477. getClassName(): string;
  86478. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86479. }
  86480. }
  86481. declare module BABYLON {
  86482. /** @hidden */
  86483. export var mixPixelShader: {
  86484. name: string;
  86485. shader: string;
  86486. };
  86487. }
  86488. declare module BABYLON {
  86489. /** @hidden */
  86490. export var mixVertexShader: {
  86491. name: string;
  86492. shader: string;
  86493. };
  86494. }
  86495. declare module BABYLON {
  86496. export class MixMaterial extends BABYLON.PushMaterial {
  86497. /**
  86498. * Mix textures
  86499. */
  86500. private _mixTexture1;
  86501. mixTexture1: BABYLON.BaseTexture;
  86502. private _mixTexture2;
  86503. mixTexture2: BABYLON.BaseTexture;
  86504. /**
  86505. * Diffuse textures
  86506. */
  86507. private _diffuseTexture1;
  86508. diffuseTexture1: BABYLON.Texture;
  86509. private _diffuseTexture2;
  86510. diffuseTexture2: BABYLON.Texture;
  86511. private _diffuseTexture3;
  86512. diffuseTexture3: BABYLON.Texture;
  86513. private _diffuseTexture4;
  86514. diffuseTexture4: BABYLON.Texture;
  86515. private _diffuseTexture5;
  86516. diffuseTexture5: BABYLON.Texture;
  86517. private _diffuseTexture6;
  86518. diffuseTexture6: BABYLON.Texture;
  86519. private _diffuseTexture7;
  86520. diffuseTexture7: BABYLON.Texture;
  86521. private _diffuseTexture8;
  86522. diffuseTexture8: BABYLON.Texture;
  86523. /**
  86524. * Uniforms
  86525. */
  86526. diffuseColor: BABYLON.Color3;
  86527. specularColor: BABYLON.Color3;
  86528. specularPower: number;
  86529. private _disableLighting;
  86530. disableLighting: boolean;
  86531. private _maxSimultaneousLights;
  86532. maxSimultaneousLights: number;
  86533. constructor(name: string, scene: BABYLON.Scene);
  86534. needAlphaBlending(): boolean;
  86535. needAlphaTesting(): boolean;
  86536. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86537. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86538. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86539. getAnimatables(): BABYLON.IAnimatable[];
  86540. getActiveTextures(): BABYLON.BaseTexture[];
  86541. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86542. dispose(forceDisposeEffect?: boolean): void;
  86543. clone(name: string): MixMaterial;
  86544. serialize(): any;
  86545. getClassName(): string;
  86546. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86547. }
  86548. }
  86549. declare module BABYLON {
  86550. /** @hidden */
  86551. export var normalPixelShader: {
  86552. name: string;
  86553. shader: string;
  86554. };
  86555. }
  86556. declare module BABYLON {
  86557. /** @hidden */
  86558. export var normalVertexShader: {
  86559. name: string;
  86560. shader: string;
  86561. };
  86562. }
  86563. declare module BABYLON {
  86564. export class NormalMaterial extends BABYLON.PushMaterial {
  86565. private _diffuseTexture;
  86566. diffuseTexture: BABYLON.BaseTexture;
  86567. diffuseColor: BABYLON.Color3;
  86568. private _disableLighting;
  86569. disableLighting: boolean;
  86570. private _maxSimultaneousLights;
  86571. maxSimultaneousLights: number;
  86572. constructor(name: string, scene: BABYLON.Scene);
  86573. needAlphaBlending(): boolean;
  86574. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86575. needAlphaTesting(): boolean;
  86576. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86577. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86578. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86579. getAnimatables(): BABYLON.IAnimatable[];
  86580. getActiveTextures(): BABYLON.BaseTexture[];
  86581. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86582. dispose(forceDisposeEffect?: boolean): void;
  86583. clone(name: string): NormalMaterial;
  86584. serialize(): any;
  86585. getClassName(): string;
  86586. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86587. }
  86588. }
  86589. declare module BABYLON {
  86590. /** @hidden */
  86591. export var shadowOnlyPixelShader: {
  86592. name: string;
  86593. shader: string;
  86594. };
  86595. }
  86596. declare module BABYLON {
  86597. /** @hidden */
  86598. export var shadowOnlyVertexShader: {
  86599. name: string;
  86600. shader: string;
  86601. };
  86602. }
  86603. declare module BABYLON {
  86604. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86605. private _activeLight;
  86606. private _needAlphaBlending;
  86607. constructor(name: string, scene: BABYLON.Scene);
  86608. shadowColor: BABYLON.Color3;
  86609. needAlphaBlending(): boolean;
  86610. needAlphaTesting(): boolean;
  86611. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86612. get activeLight(): BABYLON.IShadowLight;
  86613. set activeLight(light: BABYLON.IShadowLight);
  86614. private _getFirstShadowLightForMesh;
  86615. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86616. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86617. clone(name: string): ShadowOnlyMaterial;
  86618. serialize(): any;
  86619. getClassName(): string;
  86620. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86621. }
  86622. }
  86623. declare module BABYLON {
  86624. /** @hidden */
  86625. export var simplePixelShader: {
  86626. name: string;
  86627. shader: string;
  86628. };
  86629. }
  86630. declare module BABYLON {
  86631. /** @hidden */
  86632. export var simpleVertexShader: {
  86633. name: string;
  86634. shader: string;
  86635. };
  86636. }
  86637. declare module BABYLON {
  86638. export class SimpleMaterial extends BABYLON.PushMaterial {
  86639. private _diffuseTexture;
  86640. diffuseTexture: BABYLON.BaseTexture;
  86641. diffuseColor: BABYLON.Color3;
  86642. private _disableLighting;
  86643. disableLighting: boolean;
  86644. private _maxSimultaneousLights;
  86645. maxSimultaneousLights: number;
  86646. constructor(name: string, scene: BABYLON.Scene);
  86647. needAlphaBlending(): boolean;
  86648. needAlphaTesting(): boolean;
  86649. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86650. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86651. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86652. getAnimatables(): BABYLON.IAnimatable[];
  86653. getActiveTextures(): BABYLON.BaseTexture[];
  86654. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86655. dispose(forceDisposeEffect?: boolean): void;
  86656. clone(name: string): SimpleMaterial;
  86657. serialize(): any;
  86658. getClassName(): string;
  86659. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86660. }
  86661. }
  86662. declare module BABYLON {
  86663. /** @hidden */
  86664. export var skyPixelShader: {
  86665. name: string;
  86666. shader: string;
  86667. };
  86668. }
  86669. declare module BABYLON {
  86670. /** @hidden */
  86671. export var skyVertexShader: {
  86672. name: string;
  86673. shader: string;
  86674. };
  86675. }
  86676. declare module BABYLON {
  86677. /**
  86678. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86679. * @see https://doc.babylonjs.com/extensions/sky
  86680. */
  86681. export class SkyMaterial extends BABYLON.PushMaterial {
  86682. /**
  86683. * Defines the overall luminance of sky in interval ]0, 1[.
  86684. */
  86685. luminance: number;
  86686. /**
  86687. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86688. */
  86689. turbidity: number;
  86690. /**
  86691. * Defines the sky appearance (light intensity).
  86692. */
  86693. rayleigh: number;
  86694. /**
  86695. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86696. */
  86697. mieCoefficient: number;
  86698. /**
  86699. * Defines the amount of haze particles following the Mie scattering theory.
  86700. */
  86701. mieDirectionalG: number;
  86702. /**
  86703. * Defines the distance of the sun according to the active scene camera.
  86704. */
  86705. distance: number;
  86706. /**
  86707. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86708. * "inclined".
  86709. */
  86710. inclination: number;
  86711. /**
  86712. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86713. * an object direction and a reference direction.
  86714. */
  86715. azimuth: number;
  86716. /**
  86717. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86718. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86719. */
  86720. sunPosition: BABYLON.Vector3;
  86721. /**
  86722. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86723. * .sunPosition property.
  86724. */
  86725. useSunPosition: boolean;
  86726. /**
  86727. * Defines an offset vector used to get a horizon offset.
  86728. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86729. */
  86730. cameraOffset: BABYLON.Vector3;
  86731. private _cameraPosition;
  86732. /**
  86733. * Instantiates a new sky material.
  86734. * This material allows to create dynamic and texture free
  86735. * effects for skyboxes by taking care of the atmosphere state.
  86736. * @see https://doc.babylonjs.com/extensions/sky
  86737. * @param name Define the name of the material in the scene
  86738. * @param scene Define the scene the material belong to
  86739. */
  86740. constructor(name: string, scene: BABYLON.Scene);
  86741. /**
  86742. * Specifies if the material will require alpha blending
  86743. * @returns a boolean specifying if alpha blending is needed
  86744. */
  86745. needAlphaBlending(): boolean;
  86746. /**
  86747. * Specifies if this material should be rendered in alpha test mode
  86748. * @returns false as the sky material doesn't need alpha testing.
  86749. */
  86750. needAlphaTesting(): boolean;
  86751. /**
  86752. * Get the texture used for alpha test purpose.
  86753. * @returns null as the sky material has no texture.
  86754. */
  86755. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86756. /**
  86757. * Get if the submesh is ready to be used and all its information available.
  86758. * Child classes can use it to update shaders
  86759. * @param mesh defines the mesh to check
  86760. * @param subMesh defines which submesh to check
  86761. * @param useInstances specifies that instances should be used
  86762. * @returns a boolean indicating that the submesh is ready or not
  86763. */
  86764. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86765. /**
  86766. * Binds the submesh to this material by preparing the effect and shader to draw
  86767. * @param world defines the world transformation matrix
  86768. * @param mesh defines the mesh containing the submesh
  86769. * @param subMesh defines the submesh to bind the material to
  86770. */
  86771. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86772. /**
  86773. * Get the list of animatables in the material.
  86774. * @returns the list of animatables object used in the material
  86775. */
  86776. getAnimatables(): BABYLON.IAnimatable[];
  86777. /**
  86778. * Disposes the material
  86779. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86780. */
  86781. dispose(forceDisposeEffect?: boolean): void;
  86782. /**
  86783. * Makes a duplicate of the material, and gives it a new name
  86784. * @param name defines the new name for the duplicated material
  86785. * @returns the cloned material
  86786. */
  86787. clone(name: string): SkyMaterial;
  86788. /**
  86789. * Serializes this material in a JSON representation
  86790. * @returns the serialized material object
  86791. */
  86792. serialize(): any;
  86793. /**
  86794. * Gets the current class name of the material e.g. "SkyMaterial"
  86795. * Mainly use in serialization.
  86796. * @returns the class name
  86797. */
  86798. getClassName(): string;
  86799. /**
  86800. * Creates a sky material from parsed material data
  86801. * @param source defines the JSON representation of the material
  86802. * @param scene defines the hosting scene
  86803. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86804. * @returns a new sky material
  86805. */
  86806. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86807. }
  86808. }
  86809. declare module BABYLON {
  86810. /** @hidden */
  86811. export var terrainPixelShader: {
  86812. name: string;
  86813. shader: string;
  86814. };
  86815. }
  86816. declare module BABYLON {
  86817. /** @hidden */
  86818. export var terrainVertexShader: {
  86819. name: string;
  86820. shader: string;
  86821. };
  86822. }
  86823. declare module BABYLON {
  86824. export class TerrainMaterial extends BABYLON.PushMaterial {
  86825. private _mixTexture;
  86826. mixTexture: BABYLON.BaseTexture;
  86827. private _diffuseTexture1;
  86828. diffuseTexture1: BABYLON.Texture;
  86829. private _diffuseTexture2;
  86830. diffuseTexture2: BABYLON.Texture;
  86831. private _diffuseTexture3;
  86832. diffuseTexture3: BABYLON.Texture;
  86833. private _bumpTexture1;
  86834. bumpTexture1: BABYLON.Texture;
  86835. private _bumpTexture2;
  86836. bumpTexture2: BABYLON.Texture;
  86837. private _bumpTexture3;
  86838. bumpTexture3: BABYLON.Texture;
  86839. diffuseColor: BABYLON.Color3;
  86840. specularColor: BABYLON.Color3;
  86841. specularPower: number;
  86842. private _disableLighting;
  86843. disableLighting: boolean;
  86844. private _maxSimultaneousLights;
  86845. maxSimultaneousLights: number;
  86846. constructor(name: string, scene: BABYLON.Scene);
  86847. needAlphaBlending(): boolean;
  86848. needAlphaTesting(): boolean;
  86849. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86850. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86851. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86852. getAnimatables(): BABYLON.IAnimatable[];
  86853. getActiveTextures(): BABYLON.BaseTexture[];
  86854. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86855. dispose(forceDisposeEffect?: boolean): void;
  86856. clone(name: string): TerrainMaterial;
  86857. serialize(): any;
  86858. getClassName(): string;
  86859. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  86860. }
  86861. }
  86862. declare module BABYLON {
  86863. /** @hidden */
  86864. export var triplanarPixelShader: {
  86865. name: string;
  86866. shader: string;
  86867. };
  86868. }
  86869. declare module BABYLON {
  86870. /** @hidden */
  86871. export var triplanarVertexShader: {
  86872. name: string;
  86873. shader: string;
  86874. };
  86875. }
  86876. declare module BABYLON {
  86877. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  86878. mixTexture: BABYLON.BaseTexture;
  86879. private _diffuseTextureX;
  86880. diffuseTextureX: BABYLON.BaseTexture;
  86881. private _diffuseTextureY;
  86882. diffuseTextureY: BABYLON.BaseTexture;
  86883. private _diffuseTextureZ;
  86884. diffuseTextureZ: BABYLON.BaseTexture;
  86885. private _normalTextureX;
  86886. normalTextureX: BABYLON.BaseTexture;
  86887. private _normalTextureY;
  86888. normalTextureY: BABYLON.BaseTexture;
  86889. private _normalTextureZ;
  86890. normalTextureZ: BABYLON.BaseTexture;
  86891. tileSize: number;
  86892. diffuseColor: BABYLON.Color3;
  86893. specularColor: BABYLON.Color3;
  86894. specularPower: number;
  86895. private _disableLighting;
  86896. disableLighting: boolean;
  86897. private _maxSimultaneousLights;
  86898. maxSimultaneousLights: number;
  86899. constructor(name: string, scene: BABYLON.Scene);
  86900. needAlphaBlending(): boolean;
  86901. needAlphaTesting(): boolean;
  86902. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86903. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86904. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86905. getAnimatables(): BABYLON.IAnimatable[];
  86906. getActiveTextures(): BABYLON.BaseTexture[];
  86907. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86908. dispose(forceDisposeEffect?: boolean): void;
  86909. clone(name: string): TriPlanarMaterial;
  86910. serialize(): any;
  86911. getClassName(): string;
  86912. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  86913. }
  86914. }
  86915. declare module BABYLON {
  86916. /** @hidden */
  86917. export var waterPixelShader: {
  86918. name: string;
  86919. shader: string;
  86920. };
  86921. }
  86922. declare module BABYLON {
  86923. /** @hidden */
  86924. export var waterVertexShader: {
  86925. name: string;
  86926. shader: string;
  86927. };
  86928. }
  86929. declare module BABYLON {
  86930. export class WaterMaterial extends BABYLON.PushMaterial {
  86931. renderTargetSize: BABYLON.Vector2;
  86932. private _bumpTexture;
  86933. bumpTexture: BABYLON.BaseTexture;
  86934. diffuseColor: BABYLON.Color3;
  86935. specularColor: BABYLON.Color3;
  86936. specularPower: number;
  86937. private _disableLighting;
  86938. disableLighting: boolean;
  86939. private _maxSimultaneousLights;
  86940. maxSimultaneousLights: number;
  86941. /**
  86942. * @param {number}: Represents the wind force
  86943. */
  86944. windForce: number;
  86945. /**
  86946. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  86947. */
  86948. windDirection: BABYLON.Vector2;
  86949. /**
  86950. * @param {number}: Wave height, represents the height of the waves
  86951. */
  86952. waveHeight: number;
  86953. /**
  86954. * @param {number}: Bump height, represents the bump height related to the bump map
  86955. */
  86956. bumpHeight: number;
  86957. /**
  86958. * @param {boolean}: Add a smaller moving bump to less steady waves.
  86959. */
  86960. private _bumpSuperimpose;
  86961. bumpSuperimpose: boolean;
  86962. /**
  86963. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  86964. */
  86965. private _fresnelSeparate;
  86966. fresnelSeparate: boolean;
  86967. /**
  86968. * @param {boolean}: bump Waves modify the reflection.
  86969. */
  86970. private _bumpAffectsReflection;
  86971. bumpAffectsReflection: boolean;
  86972. /**
  86973. * @param {number}: The water color blended with the refraction (near)
  86974. */
  86975. waterColor: BABYLON.Color3;
  86976. /**
  86977. * @param {number}: The blend factor related to the water color
  86978. */
  86979. colorBlendFactor: number;
  86980. /**
  86981. * @param {number}: The water color blended with the reflection (far)
  86982. */
  86983. waterColor2: BABYLON.Color3;
  86984. /**
  86985. * @param {number}: The blend factor related to the water color (reflection, far)
  86986. */
  86987. colorBlendFactor2: number;
  86988. /**
  86989. * @param {number}: Represents the maximum length of a wave
  86990. */
  86991. waveLength: number;
  86992. /**
  86993. * @param {number}: Defines the waves speed
  86994. */
  86995. waveSpeed: number;
  86996. /**
  86997. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86998. * will avoid calculating useless pixels in the pixel shader of the water material.
  86999. */
  87000. disableClipPlane: boolean;
  87001. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87002. private _mesh;
  87003. private _refractionRTT;
  87004. private _reflectionRTT;
  87005. private _reflectionTransform;
  87006. private _lastTime;
  87007. private _lastDeltaTime;
  87008. private _useLogarithmicDepth;
  87009. private _waitingRenderList;
  87010. private _imageProcessingConfiguration;
  87011. private _imageProcessingObserver;
  87012. /**
  87013. * Gets a boolean indicating that current material needs to register RTT
  87014. */
  87015. get hasRenderTargetTextures(): boolean;
  87016. /**
  87017. * Constructor
  87018. */
  87019. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87020. get useLogarithmicDepth(): boolean;
  87021. set useLogarithmicDepth(value: boolean);
  87022. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87023. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87024. addToRenderList(node: any): void;
  87025. enableRenderTargets(enable: boolean): void;
  87026. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87027. get renderTargetsEnabled(): boolean;
  87028. needAlphaBlending(): boolean;
  87029. needAlphaTesting(): boolean;
  87030. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87031. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87032. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87033. private _createRenderTargets;
  87034. getAnimatables(): BABYLON.IAnimatable[];
  87035. getActiveTextures(): BABYLON.BaseTexture[];
  87036. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87037. dispose(forceDisposeEffect?: boolean): void;
  87038. clone(name: string): WaterMaterial;
  87039. serialize(): any;
  87040. getClassName(): string;
  87041. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87042. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87043. }
  87044. }
  87045. declare module BABYLON {
  87046. /** @hidden */
  87047. export var asciiartPixelShader: {
  87048. name: string;
  87049. shader: string;
  87050. };
  87051. }
  87052. declare module BABYLON {
  87053. /**
  87054. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87055. *
  87056. * It basically takes care rendering the font front the given font size to a texture.
  87057. * This is used later on in the postprocess.
  87058. */
  87059. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87060. private _font;
  87061. private _text;
  87062. private _charSize;
  87063. /**
  87064. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87065. */
  87066. get charSize(): number;
  87067. /**
  87068. * Create a new instance of the Ascii Art FontTexture class
  87069. * @param name the name of the texture
  87070. * @param font the font to use, use the W3C CSS notation
  87071. * @param text the caracter set to use in the rendering.
  87072. * @param scene the scene that owns the texture
  87073. */
  87074. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87075. /**
  87076. * Gets the max char width of a font.
  87077. * @param font the font to use, use the W3C CSS notation
  87078. * @return the max char width
  87079. */
  87080. private getFontWidth;
  87081. /**
  87082. * Gets the max char height of a font.
  87083. * @param font the font to use, use the W3C CSS notation
  87084. * @return the max char height
  87085. */
  87086. private getFontHeight;
  87087. /**
  87088. * Clones the current AsciiArtTexture.
  87089. * @return the clone of the texture.
  87090. */
  87091. clone(): AsciiArtFontTexture;
  87092. /**
  87093. * Parses a json object representing the texture and returns an instance of it.
  87094. * @param source the source JSON representation
  87095. * @param scene the scene to create the texture for
  87096. * @return the parsed texture
  87097. */
  87098. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87099. }
  87100. /**
  87101. * Option available in the Ascii Art Post Process.
  87102. */
  87103. export interface IAsciiArtPostProcessOptions {
  87104. /**
  87105. * The font to use following the w3c font definition.
  87106. */
  87107. font?: string;
  87108. /**
  87109. * The character set to use in the postprocess.
  87110. */
  87111. characterSet?: string;
  87112. /**
  87113. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87114. * This number is defined between 0 and 1;
  87115. */
  87116. mixToTile?: number;
  87117. /**
  87118. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87119. * This number is defined between 0 and 1;
  87120. */
  87121. mixToNormal?: number;
  87122. }
  87123. /**
  87124. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87125. *
  87126. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87127. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87128. */
  87129. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87130. /**
  87131. * The font texture used to render the char in the post process.
  87132. */
  87133. private _asciiArtFontTexture;
  87134. /**
  87135. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87136. * This number is defined between 0 and 1;
  87137. */
  87138. mixToTile: number;
  87139. /**
  87140. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87141. * This number is defined between 0 and 1;
  87142. */
  87143. mixToNormal: number;
  87144. /**
  87145. * Instantiates a new Ascii Art Post Process.
  87146. * @param name the name to give to the postprocess
  87147. * @camera the camera to apply the post process to.
  87148. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87149. */
  87150. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87151. }
  87152. }
  87153. declare module BABYLON {
  87154. /** @hidden */
  87155. export var digitalrainPixelShader: {
  87156. name: string;
  87157. shader: string;
  87158. };
  87159. }
  87160. declare module BABYLON {
  87161. /**
  87162. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87163. *
  87164. * It basically takes care rendering the font front the given font size to a texture.
  87165. * This is used later on in the postprocess.
  87166. */
  87167. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87168. private _font;
  87169. private _text;
  87170. private _charSize;
  87171. /**
  87172. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87173. */
  87174. get charSize(): number;
  87175. /**
  87176. * Create a new instance of the Digital Rain FontTexture class
  87177. * @param name the name of the texture
  87178. * @param font the font to use, use the W3C CSS notation
  87179. * @param text the caracter set to use in the rendering.
  87180. * @param scene the scene that owns the texture
  87181. */
  87182. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87183. /**
  87184. * Gets the max char width of a font.
  87185. * @param font the font to use, use the W3C CSS notation
  87186. * @return the max char width
  87187. */
  87188. private getFontWidth;
  87189. /**
  87190. * Gets the max char height of a font.
  87191. * @param font the font to use, use the W3C CSS notation
  87192. * @return the max char height
  87193. */
  87194. private getFontHeight;
  87195. /**
  87196. * Clones the current DigitalRainFontTexture.
  87197. * @return the clone of the texture.
  87198. */
  87199. clone(): DigitalRainFontTexture;
  87200. /**
  87201. * Parses a json object representing the texture and returns an instance of it.
  87202. * @param source the source JSON representation
  87203. * @param scene the scene to create the texture for
  87204. * @return the parsed texture
  87205. */
  87206. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87207. }
  87208. /**
  87209. * Option available in the Digital Rain Post Process.
  87210. */
  87211. export interface IDigitalRainPostProcessOptions {
  87212. /**
  87213. * The font to use following the w3c font definition.
  87214. */
  87215. font?: string;
  87216. /**
  87217. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87218. * This number is defined between 0 and 1;
  87219. */
  87220. mixToTile?: number;
  87221. /**
  87222. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87223. * This number is defined between 0 and 1;
  87224. */
  87225. mixToNormal?: number;
  87226. }
  87227. /**
  87228. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87229. *
  87230. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87231. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87232. */
  87233. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87234. /**
  87235. * The font texture used to render the char in the post process.
  87236. */
  87237. private _digitalRainFontTexture;
  87238. /**
  87239. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87240. * This number is defined between 0 and 1;
  87241. */
  87242. mixToTile: number;
  87243. /**
  87244. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87245. * This number is defined between 0 and 1;
  87246. */
  87247. mixToNormal: number;
  87248. /**
  87249. * Instantiates a new Digital Rain Post Process.
  87250. * @param name the name to give to the postprocess
  87251. * @camera the camera to apply the post process to.
  87252. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87253. */
  87254. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87255. }
  87256. }
  87257. declare module BABYLON {
  87258. /** @hidden */
  87259. export var brickProceduralTexturePixelShader: {
  87260. name: string;
  87261. shader: string;
  87262. };
  87263. }
  87264. declare module BABYLON {
  87265. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87266. private _numberOfBricksHeight;
  87267. private _numberOfBricksWidth;
  87268. private _jointColor;
  87269. private _brickColor;
  87270. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87271. updateShaderUniforms(): void;
  87272. get numberOfBricksHeight(): number;
  87273. set numberOfBricksHeight(value: number);
  87274. get numberOfBricksWidth(): number;
  87275. set numberOfBricksWidth(value: number);
  87276. get jointColor(): BABYLON.Color3;
  87277. set jointColor(value: BABYLON.Color3);
  87278. get brickColor(): BABYLON.Color3;
  87279. set brickColor(value: BABYLON.Color3);
  87280. /**
  87281. * Serializes this brick procedural texture
  87282. * @returns a serialized brick procedural texture object
  87283. */
  87284. serialize(): any;
  87285. /**
  87286. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87287. * @param parsedTexture defines parsed texture data
  87288. * @param scene defines the current scene
  87289. * @param rootUrl defines the root URL containing brick procedural texture information
  87290. * @returns a parsed Brick Procedural BABYLON.Texture
  87291. */
  87292. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87293. }
  87294. }
  87295. declare module BABYLON {
  87296. /** @hidden */
  87297. export var cloudProceduralTexturePixelShader: {
  87298. name: string;
  87299. shader: string;
  87300. };
  87301. }
  87302. declare module BABYLON {
  87303. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87304. private _skyColor;
  87305. private _cloudColor;
  87306. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87307. updateShaderUniforms(): void;
  87308. get skyColor(): BABYLON.Color4;
  87309. set skyColor(value: BABYLON.Color4);
  87310. get cloudColor(): BABYLON.Color4;
  87311. set cloudColor(value: BABYLON.Color4);
  87312. /**
  87313. * Serializes this cloud procedural texture
  87314. * @returns a serialized cloud procedural texture object
  87315. */
  87316. serialize(): any;
  87317. /**
  87318. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87319. * @param parsedTexture defines parsed texture data
  87320. * @param scene defines the current scene
  87321. * @param rootUrl defines the root URL containing cloud procedural texture information
  87322. * @returns a parsed Cloud Procedural BABYLON.Texture
  87323. */
  87324. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87325. }
  87326. }
  87327. declare module BABYLON {
  87328. /** @hidden */
  87329. export var fireProceduralTexturePixelShader: {
  87330. name: string;
  87331. shader: string;
  87332. };
  87333. }
  87334. declare module BABYLON {
  87335. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87336. private _time;
  87337. private _speed;
  87338. private _autoGenerateTime;
  87339. private _fireColors;
  87340. private _alphaThreshold;
  87341. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87342. updateShaderUniforms(): void;
  87343. render(useCameraPostProcess?: boolean): void;
  87344. static get PurpleFireColors(): BABYLON.Color3[];
  87345. static get GreenFireColors(): BABYLON.Color3[];
  87346. static get RedFireColors(): BABYLON.Color3[];
  87347. static get BlueFireColors(): BABYLON.Color3[];
  87348. get autoGenerateTime(): boolean;
  87349. set autoGenerateTime(value: boolean);
  87350. get fireColors(): BABYLON.Color3[];
  87351. set fireColors(value: BABYLON.Color3[]);
  87352. get time(): number;
  87353. set time(value: number);
  87354. get speed(): BABYLON.Vector2;
  87355. set speed(value: BABYLON.Vector2);
  87356. get alphaThreshold(): number;
  87357. set alphaThreshold(value: number);
  87358. /**
  87359. * Serializes this fire procedural texture
  87360. * @returns a serialized fire procedural texture object
  87361. */
  87362. serialize(): any;
  87363. /**
  87364. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87365. * @param parsedTexture defines parsed texture data
  87366. * @param scene defines the current scene
  87367. * @param rootUrl defines the root URL containing fire procedural texture information
  87368. * @returns a parsed Fire Procedural BABYLON.Texture
  87369. */
  87370. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87371. }
  87372. }
  87373. declare module BABYLON {
  87374. /** @hidden */
  87375. export var grassProceduralTexturePixelShader: {
  87376. name: string;
  87377. shader: string;
  87378. };
  87379. }
  87380. declare module BABYLON {
  87381. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87382. private _grassColors;
  87383. private _groundColor;
  87384. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87385. updateShaderUniforms(): void;
  87386. get grassColors(): BABYLON.Color3[];
  87387. set grassColors(value: BABYLON.Color3[]);
  87388. get groundColor(): BABYLON.Color3;
  87389. set groundColor(value: BABYLON.Color3);
  87390. /**
  87391. * Serializes this grass procedural texture
  87392. * @returns a serialized grass procedural texture object
  87393. */
  87394. serialize(): any;
  87395. /**
  87396. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87397. * @param parsedTexture defines parsed texture data
  87398. * @param scene defines the current scene
  87399. * @param rootUrl defines the root URL containing grass procedural texture information
  87400. * @returns a parsed Grass Procedural BABYLON.Texture
  87401. */
  87402. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87403. }
  87404. }
  87405. declare module BABYLON {
  87406. /** @hidden */
  87407. export var marbleProceduralTexturePixelShader: {
  87408. name: string;
  87409. shader: string;
  87410. };
  87411. }
  87412. declare module BABYLON {
  87413. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87414. private _numberOfTilesHeight;
  87415. private _numberOfTilesWidth;
  87416. private _amplitude;
  87417. private _jointColor;
  87418. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87419. updateShaderUniforms(): void;
  87420. get numberOfTilesHeight(): number;
  87421. set numberOfTilesHeight(value: number);
  87422. get amplitude(): number;
  87423. set amplitude(value: number);
  87424. get numberOfTilesWidth(): number;
  87425. set numberOfTilesWidth(value: number);
  87426. get jointColor(): BABYLON.Color3;
  87427. set jointColor(value: BABYLON.Color3);
  87428. /**
  87429. * Serializes this marble procedural texture
  87430. * @returns a serialized marble procedural texture object
  87431. */
  87432. serialize(): any;
  87433. /**
  87434. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87435. * @param parsedTexture defines parsed texture data
  87436. * @param scene defines the current scene
  87437. * @param rootUrl defines the root URL containing marble procedural texture information
  87438. * @returns a parsed Marble Procedural BABYLON.Texture
  87439. */
  87440. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87441. }
  87442. }
  87443. declare module BABYLON {
  87444. /** @hidden */
  87445. export var normalMapProceduralTexturePixelShader: {
  87446. name: string;
  87447. shader: string;
  87448. };
  87449. }
  87450. declare module BABYLON {
  87451. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87452. private _baseTexture;
  87453. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87454. updateShaderUniforms(): void;
  87455. render(useCameraPostProcess?: boolean): void;
  87456. resize(size: any, generateMipMaps: any): void;
  87457. get baseTexture(): BABYLON.Texture;
  87458. set baseTexture(texture: BABYLON.Texture);
  87459. /**
  87460. * Serializes this normal map procedural texture
  87461. * @returns a serialized normal map procedural texture object
  87462. */
  87463. serialize(): any;
  87464. /**
  87465. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87466. * @param parsedTexture defines parsed texture data
  87467. * @param scene defines the current scene
  87468. * @param rootUrl defines the root URL containing normal map procedural texture information
  87469. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87470. */
  87471. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87472. }
  87473. }
  87474. declare module BABYLON {
  87475. /** @hidden */
  87476. export var perlinNoiseProceduralTexturePixelShader: {
  87477. name: string;
  87478. shader: string;
  87479. };
  87480. }
  87481. declare module BABYLON {
  87482. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87483. time: number;
  87484. timeScale: number;
  87485. translationSpeed: number;
  87486. private _currentTranslation;
  87487. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87488. updateShaderUniforms(): void;
  87489. render(useCameraPostProcess?: boolean): void;
  87490. resize(size: any, generateMipMaps: any): void;
  87491. /**
  87492. * Serializes this perlin noise procedural texture
  87493. * @returns a serialized perlin noise procedural texture object
  87494. */
  87495. serialize(): any;
  87496. /**
  87497. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87498. * @param parsedTexture defines parsed texture data
  87499. * @param scene defines the current scene
  87500. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87501. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87502. */
  87503. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87504. }
  87505. }
  87506. declare module BABYLON {
  87507. /** @hidden */
  87508. export var roadProceduralTexturePixelShader: {
  87509. name: string;
  87510. shader: string;
  87511. };
  87512. }
  87513. declare module BABYLON {
  87514. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87515. private _roadColor;
  87516. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87517. updateShaderUniforms(): void;
  87518. get roadColor(): BABYLON.Color3;
  87519. set roadColor(value: BABYLON.Color3);
  87520. /**
  87521. * Serializes this road procedural texture
  87522. * @returns a serialized road procedural texture object
  87523. */
  87524. serialize(): any;
  87525. /**
  87526. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87527. * @param parsedTexture defines parsed texture data
  87528. * @param scene defines the current scene
  87529. * @param rootUrl defines the root URL containing road procedural texture information
  87530. * @returns a parsed Road Procedural BABYLON.Texture
  87531. */
  87532. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87533. }
  87534. }
  87535. declare module BABYLON {
  87536. /** @hidden */
  87537. export var starfieldProceduralTexturePixelShader: {
  87538. name: string;
  87539. shader: string;
  87540. };
  87541. }
  87542. declare module BABYLON {
  87543. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87544. private _time;
  87545. private _alpha;
  87546. private _beta;
  87547. private _zoom;
  87548. private _formuparam;
  87549. private _stepsize;
  87550. private _tile;
  87551. private _brightness;
  87552. private _darkmatter;
  87553. private _distfading;
  87554. private _saturation;
  87555. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87556. updateShaderUniforms(): void;
  87557. get time(): number;
  87558. set time(value: number);
  87559. get alpha(): number;
  87560. set alpha(value: number);
  87561. get beta(): number;
  87562. set beta(value: number);
  87563. get formuparam(): number;
  87564. set formuparam(value: number);
  87565. get stepsize(): number;
  87566. set stepsize(value: number);
  87567. get zoom(): number;
  87568. set zoom(value: number);
  87569. get tile(): number;
  87570. set tile(value: number);
  87571. get brightness(): number;
  87572. set brightness(value: number);
  87573. get darkmatter(): number;
  87574. set darkmatter(value: number);
  87575. get distfading(): number;
  87576. set distfading(value: number);
  87577. get saturation(): number;
  87578. set saturation(value: number);
  87579. /**
  87580. * Serializes this starfield procedural texture
  87581. * @returns a serialized starfield procedural texture object
  87582. */
  87583. serialize(): any;
  87584. /**
  87585. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87586. * @param parsedTexture defines parsed texture data
  87587. * @param scene defines the current scene
  87588. * @param rootUrl defines the root URL containing startfield procedural texture information
  87589. * @returns a parsed Starfield Procedural BABYLON.Texture
  87590. */
  87591. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87592. }
  87593. }
  87594. declare module BABYLON {
  87595. /** @hidden */
  87596. export var woodProceduralTexturePixelShader: {
  87597. name: string;
  87598. shader: string;
  87599. };
  87600. }
  87601. declare module BABYLON {
  87602. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87603. private _ampScale;
  87604. private _woodColor;
  87605. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87606. updateShaderUniforms(): void;
  87607. get ampScale(): number;
  87608. set ampScale(value: number);
  87609. get woodColor(): BABYLON.Color3;
  87610. set woodColor(value: BABYLON.Color3);
  87611. /**
  87612. * Serializes this wood procedural texture
  87613. * @returns a serialized wood procedural texture object
  87614. */
  87615. serialize(): any;
  87616. /**
  87617. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87618. * @param parsedTexture defines parsed texture data
  87619. * @param scene defines the current scene
  87620. * @param rootUrl defines the root URL containing wood procedural texture information
  87621. * @returns a parsed Wood Procedural BABYLON.Texture
  87622. */
  87623. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87624. }
  87625. }