documentation.d.ts 3.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  695. static readonly GEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. * @param options options to be passed to the loader
  1123. */
  1124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1125. /**
  1126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1127. * @param data contains the texture data
  1128. * @param texture defines the BabylonJS internal texture
  1129. * @param callback defines the method to call once ready to upload
  1130. * @param options options to be passed to the loader
  1131. */
  1132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1133. }
  1134. }
  1135. declare module BABYLON {
  1136. /**
  1137. * Class used to store and describe the pipeline context associated with an effect
  1138. */
  1139. export interface IPipelineContext {
  1140. /**
  1141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1142. */
  1143. isAsync: boolean;
  1144. /**
  1145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1146. */
  1147. isReady: boolean;
  1148. /** @hidden */
  1149. _getVertexShaderCode(): string | null;
  1150. /** @hidden */
  1151. _getFragmentShaderCode(): string | null;
  1152. /** @hidden */
  1153. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1154. }
  1155. }
  1156. declare module BABYLON {
  1157. /**
  1158. * Class used to store gfx data (like WebGLBuffer)
  1159. */
  1160. export class DataBuffer {
  1161. /**
  1162. * Gets or sets the number of objects referencing this buffer
  1163. */
  1164. references: number;
  1165. /** Gets or sets the size of the underlying buffer */
  1166. capacity: number;
  1167. /**
  1168. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1169. */
  1170. is32Bits: boolean;
  1171. /**
  1172. * Gets the underlying buffer
  1173. */
  1174. get underlyingResource(): any;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export interface IShaderProcessor {
  1180. attributeProcessor?: (attribute: string) => string;
  1181. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1182. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1183. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1184. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1185. lineProcessor?: (line: string, isFragment: boolean) => string;
  1186. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1187. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export interface ProcessingOptions {
  1193. defines: string[];
  1194. indexParameters: any;
  1195. isFragment: boolean;
  1196. shouldUseHighPrecisionShader: boolean;
  1197. supportsUniformBuffers: boolean;
  1198. shadersRepository: string;
  1199. includesShadersStore: {
  1200. [key: string]: string;
  1201. };
  1202. processor?: IShaderProcessor;
  1203. version: string;
  1204. platformName: string;
  1205. lookForClosingBracketForUniformBuffer?: boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1236. process(preprocessors: {
  1237. [key: string]: string;
  1238. }, options: ProcessingOptions): string;
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderDefineExpression {
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. private static _OperatorPriority;
  1248. private static _Stack;
  1249. static postfixToInfix(postfix: string[]): string;
  1250. static infixToPostfix(infix: string): string[];
  1251. }
  1252. }
  1253. declare module BABYLON {
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. not: boolean;
  1267. constructor(define: string, not?: boolean);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module BABYLON {
  1274. /** @hidden */
  1275. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1276. leftOperand: ShaderDefineExpression;
  1277. rightOperand: ShaderDefineExpression;
  1278. isTrue(preprocessors: {
  1279. [key: string]: string;
  1280. }): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /** @hidden */
  1285. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1286. leftOperand: ShaderDefineExpression;
  1287. rightOperand: ShaderDefineExpression;
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /** @hidden */
  1295. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1296. define: string;
  1297. operand: string;
  1298. testValue: string;
  1299. constructor(define: string, operand: string, testValue: string);
  1300. isTrue(preprocessors: {
  1301. [key: string]: string;
  1302. }): boolean;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * Class used to enable access to offline support
  1308. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1309. */
  1310. export interface IOfflineProvider {
  1311. /**
  1312. * Gets a boolean indicating if scene must be saved in the database
  1313. */
  1314. enableSceneOffline: boolean;
  1315. /**
  1316. * Gets a boolean indicating if textures must be saved in the database
  1317. */
  1318. enableTexturesOffline: boolean;
  1319. /**
  1320. * Open the offline support and make it available
  1321. * @param successCallback defines the callback to call on success
  1322. * @param errorCallback defines the callback to call on error
  1323. */
  1324. open(successCallback: () => void, errorCallback: () => void): void;
  1325. /**
  1326. * Loads an image from the offline support
  1327. * @param url defines the url to load from
  1328. * @param image defines the target DOM image
  1329. */
  1330. loadImage(url: string, image: HTMLImageElement): void;
  1331. /**
  1332. * Loads a file from offline support
  1333. * @param url defines the URL to load from
  1334. * @param sceneLoaded defines a callback to call on success
  1335. * @param progressCallBack defines a callback to call when progress changed
  1336. * @param errorCallback defines a callback to call on error
  1337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1338. */
  1339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1340. }
  1341. }
  1342. declare module BABYLON {
  1343. /**
  1344. * Class used to help managing file picking and drag'n'drop
  1345. * File Storage
  1346. */
  1347. export class FilesInputStore {
  1348. /**
  1349. * List of files ready to be loaded
  1350. */
  1351. static FilesToLoad: {
  1352. [key: string]: File;
  1353. };
  1354. }
  1355. }
  1356. declare module BABYLON {
  1357. /**
  1358. * Class used to define a retry strategy when error happens while loading assets
  1359. */
  1360. export class RetryStrategy {
  1361. /**
  1362. * Function used to defines an exponential back off strategy
  1363. * @param maxRetries defines the maximum number of retries (3 by default)
  1364. * @param baseInterval defines the interval between retries
  1365. * @returns the strategy function to use
  1366. */
  1367. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * @ignore
  1373. * Application error to support additional information when loading a file
  1374. */
  1375. export abstract class BaseError extends Error {
  1376. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1377. }
  1378. }
  1379. declare module BABYLON {
  1380. /** @ignore */
  1381. export class LoadFileError extends BaseError {
  1382. request?: WebRequest;
  1383. file?: File;
  1384. /**
  1385. * Creates a new LoadFileError
  1386. * @param message defines the message of the error
  1387. * @param request defines the optional web request
  1388. * @param file defines the optional file
  1389. */
  1390. constructor(message: string, object?: WebRequest | File);
  1391. }
  1392. /** @ignore */
  1393. export class RequestFileError extends BaseError {
  1394. request: WebRequest;
  1395. /**
  1396. * Creates a new LoadFileError
  1397. * @param message defines the message of the error
  1398. * @param request defines the optional web request
  1399. */
  1400. constructor(message: string, request: WebRequest);
  1401. }
  1402. /** @ignore */
  1403. export class ReadFileError extends BaseError {
  1404. file: File;
  1405. /**
  1406. * Creates a new ReadFileError
  1407. * @param message defines the message of the error
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, file: File);
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export class FileTools {
  1416. /**
  1417. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1418. */
  1419. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1420. /**
  1421. * Gets or sets the base URL to use to load assets
  1422. */
  1423. static BaseUrl: string;
  1424. /**
  1425. * Default behaviour for cors in the application.
  1426. * It can be a string if the expected behavior is identical in the entire app.
  1427. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1428. */
  1429. static CorsBehavior: string | ((url: string | string[]) => string);
  1430. /**
  1431. * Gets or sets a function used to pre-process url before using them to load assets
  1432. */
  1433. static PreprocessUrl: (url: string) => string;
  1434. /**
  1435. * Removes unwanted characters from an url
  1436. * @param url defines the url to clean
  1437. * @returns the cleaned url
  1438. */
  1439. private static _CleanUrl;
  1440. /**
  1441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1442. * @param url define the url we are trying
  1443. * @param element define the dom element where to configure the cors policy
  1444. */
  1445. static SetCorsBehavior(url: string | string[], element: {
  1446. crossOrigin: string | null;
  1447. }): void;
  1448. /**
  1449. * Loads an image as an HTMLImageElement.
  1450. * @param input url string, ArrayBuffer, or Blob to load
  1451. * @param onLoad callback called when the image successfully loads
  1452. * @param onError callback called when the image fails to load
  1453. * @param offlineProvider offline provider for caching
  1454. * @param mimeType optional mime type
  1455. * @returns the HTMLImageElement of the loaded image
  1456. */
  1457. 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>;
  1458. /**
  1459. * Reads a file from a File object
  1460. * @param file defines the file to load
  1461. * @param onSuccess defines the callback to call when data is loaded
  1462. * @param onProgress defines the callback to call during loading process
  1463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1464. * @param onError defines the callback to call when an error occurs
  1465. * @returns a file request object
  1466. */
  1467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1468. /**
  1469. * Loads a file from a url
  1470. * @param url url to load
  1471. * @param onSuccess callback called when the file successfully loads
  1472. * @param onProgress callback called while file is loading (if the server supports this mode)
  1473. * @param offlineProvider defines the offline provider for caching
  1474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1475. * @param onError callback called when the file fails to load
  1476. * @returns a file request object
  1477. */
  1478. 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;
  1479. /**
  1480. * Loads a file
  1481. * @param url url to load
  1482. * @param onSuccess callback called when the file successfully loads
  1483. * @param onProgress callback called while file is loading (if the server supports this mode)
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @param onOpened callback called when the web request is opened
  1487. * @returns a file request object
  1488. */
  1489. 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;
  1490. /**
  1491. * Checks if the loaded document was accessed via `file:`-Protocol.
  1492. * @returns boolean
  1493. */
  1494. static IsFileURL(): boolean;
  1495. }
  1496. }
  1497. declare module BABYLON {
  1498. /** @hidden */
  1499. export class ShaderProcessor {
  1500. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1501. private static _ProcessPrecision;
  1502. private static _ExtractOperation;
  1503. private static _BuildSubExpression;
  1504. private static _BuildExpression;
  1505. private static _MoveCursorWithinIf;
  1506. private static _MoveCursor;
  1507. private static _EvaluatePreProcessors;
  1508. private static _PreparePreProcessors;
  1509. private static _ProcessShaderConversion;
  1510. private static _ProcessIncludes;
  1511. /**
  1512. * Loads a file from a url
  1513. * @param url url to load
  1514. * @param onSuccess callback called when the file successfully loads
  1515. * @param onProgress callback called while file is loading (if the server supports this mode)
  1516. * @param offlineProvider defines the offline provider for caching
  1517. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1518. * @param onError callback called when the file fails to load
  1519. * @returns a file request object
  1520. * @hidden
  1521. */
  1522. 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;
  1523. }
  1524. }
  1525. declare module BABYLON {
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IColor4Like {
  1530. r: float;
  1531. g: float;
  1532. b: float;
  1533. a: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IColor3Like {
  1539. r: float;
  1540. g: float;
  1541. b: float;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IVector4Like {
  1547. x: float;
  1548. y: float;
  1549. z: float;
  1550. w: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector3Like {
  1556. x: float;
  1557. y: float;
  1558. z: float;
  1559. }
  1560. /**
  1561. * @hidden
  1562. */
  1563. export interface IVector2Like {
  1564. x: float;
  1565. y: float;
  1566. }
  1567. /**
  1568. * @hidden
  1569. */
  1570. export interface IMatrixLike {
  1571. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1572. updateFlag: int;
  1573. }
  1574. /**
  1575. * @hidden
  1576. */
  1577. export interface IViewportLike {
  1578. x: float;
  1579. y: float;
  1580. width: float;
  1581. height: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IPlaneLike {
  1587. normal: IVector3Like;
  1588. d: float;
  1589. normalize(): void;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /**
  1594. * Interface used to define common properties for effect fallbacks
  1595. */
  1596. export interface IEffectFallbacks {
  1597. /**
  1598. * Removes the defines that should be removed when falling back.
  1599. * @param currentDefines defines the current define statements for the shader.
  1600. * @param effect defines the current effect we try to compile
  1601. * @returns The resulting defines with defines of the current rank removed.
  1602. */
  1603. reduce(currentDefines: string, effect: Effect): string;
  1604. /**
  1605. * Removes the fallback from the bound mesh.
  1606. */
  1607. unBindMesh(): void;
  1608. /**
  1609. * Checks to see if more fallbacks are still availible.
  1610. */
  1611. hasMoreFallbacks: boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Class used to evalaute queries containing `and` and `or` operators
  1617. */
  1618. export class AndOrNotEvaluator {
  1619. /**
  1620. * Evaluate a query
  1621. * @param query defines the query to evaluate
  1622. * @param evaluateCallback defines the callback used to filter result
  1623. * @returns true if the query matches
  1624. */
  1625. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1626. private static _HandleParenthesisContent;
  1627. private static _SimplifyNegation;
  1628. }
  1629. }
  1630. declare module BABYLON {
  1631. /**
  1632. * Class used to store custom tags
  1633. */
  1634. export class Tags {
  1635. /**
  1636. * Adds support for tags on the given object
  1637. * @param obj defines the object to use
  1638. */
  1639. static EnableFor(obj: any): void;
  1640. /**
  1641. * Removes tags support
  1642. * @param obj defines the object to use
  1643. */
  1644. static DisableFor(obj: any): void;
  1645. /**
  1646. * Gets a boolean indicating if the given object has tags
  1647. * @param obj defines the object to use
  1648. * @returns a boolean
  1649. */
  1650. static HasTags(obj: any): boolean;
  1651. /**
  1652. * Gets the tags available on a given object
  1653. * @param obj defines the object to use
  1654. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1655. * @returns the tags
  1656. */
  1657. static GetTags(obj: any, asString?: boolean): any;
  1658. /**
  1659. * Adds tags to an object
  1660. * @param obj defines the object to use
  1661. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1662. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1663. */
  1664. static AddTagsTo(obj: any, tagsString: string): void;
  1665. /**
  1666. * @hidden
  1667. */
  1668. static _AddTagTo(obj: any, tag: string): void;
  1669. /**
  1670. * Removes specific tags from a specific object
  1671. * @param obj defines the object to use
  1672. * @param tagsString defines the tags to remove
  1673. */
  1674. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1675. /**
  1676. * @hidden
  1677. */
  1678. static _RemoveTagFrom(obj: any, tag: string): void;
  1679. /**
  1680. * Defines if tags hosted on an object match a given query
  1681. * @param obj defines the object to use
  1682. * @param tagsQuery defines the tag query
  1683. * @returns a boolean
  1684. */
  1685. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1686. }
  1687. }
  1688. declare module BABYLON {
  1689. /**
  1690. * Scalar computation library
  1691. */
  1692. export class Scalar {
  1693. /**
  1694. * Two pi constants convenient for computation.
  1695. */
  1696. static TwoPi: number;
  1697. /**
  1698. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1699. * @param a number
  1700. * @param b number
  1701. * @param epsilon (default = 1.401298E-45)
  1702. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1703. */
  1704. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1705. /**
  1706. * Returns a string : the upper case translation of the number i to hexadecimal.
  1707. * @param i number
  1708. * @returns the upper case translation of the number i to hexadecimal.
  1709. */
  1710. static ToHex(i: number): string;
  1711. /**
  1712. * Returns -1 if value is negative and +1 is value is positive.
  1713. * @param value the value
  1714. * @returns the value itself if it's equal to zero.
  1715. */
  1716. static Sign(value: number): number;
  1717. /**
  1718. * Returns the value itself if it's between min and max.
  1719. * Returns min if the value is lower than min.
  1720. * Returns max if the value is greater than max.
  1721. * @param value the value to clmap
  1722. * @param min the min value to clamp to (default: 0)
  1723. * @param max the max value to clamp to (default: 1)
  1724. * @returns the clamped value
  1725. */
  1726. static Clamp(value: number, min?: number, max?: number): number;
  1727. /**
  1728. * the log2 of value.
  1729. * @param value the value to compute log2 of
  1730. * @returns the log2 of value.
  1731. */
  1732. static Log2(value: number): number;
  1733. /**
  1734. * Loops the value, so that it is never larger than length and never smaller than 0.
  1735. *
  1736. * This is similar to the modulo operator but it works with floating point numbers.
  1737. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1738. * With t = 5 and length = 2.5, the result would be 0.0.
  1739. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1740. * @param value the value
  1741. * @param length the length
  1742. * @returns the looped value
  1743. */
  1744. static Repeat(value: number, length: number): number;
  1745. /**
  1746. * Normalize the value between 0.0 and 1.0 using min and max values
  1747. * @param value value to normalize
  1748. * @param min max to normalize between
  1749. * @param max min to normalize between
  1750. * @returns the normalized value
  1751. */
  1752. static Normalize(value: number, min: number, max: number): number;
  1753. /**
  1754. * Denormalize the value from 0.0 and 1.0 using min and max values
  1755. * @param normalized value to denormalize
  1756. * @param min max to denormalize between
  1757. * @param max min to denormalize between
  1758. * @returns the denormalized value
  1759. */
  1760. static Denormalize(normalized: number, min: number, max: number): number;
  1761. /**
  1762. * Calculates the shortest difference between two given angles given in degrees.
  1763. * @param current current angle in degrees
  1764. * @param target target angle in degrees
  1765. * @returns the delta
  1766. */
  1767. static DeltaAngle(current: number, target: number): number;
  1768. /**
  1769. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1770. * @param tx value
  1771. * @param length length
  1772. * @returns The returned value will move back and forth between 0 and length
  1773. */
  1774. static PingPong(tx: number, length: number): number;
  1775. /**
  1776. * Interpolates between min and max with smoothing at the limits.
  1777. *
  1778. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1779. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1780. * @param from from
  1781. * @param to to
  1782. * @param tx value
  1783. * @returns the smooth stepped value
  1784. */
  1785. static SmoothStep(from: number, to: number, tx: number): number;
  1786. /**
  1787. * Moves a value current towards target.
  1788. *
  1789. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1790. * Negative values of maxDelta pushes the value away from target.
  1791. * @param current current value
  1792. * @param target target value
  1793. * @param maxDelta max distance to move
  1794. * @returns resulting value
  1795. */
  1796. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1797. /**
  1798. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1799. *
  1800. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1801. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1802. * @param current current value
  1803. * @param target target value
  1804. * @param maxDelta max distance to move
  1805. * @returns resulting angle
  1806. */
  1807. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1808. /**
  1809. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1810. * @param start start value
  1811. * @param end target value
  1812. * @param amount amount to lerp between
  1813. * @returns the lerped value
  1814. */
  1815. static Lerp(start: number, end: number, amount: number): number;
  1816. /**
  1817. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1818. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1819. * @param start start value
  1820. * @param end target value
  1821. * @param amount amount to lerp between
  1822. * @returns the lerped value
  1823. */
  1824. static LerpAngle(start: number, end: number, amount: number): number;
  1825. /**
  1826. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1827. * @param a start value
  1828. * @param b target value
  1829. * @param value value between a and b
  1830. * @returns the inverseLerp value
  1831. */
  1832. static InverseLerp(a: number, b: number, value: number): number;
  1833. /**
  1834. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1835. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1836. * @param value1 spline value
  1837. * @param tangent1 spline value
  1838. * @param value2 spline value
  1839. * @param tangent2 spline value
  1840. * @param amount input value
  1841. * @returns hermite result
  1842. */
  1843. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1844. /**
  1845. * Returns a random float number between and min and max values
  1846. * @param min min value of random
  1847. * @param max max value of random
  1848. * @returns random value
  1849. */
  1850. static RandomRange(min: number, max: number): number;
  1851. /**
  1852. * This function returns percentage of a number in a given range.
  1853. *
  1854. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1855. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1856. * @param number to convert to percentage
  1857. * @param min min range
  1858. * @param max max range
  1859. * @returns the percentage
  1860. */
  1861. static RangeToPercent(number: number, min: number, max: number): number;
  1862. /**
  1863. * This function returns number that corresponds to the percentage in a given range.
  1864. *
  1865. * PercentToRange(0.34,0,100) will return 34.
  1866. * @param percent to convert to number
  1867. * @param min min range
  1868. * @param max max range
  1869. * @returns the number
  1870. */
  1871. static PercentToRange(percent: number, min: number, max: number): number;
  1872. /**
  1873. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1874. * @param angle The angle to normalize in radian.
  1875. * @return The converted angle.
  1876. */
  1877. static NormalizeRadians(angle: number): number;
  1878. }
  1879. }
  1880. declare module BABYLON {
  1881. /**
  1882. * Constant used to convert a value to gamma space
  1883. * @ignorenaming
  1884. */
  1885. export const ToGammaSpace: number;
  1886. /**
  1887. * Constant used to convert a value to linear space
  1888. * @ignorenaming
  1889. */
  1890. export const ToLinearSpace = 2.2;
  1891. /**
  1892. * Constant used to define the minimal number value in Babylon.js
  1893. * @ignorenaming
  1894. */
  1895. let Epsilon: number;
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class used to represent a viewport on screen
  1900. */
  1901. export class Viewport {
  1902. /** viewport left coordinate */
  1903. x: number;
  1904. /** viewport top coordinate */
  1905. y: number;
  1906. /**viewport width */
  1907. width: number;
  1908. /** viewport height */
  1909. height: number;
  1910. /**
  1911. * Creates a Viewport object located at (x, y) and sized (width, height)
  1912. * @param x defines viewport left coordinate
  1913. * @param y defines viewport top coordinate
  1914. * @param width defines the viewport width
  1915. * @param height defines the viewport height
  1916. */
  1917. constructor(
  1918. /** viewport left coordinate */
  1919. x: number,
  1920. /** viewport top coordinate */
  1921. y: number,
  1922. /**viewport width */
  1923. width: number,
  1924. /** viewport height */
  1925. height: number);
  1926. /**
  1927. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1928. * @param renderWidth defines the rendering width
  1929. * @param renderHeight defines the rendering height
  1930. * @returns a new Viewport
  1931. */
  1932. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1933. /**
  1934. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1935. * @param renderWidth defines the rendering width
  1936. * @param renderHeight defines the rendering height
  1937. * @param ref defines the target viewport
  1938. * @returns the current viewport
  1939. */
  1940. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1941. /**
  1942. * Returns a new Viewport copied from the current one
  1943. * @returns a new Viewport
  1944. */
  1945. clone(): Viewport;
  1946. }
  1947. }
  1948. declare module BABYLON {
  1949. /**
  1950. * Class containing a set of static utilities functions for arrays.
  1951. */
  1952. export class ArrayTools {
  1953. /**
  1954. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1955. * @param size the number of element to construct and put in the array
  1956. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1957. * @returns a new array filled with new objects
  1958. */
  1959. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1960. }
  1961. }
  1962. declare module BABYLON {
  1963. /**
  1964. * Represents a plane by the equation ax + by + cz + d = 0
  1965. */
  1966. export class Plane {
  1967. private static _TmpMatrix;
  1968. /**
  1969. * Normal of the plane (a,b,c)
  1970. */
  1971. normal: Vector3;
  1972. /**
  1973. * d component of the plane
  1974. */
  1975. d: number;
  1976. /**
  1977. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1978. * @param a a component of the plane
  1979. * @param b b component of the plane
  1980. * @param c c component of the plane
  1981. * @param d d component of the plane
  1982. */
  1983. constructor(a: number, b: number, c: number, d: number);
  1984. /**
  1985. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1986. */
  1987. asArray(): number[];
  1988. /**
  1989. * @returns a new plane copied from the current Plane.
  1990. */
  1991. clone(): Plane;
  1992. /**
  1993. * @returns the string "Plane".
  1994. */
  1995. getClassName(): string;
  1996. /**
  1997. * @returns the Plane hash code.
  1998. */
  1999. getHashCode(): number;
  2000. /**
  2001. * Normalize the current Plane in place.
  2002. * @returns the updated Plane.
  2003. */
  2004. normalize(): Plane;
  2005. /**
  2006. * Applies a transformation the plane and returns the result
  2007. * @param transformation the transformation matrix to be applied to the plane
  2008. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2009. */
  2010. transform(transformation: DeepImmutable<Matrix>): Plane;
  2011. /**
  2012. * Compute the dot product between the point and the plane normal
  2013. * @param point point to calculate the dot product with
  2014. * @returns the dot product (float) of the point coordinates and the plane normal.
  2015. */
  2016. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2017. /**
  2018. * Updates the current Plane from the plane defined by the three given points.
  2019. * @param point1 one of the points used to contruct the plane
  2020. * @param point2 one of the points used to contruct the plane
  2021. * @param point3 one of the points used to contruct the plane
  2022. * @returns the updated Plane.
  2023. */
  2024. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2025. /**
  2026. * Checks if the plane is facing a given direction
  2027. * @param direction the direction to check if the plane is facing
  2028. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2029. * @returns True is the vector "direction" is the same side than the plane normal.
  2030. */
  2031. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2032. /**
  2033. * Calculates the distance to a point
  2034. * @param point point to calculate distance to
  2035. * @returns the signed distance (float) from the given point to the Plane.
  2036. */
  2037. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2038. /**
  2039. * Creates a plane from an array
  2040. * @param array the array to create a plane from
  2041. * @returns a new Plane from the given array.
  2042. */
  2043. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2044. /**
  2045. * Creates a plane from three points
  2046. * @param point1 point used to create the plane
  2047. * @param point2 point used to create the plane
  2048. * @param point3 point used to create the plane
  2049. * @returns a new Plane defined by the three given points.
  2050. */
  2051. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2052. /**
  2053. * Creates a plane from an origin point and a normal
  2054. * @param origin origin of the plane to be constructed
  2055. * @param normal normal of the plane to be constructed
  2056. * @returns a new Plane the normal vector to this plane at the given origin point.
  2057. * Note : the vector "normal" is updated because normalized.
  2058. */
  2059. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2060. /**
  2061. * Calculates the distance from a plane and a point
  2062. * @param origin origin of the plane to be constructed
  2063. * @param normal normal of the plane to be constructed
  2064. * @param point point to calculate distance to
  2065. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2066. */
  2067. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2068. }
  2069. }
  2070. declare module BABYLON {
  2071. /** @hidden */
  2072. export class PerformanceConfigurator {
  2073. /** @hidden */
  2074. static MatrixUse64Bits: boolean;
  2075. /** @hidden */
  2076. static MatrixTrackPrecisionChange: boolean;
  2077. /** @hidden */
  2078. static MatrixCurrentType: any;
  2079. /** @hidden */
  2080. static MatrixTrackedMatrices: Array<any> | null;
  2081. /** @hidden */
  2082. static SetMatrixPrecision(use64bits: boolean): void;
  2083. }
  2084. }
  2085. declare module BABYLON {
  2086. /**
  2087. * Class representing a vector containing 2 coordinates
  2088. */
  2089. export class Vector2 {
  2090. /** defines the first coordinate */
  2091. x: number;
  2092. /** defines the second coordinate */
  2093. y: number;
  2094. /**
  2095. * Creates a new Vector2 from the given x and y coordinates
  2096. * @param x defines the first coordinate
  2097. * @param y defines the second coordinate
  2098. */
  2099. constructor(
  2100. /** defines the first coordinate */
  2101. x?: number,
  2102. /** defines the second coordinate */
  2103. y?: number);
  2104. /**
  2105. * Gets a string with the Vector2 coordinates
  2106. * @returns a string with the Vector2 coordinates
  2107. */
  2108. toString(): string;
  2109. /**
  2110. * Gets class name
  2111. * @returns the string "Vector2"
  2112. */
  2113. getClassName(): string;
  2114. /**
  2115. * Gets current vector hash code
  2116. * @returns the Vector2 hash code as a number
  2117. */
  2118. getHashCode(): number;
  2119. /**
  2120. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2121. * @param array defines the source array
  2122. * @param index defines the offset in source array
  2123. * @returns the current Vector2
  2124. */
  2125. toArray(array: FloatArray, index?: number): Vector2;
  2126. /**
  2127. * Update the current vector from an array
  2128. * @param array defines the destination array
  2129. * @param index defines the offset in the destination array
  2130. * @returns the current Vector3
  2131. */
  2132. fromArray(array: FloatArray, index?: number): Vector2;
  2133. /**
  2134. * Copy the current vector to an array
  2135. * @returns a new array with 2 elements: the Vector2 coordinates.
  2136. */
  2137. asArray(): number[];
  2138. /**
  2139. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2140. * @param source defines the source Vector2
  2141. * @returns the current updated Vector2
  2142. */
  2143. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets the Vector2 coordinates with the given floats
  2146. * @param x defines the first coordinate
  2147. * @param y defines the second coordinate
  2148. * @returns the current updated Vector2
  2149. */
  2150. copyFromFloats(x: number, y: number): Vector2;
  2151. /**
  2152. * Sets the Vector2 coordinates with the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns the current updated Vector2
  2156. */
  2157. set(x: number, y: number): Vector2;
  2158. /**
  2159. * Add another vector with the current one
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2162. */
  2163. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. addVector3(otherVector: Vector3): Vector2;
  2183. /**
  2184. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2185. * @param otherVector defines the other vector
  2186. * @returns a new Vector2
  2187. */
  2188. subtract(otherVector: Vector2): Vector2;
  2189. /**
  2190. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2191. * @param otherVector defines the other vector
  2192. * @param result defines the target vector
  2193. * @returns the unmodified current Vector2
  2194. */
  2195. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2196. /**
  2197. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2198. * @param otherVector defines the other vector
  2199. * @returns the current updated Vector2
  2200. */
  2201. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Multiplies in place the current Vector2 coordinates by the given ones
  2204. * @param otherVector defines the other vector
  2205. * @returns the current updated Vector2
  2206. */
  2207. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2208. /**
  2209. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2210. * @param otherVector defines the other vector
  2211. * @returns a new Vector2
  2212. */
  2213. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2216. * @param otherVector defines the other vector
  2217. * @param result defines the target vector
  2218. * @returns the unmodified current Vector2
  2219. */
  2220. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2223. * @param x defines the first coordinate
  2224. * @param y defines the second coordinate
  2225. * @returns a new Vector2
  2226. */
  2227. multiplyByFloats(x: number, y: number): Vector2;
  2228. /**
  2229. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2230. * @param otherVector defines the other vector
  2231. * @returns a new Vector2
  2232. */
  2233. divide(otherVector: Vector2): Vector2;
  2234. /**
  2235. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2236. * @param otherVector defines the other vector
  2237. * @param result defines the target vector
  2238. * @returns the unmodified current Vector2
  2239. */
  2240. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2241. /**
  2242. * Divides the current Vector2 coordinates by the given ones
  2243. * @param otherVector defines the other vector
  2244. * @returns the current updated Vector2
  2245. */
  2246. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2247. /**
  2248. * Gets a new Vector2 with current Vector2 negated coordinates
  2249. * @returns a new Vector2
  2250. */
  2251. negate(): Vector2;
  2252. /**
  2253. * Negate this vector in place
  2254. * @returns this
  2255. */
  2256. negateInPlace(): Vector2;
  2257. /**
  2258. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2259. * @param result defines the Vector3 object where to store the result
  2260. * @returns the current Vector2
  2261. */
  2262. negateToRef(result: Vector2): Vector2;
  2263. /**
  2264. * Multiply the Vector2 coordinates by scale
  2265. * @param scale defines the scaling factor
  2266. * @returns the current updated Vector2
  2267. */
  2268. scaleInPlace(scale: number): Vector2;
  2269. /**
  2270. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2271. * @param scale defines the scaling factor
  2272. * @returns a new Vector2
  2273. */
  2274. scale(scale: number): Vector2;
  2275. /**
  2276. * Scale the current Vector2 values by a factor to a given Vector2
  2277. * @param scale defines the scale factor
  2278. * @param result defines the Vector2 object where to store the result
  2279. * @returns the unmodified current Vector2
  2280. */
  2281. scaleToRef(scale: number, result: Vector2): Vector2;
  2282. /**
  2283. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2284. * @param scale defines the scale factor
  2285. * @param result defines the Vector2 object where to store the result
  2286. * @returns the unmodified current Vector2
  2287. */
  2288. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2289. /**
  2290. * Gets a boolean if two vectors are equals
  2291. * @param otherVector defines the other vector
  2292. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2293. */
  2294. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2295. /**
  2296. * Gets a boolean if two vectors are equals (using an epsilon value)
  2297. * @param otherVector defines the other vector
  2298. * @param epsilon defines the minimal distance to consider equality
  2299. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2300. */
  2301. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2302. /**
  2303. * Gets a new Vector2 from current Vector2 floored values
  2304. * @returns a new Vector2
  2305. */
  2306. floor(): Vector2;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. fract(): Vector2;
  2312. /**
  2313. * Gets the length of the vector
  2314. * @returns the vector length (float)
  2315. */
  2316. length(): number;
  2317. /**
  2318. * Gets the vector squared length
  2319. * @returns the vector squared length (float)
  2320. */
  2321. lengthSquared(): number;
  2322. /**
  2323. * Normalize the vector
  2324. * @returns the current updated Vector2
  2325. */
  2326. normalize(): Vector2;
  2327. /**
  2328. * Gets a new Vector2 copied from the Vector2
  2329. * @returns a new Vector2
  2330. */
  2331. clone(): Vector2;
  2332. /**
  2333. * Gets a new Vector2(0, 0)
  2334. * @returns a new Vector2
  2335. */
  2336. static Zero(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(1, 1)
  2339. * @returns a new Vector2
  2340. */
  2341. static One(): Vector2;
  2342. /**
  2343. * Gets a new Vector2 set from the given index element of the given array
  2344. * @param array defines the data source
  2345. * @param offset defines the offset in the data source
  2346. * @returns a new Vector2
  2347. */
  2348. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2349. /**
  2350. * Sets "result" from the given index element of the given array
  2351. * @param array defines the data source
  2352. * @param offset defines the offset in the data source
  2353. * @param result defines the target vector
  2354. */
  2355. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2356. /**
  2357. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2358. * @param value1 defines 1st point of control
  2359. * @param value2 defines 2nd point of control
  2360. * @param value3 defines 3rd point of control
  2361. * @param value4 defines 4th point of control
  2362. * @param amount defines the interpolation factor
  2363. * @returns a new Vector2
  2364. */
  2365. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2366. /**
  2367. * 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".
  2368. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2369. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2370. * @param value defines the value to clamp
  2371. * @param min defines the lower limit
  2372. * @param max defines the upper limit
  2373. * @returns a new Vector2
  2374. */
  2375. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2378. * @param value1 defines the 1st control point
  2379. * @param tangent1 defines the outgoing tangent
  2380. * @param value2 defines the 2nd control point
  2381. * @param tangent2 defines the incoming tangent
  2382. * @param amount defines the interpolation factor
  2383. * @returns a new Vector2
  2384. */
  2385. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2386. /**
  2387. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2388. * @param start defines the start vector
  2389. * @param end defines the end vector
  2390. * @param amount defines the interpolation factor
  2391. * @returns a new Vector2
  2392. */
  2393. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2394. /**
  2395. * Gets the dot product of the vector "left" and the vector "right"
  2396. * @param left defines first vector
  2397. * @param right defines second vector
  2398. * @returns the dot product (float)
  2399. */
  2400. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2401. /**
  2402. * Returns a new Vector2 equal to the normalized given vector
  2403. * @param vector defines the vector to normalize
  2404. * @returns a new Vector2
  2405. */
  2406. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2407. /**
  2408. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2409. * @param left defines 1st vector
  2410. * @param right defines 2nd vector
  2411. * @returns a new Vector2
  2412. */
  2413. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2414. /**
  2415. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2416. * @param left defines 1st vector
  2417. * @param right defines 2nd vector
  2418. * @returns a new Vector2
  2419. */
  2420. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2421. /**
  2422. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2423. * @param vector defines the vector to transform
  2424. * @param transformation defines the matrix to apply
  2425. * @returns a new Vector2
  2426. */
  2427. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2428. /**
  2429. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2430. * @param vector defines the vector to transform
  2431. * @param transformation defines the matrix to apply
  2432. * @param result defines the target vector
  2433. */
  2434. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2435. /**
  2436. * Determines if a given vector is included in a triangle
  2437. * @param p defines the vector to test
  2438. * @param p0 defines 1st triangle point
  2439. * @param p1 defines 2nd triangle point
  2440. * @param p2 defines 3rd triangle point
  2441. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2442. */
  2443. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2444. /**
  2445. * Gets the distance between the vectors "value1" and "value2"
  2446. * @param value1 defines first vector
  2447. * @param value2 defines second vector
  2448. * @returns the distance between vectors
  2449. */
  2450. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2451. /**
  2452. * Returns the squared distance between the vectors "value1" and "value2"
  2453. * @param value1 defines first vector
  2454. * @param value2 defines second vector
  2455. * @returns the squared distance between vectors
  2456. */
  2457. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2458. /**
  2459. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2460. * @param value1 defines first vector
  2461. * @param value2 defines second vector
  2462. * @returns a new Vector2
  2463. */
  2464. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2465. /**
  2466. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2467. * @param p defines the middle point
  2468. * @param segA defines one point of the segment
  2469. * @param segB defines the other point of the segment
  2470. * @returns the shortest distance
  2471. */
  2472. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2473. }
  2474. /**
  2475. * Class used to store (x,y,z) vector representation
  2476. * A Vector3 is the main object used in 3D geometry
  2477. * It can represent etiher the coordinates of a point the space, either a direction
  2478. * Reminder: js uses a left handed forward facing system
  2479. */
  2480. export class Vector3 {
  2481. private static _UpReadOnly;
  2482. private static _ZeroReadOnly;
  2483. /** @hidden */
  2484. _x: number;
  2485. /** @hidden */
  2486. _y: number;
  2487. /** @hidden */
  2488. _z: number;
  2489. /** @hidden */
  2490. _isDirty: boolean;
  2491. /** Gets or sets the x coordinate */
  2492. get x(): number;
  2493. set x(value: number);
  2494. /** Gets or sets the y coordinate */
  2495. get y(): number;
  2496. set y(value: number);
  2497. /** Gets or sets the z coordinate */
  2498. get z(): number;
  2499. set z(value: number);
  2500. /**
  2501. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2502. * @param x defines the first coordinates (on X axis)
  2503. * @param y defines the second coordinates (on Y axis)
  2504. * @param z defines the third coordinates (on Z axis)
  2505. */
  2506. constructor(x?: number, y?: number, z?: number);
  2507. /**
  2508. * Creates a string representation of the Vector3
  2509. * @returns a string with the Vector3 coordinates.
  2510. */
  2511. toString(): string;
  2512. /**
  2513. * Gets the class name
  2514. * @returns the string "Vector3"
  2515. */
  2516. getClassName(): string;
  2517. /**
  2518. * Creates the Vector3 hash code
  2519. * @returns a number which tends to be unique between Vector3 instances
  2520. */
  2521. getHashCode(): number;
  2522. /**
  2523. * Creates an array containing three elements : the coordinates of the Vector3
  2524. * @returns a new array of numbers
  2525. */
  2526. asArray(): number[];
  2527. /**
  2528. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2529. * @param array defines the destination array
  2530. * @param index defines the offset in the destination array
  2531. * @returns the current Vector3
  2532. */
  2533. toArray(array: FloatArray, index?: number): Vector3;
  2534. /**
  2535. * Update the current vector from an array
  2536. * @param array defines the destination array
  2537. * @param index defines the offset in the destination array
  2538. * @returns the current Vector3
  2539. */
  2540. fromArray(array: FloatArray, index?: number): Vector3;
  2541. /**
  2542. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2543. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2544. */
  2545. toQuaternion(): Quaternion;
  2546. /**
  2547. * Adds the given vector to the current Vector3
  2548. * @param otherVector defines the second operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2552. /**
  2553. * Adds the given coordinates to the current Vector3
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2562. * @param otherVector defines the second operand
  2563. * @returns the resulting Vector3
  2564. */
  2565. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2566. /**
  2567. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2568. * @param otherVector defines the second operand
  2569. * @param result defines the Vector3 object where to store the result
  2570. * @returns the current Vector3
  2571. */
  2572. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2573. /**
  2574. * Subtract the given vector from the current Vector3
  2575. * @param otherVector defines the second operand
  2576. * @returns the current updated Vector3
  2577. */
  2578. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2579. /**
  2580. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2581. * @param otherVector defines the second operand
  2582. * @returns the resulting Vector3
  2583. */
  2584. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2585. /**
  2586. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2587. * @param otherVector defines the second operand
  2588. * @param result defines the Vector3 object where to store the result
  2589. * @returns the current Vector3
  2590. */
  2591. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2592. /**
  2593. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  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. * @returns the resulting Vector3
  2598. */
  2599. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2600. /**
  2601. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2602. * @param x defines the x coordinate of the operand
  2603. * @param y defines the y coordinate of the operand
  2604. * @param z defines the z coordinate of the operand
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the current Vector3
  2607. */
  2608. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2609. /**
  2610. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2611. * @returns a new Vector3
  2612. */
  2613. negate(): Vector3;
  2614. /**
  2615. * Negate this vector in place
  2616. * @returns this
  2617. */
  2618. negateInPlace(): Vector3;
  2619. /**
  2620. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2621. * @param result defines the Vector3 object where to store the result
  2622. * @returns the current Vector3
  2623. */
  2624. negateToRef(result: Vector3): Vector3;
  2625. /**
  2626. * Multiplies the Vector3 coordinates by the float "scale"
  2627. * @param scale defines the multiplier factor
  2628. * @returns the current updated Vector3
  2629. */
  2630. scaleInPlace(scale: number): Vector3;
  2631. /**
  2632. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2633. * @param scale defines the multiplier factor
  2634. * @returns a new Vector3
  2635. */
  2636. scale(scale: number): Vector3;
  2637. /**
  2638. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2639. * @param scale defines the multiplier factor
  2640. * @param result defines the Vector3 object where to store the result
  2641. * @returns the current Vector3
  2642. */
  2643. scaleToRef(scale: number, result: Vector3): Vector3;
  2644. /**
  2645. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2646. * @param scale defines the scale factor
  2647. * @param result defines the Vector3 object where to store the result
  2648. * @returns the unmodified current Vector3
  2649. */
  2650. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2651. /**
  2652. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2653. * @param origin defines the origin of the projection ray
  2654. * @param plane defines the plane to project to
  2655. * @returns the projected vector3
  2656. */
  2657. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2658. /**
  2659. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2660. * @param origin defines the origin of the projection ray
  2661. * @param plane defines the plane to project to
  2662. * @param result defines the Vector3 where to store the result
  2663. */
  2664. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2665. /**
  2666. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2667. * @param otherVector defines the second operand
  2668. * @returns true if both vectors are equals
  2669. */
  2670. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2671. /**
  2672. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2673. * @param otherVector defines the second operand
  2674. * @param epsilon defines the minimal distance to define values as equals
  2675. * @returns true if both vectors are distant less than epsilon
  2676. */
  2677. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2678. /**
  2679. * Returns true if the current Vector3 coordinates equals the given floats
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns true if both vectors are equals
  2684. */
  2685. equalsToFloats(x: number, y: number, z: number): boolean;
  2686. /**
  2687. * Multiplies the current Vector3 coordinates by the given ones
  2688. * @param otherVector defines the second operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2692. /**
  2693. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2694. * @param otherVector defines the second operand
  2695. * @returns the new Vector3
  2696. */
  2697. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2698. /**
  2699. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2700. * @param otherVector defines the second operand
  2701. * @param result defines the Vector3 object where to store the result
  2702. * @returns the current Vector3
  2703. */
  2704. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2705. /**
  2706. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2707. * @param x defines the x coordinate of the operand
  2708. * @param y defines the y coordinate of the operand
  2709. * @param z defines the z coordinate of the operand
  2710. * @returns the new Vector3
  2711. */
  2712. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2715. * @param otherVector defines the second operand
  2716. * @returns the new Vector3
  2717. */
  2718. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2719. /**
  2720. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2721. * @param otherVector defines the second operand
  2722. * @param result defines the Vector3 object where to store the result
  2723. * @returns the current Vector3
  2724. */
  2725. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2726. /**
  2727. * Divides the current Vector3 coordinates by the given ones.
  2728. * @param otherVector defines the second operand
  2729. * @returns the current updated Vector3
  2730. */
  2731. divideInPlace(otherVector: Vector3): Vector3;
  2732. /**
  2733. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2734. * @param other defines the second operand
  2735. * @returns the current updated Vector3
  2736. */
  2737. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2738. /**
  2739. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2740. * @param other defines the second operand
  2741. * @returns the current updated Vector3
  2742. */
  2743. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2744. /**
  2745. * Updates the current Vector3 with the minimal 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. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2752. /**
  2753. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2754. * @param x defines the x coordinate of the operand
  2755. * @param y defines the y coordinate of the operand
  2756. * @param z defines the z coordinate of the operand
  2757. * @returns the current updated Vector3
  2758. */
  2759. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2760. /**
  2761. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2762. * Check if is non uniform within a certain amount of decimal places to account for this
  2763. * @param epsilon the amount the values can differ
  2764. * @returns if the the vector is non uniform to a certain number of decimal places
  2765. */
  2766. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2767. /**
  2768. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2769. */
  2770. get isNonUniform(): boolean;
  2771. /**
  2772. * Gets a new Vector3 from current Vector3 floored values
  2773. * @returns a new Vector3
  2774. */
  2775. floor(): Vector3;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. fract(): Vector3;
  2781. /**
  2782. * Gets the length of the Vector3
  2783. * @returns the length of the Vector3
  2784. */
  2785. length(): number;
  2786. /**
  2787. * Gets the squared length of the Vector3
  2788. * @returns squared length of the Vector3
  2789. */
  2790. lengthSquared(): number;
  2791. /**
  2792. * Normalize the current Vector3.
  2793. * Please note that this is an in place operation.
  2794. * @returns the current updated Vector3
  2795. */
  2796. normalize(): Vector3;
  2797. /**
  2798. * Reorders the x y z properties of the vector in place
  2799. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2800. * @returns the current updated vector
  2801. */
  2802. reorderInPlace(order: string): this;
  2803. /**
  2804. * Rotates the vector around 0,0,0 by a quaternion
  2805. * @param quaternion the rotation quaternion
  2806. * @param result vector to store the result
  2807. * @returns the resulting vector
  2808. */
  2809. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2810. /**
  2811. * Rotates a vector around a given point
  2812. * @param quaternion the rotation quaternion
  2813. * @param point the point to rotate around
  2814. * @param result vector to store the result
  2815. * @returns the resulting vector
  2816. */
  2817. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2818. /**
  2819. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2820. * The cross product is then orthogonal to both current and "other"
  2821. * @param other defines the right operand
  2822. * @returns the cross product
  2823. */
  2824. cross(other: Vector3): Vector3;
  2825. /**
  2826. * Normalize the current Vector3 with the given input length.
  2827. * Please note that this is an in place operation.
  2828. * @param len the length of the vector
  2829. * @returns the current updated Vector3
  2830. */
  2831. normalizeFromLength(len: number): Vector3;
  2832. /**
  2833. * Normalize the current Vector3 to a new vector
  2834. * @returns the new Vector3
  2835. */
  2836. normalizeToNew(): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to the reference
  2839. * @param reference define the Vector3 to update
  2840. * @returns the updated Vector3
  2841. */
  2842. normalizeToRef(reference: Vector3): Vector3;
  2843. /**
  2844. * Creates a new Vector3 copied from the current Vector3
  2845. * @returns the new Vector3
  2846. */
  2847. clone(): Vector3;
  2848. /**
  2849. * Copies the given vector coordinates to the current Vector3 ones
  2850. * @param source defines the source Vector3
  2851. * @returns the current updated Vector3
  2852. */
  2853. copyFrom(source: DeepImmutable<Vector3>): 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. copyFromFloats(x: number, y: number, z: number): Vector3;
  2862. /**
  2863. * Copies the given floats to the current Vector3 coordinates
  2864. * @param x defines the x coordinate of the operand
  2865. * @param y defines the y coordinate of the operand
  2866. * @param z defines the z coordinate of the operand
  2867. * @returns the current updated Vector3
  2868. */
  2869. set(x: number, y: number, z: number): Vector3;
  2870. /**
  2871. * Copies the given float to the current Vector3 coordinates
  2872. * @param v defines the x, y and z coordinates of the operand
  2873. * @returns the current updated Vector3
  2874. */
  2875. setAll(v: number): Vector3;
  2876. /**
  2877. * Get the clip factor between two vectors
  2878. * @param vector0 defines the first operand
  2879. * @param vector1 defines the second operand
  2880. * @param axis defines the axis to use
  2881. * @param size defines the size along the axis
  2882. * @returns the clip factor
  2883. */
  2884. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2885. /**
  2886. * Get angle between two vectors
  2887. * @param vector0 angle between vector0 and vector1
  2888. * @param vector1 angle between vector0 and vector1
  2889. * @param normal direction of the normal
  2890. * @return the angle between vector0 and vector1
  2891. */
  2892. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2893. /**
  2894. * Returns a new Vector3 set from the index "offset" of the given array
  2895. * @param array defines the source array
  2896. * @param offset defines the offset in the source array
  2897. * @returns the new Vector3
  2898. */
  2899. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2900. /**
  2901. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2902. * @param array defines the source array
  2903. * @param offset defines the offset in the source array
  2904. * @returns the new Vector3
  2905. * @deprecated Please use FromArray instead.
  2906. */
  2907. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2908. /**
  2909. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2910. * @param array defines the source array
  2911. * @param offset defines the offset in the source array
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2915. /**
  2916. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2917. * @param array defines the source array
  2918. * @param offset defines the offset in the source array
  2919. * @param result defines the Vector3 where to store the result
  2920. * @deprecated Please use FromArrayToRef instead.
  2921. */
  2922. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2923. /**
  2924. * Sets the given vector "result" with the given floats.
  2925. * @param x defines the x coordinate of the source
  2926. * @param y defines the y coordinate of the source
  2927. * @param z defines the z coordinate of the source
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2931. /**
  2932. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2933. * @returns a new empty Vector3
  2934. */
  2935. static Zero(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2938. * @returns a new unit Vector3
  2939. */
  2940. static One(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2943. * @returns a new up Vector3
  2944. */
  2945. static Up(): Vector3;
  2946. /**
  2947. * Gets a up Vector3 that must not be updated
  2948. */
  2949. static get UpReadOnly(): DeepImmutable<Vector3>;
  2950. /**
  2951. * Gets a zero Vector3 that must not be updated
  2952. */
  2953. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2954. /**
  2955. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2956. * @returns a new down Vector3
  2957. */
  2958. static Down(): Vector3;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2961. * @param rightHandedSystem is the scene right-handed (negative z)
  2962. * @returns a new forward Vector3
  2963. */
  2964. static Forward(rightHandedSystem?: boolean): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2967. * @param rightHandedSystem is the scene right-handed (negative-z)
  2968. * @returns a new forward Vector3
  2969. */
  2970. static Backward(rightHandedSystem?: boolean): Vector3;
  2971. /**
  2972. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2973. * @returns a new right Vector3
  2974. */
  2975. static Right(): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2978. * @returns a new left Vector3
  2979. */
  2980. static Left(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set 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. * @returns the transformed Vector3
  2987. */
  2988. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2989. /**
  2990. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2991. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2992. * @param vector defines the Vector3 to transform
  2993. * @param transformation defines the transformation matrix
  2994. * @param result defines the Vector3 where to store the result
  2995. */
  2996. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2997. /**
  2998. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2999. * This method computes tranformed coordinates only, not transformed direction vectors
  3000. * @param x define the x coordinate of the source vector
  3001. * @param y define the y coordinate of the source vector
  3002. * @param z define the z coordinate of the source vector
  3003. * @param transformation defines the transformation matrix
  3004. * @param result defines the Vector3 where to store the result
  3005. */
  3006. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3007. /**
  3008. * Returns a new Vector3 set 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. * @returns the new Vector3
  3013. */
  3014. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3015. /**
  3016. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3017. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3018. * @param vector defines the Vector3 to transform
  3019. * @param transformation defines the transformation matrix
  3020. * @param result defines the Vector3 where to store the result
  3021. */
  3022. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3023. /**
  3024. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3025. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3026. * @param x define the x coordinate of the source vector
  3027. * @param y define the y coordinate of the source vector
  3028. * @param z define the z coordinate of the source vector
  3029. * @param transformation defines the transformation matrix
  3030. * @param result defines the Vector3 where to store the result
  3031. */
  3032. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3033. /**
  3034. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3035. * @param value1 defines the first control point
  3036. * @param value2 defines the second control point
  3037. * @param value3 defines the third control point
  3038. * @param value4 defines the fourth control point
  3039. * @param amount defines the amount on the spline to use
  3040. * @returns the new Vector3
  3041. */
  3042. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3043. /**
  3044. * 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"
  3045. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3046. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3047. * @param value defines the current value
  3048. * @param min defines the lower range value
  3049. * @param max defines the upper range value
  3050. * @returns the new Vector3
  3051. */
  3052. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3053. /**
  3054. * 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"
  3055. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3056. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3057. * @param value defines the current value
  3058. * @param min defines the lower range value
  3059. * @param max defines the upper range value
  3060. * @param result defines the Vector3 where to store the result
  3061. */
  3062. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3063. /**
  3064. * Checks if a given vector is inside a specific range
  3065. * @param v defines the vector to test
  3066. * @param min defines the minimum range
  3067. * @param max defines the maximum range
  3068. */
  3069. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3070. /**
  3071. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3072. * @param value1 defines the first control point
  3073. * @param tangent1 defines the first tangent vector
  3074. * @param value2 defines the second control point
  3075. * @param tangent2 defines the second tangent vector
  3076. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3077. * @returns the new Vector3
  3078. */
  3079. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3080. /**
  3081. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "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. * @returns the new Vector3
  3086. */
  3087. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3088. /**
  3089. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3090. * @param start defines the start value
  3091. * @param end defines the end value
  3092. * @param amount max defines amount between both (between 0 and 1)
  3093. * @param result defines the Vector3 where to store the result
  3094. */
  3095. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3096. /**
  3097. * Returns the dot product (float) between the vectors "left" and "right"
  3098. * @param left defines the left operand
  3099. * @param right defines the right operand
  3100. * @returns the dot product
  3101. */
  3102. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3103. /**
  3104. * Returns a new Vector3 as the cross product of the vectors "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. * @returns the cross product
  3109. */
  3110. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3111. /**
  3112. * Sets the given vector "result" with the cross product of "left" and "right"
  3113. * The cross product is then orthogonal to both "left" and "right"
  3114. * @param left defines the left operand
  3115. * @param right defines the right operand
  3116. * @param result defines the Vector3 where to store the result
  3117. */
  3118. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3119. /**
  3120. * Returns a new Vector3 as the normalization of the given vector
  3121. * @param vector defines the Vector3 to normalize
  3122. * @returns the new Vector3
  3123. */
  3124. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3125. /**
  3126. * Sets the given vector "result" with the normalization of the given first vector
  3127. * @param vector defines the Vector3 to normalize
  3128. * @param result defines the Vector3 where to store the result
  3129. */
  3130. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3131. /**
  3132. * Project a Vector3 onto screen space
  3133. * @param vector defines the Vector3 to project
  3134. * @param world defines the world matrix to use
  3135. * @param transform defines the transform (view x projection) matrix to use
  3136. * @param viewport defines the screen viewport to use
  3137. * @returns the new Vector3
  3138. */
  3139. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3140. /**
  3141. * Project a Vector3 onto screen space to reference
  3142. * @param vector defines the Vector3 to project
  3143. * @param world defines the world matrix to use
  3144. * @param transform defines the transform (view x projection) matrix to use
  3145. * @param viewport defines the screen viewport to use
  3146. * @param result the vector in which the screen space will be stored
  3147. * @returns the new Vector3
  3148. */
  3149. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3150. /** @hidden */
  3151. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3152. /**
  3153. * Unproject from screen space to object space
  3154. * @param source defines the screen space Vector3 to use
  3155. * @param viewportWidth defines the current width of the viewport
  3156. * @param viewportHeight defines the current height of the viewport
  3157. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3158. * @param transform defines the transform (view x projection) matrix to use
  3159. * @returns the new Vector3
  3160. */
  3161. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3162. /**
  3163. * Unproject from screen space to object space
  3164. * @param source defines the screen space Vector3 to use
  3165. * @param viewportWidth defines the current width of the viewport
  3166. * @param viewportHeight defines the current height of the viewport
  3167. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3168. * @param view defines the view matrix to use
  3169. * @param projection defines the projection matrix to use
  3170. * @returns the new Vector3
  3171. */
  3172. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3173. /**
  3174. * Unproject from screen space to object space
  3175. * @param source defines the screen space Vector3 to use
  3176. * @param viewportWidth defines the current width of the viewport
  3177. * @param viewportHeight defines the current height of the viewport
  3178. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3179. * @param view defines the view matrix to use
  3180. * @param projection defines the projection matrix to use
  3181. * @param result defines the Vector3 where to store the result
  3182. */
  3183. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3184. /**
  3185. * Unproject from screen space to object space
  3186. * @param sourceX defines the screen space x coordinate to use
  3187. * @param sourceY defines the screen space y coordinate to use
  3188. * @param sourceZ defines the screen space z coordinate to use
  3189. * @param viewportWidth defines the current width of the viewport
  3190. * @param viewportHeight defines the current height of the viewport
  3191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3192. * @param view defines the view matrix to use
  3193. * @param projection defines the projection matrix to use
  3194. * @param result defines the Vector3 where to store the result
  3195. */
  3196. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3197. /**
  3198. * Gets the minimal coordinate values between two Vector3
  3199. * @param left defines the first operand
  3200. * @param right defines the second operand
  3201. * @returns the new Vector3
  3202. */
  3203. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3204. /**
  3205. * Gets the maximal coordinate values between two Vector3
  3206. * @param left defines the first operand
  3207. * @param right defines the second operand
  3208. * @returns the new Vector3
  3209. */
  3210. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3211. /**
  3212. * Returns the distance between the vectors "value1" and "value2"
  3213. * @param value1 defines the first operand
  3214. * @param value2 defines the second operand
  3215. * @returns the distance
  3216. */
  3217. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3218. /**
  3219. * Returns the squared distance between the vectors "value1" and "value2"
  3220. * @param value1 defines the first operand
  3221. * @param value2 defines the second operand
  3222. * @returns the squared distance
  3223. */
  3224. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3225. /**
  3226. * Returns a new Vector3 located at the center between "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the new Vector3
  3230. */
  3231. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3232. /**
  3233. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3234. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3235. * to something in order to rotate it from its local system to the given target system
  3236. * Note: axis1, axis2 and axis3 are normalized during this operation
  3237. * @param axis1 defines the first axis
  3238. * @param axis2 defines the second axis
  3239. * @param axis3 defines the third axis
  3240. * @returns a new Vector3
  3241. */
  3242. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3243. /**
  3244. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3245. * @param axis1 defines the first axis
  3246. * @param axis2 defines the second axis
  3247. * @param axis3 defines the third axis
  3248. * @param ref defines the Vector3 where to store the result
  3249. */
  3250. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3251. }
  3252. /**
  3253. * Vector4 class created for EulerAngle class conversion to Quaternion
  3254. */
  3255. export class Vector4 {
  3256. /** x value of the vector */
  3257. x: number;
  3258. /** y value of the vector */
  3259. y: number;
  3260. /** z value of the vector */
  3261. z: number;
  3262. /** w value of the vector */
  3263. w: number;
  3264. /**
  3265. * Creates a Vector4 object from the given floats.
  3266. * @param x x value of the vector
  3267. * @param y y value of the vector
  3268. * @param z z value of the vector
  3269. * @param w w value of the vector
  3270. */
  3271. constructor(
  3272. /** x value of the vector */
  3273. x: number,
  3274. /** y value of the vector */
  3275. y: number,
  3276. /** z value of the vector */
  3277. z: number,
  3278. /** w value of the vector */
  3279. w: number);
  3280. /**
  3281. * Returns the string with the Vector4 coordinates.
  3282. * @returns a string containing all the vector values
  3283. */
  3284. toString(): string;
  3285. /**
  3286. * Returns the string "Vector4".
  3287. * @returns "Vector4"
  3288. */
  3289. getClassName(): string;
  3290. /**
  3291. * Returns the Vector4 hash code.
  3292. * @returns a unique hash code
  3293. */
  3294. getHashCode(): number;
  3295. /**
  3296. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3297. * @returns the resulting array
  3298. */
  3299. asArray(): number[];
  3300. /**
  3301. * Populates the given array from the given index with the Vector4 coordinates.
  3302. * @param array array to populate
  3303. * @param index index of the array to start at (default: 0)
  3304. * @returns the Vector4.
  3305. */
  3306. toArray(array: FloatArray, index?: number): Vector4;
  3307. /**
  3308. * Update the current vector from an array
  3309. * @param array defines the destination array
  3310. * @param index defines the offset in the destination array
  3311. * @returns the current Vector3
  3312. */
  3313. fromArray(array: FloatArray, index?: number): Vector4;
  3314. /**
  3315. * Adds the given vector to the current Vector4.
  3316. * @param otherVector the vector to add
  3317. * @returns the updated Vector4.
  3318. */
  3319. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3320. /**
  3321. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3322. * @param otherVector the vector to add
  3323. * @returns the resulting vector
  3324. */
  3325. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3326. /**
  3327. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3328. * @param otherVector the vector to add
  3329. * @param result the vector to store the result
  3330. * @returns the current Vector4.
  3331. */
  3332. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3333. /**
  3334. * Subtract in place the given vector from the current Vector4.
  3335. * @param otherVector the vector to subtract
  3336. * @returns the updated Vector4.
  3337. */
  3338. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3339. /**
  3340. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3341. * @param otherVector the vector to add
  3342. * @returns the new vector with the result
  3343. */
  3344. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3345. /**
  3346. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3347. * @param otherVector the vector to subtract
  3348. * @param result the vector to store the result
  3349. * @returns the current Vector4.
  3350. */
  3351. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3352. /**
  3353. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3354. */
  3355. /**
  3356. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3357. * @param x value to subtract
  3358. * @param y value to subtract
  3359. * @param z value to subtract
  3360. * @param w value to subtract
  3361. * @returns new vector containing the result
  3362. */
  3363. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3364. /**
  3365. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3366. * @param x value to subtract
  3367. * @param y value to subtract
  3368. * @param z value to subtract
  3369. * @param w value to subtract
  3370. * @param result the vector to store the result in
  3371. * @returns the current Vector4.
  3372. */
  3373. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3376. * @returns a new vector with the negated values
  3377. */
  3378. negate(): Vector4;
  3379. /**
  3380. * Negate this vector in place
  3381. * @returns this
  3382. */
  3383. negateInPlace(): Vector4;
  3384. /**
  3385. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3386. * @param result defines the Vector3 object where to store the result
  3387. * @returns the current Vector4
  3388. */
  3389. negateToRef(result: Vector4): Vector4;
  3390. /**
  3391. * Multiplies the current Vector4 coordinates by scale (float).
  3392. * @param scale the number to scale with
  3393. * @returns the updated Vector4.
  3394. */
  3395. scaleInPlace(scale: number): Vector4;
  3396. /**
  3397. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3398. * @param scale the number to scale with
  3399. * @returns a new vector with the result
  3400. */
  3401. scale(scale: number): Vector4;
  3402. /**
  3403. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3404. * @param scale the number to scale with
  3405. * @param result a vector to store the result in
  3406. * @returns the current Vector4.
  3407. */
  3408. scaleToRef(scale: number, result: Vector4): Vector4;
  3409. /**
  3410. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3411. * @param scale defines the scale factor
  3412. * @param result defines the Vector4 object where to store the result
  3413. * @returns the unmodified current Vector4
  3414. */
  3415. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3416. /**
  3417. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3418. * @param otherVector the vector to compare against
  3419. * @returns true if they are equal
  3420. */
  3421. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3422. /**
  3423. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3424. * @param otherVector vector to compare against
  3425. * @param epsilon (Default: very small number)
  3426. * @returns true if they are equal
  3427. */
  3428. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3429. /**
  3430. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3431. * @param x x value to compare against
  3432. * @param y y value to compare against
  3433. * @param z z value to compare against
  3434. * @param w w value to compare against
  3435. * @returns true if equal
  3436. */
  3437. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3438. /**
  3439. * Multiplies in place the current Vector4 by the given one.
  3440. * @param otherVector vector to multiple with
  3441. * @returns the updated Vector4.
  3442. */
  3443. multiplyInPlace(otherVector: Vector4): Vector4;
  3444. /**
  3445. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3446. * @param otherVector vector to multiple with
  3447. * @returns resulting new vector
  3448. */
  3449. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3452. * @param otherVector vector to multiple with
  3453. * @param result vector to store the result
  3454. * @returns the current Vector4.
  3455. */
  3456. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3457. /**
  3458. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3459. * @param x x value multiply with
  3460. * @param y y value multiply with
  3461. * @param z z value multiply with
  3462. * @param w w value multiply with
  3463. * @returns resulting new vector
  3464. */
  3465. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3466. /**
  3467. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3468. * @param otherVector vector to devide with
  3469. * @returns resulting new vector
  3470. */
  3471. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3472. /**
  3473. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3474. * @param otherVector vector to devide with
  3475. * @param result vector to store the result
  3476. * @returns the current Vector4.
  3477. */
  3478. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3479. /**
  3480. * Divides the current Vector3 coordinates by the given ones.
  3481. * @param otherVector vector to devide with
  3482. * @returns the updated Vector3.
  3483. */
  3484. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3485. /**
  3486. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3487. * @param other defines the second operand
  3488. * @returns the current updated Vector4
  3489. */
  3490. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3491. /**
  3492. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3493. * @param other defines the second operand
  3494. * @returns the current updated Vector4
  3495. */
  3496. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector4 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. floor(): Vector4;
  3502. /**
  3503. * Gets a new Vector4 from current Vector3 floored values
  3504. * @returns a new Vector4
  3505. */
  3506. fract(): Vector4;
  3507. /**
  3508. * Returns the Vector4 length (float).
  3509. * @returns the length
  3510. */
  3511. length(): number;
  3512. /**
  3513. * Returns the Vector4 squared length (float).
  3514. * @returns the length squared
  3515. */
  3516. lengthSquared(): number;
  3517. /**
  3518. * Normalizes in place the Vector4.
  3519. * @returns the updated Vector4.
  3520. */
  3521. normalize(): Vector4;
  3522. /**
  3523. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3524. * @returns this converted to a new vector3
  3525. */
  3526. toVector3(): Vector3;
  3527. /**
  3528. * Returns a new Vector4 copied from the current one.
  3529. * @returns the new cloned vector
  3530. */
  3531. clone(): Vector4;
  3532. /**
  3533. * Updates the current Vector4 with the given one coordinates.
  3534. * @param source the source vector to copy from
  3535. * @returns the updated Vector4.
  3536. */
  3537. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3538. /**
  3539. * Updates the current Vector4 coordinates with the given floats.
  3540. * @param x float to copy from
  3541. * @param y float to copy from
  3542. * @param z float to copy from
  3543. * @param w float to copy from
  3544. * @returns the updated Vector4.
  3545. */
  3546. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3547. /**
  3548. * Updates the current Vector4 coordinates with the given floats.
  3549. * @param x float to set from
  3550. * @param y float to set from
  3551. * @param z float to set from
  3552. * @param w float to set from
  3553. * @returns the updated Vector4.
  3554. */
  3555. set(x: number, y: number, z: number, w: number): Vector4;
  3556. /**
  3557. * Copies the given float to the current Vector3 coordinates
  3558. * @param v defines the x, y, z and w coordinates of the operand
  3559. * @returns the current updated Vector3
  3560. */
  3561. setAll(v: number): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set from the starting index of the given array.
  3564. * @param array the array to pull values from
  3565. * @param offset the offset into the array to start at
  3566. * @returns the new vector
  3567. */
  3568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3569. /**
  3570. * Updates the given vector "result" from the starting index of the given array.
  3571. * @param array the array to pull values from
  3572. * @param offset the offset into the array to start at
  3573. * @param result the vector to store the result in
  3574. */
  3575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3576. /**
  3577. * Updates the given vector "result" from the starting index of the given Float32Array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @param result the vector to store the result in
  3581. */
  3582. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3583. /**
  3584. * Updates the given vector "result" coordinates from the given floats.
  3585. * @param x float to set from
  3586. * @param y float to set from
  3587. * @param z float to set from
  3588. * @param w float to set from
  3589. * @param result the vector to the floats in
  3590. */
  3591. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3592. /**
  3593. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3594. * @returns the new vector
  3595. */
  3596. static Zero(): Vector4;
  3597. /**
  3598. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3599. * @returns the new vector
  3600. */
  3601. static One(): Vector4;
  3602. /**
  3603. * Returns a new normalized Vector4 from the given one.
  3604. * @param vector the vector to normalize
  3605. * @returns the vector
  3606. */
  3607. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Updates the given vector "result" from the normalization of the given one.
  3610. * @param vector the vector to normalize
  3611. * @param result the vector to store the result in
  3612. */
  3613. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3614. /**
  3615. * Returns a vector with the minimum values from the left and right vectors
  3616. * @param left left vector to minimize
  3617. * @param right right vector to minimize
  3618. * @returns a new vector with the minimum of the left and right vector values
  3619. */
  3620. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3621. /**
  3622. * Returns a vector with the maximum values from the left and right vectors
  3623. * @param left left vector to maximize
  3624. * @param right right vector to maximize
  3625. * @returns a new vector with the maximum of the left and right vector values
  3626. */
  3627. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3628. /**
  3629. * Returns the distance (float) between the vectors "value1" and "value2".
  3630. * @param value1 value to calulate the distance between
  3631. * @param value2 value to calulate the distance between
  3632. * @return the distance between the two vectors
  3633. */
  3634. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3635. /**
  3636. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3637. * @param value1 value to calulate the distance between
  3638. * @param value2 value to calulate the distance between
  3639. * @return the distance between the two vectors squared
  3640. */
  3641. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3642. /**
  3643. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the center between
  3645. * @param value2 value to calulate the center between
  3646. * @return the center between the two vectors
  3647. */
  3648. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3649. /**
  3650. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3651. * This methods computes transformed normalized direction vectors only.
  3652. * @param vector the vector to transform
  3653. * @param transformation the transformation matrix to apply
  3654. * @returns the new vector
  3655. */
  3656. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3657. /**
  3658. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3659. * This methods computes transformed normalized direction vectors only.
  3660. * @param vector the vector to transform
  3661. * @param transformation the transformation matrix to apply
  3662. * @param result the vector to store the result in
  3663. */
  3664. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3665. /**
  3666. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3667. * This methods computes transformed normalized direction vectors only.
  3668. * @param x value to transform
  3669. * @param y value to transform
  3670. * @param z value to transform
  3671. * @param w value to transform
  3672. * @param transformation the transformation matrix to apply
  3673. * @param result the vector to store the results in
  3674. */
  3675. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3676. /**
  3677. * Creates a new Vector4 from a Vector3
  3678. * @param source defines the source data
  3679. * @param w defines the 4th component (default is 0)
  3680. * @returns a new Vector4
  3681. */
  3682. static FromVector3(source: Vector3, w?: number): Vector4;
  3683. }
  3684. /**
  3685. * Class used to store quaternion data
  3686. * @see https://en.wikipedia.org/wiki/Quaternion
  3687. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3688. */
  3689. export class Quaternion {
  3690. /** @hidden */
  3691. _x: number;
  3692. /** @hidden */
  3693. _y: number;
  3694. /** @hidden */
  3695. _z: number;
  3696. /** @hidden */
  3697. _w: number;
  3698. /** @hidden */
  3699. _isDirty: boolean;
  3700. /** Gets or sets the x coordinate */
  3701. get x(): number;
  3702. set x(value: number);
  3703. /** Gets or sets the y coordinate */
  3704. get y(): number;
  3705. set y(value: number);
  3706. /** Gets or sets the z coordinate */
  3707. get z(): number;
  3708. set z(value: number);
  3709. /** Gets or sets the w coordinate */
  3710. get w(): number;
  3711. set w(value: number);
  3712. /**
  3713. * Creates a new Quaternion from the given floats
  3714. * @param x defines the first component (0 by default)
  3715. * @param y defines the second component (0 by default)
  3716. * @param z defines the third component (0 by default)
  3717. * @param w defines the fourth component (1.0 by default)
  3718. */
  3719. constructor(x?: number, y?: number, z?: number, w?: number);
  3720. /**
  3721. * Gets a string representation for the current quaternion
  3722. * @returns a string with the Quaternion coordinates
  3723. */
  3724. toString(): string;
  3725. /**
  3726. * Gets the class name of the quaternion
  3727. * @returns the string "Quaternion"
  3728. */
  3729. getClassName(): string;
  3730. /**
  3731. * Gets a hash code for this quaternion
  3732. * @returns the quaternion hash code
  3733. */
  3734. getHashCode(): number;
  3735. /**
  3736. * Copy the quaternion to an array
  3737. * @returns a new array populated with 4 elements from the quaternion coordinates
  3738. */
  3739. asArray(): number[];
  3740. /**
  3741. * Check if two quaternions are equals
  3742. * @param otherQuaternion defines the second operand
  3743. * @return true if the current quaternion and the given one coordinates are strictly equals
  3744. */
  3745. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3746. /**
  3747. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3748. * @param otherQuaternion defines the other quaternion
  3749. * @param epsilon defines the minimal distance to consider equality
  3750. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3751. */
  3752. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3753. /**
  3754. * Clone the current quaternion
  3755. * @returns a new quaternion copied from the current one
  3756. */
  3757. clone(): Quaternion;
  3758. /**
  3759. * Copy a quaternion to the current one
  3760. * @param other defines the other quaternion
  3761. * @returns the updated current quaternion
  3762. */
  3763. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3764. /**
  3765. * Updates the current quaternion with the given float coordinates
  3766. * @param x defines the x coordinate
  3767. * @param y defines the y coordinate
  3768. * @param z defines the z coordinate
  3769. * @param w defines the w coordinate
  3770. * @returns the updated current quaternion
  3771. */
  3772. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3773. /**
  3774. * Updates the current quaternion from the given float coordinates
  3775. * @param x defines the x coordinate
  3776. * @param y defines the y coordinate
  3777. * @param z defines the z coordinate
  3778. * @param w defines the w coordinate
  3779. * @returns the updated current quaternion
  3780. */
  3781. set(x: number, y: number, z: number, w: number): Quaternion;
  3782. /**
  3783. * Adds two quaternions
  3784. * @param other defines the second operand
  3785. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3786. */
  3787. add(other: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Add a quaternion to the current one
  3790. * @param other defines the quaternion to add
  3791. * @returns the current quaternion
  3792. */
  3793. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3794. /**
  3795. * Subtract two quaternions
  3796. * @param other defines the second operand
  3797. * @returns a new quaternion as the subtraction result of the given one from the current one
  3798. */
  3799. subtract(other: Quaternion): Quaternion;
  3800. /**
  3801. * Multiplies the current quaternion by a scale factor
  3802. * @param value defines the scale factor
  3803. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3804. */
  3805. scale(value: number): Quaternion;
  3806. /**
  3807. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3808. * @param scale defines the scale factor
  3809. * @param result defines the Quaternion object where to store the result
  3810. * @returns the unmodified current quaternion
  3811. */
  3812. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3813. /**
  3814. * Multiplies in place the current quaternion by a scale factor
  3815. * @param value defines the scale factor
  3816. * @returns the current modified quaternion
  3817. */
  3818. scaleInPlace(value: number): Quaternion;
  3819. /**
  3820. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3821. * @param scale defines the scale factor
  3822. * @param result defines the Quaternion object where to store the result
  3823. * @returns the unmodified current quaternion
  3824. */
  3825. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3826. /**
  3827. * Multiplies two quaternions
  3828. * @param q1 defines the second operand
  3829. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3830. */
  3831. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3834. * @param q1 defines the second operand
  3835. * @param result defines the target quaternion
  3836. * @returns the current quaternion
  3837. */
  3838. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3839. /**
  3840. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3841. * @param q1 defines the second operand
  3842. * @returns the currentupdated quaternion
  3843. */
  3844. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3845. /**
  3846. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3847. * @param ref defines the target quaternion
  3848. * @returns the current quaternion
  3849. */
  3850. conjugateToRef(ref: Quaternion): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns the current updated quaternion
  3854. */
  3855. conjugateInPlace(): Quaternion;
  3856. /**
  3857. * Conjugates in place (1-q) the current quaternion
  3858. * @returns a new quaternion
  3859. */
  3860. conjugate(): Quaternion;
  3861. /**
  3862. * Gets length of current quaternion
  3863. * @returns the quaternion length (float)
  3864. */
  3865. length(): number;
  3866. /**
  3867. * Normalize in place the current quaternion
  3868. * @returns the current updated quaternion
  3869. */
  3870. normalize(): Quaternion;
  3871. /**
  3872. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3873. * @param order is a reserved parameter and is ignored for now
  3874. * @returns a new Vector3 containing the Euler angles
  3875. */
  3876. toEulerAngles(order?: string): Vector3;
  3877. /**
  3878. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3879. * @param result defines the vector which will be filled with the Euler angles
  3880. * @returns the current unchanged quaternion
  3881. */
  3882. toEulerAnglesToRef(result: Vector3): Quaternion;
  3883. /**
  3884. * Updates the given rotation matrix with the current quaternion values
  3885. * @param result defines the target matrix
  3886. * @returns the current unchanged quaternion
  3887. */
  3888. toRotationMatrix(result: Matrix): Quaternion;
  3889. /**
  3890. * Updates the current quaternion from the given rotation matrix values
  3891. * @param matrix defines the source matrix
  3892. * @returns the current updated quaternion
  3893. */
  3894. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3895. /**
  3896. * Creates a new quaternion from a rotation matrix
  3897. * @param matrix defines the source matrix
  3898. * @returns a new quaternion created from the given rotation matrix values
  3899. */
  3900. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3901. /**
  3902. * Updates the given quaternion with the given rotation matrix values
  3903. * @param matrix defines the source matrix
  3904. * @param result defines the target quaternion
  3905. */
  3906. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3907. /**
  3908. * Returns the dot product (float) between the quaternions "left" and "right"
  3909. * @param left defines the left operand
  3910. * @param right defines the right operand
  3911. * @returns the dot product
  3912. */
  3913. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3914. /**
  3915. * Checks if the two quaternions are close to each other
  3916. * @param quat0 defines the first quaternion to check
  3917. * @param quat1 defines the second quaternion to check
  3918. * @returns true if the two quaternions are close to each other
  3919. */
  3920. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3921. /**
  3922. * Creates an empty quaternion
  3923. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3924. */
  3925. static Zero(): Quaternion;
  3926. /**
  3927. * Inverse a given quaternion
  3928. * @param q defines the source quaternion
  3929. * @returns a new quaternion as the inverted current quaternion
  3930. */
  3931. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3932. /**
  3933. * Inverse a given quaternion
  3934. * @param q defines the source quaternion
  3935. * @param result the quaternion the result will be stored in
  3936. * @returns the result quaternion
  3937. */
  3938. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3939. /**
  3940. * Creates an identity quaternion
  3941. * @returns the identity quaternion
  3942. */
  3943. static Identity(): Quaternion;
  3944. /**
  3945. * Gets a boolean indicating if the given quaternion is identity
  3946. * @param quaternion defines the quaternion to check
  3947. * @returns true if the quaternion is identity
  3948. */
  3949. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3950. /**
  3951. * Creates a quaternion from a rotation around an axis
  3952. * @param axis defines the axis to use
  3953. * @param angle defines the angle to use
  3954. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3955. */
  3956. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3957. /**
  3958. * Creates a rotation around an axis and stores it into the given quaternion
  3959. * @param axis defines the axis to use
  3960. * @param angle defines the angle to use
  3961. * @param result defines the target quaternion
  3962. * @returns the target quaternion
  3963. */
  3964. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3965. /**
  3966. * Creates a new quaternion from data stored into an array
  3967. * @param array defines the data source
  3968. * @param offset defines the offset in the source array where the data starts
  3969. * @returns a new quaternion
  3970. */
  3971. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3972. /**
  3973. * Updates the given quaternion "result" from the starting index of the given array.
  3974. * @param array the array to pull values from
  3975. * @param offset the offset into the array to start at
  3976. * @param result the quaternion to store the result in
  3977. */
  3978. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3979. /**
  3980. * Create a quaternion from Euler rotation angles
  3981. * @param x Pitch
  3982. * @param y Yaw
  3983. * @param z Roll
  3984. * @returns the new Quaternion
  3985. */
  3986. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3987. /**
  3988. * Updates a quaternion from Euler rotation angles
  3989. * @param x Pitch
  3990. * @param y Yaw
  3991. * @param z Roll
  3992. * @param result the quaternion to store the result
  3993. * @returns the updated quaternion
  3994. */
  3995. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3996. /**
  3997. * Create a quaternion from Euler rotation vector
  3998. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3999. * @returns the new Quaternion
  4000. */
  4001. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4002. /**
  4003. * Updates a quaternion from Euler rotation vector
  4004. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4005. * @param result the quaternion to store the result
  4006. * @returns the updated quaternion
  4007. */
  4008. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4009. /**
  4010. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4011. * @param yaw defines the rotation around Y axis
  4012. * @param pitch defines the rotation around X axis
  4013. * @param roll defines the rotation around Z axis
  4014. * @returns the new quaternion
  4015. */
  4016. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4017. /**
  4018. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4019. * @param yaw defines the rotation around Y axis
  4020. * @param pitch defines the rotation around X axis
  4021. * @param roll defines the rotation around Z axis
  4022. * @param result defines the target quaternion
  4023. */
  4024. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4025. /**
  4026. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4027. * @param alpha defines the rotation around first axis
  4028. * @param beta defines the rotation around second axis
  4029. * @param gamma defines the rotation around third axis
  4030. * @returns the new quaternion
  4031. */
  4032. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4033. /**
  4034. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4035. * @param alpha defines the rotation around first axis
  4036. * @param beta defines the rotation around second axis
  4037. * @param gamma defines the rotation around third axis
  4038. * @param result defines the target quaternion
  4039. */
  4040. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4041. /**
  4042. * 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)
  4043. * @param axis1 defines the first axis
  4044. * @param axis2 defines the second axis
  4045. * @param axis3 defines the third axis
  4046. * @returns the new quaternion
  4047. */
  4048. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4049. /**
  4050. * 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
  4051. * @param axis1 defines the first axis
  4052. * @param axis2 defines the second axis
  4053. * @param axis3 defines the third axis
  4054. * @param ref defines the target quaternion
  4055. */
  4056. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4057. /**
  4058. * Interpolates between two quaternions
  4059. * @param left defines first quaternion
  4060. * @param right defines second quaternion
  4061. * @param amount defines the gradient to use
  4062. * @returns the new interpolated quaternion
  4063. */
  4064. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4065. /**
  4066. * Interpolates between two quaternions and stores it into a target quaternion
  4067. * @param left defines first quaternion
  4068. * @param right defines second quaternion
  4069. * @param amount defines the gradient to use
  4070. * @param result defines the target quaternion
  4071. */
  4072. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4073. /**
  4074. * Interpolate between two quaternions using Hermite interpolation
  4075. * @param value1 defines first quaternion
  4076. * @param tangent1 defines the incoming tangent
  4077. * @param value2 defines second quaternion
  4078. * @param tangent2 defines the outgoing tangent
  4079. * @param amount defines the target quaternion
  4080. * @returns the new interpolated quaternion
  4081. */
  4082. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4083. }
  4084. /**
  4085. * Class used to store matrix data (4x4)
  4086. */
  4087. export class Matrix {
  4088. /**
  4089. * Gets the precision of matrix computations
  4090. */
  4091. static get Use64Bits(): boolean;
  4092. private static _updateFlagSeed;
  4093. private static _identityReadOnly;
  4094. private _isIdentity;
  4095. private _isIdentityDirty;
  4096. private _isIdentity3x2;
  4097. private _isIdentity3x2Dirty;
  4098. /**
  4099. * Gets the update flag of the matrix which is an unique number for the matrix.
  4100. * It will be incremented every time the matrix data change.
  4101. * You can use it to speed the comparison between two versions of the same matrix.
  4102. */
  4103. updateFlag: number;
  4104. private readonly _m;
  4105. /**
  4106. * Gets the internal data of the matrix
  4107. */
  4108. get m(): DeepImmutable<Float32Array | Array<number>>;
  4109. /** @hidden */
  4110. _markAsUpdated(): void;
  4111. /** @hidden */
  4112. private _updateIdentityStatus;
  4113. /**
  4114. * Creates an empty matrix (filled with zeros)
  4115. */
  4116. constructor();
  4117. /**
  4118. * Check if the current matrix is identity
  4119. * @returns true is the matrix is the identity matrix
  4120. */
  4121. isIdentity(): boolean;
  4122. /**
  4123. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4124. * @returns true is the matrix is the identity matrix
  4125. */
  4126. isIdentityAs3x2(): boolean;
  4127. /**
  4128. * Gets the determinant of the matrix
  4129. * @returns the matrix determinant
  4130. */
  4131. determinant(): number;
  4132. /**
  4133. * Returns the matrix as a Float32Array or Array<number>
  4134. * @returns the matrix underlying array
  4135. */
  4136. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4137. /**
  4138. * Returns the matrix as a Float32Array or Array<number>
  4139. * @returns the matrix underlying array.
  4140. */
  4141. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4142. /**
  4143. * Inverts the current matrix in place
  4144. * @returns the current inverted matrix
  4145. */
  4146. invert(): Matrix;
  4147. /**
  4148. * Sets all the matrix elements to zero
  4149. * @returns the current matrix
  4150. */
  4151. reset(): Matrix;
  4152. /**
  4153. * Adds the current matrix with a second one
  4154. * @param other defines the matrix to add
  4155. * @returns a new matrix as the addition of the current matrix and the given one
  4156. */
  4157. add(other: DeepImmutable<Matrix>): Matrix;
  4158. /**
  4159. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4160. * @param other defines the matrix to add
  4161. * @param result defines the target matrix
  4162. * @returns the current matrix
  4163. */
  4164. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4165. /**
  4166. * Adds in place the given matrix to the current matrix
  4167. * @param other defines the second operand
  4168. * @returns the current updated matrix
  4169. */
  4170. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4171. /**
  4172. * Sets the given matrix to the current inverted Matrix
  4173. * @param other defines the target matrix
  4174. * @returns the unmodified current matrix
  4175. */
  4176. invertToRef(other: Matrix): Matrix;
  4177. /**
  4178. * add a value at the specified position in the current Matrix
  4179. * @param index the index of the value within the matrix. between 0 and 15.
  4180. * @param value the value to be added
  4181. * @returns the current updated matrix
  4182. */
  4183. addAtIndex(index: number, value: number): Matrix;
  4184. /**
  4185. * mutiply the specified position in the current Matrix by a value
  4186. * @param index the index of the value within the matrix. between 0 and 15.
  4187. * @param value the value to be added
  4188. * @returns the current updated matrix
  4189. */
  4190. multiplyAtIndex(index: number, value: number): Matrix;
  4191. /**
  4192. * Inserts the translation vector (using 3 floats) in the current matrix
  4193. * @param x defines the 1st component of the translation
  4194. * @param y defines the 2nd component of the translation
  4195. * @param z defines the 3rd component of the translation
  4196. * @returns the current updated matrix
  4197. */
  4198. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4199. /**
  4200. * Adds the translation vector (using 3 floats) in the current matrix
  4201. * @param x defines the 1st component of the translation
  4202. * @param y defines the 2nd component of the translation
  4203. * @param z defines the 3rd component of the translation
  4204. * @returns the current updated matrix
  4205. */
  4206. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4207. /**
  4208. * Inserts the translation vector in the current matrix
  4209. * @param vector3 defines the translation to insert
  4210. * @returns the current updated matrix
  4211. */
  4212. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4213. /**
  4214. * Gets the translation value of the current matrix
  4215. * @returns a new Vector3 as the extracted translation from the matrix
  4216. */
  4217. getTranslation(): Vector3;
  4218. /**
  4219. * Fill a Vector3 with the extracted translation from the matrix
  4220. * @param result defines the Vector3 where to store the translation
  4221. * @returns the current matrix
  4222. */
  4223. getTranslationToRef(result: Vector3): Matrix;
  4224. /**
  4225. * Remove rotation and scaling part from the matrix
  4226. * @returns the updated matrix
  4227. */
  4228. removeRotationAndScaling(): Matrix;
  4229. /**
  4230. * Multiply two matrices
  4231. * @param other defines the second operand
  4232. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4233. */
  4234. multiply(other: DeepImmutable<Matrix>): Matrix;
  4235. /**
  4236. * Copy the current matrix from the given one
  4237. * @param other defines the source matrix
  4238. * @returns the current updated matrix
  4239. */
  4240. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4241. /**
  4242. * Populates the given array from the starting index with the current matrix values
  4243. * @param array defines the target array
  4244. * @param offset defines the offset in the target array where to start storing values
  4245. * @returns the current matrix
  4246. */
  4247. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4248. /**
  4249. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4250. * @param other defines the second operand
  4251. * @param result defines the matrix where to store the multiplication
  4252. * @returns the current matrix
  4253. */
  4254. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4255. /**
  4256. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4257. * @param other defines the second operand
  4258. * @param result defines the array where to store the multiplication
  4259. * @param offset defines the offset in the target array where to start storing values
  4260. * @returns the current matrix
  4261. */
  4262. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4263. /**
  4264. * Check equality between this matrix and a second one
  4265. * @param value defines the second matrix to compare
  4266. * @returns true is the current matrix and the given one values are strictly equal
  4267. */
  4268. equals(value: DeepImmutable<Matrix>): boolean;
  4269. /**
  4270. * Clone the current matrix
  4271. * @returns a new matrix from the current matrix
  4272. */
  4273. clone(): Matrix;
  4274. /**
  4275. * Returns the name of the current matrix class
  4276. * @returns the string "Matrix"
  4277. */
  4278. getClassName(): string;
  4279. /**
  4280. * Gets the hash code of the current matrix
  4281. * @returns the hash code
  4282. */
  4283. getHashCode(): number;
  4284. /**
  4285. * Decomposes the current Matrix into a translation, rotation and scaling components
  4286. * @param scale defines the scale vector3 given as a reference to update
  4287. * @param rotation defines the rotation quaternion given as a reference to update
  4288. * @param translation defines the translation vector3 given as a reference to update
  4289. * @returns true if operation was successful
  4290. */
  4291. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4292. /**
  4293. * Gets specific row of the matrix
  4294. * @param index defines the number of the row to get
  4295. * @returns the index-th row of the current matrix as a new Vector4
  4296. */
  4297. getRow(index: number): Nullable<Vector4>;
  4298. /**
  4299. * Sets the index-th row of the current matrix to the vector4 values
  4300. * @param index defines the number of the row to set
  4301. * @param row defines the target vector4
  4302. * @returns the updated current matrix
  4303. */
  4304. setRow(index: number, row: Vector4): Matrix;
  4305. /**
  4306. * Compute the transpose of the matrix
  4307. * @returns the new transposed matrix
  4308. */
  4309. transpose(): Matrix;
  4310. /**
  4311. * Compute the transpose of the matrix and store it in a given matrix
  4312. * @param result defines the target matrix
  4313. * @returns the current matrix
  4314. */
  4315. transposeToRef(result: Matrix): Matrix;
  4316. /**
  4317. * Sets the index-th row of the current matrix with the given 4 x float values
  4318. * @param index defines the row index
  4319. * @param x defines the x component to set
  4320. * @param y defines the y component to set
  4321. * @param z defines the z component to set
  4322. * @param w defines the w component to set
  4323. * @returns the updated current matrix
  4324. */
  4325. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4326. /**
  4327. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4328. * @param scale defines the scale factor
  4329. * @returns a new matrix
  4330. */
  4331. scale(scale: number): Matrix;
  4332. /**
  4333. * Scale the current matrix values by a factor to a given result matrix
  4334. * @param scale defines the scale factor
  4335. * @param result defines the matrix to store the result
  4336. * @returns the current matrix
  4337. */
  4338. scaleToRef(scale: number, result: Matrix): Matrix;
  4339. /**
  4340. * Scale the current matrix values by a factor and add the result to a given matrix
  4341. * @param scale defines the scale factor
  4342. * @param result defines the Matrix to store the result
  4343. * @returns the current matrix
  4344. */
  4345. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4346. /**
  4347. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4348. * @param ref matrix to store the result
  4349. */
  4350. toNormalMatrix(ref: Matrix): void;
  4351. /**
  4352. * Gets only rotation part of the current matrix
  4353. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4354. */
  4355. getRotationMatrix(): Matrix;
  4356. /**
  4357. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4358. * @param result defines the target matrix to store data to
  4359. * @returns the current matrix
  4360. */
  4361. getRotationMatrixToRef(result: Matrix): Matrix;
  4362. /**
  4363. * Toggles model matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleModelMatrixHandInPlace(): void;
  4366. /**
  4367. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4368. */
  4369. toggleProjectionMatrixHandInPlace(): void;
  4370. /**
  4371. * Creates a matrix from an array
  4372. * @param array defines the source array
  4373. * @param offset defines an offset in the source array
  4374. * @returns a new Matrix set from the starting index of the given array
  4375. */
  4376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4377. /**
  4378. * Copy the content of an array into a given matrix
  4379. * @param array defines the source array
  4380. * @param offset defines an offset in the source array
  4381. * @param result defines the target matrix
  4382. */
  4383. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4384. /**
  4385. * Stores an array into a matrix after having multiplied each component by a given factor
  4386. * @param array defines the source array
  4387. * @param offset defines the offset in the source array
  4388. * @param scale defines the scaling factor
  4389. * @param result defines the target matrix
  4390. */
  4391. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4392. /**
  4393. * Gets an identity matrix that must not be updated
  4394. */
  4395. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4396. /**
  4397. * Stores a list of values (16) inside a given matrix
  4398. * @param initialM11 defines 1st value of 1st row
  4399. * @param initialM12 defines 2nd value of 1st row
  4400. * @param initialM13 defines 3rd value of 1st row
  4401. * @param initialM14 defines 4th value of 1st row
  4402. * @param initialM21 defines 1st value of 2nd row
  4403. * @param initialM22 defines 2nd value of 2nd row
  4404. * @param initialM23 defines 3rd value of 2nd row
  4405. * @param initialM24 defines 4th value of 2nd row
  4406. * @param initialM31 defines 1st value of 3rd row
  4407. * @param initialM32 defines 2nd value of 3rd row
  4408. * @param initialM33 defines 3rd value of 3rd row
  4409. * @param initialM34 defines 4th value of 3rd row
  4410. * @param initialM41 defines 1st value of 4th row
  4411. * @param initialM42 defines 2nd value of 4th row
  4412. * @param initialM43 defines 3rd value of 4th row
  4413. * @param initialM44 defines 4th value of 4th row
  4414. * @param result defines the target matrix
  4415. */
  4416. 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;
  4417. /**
  4418. * Creates new matrix from a list of values (16)
  4419. * @param initialM11 defines 1st value of 1st row
  4420. * @param initialM12 defines 2nd value of 1st row
  4421. * @param initialM13 defines 3rd value of 1st row
  4422. * @param initialM14 defines 4th value of 1st row
  4423. * @param initialM21 defines 1st value of 2nd row
  4424. * @param initialM22 defines 2nd value of 2nd row
  4425. * @param initialM23 defines 3rd value of 2nd row
  4426. * @param initialM24 defines 4th value of 2nd row
  4427. * @param initialM31 defines 1st value of 3rd row
  4428. * @param initialM32 defines 2nd value of 3rd row
  4429. * @param initialM33 defines 3rd value of 3rd row
  4430. * @param initialM34 defines 4th value of 3rd row
  4431. * @param initialM41 defines 1st value of 4th row
  4432. * @param initialM42 defines 2nd value of 4th row
  4433. * @param initialM43 defines 3rd value of 4th row
  4434. * @param initialM44 defines 4th value of 4th row
  4435. * @returns the new matrix
  4436. */
  4437. 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;
  4438. /**
  4439. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4440. * @param scale defines the scale vector3
  4441. * @param rotation defines the rotation quaternion
  4442. * @param translation defines the translation vector3
  4443. * @returns a new matrix
  4444. */
  4445. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4446. /**
  4447. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4448. * @param scale defines the scale vector3
  4449. * @param rotation defines the rotation quaternion
  4450. * @param translation defines the translation vector3
  4451. * @param result defines the target matrix
  4452. */
  4453. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4454. /**
  4455. * Creates a new identity matrix
  4456. * @returns a new identity matrix
  4457. */
  4458. static Identity(): Matrix;
  4459. /**
  4460. * Creates a new identity matrix and stores the result in a given matrix
  4461. * @param result defines the target matrix
  4462. */
  4463. static IdentityToRef(result: Matrix): void;
  4464. /**
  4465. * Creates a new zero matrix
  4466. * @returns a new zero matrix
  4467. */
  4468. static Zero(): Matrix;
  4469. /**
  4470. * Creates a new rotation matrix for "angle" radians around the X axis
  4471. * @param angle defines the angle (in radians) to use
  4472. * @return the new matrix
  4473. */
  4474. static RotationX(angle: number): Matrix;
  4475. /**
  4476. * Creates a new matrix as the invert of a given matrix
  4477. * @param source defines the source matrix
  4478. * @returns the new matrix
  4479. */
  4480. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4481. /**
  4482. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4483. * @param angle defines the angle (in radians) to use
  4484. * @param result defines the target matrix
  4485. */
  4486. static RotationXToRef(angle: number, result: Matrix): void;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the Y axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationY(angle: number): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4495. * @param angle defines the angle (in radians) to use
  4496. * @param result defines the target matrix
  4497. */
  4498. static RotationYToRef(angle: number, result: Matrix): void;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the Z axis
  4501. * @param angle defines the angle (in radians) to use
  4502. * @return the new matrix
  4503. */
  4504. static RotationZ(angle: number): Matrix;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4507. * @param angle defines the angle (in radians) to use
  4508. * @param result defines the target matrix
  4509. */
  4510. static RotationZToRef(angle: number, result: Matrix): void;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the given axis
  4513. * @param axis defines the axis to use
  4514. * @param angle defines the angle (in radians) to use
  4515. * @return the new matrix
  4516. */
  4517. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4518. /**
  4519. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4520. * @param axis defines the axis to use
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4525. /**
  4526. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4527. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4528. * @param from defines the vector to align
  4529. * @param to defines the vector to align to
  4530. * @param result defines the target matrix
  4531. */
  4532. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4533. /**
  4534. * Creates a rotation matrix
  4535. * @param yaw defines the yaw angle in radians (Y axis)
  4536. * @param pitch defines the pitch angle in radians (X axis)
  4537. * @param roll defines the roll angle in radians (Z axis)
  4538. * @returns the new rotation matrix
  4539. */
  4540. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4541. /**
  4542. * Creates a rotation matrix and stores it in a given matrix
  4543. * @param yaw defines the yaw angle in radians (Y axis)
  4544. * @param pitch defines the pitch angle in radians (X axis)
  4545. * @param roll defines the roll angle in radians (Z axis)
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4549. /**
  4550. * Creates a scaling matrix
  4551. * @param x defines the scale factor on X axis
  4552. * @param y defines the scale factor on Y axis
  4553. * @param z defines the scale factor on Z axis
  4554. * @returns the new matrix
  4555. */
  4556. static Scaling(x: number, y: number, z: number): Matrix;
  4557. /**
  4558. * Creates a scaling matrix and stores it in a given matrix
  4559. * @param x defines the scale factor on X axis
  4560. * @param y defines the scale factor on Y axis
  4561. * @param z defines the scale factor on Z axis
  4562. * @param result defines the target matrix
  4563. */
  4564. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4565. /**
  4566. * Creates a translation matrix
  4567. * @param x defines the translation on X axis
  4568. * @param y defines the translation on Y axis
  4569. * @param z defines the translationon Z axis
  4570. * @returns the new matrix
  4571. */
  4572. static Translation(x: number, y: number, z: number): Matrix;
  4573. /**
  4574. * Creates a translation matrix and stores it in a given matrix
  4575. * @param x defines the translation on X axis
  4576. * @param y defines the translation on Y axis
  4577. * @param z defines the translationon Z axis
  4578. * @param result defines the target matrix
  4579. */
  4580. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4581. /**
  4582. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4583. * @param startValue defines the start value
  4584. * @param endValue defines the end value
  4585. * @param gradient defines the gradient factor
  4586. * @returns the new matrix
  4587. */
  4588. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4589. /**
  4590. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4591. * @param startValue defines the start value
  4592. * @param endValue defines the end value
  4593. * @param gradient defines the gradient factor
  4594. * @param result defines the Matrix object where to store data
  4595. */
  4596. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4597. /**
  4598. * Builds a new matrix whose values are computed by:
  4599. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4600. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4601. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4602. * @param startValue defines the first matrix
  4603. * @param endValue defines the second matrix
  4604. * @param gradient defines the gradient between the two matrices
  4605. * @returns the new matrix
  4606. */
  4607. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4608. /**
  4609. * Update a matrix to values which are computed by:
  4610. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4611. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4612. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4613. * @param startValue defines the first matrix
  4614. * @param endValue defines the second matrix
  4615. * @param gradient defines the gradient between the two matrices
  4616. * @param result defines the target matrix
  4617. */
  4618. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, 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 left 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 LookAtLH(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 left 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 LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4637. /**
  4638. * 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"
  4639. * This function works in right handed mode
  4640. * @param eye defines the final position of the entity
  4641. * @param target defines where the entity should look at
  4642. * @param up defines the up vector for the entity
  4643. * @returns the new matrix
  4644. */
  4645. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4646. /**
  4647. * 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".
  4648. * This function works in right handed mode
  4649. * @param eye defines the final position of the entity
  4650. * @param target defines where the entity should look at
  4651. * @param up defines the up vector for the entity
  4652. * @param result defines the target matrix
  4653. */
  4654. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4655. /**
  4656. * Create a left-handed orthographic projection matrix
  4657. * @param width defines the viewport width
  4658. * @param height defines the viewport height
  4659. * @param znear defines the near clip plane
  4660. * @param zfar defines the far clip plane
  4661. * @returns a new matrix as a left-handed orthographic projection matrix
  4662. */
  4663. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4664. /**
  4665. * Store a left-handed orthographic projection to a given matrix
  4666. * @param width defines the viewport width
  4667. * @param height defines the viewport height
  4668. * @param znear defines the near clip plane
  4669. * @param zfar defines the far clip plane
  4670. * @param result defines the target matrix
  4671. */
  4672. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4673. /**
  4674. * Create a left-handed orthographic projection matrix
  4675. * @param left defines the viewport left coordinate
  4676. * @param right defines the viewport right coordinate
  4677. * @param bottom defines the viewport bottom coordinate
  4678. * @param top defines the viewport top coordinate
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @returns a new matrix as a left-handed orthographic projection matrix
  4682. */
  4683. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4684. /**
  4685. * Stores a left-handed orthographic projection into a given matrix
  4686. * @param left defines the viewport left coordinate
  4687. * @param right defines the viewport right coordinate
  4688. * @param bottom defines the viewport bottom coordinate
  4689. * @param top defines the viewport top coordinate
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. */
  4694. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4695. /**
  4696. * Creates a right-handed orthographic projection matrix
  4697. * @param left defines the viewport left coordinate
  4698. * @param right defines the viewport right coordinate
  4699. * @param bottom defines the viewport bottom coordinate
  4700. * @param top defines the viewport top coordinate
  4701. * @param znear defines the near clip plane
  4702. * @param zfar defines the far clip plane
  4703. * @returns a new matrix as a right-handed orthographic projection matrix
  4704. */
  4705. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4706. /**
  4707. * Stores a right-handed orthographic projection into a given matrix
  4708. * @param left defines the viewport left coordinate
  4709. * @param right defines the viewport right coordinate
  4710. * @param bottom defines the viewport bottom coordinate
  4711. * @param top defines the viewport top coordinate
  4712. * @param znear defines the near clip plane
  4713. * @param zfar defines the far clip plane
  4714. * @param result defines the target matrix
  4715. */
  4716. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4717. /**
  4718. * Creates a left-handed perspective projection matrix
  4719. * @param width defines the viewport width
  4720. * @param height defines the viewport height
  4721. * @param znear defines the near clip plane
  4722. * @param zfar defines the far clip plane
  4723. * @returns a new matrix as a left-handed perspective projection matrix
  4724. */
  4725. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4726. /**
  4727. * Creates a left-handed perspective projection matrix
  4728. * @param fov defines the horizontal field of view
  4729. * @param aspect defines the aspect ratio
  4730. * @param znear defines the near clip plane
  4731. * @param zfar defines the far clip plane
  4732. * @returns a new matrix as a left-handed perspective projection matrix
  4733. */
  4734. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4735. /**
  4736. * Stores a left-handed perspective projection into a given matrix
  4737. * @param fov defines the horizontal field of view
  4738. * @param aspect defines the aspect ratio
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @param result defines the target matrix
  4742. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4743. */
  4744. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4745. /**
  4746. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4747. * @param fov defines the horizontal field of view
  4748. * @param aspect defines the aspect ratio
  4749. * @param znear defines the near clip plane
  4750. * @param zfar not used as infinity is used as far clip
  4751. * @param result defines the target matrix
  4752. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4753. */
  4754. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4755. /**
  4756. * Creates a right-handed perspective projection matrix
  4757. * @param fov defines the horizontal field of view
  4758. * @param aspect defines the aspect ratio
  4759. * @param znear defines the near clip plane
  4760. * @param zfar defines the far clip plane
  4761. * @returns a new matrix as a right-handed perspective projection matrix
  4762. */
  4763. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4764. /**
  4765. * Stores a right-handed perspective projection into a given matrix
  4766. * @param fov defines the horizontal field of view
  4767. * @param aspect defines the aspect ratio
  4768. * @param znear defines the near clip plane
  4769. * @param zfar defines the far clip plane
  4770. * @param result defines the target matrix
  4771. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4772. */
  4773. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4774. /**
  4775. * Stores a right-handed perspective projection into a given matrix
  4776. * @param fov defines the horizontal field of view
  4777. * @param aspect defines the aspect ratio
  4778. * @param znear defines the near clip plane
  4779. * @param zfar not used as infinity is used as far clip
  4780. * @param result defines the target matrix
  4781. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4782. */
  4783. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4784. /**
  4785. * Stores a perspective projection for WebVR info a given matrix
  4786. * @param fov defines the field of view
  4787. * @param znear defines the near clip plane
  4788. * @param zfar defines the far clip plane
  4789. * @param result defines the target matrix
  4790. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4791. */
  4792. static PerspectiveFovWebVRToRef(fov: {
  4793. upDegrees: number;
  4794. downDegrees: number;
  4795. leftDegrees: number;
  4796. rightDegrees: number;
  4797. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4798. /**
  4799. * Computes a complete transformation matrix
  4800. * @param viewport defines the viewport to use
  4801. * @param world defines the world matrix
  4802. * @param view defines the view matrix
  4803. * @param projection defines the projection matrix
  4804. * @param zmin defines the near clip plane
  4805. * @param zmax defines the far clip plane
  4806. * @returns the transformation matrix
  4807. */
  4808. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4809. /**
  4810. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4811. * @param matrix defines the matrix to use
  4812. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4813. */
  4814. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4815. /**
  4816. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4817. * @param matrix defines the matrix to use
  4818. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4819. */
  4820. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4821. /**
  4822. * Compute the transpose of a given matrix
  4823. * @param matrix defines the matrix to transpose
  4824. * @returns the new matrix
  4825. */
  4826. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4827. /**
  4828. * Compute the transpose of a matrix and store it in a target matrix
  4829. * @param matrix defines the matrix to transpose
  4830. * @param result defines the target matrix
  4831. */
  4832. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4833. /**
  4834. * Computes a reflection matrix from a plane
  4835. * @param plane defines the reflection plane
  4836. * @returns a new matrix
  4837. */
  4838. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4839. /**
  4840. * Computes a reflection matrix from a plane
  4841. * @param plane defines the reflection plane
  4842. * @param result defines the target matrix
  4843. */
  4844. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4845. /**
  4846. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4847. * @param xaxis defines the value of the 1st axis
  4848. * @param yaxis defines the value of the 2nd axis
  4849. * @param zaxis defines the value of the 3rd axis
  4850. * @param result defines the target matrix
  4851. */
  4852. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4853. /**
  4854. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4855. * @param quat defines the quaternion to use
  4856. * @param result defines the target matrix
  4857. */
  4858. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4859. }
  4860. /**
  4861. * @hidden
  4862. */
  4863. export class TmpVectors {
  4864. static Vector2: Vector2[];
  4865. static Vector3: Vector3[];
  4866. static Vector4: Vector4[];
  4867. static Quaternion: Quaternion[];
  4868. static Matrix: Matrix[];
  4869. }
  4870. }
  4871. declare module BABYLON {
  4872. /**
  4873. * Defines potential orientation for back face culling
  4874. */
  4875. export enum Orientation {
  4876. /**
  4877. * Clockwise
  4878. */
  4879. CW = 0,
  4880. /** Counter clockwise */
  4881. CCW = 1
  4882. }
  4883. /** Class used to represent a Bezier curve */
  4884. export class BezierCurve {
  4885. /**
  4886. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4887. * @param t defines the time
  4888. * @param x1 defines the left coordinate on X axis
  4889. * @param y1 defines the left coordinate on Y axis
  4890. * @param x2 defines the right coordinate on X axis
  4891. * @param y2 defines the right coordinate on Y axis
  4892. * @returns the interpolated value
  4893. */
  4894. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4895. }
  4896. /**
  4897. * Defines angle representation
  4898. */
  4899. export class Angle {
  4900. private _radians;
  4901. /**
  4902. * Creates an Angle object of "radians" radians (float).
  4903. * @param radians the angle in radians
  4904. */
  4905. constructor(radians: number);
  4906. /**
  4907. * Get value in degrees
  4908. * @returns the Angle value in degrees (float)
  4909. */
  4910. degrees(): number;
  4911. /**
  4912. * Get value in radians
  4913. * @returns the Angle value in radians (float)
  4914. */
  4915. radians(): number;
  4916. /**
  4917. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4918. * @param a defines first point as the origin
  4919. * @param b defines point
  4920. * @returns a new Angle
  4921. */
  4922. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4923. /**
  4924. * Gets a new Angle object from the given float in radians
  4925. * @param radians defines the angle value in radians
  4926. * @returns a new Angle
  4927. */
  4928. static FromRadians(radians: number): Angle;
  4929. /**
  4930. * Gets a new Angle object from the given float in degrees
  4931. * @param degrees defines the angle value in degrees
  4932. * @returns a new Angle
  4933. */
  4934. static FromDegrees(degrees: number): Angle;
  4935. }
  4936. /**
  4937. * This represents an arc in a 2d space.
  4938. */
  4939. export class Arc2 {
  4940. /** Defines the start point of the arc */
  4941. startPoint: Vector2;
  4942. /** Defines the mid point of the arc */
  4943. midPoint: Vector2;
  4944. /** Defines the end point of the arc */
  4945. endPoint: Vector2;
  4946. /**
  4947. * Defines the center point of the arc.
  4948. */
  4949. centerPoint: Vector2;
  4950. /**
  4951. * Defines the radius of the arc.
  4952. */
  4953. radius: number;
  4954. /**
  4955. * Defines the angle of the arc (from mid point to end point).
  4956. */
  4957. angle: Angle;
  4958. /**
  4959. * Defines the start angle of the arc (from start point to middle point).
  4960. */
  4961. startAngle: Angle;
  4962. /**
  4963. * Defines the orientation of the arc (clock wise/counter clock wise).
  4964. */
  4965. orientation: Orientation;
  4966. /**
  4967. * Creates an Arc object from the three given points : start, middle and end.
  4968. * @param startPoint Defines the start point of the arc
  4969. * @param midPoint Defines the midlle point of the arc
  4970. * @param endPoint Defines the end point of the arc
  4971. */
  4972. constructor(
  4973. /** Defines the start point of the arc */
  4974. startPoint: Vector2,
  4975. /** Defines the mid point of the arc */
  4976. midPoint: Vector2,
  4977. /** Defines the end point of the arc */
  4978. endPoint: Vector2);
  4979. }
  4980. /**
  4981. * Represents a 2D path made up of multiple 2D points
  4982. */
  4983. export class Path2 {
  4984. private _points;
  4985. private _length;
  4986. /**
  4987. * If the path start and end point are the same
  4988. */
  4989. closed: boolean;
  4990. /**
  4991. * Creates a Path2 object from the starting 2D coordinates x and y.
  4992. * @param x the starting points x value
  4993. * @param y the starting points y value
  4994. */
  4995. constructor(x: number, y: number);
  4996. /**
  4997. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4998. * @param x the added points x value
  4999. * @param y the added points y value
  5000. * @returns the updated Path2.
  5001. */
  5002. addLineTo(x: number, y: number): Path2;
  5003. /**
  5004. * 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.
  5005. * @param midX middle point x value
  5006. * @param midY middle point y value
  5007. * @param endX end point x value
  5008. * @param endY end point y value
  5009. * @param numberOfSegments (default: 36)
  5010. * @returns the updated Path2.
  5011. */
  5012. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5013. /**
  5014. * Closes the Path2.
  5015. * @returns the Path2.
  5016. */
  5017. close(): Path2;
  5018. /**
  5019. * Gets the sum of the distance between each sequential point in the path
  5020. * @returns the Path2 total length (float).
  5021. */
  5022. length(): number;
  5023. /**
  5024. * Gets the points which construct the path
  5025. * @returns the Path2 internal array of points.
  5026. */
  5027. getPoints(): Vector2[];
  5028. /**
  5029. * Retreives the point at the distance aways from the starting point
  5030. * @param normalizedLengthPosition the length along the path to retreive the point from
  5031. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5032. */
  5033. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5034. /**
  5035. * Creates a new path starting from an x and y position
  5036. * @param x starting x value
  5037. * @param y starting y value
  5038. * @returns a new Path2 starting at the coordinates (x, y).
  5039. */
  5040. static StartingAt(x: number, y: number): Path2;
  5041. }
  5042. /**
  5043. * Represents a 3D path made up of multiple 3D points
  5044. */
  5045. export class Path3D {
  5046. /**
  5047. * an array of Vector3, the curve axis of the Path3D
  5048. */
  5049. path: Vector3[];
  5050. private _curve;
  5051. private _distances;
  5052. private _tangents;
  5053. private _normals;
  5054. private _binormals;
  5055. private _raw;
  5056. private _alignTangentsWithPath;
  5057. private readonly _pointAtData;
  5058. /**
  5059. * new Path3D(path, normal, raw)
  5060. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5061. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5062. * @param path an array of Vector3, the curve axis of the Path3D
  5063. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5064. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5065. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5066. */
  5067. constructor(
  5068. /**
  5069. * an array of Vector3, the curve axis of the Path3D
  5070. */
  5071. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5072. /**
  5073. * Returns the Path3D array of successive Vector3 designing its curve.
  5074. * @returns the Path3D array of successive Vector3 designing its curve.
  5075. */
  5076. getCurve(): Vector3[];
  5077. /**
  5078. * Returns the Path3D array of successive Vector3 designing its curve.
  5079. * @returns the Path3D array of successive Vector3 designing its curve.
  5080. */
  5081. getPoints(): Vector3[];
  5082. /**
  5083. * @returns the computed length (float) of the path.
  5084. */
  5085. length(): number;
  5086. /**
  5087. * Returns an array populated with tangent vectors on each Path3D curve point.
  5088. * @returns an array populated with tangent vectors on each Path3D curve point.
  5089. */
  5090. getTangents(): Vector3[];
  5091. /**
  5092. * Returns an array populated with normal vectors on each Path3D curve point.
  5093. * @returns an array populated with normal vectors on each Path3D curve point.
  5094. */
  5095. getNormals(): Vector3[];
  5096. /**
  5097. * Returns an array populated with binormal vectors on each Path3D curve point.
  5098. * @returns an array populated with binormal vectors on each Path3D curve point.
  5099. */
  5100. getBinormals(): Vector3[];
  5101. /**
  5102. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5103. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5104. */
  5105. getDistances(): number[];
  5106. /**
  5107. * Returns an interpolated point along this path
  5108. * @param position the position of the point along this path, from 0.0 to 1.0
  5109. * @returns a new Vector3 as the point
  5110. */
  5111. getPointAt(position: number): Vector3;
  5112. /**
  5113. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5114. * @param position the position of the point along this path, from 0.0 to 1.0
  5115. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5116. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5117. */
  5118. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5119. /**
  5120. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5121. * @param position the position of the point along this path, from 0.0 to 1.0
  5122. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5123. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5124. */
  5125. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5126. /**
  5127. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5128. * @param position the position of the point along this path, from 0.0 to 1.0
  5129. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5130. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5131. */
  5132. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5133. /**
  5134. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5135. * @param position the position of the point along this path, from 0.0 to 1.0
  5136. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5137. */
  5138. getDistanceAt(position: number): number;
  5139. /**
  5140. * Returns the array index of the previous point of an interpolated point along this path
  5141. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5142. * @returns the array index
  5143. */
  5144. getPreviousPointIndexAt(position: number): number;
  5145. /**
  5146. * 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)
  5147. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5148. * @returns the sub position
  5149. */
  5150. getSubPositionAt(position: number): number;
  5151. /**
  5152. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5153. * @param target the vector of which to get the closest position to
  5154. * @returns the position of the closest virtual point on this path to the target vector
  5155. */
  5156. getClosestPositionTo(target: Vector3): number;
  5157. /**
  5158. * Returns a sub path (slice) of this path
  5159. * @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
  5160. * @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
  5161. * @returns a sub path (slice) of this path
  5162. */
  5163. slice(start?: number, end?: number): Path3D;
  5164. /**
  5165. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5166. * @param path path which all values are copied into the curves points
  5167. * @param firstNormal which should be projected onto the curve
  5168. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5169. * @returns the same object updated.
  5170. */
  5171. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5172. private _compute;
  5173. private _getFirstNonNullVector;
  5174. private _getLastNonNullVector;
  5175. private _normalVector;
  5176. /**
  5177. * Updates the point at data for an interpolated point along this curve
  5178. * @param position the position of the point along this curve, from 0.0 to 1.0
  5179. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5180. * @returns the (updated) point at data
  5181. */
  5182. private _updatePointAtData;
  5183. /**
  5184. * Updates the point at data from the specified parameters
  5185. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5186. * @param point the interpolated point
  5187. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5188. */
  5189. private _setPointAtData;
  5190. /**
  5191. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5192. */
  5193. private _updateInterpolationMatrix;
  5194. }
  5195. /**
  5196. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5197. * A Curve3 is designed from a series of successive Vector3.
  5198. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5199. */
  5200. export class Curve3 {
  5201. private _points;
  5202. private _length;
  5203. /**
  5204. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5205. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5206. * @param v1 (Vector3) the control point
  5207. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5208. * @param nbPoints (integer) the wanted number of points in the curve
  5209. * @returns the created Curve3
  5210. */
  5211. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5212. /**
  5213. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5214. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5215. * @param v1 (Vector3) the first control point
  5216. * @param v2 (Vector3) the second control point
  5217. * @param v3 (Vector3) the end point of the Cubic Bezier
  5218. * @param nbPoints (integer) the wanted number of points in the curve
  5219. * @returns the created Curve3
  5220. */
  5221. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5222. /**
  5223. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5224. * @param p1 (Vector3) the origin point of the Hermite Spline
  5225. * @param t1 (Vector3) the tangent vector at the origin point
  5226. * @param p2 (Vector3) the end point of the Hermite Spline
  5227. * @param t2 (Vector3) the tangent vector at the end point
  5228. * @param nbPoints (integer) the wanted number of points in the curve
  5229. * @returns the created Curve3
  5230. */
  5231. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5232. /**
  5233. * Returns a Curve3 object along a CatmullRom Spline curve :
  5234. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5235. * @param nbPoints (integer) the wanted number of points between each curve control points
  5236. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5237. * @returns the created Curve3
  5238. */
  5239. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5240. /**
  5241. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5242. * A Curve3 is designed from a series of successive Vector3.
  5243. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5244. * @param points points which make up the curve
  5245. */
  5246. constructor(points: Vector3[]);
  5247. /**
  5248. * @returns the Curve3 stored array of successive Vector3
  5249. */
  5250. getPoints(): Vector3[];
  5251. /**
  5252. * @returns the computed length (float) of the curve.
  5253. */
  5254. length(): number;
  5255. /**
  5256. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5257. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5258. * curveA and curveB keep unchanged.
  5259. * @param curve the curve to continue from this curve
  5260. * @returns the newly constructed curve
  5261. */
  5262. continue(curve: DeepImmutable<Curve3>): Curve3;
  5263. private _computeLength;
  5264. }
  5265. }
  5266. declare module BABYLON {
  5267. /**
  5268. * This represents the main contract an easing function should follow.
  5269. * Easing functions are used throughout the animation system.
  5270. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5271. */
  5272. export interface IEasingFunction {
  5273. /**
  5274. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5275. * of the easing function.
  5276. * The link below provides some of the most common examples of easing functions.
  5277. * @see https://easings.net/
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Base class used for every default easing function.
  5285. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5286. */
  5287. export class EasingFunction implements IEasingFunction {
  5288. /**
  5289. * Interpolation follows the mathematical formula associated with the easing function.
  5290. */
  5291. static readonly EASINGMODE_EASEIN: number;
  5292. /**
  5293. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5294. */
  5295. static readonly EASINGMODE_EASEOUT: number;
  5296. /**
  5297. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5298. */
  5299. static readonly EASINGMODE_EASEINOUT: number;
  5300. private _easingMode;
  5301. /**
  5302. * Sets the easing mode of the current function.
  5303. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5304. */
  5305. setEasingMode(easingMode: number): void;
  5306. /**
  5307. * Gets the current easing mode.
  5308. * @returns the easing mode
  5309. */
  5310. getEasingMode(): number;
  5311. /**
  5312. * @hidden
  5313. */
  5314. easeInCore(gradient: number): number;
  5315. /**
  5316. * Given an input gradient between 0 and 1, this returns the corresponding value
  5317. * of the easing function.
  5318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5319. * @returns the corresponding value on the curve defined by the easing function
  5320. */
  5321. ease(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with a circle shape (see link below).
  5325. * @see https://easings.net/#easeInCirc
  5326. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class CircleEase extends EasingFunction implements IEasingFunction {
  5329. /** @hidden */
  5330. easeInCore(gradient: number): number;
  5331. }
  5332. /**
  5333. * Easing function with a ease back shape (see link below).
  5334. * @see https://easings.net/#easeInBack
  5335. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5336. */
  5337. export class BackEase extends EasingFunction implements IEasingFunction {
  5338. /** Defines the amplitude of the function */
  5339. amplitude: number;
  5340. /**
  5341. * Instantiates a back ease easing
  5342. * @see https://easings.net/#easeInBack
  5343. * @param amplitude Defines the amplitude of the function
  5344. */
  5345. constructor(
  5346. /** Defines the amplitude of the function */
  5347. amplitude?: number);
  5348. /** @hidden */
  5349. easeInCore(gradient: number): number;
  5350. }
  5351. /**
  5352. * Easing function with a bouncing shape (see link below).
  5353. * @see https://easings.net/#easeInBounce
  5354. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5355. */
  5356. export class BounceEase extends EasingFunction implements IEasingFunction {
  5357. /** Defines the number of bounces */
  5358. bounces: number;
  5359. /** Defines the amplitude of the bounce */
  5360. bounciness: number;
  5361. /**
  5362. * Instantiates a bounce easing
  5363. * @see https://easings.net/#easeInBounce
  5364. * @param bounces Defines the number of bounces
  5365. * @param bounciness Defines the amplitude of the bounce
  5366. */
  5367. constructor(
  5368. /** Defines the number of bounces */
  5369. bounces?: number,
  5370. /** Defines the amplitude of the bounce */
  5371. bounciness?: number);
  5372. /** @hidden */
  5373. easeInCore(gradient: number): number;
  5374. }
  5375. /**
  5376. * Easing function with a power of 3 shape (see link below).
  5377. * @see https://easings.net/#easeInCubic
  5378. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5379. */
  5380. export class CubicEase extends EasingFunction implements IEasingFunction {
  5381. /** @hidden */
  5382. easeInCore(gradient: number): number;
  5383. }
  5384. /**
  5385. * Easing function with an elastic shape (see link below).
  5386. * @see https://easings.net/#easeInElastic
  5387. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5388. */
  5389. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5390. /** Defines the number of oscillations*/
  5391. oscillations: number;
  5392. /** Defines the amplitude of the oscillations*/
  5393. springiness: number;
  5394. /**
  5395. * Instantiates an elastic easing function
  5396. * @see https://easings.net/#easeInElastic
  5397. * @param oscillations Defines the number of oscillations
  5398. * @param springiness Defines the amplitude of the oscillations
  5399. */
  5400. constructor(
  5401. /** Defines the number of oscillations*/
  5402. oscillations?: number,
  5403. /** Defines the amplitude of the oscillations*/
  5404. springiness?: number);
  5405. /** @hidden */
  5406. easeInCore(gradient: number): number;
  5407. }
  5408. /**
  5409. * Easing function with an exponential shape (see link below).
  5410. * @see https://easings.net/#easeInExpo
  5411. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5412. */
  5413. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5414. /** Defines the exponent of the function */
  5415. exponent: number;
  5416. /**
  5417. * Instantiates an exponential easing function
  5418. * @see https://easings.net/#easeInExpo
  5419. * @param exponent Defines the exponent of the function
  5420. */
  5421. constructor(
  5422. /** Defines the exponent of the function */
  5423. exponent?: number);
  5424. /** @hidden */
  5425. easeInCore(gradient: number): number;
  5426. }
  5427. /**
  5428. * Easing function with a power shape (see link below).
  5429. * @see https://easings.net/#easeInQuad
  5430. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5431. */
  5432. export class PowerEase extends EasingFunction implements IEasingFunction {
  5433. /** Defines the power of the function */
  5434. power: number;
  5435. /**
  5436. * Instantiates an power base easing function
  5437. * @see https://easings.net/#easeInQuad
  5438. * @param power Defines the power of the function
  5439. */
  5440. constructor(
  5441. /** Defines the power of the function */
  5442. power?: number);
  5443. /** @hidden */
  5444. easeInCore(gradient: number): number;
  5445. }
  5446. /**
  5447. * Easing function with a power of 2 shape (see link below).
  5448. * @see https://easings.net/#easeInQuad
  5449. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5450. */
  5451. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5452. /** @hidden */
  5453. easeInCore(gradient: number): number;
  5454. }
  5455. /**
  5456. * Easing function with a power of 4 shape (see link below).
  5457. * @see https://easings.net/#easeInQuart
  5458. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5459. */
  5460. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5461. /** @hidden */
  5462. easeInCore(gradient: number): number;
  5463. }
  5464. /**
  5465. * Easing function with a power of 5 shape (see link below).
  5466. * @see https://easings.net/#easeInQuint
  5467. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5468. */
  5469. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5470. /** @hidden */
  5471. easeInCore(gradient: number): number;
  5472. }
  5473. /**
  5474. * Easing function with a sin shape (see link below).
  5475. * @see https://easings.net/#easeInSine
  5476. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5477. */
  5478. export class SineEase extends EasingFunction implements IEasingFunction {
  5479. /** @hidden */
  5480. easeInCore(gradient: number): number;
  5481. }
  5482. /**
  5483. * Easing function with a bezier shape (see link below).
  5484. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5485. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5486. */
  5487. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5488. /** Defines the x component of the start tangent in the bezier curve */
  5489. x1: number;
  5490. /** Defines the y component of the start tangent in the bezier curve */
  5491. y1: number;
  5492. /** Defines the x component of the end tangent in the bezier curve */
  5493. x2: number;
  5494. /** Defines the y component of the end tangent in the bezier curve */
  5495. y2: number;
  5496. /**
  5497. * Instantiates a bezier function
  5498. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5499. * @param x1 Defines the x component of the start tangent in the bezier curve
  5500. * @param y1 Defines the y component of the start tangent in the bezier curve
  5501. * @param x2 Defines the x component of the end tangent in the bezier curve
  5502. * @param y2 Defines the y component of the end tangent in the bezier curve
  5503. */
  5504. constructor(
  5505. /** Defines the x component of the start tangent in the bezier curve */
  5506. x1?: number,
  5507. /** Defines the y component of the start tangent in the bezier curve */
  5508. y1?: number,
  5509. /** Defines the x component of the end tangent in the bezier curve */
  5510. x2?: number,
  5511. /** Defines the y component of the end tangent in the bezier curve */
  5512. y2?: number);
  5513. /** @hidden */
  5514. easeInCore(gradient: number): number;
  5515. }
  5516. }
  5517. declare module BABYLON {
  5518. /**
  5519. * Class used to hold a RBG color
  5520. */
  5521. export class Color3 {
  5522. /**
  5523. * Defines the red component (between 0 and 1, default is 0)
  5524. */
  5525. r: number;
  5526. /**
  5527. * Defines the green component (between 0 and 1, default is 0)
  5528. */
  5529. g: number;
  5530. /**
  5531. * Defines the blue component (between 0 and 1, default is 0)
  5532. */
  5533. b: number;
  5534. /**
  5535. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5536. * @param r defines the red component (between 0 and 1, default is 0)
  5537. * @param g defines the green component (between 0 and 1, default is 0)
  5538. * @param b defines the blue component (between 0 and 1, default is 0)
  5539. */
  5540. constructor(
  5541. /**
  5542. * Defines the red component (between 0 and 1, default is 0)
  5543. */
  5544. r?: number,
  5545. /**
  5546. * Defines the green component (between 0 and 1, default is 0)
  5547. */
  5548. g?: number,
  5549. /**
  5550. * Defines the blue component (between 0 and 1, default is 0)
  5551. */
  5552. b?: number);
  5553. /**
  5554. * Creates a string with the Color3 current values
  5555. * @returns the string representation of the Color3 object
  5556. */
  5557. toString(): string;
  5558. /**
  5559. * Returns the string "Color3"
  5560. * @returns "Color3"
  5561. */
  5562. getClassName(): string;
  5563. /**
  5564. * Compute the Color3 hash code
  5565. * @returns an unique number that can be used to hash Color3 objects
  5566. */
  5567. getHashCode(): number;
  5568. /**
  5569. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5570. * @param array defines the array where to store the r,g,b components
  5571. * @param index defines an optional index in the target array to define where to start storing values
  5572. * @returns the current Color3 object
  5573. */
  5574. toArray(array: FloatArray, index?: number): Color3;
  5575. /**
  5576. * Update the current color with values stored in an array from the starting index of the given array
  5577. * @param array defines the source array
  5578. * @param offset defines an offset in the source array
  5579. * @returns the current Color3 object
  5580. */
  5581. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5582. /**
  5583. * Returns a new Color4 object from the current Color3 and the given alpha
  5584. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5585. * @returns a new Color4 object
  5586. */
  5587. toColor4(alpha?: number): Color4;
  5588. /**
  5589. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5590. * @returns the new array
  5591. */
  5592. asArray(): number[];
  5593. /**
  5594. * Returns the luminance value
  5595. * @returns a float value
  5596. */
  5597. toLuminance(): number;
  5598. /**
  5599. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5600. * @param otherColor defines the second operand
  5601. * @returns the new Color3 object
  5602. */
  5603. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5604. /**
  5605. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5606. * @param otherColor defines the second operand
  5607. * @param result defines the Color3 object where to store the result
  5608. * @returns the current Color3
  5609. */
  5610. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5611. /**
  5612. * Determines equality between Color3 objects
  5613. * @param otherColor defines the second operand
  5614. * @returns true if the rgb values are equal to the given ones
  5615. */
  5616. equals(otherColor: DeepImmutable<Color3>): boolean;
  5617. /**
  5618. * Determines equality between the current Color3 object and a set of r,b,g values
  5619. * @param r defines the red component to check
  5620. * @param g defines the green component to check
  5621. * @param b defines the blue component to check
  5622. * @returns true if the rgb values are equal to the given ones
  5623. */
  5624. equalsFloats(r: number, g: number, b: number): boolean;
  5625. /**
  5626. * Multiplies in place each rgb value by scale
  5627. * @param scale defines the scaling factor
  5628. * @returns the updated Color3
  5629. */
  5630. scale(scale: number): Color3;
  5631. /**
  5632. * Multiplies the rgb values by scale and stores the result into "result"
  5633. * @param scale defines the scaling factor
  5634. * @param result defines the Color3 object where to store the result
  5635. * @returns the unmodified current Color3
  5636. */
  5637. scaleToRef(scale: number, result: Color3): Color3;
  5638. /**
  5639. * Scale the current Color3 values by a factor and add the result to a given Color3
  5640. * @param scale defines the scale factor
  5641. * @param result defines color to store the result into
  5642. * @returns the unmodified current Color3
  5643. */
  5644. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5645. /**
  5646. * Clamps the rgb values by the min and max values and stores the result into "result"
  5647. * @param min defines minimum clamping value (default is 0)
  5648. * @param max defines maximum clamping value (default is 1)
  5649. * @param result defines color to store the result into
  5650. * @returns the original Color3
  5651. */
  5652. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5653. /**
  5654. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5655. * @param otherColor defines the second operand
  5656. * @returns the new Color3
  5657. */
  5658. add(otherColor: DeepImmutable<Color3>): Color3;
  5659. /**
  5660. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5661. * @param otherColor defines the second operand
  5662. * @param result defines Color3 object to store the result into
  5663. * @returns the unmodified current Color3
  5664. */
  5665. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5666. /**
  5667. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5668. * @param otherColor defines the second operand
  5669. * @returns the new Color3
  5670. */
  5671. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5672. /**
  5673. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5674. * @param otherColor defines the second operand
  5675. * @param result defines Color3 object to store the result into
  5676. * @returns the unmodified current Color3
  5677. */
  5678. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5679. /**
  5680. * Copy the current object
  5681. * @returns a new Color3 copied the current one
  5682. */
  5683. clone(): Color3;
  5684. /**
  5685. * Copies the rgb values from the source in the current Color3
  5686. * @param source defines the source Color3 object
  5687. * @returns the updated Color3 object
  5688. */
  5689. copyFrom(source: DeepImmutable<Color3>): Color3;
  5690. /**
  5691. * Updates the Color3 rgb values from the given floats
  5692. * @param r defines the red component to read from
  5693. * @param g defines the green component to read from
  5694. * @param b defines the blue component to read from
  5695. * @returns the current Color3 object
  5696. */
  5697. copyFromFloats(r: number, g: number, b: number): Color3;
  5698. /**
  5699. * Updates the Color3 rgb values from the given floats
  5700. * @param r defines the red component to read from
  5701. * @param g defines the green component to read from
  5702. * @param b defines the blue component to read from
  5703. * @returns the current Color3 object
  5704. */
  5705. set(r: number, g: number, b: number): Color3;
  5706. /**
  5707. * Compute the Color3 hexadecimal code as a string
  5708. * @returns a string containing the hexadecimal representation of the Color3 object
  5709. */
  5710. toHexString(): string;
  5711. /**
  5712. * Computes a new Color3 converted from the current one to linear space
  5713. * @returns a new Color3 object
  5714. */
  5715. toLinearSpace(): Color3;
  5716. /**
  5717. * Converts current color in rgb space to HSV values
  5718. * @returns a new color3 representing the HSV values
  5719. */
  5720. toHSV(): Color3;
  5721. /**
  5722. * Converts current color in rgb space to HSV values
  5723. * @param result defines the Color3 where to store the HSV values
  5724. */
  5725. toHSVToRef(result: Color3): void;
  5726. /**
  5727. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5728. * @param convertedColor defines the Color3 object where to store the linear space version
  5729. * @returns the unmodified Color3
  5730. */
  5731. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5732. /**
  5733. * Computes a new Color3 converted from the current one to gamma space
  5734. * @returns a new Color3 object
  5735. */
  5736. toGammaSpace(): Color3;
  5737. /**
  5738. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5739. * @param convertedColor defines the Color3 object where to store the gamma space version
  5740. * @returns the unmodified Color3
  5741. */
  5742. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5743. private static _BlackReadOnly;
  5744. /**
  5745. * Convert Hue, saturation and value to a Color3 (RGB)
  5746. * @param hue defines the hue
  5747. * @param saturation defines the saturation
  5748. * @param value defines the value
  5749. * @param result defines the Color3 where to store the RGB values
  5750. */
  5751. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5752. /**
  5753. * Creates a new Color3 from the string containing valid hexadecimal values
  5754. * @param hex defines a string containing valid hexadecimal values
  5755. * @returns a new Color3 object
  5756. */
  5757. static FromHexString(hex: string): Color3;
  5758. /**
  5759. * Creates a new Color3 from the starting index of the given array
  5760. * @param array defines the source array
  5761. * @param offset defines an offset in the source array
  5762. * @returns a new Color3 object
  5763. */
  5764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5765. /**
  5766. * Creates a new Color3 from the starting index element of the given array
  5767. * @param array defines the source array to read from
  5768. * @param offset defines the offset in the source array
  5769. * @param result defines the target Color3 object
  5770. */
  5771. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5772. /**
  5773. * Creates a new Color3 from integer values (< 256)
  5774. * @param r defines the red component to read from (value between 0 and 255)
  5775. * @param g defines the green component to read from (value between 0 and 255)
  5776. * @param b defines the blue component to read from (value between 0 and 255)
  5777. * @returns a new Color3 object
  5778. */
  5779. static FromInts(r: number, g: number, b: number): Color3;
  5780. /**
  5781. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5782. * @param start defines the start Color3 value
  5783. * @param end defines the end Color3 value
  5784. * @param amount defines the gradient value between start and end
  5785. * @returns a new Color3 object
  5786. */
  5787. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5788. /**
  5789. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5790. * @param left defines the start value
  5791. * @param right defines the end value
  5792. * @param amount defines the gradient factor
  5793. * @param result defines the Color3 object where to store the result
  5794. */
  5795. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5796. /**
  5797. * Returns a Color3 value containing a red color
  5798. * @returns a new Color3 object
  5799. */
  5800. static Red(): Color3;
  5801. /**
  5802. * Returns a Color3 value containing a green color
  5803. * @returns a new Color3 object
  5804. */
  5805. static Green(): Color3;
  5806. /**
  5807. * Returns a Color3 value containing a blue color
  5808. * @returns a new Color3 object
  5809. */
  5810. static Blue(): Color3;
  5811. /**
  5812. * Returns a Color3 value containing a black color
  5813. * @returns a new Color3 object
  5814. */
  5815. static Black(): Color3;
  5816. /**
  5817. * Gets a Color3 value containing a black color that must not be updated
  5818. */
  5819. static get BlackReadOnly(): DeepImmutable<Color3>;
  5820. /**
  5821. * Returns a Color3 value containing a white color
  5822. * @returns a new Color3 object
  5823. */
  5824. static White(): Color3;
  5825. /**
  5826. * Returns a Color3 value containing a purple color
  5827. * @returns a new Color3 object
  5828. */
  5829. static Purple(): Color3;
  5830. /**
  5831. * Returns a Color3 value containing a magenta color
  5832. * @returns a new Color3 object
  5833. */
  5834. static Magenta(): Color3;
  5835. /**
  5836. * Returns a Color3 value containing a yellow color
  5837. * @returns a new Color3 object
  5838. */
  5839. static Yellow(): Color3;
  5840. /**
  5841. * Returns a Color3 value containing a gray color
  5842. * @returns a new Color3 object
  5843. */
  5844. static Gray(): Color3;
  5845. /**
  5846. * Returns a Color3 value containing a teal color
  5847. * @returns a new Color3 object
  5848. */
  5849. static Teal(): Color3;
  5850. /**
  5851. * Returns a Color3 value containing a random color
  5852. * @returns a new Color3 object
  5853. */
  5854. static Random(): Color3;
  5855. }
  5856. /**
  5857. * Class used to hold a RBGA color
  5858. */
  5859. export class Color4 {
  5860. /**
  5861. * Defines the red component (between 0 and 1, default is 0)
  5862. */
  5863. r: number;
  5864. /**
  5865. * Defines the green component (between 0 and 1, default is 0)
  5866. */
  5867. g: number;
  5868. /**
  5869. * Defines the blue component (between 0 and 1, default is 0)
  5870. */
  5871. b: number;
  5872. /**
  5873. * Defines the alpha component (between 0 and 1, default is 1)
  5874. */
  5875. a: number;
  5876. /**
  5877. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5878. * @param r defines the red component (between 0 and 1, default is 0)
  5879. * @param g defines the green component (between 0 and 1, default is 0)
  5880. * @param b defines the blue component (between 0 and 1, default is 0)
  5881. * @param a defines the alpha component (between 0 and 1, default is 1)
  5882. */
  5883. constructor(
  5884. /**
  5885. * Defines the red component (between 0 and 1, default is 0)
  5886. */
  5887. r?: number,
  5888. /**
  5889. * Defines the green component (between 0 and 1, default is 0)
  5890. */
  5891. g?: number,
  5892. /**
  5893. * Defines the blue component (between 0 and 1, default is 0)
  5894. */
  5895. b?: number,
  5896. /**
  5897. * Defines the alpha component (between 0 and 1, default is 1)
  5898. */
  5899. a?: number);
  5900. /**
  5901. * Adds in place the given Color4 values to the current Color4 object
  5902. * @param right defines the second operand
  5903. * @returns the current updated Color4 object
  5904. */
  5905. addInPlace(right: DeepImmutable<Color4>): Color4;
  5906. /**
  5907. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5908. * @returns the new array
  5909. */
  5910. asArray(): number[];
  5911. /**
  5912. * Stores from the starting index in the given array the Color4 successive values
  5913. * @param array defines the array where to store the r,g,b components
  5914. * @param index defines an optional index in the target array to define where to start storing values
  5915. * @returns the current Color4 object
  5916. */
  5917. toArray(array: number[], index?: number): Color4;
  5918. /**
  5919. * Update the current color with values stored in an array from the starting index of the given array
  5920. * @param array defines the source array
  5921. * @param offset defines an offset in the source array
  5922. * @returns the current Color4 object
  5923. */
  5924. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5925. /**
  5926. * Determines equality between Color4 objects
  5927. * @param otherColor defines the second operand
  5928. * @returns true if the rgba values are equal to the given ones
  5929. */
  5930. equals(otherColor: DeepImmutable<Color4>): boolean;
  5931. /**
  5932. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5933. * @param right defines the second operand
  5934. * @returns a new Color4 object
  5935. */
  5936. add(right: DeepImmutable<Color4>): Color4;
  5937. /**
  5938. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5939. * @param right defines the second operand
  5940. * @returns a new Color4 object
  5941. */
  5942. subtract(right: DeepImmutable<Color4>): Color4;
  5943. /**
  5944. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5945. * @param right defines the second operand
  5946. * @param result defines the Color4 object where to store the result
  5947. * @returns the current Color4 object
  5948. */
  5949. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5950. /**
  5951. * Creates a new Color4 with the current Color4 values multiplied by scale
  5952. * @param scale defines the scaling factor to apply
  5953. * @returns a new Color4 object
  5954. */
  5955. scale(scale: number): Color4;
  5956. /**
  5957. * Multiplies the current Color4 values by scale and stores the result in "result"
  5958. * @param scale defines the scaling factor to apply
  5959. * @param result defines the Color4 object where to store the result
  5960. * @returns the current unmodified Color4
  5961. */
  5962. scaleToRef(scale: number, result: Color4): Color4;
  5963. /**
  5964. * Scale the current Color4 values by a factor and add the result to a given Color4
  5965. * @param scale defines the scale factor
  5966. * @param result defines the Color4 object where to store the result
  5967. * @returns the unmodified current Color4
  5968. */
  5969. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5970. /**
  5971. * Clamps the rgb values by the min and max values and stores the result into "result"
  5972. * @param min defines minimum clamping value (default is 0)
  5973. * @param max defines maximum clamping value (default is 1)
  5974. * @param result defines color to store the result into.
  5975. * @returns the cuurent Color4
  5976. */
  5977. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5978. /**
  5979. * Multipy an Color4 value by another and return a new Color4 object
  5980. * @param color defines the Color4 value to multiply by
  5981. * @returns a new Color4 object
  5982. */
  5983. multiply(color: Color4): Color4;
  5984. /**
  5985. * Multipy a Color4 value by another and push the result in a reference value
  5986. * @param color defines the Color4 value to multiply by
  5987. * @param result defines the Color4 to fill the result in
  5988. * @returns the result Color4
  5989. */
  5990. multiplyToRef(color: Color4, result: Color4): Color4;
  5991. /**
  5992. * Creates a string with the Color4 current values
  5993. * @returns the string representation of the Color4 object
  5994. */
  5995. toString(): string;
  5996. /**
  5997. * Returns the string "Color4"
  5998. * @returns "Color4"
  5999. */
  6000. getClassName(): string;
  6001. /**
  6002. * Compute the Color4 hash code
  6003. * @returns an unique number that can be used to hash Color4 objects
  6004. */
  6005. getHashCode(): number;
  6006. /**
  6007. * Creates a new Color4 copied from the current one
  6008. * @returns a new Color4 object
  6009. */
  6010. clone(): Color4;
  6011. /**
  6012. * Copies the given Color4 values into the current one
  6013. * @param source defines the source Color4 object
  6014. * @returns the current updated Color4 object
  6015. */
  6016. copyFrom(source: Color4): Color4;
  6017. /**
  6018. * Copies the given float values into the current one
  6019. * @param r defines the red component to read from
  6020. * @param g defines the green component to read from
  6021. * @param b defines the blue component to read from
  6022. * @param a defines the alpha component to read from
  6023. * @returns the current updated Color4 object
  6024. */
  6025. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6026. /**
  6027. * Copies the given float values into the current one
  6028. * @param r defines the red component to read from
  6029. * @param g defines the green component to read from
  6030. * @param b defines the blue component to read from
  6031. * @param a defines the alpha component to read from
  6032. * @returns the current updated Color4 object
  6033. */
  6034. set(r: number, g: number, b: number, a: number): Color4;
  6035. /**
  6036. * Compute the Color4 hexadecimal code as a string
  6037. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6038. * @returns a string containing the hexadecimal representation of the Color4 object
  6039. */
  6040. toHexString(returnAsColor3?: boolean): string;
  6041. /**
  6042. * Computes a new Color4 converted from the current one to linear space
  6043. * @returns a new Color4 object
  6044. */
  6045. toLinearSpace(): Color4;
  6046. /**
  6047. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6048. * @param convertedColor defines the Color4 object where to store the linear space version
  6049. * @returns the unmodified Color4
  6050. */
  6051. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6052. /**
  6053. * Computes a new Color4 converted from the current one to gamma space
  6054. * @returns a new Color4 object
  6055. */
  6056. toGammaSpace(): Color4;
  6057. /**
  6058. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6059. * @param convertedColor defines the Color4 object where to store the gamma space version
  6060. * @returns the unmodified Color4
  6061. */
  6062. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6063. /**
  6064. * Creates a new Color4 from the string containing valid hexadecimal values
  6065. * @param hex defines a string containing valid hexadecimal values
  6066. * @returns a new Color4 object
  6067. */
  6068. static FromHexString(hex: string): Color4;
  6069. /**
  6070. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6071. * @param left defines the start value
  6072. * @param right defines the end value
  6073. * @param amount defines the gradient factor
  6074. * @returns a new Color4 object
  6075. */
  6076. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6077. /**
  6078. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6079. * @param left defines the start value
  6080. * @param right defines the end value
  6081. * @param amount defines the gradient factor
  6082. * @param result defines the Color4 object where to store data
  6083. */
  6084. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6085. /**
  6086. * Creates a new Color4 from a Color3 and an alpha value
  6087. * @param color3 defines the source Color3 to read from
  6088. * @param alpha defines the alpha component (1.0 by default)
  6089. * @returns a new Color4 object
  6090. */
  6091. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6092. /**
  6093. * Creates a new Color4 from the starting index element of the given array
  6094. * @param array defines the source array to read from
  6095. * @param offset defines the offset in the source array
  6096. * @returns a new Color4 object
  6097. */
  6098. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6099. /**
  6100. * Creates a new Color4 from the starting index element of the given array
  6101. * @param array defines the source array to read from
  6102. * @param offset defines the offset in the source array
  6103. * @param result defines the target Color4 object
  6104. */
  6105. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6106. /**
  6107. * Creates a new Color3 from integer values (< 256)
  6108. * @param r defines the red component to read from (value between 0 and 255)
  6109. * @param g defines the green component to read from (value between 0 and 255)
  6110. * @param b defines the blue component to read from (value between 0 and 255)
  6111. * @param a defines the alpha component to read from (value between 0 and 255)
  6112. * @returns a new Color3 object
  6113. */
  6114. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6115. /**
  6116. * Check the content of a given array and convert it to an array containing RGBA data
  6117. * If the original array was already containing count * 4 values then it is returned directly
  6118. * @param colors defines the array to check
  6119. * @param count defines the number of RGBA data to expect
  6120. * @returns an array containing count * 4 values (RGBA)
  6121. */
  6122. static CheckColors4(colors: number[], count: number): number[];
  6123. }
  6124. /**
  6125. * @hidden
  6126. */
  6127. export class TmpColors {
  6128. static Color3: Color3[];
  6129. static Color4: Color4[];
  6130. }
  6131. }
  6132. declare module BABYLON {
  6133. /**
  6134. * Defines an interface which represents an animation key frame
  6135. */
  6136. export interface IAnimationKey {
  6137. /**
  6138. * Frame of the key frame
  6139. */
  6140. frame: number;
  6141. /**
  6142. * Value at the specifies key frame
  6143. */
  6144. value: any;
  6145. /**
  6146. * The input tangent for the cubic hermite spline
  6147. */
  6148. inTangent?: any;
  6149. /**
  6150. * The output tangent for the cubic hermite spline
  6151. */
  6152. outTangent?: any;
  6153. /**
  6154. * The animation interpolation type
  6155. */
  6156. interpolation?: AnimationKeyInterpolation;
  6157. }
  6158. /**
  6159. * Enum for the animation key frame interpolation type
  6160. */
  6161. export enum AnimationKeyInterpolation {
  6162. /**
  6163. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6164. */
  6165. STEP = 1
  6166. }
  6167. }
  6168. declare module BABYLON {
  6169. /**
  6170. * Represents the range of an animation
  6171. */
  6172. export class AnimationRange {
  6173. /**The name of the animation range**/
  6174. name: string;
  6175. /**The starting frame of the animation */
  6176. from: number;
  6177. /**The ending frame of the animation*/
  6178. to: number;
  6179. /**
  6180. * Initializes the range of an animation
  6181. * @param name The name of the animation range
  6182. * @param from The starting frame of the animation
  6183. * @param to The ending frame of the animation
  6184. */
  6185. constructor(
  6186. /**The name of the animation range**/
  6187. name: string,
  6188. /**The starting frame of the animation */
  6189. from: number,
  6190. /**The ending frame of the animation*/
  6191. to: number);
  6192. /**
  6193. * Makes a copy of the animation range
  6194. * @returns A copy of the animation range
  6195. */
  6196. clone(): AnimationRange;
  6197. }
  6198. }
  6199. declare module BABYLON {
  6200. /**
  6201. * Composed of a frame, and an action function
  6202. */
  6203. export class AnimationEvent {
  6204. /** The frame for which the event is triggered **/
  6205. frame: number;
  6206. /** The event to perform when triggered **/
  6207. action: (currentFrame: number) => void;
  6208. /** Specifies if the event should be triggered only once**/
  6209. onlyOnce?: boolean | undefined;
  6210. /**
  6211. * Specifies if the animation event is done
  6212. */
  6213. isDone: boolean;
  6214. /**
  6215. * Initializes the animation event
  6216. * @param frame The frame for which the event is triggered
  6217. * @param action The event to perform when triggered
  6218. * @param onlyOnce Specifies if the event should be triggered only once
  6219. */
  6220. constructor(
  6221. /** The frame for which the event is triggered **/
  6222. frame: number,
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void,
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined);
  6227. /** @hidden */
  6228. _clone(): AnimationEvent;
  6229. }
  6230. }
  6231. declare module BABYLON {
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module BABYLON {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module BABYLON {
  6383. /**
  6384. * @ignore
  6385. * This is a list of all the different input types that are available in the application.
  6386. * Fo instance: ArcRotateCameraGamepadInput...
  6387. */
  6388. export var CameraInputTypes: {};
  6389. /**
  6390. * This is the contract to implement in order to create a new input class.
  6391. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6392. */
  6393. export interface ICameraInput<TCamera extends Camera> {
  6394. /**
  6395. * Defines the camera the input is attached to.
  6396. */
  6397. camera: Nullable<TCamera>;
  6398. /**
  6399. * Gets the class name of the current intput.
  6400. * @returns the class name
  6401. */
  6402. getClassName(): string;
  6403. /**
  6404. * Get the friendly name associated with the input class.
  6405. * @returns the input friendly name
  6406. */
  6407. getSimpleName(): string;
  6408. /**
  6409. * Attach the input controls to a specific dom element to get the input from.
  6410. * @param element Defines the element the controls should be listened from
  6411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6412. */
  6413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6414. /**
  6415. * Detach the current controls from the specified dom element.
  6416. * @param element Defines the element to stop listening the inputs from
  6417. */
  6418. detachControl(element: Nullable<HTMLElement>): void;
  6419. /**
  6420. * Update the current camera state depending on the inputs that have been used this frame.
  6421. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6422. */
  6423. checkInputs?: () => void;
  6424. }
  6425. /**
  6426. * Represents a map of input types to input instance or input index to input instance.
  6427. */
  6428. export interface CameraInputsMap<TCamera extends Camera> {
  6429. /**
  6430. * Accessor to the input by input type.
  6431. */
  6432. [name: string]: ICameraInput<TCamera>;
  6433. /**
  6434. * Accessor to the input by input index.
  6435. */
  6436. [idx: number]: ICameraInput<TCamera>;
  6437. }
  6438. /**
  6439. * This represents the input manager used within a camera.
  6440. * It helps dealing with all the different kind of input attached to a camera.
  6441. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6442. */
  6443. export class CameraInputsManager<TCamera extends Camera> {
  6444. /**
  6445. * Defines the list of inputs attahed to the camera.
  6446. */
  6447. attached: CameraInputsMap<TCamera>;
  6448. /**
  6449. * Defines the dom element the camera is collecting inputs from.
  6450. * This is null if the controls have not been attached.
  6451. */
  6452. attachedElement: Nullable<HTMLElement>;
  6453. /**
  6454. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6455. */
  6456. noPreventDefault: boolean;
  6457. /**
  6458. * Defined the camera the input manager belongs to.
  6459. */
  6460. camera: TCamera;
  6461. /**
  6462. * Update the current camera state depending on the inputs that have been used this frame.
  6463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6464. */
  6465. checkInputs: () => void;
  6466. /**
  6467. * Instantiate a new Camera Input Manager.
  6468. * @param camera Defines the camera the input manager blongs to
  6469. */
  6470. constructor(camera: TCamera);
  6471. /**
  6472. * Add an input method to a camera
  6473. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6474. * @param input camera input method
  6475. */
  6476. add(input: ICameraInput<TCamera>): void;
  6477. /**
  6478. * Remove a specific input method from a camera
  6479. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6480. * @param inputToRemove camera input method
  6481. */
  6482. remove(inputToRemove: ICameraInput<TCamera>): void;
  6483. /**
  6484. * Remove a specific input type from a camera
  6485. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6486. * @param inputType the type of the input to remove
  6487. */
  6488. removeByType(inputType: string): void;
  6489. private _addCheckInputs;
  6490. /**
  6491. * Attach the input controls to the currently attached dom element to listen the events from.
  6492. * @param input Defines the input to attach
  6493. */
  6494. attachInput(input: ICameraInput<TCamera>): void;
  6495. /**
  6496. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6497. * @param element Defines the dom element to collect the events from
  6498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6499. */
  6500. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6501. /**
  6502. * Detach the current manager inputs controls from a specific dom element.
  6503. * @param element Defines the dom element to collect the events from
  6504. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6505. */
  6506. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6507. /**
  6508. * Rebuild the dynamic inputCheck function from the current list of
  6509. * defined inputs in the manager.
  6510. */
  6511. rebuildInputCheck(): void;
  6512. /**
  6513. * Remove all attached input methods from a camera
  6514. */
  6515. clear(): void;
  6516. /**
  6517. * Serialize the current input manager attached to a camera.
  6518. * This ensures than once parsed,
  6519. * the input associated to the camera will be identical to the current ones
  6520. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6521. */
  6522. serialize(serializedCamera: any): void;
  6523. /**
  6524. * Parses an input manager serialized JSON to restore the previous list of inputs
  6525. * and states associated to a camera.
  6526. * @param parsedCamera Defines the JSON to parse
  6527. */
  6528. parse(parsedCamera: any): void;
  6529. }
  6530. }
  6531. declare module BABYLON {
  6532. /**
  6533. * Class used to store data that will be store in GPU memory
  6534. */
  6535. export class Buffer {
  6536. private _engine;
  6537. private _buffer;
  6538. /** @hidden */
  6539. _data: Nullable<DataArray>;
  6540. private _updatable;
  6541. private _instanced;
  6542. private _divisor;
  6543. /**
  6544. * Gets the byte stride.
  6545. */
  6546. readonly byteStride: number;
  6547. /**
  6548. * Constructor
  6549. * @param engine the engine
  6550. * @param data the data to use for this buffer
  6551. * @param updatable whether the data is updatable
  6552. * @param stride the stride (optional)
  6553. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6554. * @param instanced whether the buffer is instanced (optional)
  6555. * @param useBytes set to true if the stride in in bytes (optional)
  6556. * @param divisor sets an optional divisor for instances (1 by default)
  6557. */
  6558. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6559. /**
  6560. * Create a new VertexBuffer based on the current buffer
  6561. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6562. * @param offset defines offset in the buffer (0 by default)
  6563. * @param size defines the size in floats of attributes (position is 3 for instance)
  6564. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6565. * @param instanced defines if the vertex buffer contains indexed data
  6566. * @param useBytes defines if the offset and stride are in bytes *
  6567. * @param divisor sets an optional divisor for instances (1 by default)
  6568. * @returns the new vertex buffer
  6569. */
  6570. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6571. /**
  6572. * Gets a boolean indicating if the Buffer is updatable?
  6573. * @returns true if the buffer is updatable
  6574. */
  6575. isUpdatable(): boolean;
  6576. /**
  6577. * Gets current buffer's data
  6578. * @returns a DataArray or null
  6579. */
  6580. getData(): Nullable<DataArray>;
  6581. /**
  6582. * Gets underlying native buffer
  6583. * @returns underlying native buffer
  6584. */
  6585. getBuffer(): Nullable<DataBuffer>;
  6586. /**
  6587. * Gets the stride in float32 units (i.e. byte stride / 4).
  6588. * May not be an integer if the byte stride is not divisible by 4.
  6589. * @returns the stride in float32 units
  6590. * @deprecated Please use byteStride instead.
  6591. */
  6592. getStrideSize(): number;
  6593. /**
  6594. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6595. * @param data defines the data to store
  6596. */
  6597. create(data?: Nullable<DataArray>): void;
  6598. /** @hidden */
  6599. _rebuild(): void;
  6600. /**
  6601. * Update current buffer data
  6602. * @param data defines the data to store
  6603. */
  6604. update(data: DataArray): void;
  6605. /**
  6606. * Updates the data directly.
  6607. * @param data the new data
  6608. * @param offset the new offset
  6609. * @param vertexCount the vertex count (optional)
  6610. * @param useBytes set to true if the offset is in bytes
  6611. */
  6612. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6613. /**
  6614. * Release all resources
  6615. */
  6616. dispose(): void;
  6617. }
  6618. /**
  6619. * Specialized buffer used to store vertex data
  6620. */
  6621. export class VertexBuffer {
  6622. /** @hidden */
  6623. _buffer: Buffer;
  6624. private _kind;
  6625. private _size;
  6626. private _ownsBuffer;
  6627. private _instanced;
  6628. private _instanceDivisor;
  6629. /**
  6630. * The byte type.
  6631. */
  6632. static readonly BYTE: number;
  6633. /**
  6634. * The unsigned byte type.
  6635. */
  6636. static readonly UNSIGNED_BYTE: number;
  6637. /**
  6638. * The short type.
  6639. */
  6640. static readonly SHORT: number;
  6641. /**
  6642. * The unsigned short type.
  6643. */
  6644. static readonly UNSIGNED_SHORT: number;
  6645. /**
  6646. * The integer type.
  6647. */
  6648. static readonly INT: number;
  6649. /**
  6650. * The unsigned integer type.
  6651. */
  6652. static readonly UNSIGNED_INT: number;
  6653. /**
  6654. * The float type.
  6655. */
  6656. static readonly FLOAT: number;
  6657. /**
  6658. * Gets or sets the instance divisor when in instanced mode
  6659. */
  6660. get instanceDivisor(): number;
  6661. set instanceDivisor(value: number);
  6662. /**
  6663. * Gets the byte stride.
  6664. */
  6665. readonly byteStride: number;
  6666. /**
  6667. * Gets the byte offset.
  6668. */
  6669. readonly byteOffset: number;
  6670. /**
  6671. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6672. */
  6673. readonly normalized: boolean;
  6674. /**
  6675. * Gets the data type of each component in the array.
  6676. */
  6677. readonly type: number;
  6678. /**
  6679. * Constructor
  6680. * @param engine the engine
  6681. * @param data the data to use for this vertex buffer
  6682. * @param kind the vertex buffer kind
  6683. * @param updatable whether the data is updatable
  6684. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6685. * @param stride the stride (optional)
  6686. * @param instanced whether the buffer is instanced (optional)
  6687. * @param offset the offset of the data (optional)
  6688. * @param size the number of components (optional)
  6689. * @param type the type of the component (optional)
  6690. * @param normalized whether the data contains normalized data (optional)
  6691. * @param useBytes set to true if stride and offset are in bytes (optional)
  6692. * @param divisor defines the instance divisor to use (1 by default)
  6693. */
  6694. 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);
  6695. /** @hidden */
  6696. _rebuild(): void;
  6697. /**
  6698. * Returns the kind of the VertexBuffer (string)
  6699. * @returns a string
  6700. */
  6701. getKind(): string;
  6702. /**
  6703. * Gets a boolean indicating if the VertexBuffer is updatable?
  6704. * @returns true if the buffer is updatable
  6705. */
  6706. isUpdatable(): boolean;
  6707. /**
  6708. * Gets current buffer's data
  6709. * @returns a DataArray or null
  6710. */
  6711. getData(): Nullable<DataArray>;
  6712. /**
  6713. * Gets underlying native buffer
  6714. * @returns underlying native buffer
  6715. */
  6716. getBuffer(): Nullable<DataBuffer>;
  6717. /**
  6718. * Gets the stride in float32 units (i.e. byte stride / 4).
  6719. * May not be an integer if the byte stride is not divisible by 4.
  6720. * @returns the stride in float32 units
  6721. * @deprecated Please use byteStride instead.
  6722. */
  6723. getStrideSize(): number;
  6724. /**
  6725. * Returns the offset as a multiple of the type byte length.
  6726. * @returns the offset in bytes
  6727. * @deprecated Please use byteOffset instead.
  6728. */
  6729. getOffset(): number;
  6730. /**
  6731. * Returns the number of components per vertex attribute (integer)
  6732. * @returns the size in float
  6733. */
  6734. getSize(): number;
  6735. /**
  6736. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6737. * @returns true if this buffer is instanced
  6738. */
  6739. getIsInstanced(): boolean;
  6740. /**
  6741. * Returns the instancing divisor, zero for non-instanced (integer).
  6742. * @returns a number
  6743. */
  6744. getInstanceDivisor(): number;
  6745. /**
  6746. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6747. * @param data defines the data to store
  6748. */
  6749. create(data?: DataArray): void;
  6750. /**
  6751. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6752. * This function will create a new buffer if the current one is not updatable
  6753. * @param data defines the data to store
  6754. */
  6755. update(data: DataArray): void;
  6756. /**
  6757. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6758. * Returns the directly updated WebGLBuffer.
  6759. * @param data the new data
  6760. * @param offset the new offset
  6761. * @param useBytes set to true if the offset is in bytes
  6762. */
  6763. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6764. /**
  6765. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6766. */
  6767. dispose(): void;
  6768. /**
  6769. * Enumerates each value of this vertex buffer as numbers.
  6770. * @param count the number of values to enumerate
  6771. * @param callback the callback function called for each value
  6772. */
  6773. forEach(count: number, callback: (value: number, index: number) => void): void;
  6774. /**
  6775. * Positions
  6776. */
  6777. static readonly PositionKind: string;
  6778. /**
  6779. * Normals
  6780. */
  6781. static readonly NormalKind: string;
  6782. /**
  6783. * Tangents
  6784. */
  6785. static readonly TangentKind: string;
  6786. /**
  6787. * Texture coordinates
  6788. */
  6789. static readonly UVKind: string;
  6790. /**
  6791. * Texture coordinates 2
  6792. */
  6793. static readonly UV2Kind: string;
  6794. /**
  6795. * Texture coordinates 3
  6796. */
  6797. static readonly UV3Kind: string;
  6798. /**
  6799. * Texture coordinates 4
  6800. */
  6801. static readonly UV4Kind: string;
  6802. /**
  6803. * Texture coordinates 5
  6804. */
  6805. static readonly UV5Kind: string;
  6806. /**
  6807. * Texture coordinates 6
  6808. */
  6809. static readonly UV6Kind: string;
  6810. /**
  6811. * Colors
  6812. */
  6813. static readonly ColorKind: string;
  6814. /**
  6815. * Matrix indices (for bones)
  6816. */
  6817. static readonly MatricesIndicesKind: string;
  6818. /**
  6819. * Matrix weights (for bones)
  6820. */
  6821. static readonly MatricesWeightsKind: string;
  6822. /**
  6823. * Additional matrix indices (for bones)
  6824. */
  6825. static readonly MatricesIndicesExtraKind: string;
  6826. /**
  6827. * Additional matrix weights (for bones)
  6828. */
  6829. static readonly MatricesWeightsExtraKind: string;
  6830. /**
  6831. * Deduces the stride given a kind.
  6832. * @param kind The kind string to deduce
  6833. * @returns The deduced stride
  6834. */
  6835. static DeduceStride(kind: string): number;
  6836. /**
  6837. * Gets the byte length of the given type.
  6838. * @param type the type
  6839. * @returns the number of bytes
  6840. */
  6841. static GetTypeByteLength(type: number): number;
  6842. /**
  6843. * Enumerates each value of the given parameters as numbers.
  6844. * @param data the data to enumerate
  6845. * @param byteOffset the byte offset of the data
  6846. * @param byteStride the byte stride of the data
  6847. * @param componentCount the number of components per element
  6848. * @param componentType the type of the component
  6849. * @param count the number of values to enumerate
  6850. * @param normalized whether the data is normalized
  6851. * @param callback the callback function called for each value
  6852. */
  6853. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6854. private static _GetFloatValue;
  6855. }
  6856. }
  6857. declare module BABYLON {
  6858. /**
  6859. * The options Interface for creating a Capsule Mesh
  6860. */
  6861. export interface ICreateCapsuleOptions {
  6862. /** The Orientation of the capsule. Default : Vector3.Up() */
  6863. orientation?: Vector3;
  6864. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6865. subdivisions: number;
  6866. /** Number of cylindrical segments on the capsule. */
  6867. tessellation: number;
  6868. /** Height or Length of the capsule. */
  6869. height: number;
  6870. /** Radius of the capsule. */
  6871. radius: number;
  6872. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6873. capSubdivisions: number;
  6874. /** Overwrite for the top radius. */
  6875. radiusTop?: number;
  6876. /** Overwrite for the bottom radius. */
  6877. radiusBottom?: number;
  6878. /** Overwrite for the top capSubdivisions. */
  6879. topCapSubdivisions?: number;
  6880. /** Overwrite for the bottom capSubdivisions. */
  6881. bottomCapSubdivisions?: number;
  6882. }
  6883. /**
  6884. * Class containing static functions to help procedurally build meshes
  6885. */
  6886. export class CapsuleBuilder {
  6887. /**
  6888. * Creates a capsule or a pill mesh
  6889. * @param name defines the name of the mesh
  6890. * @param options The constructors options.
  6891. * @param scene The scene the mesh is scoped to.
  6892. * @returns Capsule Mesh
  6893. */
  6894. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6895. }
  6896. }
  6897. declare module BABYLON {
  6898. /**
  6899. * @hidden
  6900. */
  6901. export class IntersectionInfo {
  6902. bu: Nullable<number>;
  6903. bv: Nullable<number>;
  6904. distance: number;
  6905. faceId: number;
  6906. subMeshId: number;
  6907. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6908. }
  6909. }
  6910. declare module BABYLON {
  6911. /**
  6912. * Class used to store bounding sphere information
  6913. */
  6914. export class BoundingSphere {
  6915. /**
  6916. * Gets the center of the bounding sphere in local space
  6917. */
  6918. readonly center: Vector3;
  6919. /**
  6920. * Radius of the bounding sphere in local space
  6921. */
  6922. radius: number;
  6923. /**
  6924. * Gets the center of the bounding sphere in world space
  6925. */
  6926. readonly centerWorld: Vector3;
  6927. /**
  6928. * Radius of the bounding sphere in world space
  6929. */
  6930. radiusWorld: number;
  6931. /**
  6932. * Gets the minimum vector in local space
  6933. */
  6934. readonly minimum: Vector3;
  6935. /**
  6936. * Gets the maximum vector in local space
  6937. */
  6938. readonly maximum: Vector3;
  6939. private _worldMatrix;
  6940. private static readonly TmpVector3;
  6941. /**
  6942. * Creates a new bounding sphere
  6943. * @param min defines the minimum vector (in local space)
  6944. * @param max defines the maximum vector (in local space)
  6945. * @param worldMatrix defines the new world matrix
  6946. */
  6947. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6948. /**
  6949. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6950. * @param min defines the new minimum vector (in local space)
  6951. * @param max defines the new maximum vector (in local space)
  6952. * @param worldMatrix defines the new world matrix
  6953. */
  6954. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6955. /**
  6956. * Scale the current bounding sphere by applying a scale factor
  6957. * @param factor defines the scale factor to apply
  6958. * @returns the current bounding box
  6959. */
  6960. scale(factor: number): BoundingSphere;
  6961. /**
  6962. * Gets the world matrix of the bounding box
  6963. * @returns a matrix
  6964. */
  6965. getWorldMatrix(): DeepImmutable<Matrix>;
  6966. /** @hidden */
  6967. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6968. /**
  6969. * Tests if the bounding sphere is intersecting the frustum planes
  6970. * @param frustumPlanes defines the frustum planes to test
  6971. * @returns true if there is an intersection
  6972. */
  6973. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6974. /**
  6975. * Tests if the bounding sphere center is in between the frustum planes.
  6976. * Used for optimistic fast inclusion.
  6977. * @param frustumPlanes defines the frustum planes to test
  6978. * @returns true if the sphere center is in between the frustum planes
  6979. */
  6980. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6981. /**
  6982. * Tests if a point is inside the bounding sphere
  6983. * @param point defines the point to test
  6984. * @returns true if the point is inside the bounding sphere
  6985. */
  6986. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6987. /**
  6988. * Checks if two sphere intersct
  6989. * @param sphere0 sphere 0
  6990. * @param sphere1 sphere 1
  6991. * @returns true if the speres intersect
  6992. */
  6993. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6994. }
  6995. }
  6996. declare module BABYLON {
  6997. /**
  6998. * Class used to store bounding box information
  6999. */
  7000. export class BoundingBox implements ICullable {
  7001. /**
  7002. * Gets the 8 vectors representing the bounding box in local space
  7003. */
  7004. readonly vectors: Vector3[];
  7005. /**
  7006. * Gets the center of the bounding box in local space
  7007. */
  7008. readonly center: Vector3;
  7009. /**
  7010. * Gets the center of the bounding box in world space
  7011. */
  7012. readonly centerWorld: Vector3;
  7013. /**
  7014. * Gets the extend size in local space
  7015. */
  7016. readonly extendSize: Vector3;
  7017. /**
  7018. * Gets the extend size in world space
  7019. */
  7020. readonly extendSizeWorld: Vector3;
  7021. /**
  7022. * Gets the OBB (object bounding box) directions
  7023. */
  7024. readonly directions: Vector3[];
  7025. /**
  7026. * Gets the 8 vectors representing the bounding box in world space
  7027. */
  7028. readonly vectorsWorld: Vector3[];
  7029. /**
  7030. * Gets the minimum vector in world space
  7031. */
  7032. readonly minimumWorld: Vector3;
  7033. /**
  7034. * Gets the maximum vector in world space
  7035. */
  7036. readonly maximumWorld: Vector3;
  7037. /**
  7038. * Gets the minimum vector in local space
  7039. */
  7040. readonly minimum: Vector3;
  7041. /**
  7042. * Gets the maximum vector in local space
  7043. */
  7044. readonly maximum: Vector3;
  7045. private _worldMatrix;
  7046. private static readonly TmpVector3;
  7047. /**
  7048. * @hidden
  7049. */
  7050. _tag: number;
  7051. /**
  7052. * Creates a new bounding box
  7053. * @param min defines the minimum vector (in local space)
  7054. * @param max defines the maximum vector (in local space)
  7055. * @param worldMatrix defines the new world matrix
  7056. */
  7057. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7058. /**
  7059. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7060. * @param min defines the new minimum vector (in local space)
  7061. * @param max defines the new maximum vector (in local space)
  7062. * @param worldMatrix defines the new world matrix
  7063. */
  7064. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7065. /**
  7066. * Scale the current bounding box by applying a scale factor
  7067. * @param factor defines the scale factor to apply
  7068. * @returns the current bounding box
  7069. */
  7070. scale(factor: number): BoundingBox;
  7071. /**
  7072. * Gets the world matrix of the bounding box
  7073. * @returns a matrix
  7074. */
  7075. getWorldMatrix(): DeepImmutable<Matrix>;
  7076. /** @hidden */
  7077. _update(world: DeepImmutable<Matrix>): void;
  7078. /**
  7079. * Tests if the bounding box is intersecting the frustum planes
  7080. * @param frustumPlanes defines the frustum planes to test
  7081. * @returns true if there is an intersection
  7082. */
  7083. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7084. /**
  7085. * Tests if the bounding box is entirely inside the frustum planes
  7086. * @param frustumPlanes defines the frustum planes to test
  7087. * @returns true if there is an inclusion
  7088. */
  7089. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7090. /**
  7091. * Tests if a point is inside the bounding box
  7092. * @param point defines the point to test
  7093. * @returns true if the point is inside the bounding box
  7094. */
  7095. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7096. /**
  7097. * Tests if the bounding box intersects with a bounding sphere
  7098. * @param sphere defines the sphere to test
  7099. * @returns true if there is an intersection
  7100. */
  7101. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7102. /**
  7103. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7104. * @param min defines the min vector to use
  7105. * @param max defines the max vector to use
  7106. * @returns true if there is an intersection
  7107. */
  7108. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7109. /**
  7110. * Tests if two bounding boxes are intersections
  7111. * @param box0 defines the first box to test
  7112. * @param box1 defines the second box to test
  7113. * @returns true if there is an intersection
  7114. */
  7115. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7116. /**
  7117. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7118. * @param minPoint defines the minimum vector of the bounding box
  7119. * @param maxPoint defines the maximum vector of the bounding box
  7120. * @param sphereCenter defines the sphere center
  7121. * @param sphereRadius defines the sphere radius
  7122. * @returns true if there is an intersection
  7123. */
  7124. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7125. /**
  7126. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7127. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7128. * @param frustumPlanes defines the frustum planes to test
  7129. * @return true if there is an inclusion
  7130. */
  7131. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7132. /**
  7133. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7134. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7135. * @param frustumPlanes defines the frustum planes to test
  7136. * @return true if there is an intersection
  7137. */
  7138. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /** @hidden */
  7143. export class Collider {
  7144. /** Define if a collision was found */
  7145. collisionFound: boolean;
  7146. /**
  7147. * Define last intersection point in local space
  7148. */
  7149. intersectionPoint: Vector3;
  7150. /**
  7151. * Define last collided mesh
  7152. */
  7153. collidedMesh: Nullable<AbstractMesh>;
  7154. private _collisionPoint;
  7155. private _planeIntersectionPoint;
  7156. private _tempVector;
  7157. private _tempVector2;
  7158. private _tempVector3;
  7159. private _tempVector4;
  7160. private _edge;
  7161. private _baseToVertex;
  7162. private _destinationPoint;
  7163. private _slidePlaneNormal;
  7164. private _displacementVector;
  7165. /** @hidden */
  7166. _radius: Vector3;
  7167. /** @hidden */
  7168. _retry: number;
  7169. private _velocity;
  7170. private _basePoint;
  7171. private _epsilon;
  7172. /** @hidden */
  7173. _velocityWorldLength: number;
  7174. /** @hidden */
  7175. _basePointWorld: Vector3;
  7176. private _velocityWorld;
  7177. private _normalizedVelocity;
  7178. /** @hidden */
  7179. _initialVelocity: Vector3;
  7180. /** @hidden */
  7181. _initialPosition: Vector3;
  7182. private _nearestDistance;
  7183. private _collisionMask;
  7184. get collisionMask(): number;
  7185. set collisionMask(mask: number);
  7186. /**
  7187. * Gets the plane normal used to compute the sliding response (in local space)
  7188. */
  7189. get slidePlaneNormal(): Vector3;
  7190. /** @hidden */
  7191. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7192. /** @hidden */
  7193. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7194. /** @hidden */
  7195. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7196. /** @hidden */
  7197. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7198. /** @hidden */
  7199. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7200. /** @hidden */
  7201. _getResponse(pos: Vector3, vel: Vector3): void;
  7202. }
  7203. }
  7204. declare module BABYLON {
  7205. /**
  7206. * Interface for cullable objects
  7207. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7208. */
  7209. export interface ICullable {
  7210. /**
  7211. * Checks if the object or part of the object is in the frustum
  7212. * @param frustumPlanes Camera near/planes
  7213. * @returns true if the object is in frustum otherwise false
  7214. */
  7215. isInFrustum(frustumPlanes: Plane[]): boolean;
  7216. /**
  7217. * Checks if a cullable object (mesh...) is in the camera frustum
  7218. * Unlike isInFrustum this cheks the full bounding box
  7219. * @param frustumPlanes Camera near/planes
  7220. * @returns true if the object is in frustum otherwise false
  7221. */
  7222. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7223. }
  7224. /**
  7225. * Info for a bounding data of a mesh
  7226. */
  7227. export class BoundingInfo implements ICullable {
  7228. /**
  7229. * Bounding box for the mesh
  7230. */
  7231. readonly boundingBox: BoundingBox;
  7232. /**
  7233. * Bounding sphere for the mesh
  7234. */
  7235. readonly boundingSphere: BoundingSphere;
  7236. private _isLocked;
  7237. private static readonly TmpVector3;
  7238. /**
  7239. * Constructs bounding info
  7240. * @param minimum min vector of the bounding box/sphere
  7241. * @param maximum max vector of the bounding box/sphere
  7242. * @param worldMatrix defines the new world matrix
  7243. */
  7244. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7245. /**
  7246. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7247. * @param min defines the new minimum vector (in local space)
  7248. * @param max defines the new maximum vector (in local space)
  7249. * @param worldMatrix defines the new world matrix
  7250. */
  7251. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7252. /**
  7253. * min vector of the bounding box/sphere
  7254. */
  7255. get minimum(): Vector3;
  7256. /**
  7257. * max vector of the bounding box/sphere
  7258. */
  7259. get maximum(): Vector3;
  7260. /**
  7261. * If the info is locked and won't be updated to avoid perf overhead
  7262. */
  7263. get isLocked(): boolean;
  7264. set isLocked(value: boolean);
  7265. /**
  7266. * Updates the bounding sphere and box
  7267. * @param world world matrix to be used to update
  7268. */
  7269. update(world: DeepImmutable<Matrix>): void;
  7270. /**
  7271. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7272. * @param center New center of the bounding info
  7273. * @param extend New extend of the bounding info
  7274. * @returns the current bounding info
  7275. */
  7276. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7277. /**
  7278. * Scale the current bounding info by applying a scale factor
  7279. * @param factor defines the scale factor to apply
  7280. * @returns the current bounding info
  7281. */
  7282. scale(factor: number): BoundingInfo;
  7283. /**
  7284. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7285. * @param frustumPlanes defines the frustum to test
  7286. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7287. * @returns true if the bounding info is in the frustum planes
  7288. */
  7289. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7290. /**
  7291. * Gets the world distance between the min and max points of the bounding box
  7292. */
  7293. get diagonalLength(): number;
  7294. /**
  7295. * Checks if a cullable object (mesh...) is in the camera frustum
  7296. * Unlike isInFrustum this cheks the full bounding box
  7297. * @param frustumPlanes Camera near/planes
  7298. * @returns true if the object is in frustum otherwise false
  7299. */
  7300. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7301. /** @hidden */
  7302. _checkCollision(collider: Collider): boolean;
  7303. /**
  7304. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7305. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7306. * @param point the point to check intersection with
  7307. * @returns if the point intersects
  7308. */
  7309. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7310. /**
  7311. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7312. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7313. * @param boundingInfo the bounding info to check intersection with
  7314. * @param precise if the intersection should be done using OBB
  7315. * @returns if the bounding info intersects
  7316. */
  7317. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * Extracts minimum and maximum values from a list of indexed positions
  7323. * @param positions defines the positions to use
  7324. * @param indices defines the indices to the positions
  7325. * @param indexStart defines the start index
  7326. * @param indexCount defines the end index
  7327. * @param bias defines bias value to add to the result
  7328. * @return minimum and maximum values
  7329. */
  7330. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7331. minimum: Vector3;
  7332. maximum: Vector3;
  7333. };
  7334. /**
  7335. * Extracts minimum and maximum values from a list of positions
  7336. * @param positions defines the positions to use
  7337. * @param start defines the start index in the positions array
  7338. * @param count defines the number of positions to handle
  7339. * @param bias defines bias value to add to the result
  7340. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7341. * @return minimum and maximum values
  7342. */
  7343. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7344. minimum: Vector3;
  7345. maximum: Vector3;
  7346. };
  7347. }
  7348. declare module BABYLON {
  7349. /** @hidden */
  7350. export class WebGLDataBuffer extends DataBuffer {
  7351. private _buffer;
  7352. constructor(resource: WebGLBuffer);
  7353. get underlyingResource(): any;
  7354. }
  7355. }
  7356. declare module BABYLON {
  7357. /** @hidden */
  7358. export class WebGLPipelineContext implements IPipelineContext {
  7359. engine: ThinEngine;
  7360. program: Nullable<WebGLProgram>;
  7361. context?: WebGLRenderingContext;
  7362. vertexShader?: WebGLShader;
  7363. fragmentShader?: WebGLShader;
  7364. isParallelCompiled: boolean;
  7365. onCompiled?: () => void;
  7366. transformFeedback?: WebGLTransformFeedback | null;
  7367. vertexCompilationError: Nullable<string>;
  7368. fragmentCompilationError: Nullable<string>;
  7369. programLinkError: Nullable<string>;
  7370. programValidationError: Nullable<string>;
  7371. get isAsync(): boolean;
  7372. get isReady(): boolean;
  7373. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7374. _getVertexShaderCode(): string | null;
  7375. _getFragmentShaderCode(): string | null;
  7376. }
  7377. }
  7378. declare module BABYLON {
  7379. interface ThinEngine {
  7380. /**
  7381. * Create an uniform buffer
  7382. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7383. * @param elements defines the content of the uniform buffer
  7384. * @returns the webGL uniform buffer
  7385. */
  7386. createUniformBuffer(elements: FloatArray): DataBuffer;
  7387. /**
  7388. * Create a dynamic uniform buffer
  7389. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7390. * @param elements defines the content of the uniform buffer
  7391. * @returns the webGL uniform buffer
  7392. */
  7393. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7394. /**
  7395. * Update an existing uniform buffer
  7396. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7397. * @param uniformBuffer defines the target uniform buffer
  7398. * @param elements defines the content to update
  7399. * @param offset defines the offset in the uniform buffer where update should start
  7400. * @param count defines the size of the data to update
  7401. */
  7402. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7403. /**
  7404. * Bind an uniform buffer to the current webGL context
  7405. * @param buffer defines the buffer to bind
  7406. */
  7407. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7408. /**
  7409. * Bind a buffer to the current webGL context at a given location
  7410. * @param buffer defines the buffer to bind
  7411. * @param location defines the index where to bind the buffer
  7412. */
  7413. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7414. /**
  7415. * Bind a specific block at a given index in a specific shader program
  7416. * @param pipelineContext defines the pipeline context to use
  7417. * @param blockName defines the block name
  7418. * @param index defines the index where to bind the block
  7419. */
  7420. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7421. }
  7422. }
  7423. declare module BABYLON {
  7424. /**
  7425. * Uniform buffer objects.
  7426. *
  7427. * Handles blocks of uniform on the GPU.
  7428. *
  7429. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7430. *
  7431. * For more information, please refer to :
  7432. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7433. */
  7434. export class UniformBuffer {
  7435. private _engine;
  7436. private _buffer;
  7437. private _data;
  7438. private _bufferData;
  7439. private _dynamic?;
  7440. private _uniformLocations;
  7441. private _uniformSizes;
  7442. private _uniformLocationPointer;
  7443. private _needSync;
  7444. private _noUBO;
  7445. private _currentEffect;
  7446. /** @hidden */
  7447. _alreadyBound: boolean;
  7448. private static _MAX_UNIFORM_SIZE;
  7449. private static _tempBuffer;
  7450. /**
  7451. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7456. /**
  7457. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7462. /**
  7463. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  7468. /**
  7469. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7474. /**
  7475. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7480. /**
  7481. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7486. /**
  7487. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7492. /**
  7493. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7498. /**
  7499. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7500. * This is dynamic to allow compat with webgl 1 and 2.
  7501. * You will need to pass the name of the uniform as well as the value.
  7502. */
  7503. updateVector4: (name: string, vector: Vector4) => void;
  7504. /**
  7505. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7506. * This is dynamic to allow compat with webgl 1 and 2.
  7507. * You will need to pass the name of the uniform as well as the value.
  7508. */
  7509. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7510. /**
  7511. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7512. * This is dynamic to allow compat with webgl 1 and 2.
  7513. * You will need to pass the name of the uniform as well as the value.
  7514. */
  7515. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7516. /**
  7517. * Instantiates a new Uniform buffer objects.
  7518. *
  7519. * Handles blocks of uniform on the GPU.
  7520. *
  7521. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7522. *
  7523. * For more information, please refer to :
  7524. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7525. * @param engine Define the engine the buffer is associated with
  7526. * @param data Define the data contained in the buffer
  7527. * @param dynamic Define if the buffer is updatable
  7528. */
  7529. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7530. /**
  7531. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7532. * or just falling back on setUniformXXX calls.
  7533. */
  7534. get useUbo(): boolean;
  7535. /**
  7536. * Indicates if the WebGL underlying uniform buffer is in sync
  7537. * with the javascript cache data.
  7538. */
  7539. get isSync(): boolean;
  7540. /**
  7541. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7542. * Also, a dynamic UniformBuffer will disable cache verification and always
  7543. * update the underlying WebGL uniform buffer to the GPU.
  7544. * @returns if Dynamic, otherwise false
  7545. */
  7546. isDynamic(): boolean;
  7547. /**
  7548. * The data cache on JS side.
  7549. * @returns the underlying data as a float array
  7550. */
  7551. getData(): Float32Array;
  7552. /**
  7553. * The underlying WebGL Uniform buffer.
  7554. * @returns the webgl buffer
  7555. */
  7556. getBuffer(): Nullable<DataBuffer>;
  7557. /**
  7558. * std140 layout specifies how to align data within an UBO structure.
  7559. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7560. * for specs.
  7561. */
  7562. private _fillAlignment;
  7563. /**
  7564. * Adds an uniform in the buffer.
  7565. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7566. * for the layout to be correct !
  7567. * @param name Name of the uniform, as used in the uniform block in the shader.
  7568. * @param size Data size, or data directly.
  7569. */
  7570. addUniform(name: string, size: number | number[]): void;
  7571. /**
  7572. * Adds a Matrix 4x4 to the uniform buffer.
  7573. * @param name Name of the uniform, as used in the uniform block in the shader.
  7574. * @param mat A 4x4 matrix.
  7575. */
  7576. addMatrix(name: string, mat: Matrix): void;
  7577. /**
  7578. * Adds a vec2 to the uniform buffer.
  7579. * @param name Name of the uniform, as used in the uniform block in the shader.
  7580. * @param x Define the x component value of the vec2
  7581. * @param y Define the y component value of the vec2
  7582. */
  7583. addFloat2(name: string, x: number, y: number): void;
  7584. /**
  7585. * Adds a vec3 to the uniform buffer.
  7586. * @param name Name of the uniform, as used in the uniform block in the shader.
  7587. * @param x Define the x component value of the vec3
  7588. * @param y Define the y component value of the vec3
  7589. * @param z Define the z component value of the vec3
  7590. */
  7591. addFloat3(name: string, x: number, y: number, z: number): void;
  7592. /**
  7593. * Adds a vec3 to the uniform buffer.
  7594. * @param name Name of the uniform, as used in the uniform block in the shader.
  7595. * @param color Define the vec3 from a Color
  7596. */
  7597. addColor3(name: string, color: Color3): void;
  7598. /**
  7599. * Adds a vec4 to the uniform buffer.
  7600. * @param name Name of the uniform, as used in the uniform block in the shader.
  7601. * @param color Define the rgb components from a Color
  7602. * @param alpha Define the a component of the vec4
  7603. */
  7604. addColor4(name: string, color: Color3, alpha: number): void;
  7605. /**
  7606. * Adds a vec3 to the uniform buffer.
  7607. * @param name Name of the uniform, as used in the uniform block in the shader.
  7608. * @param vector Define the vec3 components from a Vector
  7609. */
  7610. addVector3(name: string, vector: Vector3): void;
  7611. /**
  7612. * Adds a Matrix 3x3 to the uniform buffer.
  7613. * @param name Name of the uniform, as used in the uniform block in the shader.
  7614. */
  7615. addMatrix3x3(name: string): void;
  7616. /**
  7617. * Adds a Matrix 2x2 to the uniform buffer.
  7618. * @param name Name of the uniform, as used in the uniform block in the shader.
  7619. */
  7620. addMatrix2x2(name: string): void;
  7621. /**
  7622. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7623. */
  7624. create(): void;
  7625. /** @hidden */
  7626. _rebuild(): void;
  7627. /**
  7628. * Updates the WebGL Uniform Buffer on the GPU.
  7629. * If the `dynamic` flag is set to true, no cache comparison is done.
  7630. * Otherwise, the buffer will be updated only if the cache differs.
  7631. */
  7632. update(): void;
  7633. /**
  7634. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7635. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7636. * @param data Define the flattened data
  7637. * @param size Define the size of the data.
  7638. */
  7639. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7640. private _valueCache;
  7641. private _cacheMatrix;
  7642. private _updateMatrix3x3ForUniform;
  7643. private _updateMatrix3x3ForEffect;
  7644. private _updateMatrix2x2ForEffect;
  7645. private _updateMatrix2x2ForUniform;
  7646. private _updateFloatForEffect;
  7647. private _updateFloatForUniform;
  7648. private _updateFloat2ForEffect;
  7649. private _updateFloat2ForUniform;
  7650. private _updateFloat3ForEffect;
  7651. private _updateFloat3ForUniform;
  7652. private _updateFloat4ForEffect;
  7653. private _updateFloat4ForUniform;
  7654. private _updateMatrixForEffect;
  7655. private _updateMatrixForUniform;
  7656. private _updateVector3ForEffect;
  7657. private _updateVector3ForUniform;
  7658. private _updateVector4ForEffect;
  7659. private _updateVector4ForUniform;
  7660. private _updateColor3ForEffect;
  7661. private _updateColor3ForUniform;
  7662. private _updateColor4ForEffect;
  7663. private _updateColor4ForUniform;
  7664. /**
  7665. * Sets a sampler uniform on the effect.
  7666. * @param name Define the name of the sampler.
  7667. * @param texture Define the texture to set in the sampler
  7668. */
  7669. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7670. /**
  7671. * Directly updates the value of the uniform in the cache AND on the GPU.
  7672. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7673. * @param data Define the flattened data
  7674. */
  7675. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7676. /**
  7677. * Binds this uniform buffer to an effect.
  7678. * @param effect Define the effect to bind the buffer to
  7679. * @param name Name of the uniform block in the shader.
  7680. */
  7681. bindToEffect(effect: Effect, name: string): void;
  7682. /**
  7683. * Disposes the uniform buffer.
  7684. */
  7685. dispose(): void;
  7686. }
  7687. }
  7688. declare module BABYLON {
  7689. /**
  7690. * Enum that determines the text-wrapping mode to use.
  7691. */
  7692. export enum InspectableType {
  7693. /**
  7694. * Checkbox for booleans
  7695. */
  7696. Checkbox = 0,
  7697. /**
  7698. * Sliders for numbers
  7699. */
  7700. Slider = 1,
  7701. /**
  7702. * Vector3
  7703. */
  7704. Vector3 = 2,
  7705. /**
  7706. * Quaternions
  7707. */
  7708. Quaternion = 3,
  7709. /**
  7710. * Color3
  7711. */
  7712. Color3 = 4,
  7713. /**
  7714. * String
  7715. */
  7716. String = 5
  7717. }
  7718. /**
  7719. * Interface used to define custom inspectable properties.
  7720. * This interface is used by the inspector to display custom property grids
  7721. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7722. */
  7723. export interface IInspectable {
  7724. /**
  7725. * Gets the label to display
  7726. */
  7727. label: string;
  7728. /**
  7729. * Gets the name of the property to edit
  7730. */
  7731. propertyName: string;
  7732. /**
  7733. * Gets the type of the editor to use
  7734. */
  7735. type: InspectableType;
  7736. /**
  7737. * Gets the minimum value of the property when using in "slider" mode
  7738. */
  7739. min?: number;
  7740. /**
  7741. * Gets the maximum value of the property when using in "slider" mode
  7742. */
  7743. max?: number;
  7744. /**
  7745. * Gets the setp to use when using in "slider" mode
  7746. */
  7747. step?: number;
  7748. }
  7749. }
  7750. declare module BABYLON {
  7751. /**
  7752. * Class used to provide helper for timing
  7753. */
  7754. export class TimingTools {
  7755. /**
  7756. * Polyfill for setImmediate
  7757. * @param action defines the action to execute after the current execution block
  7758. */
  7759. static SetImmediate(action: () => void): void;
  7760. }
  7761. }
  7762. declare module BABYLON {
  7763. /**
  7764. * Class used to enable instatition of objects by class name
  7765. */
  7766. export class InstantiationTools {
  7767. /**
  7768. * Use this object to register external classes like custom textures or material
  7769. * to allow the laoders to instantiate them
  7770. */
  7771. static RegisteredExternalClasses: {
  7772. [key: string]: Object;
  7773. };
  7774. /**
  7775. * Tries to instantiate a new object from a given class name
  7776. * @param className defines the class name to instantiate
  7777. * @returns the new object or null if the system was not able to do the instantiation
  7778. */
  7779. static Instantiate(className: string): any;
  7780. }
  7781. }
  7782. declare module BABYLON {
  7783. /**
  7784. * Define options used to create a depth texture
  7785. */
  7786. export class DepthTextureCreationOptions {
  7787. /** Specifies whether or not a stencil should be allocated in the texture */
  7788. generateStencil?: boolean;
  7789. /** Specifies whether or not bilinear filtering is enable on the texture */
  7790. bilinearFiltering?: boolean;
  7791. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7792. comparisonFunction?: number;
  7793. /** Specifies if the created texture is a cube texture */
  7794. isCube?: boolean;
  7795. }
  7796. }
  7797. declare module BABYLON {
  7798. interface ThinEngine {
  7799. /**
  7800. * Creates a depth stencil cube texture.
  7801. * This is only available in WebGL 2.
  7802. * @param size The size of face edge in the cube texture.
  7803. * @param options The options defining the cube texture.
  7804. * @returns The cube texture
  7805. */
  7806. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7807. /**
  7808. * Creates a cube texture
  7809. * @param rootUrl defines the url where the files to load is located
  7810. * @param scene defines the current scene
  7811. * @param files defines the list of files to load (1 per face)
  7812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7813. * @param onLoad defines an optional callback raised when the texture is loaded
  7814. * @param onError defines an optional callback raised if there is an issue to load the texture
  7815. * @param format defines the format of the data
  7816. * @param forcedExtension defines the extension to use to pick the right loader
  7817. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7818. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7819. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7820. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7821. * @param loaderOptions options to be passed to the loader
  7822. * @returns the cube texture as an InternalTexture
  7823. */
  7824. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  7825. /**
  7826. * Creates a cube texture
  7827. * @param rootUrl defines the url where the files to load is located
  7828. * @param scene defines the current scene
  7829. * @param files defines the list of files to load (1 per face)
  7830. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7831. * @param onLoad defines an optional callback raised when the texture is loaded
  7832. * @param onError defines an optional callback raised if there is an issue to load the texture
  7833. * @param format defines the format of the data
  7834. * @param forcedExtension defines the extension to use to pick the right loader
  7835. * @returns the cube texture as an InternalTexture
  7836. */
  7837. 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;
  7838. /**
  7839. * Creates a cube texture
  7840. * @param rootUrl defines the url where the files to load is located
  7841. * @param scene defines the current scene
  7842. * @param files defines the list of files to load (1 per face)
  7843. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7844. * @param onLoad defines an optional callback raised when the texture is loaded
  7845. * @param onError defines an optional callback raised if there is an issue to load the texture
  7846. * @param format defines the format of the data
  7847. * @param forcedExtension defines the extension to use to pick the right loader
  7848. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7849. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7850. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7851. * @returns the cube texture as an InternalTexture
  7852. */
  7853. 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;
  7854. /** @hidden */
  7855. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7856. /** @hidden */
  7857. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7858. /** @hidden */
  7859. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7860. /** @hidden */
  7861. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7862. /**
  7863. * @hidden
  7864. */
  7865. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7866. }
  7867. }
  7868. declare module BABYLON {
  7869. /**
  7870. * Class for creating a cube texture
  7871. */
  7872. export class CubeTexture extends BaseTexture {
  7873. private _delayedOnLoad;
  7874. /**
  7875. * Observable triggered once the texture has been loaded.
  7876. */
  7877. onLoadObservable: Observable<CubeTexture>;
  7878. /**
  7879. * The url of the texture
  7880. */
  7881. url: string;
  7882. /**
  7883. * Gets or sets the center of the bounding box associated with the cube texture.
  7884. * It must define where the camera used to render the texture was set
  7885. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7886. */
  7887. boundingBoxPosition: Vector3;
  7888. private _boundingBoxSize;
  7889. /**
  7890. * Gets or sets the size of the bounding box associated with the cube texture
  7891. * When defined, the cubemap will switch to local mode
  7892. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7893. * @example https://www.babylonjs-playground.com/#RNASML
  7894. */
  7895. set boundingBoxSize(value: Vector3);
  7896. /**
  7897. * Returns the bounding box size
  7898. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7899. */
  7900. get boundingBoxSize(): Vector3;
  7901. protected _rotationY: number;
  7902. /**
  7903. * Sets texture matrix rotation angle around Y axis in radians.
  7904. */
  7905. set rotationY(value: number);
  7906. /**
  7907. * Gets texture matrix rotation angle around Y axis radians.
  7908. */
  7909. get rotationY(): number;
  7910. /**
  7911. * Are mip maps generated for this texture or not.
  7912. */
  7913. get noMipmap(): boolean;
  7914. private _noMipmap;
  7915. private _files;
  7916. protected _forcedExtension: Nullable<string>;
  7917. private _extensions;
  7918. private _textureMatrix;
  7919. private _format;
  7920. private _createPolynomials;
  7921. private _loaderOptions;
  7922. /**
  7923. * Creates a cube texture from an array of image urls
  7924. * @param files defines an array of image urls
  7925. * @param scene defines the hosting scene
  7926. * @param noMipmap specifies if mip maps are not used
  7927. * @returns a cube texture
  7928. */
  7929. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7930. /**
  7931. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7932. * @param url defines the url of the prefiltered texture
  7933. * @param scene defines the scene the texture is attached to
  7934. * @param forcedExtension defines the extension of the file if different from the url
  7935. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7936. * @return the prefiltered texture
  7937. */
  7938. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7939. /**
  7940. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7941. * as prefiltered data.
  7942. * @param rootUrl defines the url of the texture or the root name of the six images
  7943. * @param null defines the scene or engine the texture is attached to
  7944. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7945. * @param noMipmap defines if mipmaps should be created or not
  7946. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7947. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7948. * @param onError defines a callback triggered in case of error during load
  7949. * @param format defines the internal format to use for the texture once loaded
  7950. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7951. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7952. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7953. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7954. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7955. * @param loaderOptions options to be passed to the loader
  7956. * @return the cube texture
  7957. */
  7958. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  7959. /**
  7960. * Get the current class name of the texture useful for serialization or dynamic coding.
  7961. * @returns "CubeTexture"
  7962. */
  7963. getClassName(): string;
  7964. /**
  7965. * Update the url (and optional buffer) of this texture if url was null during construction.
  7966. * @param url the url of the texture
  7967. * @param forcedExtension defines the extension to use
  7968. * @param onLoad callback called when the texture is loaded (defaults to null)
  7969. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7970. */
  7971. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7972. /**
  7973. * Delays loading of the cube texture
  7974. * @param forcedExtension defines the extension to use
  7975. */
  7976. delayLoad(forcedExtension?: string): void;
  7977. /**
  7978. * Returns the reflection texture matrix
  7979. * @returns the reflection texture matrix
  7980. */
  7981. getReflectionTextureMatrix(): Matrix;
  7982. /**
  7983. * Sets the reflection texture matrix
  7984. * @param value Reflection texture matrix
  7985. */
  7986. setReflectionTextureMatrix(value: Matrix): void;
  7987. /**
  7988. * Parses text to create a cube texture
  7989. * @param parsedTexture define the serialized text to read from
  7990. * @param scene defines the hosting scene
  7991. * @param rootUrl defines the root url of the cube texture
  7992. * @returns a cube texture
  7993. */
  7994. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7995. /**
  7996. * Makes a clone, or deep copy, of the cube texture
  7997. * @returns a new cube texture
  7998. */
  7999. clone(): CubeTexture;
  8000. }
  8001. }
  8002. declare module BABYLON {
  8003. /**
  8004. * Manages the defines for the Material
  8005. */
  8006. export class MaterialDefines {
  8007. /** @hidden */
  8008. protected _keys: string[];
  8009. private _isDirty;
  8010. /** @hidden */
  8011. _renderId: number;
  8012. /** @hidden */
  8013. _areLightsDirty: boolean;
  8014. /** @hidden */
  8015. _areLightsDisposed: boolean;
  8016. /** @hidden */
  8017. _areAttributesDirty: boolean;
  8018. /** @hidden */
  8019. _areTexturesDirty: boolean;
  8020. /** @hidden */
  8021. _areFresnelDirty: boolean;
  8022. /** @hidden */
  8023. _areMiscDirty: boolean;
  8024. /** @hidden */
  8025. _arePrePassDirty: boolean;
  8026. /** @hidden */
  8027. _areImageProcessingDirty: boolean;
  8028. /** @hidden */
  8029. _normals: boolean;
  8030. /** @hidden */
  8031. _uvs: boolean;
  8032. /** @hidden */
  8033. _needNormals: boolean;
  8034. /** @hidden */
  8035. _needUVs: boolean;
  8036. [id: string]: any;
  8037. /**
  8038. * Specifies if the material needs to be re-calculated
  8039. */
  8040. get isDirty(): boolean;
  8041. /**
  8042. * Marks the material to indicate that it has been re-calculated
  8043. */
  8044. markAsProcessed(): void;
  8045. /**
  8046. * Marks the material to indicate that it needs to be re-calculated
  8047. */
  8048. markAsUnprocessed(): void;
  8049. /**
  8050. * Marks the material to indicate all of its defines need to be re-calculated
  8051. */
  8052. markAllAsDirty(): void;
  8053. /**
  8054. * Marks the material to indicate that image processing needs to be re-calculated
  8055. */
  8056. markAsImageProcessingDirty(): void;
  8057. /**
  8058. * Marks the material to indicate the lights need to be re-calculated
  8059. * @param disposed Defines whether the light is dirty due to dispose or not
  8060. */
  8061. markAsLightDirty(disposed?: boolean): void;
  8062. /**
  8063. * Marks the attribute state as changed
  8064. */
  8065. markAsAttributesDirty(): void;
  8066. /**
  8067. * Marks the texture state as changed
  8068. */
  8069. markAsTexturesDirty(): void;
  8070. /**
  8071. * Marks the fresnel state as changed
  8072. */
  8073. markAsFresnelDirty(): void;
  8074. /**
  8075. * Marks the misc state as changed
  8076. */
  8077. markAsMiscDirty(): void;
  8078. /**
  8079. * Marks the prepass state as changed
  8080. */
  8081. markAsPrePassDirty(): void;
  8082. /**
  8083. * Rebuilds the material defines
  8084. */
  8085. rebuild(): void;
  8086. /**
  8087. * Specifies if two material defines are equal
  8088. * @param other - A material define instance to compare to
  8089. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8090. */
  8091. isEqual(other: MaterialDefines): boolean;
  8092. /**
  8093. * Clones this instance's defines to another instance
  8094. * @param other - material defines to clone values to
  8095. */
  8096. cloneTo(other: MaterialDefines): void;
  8097. /**
  8098. * Resets the material define values
  8099. */
  8100. reset(): void;
  8101. /**
  8102. * Converts the material define values to a string
  8103. * @returns - String of material define information
  8104. */
  8105. toString(): string;
  8106. }
  8107. }
  8108. declare module BABYLON {
  8109. /**
  8110. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8111. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8112. * 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;
  8113. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8114. */
  8115. export class ColorCurves {
  8116. private _dirty;
  8117. private _tempColor;
  8118. private _globalCurve;
  8119. private _highlightsCurve;
  8120. private _midtonesCurve;
  8121. private _shadowsCurve;
  8122. private _positiveCurve;
  8123. private _negativeCurve;
  8124. private _globalHue;
  8125. private _globalDensity;
  8126. private _globalSaturation;
  8127. private _globalExposure;
  8128. /**
  8129. * Gets the global Hue value.
  8130. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8131. */
  8132. get globalHue(): number;
  8133. /**
  8134. * Sets the global Hue value.
  8135. * 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).
  8136. */
  8137. set globalHue(value: number);
  8138. /**
  8139. * Gets the global Density value.
  8140. * 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.
  8141. * Values less than zero provide a filter of opposite hue.
  8142. */
  8143. get globalDensity(): number;
  8144. /**
  8145. * Sets the global Density value.
  8146. * 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.
  8147. * Values less than zero provide a filter of opposite hue.
  8148. */
  8149. set globalDensity(value: number);
  8150. /**
  8151. * Gets the global Saturation value.
  8152. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8153. */
  8154. get globalSaturation(): number;
  8155. /**
  8156. * Sets the global Saturation value.
  8157. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8158. */
  8159. set globalSaturation(value: number);
  8160. /**
  8161. * Gets the global Exposure value.
  8162. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8163. */
  8164. get globalExposure(): number;
  8165. /**
  8166. * Sets the global Exposure value.
  8167. * 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.
  8168. */
  8169. set globalExposure(value: number);
  8170. private _highlightsHue;
  8171. private _highlightsDensity;
  8172. private _highlightsSaturation;
  8173. private _highlightsExposure;
  8174. /**
  8175. * Gets the highlights Hue value.
  8176. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8177. */
  8178. get highlightsHue(): number;
  8179. /**
  8180. * Sets the highlights Hue value.
  8181. * 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).
  8182. */
  8183. set highlightsHue(value: number);
  8184. /**
  8185. * Gets the highlights Density value.
  8186. * 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.
  8187. * Values less than zero provide a filter of opposite hue.
  8188. */
  8189. get highlightsDensity(): number;
  8190. /**
  8191. * Sets the highlights Density value.
  8192. * 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.
  8193. * Values less than zero provide a filter of opposite hue.
  8194. */
  8195. set highlightsDensity(value: number);
  8196. /**
  8197. * Gets the highlights Saturation value.
  8198. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8199. */
  8200. get highlightsSaturation(): number;
  8201. /**
  8202. * Sets the highlights Saturation value.
  8203. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8204. */
  8205. set highlightsSaturation(value: number);
  8206. /**
  8207. * Gets the highlights Exposure value.
  8208. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8209. */
  8210. get highlightsExposure(): number;
  8211. /**
  8212. * Sets the highlights Exposure value.
  8213. * 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.
  8214. */
  8215. set highlightsExposure(value: number);
  8216. private _midtonesHue;
  8217. private _midtonesDensity;
  8218. private _midtonesSaturation;
  8219. private _midtonesExposure;
  8220. /**
  8221. * Gets the midtones Hue value.
  8222. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8223. */
  8224. get midtonesHue(): number;
  8225. /**
  8226. * Sets the midtones Hue value.
  8227. * 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).
  8228. */
  8229. set midtonesHue(value: number);
  8230. /**
  8231. * Gets the midtones Density value.
  8232. * 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.
  8233. * Values less than zero provide a filter of opposite hue.
  8234. */
  8235. get midtonesDensity(): number;
  8236. /**
  8237. * Sets the midtones Density value.
  8238. * 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.
  8239. * Values less than zero provide a filter of opposite hue.
  8240. */
  8241. set midtonesDensity(value: number);
  8242. /**
  8243. * Gets the midtones Saturation value.
  8244. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8245. */
  8246. get midtonesSaturation(): number;
  8247. /**
  8248. * Sets the midtones Saturation value.
  8249. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8250. */
  8251. set midtonesSaturation(value: number);
  8252. /**
  8253. * Gets the midtones Exposure value.
  8254. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8255. */
  8256. get midtonesExposure(): number;
  8257. /**
  8258. * Sets the midtones Exposure value.
  8259. * 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.
  8260. */
  8261. set midtonesExposure(value: number);
  8262. private _shadowsHue;
  8263. private _shadowsDensity;
  8264. private _shadowsSaturation;
  8265. private _shadowsExposure;
  8266. /**
  8267. * Gets the shadows Hue value.
  8268. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8269. */
  8270. get shadowsHue(): number;
  8271. /**
  8272. * Sets the shadows Hue value.
  8273. * 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).
  8274. */
  8275. set shadowsHue(value: number);
  8276. /**
  8277. * Gets the shadows Density value.
  8278. * 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.
  8279. * Values less than zero provide a filter of opposite hue.
  8280. */
  8281. get shadowsDensity(): number;
  8282. /**
  8283. * Sets the shadows Density value.
  8284. * 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.
  8285. * Values less than zero provide a filter of opposite hue.
  8286. */
  8287. set shadowsDensity(value: number);
  8288. /**
  8289. * Gets the shadows Saturation value.
  8290. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8291. */
  8292. get shadowsSaturation(): number;
  8293. /**
  8294. * Sets the shadows Saturation value.
  8295. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8296. */
  8297. set shadowsSaturation(value: number);
  8298. /**
  8299. * Gets the shadows Exposure value.
  8300. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8301. */
  8302. get shadowsExposure(): number;
  8303. /**
  8304. * Sets the shadows Exposure value.
  8305. * 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.
  8306. */
  8307. set shadowsExposure(value: number);
  8308. /**
  8309. * Returns the class name
  8310. * @returns The class name
  8311. */
  8312. getClassName(): string;
  8313. /**
  8314. * Binds the color curves to the shader.
  8315. * @param colorCurves The color curve to bind
  8316. * @param effect The effect to bind to
  8317. * @param positiveUniform The positive uniform shader parameter
  8318. * @param neutralUniform The neutral uniform shader parameter
  8319. * @param negativeUniform The negative uniform shader parameter
  8320. */
  8321. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8322. /**
  8323. * Prepare the list of uniforms associated with the ColorCurves effects.
  8324. * @param uniformsList The list of uniforms used in the effect
  8325. */
  8326. static PrepareUniforms(uniformsList: string[]): void;
  8327. /**
  8328. * Returns color grading data based on a hue, density, saturation and exposure value.
  8329. * @param filterHue The hue of the color filter.
  8330. * @param filterDensity The density of the color filter.
  8331. * @param saturation The saturation.
  8332. * @param exposure The exposure.
  8333. * @param result The result data container.
  8334. */
  8335. private getColorGradingDataToRef;
  8336. /**
  8337. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8338. * @param value The input slider value in range [-100,100].
  8339. * @returns Adjusted value.
  8340. */
  8341. private static applyColorGradingSliderNonlinear;
  8342. /**
  8343. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8344. * @param hue The hue (H) input.
  8345. * @param saturation The saturation (S) input.
  8346. * @param brightness The brightness (B) input.
  8347. * @result An RGBA color represented as Vector4.
  8348. */
  8349. private static fromHSBToRef;
  8350. /**
  8351. * Returns a value clamped between min and max
  8352. * @param value The value to clamp
  8353. * @param min The minimum of value
  8354. * @param max The maximum of value
  8355. * @returns The clamped value.
  8356. */
  8357. private static clamp;
  8358. /**
  8359. * Clones the current color curve instance.
  8360. * @return The cloned curves
  8361. */
  8362. clone(): ColorCurves;
  8363. /**
  8364. * Serializes the current color curve instance to a json representation.
  8365. * @return a JSON representation
  8366. */
  8367. serialize(): any;
  8368. /**
  8369. * Parses the color curve from a json representation.
  8370. * @param source the JSON source to parse
  8371. * @return The parsed curves
  8372. */
  8373. static Parse(source: any): ColorCurves;
  8374. }
  8375. }
  8376. declare module BABYLON {
  8377. /**
  8378. * Interface to follow in your material defines to integrate easily the
  8379. * Image proccessing functions.
  8380. * @hidden
  8381. */
  8382. export interface IImageProcessingConfigurationDefines {
  8383. IMAGEPROCESSING: boolean;
  8384. VIGNETTE: boolean;
  8385. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8386. VIGNETTEBLENDMODEOPAQUE: boolean;
  8387. TONEMAPPING: boolean;
  8388. TONEMAPPING_ACES: boolean;
  8389. CONTRAST: boolean;
  8390. EXPOSURE: boolean;
  8391. COLORCURVES: boolean;
  8392. COLORGRADING: boolean;
  8393. COLORGRADING3D: boolean;
  8394. SAMPLER3DGREENDEPTH: boolean;
  8395. SAMPLER3DBGRMAP: boolean;
  8396. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8397. }
  8398. /**
  8399. * @hidden
  8400. */
  8401. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8402. IMAGEPROCESSING: boolean;
  8403. VIGNETTE: boolean;
  8404. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8405. VIGNETTEBLENDMODEOPAQUE: boolean;
  8406. TONEMAPPING: boolean;
  8407. TONEMAPPING_ACES: boolean;
  8408. CONTRAST: boolean;
  8409. COLORCURVES: boolean;
  8410. COLORGRADING: boolean;
  8411. COLORGRADING3D: boolean;
  8412. SAMPLER3DGREENDEPTH: boolean;
  8413. SAMPLER3DBGRMAP: boolean;
  8414. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8415. EXPOSURE: boolean;
  8416. constructor();
  8417. }
  8418. /**
  8419. * This groups together the common properties used for image processing either in direct forward pass
  8420. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8421. * or not.
  8422. */
  8423. export class ImageProcessingConfiguration {
  8424. /**
  8425. * Default tone mapping applied in BabylonJS.
  8426. */
  8427. static readonly TONEMAPPING_STANDARD: number;
  8428. /**
  8429. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8430. * to other engines rendering to increase portability.
  8431. */
  8432. static readonly TONEMAPPING_ACES: number;
  8433. /**
  8434. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8435. */
  8436. colorCurves: Nullable<ColorCurves>;
  8437. private _colorCurvesEnabled;
  8438. /**
  8439. * Gets wether the color curves effect is enabled.
  8440. */
  8441. get colorCurvesEnabled(): boolean;
  8442. /**
  8443. * Sets wether the color curves effect is enabled.
  8444. */
  8445. set colorCurvesEnabled(value: boolean);
  8446. private _colorGradingTexture;
  8447. /**
  8448. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8449. */
  8450. get colorGradingTexture(): Nullable<BaseTexture>;
  8451. /**
  8452. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8453. */
  8454. set colorGradingTexture(value: Nullable<BaseTexture>);
  8455. private _colorGradingEnabled;
  8456. /**
  8457. * Gets wether the color grading effect is enabled.
  8458. */
  8459. get colorGradingEnabled(): boolean;
  8460. /**
  8461. * Sets wether the color grading effect is enabled.
  8462. */
  8463. set colorGradingEnabled(value: boolean);
  8464. private _colorGradingWithGreenDepth;
  8465. /**
  8466. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8467. */
  8468. get colorGradingWithGreenDepth(): boolean;
  8469. /**
  8470. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8471. */
  8472. set colorGradingWithGreenDepth(value: boolean);
  8473. private _colorGradingBGR;
  8474. /**
  8475. * Gets wether the color grading texture contains BGR values.
  8476. */
  8477. get colorGradingBGR(): boolean;
  8478. /**
  8479. * Sets wether the color grading texture contains BGR values.
  8480. */
  8481. set colorGradingBGR(value: boolean);
  8482. /** @hidden */
  8483. _exposure: number;
  8484. /**
  8485. * Gets the Exposure used in the effect.
  8486. */
  8487. get exposure(): number;
  8488. /**
  8489. * Sets the Exposure used in the effect.
  8490. */
  8491. set exposure(value: number);
  8492. private _toneMappingEnabled;
  8493. /**
  8494. * Gets wether the tone mapping effect is enabled.
  8495. */
  8496. get toneMappingEnabled(): boolean;
  8497. /**
  8498. * Sets wether the tone mapping effect is enabled.
  8499. */
  8500. set toneMappingEnabled(value: boolean);
  8501. private _toneMappingType;
  8502. /**
  8503. * Gets the type of tone mapping effect.
  8504. */
  8505. get toneMappingType(): number;
  8506. /**
  8507. * Sets the type of tone mapping effect used in BabylonJS.
  8508. */
  8509. set toneMappingType(value: number);
  8510. protected _contrast: number;
  8511. /**
  8512. * Gets the contrast used in the effect.
  8513. */
  8514. get contrast(): number;
  8515. /**
  8516. * Sets the contrast used in the effect.
  8517. */
  8518. set contrast(value: number);
  8519. /**
  8520. * Vignette stretch size.
  8521. */
  8522. vignetteStretch: number;
  8523. /**
  8524. * Vignette centre X Offset.
  8525. */
  8526. vignetteCentreX: number;
  8527. /**
  8528. * Vignette centre Y Offset.
  8529. */
  8530. vignetteCentreY: number;
  8531. /**
  8532. * Vignette weight or intensity of the vignette effect.
  8533. */
  8534. vignetteWeight: number;
  8535. /**
  8536. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8537. * if vignetteEnabled is set to true.
  8538. */
  8539. vignetteColor: Color4;
  8540. /**
  8541. * Camera field of view used by the Vignette effect.
  8542. */
  8543. vignetteCameraFov: number;
  8544. private _vignetteBlendMode;
  8545. /**
  8546. * Gets the vignette blend mode allowing different kind of effect.
  8547. */
  8548. get vignetteBlendMode(): number;
  8549. /**
  8550. * Sets the vignette blend mode allowing different kind of effect.
  8551. */
  8552. set vignetteBlendMode(value: number);
  8553. private _vignetteEnabled;
  8554. /**
  8555. * Gets wether the vignette effect is enabled.
  8556. */
  8557. get vignetteEnabled(): boolean;
  8558. /**
  8559. * Sets wether the vignette effect is enabled.
  8560. */
  8561. set vignetteEnabled(value: boolean);
  8562. private _applyByPostProcess;
  8563. /**
  8564. * Gets wether the image processing is applied through a post process or not.
  8565. */
  8566. get applyByPostProcess(): boolean;
  8567. /**
  8568. * Sets wether the image processing is applied through a post process or not.
  8569. */
  8570. set applyByPostProcess(value: boolean);
  8571. private _isEnabled;
  8572. /**
  8573. * Gets wether the image processing is enabled or not.
  8574. */
  8575. get isEnabled(): boolean;
  8576. /**
  8577. * Sets wether the image processing is enabled or not.
  8578. */
  8579. set isEnabled(value: boolean);
  8580. /**
  8581. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8582. */
  8583. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8584. /**
  8585. * Method called each time the image processing information changes requires to recompile the effect.
  8586. */
  8587. protected _updateParameters(): void;
  8588. /**
  8589. * Gets the current class name.
  8590. * @return "ImageProcessingConfiguration"
  8591. */
  8592. getClassName(): string;
  8593. /**
  8594. * Prepare the list of uniforms associated with the Image Processing effects.
  8595. * @param uniforms The list of uniforms used in the effect
  8596. * @param defines the list of defines currently in use
  8597. */
  8598. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8599. /**
  8600. * Prepare the list of samplers associated with the Image Processing effects.
  8601. * @param samplersList The list of uniforms used in the effect
  8602. * @param defines the list of defines currently in use
  8603. */
  8604. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8605. /**
  8606. * Prepare the list of defines associated to the shader.
  8607. * @param defines the list of defines to complete
  8608. * @param forPostProcess Define if we are currently in post process mode or not
  8609. */
  8610. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8611. /**
  8612. * Returns true if all the image processing information are ready.
  8613. * @returns True if ready, otherwise, false
  8614. */
  8615. isReady(): boolean;
  8616. /**
  8617. * Binds the image processing to the shader.
  8618. * @param effect The effect to bind to
  8619. * @param overrideAspectRatio Override the aspect ratio of the effect
  8620. */
  8621. bind(effect: Effect, overrideAspectRatio?: number): void;
  8622. /**
  8623. * Clones the current image processing instance.
  8624. * @return The cloned image processing
  8625. */
  8626. clone(): ImageProcessingConfiguration;
  8627. /**
  8628. * Serializes the current image processing instance to a json representation.
  8629. * @return a JSON representation
  8630. */
  8631. serialize(): any;
  8632. /**
  8633. * Parses the image processing from a json representation.
  8634. * @param source the JSON source to parse
  8635. * @return The parsed image processing
  8636. */
  8637. static Parse(source: any): ImageProcessingConfiguration;
  8638. private static _VIGNETTEMODE_MULTIPLY;
  8639. private static _VIGNETTEMODE_OPAQUE;
  8640. /**
  8641. * Used to apply the vignette as a mix with the pixel color.
  8642. */
  8643. static get VIGNETTEMODE_MULTIPLY(): number;
  8644. /**
  8645. * Used to apply the vignette as a replacement of the pixel color.
  8646. */
  8647. static get VIGNETTEMODE_OPAQUE(): number;
  8648. }
  8649. }
  8650. declare module BABYLON {
  8651. /** @hidden */
  8652. export var postprocessVertexShader: {
  8653. name: string;
  8654. shader: string;
  8655. };
  8656. }
  8657. declare module BABYLON {
  8658. /**
  8659. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8660. */
  8661. export type RenderTargetTextureSize = number | {
  8662. width: number;
  8663. height: number;
  8664. layers?: number;
  8665. };
  8666. interface ThinEngine {
  8667. /**
  8668. * Creates a new render target texture
  8669. * @param size defines the size of the texture
  8670. * @param options defines the options used to create the texture
  8671. * @returns a new render target texture stored in an InternalTexture
  8672. */
  8673. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8674. /**
  8675. * Creates a depth stencil texture.
  8676. * This is only available in WebGL 2 or with the depth texture extension available.
  8677. * @param size The size of face edge in the texture.
  8678. * @param options The options defining the texture.
  8679. * @returns The texture
  8680. */
  8681. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8682. /** @hidden */
  8683. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8684. }
  8685. }
  8686. declare module BABYLON {
  8687. /**
  8688. * Defines the kind of connection point for node based material
  8689. */
  8690. export enum NodeMaterialBlockConnectionPointTypes {
  8691. /** Float */
  8692. Float = 1,
  8693. /** Int */
  8694. Int = 2,
  8695. /** Vector2 */
  8696. Vector2 = 4,
  8697. /** Vector3 */
  8698. Vector3 = 8,
  8699. /** Vector4 */
  8700. Vector4 = 16,
  8701. /** Color3 */
  8702. Color3 = 32,
  8703. /** Color4 */
  8704. Color4 = 64,
  8705. /** Matrix */
  8706. Matrix = 128,
  8707. /** Custom object */
  8708. Object = 256,
  8709. /** Detect type based on connection */
  8710. AutoDetect = 1024,
  8711. /** Output type that will be defined by input type */
  8712. BasedOnInput = 2048
  8713. }
  8714. }
  8715. declare module BABYLON {
  8716. /**
  8717. * Enum used to define the target of a block
  8718. */
  8719. export enum NodeMaterialBlockTargets {
  8720. /** Vertex shader */
  8721. Vertex = 1,
  8722. /** Fragment shader */
  8723. Fragment = 2,
  8724. /** Neutral */
  8725. Neutral = 4,
  8726. /** Vertex and Fragment */
  8727. VertexAndFragment = 3
  8728. }
  8729. }
  8730. declare module BABYLON {
  8731. /**
  8732. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8733. */
  8734. export enum NodeMaterialBlockConnectionPointMode {
  8735. /** Value is an uniform */
  8736. Uniform = 0,
  8737. /** Value is a mesh attribute */
  8738. Attribute = 1,
  8739. /** Value is a varying between vertex and fragment shaders */
  8740. Varying = 2,
  8741. /** Mode is undefined */
  8742. Undefined = 3
  8743. }
  8744. }
  8745. declare module BABYLON {
  8746. /**
  8747. * Enum used to define system values e.g. values automatically provided by the system
  8748. */
  8749. export enum NodeMaterialSystemValues {
  8750. /** World */
  8751. World = 1,
  8752. /** View */
  8753. View = 2,
  8754. /** Projection */
  8755. Projection = 3,
  8756. /** ViewProjection */
  8757. ViewProjection = 4,
  8758. /** WorldView */
  8759. WorldView = 5,
  8760. /** WorldViewProjection */
  8761. WorldViewProjection = 6,
  8762. /** CameraPosition */
  8763. CameraPosition = 7,
  8764. /** Fog Color */
  8765. FogColor = 8,
  8766. /** Delta time */
  8767. DeltaTime = 9
  8768. }
  8769. }
  8770. declare module BABYLON {
  8771. /** Defines supported spaces */
  8772. export enum Space {
  8773. /** Local (object) space */
  8774. LOCAL = 0,
  8775. /** World space */
  8776. WORLD = 1,
  8777. /** Bone space */
  8778. BONE = 2
  8779. }
  8780. /** Defines the 3 main axes */
  8781. export class Axis {
  8782. /** X axis */
  8783. static X: Vector3;
  8784. /** Y axis */
  8785. static Y: Vector3;
  8786. /** Z axis */
  8787. static Z: Vector3;
  8788. }
  8789. }
  8790. declare module BABYLON {
  8791. /**
  8792. * Represents a camera frustum
  8793. */
  8794. export class Frustum {
  8795. /**
  8796. * Gets the planes representing the frustum
  8797. * @param transform matrix to be applied to the returned planes
  8798. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8799. */
  8800. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8801. /**
  8802. * Gets the near frustum plane transformed by the transform matrix
  8803. * @param transform transformation matrix to be applied to the resulting frustum plane
  8804. * @param frustumPlane the resuling frustum plane
  8805. */
  8806. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8807. /**
  8808. * Gets the far frustum plane transformed by the transform matrix
  8809. * @param transform transformation matrix to be applied to the resulting frustum plane
  8810. * @param frustumPlane the resuling frustum plane
  8811. */
  8812. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8813. /**
  8814. * Gets the left frustum plane transformed by the transform matrix
  8815. * @param transform transformation matrix to be applied to the resulting frustum plane
  8816. * @param frustumPlane the resuling frustum plane
  8817. */
  8818. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8819. /**
  8820. * Gets the right frustum plane transformed by the transform matrix
  8821. * @param transform transformation matrix to be applied to the resulting frustum plane
  8822. * @param frustumPlane the resuling frustum plane
  8823. */
  8824. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8825. /**
  8826. * Gets the top frustum plane transformed by the transform matrix
  8827. * @param transform transformation matrix to be applied to the resulting frustum plane
  8828. * @param frustumPlane the resuling frustum plane
  8829. */
  8830. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8831. /**
  8832. * Gets the bottom frustum plane transformed by the transform matrix
  8833. * @param transform transformation matrix to be applied to the resulting frustum plane
  8834. * @param frustumPlane the resuling frustum plane
  8835. */
  8836. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8837. /**
  8838. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8839. * @param transform transformation matrix to be applied to the resulting frustum planes
  8840. * @param frustumPlanes the resuling frustum planes
  8841. */
  8842. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8843. }
  8844. }
  8845. declare module BABYLON {
  8846. /**
  8847. * Interface for the size containing width and height
  8848. */
  8849. export interface ISize {
  8850. /**
  8851. * Width
  8852. */
  8853. width: number;
  8854. /**
  8855. * Heighht
  8856. */
  8857. height: number;
  8858. }
  8859. /**
  8860. * Size containing widht and height
  8861. */
  8862. export class Size implements ISize {
  8863. /**
  8864. * Width
  8865. */
  8866. width: number;
  8867. /**
  8868. * Height
  8869. */
  8870. height: number;
  8871. /**
  8872. * Creates a Size object from the given width and height (floats).
  8873. * @param width width of the new size
  8874. * @param height height of the new size
  8875. */
  8876. constructor(width: number, height: number);
  8877. /**
  8878. * Returns a string with the Size width and height
  8879. * @returns a string with the Size width and height
  8880. */
  8881. toString(): string;
  8882. /**
  8883. * "Size"
  8884. * @returns the string "Size"
  8885. */
  8886. getClassName(): string;
  8887. /**
  8888. * Returns the Size hash code.
  8889. * @returns a hash code for a unique width and height
  8890. */
  8891. getHashCode(): number;
  8892. /**
  8893. * Updates the current size from the given one.
  8894. * @param src the given size
  8895. */
  8896. copyFrom(src: Size): void;
  8897. /**
  8898. * Updates in place the current Size from the given floats.
  8899. * @param width width of the new size
  8900. * @param height height of the new size
  8901. * @returns the updated Size.
  8902. */
  8903. copyFromFloats(width: number, height: number): Size;
  8904. /**
  8905. * Updates in place the current Size from the given floats.
  8906. * @param width width to set
  8907. * @param height height to set
  8908. * @returns the updated Size.
  8909. */
  8910. set(width: number, height: number): Size;
  8911. /**
  8912. * Multiplies the width and height by numbers
  8913. * @param w factor to multiple the width by
  8914. * @param h factor to multiple the height by
  8915. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8916. */
  8917. multiplyByFloats(w: number, h: number): Size;
  8918. /**
  8919. * Clones the size
  8920. * @returns a new Size copied from the given one.
  8921. */
  8922. clone(): Size;
  8923. /**
  8924. * True if the current Size and the given one width and height are strictly equal.
  8925. * @param other the other size to compare against
  8926. * @returns True if the current Size and the given one width and height are strictly equal.
  8927. */
  8928. equals(other: Size): boolean;
  8929. /**
  8930. * The surface of the Size : width * height (float).
  8931. */
  8932. get surface(): number;
  8933. /**
  8934. * Create a new size of zero
  8935. * @returns a new Size set to (0.0, 0.0)
  8936. */
  8937. static Zero(): Size;
  8938. /**
  8939. * Sums the width and height of two sizes
  8940. * @param otherSize size to add to this size
  8941. * @returns a new Size set as the addition result of the current Size and the given one.
  8942. */
  8943. add(otherSize: Size): Size;
  8944. /**
  8945. * Subtracts the width and height of two
  8946. * @param otherSize size to subtract to this size
  8947. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8948. */
  8949. subtract(otherSize: Size): Size;
  8950. /**
  8951. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8952. * @param start starting size to lerp between
  8953. * @param end end size to lerp between
  8954. * @param amount amount to lerp between the start and end values
  8955. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8956. */
  8957. static Lerp(start: Size, end: Size, amount: number): Size;
  8958. }
  8959. }
  8960. declare module BABYLON {
  8961. /**
  8962. * Contains position and normal vectors for a vertex
  8963. */
  8964. export class PositionNormalVertex {
  8965. /** the position of the vertex (defaut: 0,0,0) */
  8966. position: Vector3;
  8967. /** the normal of the vertex (defaut: 0,1,0) */
  8968. normal: Vector3;
  8969. /**
  8970. * Creates a PositionNormalVertex
  8971. * @param position the position of the vertex (defaut: 0,0,0)
  8972. * @param normal the normal of the vertex (defaut: 0,1,0)
  8973. */
  8974. constructor(
  8975. /** the position of the vertex (defaut: 0,0,0) */
  8976. position?: Vector3,
  8977. /** the normal of the vertex (defaut: 0,1,0) */
  8978. normal?: Vector3);
  8979. /**
  8980. * Clones the PositionNormalVertex
  8981. * @returns the cloned PositionNormalVertex
  8982. */
  8983. clone(): PositionNormalVertex;
  8984. }
  8985. /**
  8986. * Contains position, normal and uv vectors for a vertex
  8987. */
  8988. export class PositionNormalTextureVertex {
  8989. /** the position of the vertex (defaut: 0,0,0) */
  8990. position: Vector3;
  8991. /** the normal of the vertex (defaut: 0,1,0) */
  8992. normal: Vector3;
  8993. /** the uv of the vertex (default: 0,0) */
  8994. uv: Vector2;
  8995. /**
  8996. * Creates a PositionNormalTextureVertex
  8997. * @param position the position of the vertex (defaut: 0,0,0)
  8998. * @param normal the normal of the vertex (defaut: 0,1,0)
  8999. * @param uv the uv of the vertex (default: 0,0)
  9000. */
  9001. constructor(
  9002. /** the position of the vertex (defaut: 0,0,0) */
  9003. position?: Vector3,
  9004. /** the normal of the vertex (defaut: 0,1,0) */
  9005. normal?: Vector3,
  9006. /** the uv of the vertex (default: 0,0) */
  9007. uv?: Vector2);
  9008. /**
  9009. * Clones the PositionNormalTextureVertex
  9010. * @returns the cloned PositionNormalTextureVertex
  9011. */
  9012. clone(): PositionNormalTextureVertex;
  9013. }
  9014. }
  9015. declare module BABYLON {
  9016. /**
  9017. * Enum defining the type of animations supported by InputBlock
  9018. */
  9019. export enum AnimatedInputBlockTypes {
  9020. /** No animation */
  9021. None = 0,
  9022. /** Time based animation. Will only work for floats */
  9023. Time = 1
  9024. }
  9025. }
  9026. declare module BABYLON {
  9027. /**
  9028. * Interface describing all the common properties and methods a shadow light needs to implement.
  9029. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9030. * as well as binding the different shadow properties to the effects.
  9031. */
  9032. export interface IShadowLight extends Light {
  9033. /**
  9034. * The light id in the scene (used in scene.findLighById for instance)
  9035. */
  9036. id: string;
  9037. /**
  9038. * The position the shdow will be casted from.
  9039. */
  9040. position: Vector3;
  9041. /**
  9042. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9043. */
  9044. direction: Vector3;
  9045. /**
  9046. * The transformed position. Position of the light in world space taking parenting in account.
  9047. */
  9048. transformedPosition: Vector3;
  9049. /**
  9050. * The transformed direction. Direction of the light in world space taking parenting in account.
  9051. */
  9052. transformedDirection: Vector3;
  9053. /**
  9054. * The friendly name of the light in the scene.
  9055. */
  9056. name: string;
  9057. /**
  9058. * Defines the shadow projection clipping minimum z value.
  9059. */
  9060. shadowMinZ: number;
  9061. /**
  9062. * Defines the shadow projection clipping maximum z value.
  9063. */
  9064. shadowMaxZ: number;
  9065. /**
  9066. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9067. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9068. */
  9069. computeTransformedInformation(): boolean;
  9070. /**
  9071. * Gets the scene the light belongs to.
  9072. * @returns The scene
  9073. */
  9074. getScene(): Scene;
  9075. /**
  9076. * Callback defining a custom Projection Matrix Builder.
  9077. * This can be used to override the default projection matrix computation.
  9078. */
  9079. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9080. /**
  9081. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9082. * @param matrix The materix to updated with the projection information
  9083. * @param viewMatrix The transform matrix of the light
  9084. * @param renderList The list of mesh to render in the map
  9085. * @returns The current light
  9086. */
  9087. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9088. /**
  9089. * Gets the current depth scale used in ESM.
  9090. * @returns The scale
  9091. */
  9092. getDepthScale(): number;
  9093. /**
  9094. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9095. * @returns true if a cube texture needs to be use
  9096. */
  9097. needCube(): boolean;
  9098. /**
  9099. * Detects if the projection matrix requires to be recomputed this frame.
  9100. * @returns true if it requires to be recomputed otherwise, false.
  9101. */
  9102. needProjectionMatrixCompute(): boolean;
  9103. /**
  9104. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9105. */
  9106. forceProjectionMatrixCompute(): void;
  9107. /**
  9108. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9109. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9110. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9111. */
  9112. getShadowDirection(faceIndex?: number): Vector3;
  9113. /**
  9114. * Gets the minZ used for shadow according to both the scene and the light.
  9115. * @param activeCamera The camera we are returning the min for
  9116. * @returns the depth min z
  9117. */
  9118. getDepthMinZ(activeCamera: Camera): number;
  9119. /**
  9120. * Gets the maxZ used for shadow according to both the scene and the light.
  9121. * @param activeCamera The camera we are returning the max for
  9122. * @returns the depth max z
  9123. */
  9124. getDepthMaxZ(activeCamera: Camera): number;
  9125. }
  9126. /**
  9127. * Base implementation IShadowLight
  9128. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9129. */
  9130. export abstract class ShadowLight extends Light implements IShadowLight {
  9131. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9132. protected _position: Vector3;
  9133. protected _setPosition(value: Vector3): void;
  9134. /**
  9135. * Sets the position the shadow will be casted from. Also use as the light position for both
  9136. * point and spot lights.
  9137. */
  9138. get position(): Vector3;
  9139. /**
  9140. * Sets the position the shadow will be casted from. Also use as the light position for both
  9141. * point and spot lights.
  9142. */
  9143. set position(value: Vector3);
  9144. protected _direction: Vector3;
  9145. protected _setDirection(value: Vector3): void;
  9146. /**
  9147. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9148. * Also use as the light direction on spot and directional lights.
  9149. */
  9150. get direction(): Vector3;
  9151. /**
  9152. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9153. * Also use as the light direction on spot and directional lights.
  9154. */
  9155. set direction(value: Vector3);
  9156. protected _shadowMinZ: number;
  9157. /**
  9158. * Gets the shadow projection clipping minimum z value.
  9159. */
  9160. get shadowMinZ(): number;
  9161. /**
  9162. * Sets the shadow projection clipping minimum z value.
  9163. */
  9164. set shadowMinZ(value: number);
  9165. protected _shadowMaxZ: number;
  9166. /**
  9167. * Sets the shadow projection clipping maximum z value.
  9168. */
  9169. get shadowMaxZ(): number;
  9170. /**
  9171. * Gets the shadow projection clipping maximum z value.
  9172. */
  9173. set shadowMaxZ(value: number);
  9174. /**
  9175. * Callback defining a custom Projection Matrix Builder.
  9176. * This can be used to override the default projection matrix computation.
  9177. */
  9178. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9179. /**
  9180. * The transformed position. Position of the light in world space taking parenting in account.
  9181. */
  9182. transformedPosition: Vector3;
  9183. /**
  9184. * The transformed direction. Direction of the light in world space taking parenting in account.
  9185. */
  9186. transformedDirection: Vector3;
  9187. private _needProjectionMatrixCompute;
  9188. /**
  9189. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9190. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9191. */
  9192. computeTransformedInformation(): boolean;
  9193. /**
  9194. * Return the depth scale used for the shadow map.
  9195. * @returns the depth scale.
  9196. */
  9197. getDepthScale(): number;
  9198. /**
  9199. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9200. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9201. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9202. */
  9203. getShadowDirection(faceIndex?: number): Vector3;
  9204. /**
  9205. * Returns the ShadowLight absolute position in the World.
  9206. * @returns the position vector in world space
  9207. */
  9208. getAbsolutePosition(): Vector3;
  9209. /**
  9210. * Sets the ShadowLight direction toward the passed target.
  9211. * @param target The point to target in local space
  9212. * @returns the updated ShadowLight direction
  9213. */
  9214. setDirectionToTarget(target: Vector3): Vector3;
  9215. /**
  9216. * Returns the light rotation in euler definition.
  9217. * @returns the x y z rotation in local space.
  9218. */
  9219. getRotation(): Vector3;
  9220. /**
  9221. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9222. * @returns true if a cube texture needs to be use
  9223. */
  9224. needCube(): boolean;
  9225. /**
  9226. * Detects if the projection matrix requires to be recomputed this frame.
  9227. * @returns true if it requires to be recomputed otherwise, false.
  9228. */
  9229. needProjectionMatrixCompute(): boolean;
  9230. /**
  9231. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9232. */
  9233. forceProjectionMatrixCompute(): void;
  9234. /** @hidden */
  9235. _initCache(): void;
  9236. /** @hidden */
  9237. _isSynchronized(): boolean;
  9238. /**
  9239. * Computes the world matrix of the node
  9240. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9241. * @returns the world matrix
  9242. */
  9243. computeWorldMatrix(force?: boolean): Matrix;
  9244. /**
  9245. * Gets the minZ used for shadow according to both the scene and the light.
  9246. * @param activeCamera The camera we are returning the min for
  9247. * @returns the depth min z
  9248. */
  9249. getDepthMinZ(activeCamera: Camera): number;
  9250. /**
  9251. * Gets the maxZ used for shadow according to both the scene and the light.
  9252. * @param activeCamera The camera we are returning the max for
  9253. * @returns the depth max z
  9254. */
  9255. getDepthMaxZ(activeCamera: Camera): number;
  9256. /**
  9257. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9258. * @param matrix The materix to updated with the projection information
  9259. * @param viewMatrix The transform matrix of the light
  9260. * @param renderList The list of mesh to render in the map
  9261. * @returns The current light
  9262. */
  9263. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9264. }
  9265. }
  9266. declare module BABYLON {
  9267. /** @hidden */
  9268. export var packingFunctions: {
  9269. name: string;
  9270. shader: string;
  9271. };
  9272. }
  9273. declare module BABYLON {
  9274. /** @hidden */
  9275. export var bayerDitherFunctions: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module BABYLON {
  9281. /** @hidden */
  9282. export var shadowMapFragmentDeclaration: {
  9283. name: string;
  9284. shader: string;
  9285. };
  9286. }
  9287. declare module BABYLON {
  9288. /** @hidden */
  9289. export var clipPlaneFragmentDeclaration: {
  9290. name: string;
  9291. shader: string;
  9292. };
  9293. }
  9294. declare module BABYLON {
  9295. /** @hidden */
  9296. export var clipPlaneFragment: {
  9297. name: string;
  9298. shader: string;
  9299. };
  9300. }
  9301. declare module BABYLON {
  9302. /** @hidden */
  9303. export var shadowMapFragment: {
  9304. name: string;
  9305. shader: string;
  9306. };
  9307. }
  9308. declare module BABYLON {
  9309. /** @hidden */
  9310. export var shadowMapPixelShader: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module BABYLON {
  9316. /** @hidden */
  9317. export var bonesDeclaration: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module BABYLON {
  9323. /** @hidden */
  9324. export var morphTargetsVertexGlobalDeclaration: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module BABYLON {
  9330. /** @hidden */
  9331. export var morphTargetsVertexDeclaration: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module BABYLON {
  9337. /** @hidden */
  9338. export var instancesDeclaration: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module BABYLON {
  9344. /** @hidden */
  9345. export var helperFunctions: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module BABYLON {
  9351. /** @hidden */
  9352. export var shadowMapVertexDeclaration: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module BABYLON {
  9358. /** @hidden */
  9359. export var clipPlaneVertexDeclaration: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module BABYLON {
  9365. /** @hidden */
  9366. export var morphTargetsVertex: {
  9367. name: string;
  9368. shader: string;
  9369. };
  9370. }
  9371. declare module BABYLON {
  9372. /** @hidden */
  9373. export var instancesVertex: {
  9374. name: string;
  9375. shader: string;
  9376. };
  9377. }
  9378. declare module BABYLON {
  9379. /** @hidden */
  9380. export var bonesVertex: {
  9381. name: string;
  9382. shader: string;
  9383. };
  9384. }
  9385. declare module BABYLON {
  9386. /** @hidden */
  9387. export var shadowMapVertexNormalBias: {
  9388. name: string;
  9389. shader: string;
  9390. };
  9391. }
  9392. declare module BABYLON {
  9393. /** @hidden */
  9394. export var shadowMapVertexMetric: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module BABYLON {
  9400. /** @hidden */
  9401. export var clipPlaneVertex: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module BABYLON {
  9407. /** @hidden */
  9408. export var shadowMapVertexShader: {
  9409. name: string;
  9410. shader: string;
  9411. };
  9412. }
  9413. declare module BABYLON {
  9414. /** @hidden */
  9415. export var depthBoxBlurPixelShader: {
  9416. name: string;
  9417. shader: string;
  9418. };
  9419. }
  9420. declare module BABYLON {
  9421. /** @hidden */
  9422. export var shadowMapFragmentSoftTransparentShadow: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module BABYLON {
  9428. /**
  9429. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9430. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9431. */
  9432. export class EffectFallbacks implements IEffectFallbacks {
  9433. private _defines;
  9434. private _currentRank;
  9435. private _maxRank;
  9436. private _mesh;
  9437. /**
  9438. * Removes the fallback from the bound mesh.
  9439. */
  9440. unBindMesh(): void;
  9441. /**
  9442. * Adds a fallback on the specified property.
  9443. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9444. * @param define The name of the define in the shader
  9445. */
  9446. addFallback(rank: number, define: string): void;
  9447. /**
  9448. * Sets the mesh to use CPU skinning when needing to fallback.
  9449. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9450. * @param mesh The mesh to use the fallbacks.
  9451. */
  9452. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9453. /**
  9454. * Checks to see if more fallbacks are still availible.
  9455. */
  9456. get hasMoreFallbacks(): boolean;
  9457. /**
  9458. * Removes the defines that should be removed when falling back.
  9459. * @param currentDefines defines the current define statements for the shader.
  9460. * @param effect defines the current effect we try to compile
  9461. * @returns The resulting defines with defines of the current rank removed.
  9462. */
  9463. reduce(currentDefines: string, effect: Effect): string;
  9464. }
  9465. }
  9466. declare module BABYLON {
  9467. /**
  9468. * Interface used to define Action
  9469. */
  9470. export interface IAction {
  9471. /**
  9472. * Trigger for the action
  9473. */
  9474. trigger: number;
  9475. /** Options of the trigger */
  9476. triggerOptions: any;
  9477. /**
  9478. * Gets the trigger parameters
  9479. * @returns the trigger parameters
  9480. */
  9481. getTriggerParameter(): any;
  9482. /**
  9483. * Internal only - executes current action event
  9484. * @hidden
  9485. */
  9486. _executeCurrent(evt?: ActionEvent): void;
  9487. /**
  9488. * Serialize placeholder for child classes
  9489. * @param parent of child
  9490. * @returns the serialized object
  9491. */
  9492. serialize(parent: any): any;
  9493. /**
  9494. * Internal only
  9495. * @hidden
  9496. */
  9497. _prepare(): void;
  9498. /**
  9499. * Internal only - manager for action
  9500. * @hidden
  9501. */
  9502. _actionManager: Nullable<AbstractActionManager>;
  9503. /**
  9504. * Adds action to chain of actions, may be a DoNothingAction
  9505. * @param action defines the next action to execute
  9506. * @returns The action passed in
  9507. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9508. */
  9509. then(action: IAction): IAction;
  9510. }
  9511. /**
  9512. * The action to be carried out following a trigger
  9513. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9514. */
  9515. export class Action implements IAction {
  9516. /** the trigger, with or without parameters, for the action */
  9517. triggerOptions: any;
  9518. /**
  9519. * Trigger for the action
  9520. */
  9521. trigger: number;
  9522. /**
  9523. * Internal only - manager for action
  9524. * @hidden
  9525. */
  9526. _actionManager: ActionManager;
  9527. private _nextActiveAction;
  9528. private _child;
  9529. private _condition?;
  9530. private _triggerParameter;
  9531. /**
  9532. * An event triggered prior to action being executed.
  9533. */
  9534. onBeforeExecuteObservable: Observable<Action>;
  9535. /**
  9536. * Creates a new Action
  9537. * @param triggerOptions the trigger, with or without parameters, for the action
  9538. * @param condition an optional determinant of action
  9539. */
  9540. constructor(
  9541. /** the trigger, with or without parameters, for the action */
  9542. triggerOptions: any, condition?: Condition);
  9543. /**
  9544. * Internal only
  9545. * @hidden
  9546. */
  9547. _prepare(): void;
  9548. /**
  9549. * Gets the trigger parameters
  9550. * @returns the trigger parameters
  9551. */
  9552. getTriggerParameter(): any;
  9553. /**
  9554. * Internal only - executes current action event
  9555. * @hidden
  9556. */
  9557. _executeCurrent(evt?: ActionEvent): void;
  9558. /**
  9559. * Execute placeholder for child classes
  9560. * @param evt optional action event
  9561. */
  9562. execute(evt?: ActionEvent): void;
  9563. /**
  9564. * Skips to next active action
  9565. */
  9566. skipToNextActiveAction(): void;
  9567. /**
  9568. * Adds action to chain of actions, may be a DoNothingAction
  9569. * @param action defines the next action to execute
  9570. * @returns The action passed in
  9571. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9572. */
  9573. then(action: Action): Action;
  9574. /**
  9575. * Internal only
  9576. * @hidden
  9577. */
  9578. _getProperty(propertyPath: string): string;
  9579. /**
  9580. * Internal only
  9581. * @hidden
  9582. */
  9583. _getEffectiveTarget(target: any, propertyPath: string): any;
  9584. /**
  9585. * Serialize placeholder for child classes
  9586. * @param parent of child
  9587. * @returns the serialized object
  9588. */
  9589. serialize(parent: any): any;
  9590. /**
  9591. * Internal only called by serialize
  9592. * @hidden
  9593. */
  9594. protected _serialize(serializedAction: any, parent?: any): any;
  9595. /**
  9596. * Internal only
  9597. * @hidden
  9598. */
  9599. static _SerializeValueAsString: (value: any) => string;
  9600. /**
  9601. * Internal only
  9602. * @hidden
  9603. */
  9604. static _GetTargetProperty: (target: Scene | Node) => {
  9605. name: string;
  9606. targetType: string;
  9607. value: string;
  9608. };
  9609. }
  9610. }
  9611. declare module BABYLON {
  9612. /**
  9613. * A Condition applied to an Action
  9614. */
  9615. export class Condition {
  9616. /**
  9617. * Internal only - manager for action
  9618. * @hidden
  9619. */
  9620. _actionManager: ActionManager;
  9621. /**
  9622. * Internal only
  9623. * @hidden
  9624. */
  9625. _evaluationId: number;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. _currentResult: boolean;
  9631. /**
  9632. * Creates a new Condition
  9633. * @param actionManager the manager of the action the condition is applied to
  9634. */
  9635. constructor(actionManager: ActionManager);
  9636. /**
  9637. * Check if the current condition is valid
  9638. * @returns a boolean
  9639. */
  9640. isValid(): boolean;
  9641. /**
  9642. * Internal only
  9643. * @hidden
  9644. */
  9645. _getProperty(propertyPath: string): string;
  9646. /**
  9647. * Internal only
  9648. * @hidden
  9649. */
  9650. _getEffectiveTarget(target: any, propertyPath: string): any;
  9651. /**
  9652. * Serialize placeholder for child classes
  9653. * @returns the serialized object
  9654. */
  9655. serialize(): any;
  9656. /**
  9657. * Internal only
  9658. * @hidden
  9659. */
  9660. protected _serialize(serializedCondition: any): any;
  9661. }
  9662. /**
  9663. * Defines specific conditional operators as extensions of Condition
  9664. */
  9665. export class ValueCondition extends Condition {
  9666. /** path to specify the property of the target the conditional operator uses */
  9667. propertyPath: string;
  9668. /** the value compared by the conditional operator against the current value of the property */
  9669. value: any;
  9670. /** the conditional operator, default ValueCondition.IsEqual */
  9671. operator: number;
  9672. /**
  9673. * Internal only
  9674. * @hidden
  9675. */
  9676. private static _IsEqual;
  9677. /**
  9678. * Internal only
  9679. * @hidden
  9680. */
  9681. private static _IsDifferent;
  9682. /**
  9683. * Internal only
  9684. * @hidden
  9685. */
  9686. private static _IsGreater;
  9687. /**
  9688. * Internal only
  9689. * @hidden
  9690. */
  9691. private static _IsLesser;
  9692. /**
  9693. * returns the number for IsEqual
  9694. */
  9695. static get IsEqual(): number;
  9696. /**
  9697. * Returns the number for IsDifferent
  9698. */
  9699. static get IsDifferent(): number;
  9700. /**
  9701. * Returns the number for IsGreater
  9702. */
  9703. static get IsGreater(): number;
  9704. /**
  9705. * Returns the number for IsLesser
  9706. */
  9707. static get IsLesser(): number;
  9708. /**
  9709. * Internal only The action manager for the condition
  9710. * @hidden
  9711. */
  9712. _actionManager: ActionManager;
  9713. /**
  9714. * Internal only
  9715. * @hidden
  9716. */
  9717. private _target;
  9718. /**
  9719. * Internal only
  9720. * @hidden
  9721. */
  9722. private _effectiveTarget;
  9723. /**
  9724. * Internal only
  9725. * @hidden
  9726. */
  9727. private _property;
  9728. /**
  9729. * Creates a new ValueCondition
  9730. * @param actionManager manager for the action the condition applies to
  9731. * @param target for the action
  9732. * @param propertyPath path to specify the property of the target the conditional operator uses
  9733. * @param value the value compared by the conditional operator against the current value of the property
  9734. * @param operator the conditional operator, default ValueCondition.IsEqual
  9735. */
  9736. constructor(actionManager: ActionManager, target: any,
  9737. /** path to specify the property of the target the conditional operator uses */
  9738. propertyPath: string,
  9739. /** the value compared by the conditional operator against the current value of the property */
  9740. value: any,
  9741. /** the conditional operator, default ValueCondition.IsEqual */
  9742. operator?: number);
  9743. /**
  9744. * Compares the given value with the property value for the specified conditional operator
  9745. * @returns the result of the comparison
  9746. */
  9747. isValid(): boolean;
  9748. /**
  9749. * Serialize the ValueCondition into a JSON compatible object
  9750. * @returns serialization object
  9751. */
  9752. serialize(): any;
  9753. /**
  9754. * Gets the name of the conditional operator for the ValueCondition
  9755. * @param operator the conditional operator
  9756. * @returns the name
  9757. */
  9758. static GetOperatorName(operator: number): string;
  9759. }
  9760. /**
  9761. * Defines a predicate condition as an extension of Condition
  9762. */
  9763. export class PredicateCondition extends Condition {
  9764. /** defines the predicate function used to validate the condition */
  9765. predicate: () => boolean;
  9766. /**
  9767. * Internal only - manager for action
  9768. * @hidden
  9769. */
  9770. _actionManager: ActionManager;
  9771. /**
  9772. * Creates a new PredicateCondition
  9773. * @param actionManager manager for the action the condition applies to
  9774. * @param predicate defines the predicate function used to validate the condition
  9775. */
  9776. constructor(actionManager: ActionManager,
  9777. /** defines the predicate function used to validate the condition */
  9778. predicate: () => boolean);
  9779. /**
  9780. * @returns the validity of the predicate condition
  9781. */
  9782. isValid(): boolean;
  9783. }
  9784. /**
  9785. * Defines a state condition as an extension of Condition
  9786. */
  9787. export class StateCondition extends Condition {
  9788. /** Value to compare with target state */
  9789. value: string;
  9790. /**
  9791. * Internal only - manager for action
  9792. * @hidden
  9793. */
  9794. _actionManager: ActionManager;
  9795. /**
  9796. * Internal only
  9797. * @hidden
  9798. */
  9799. private _target;
  9800. /**
  9801. * Creates a new StateCondition
  9802. * @param actionManager manager for the action the condition applies to
  9803. * @param target of the condition
  9804. * @param value to compare with target state
  9805. */
  9806. constructor(actionManager: ActionManager, target: any,
  9807. /** Value to compare with target state */
  9808. value: string);
  9809. /**
  9810. * Gets a boolean indicating if the current condition is met
  9811. * @returns the validity of the state
  9812. */
  9813. isValid(): boolean;
  9814. /**
  9815. * Serialize the StateCondition into a JSON compatible object
  9816. * @returns serialization object
  9817. */
  9818. serialize(): any;
  9819. }
  9820. }
  9821. declare module BABYLON {
  9822. /**
  9823. * This defines an action responsible to toggle a boolean once triggered.
  9824. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9825. */
  9826. export class SwitchBooleanAction extends Action {
  9827. /**
  9828. * The path to the boolean property in the target object
  9829. */
  9830. propertyPath: string;
  9831. private _target;
  9832. private _effectiveTarget;
  9833. private _property;
  9834. /**
  9835. * Instantiate the action
  9836. * @param triggerOptions defines the trigger options
  9837. * @param target defines the object containing the boolean
  9838. * @param propertyPath defines the path to the boolean property in the target object
  9839. * @param condition defines the trigger related conditions
  9840. */
  9841. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9842. /** @hidden */
  9843. _prepare(): void;
  9844. /**
  9845. * Execute the action toggle the boolean value.
  9846. */
  9847. execute(): void;
  9848. /**
  9849. * Serializes the actions and its related information.
  9850. * @param parent defines the object to serialize in
  9851. * @returns the serialized object
  9852. */
  9853. serialize(parent: any): any;
  9854. }
  9855. /**
  9856. * This defines an action responsible to set a the state field of the target
  9857. * to a desired value once triggered.
  9858. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9859. */
  9860. export class SetStateAction extends Action {
  9861. /**
  9862. * The value to store in the state field.
  9863. */
  9864. value: string;
  9865. private _target;
  9866. /**
  9867. * Instantiate the action
  9868. * @param triggerOptions defines the trigger options
  9869. * @param target defines the object containing the state property
  9870. * @param value defines the value to store in the state field
  9871. * @param condition defines the trigger related conditions
  9872. */
  9873. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9874. /**
  9875. * Execute the action and store the value on the target state property.
  9876. */
  9877. execute(): void;
  9878. /**
  9879. * Serializes the actions and its related information.
  9880. * @param parent defines the object to serialize in
  9881. * @returns the serialized object
  9882. */
  9883. serialize(parent: any): any;
  9884. }
  9885. /**
  9886. * This defines an action responsible to set a property of the target
  9887. * to a desired value once triggered.
  9888. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9889. */
  9890. export class SetValueAction extends Action {
  9891. /**
  9892. * The path of the property to set in the target.
  9893. */
  9894. propertyPath: string;
  9895. /**
  9896. * The value to set in the property
  9897. */
  9898. value: any;
  9899. private _target;
  9900. private _effectiveTarget;
  9901. private _property;
  9902. /**
  9903. * Instantiate the action
  9904. * @param triggerOptions defines the trigger options
  9905. * @param target defines the object containing the property
  9906. * @param propertyPath defines the path of the property to set in the target
  9907. * @param value defines the value to set in the property
  9908. * @param condition defines the trigger related conditions
  9909. */
  9910. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9911. /** @hidden */
  9912. _prepare(): void;
  9913. /**
  9914. * Execute the action and set the targetted property to the desired value.
  9915. */
  9916. execute(): void;
  9917. /**
  9918. * Serializes the actions and its related information.
  9919. * @param parent defines the object to serialize in
  9920. * @returns the serialized object
  9921. */
  9922. serialize(parent: any): any;
  9923. }
  9924. /**
  9925. * This defines an action responsible to increment the target value
  9926. * to a desired value once triggered.
  9927. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9928. */
  9929. export class IncrementValueAction extends Action {
  9930. /**
  9931. * The path of the property to increment in the target.
  9932. */
  9933. propertyPath: string;
  9934. /**
  9935. * The value we should increment the property by.
  9936. */
  9937. value: any;
  9938. private _target;
  9939. private _effectiveTarget;
  9940. private _property;
  9941. /**
  9942. * Instantiate the action
  9943. * @param triggerOptions defines the trigger options
  9944. * @param target defines the object containing the property
  9945. * @param propertyPath defines the path of the property to increment in the target
  9946. * @param value defines the value value we should increment the property by
  9947. * @param condition defines the trigger related conditions
  9948. */
  9949. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9950. /** @hidden */
  9951. _prepare(): void;
  9952. /**
  9953. * Execute the action and increment the target of the value amount.
  9954. */
  9955. execute(): void;
  9956. /**
  9957. * Serializes the actions and its related information.
  9958. * @param parent defines the object to serialize in
  9959. * @returns the serialized object
  9960. */
  9961. serialize(parent: any): any;
  9962. }
  9963. /**
  9964. * This defines an action responsible to start an animation once triggered.
  9965. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9966. */
  9967. export class PlayAnimationAction extends Action {
  9968. /**
  9969. * Where the animation should start (animation frame)
  9970. */
  9971. from: number;
  9972. /**
  9973. * Where the animation should stop (animation frame)
  9974. */
  9975. to: number;
  9976. /**
  9977. * Define if the animation should loop or stop after the first play.
  9978. */
  9979. loop?: boolean;
  9980. private _target;
  9981. /**
  9982. * Instantiate the action
  9983. * @param triggerOptions defines the trigger options
  9984. * @param target defines the target animation or animation name
  9985. * @param from defines from where the animation should start (animation frame)
  9986. * @param end defines where the animation should stop (animation frame)
  9987. * @param loop defines if the animation should loop or stop after the first play
  9988. * @param condition defines the trigger related conditions
  9989. */
  9990. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9991. /** @hidden */
  9992. _prepare(): void;
  9993. /**
  9994. * Execute the action and play the animation.
  9995. */
  9996. execute(): void;
  9997. /**
  9998. * Serializes the actions and its related information.
  9999. * @param parent defines the object to serialize in
  10000. * @returns the serialized object
  10001. */
  10002. serialize(parent: any): any;
  10003. }
  10004. /**
  10005. * This defines an action responsible to stop an animation once triggered.
  10006. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10007. */
  10008. export class StopAnimationAction extends Action {
  10009. private _target;
  10010. /**
  10011. * Instantiate the action
  10012. * @param triggerOptions defines the trigger options
  10013. * @param target defines the target animation or animation name
  10014. * @param condition defines the trigger related conditions
  10015. */
  10016. constructor(triggerOptions: any, target: any, condition?: Condition);
  10017. /** @hidden */
  10018. _prepare(): void;
  10019. /**
  10020. * Execute the action and stop the animation.
  10021. */
  10022. execute(): void;
  10023. /**
  10024. * Serializes the actions and its related information.
  10025. * @param parent defines the object to serialize in
  10026. * @returns the serialized object
  10027. */
  10028. serialize(parent: any): any;
  10029. }
  10030. /**
  10031. * This defines an action responsible that does nothing once triggered.
  10032. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10033. */
  10034. export class DoNothingAction extends Action {
  10035. /**
  10036. * Instantiate the action
  10037. * @param triggerOptions defines the trigger options
  10038. * @param condition defines the trigger related conditions
  10039. */
  10040. constructor(triggerOptions?: any, condition?: Condition);
  10041. /**
  10042. * Execute the action and do nothing.
  10043. */
  10044. execute(): void;
  10045. /**
  10046. * Serializes the actions and its related information.
  10047. * @param parent defines the object to serialize in
  10048. * @returns the serialized object
  10049. */
  10050. serialize(parent: any): any;
  10051. }
  10052. /**
  10053. * This defines an action responsible to trigger several actions once triggered.
  10054. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10055. */
  10056. export class CombineAction extends Action {
  10057. /**
  10058. * The list of aggregated animations to run.
  10059. */
  10060. children: Action[];
  10061. /**
  10062. * Instantiate the action
  10063. * @param triggerOptions defines the trigger options
  10064. * @param children defines the list of aggregated animations to run
  10065. * @param condition defines the trigger related conditions
  10066. */
  10067. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10068. /** @hidden */
  10069. _prepare(): void;
  10070. /**
  10071. * Execute the action and executes all the aggregated actions.
  10072. */
  10073. execute(evt: ActionEvent): void;
  10074. /**
  10075. * Serializes the actions and its related information.
  10076. * @param parent defines the object to serialize in
  10077. * @returns the serialized object
  10078. */
  10079. serialize(parent: any): any;
  10080. }
  10081. /**
  10082. * This defines an action responsible to run code (external event) once triggered.
  10083. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10084. */
  10085. export class ExecuteCodeAction extends Action {
  10086. /**
  10087. * The callback function to run.
  10088. */
  10089. func: (evt: ActionEvent) => void;
  10090. /**
  10091. * Instantiate the action
  10092. * @param triggerOptions defines the trigger options
  10093. * @param func defines the callback function to run
  10094. * @param condition defines the trigger related conditions
  10095. */
  10096. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10097. /**
  10098. * Execute the action and run the attached code.
  10099. */
  10100. execute(evt: ActionEvent): void;
  10101. }
  10102. /**
  10103. * This defines an action responsible to set the parent property of the target once triggered.
  10104. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10105. */
  10106. export class SetParentAction extends Action {
  10107. private _parent;
  10108. private _target;
  10109. /**
  10110. * Instantiate the action
  10111. * @param triggerOptions defines the trigger options
  10112. * @param target defines the target containing the parent property
  10113. * @param parent defines from where the animation should start (animation frame)
  10114. * @param condition defines the trigger related conditions
  10115. */
  10116. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10117. /** @hidden */
  10118. _prepare(): void;
  10119. /**
  10120. * Execute the action and set the parent property.
  10121. */
  10122. execute(): void;
  10123. /**
  10124. * Serializes the actions and its related information.
  10125. * @param parent defines the object to serialize in
  10126. * @returns the serialized object
  10127. */
  10128. serialize(parent: any): any;
  10129. }
  10130. }
  10131. declare module BABYLON {
  10132. /**
  10133. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10134. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10136. */
  10137. export class ActionManager extends AbstractActionManager {
  10138. /**
  10139. * Nothing
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly NothingTrigger: number;
  10143. /**
  10144. * On pick
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnPickTrigger: number;
  10148. /**
  10149. * On left pick
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnLeftPickTrigger: number;
  10153. /**
  10154. * On right pick
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnRightPickTrigger: number;
  10158. /**
  10159. * On center pick
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnCenterPickTrigger: number;
  10163. /**
  10164. * On pick down
  10165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10166. */
  10167. static readonly OnPickDownTrigger: number;
  10168. /**
  10169. * On double pick
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10171. */
  10172. static readonly OnDoublePickTrigger: number;
  10173. /**
  10174. * On pick up
  10175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10176. */
  10177. static readonly OnPickUpTrigger: number;
  10178. /**
  10179. * On pick out.
  10180. * This trigger will only be raised if you also declared a OnPickDown
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnPickOutTrigger: number;
  10184. /**
  10185. * On long press
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnLongPressTrigger: number;
  10189. /**
  10190. * On pointer over
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnPointerOverTrigger: number;
  10194. /**
  10195. * On pointer out
  10196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10197. */
  10198. static readonly OnPointerOutTrigger: number;
  10199. /**
  10200. * On every frame
  10201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10202. */
  10203. static readonly OnEveryFrameTrigger: number;
  10204. /**
  10205. * On intersection enter
  10206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10207. */
  10208. static readonly OnIntersectionEnterTrigger: number;
  10209. /**
  10210. * On intersection exit
  10211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10212. */
  10213. static readonly OnIntersectionExitTrigger: number;
  10214. /**
  10215. * On key down
  10216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10217. */
  10218. static readonly OnKeyDownTrigger: number;
  10219. /**
  10220. * On key up
  10221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10222. */
  10223. static readonly OnKeyUpTrigger: number;
  10224. private _scene;
  10225. /**
  10226. * Creates a new action manager
  10227. * @param scene defines the hosting scene
  10228. */
  10229. constructor(scene: Scene);
  10230. /**
  10231. * Releases all associated resources
  10232. */
  10233. dispose(): void;
  10234. /**
  10235. * Gets hosting scene
  10236. * @returns the hosting scene
  10237. */
  10238. getScene(): Scene;
  10239. /**
  10240. * Does this action manager handles actions of any of the given triggers
  10241. * @param triggers defines the triggers to be tested
  10242. * @return a boolean indicating whether one (or more) of the triggers is handled
  10243. */
  10244. hasSpecificTriggers(triggers: number[]): boolean;
  10245. /**
  10246. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10247. * speed.
  10248. * @param triggerA defines the trigger to be tested
  10249. * @param triggerB defines the trigger to be tested
  10250. * @return a boolean indicating whether one (or more) of the triggers is handled
  10251. */
  10252. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10253. /**
  10254. * Does this action manager handles actions of a given trigger
  10255. * @param trigger defines the trigger to be tested
  10256. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10257. * @return whether the trigger is handled
  10258. */
  10259. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10260. /**
  10261. * Does this action manager has pointer triggers
  10262. */
  10263. get hasPointerTriggers(): boolean;
  10264. /**
  10265. * Does this action manager has pick triggers
  10266. */
  10267. get hasPickTriggers(): boolean;
  10268. /**
  10269. * Registers an action to this action manager
  10270. * @param action defines the action to be registered
  10271. * @return the action amended (prepared) after registration
  10272. */
  10273. registerAction(action: IAction): Nullable<IAction>;
  10274. /**
  10275. * Unregisters an action to this action manager
  10276. * @param action defines the action to be unregistered
  10277. * @return a boolean indicating whether the action has been unregistered
  10278. */
  10279. unregisterAction(action: IAction): Boolean;
  10280. /**
  10281. * Process a specific trigger
  10282. * @param trigger defines the trigger to process
  10283. * @param evt defines the event details to be processed
  10284. */
  10285. processTrigger(trigger: number, evt?: IActionEvent): void;
  10286. /** @hidden */
  10287. _getEffectiveTarget(target: any, propertyPath: string): any;
  10288. /** @hidden */
  10289. _getProperty(propertyPath: string): string;
  10290. /**
  10291. * Serialize this manager to a JSON object
  10292. * @param name defines the property name to store this manager
  10293. * @returns a JSON representation of this manager
  10294. */
  10295. serialize(name: string): any;
  10296. /**
  10297. * Creates a new ActionManager from a JSON data
  10298. * @param parsedActions defines the JSON data to read from
  10299. * @param object defines the hosting mesh
  10300. * @param scene defines the hosting scene
  10301. */
  10302. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10303. /**
  10304. * Get a trigger name by index
  10305. * @param trigger defines the trigger index
  10306. * @returns a trigger name
  10307. */
  10308. static GetTriggerName(trigger: number): string;
  10309. }
  10310. }
  10311. declare module BABYLON {
  10312. /**
  10313. * Class used to represent a sprite
  10314. * @see https://doc.babylonjs.com/babylon101/sprites
  10315. */
  10316. export class Sprite implements IAnimatable {
  10317. /** defines the name */
  10318. name: string;
  10319. /** Gets or sets the current world position */
  10320. position: Vector3;
  10321. /** Gets or sets the main color */
  10322. color: Color4;
  10323. /** Gets or sets the width */
  10324. width: number;
  10325. /** Gets or sets the height */
  10326. height: number;
  10327. /** Gets or sets rotation angle */
  10328. angle: number;
  10329. /** Gets or sets the cell index in the sprite sheet */
  10330. cellIndex: number;
  10331. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10332. cellRef: string;
  10333. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10334. invertU: boolean;
  10335. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10336. invertV: boolean;
  10337. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10338. disposeWhenFinishedAnimating: boolean;
  10339. /** Gets the list of attached animations */
  10340. animations: Nullable<Array<Animation>>;
  10341. /** Gets or sets a boolean indicating if the sprite can be picked */
  10342. isPickable: boolean;
  10343. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10344. useAlphaForPicking: boolean;
  10345. /** @hidden */
  10346. _xOffset: number;
  10347. /** @hidden */
  10348. _yOffset: number;
  10349. /** @hidden */
  10350. _xSize: number;
  10351. /** @hidden */
  10352. _ySize: number;
  10353. /**
  10354. * Gets or sets the associated action manager
  10355. */
  10356. actionManager: Nullable<ActionManager>;
  10357. /**
  10358. * An event triggered when the control has been disposed
  10359. */
  10360. onDisposeObservable: Observable<Sprite>;
  10361. private _animationStarted;
  10362. private _loopAnimation;
  10363. private _fromIndex;
  10364. private _toIndex;
  10365. private _delay;
  10366. private _direction;
  10367. private _manager;
  10368. private _time;
  10369. private _onAnimationEnd;
  10370. /**
  10371. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10372. */
  10373. isVisible: boolean;
  10374. /**
  10375. * Gets or sets the sprite size
  10376. */
  10377. get size(): number;
  10378. set size(value: number);
  10379. /**
  10380. * Returns a boolean indicating if the animation is started
  10381. */
  10382. get animationStarted(): boolean;
  10383. /**
  10384. * Gets or sets the unique id of the sprite
  10385. */
  10386. uniqueId: number;
  10387. /**
  10388. * Gets the manager of this sprite
  10389. */
  10390. get manager(): ISpriteManager;
  10391. /**
  10392. * Creates a new Sprite
  10393. * @param name defines the name
  10394. * @param manager defines the manager
  10395. */
  10396. constructor(
  10397. /** defines the name */
  10398. name: string, manager: ISpriteManager);
  10399. /**
  10400. * Returns the string "Sprite"
  10401. * @returns "Sprite"
  10402. */
  10403. getClassName(): string;
  10404. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10405. get fromIndex(): number;
  10406. set fromIndex(value: number);
  10407. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10408. get toIndex(): number;
  10409. set toIndex(value: number);
  10410. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10411. get loopAnimation(): boolean;
  10412. set loopAnimation(value: boolean);
  10413. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10414. get delay(): number;
  10415. set delay(value: number);
  10416. /**
  10417. * Starts an animation
  10418. * @param from defines the initial key
  10419. * @param to defines the end key
  10420. * @param loop defines if the animation must loop
  10421. * @param delay defines the start delay (in ms)
  10422. * @param onAnimationEnd defines a callback to call when animation ends
  10423. */
  10424. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10425. /** Stops current animation (if any) */
  10426. stopAnimation(): void;
  10427. /** @hidden */
  10428. _animate(deltaTime: number): void;
  10429. /** Release associated resources */
  10430. dispose(): void;
  10431. /**
  10432. * Serializes the sprite to a JSON object
  10433. * @returns the JSON object
  10434. */
  10435. serialize(): any;
  10436. /**
  10437. * Parses a JSON object to create a new sprite
  10438. * @param parsedSprite The JSON object to parse
  10439. * @param manager defines the hosting manager
  10440. * @returns the new sprite
  10441. */
  10442. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10443. }
  10444. }
  10445. declare module BABYLON {
  10446. /**
  10447. * Information about the result of picking within a scene
  10448. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10449. */
  10450. export class PickingInfo {
  10451. /** @hidden */
  10452. _pickingUnavailable: boolean;
  10453. /**
  10454. * If the pick collided with an object
  10455. */
  10456. hit: boolean;
  10457. /**
  10458. * Distance away where the pick collided
  10459. */
  10460. distance: number;
  10461. /**
  10462. * The location of pick collision
  10463. */
  10464. pickedPoint: Nullable<Vector3>;
  10465. /**
  10466. * The mesh corresponding the the pick collision
  10467. */
  10468. pickedMesh: Nullable<AbstractMesh>;
  10469. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10470. bu: number;
  10471. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10472. bv: number;
  10473. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10474. faceId: number;
  10475. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10476. subMeshFaceId: number;
  10477. /** Id of the the submesh that was picked */
  10478. subMeshId: number;
  10479. /** If a sprite was picked, this will be the sprite the pick collided with */
  10480. pickedSprite: Nullable<Sprite>;
  10481. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10482. thinInstanceIndex: number;
  10483. /**
  10484. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10485. */
  10486. originMesh: Nullable<AbstractMesh>;
  10487. /**
  10488. * The ray that was used to perform the picking.
  10489. */
  10490. ray: Nullable<Ray>;
  10491. /**
  10492. * Gets the normal correspodning to the face the pick collided with
  10493. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10494. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10495. * @returns The normal correspodning to the face the pick collided with
  10496. */
  10497. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10498. /**
  10499. * Gets the texture coordinates of where the pick occured
  10500. * @returns the vector containing the coordnates of the texture
  10501. */
  10502. getTextureCoordinates(): Nullable<Vector2>;
  10503. }
  10504. }
  10505. declare module BABYLON {
  10506. /**
  10507. * Class representing a ray with position and direction
  10508. */
  10509. export class Ray {
  10510. /** origin point */
  10511. origin: Vector3;
  10512. /** direction */
  10513. direction: Vector3;
  10514. /** length of the ray */
  10515. length: number;
  10516. private static readonly _TmpVector3;
  10517. private _tmpRay;
  10518. /**
  10519. * Creates a new ray
  10520. * @param origin origin point
  10521. * @param direction direction
  10522. * @param length length of the ray
  10523. */
  10524. constructor(
  10525. /** origin point */
  10526. origin: Vector3,
  10527. /** direction */
  10528. direction: Vector3,
  10529. /** length of the ray */
  10530. length?: number);
  10531. /**
  10532. * Checks if the ray intersects a box
  10533. * This does not account for the ray lenght by design to improve perfs.
  10534. * @param minimum bound of the box
  10535. * @param maximum bound of the box
  10536. * @param intersectionTreshold extra extend to be added to the box in all direction
  10537. * @returns if the box was hit
  10538. */
  10539. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10540. /**
  10541. * Checks if the ray intersects a box
  10542. * This does not account for the ray lenght by design to improve perfs.
  10543. * @param box the bounding box to check
  10544. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10545. * @returns if the box was hit
  10546. */
  10547. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10548. /**
  10549. * If the ray hits a sphere
  10550. * @param sphere the bounding sphere to check
  10551. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10552. * @returns true if it hits the sphere
  10553. */
  10554. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10555. /**
  10556. * If the ray hits a triange
  10557. * @param vertex0 triangle vertex
  10558. * @param vertex1 triangle vertex
  10559. * @param vertex2 triangle vertex
  10560. * @returns intersection information if hit
  10561. */
  10562. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10563. /**
  10564. * Checks if ray intersects a plane
  10565. * @param plane the plane to check
  10566. * @returns the distance away it was hit
  10567. */
  10568. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10569. /**
  10570. * Calculate the intercept of a ray on a given axis
  10571. * @param axis to check 'x' | 'y' | 'z'
  10572. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10573. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10574. */
  10575. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10576. /**
  10577. * Checks if ray intersects a mesh
  10578. * @param mesh the mesh to check
  10579. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10580. * @returns picking info of the intersecton
  10581. */
  10582. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10583. /**
  10584. * Checks if ray intersects a mesh
  10585. * @param meshes the meshes to check
  10586. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10587. * @param results array to store result in
  10588. * @returns Array of picking infos
  10589. */
  10590. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10591. private _comparePickingInfo;
  10592. private static smallnum;
  10593. private static rayl;
  10594. /**
  10595. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10596. * @param sega the first point of the segment to test the intersection against
  10597. * @param segb the second point of the segment to test the intersection against
  10598. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10599. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10600. */
  10601. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10602. /**
  10603. * Update the ray from viewport position
  10604. * @param x position
  10605. * @param y y position
  10606. * @param viewportWidth viewport width
  10607. * @param viewportHeight viewport height
  10608. * @param world world matrix
  10609. * @param view view matrix
  10610. * @param projection projection matrix
  10611. * @returns this ray updated
  10612. */
  10613. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10614. /**
  10615. * Creates a ray with origin and direction of 0,0,0
  10616. * @returns the new ray
  10617. */
  10618. static Zero(): Ray;
  10619. /**
  10620. * Creates a new ray from screen space and viewport
  10621. * @param x position
  10622. * @param y y position
  10623. * @param viewportWidth viewport width
  10624. * @param viewportHeight viewport height
  10625. * @param world world matrix
  10626. * @param view view matrix
  10627. * @param projection projection matrix
  10628. * @returns new ray
  10629. */
  10630. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10631. /**
  10632. * 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
  10633. * transformed to the given world matrix.
  10634. * @param origin The origin point
  10635. * @param end The end point
  10636. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10637. * @returns the new ray
  10638. */
  10639. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10640. /**
  10641. * Transforms a ray by a matrix
  10642. * @param ray ray to transform
  10643. * @param matrix matrix to apply
  10644. * @returns the resulting new ray
  10645. */
  10646. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10647. /**
  10648. * Transforms a ray by a matrix
  10649. * @param ray ray to transform
  10650. * @param matrix matrix to apply
  10651. * @param result ray to store result in
  10652. */
  10653. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10654. /**
  10655. * Unproject a ray from screen space to object space
  10656. * @param sourceX defines the screen space x coordinate to use
  10657. * @param sourceY defines the screen space y coordinate to use
  10658. * @param viewportWidth defines the current width of the viewport
  10659. * @param viewportHeight defines the current height of the viewport
  10660. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10661. * @param view defines the view matrix to use
  10662. * @param projection defines the projection matrix to use
  10663. */
  10664. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10665. }
  10666. /**
  10667. * Type used to define predicate used to select faces when a mesh intersection is detected
  10668. */
  10669. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10670. interface Scene {
  10671. /** @hidden */
  10672. _tempPickingRay: Nullable<Ray>;
  10673. /** @hidden */
  10674. _cachedRayForTransform: Ray;
  10675. /** @hidden */
  10676. _pickWithRayInverseMatrix: Matrix;
  10677. /** @hidden */
  10678. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10679. /** @hidden */
  10680. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10681. /** @hidden */
  10682. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10683. }
  10684. }
  10685. declare module BABYLON {
  10686. /**
  10687. * Groups all the scene component constants in one place to ease maintenance.
  10688. * @hidden
  10689. */
  10690. export class SceneComponentConstants {
  10691. static readonly NAME_EFFECTLAYER: string;
  10692. static readonly NAME_LAYER: string;
  10693. static readonly NAME_LENSFLARESYSTEM: string;
  10694. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10695. static readonly NAME_PARTICLESYSTEM: string;
  10696. static readonly NAME_GAMEPAD: string;
  10697. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10698. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10699. static readonly NAME_PREPASSRENDERER: string;
  10700. static readonly NAME_DEPTHRENDERER: string;
  10701. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10702. static readonly NAME_SPRITE: string;
  10703. static readonly NAME_SUBSURFACE: string;
  10704. static readonly NAME_OUTLINERENDERER: string;
  10705. static readonly NAME_PROCEDURALTEXTURE: string;
  10706. static readonly NAME_SHADOWGENERATOR: string;
  10707. static readonly NAME_OCTREE: string;
  10708. static readonly NAME_PHYSICSENGINE: string;
  10709. static readonly NAME_AUDIO: string;
  10710. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10711. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10712. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10713. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10714. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10715. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10716. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10717. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10718. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10719. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10720. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10721. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10722. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10723. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10724. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10725. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10726. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10727. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10728. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10729. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10730. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10731. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10732. static readonly STEP_AFTERRENDER_AUDIO: number;
  10733. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10734. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10735. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10736. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10737. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10738. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10739. static readonly STEP_POINTERMOVE_SPRITE: number;
  10740. static readonly STEP_POINTERDOWN_SPRITE: number;
  10741. static readonly STEP_POINTERUP_SPRITE: number;
  10742. }
  10743. /**
  10744. * This represents a scene component.
  10745. *
  10746. * This is used to decouple the dependency the scene is having on the different workloads like
  10747. * layers, post processes...
  10748. */
  10749. export interface ISceneComponent {
  10750. /**
  10751. * The name of the component. Each component must have a unique name.
  10752. */
  10753. name: string;
  10754. /**
  10755. * The scene the component belongs to.
  10756. */
  10757. scene: Scene;
  10758. /**
  10759. * Register the component to one instance of a scene.
  10760. */
  10761. register(): void;
  10762. /**
  10763. * Rebuilds the elements related to this component in case of
  10764. * context lost for instance.
  10765. */
  10766. rebuild(): void;
  10767. /**
  10768. * Disposes the component and the associated ressources.
  10769. */
  10770. dispose(): void;
  10771. }
  10772. /**
  10773. * This represents a SERIALIZABLE scene component.
  10774. *
  10775. * This extends Scene Component to add Serialization methods on top.
  10776. */
  10777. export interface ISceneSerializableComponent extends ISceneComponent {
  10778. /**
  10779. * Adds all the elements from the container to the scene
  10780. * @param container the container holding the elements
  10781. */
  10782. addFromContainer(container: AbstractScene): void;
  10783. /**
  10784. * Removes all the elements in the container from the scene
  10785. * @param container contains the elements to remove
  10786. * @param dispose if the removed element should be disposed (default: false)
  10787. */
  10788. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10789. /**
  10790. * Serializes the component data to the specified json object
  10791. * @param serializationObject The object to serialize to
  10792. */
  10793. serialize(serializationObject: any): void;
  10794. }
  10795. /**
  10796. * Strong typing of a Mesh related stage step action
  10797. */
  10798. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10799. /**
  10800. * Strong typing of a Evaluate Sub Mesh related stage step action
  10801. */
  10802. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10803. /**
  10804. * Strong typing of a pre active Mesh related stage step action
  10805. */
  10806. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10807. /**
  10808. * Strong typing of a Camera related stage step action
  10809. */
  10810. export type CameraStageAction = (camera: Camera) => void;
  10811. /**
  10812. * Strong typing of a Camera Frame buffer related stage step action
  10813. */
  10814. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10815. /**
  10816. * Strong typing of a Render Target related stage step action
  10817. */
  10818. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10819. /**
  10820. * Strong typing of a RenderingGroup related stage step action
  10821. */
  10822. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10823. /**
  10824. * Strong typing of a Mesh Render related stage step action
  10825. */
  10826. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10827. /**
  10828. * Strong typing of a simple stage step action
  10829. */
  10830. export type SimpleStageAction = () => void;
  10831. /**
  10832. * Strong typing of a render target action.
  10833. */
  10834. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10835. /**
  10836. * Strong typing of a pointer move action.
  10837. */
  10838. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10839. /**
  10840. * Strong typing of a pointer up/down action.
  10841. */
  10842. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10843. /**
  10844. * Representation of a stage in the scene (Basically a list of ordered steps)
  10845. * @hidden
  10846. */
  10847. export class Stage<T extends Function> extends Array<{
  10848. index: number;
  10849. component: ISceneComponent;
  10850. action: T;
  10851. }> {
  10852. /**
  10853. * Hide ctor from the rest of the world.
  10854. * @param items The items to add.
  10855. */
  10856. private constructor();
  10857. /**
  10858. * Creates a new Stage.
  10859. * @returns A new instance of a Stage
  10860. */
  10861. static Create<T extends Function>(): Stage<T>;
  10862. /**
  10863. * Registers a step in an ordered way in the targeted stage.
  10864. * @param index Defines the position to register the step in
  10865. * @param component Defines the component attached to the step
  10866. * @param action Defines the action to launch during the step
  10867. */
  10868. registerStep(index: number, component: ISceneComponent, action: T): void;
  10869. /**
  10870. * Clears all the steps from the stage.
  10871. */
  10872. clear(): void;
  10873. }
  10874. }
  10875. declare module BABYLON {
  10876. interface Scene {
  10877. /** @hidden */
  10878. _pointerOverSprite: Nullable<Sprite>;
  10879. /** @hidden */
  10880. _pickedDownSprite: Nullable<Sprite>;
  10881. /** @hidden */
  10882. _tempSpritePickingRay: Nullable<Ray>;
  10883. /**
  10884. * All of the sprite managers added to this scene
  10885. * @see https://doc.babylonjs.com/babylon101/sprites
  10886. */
  10887. spriteManagers: Array<ISpriteManager>;
  10888. /**
  10889. * An event triggered when sprites rendering is about to start
  10890. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10891. */
  10892. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10893. /**
  10894. * An event triggered when sprites rendering is done
  10895. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10896. */
  10897. onAfterSpritesRenderingObservable: Observable<Scene>;
  10898. /** @hidden */
  10899. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10900. /** Launch a ray to try to pick a sprite in the scene
  10901. * @param x position on screen
  10902. * @param y position on screen
  10903. * @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
  10904. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10905. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10906. * @returns a PickingInfo
  10907. */
  10908. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10909. /** Use the given ray to pick a sprite in the scene
  10910. * @param ray The ray (in world space) to use to pick meshes
  10911. * @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
  10912. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10913. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10914. * @returns a PickingInfo
  10915. */
  10916. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10917. /** @hidden */
  10918. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10919. /** Launch a ray to try to pick sprites in the scene
  10920. * @param x position on screen
  10921. * @param y position on screen
  10922. * @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
  10923. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10924. * @returns a PickingInfo array
  10925. */
  10926. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10927. /** Use the given ray to pick sprites in the scene
  10928. * @param ray The ray (in world space) to use to pick meshes
  10929. * @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
  10930. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10931. * @returns a PickingInfo array
  10932. */
  10933. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10934. /**
  10935. * Force the sprite under the pointer
  10936. * @param sprite defines the sprite to use
  10937. */
  10938. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10939. /**
  10940. * Gets the sprite under the pointer
  10941. * @returns a Sprite or null if no sprite is under the pointer
  10942. */
  10943. getPointerOverSprite(): Nullable<Sprite>;
  10944. }
  10945. /**
  10946. * Defines the sprite scene component responsible to manage sprites
  10947. * in a given scene.
  10948. */
  10949. export class SpriteSceneComponent implements ISceneComponent {
  10950. /**
  10951. * The component name helpfull to identify the component in the list of scene components.
  10952. */
  10953. readonly name: string;
  10954. /**
  10955. * The scene the component belongs to.
  10956. */
  10957. scene: Scene;
  10958. /** @hidden */
  10959. private _spritePredicate;
  10960. /**
  10961. * Creates a new instance of the component for the given scene
  10962. * @param scene Defines the scene to register the component in
  10963. */
  10964. constructor(scene: Scene);
  10965. /**
  10966. * Registers the component in a given scene
  10967. */
  10968. register(): void;
  10969. /**
  10970. * Rebuilds the elements related to this component in case of
  10971. * context lost for instance.
  10972. */
  10973. rebuild(): void;
  10974. /**
  10975. * Disposes the component and the associated ressources.
  10976. */
  10977. dispose(): void;
  10978. private _pickSpriteButKeepRay;
  10979. private _pointerMove;
  10980. private _pointerDown;
  10981. private _pointerUp;
  10982. }
  10983. }
  10984. declare module BABYLON {
  10985. /** @hidden */
  10986. export var fogFragmentDeclaration: {
  10987. name: string;
  10988. shader: string;
  10989. };
  10990. }
  10991. declare module BABYLON {
  10992. /** @hidden */
  10993. export var fogFragment: {
  10994. name: string;
  10995. shader: string;
  10996. };
  10997. }
  10998. declare module BABYLON {
  10999. /** @hidden */
  11000. export var imageProcessingCompatibility: {
  11001. name: string;
  11002. shader: string;
  11003. };
  11004. }
  11005. declare module BABYLON {
  11006. /** @hidden */
  11007. export var spritesPixelShader: {
  11008. name: string;
  11009. shader: string;
  11010. };
  11011. }
  11012. declare module BABYLON {
  11013. /** @hidden */
  11014. export var fogVertexDeclaration: {
  11015. name: string;
  11016. shader: string;
  11017. };
  11018. }
  11019. declare module BABYLON {
  11020. /** @hidden */
  11021. export var spritesVertexShader: {
  11022. name: string;
  11023. shader: string;
  11024. };
  11025. }
  11026. declare module BABYLON {
  11027. /**
  11028. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11029. */
  11030. export interface ISpriteManager extends IDisposable {
  11031. /**
  11032. * Gets manager's name
  11033. */
  11034. name: string;
  11035. /**
  11036. * Restricts the camera to viewing objects with the same layerMask.
  11037. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11038. */
  11039. layerMask: number;
  11040. /**
  11041. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11042. */
  11043. isPickable: boolean;
  11044. /**
  11045. * Gets the hosting scene
  11046. */
  11047. scene: Scene;
  11048. /**
  11049. * Specifies the rendering group id for this mesh (0 by default)
  11050. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11051. */
  11052. renderingGroupId: number;
  11053. /**
  11054. * Defines the list of sprites managed by the manager.
  11055. */
  11056. sprites: Array<Sprite>;
  11057. /**
  11058. * Gets or sets the spritesheet texture
  11059. */
  11060. texture: Texture;
  11061. /** Defines the default width of a cell in the spritesheet */
  11062. cellWidth: number;
  11063. /** Defines the default height of a cell in the spritesheet */
  11064. cellHeight: number;
  11065. /**
  11066. * Tests the intersection of a sprite with a specific ray.
  11067. * @param ray The ray we are sending to test the collision
  11068. * @param camera The camera space we are sending rays in
  11069. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11070. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11071. * @returns picking info or null.
  11072. */
  11073. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11074. /**
  11075. * Intersects the sprites with a ray
  11076. * @param ray defines the ray to intersect with
  11077. * @param camera defines the current active camera
  11078. * @param predicate defines a predicate used to select candidate sprites
  11079. * @returns null if no hit or a PickingInfo array
  11080. */
  11081. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11082. /**
  11083. * Renders the list of sprites on screen.
  11084. */
  11085. render(): void;
  11086. }
  11087. /**
  11088. * Class used to manage multiple sprites on the same spritesheet
  11089. * @see https://doc.babylonjs.com/babylon101/sprites
  11090. */
  11091. export class SpriteManager implements ISpriteManager {
  11092. /** defines the manager's name */
  11093. name: string;
  11094. /** Define the Url to load snippets */
  11095. static SnippetUrl: string;
  11096. /** Snippet ID if the manager was created from the snippet server */
  11097. snippetId: string;
  11098. /** Gets the list of sprites */
  11099. sprites: Sprite[];
  11100. /** Gets or sets the rendering group id (0 by default) */
  11101. renderingGroupId: number;
  11102. /** Gets or sets camera layer mask */
  11103. layerMask: number;
  11104. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11105. fogEnabled: boolean;
  11106. /** Gets or sets a boolean indicating if the sprites are pickable */
  11107. isPickable: boolean;
  11108. /** Defines the default width of a cell in the spritesheet */
  11109. cellWidth: number;
  11110. /** Defines the default height of a cell in the spritesheet */
  11111. cellHeight: number;
  11112. /** Associative array from JSON sprite data file */
  11113. private _cellData;
  11114. /** Array of sprite names from JSON sprite data file */
  11115. private _spriteMap;
  11116. /** True when packed cell data from JSON file is ready*/
  11117. private _packedAndReady;
  11118. private _textureContent;
  11119. private _useInstancing;
  11120. /**
  11121. * An event triggered when the manager is disposed.
  11122. */
  11123. onDisposeObservable: Observable<SpriteManager>;
  11124. private _onDisposeObserver;
  11125. /**
  11126. * Callback called when the manager is disposed
  11127. */
  11128. set onDispose(callback: () => void);
  11129. private _capacity;
  11130. private _fromPacked;
  11131. private _spriteTexture;
  11132. private _epsilon;
  11133. private _scene;
  11134. private _vertexData;
  11135. private _buffer;
  11136. private _vertexBuffers;
  11137. private _spriteBuffer;
  11138. private _indexBuffer;
  11139. private _effectBase;
  11140. private _effectFog;
  11141. private _vertexBufferSize;
  11142. /**
  11143. * Gets or sets the unique id of the sprite
  11144. */
  11145. uniqueId: number;
  11146. /**
  11147. * Gets the array of sprites
  11148. */
  11149. get children(): Sprite[];
  11150. /**
  11151. * Gets the hosting scene
  11152. */
  11153. get scene(): Scene;
  11154. /**
  11155. * Gets the capacity of the manager
  11156. */
  11157. get capacity(): number;
  11158. /**
  11159. * Gets or sets the spritesheet texture
  11160. */
  11161. get texture(): Texture;
  11162. set texture(value: Texture);
  11163. private _blendMode;
  11164. /**
  11165. * Blend mode use to render the particle, it can be any of
  11166. * the static Constants.ALPHA_x properties provided in this class.
  11167. * Default value is Constants.ALPHA_COMBINE
  11168. */
  11169. get blendMode(): number;
  11170. set blendMode(blendMode: number);
  11171. /** Disables writing to the depth buffer when rendering the sprites.
  11172. * It can be handy to disable depth writing when using textures without alpha channel
  11173. * and setting some specific blend modes.
  11174. */
  11175. disableDepthWrite: boolean;
  11176. /**
  11177. * Creates a new sprite manager
  11178. * @param name defines the manager's name
  11179. * @param imgUrl defines the sprite sheet url
  11180. * @param capacity defines the maximum allowed number of sprites
  11181. * @param cellSize defines the size of a sprite cell
  11182. * @param scene defines the hosting scene
  11183. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11184. * @param samplingMode defines the smapling mode to use with spritesheet
  11185. * @param fromPacked set to false; do not alter
  11186. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11187. */
  11188. constructor(
  11189. /** defines the manager's name */
  11190. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11191. /**
  11192. * Returns the string "SpriteManager"
  11193. * @returns "SpriteManager"
  11194. */
  11195. getClassName(): string;
  11196. private _makePacked;
  11197. private _appendSpriteVertex;
  11198. private _checkTextureAlpha;
  11199. /**
  11200. * Intersects the sprites with a ray
  11201. * @param ray defines the ray to intersect with
  11202. * @param camera defines the current active camera
  11203. * @param predicate defines a predicate used to select candidate sprites
  11204. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11205. * @returns null if no hit or a PickingInfo
  11206. */
  11207. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11208. /**
  11209. * Intersects the sprites with a ray
  11210. * @param ray defines the ray to intersect with
  11211. * @param camera defines the current active camera
  11212. * @param predicate defines a predicate used to select candidate sprites
  11213. * @returns null if no hit or a PickingInfo array
  11214. */
  11215. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11216. /**
  11217. * Render all child sprites
  11218. */
  11219. render(): void;
  11220. /**
  11221. * Release associated resources
  11222. */
  11223. dispose(): void;
  11224. /**
  11225. * Serializes the sprite manager to a JSON object
  11226. * @param serializeTexture defines if the texture must be serialized as well
  11227. * @returns the JSON object
  11228. */
  11229. serialize(serializeTexture?: boolean): any;
  11230. /**
  11231. * Parses a JSON object to create a new sprite manager.
  11232. * @param parsedManager The JSON object to parse
  11233. * @param scene The scene to create the sprite managerin
  11234. * @param rootUrl The root url to use to load external dependencies like texture
  11235. * @returns the new sprite manager
  11236. */
  11237. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11238. /**
  11239. * Creates a sprite manager from a snippet saved in a remote file
  11240. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11241. * @param url defines the url to load from
  11242. * @param scene defines the hosting scene
  11243. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11244. * @returns a promise that will resolve to the new sprite manager
  11245. */
  11246. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11247. /**
  11248. * Creates a sprite manager from a snippet saved by the sprite editor
  11249. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11250. * @param scene defines the hosting scene
  11251. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11252. * @returns a promise that will resolve to the new sprite manager
  11253. */
  11254. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11255. }
  11256. }
  11257. declare module BABYLON {
  11258. /** Interface used by value gradients (color, factor, ...) */
  11259. export interface IValueGradient {
  11260. /**
  11261. * Gets or sets the gradient value (between 0 and 1)
  11262. */
  11263. gradient: number;
  11264. }
  11265. /** Class used to store color4 gradient */
  11266. export class ColorGradient implements IValueGradient {
  11267. /**
  11268. * Gets or sets the gradient value (between 0 and 1)
  11269. */
  11270. gradient: number;
  11271. /**
  11272. * Gets or sets first associated color
  11273. */
  11274. color1: Color4;
  11275. /**
  11276. * Gets or sets second associated color
  11277. */
  11278. color2?: Color4 | undefined;
  11279. /**
  11280. * Creates a new color4 gradient
  11281. * @param gradient gets or sets the gradient value (between 0 and 1)
  11282. * @param color1 gets or sets first associated color
  11283. * @param color2 gets or sets first second color
  11284. */
  11285. constructor(
  11286. /**
  11287. * Gets or sets the gradient value (between 0 and 1)
  11288. */
  11289. gradient: number,
  11290. /**
  11291. * Gets or sets first associated color
  11292. */
  11293. color1: Color4,
  11294. /**
  11295. * Gets or sets second associated color
  11296. */
  11297. color2?: Color4 | undefined);
  11298. /**
  11299. * Will get a color picked randomly between color1 and color2.
  11300. * If color2 is undefined then color1 will be used
  11301. * @param result defines the target Color4 to store the result in
  11302. */
  11303. getColorToRef(result: Color4): void;
  11304. }
  11305. /** Class used to store color 3 gradient */
  11306. export class Color3Gradient implements IValueGradient {
  11307. /**
  11308. * Gets or sets the gradient value (between 0 and 1)
  11309. */
  11310. gradient: number;
  11311. /**
  11312. * Gets or sets the associated color
  11313. */
  11314. color: Color3;
  11315. /**
  11316. * Creates a new color3 gradient
  11317. * @param gradient gets or sets the gradient value (between 0 and 1)
  11318. * @param color gets or sets associated color
  11319. */
  11320. constructor(
  11321. /**
  11322. * Gets or sets the gradient value (between 0 and 1)
  11323. */
  11324. gradient: number,
  11325. /**
  11326. * Gets or sets the associated color
  11327. */
  11328. color: Color3);
  11329. }
  11330. /** Class used to store factor gradient */
  11331. export class FactorGradient implements IValueGradient {
  11332. /**
  11333. * Gets or sets the gradient value (between 0 and 1)
  11334. */
  11335. gradient: number;
  11336. /**
  11337. * Gets or sets first associated factor
  11338. */
  11339. factor1: number;
  11340. /**
  11341. * Gets or sets second associated factor
  11342. */
  11343. factor2?: number | undefined;
  11344. /**
  11345. * Creates a new factor gradient
  11346. * @param gradient gets or sets the gradient value (between 0 and 1)
  11347. * @param factor1 gets or sets first associated factor
  11348. * @param factor2 gets or sets second associated factor
  11349. */
  11350. constructor(
  11351. /**
  11352. * Gets or sets the gradient value (between 0 and 1)
  11353. */
  11354. gradient: number,
  11355. /**
  11356. * Gets or sets first associated factor
  11357. */
  11358. factor1: number,
  11359. /**
  11360. * Gets or sets second associated factor
  11361. */
  11362. factor2?: number | undefined);
  11363. /**
  11364. * Will get a number picked randomly between factor1 and factor2.
  11365. * If factor2 is undefined then factor1 will be used
  11366. * @returns the picked number
  11367. */
  11368. getFactor(): number;
  11369. }
  11370. /**
  11371. * Helper used to simplify some generic gradient tasks
  11372. */
  11373. export class GradientHelper {
  11374. /**
  11375. * Gets the current gradient from an array of IValueGradient
  11376. * @param ratio defines the current ratio to get
  11377. * @param gradients defines the array of IValueGradient
  11378. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11379. */
  11380. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11381. }
  11382. }
  11383. declare module BABYLON {
  11384. interface ThinEngine {
  11385. /**
  11386. * Creates a raw texture
  11387. * @param data defines the data to store in the texture
  11388. * @param width defines the width of the texture
  11389. * @param height defines the height of the texture
  11390. * @param format defines the format of the data
  11391. * @param generateMipMaps defines if the engine should generate the mip levels
  11392. * @param invertY defines if data must be stored with Y axis inverted
  11393. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11394. * @param compression defines the compression used (null by default)
  11395. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11396. * @returns the raw texture inside an InternalTexture
  11397. */
  11398. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11399. /**
  11400. * Update a raw texture
  11401. * @param texture defines the texture to update
  11402. * @param data defines the data to store in the texture
  11403. * @param format defines the format of the data
  11404. * @param invertY defines if data must be stored with Y axis inverted
  11405. */
  11406. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11407. /**
  11408. * Update a raw texture
  11409. * @param texture defines the texture to update
  11410. * @param data defines the data to store in the texture
  11411. * @param format defines the format of the data
  11412. * @param invertY defines if data must be stored with Y axis inverted
  11413. * @param compression defines the compression used (null by default)
  11414. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11415. */
  11416. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11417. /**
  11418. * Creates a new raw cube texture
  11419. * @param data defines the array of data to use to create each face
  11420. * @param size defines the size of the textures
  11421. * @param format defines the format of the data
  11422. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11423. * @param generateMipMaps defines if the engine should generate the mip levels
  11424. * @param invertY defines if data must be stored with Y axis inverted
  11425. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11426. * @param compression defines the compression used (null by default)
  11427. * @returns the cube texture as an InternalTexture
  11428. */
  11429. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11430. /**
  11431. * Update a raw cube texture
  11432. * @param texture defines the texture to udpdate
  11433. * @param data defines the data to store
  11434. * @param format defines the data format
  11435. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11436. * @param invertY defines if data must be stored with Y axis inverted
  11437. */
  11438. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11439. /**
  11440. * Update a raw cube texture
  11441. * @param texture defines the texture to udpdate
  11442. * @param data defines the data to store
  11443. * @param format defines the data format
  11444. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11445. * @param invertY defines if data must be stored with Y axis inverted
  11446. * @param compression defines the compression used (null by default)
  11447. */
  11448. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11449. /**
  11450. * Update a raw cube texture
  11451. * @param texture defines the texture to udpdate
  11452. * @param data defines the data to store
  11453. * @param format defines the data format
  11454. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11455. * @param invertY defines if data must be stored with Y axis inverted
  11456. * @param compression defines the compression used (null by default)
  11457. * @param level defines which level of the texture to update
  11458. */
  11459. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11460. /**
  11461. * Creates a new raw cube texture from a specified url
  11462. * @param url defines the url where the data is located
  11463. * @param scene defines the current scene
  11464. * @param size defines the size of the textures
  11465. * @param format defines the format of the data
  11466. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11467. * @param noMipmap defines if the engine should avoid generating the mip levels
  11468. * @param callback defines a callback used to extract texture data from loaded data
  11469. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11470. * @param onLoad defines a callback called when texture is loaded
  11471. * @param onError defines a callback called if there is an error
  11472. * @returns the cube texture as an InternalTexture
  11473. */
  11474. 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;
  11475. /**
  11476. * Creates a new raw cube texture from a specified url
  11477. * @param url defines the url where the data is located
  11478. * @param scene defines the current scene
  11479. * @param size defines the size of the textures
  11480. * @param format defines the format of the data
  11481. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11482. * @param noMipmap defines if the engine should avoid generating the mip levels
  11483. * @param callback defines a callback used to extract texture data from loaded data
  11484. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11485. * @param onLoad defines a callback called when texture is loaded
  11486. * @param onError defines a callback called if there is an error
  11487. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11488. * @param invertY defines if data must be stored with Y axis inverted
  11489. * @returns the cube texture as an InternalTexture
  11490. */
  11491. 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;
  11492. /**
  11493. * Creates a new raw 3D texture
  11494. * @param data defines the data used to create the texture
  11495. * @param width defines the width of the texture
  11496. * @param height defines the height of the texture
  11497. * @param depth defines the depth of the texture
  11498. * @param format defines the format of the texture
  11499. * @param generateMipMaps defines if the engine must generate mip levels
  11500. * @param invertY defines if data must be stored with Y axis inverted
  11501. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11502. * @param compression defines the compressed used (can be null)
  11503. * @param textureType defines the compressed used (can be null)
  11504. * @returns a new raw 3D texture (stored in an InternalTexture)
  11505. */
  11506. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11507. /**
  11508. * Update a raw 3D texture
  11509. * @param texture defines the texture to update
  11510. * @param data defines the data to store
  11511. * @param format defines the data format
  11512. * @param invertY defines if data must be stored with Y axis inverted
  11513. */
  11514. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11515. /**
  11516. * Update a raw 3D texture
  11517. * @param texture defines the texture to update
  11518. * @param data defines the data to store
  11519. * @param format defines the data format
  11520. * @param invertY defines if data must be stored with Y axis inverted
  11521. * @param compression defines the used compression (can be null)
  11522. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11523. */
  11524. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11525. /**
  11526. * Creates a new raw 2D array texture
  11527. * @param data defines the data used to create the texture
  11528. * @param width defines the width of the texture
  11529. * @param height defines the height of the texture
  11530. * @param depth defines the number of layers of the texture
  11531. * @param format defines the format of the texture
  11532. * @param generateMipMaps defines if the engine must generate mip levels
  11533. * @param invertY defines if data must be stored with Y axis inverted
  11534. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11535. * @param compression defines the compressed used (can be null)
  11536. * @param textureType defines the compressed used (can be null)
  11537. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11538. */
  11539. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11540. /**
  11541. * Update a raw 2D array texture
  11542. * @param texture defines the texture to update
  11543. * @param data defines the data to store
  11544. * @param format defines the data format
  11545. * @param invertY defines if data must be stored with Y axis inverted
  11546. */
  11547. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11548. /**
  11549. * Update a raw 2D array texture
  11550. * @param texture defines the texture to update
  11551. * @param data defines the data to store
  11552. * @param format defines the data format
  11553. * @param invertY defines if data must be stored with Y axis inverted
  11554. * @param compression defines the used compression (can be null)
  11555. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11556. */
  11557. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11558. }
  11559. }
  11560. declare module BABYLON {
  11561. /**
  11562. * Raw texture can help creating a texture directly from an array of data.
  11563. * This can be super useful if you either get the data from an uncompressed source or
  11564. * if you wish to create your texture pixel by pixel.
  11565. */
  11566. export class RawTexture extends Texture {
  11567. /**
  11568. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11569. */
  11570. format: number;
  11571. /**
  11572. * Instantiates a new RawTexture.
  11573. * Raw texture can help creating a texture directly from an array of data.
  11574. * This can be super useful if you either get the data from an uncompressed source or
  11575. * if you wish to create your texture pixel by pixel.
  11576. * @param data define the array of data to use to create the texture
  11577. * @param width define the width of the texture
  11578. * @param height define the height of the texture
  11579. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11580. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11581. * @param generateMipMaps define whether mip maps should be generated or not
  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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11585. */
  11586. constructor(data: ArrayBufferView, width: number, height: number,
  11587. /**
  11588. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11589. */
  11590. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11591. /**
  11592. * Updates the texture underlying data.
  11593. * @param data Define the new data of the texture
  11594. */
  11595. update(data: ArrayBufferView): void;
  11596. /**
  11597. * Creates a luminance texture from some data.
  11598. * @param data Define the texture data
  11599. * @param width Define the width of the texture
  11600. * @param height Define the height of the texture
  11601. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11602. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11603. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11604. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11605. * @returns the luminance texture
  11606. */
  11607. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11608. /**
  11609. * Creates a luminance alpha texture from some data.
  11610. * @param data Define the texture data
  11611. * @param width Define the width of the texture
  11612. * @param height Define the height of the texture
  11613. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11614. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11615. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11616. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11617. * @returns the luminance alpha texture
  11618. */
  11619. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11620. /**
  11621. * Creates an alpha texture from some data.
  11622. * @param data Define the texture data
  11623. * @param width Define the width of the texture
  11624. * @param height Define the height of the texture
  11625. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11629. * @returns the alpha texture
  11630. */
  11631. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11632. /**
  11633. * Creates a RGB texture from some data.
  11634. * @param data Define the texture data
  11635. * @param width Define the width of the texture
  11636. * @param height Define the height of the texture
  11637. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11638. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11639. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11640. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11641. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11642. * @returns the RGB alpha texture
  11643. */
  11644. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11645. /**
  11646. * Creates a RGBA texture from some data.
  11647. * @param data Define the texture data
  11648. * @param width Define the width of the texture
  11649. * @param height Define the height of the texture
  11650. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11651. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11652. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11653. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11654. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11655. * @returns the RGBA texture
  11656. */
  11657. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11658. /**
  11659. * Creates a R texture from some data.
  11660. * @param data Define the texture data
  11661. * @param width Define the width of the texture
  11662. * @param height Define the height of the texture
  11663. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11664. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11665. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11666. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11667. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11668. * @returns the R texture
  11669. */
  11670. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11671. }
  11672. }
  11673. declare module BABYLON {
  11674. interface ThinEngine {
  11675. /**
  11676. * Update a dynamic index buffer
  11677. * @param indexBuffer defines the target index buffer
  11678. * @param indices defines the data to update
  11679. * @param offset defines the offset in the target index buffer where update should start
  11680. */
  11681. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11682. /**
  11683. * Updates a dynamic vertex buffer.
  11684. * @param vertexBuffer the vertex buffer to update
  11685. * @param data the data used to update the vertex buffer
  11686. * @param byteOffset the byte offset of the data
  11687. * @param byteLength the byte length of the data
  11688. */
  11689. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11690. }
  11691. }
  11692. declare module BABYLON {
  11693. interface AbstractScene {
  11694. /**
  11695. * The list of procedural textures added to the scene
  11696. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11697. */
  11698. proceduralTextures: Array<ProceduralTexture>;
  11699. }
  11700. /**
  11701. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11702. * in a given scene.
  11703. */
  11704. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11705. /**
  11706. * The component name helpfull to identify the component in the list of scene components.
  11707. */
  11708. readonly name: string;
  11709. /**
  11710. * The scene the component belongs to.
  11711. */
  11712. scene: Scene;
  11713. /**
  11714. * Creates a new instance of the component for the given scene
  11715. * @param scene Defines the scene to register the component in
  11716. */
  11717. constructor(scene: Scene);
  11718. /**
  11719. * Registers the component in a given scene
  11720. */
  11721. register(): void;
  11722. /**
  11723. * Rebuilds the elements related to this component in case of
  11724. * context lost for instance.
  11725. */
  11726. rebuild(): void;
  11727. /**
  11728. * Disposes the component and the associated ressources.
  11729. */
  11730. dispose(): void;
  11731. private _beforeClear;
  11732. }
  11733. }
  11734. declare module BABYLON {
  11735. interface ThinEngine {
  11736. /**
  11737. * Creates a new render target cube texture
  11738. * @param size defines the size of the texture
  11739. * @param options defines the options used to create the texture
  11740. * @returns a new render target cube texture stored in an InternalTexture
  11741. */
  11742. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11743. }
  11744. }
  11745. declare module BABYLON {
  11746. /** @hidden */
  11747. export var proceduralVertexShader: {
  11748. name: string;
  11749. shader: string;
  11750. };
  11751. }
  11752. declare module BABYLON {
  11753. /**
  11754. * 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.
  11755. * This is the base class of any Procedural texture and contains most of the shareable code.
  11756. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11757. */
  11758. export class ProceduralTexture extends Texture {
  11759. /**
  11760. * Define if the texture is enabled or not (disabled texture will not render)
  11761. */
  11762. isEnabled: boolean;
  11763. /**
  11764. * Define if the texture must be cleared before rendering (default is true)
  11765. */
  11766. autoClear: boolean;
  11767. /**
  11768. * Callback called when the texture is generated
  11769. */
  11770. onGenerated: () => void;
  11771. /**
  11772. * Event raised when the texture is generated
  11773. */
  11774. onGeneratedObservable: Observable<ProceduralTexture>;
  11775. /**
  11776. * Event raised before the texture is generated
  11777. */
  11778. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11779. /**
  11780. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11781. */
  11782. nodeMaterialSource: Nullable<NodeMaterial>;
  11783. /** @hidden */
  11784. _generateMipMaps: boolean;
  11785. /** @hidden **/
  11786. _effect: Effect;
  11787. /** @hidden */
  11788. _textures: {
  11789. [key: string]: Texture;
  11790. };
  11791. /** @hidden */
  11792. protected _fallbackTexture: Nullable<Texture>;
  11793. private _size;
  11794. private _currentRefreshId;
  11795. private _frameId;
  11796. private _refreshRate;
  11797. private _vertexBuffers;
  11798. private _indexBuffer;
  11799. private _uniforms;
  11800. private _samplers;
  11801. private _fragment;
  11802. private _floats;
  11803. private _ints;
  11804. private _floatsArrays;
  11805. private _colors3;
  11806. private _colors4;
  11807. private _vectors2;
  11808. private _vectors3;
  11809. private _matrices;
  11810. private _fallbackTextureUsed;
  11811. private _fullEngine;
  11812. private _cachedDefines;
  11813. private _contentUpdateId;
  11814. private _contentData;
  11815. /**
  11816. * Instantiates a new procedural texture.
  11817. * 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.
  11818. * This is the base class of any Procedural texture and contains most of the shareable code.
  11819. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11820. * @param name Define the name of the texture
  11821. * @param size Define the size of the texture to create
  11822. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11823. * @param scene Define the scene the texture belongs to
  11824. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11825. * @param generateMipMaps Define if the texture should creates mip maps or not
  11826. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11827. * @param textureType The FBO internal texture type
  11828. */
  11829. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11830. /**
  11831. * The effect that is created when initializing the post process.
  11832. * @returns The created effect corresponding the the postprocess.
  11833. */
  11834. getEffect(): Effect;
  11835. /**
  11836. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11837. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11838. */
  11839. getContent(): Nullable<ArrayBufferView>;
  11840. private _createIndexBuffer;
  11841. /** @hidden */
  11842. _rebuild(): void;
  11843. /**
  11844. * Resets the texture in order to recreate its associated resources.
  11845. * This can be called in case of context loss
  11846. */
  11847. reset(): void;
  11848. protected _getDefines(): string;
  11849. /**
  11850. * Is the texture ready to be used ? (rendered at least once)
  11851. * @returns true if ready, otherwise, false.
  11852. */
  11853. isReady(): boolean;
  11854. /**
  11855. * Resets the refresh counter of the texture and start bak from scratch.
  11856. * Could be useful to regenerate the texture if it is setup to render only once.
  11857. */
  11858. resetRefreshCounter(): void;
  11859. /**
  11860. * Set the fragment shader to use in order to render the texture.
  11861. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11862. */
  11863. setFragment(fragment: any): void;
  11864. /**
  11865. * Define the refresh rate of the texture or the rendering frequency.
  11866. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11867. */
  11868. get refreshRate(): number;
  11869. set refreshRate(value: number);
  11870. /** @hidden */
  11871. _shouldRender(): boolean;
  11872. /**
  11873. * Get the size the texture is rendering at.
  11874. * @returns the size (on cube texture it is always squared)
  11875. */
  11876. getRenderSize(): RenderTargetTextureSize;
  11877. /**
  11878. * Resize the texture to new value.
  11879. * @param size Define the new size the texture should have
  11880. * @param generateMipMaps Define whether the new texture should create mip maps
  11881. */
  11882. resize(size: number, generateMipMaps: boolean): void;
  11883. private _checkUniform;
  11884. /**
  11885. * Set a texture in the shader program used to render.
  11886. * @param name Define the name of the uniform samplers as defined in the shader
  11887. * @param texture Define the texture to bind to this sampler
  11888. * @return the texture itself allowing "fluent" like uniform updates
  11889. */
  11890. setTexture(name: string, texture: Texture): ProceduralTexture;
  11891. /**
  11892. * Set a float in the shader.
  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. setFloat(name: string, value: number): ProceduralTexture;
  11898. /**
  11899. * Set a int in the shader.
  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. setInt(name: string, value: number): ProceduralTexture;
  11905. /**
  11906. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ProceduralTexture;
  11912. /**
  11913. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ProceduralTexture;
  11919. /**
  11920. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ProceduralTexture;
  11926. /**
  11927. * Set a vec2 in the shader from a Vector2.
  11928. * @param name Define the name of the uniform as defined in the shader
  11929. * @param value Define the value to give to the uniform
  11930. * @return the texture itself allowing "fluent" like uniform updates
  11931. */
  11932. setVector2(name: string, value: Vector2): ProceduralTexture;
  11933. /**
  11934. * Set a vec3 in the shader from a Vector3.
  11935. * @param name Define the name of the uniform as defined in the shader
  11936. * @param value Define the value to give to the uniform
  11937. * @return the texture itself allowing "fluent" like uniform updates
  11938. */
  11939. setVector3(name: string, value: Vector3): ProceduralTexture;
  11940. /**
  11941. * Set a mat4 in the shader from a MAtrix.
  11942. * @param name Define the name of the uniform as defined in the shader
  11943. * @param value Define the value to give to the uniform
  11944. * @return the texture itself allowing "fluent" like uniform updates
  11945. */
  11946. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11947. /**
  11948. * Render the texture to its associated render target.
  11949. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11950. */
  11951. render(useCameraPostProcess?: boolean): void;
  11952. /**
  11953. * Clone the texture.
  11954. * @returns the cloned texture
  11955. */
  11956. clone(): ProceduralTexture;
  11957. /**
  11958. * Dispose the texture and release its asoociated resources.
  11959. */
  11960. dispose(): void;
  11961. }
  11962. }
  11963. declare module BABYLON {
  11964. /**
  11965. * This represents the base class for particle system in Babylon.
  11966. * 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.
  11967. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11968. * @example https://doc.babylonjs.com/babylon101/particles
  11969. */
  11970. export class BaseParticleSystem {
  11971. /**
  11972. * Source color is added to the destination color without alpha affecting the result
  11973. */
  11974. static BLENDMODE_ONEONE: number;
  11975. /**
  11976. * Blend current color and particle color using particle’s alpha
  11977. */
  11978. static BLENDMODE_STANDARD: number;
  11979. /**
  11980. * Add current color and particle color multiplied by particle’s alpha
  11981. */
  11982. static BLENDMODE_ADD: number;
  11983. /**
  11984. * Multiply current color with particle color
  11985. */
  11986. static BLENDMODE_MULTIPLY: number;
  11987. /**
  11988. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11989. */
  11990. static BLENDMODE_MULTIPLYADD: number;
  11991. /**
  11992. * List of animations used by the particle system.
  11993. */
  11994. animations: Animation[];
  11995. /**
  11996. * Gets or sets the unique id of the particle system
  11997. */
  11998. uniqueId: number;
  11999. /**
  12000. * The id of the Particle system.
  12001. */
  12002. id: string;
  12003. /**
  12004. * The friendly name of the Particle system.
  12005. */
  12006. name: string;
  12007. /**
  12008. * Snippet ID if the particle system was created from the snippet server
  12009. */
  12010. snippetId: string;
  12011. /**
  12012. * The rendering group used by the Particle system to chose when to render.
  12013. */
  12014. renderingGroupId: number;
  12015. /**
  12016. * The emitter represents the Mesh or position we are attaching the particle system to.
  12017. */
  12018. emitter: Nullable<AbstractMesh | Vector3>;
  12019. /**
  12020. * The maximum number of particles to emit per frame
  12021. */
  12022. emitRate: number;
  12023. /**
  12024. * If you want to launch only a few particles at once, that can be done, as well.
  12025. */
  12026. manualEmitCount: number;
  12027. /**
  12028. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12029. */
  12030. updateSpeed: number;
  12031. /**
  12032. * The amount of time the particle system is running (depends of the overall update speed).
  12033. */
  12034. targetStopDuration: number;
  12035. /**
  12036. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12037. */
  12038. disposeOnStop: boolean;
  12039. /**
  12040. * Minimum power of emitting particles.
  12041. */
  12042. minEmitPower: number;
  12043. /**
  12044. * Maximum power of emitting particles.
  12045. */
  12046. maxEmitPower: number;
  12047. /**
  12048. * Minimum life time of emitting particles.
  12049. */
  12050. minLifeTime: number;
  12051. /**
  12052. * Maximum life time of emitting particles.
  12053. */
  12054. maxLifeTime: number;
  12055. /**
  12056. * Minimum Size of emitting particles.
  12057. */
  12058. minSize: number;
  12059. /**
  12060. * Maximum Size of emitting particles.
  12061. */
  12062. maxSize: number;
  12063. /**
  12064. * Minimum scale of emitting particles on X axis.
  12065. */
  12066. minScaleX: number;
  12067. /**
  12068. * Maximum scale of emitting particles on X axis.
  12069. */
  12070. maxScaleX: number;
  12071. /**
  12072. * Minimum scale of emitting particles on Y axis.
  12073. */
  12074. minScaleY: number;
  12075. /**
  12076. * Maximum scale of emitting particles on Y axis.
  12077. */
  12078. maxScaleY: number;
  12079. /**
  12080. * Gets or sets the minimal initial rotation in radians.
  12081. */
  12082. minInitialRotation: number;
  12083. /**
  12084. * Gets or sets the maximal initial rotation in radians.
  12085. */
  12086. maxInitialRotation: number;
  12087. /**
  12088. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12089. */
  12090. minAngularSpeed: number;
  12091. /**
  12092. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12093. */
  12094. maxAngularSpeed: number;
  12095. /**
  12096. * The texture used to render each particle. (this can be a spritesheet)
  12097. */
  12098. particleTexture: Nullable<BaseTexture>;
  12099. /**
  12100. * The layer mask we are rendering the particles through.
  12101. */
  12102. layerMask: number;
  12103. /**
  12104. * This can help using your own shader to render the particle system.
  12105. * The according effect will be created
  12106. */
  12107. customShader: any;
  12108. /**
  12109. * By default particle system starts as soon as they are created. This prevents the
  12110. * automatic start to happen and let you decide when to start emitting particles.
  12111. */
  12112. preventAutoStart: boolean;
  12113. private _noiseTexture;
  12114. /**
  12115. * Gets or sets a texture used to add random noise to particle positions
  12116. */
  12117. get noiseTexture(): Nullable<ProceduralTexture>;
  12118. set noiseTexture(value: Nullable<ProceduralTexture>);
  12119. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12120. noiseStrength: Vector3;
  12121. /**
  12122. * Callback triggered when the particle animation is ending.
  12123. */
  12124. onAnimationEnd: Nullable<() => void>;
  12125. /**
  12126. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12127. */
  12128. blendMode: number;
  12129. /**
  12130. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12131. * to override the particles.
  12132. */
  12133. forceDepthWrite: boolean;
  12134. /** 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 */
  12135. preWarmCycles: number;
  12136. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12137. preWarmStepOffset: number;
  12138. /**
  12139. * 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)
  12140. */
  12141. spriteCellChangeSpeed: number;
  12142. /**
  12143. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12144. */
  12145. startSpriteCellID: number;
  12146. /**
  12147. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12148. */
  12149. endSpriteCellID: number;
  12150. /**
  12151. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12152. */
  12153. spriteCellWidth: number;
  12154. /**
  12155. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12156. */
  12157. spriteCellHeight: number;
  12158. /**
  12159. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12160. */
  12161. spriteRandomStartCell: boolean;
  12162. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12163. translationPivot: Vector2;
  12164. /** @hidden */
  12165. protected _isAnimationSheetEnabled: boolean;
  12166. /**
  12167. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12168. */
  12169. beginAnimationOnStart: boolean;
  12170. /**
  12171. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12172. */
  12173. beginAnimationFrom: number;
  12174. /**
  12175. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12176. */
  12177. beginAnimationTo: number;
  12178. /**
  12179. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12180. */
  12181. beginAnimationLoop: boolean;
  12182. /**
  12183. * Gets or sets a world offset applied to all particles
  12184. */
  12185. worldOffset: Vector3;
  12186. /**
  12187. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12188. */
  12189. get isAnimationSheetEnabled(): boolean;
  12190. set isAnimationSheetEnabled(value: boolean);
  12191. /**
  12192. * Get hosting scene
  12193. * @returns the scene
  12194. */
  12195. getScene(): Nullable<Scene>;
  12196. /**
  12197. * You can use gravity if you want to give an orientation to your particles.
  12198. */
  12199. gravity: Vector3;
  12200. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12201. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12202. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12203. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12204. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12205. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12206. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12207. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12208. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12209. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12210. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12211. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12212. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12213. /**
  12214. * Defines the delay in milliseconds before starting the system (0 by default)
  12215. */
  12216. startDelay: number;
  12217. /**
  12218. * Gets the current list of drag gradients.
  12219. * You must use addDragGradient and removeDragGradient to udpate this list
  12220. * @returns the list of drag gradients
  12221. */
  12222. getDragGradients(): Nullable<Array<FactorGradient>>;
  12223. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12224. limitVelocityDamping: number;
  12225. /**
  12226. * Gets the current list of limit velocity gradients.
  12227. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12228. * @returns the list of limit velocity gradients
  12229. */
  12230. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12231. /**
  12232. * Gets the current list of color gradients.
  12233. * You must use addColorGradient and removeColorGradient to udpate this list
  12234. * @returns the list of color gradients
  12235. */
  12236. getColorGradients(): Nullable<Array<ColorGradient>>;
  12237. /**
  12238. * Gets the current list of size gradients.
  12239. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12240. * @returns the list of size gradients
  12241. */
  12242. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12243. /**
  12244. * Gets the current list of color remap gradients.
  12245. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12246. * @returns the list of color remap gradients
  12247. */
  12248. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12249. /**
  12250. * Gets the current list of alpha remap gradients.
  12251. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12252. * @returns the list of alpha remap gradients
  12253. */
  12254. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12255. /**
  12256. * Gets the current list of life time gradients.
  12257. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12258. * @returns the list of life time gradients
  12259. */
  12260. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12261. /**
  12262. * Gets the current list of angular speed gradients.
  12263. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12264. * @returns the list of angular speed gradients
  12265. */
  12266. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12267. /**
  12268. * Gets the current list of velocity gradients.
  12269. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12270. * @returns the list of velocity gradients
  12271. */
  12272. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12273. /**
  12274. * Gets the current list of start size gradients.
  12275. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12276. * @returns the list of start size gradients
  12277. */
  12278. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12279. /**
  12280. * Gets the current list of emit rate gradients.
  12281. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12282. * @returns the list of emit rate gradients
  12283. */
  12284. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12285. /**
  12286. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12287. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12288. */
  12289. get direction1(): Vector3;
  12290. set direction1(value: Vector3);
  12291. /**
  12292. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12293. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12294. */
  12295. get direction2(): Vector3;
  12296. set direction2(value: Vector3);
  12297. /**
  12298. * 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.
  12299. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12300. */
  12301. get minEmitBox(): Vector3;
  12302. set minEmitBox(value: Vector3);
  12303. /**
  12304. * 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.
  12305. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12306. */
  12307. get maxEmitBox(): Vector3;
  12308. set maxEmitBox(value: Vector3);
  12309. /**
  12310. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12311. */
  12312. color1: Color4;
  12313. /**
  12314. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12315. */
  12316. color2: Color4;
  12317. /**
  12318. * Color the particle will have at the end of its lifetime
  12319. */
  12320. colorDead: Color4;
  12321. /**
  12322. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12323. */
  12324. textureMask: Color4;
  12325. /**
  12326. * The particle emitter type defines the emitter used by the particle system.
  12327. * It can be for example box, sphere, or cone...
  12328. */
  12329. particleEmitterType: IParticleEmitterType;
  12330. /** @hidden */
  12331. _isSubEmitter: boolean;
  12332. /**
  12333. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12334. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12335. */
  12336. billboardMode: number;
  12337. protected _isBillboardBased: boolean;
  12338. /**
  12339. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12340. */
  12341. get isBillboardBased(): boolean;
  12342. set isBillboardBased(value: boolean);
  12343. /**
  12344. * The scene the particle system belongs to.
  12345. */
  12346. protected _scene: Nullable<Scene>;
  12347. /**
  12348. * The engine the particle system belongs to.
  12349. */
  12350. protected _engine: ThinEngine;
  12351. /**
  12352. * Local cache of defines for image processing.
  12353. */
  12354. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12355. /**
  12356. * Default configuration related to image processing available in the standard Material.
  12357. */
  12358. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12359. /**
  12360. * Gets the image processing configuration used either in this material.
  12361. */
  12362. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12363. /**
  12364. * Sets the Default image processing configuration used either in the this material.
  12365. *
  12366. * If sets to null, the scene one is in use.
  12367. */
  12368. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12369. /**
  12370. * Attaches a new image processing configuration to the Standard Material.
  12371. * @param configuration
  12372. */
  12373. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12374. /** @hidden */
  12375. protected _reset(): void;
  12376. /** @hidden */
  12377. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12378. /**
  12379. * Instantiates a particle system.
  12380. * 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.
  12381. * @param name The name of the particle system
  12382. */
  12383. constructor(name: string);
  12384. /**
  12385. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12386. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12387. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12388. * @returns the emitter
  12389. */
  12390. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12391. /**
  12392. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12393. * @param radius The radius of the hemisphere to emit from
  12394. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12395. * @returns the emitter
  12396. */
  12397. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12398. /**
  12399. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12400. * @param radius The radius of the sphere to emit from
  12401. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12402. * @returns the emitter
  12403. */
  12404. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12405. /**
  12406. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12407. * @param radius The radius of the sphere to emit from
  12408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12410. * @returns the emitter
  12411. */
  12412. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12413. /**
  12414. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12415. * @param radius The radius of the emission cylinder
  12416. * @param height The height of the emission cylinder
  12417. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12418. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12419. * @returns the emitter
  12420. */
  12421. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12422. /**
  12423. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12424. * @param radius The radius of the cylinder to emit from
  12425. * @param height The height of the emission cylinder
  12426. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12427. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12428. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12429. * @returns the emitter
  12430. */
  12431. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12432. /**
  12433. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12434. * @param radius The radius of the cone to emit from
  12435. * @param angle The base angle of the cone
  12436. * @returns the emitter
  12437. */
  12438. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12439. /**
  12440. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12443. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12444. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12445. * @returns the emitter
  12446. */
  12447. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12448. }
  12449. }
  12450. declare module BABYLON {
  12451. /**
  12452. * Type of sub emitter
  12453. */
  12454. export enum SubEmitterType {
  12455. /**
  12456. * Attached to the particle over it's lifetime
  12457. */
  12458. ATTACHED = 0,
  12459. /**
  12460. * Created when the particle dies
  12461. */
  12462. END = 1
  12463. }
  12464. /**
  12465. * Sub emitter class used to emit particles from an existing particle
  12466. */
  12467. export class SubEmitter {
  12468. /**
  12469. * the particle system to be used by the sub emitter
  12470. */
  12471. particleSystem: ParticleSystem;
  12472. /**
  12473. * Type of the submitter (Default: END)
  12474. */
  12475. type: SubEmitterType;
  12476. /**
  12477. * 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)
  12478. * Note: This only is supported when using an emitter of type Mesh
  12479. */
  12480. inheritDirection: boolean;
  12481. /**
  12482. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12483. */
  12484. inheritedVelocityAmount: number;
  12485. /**
  12486. * Creates a sub emitter
  12487. * @param particleSystem the particle system to be used by the sub emitter
  12488. */
  12489. constructor(
  12490. /**
  12491. * the particle system to be used by the sub emitter
  12492. */
  12493. particleSystem: ParticleSystem);
  12494. /**
  12495. * Clones the sub emitter
  12496. * @returns the cloned sub emitter
  12497. */
  12498. clone(): SubEmitter;
  12499. /**
  12500. * Serialize current object to a JSON object
  12501. * @returns the serialized object
  12502. */
  12503. serialize(): any;
  12504. /** @hidden */
  12505. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12506. /**
  12507. * Creates a new SubEmitter from a serialized JSON version
  12508. * @param serializationObject defines the JSON object to read from
  12509. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12510. * @param rootUrl defines the rootUrl for data loading
  12511. * @returns a new SubEmitter
  12512. */
  12513. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12514. /** Release associated resources */
  12515. dispose(): void;
  12516. }
  12517. }
  12518. declare module BABYLON {
  12519. /** @hidden */
  12520. export var imageProcessingDeclaration: {
  12521. name: string;
  12522. shader: string;
  12523. };
  12524. }
  12525. declare module BABYLON {
  12526. /** @hidden */
  12527. export var imageProcessingFunctions: {
  12528. name: string;
  12529. shader: string;
  12530. };
  12531. }
  12532. declare module BABYLON {
  12533. /** @hidden */
  12534. export var particlesPixelShader: {
  12535. name: string;
  12536. shader: string;
  12537. };
  12538. }
  12539. declare module BABYLON {
  12540. /** @hidden */
  12541. export var particlesVertexShader: {
  12542. name: string;
  12543. shader: string;
  12544. };
  12545. }
  12546. declare module BABYLON {
  12547. /**
  12548. * Interface used to define entities containing multiple clip planes
  12549. */
  12550. export interface IClipPlanesHolder {
  12551. /**
  12552. * Gets or sets the active clipplane 1
  12553. */
  12554. clipPlane: Nullable<Plane>;
  12555. /**
  12556. * Gets or sets the active clipplane 2
  12557. */
  12558. clipPlane2: Nullable<Plane>;
  12559. /**
  12560. * Gets or sets the active clipplane 3
  12561. */
  12562. clipPlane3: Nullable<Plane>;
  12563. /**
  12564. * Gets or sets the active clipplane 4
  12565. */
  12566. clipPlane4: Nullable<Plane>;
  12567. /**
  12568. * Gets or sets the active clipplane 5
  12569. */
  12570. clipPlane5: Nullable<Plane>;
  12571. /**
  12572. * Gets or sets the active clipplane 6
  12573. */
  12574. clipPlane6: Nullable<Plane>;
  12575. }
  12576. }
  12577. declare module BABYLON {
  12578. /**
  12579. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12580. *
  12581. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12582. *
  12583. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12584. */
  12585. export class ThinMaterialHelper {
  12586. /**
  12587. * Binds the clip plane information from the holder to the effect.
  12588. * @param effect The effect we are binding the data to
  12589. * @param holder The entity containing the clip plane information
  12590. */
  12591. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12592. }
  12593. }
  12594. declare module BABYLON {
  12595. interface ThinEngine {
  12596. /**
  12597. * Sets alpha constants used by some alpha blending modes
  12598. * @param r defines the red component
  12599. * @param g defines the green component
  12600. * @param b defines the blue component
  12601. * @param a defines the alpha component
  12602. */
  12603. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12604. /**
  12605. * Sets the current alpha mode
  12606. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12607. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12608. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12609. */
  12610. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12611. /**
  12612. * Gets the current alpha mode
  12613. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12614. * @returns the current alpha mode
  12615. */
  12616. getAlphaMode(): number;
  12617. /**
  12618. * Sets the current alpha equation
  12619. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12620. */
  12621. setAlphaEquation(equation: number): void;
  12622. /**
  12623. * Gets the current alpha equation.
  12624. * @returns the current alpha equation
  12625. */
  12626. getAlphaEquation(): number;
  12627. }
  12628. }
  12629. declare module BABYLON {
  12630. /**
  12631. * This represents a particle system in Babylon.
  12632. * 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.
  12633. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12634. * @example https://doc.babylonjs.com/babylon101/particles
  12635. */
  12636. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12637. /**
  12638. * Billboard mode will only apply to Y axis
  12639. */
  12640. static readonly BILLBOARDMODE_Y: number;
  12641. /**
  12642. * Billboard mode will apply to all axes
  12643. */
  12644. static readonly BILLBOARDMODE_ALL: number;
  12645. /**
  12646. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12647. */
  12648. static readonly BILLBOARDMODE_STRETCHED: number;
  12649. /**
  12650. * This function can be defined to provide custom update for active particles.
  12651. * This function will be called instead of regular update (age, position, color, etc.).
  12652. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12653. */
  12654. updateFunction: (particles: Particle[]) => void;
  12655. private _emitterWorldMatrix;
  12656. /**
  12657. * This function can be defined to specify initial direction for every new particle.
  12658. * It by default use the emitterType defined function
  12659. */
  12660. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12661. /**
  12662. * This function can be defined to specify initial position for every new particle.
  12663. * It by default use the emitterType defined function
  12664. */
  12665. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12666. /**
  12667. * @hidden
  12668. */
  12669. _inheritedVelocityOffset: Vector3;
  12670. /**
  12671. * An event triggered when the system is disposed
  12672. */
  12673. onDisposeObservable: Observable<IParticleSystem>;
  12674. /**
  12675. * An event triggered when the system is stopped
  12676. */
  12677. onStoppedObservable: Observable<IParticleSystem>;
  12678. private _onDisposeObserver;
  12679. /**
  12680. * Sets a callback that will be triggered when the system is disposed
  12681. */
  12682. set onDispose(callback: () => void);
  12683. private _particles;
  12684. private _epsilon;
  12685. private _capacity;
  12686. private _stockParticles;
  12687. private _newPartsExcess;
  12688. private _vertexData;
  12689. private _vertexBuffer;
  12690. private _vertexBuffers;
  12691. private _spriteBuffer;
  12692. private _indexBuffer;
  12693. private _effect;
  12694. private _customEffect;
  12695. private _cachedDefines;
  12696. private _scaledColorStep;
  12697. private _colorDiff;
  12698. private _scaledDirection;
  12699. private _scaledGravity;
  12700. private _currentRenderId;
  12701. private _alive;
  12702. private _useInstancing;
  12703. private _vertexArrayObject;
  12704. private _started;
  12705. private _stopped;
  12706. private _actualFrame;
  12707. private _scaledUpdateSpeed;
  12708. private _vertexBufferSize;
  12709. /** @hidden */
  12710. _currentEmitRateGradient: Nullable<FactorGradient>;
  12711. /** @hidden */
  12712. _currentEmitRate1: number;
  12713. /** @hidden */
  12714. _currentEmitRate2: number;
  12715. /** @hidden */
  12716. _currentStartSizeGradient: Nullable<FactorGradient>;
  12717. /** @hidden */
  12718. _currentStartSize1: number;
  12719. /** @hidden */
  12720. _currentStartSize2: number;
  12721. private readonly _rawTextureWidth;
  12722. private _rampGradientsTexture;
  12723. private _useRampGradients;
  12724. /** Gets or sets a matrix to use to compute projection */
  12725. defaultProjectionMatrix: Matrix;
  12726. /** Gets or sets a matrix to use to compute view */
  12727. defaultViewMatrix: Matrix;
  12728. /** Gets or sets a boolean indicating that ramp gradients must be used
  12729. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12730. */
  12731. get useRampGradients(): boolean;
  12732. set useRampGradients(value: boolean);
  12733. /**
  12734. * 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.
  12735. * 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: [])
  12736. */
  12737. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12738. private _subEmitters;
  12739. /**
  12740. * @hidden
  12741. * If the particle systems emitter should be disposed when the particle system is disposed
  12742. */
  12743. _disposeEmitterOnDispose: boolean;
  12744. /**
  12745. * The current active Sub-systems, this property is used by the root particle system only.
  12746. */
  12747. activeSubSystems: Array<ParticleSystem>;
  12748. /**
  12749. * Specifies if the particles are updated in emitter local space or world space
  12750. */
  12751. isLocal: boolean;
  12752. private _rootParticleSystem;
  12753. /**
  12754. * Gets the current list of active particles
  12755. */
  12756. get particles(): Particle[];
  12757. /**
  12758. * Gets the number of particles active at the same time.
  12759. * @returns The number of active particles.
  12760. */
  12761. getActiveCount(): number;
  12762. /**
  12763. * Returns the string "ParticleSystem"
  12764. * @returns a string containing the class name
  12765. */
  12766. getClassName(): string;
  12767. /**
  12768. * Gets a boolean indicating that the system is stopping
  12769. * @returns true if the system is currently stopping
  12770. */
  12771. isStopping(): boolean;
  12772. /**
  12773. * Gets the custom effect used to render the particles
  12774. * @param blendMode Blend mode for which the effect should be retrieved
  12775. * @returns The effect
  12776. */
  12777. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12778. /**
  12779. * Sets the custom effect used to render the particles
  12780. * @param effect The effect to set
  12781. * @param blendMode Blend mode for which the effect should be set
  12782. */
  12783. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12784. /** @hidden */
  12785. private _onBeforeDrawParticlesObservable;
  12786. /**
  12787. * Observable that will be called just before the particles are drawn
  12788. */
  12789. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12790. /**
  12791. * Gets the name of the particle vertex shader
  12792. */
  12793. get vertexShaderName(): string;
  12794. /**
  12795. * Instantiates a particle system.
  12796. * 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.
  12797. * @param name The name of the particle system
  12798. * @param capacity The max number of particles alive at the same time
  12799. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12800. * @param customEffect a custom effect used to change the way particles are rendered by default
  12801. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12802. * @param epsilon Offset used to render the particles
  12803. */
  12804. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12805. private _addFactorGradient;
  12806. private _removeFactorGradient;
  12807. /**
  12808. * Adds a new life time gradient
  12809. * @param gradient defines the gradient to use (between 0 and 1)
  12810. * @param factor defines the life time factor to affect to the specified gradient
  12811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12812. * @returns the current particle system
  12813. */
  12814. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12815. /**
  12816. * Remove a specific life time gradient
  12817. * @param gradient defines the gradient to remove
  12818. * @returns the current particle system
  12819. */
  12820. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12821. /**
  12822. * Adds a new size gradient
  12823. * @param gradient defines the gradient to use (between 0 and 1)
  12824. * @param factor defines the size factor to affect to the specified gradient
  12825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12826. * @returns the current particle system
  12827. */
  12828. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12829. /**
  12830. * Remove a specific size gradient
  12831. * @param gradient defines the gradient to remove
  12832. * @returns the current particle system
  12833. */
  12834. removeSizeGradient(gradient: number): IParticleSystem;
  12835. /**
  12836. * Adds a new color remap gradient
  12837. * @param gradient defines the gradient to use (between 0 and 1)
  12838. * @param min defines the color remap minimal range
  12839. * @param max defines the color remap maximal range
  12840. * @returns the current particle system
  12841. */
  12842. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12843. /**
  12844. * Remove a specific color remap gradient
  12845. * @param gradient defines the gradient to remove
  12846. * @returns the current particle system
  12847. */
  12848. removeColorRemapGradient(gradient: number): IParticleSystem;
  12849. /**
  12850. * Adds a new alpha remap gradient
  12851. * @param gradient defines the gradient to use (between 0 and 1)
  12852. * @param min defines the alpha remap minimal range
  12853. * @param max defines the alpha remap maximal range
  12854. * @returns the current particle system
  12855. */
  12856. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12857. /**
  12858. * Remove a specific alpha remap gradient
  12859. * @param gradient defines the gradient to remove
  12860. * @returns the current particle system
  12861. */
  12862. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12863. /**
  12864. * Adds a new angular speed gradient
  12865. * @param gradient defines the gradient to use (between 0 and 1)
  12866. * @param factor defines the angular speed to affect to the specified gradient
  12867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12868. * @returns the current particle system
  12869. */
  12870. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12871. /**
  12872. * Remove a specific angular speed gradient
  12873. * @param gradient defines the gradient to remove
  12874. * @returns the current particle system
  12875. */
  12876. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12877. /**
  12878. * Adds a new velocity gradient
  12879. * @param gradient defines the gradient to use (between 0 and 1)
  12880. * @param factor defines the velocity to affect to the specified gradient
  12881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12882. * @returns the current particle system
  12883. */
  12884. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12885. /**
  12886. * Remove a specific velocity gradient
  12887. * @param gradient defines the gradient to remove
  12888. * @returns the current particle system
  12889. */
  12890. removeVelocityGradient(gradient: number): IParticleSystem;
  12891. /**
  12892. * Adds a new limit velocity gradient
  12893. * @param gradient defines the gradient to use (between 0 and 1)
  12894. * @param factor defines the limit velocity value to affect to the specified gradient
  12895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12896. * @returns the current particle system
  12897. */
  12898. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12899. /**
  12900. * Remove a specific limit velocity gradient
  12901. * @param gradient defines the gradient to remove
  12902. * @returns the current particle system
  12903. */
  12904. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12905. /**
  12906. * Adds a new drag gradient
  12907. * @param gradient defines the gradient to use (between 0 and 1)
  12908. * @param factor defines the drag value to affect to the specified gradient
  12909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12910. * @returns the current particle system
  12911. */
  12912. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12913. /**
  12914. * Remove a specific drag gradient
  12915. * @param gradient defines the gradient to remove
  12916. * @returns the current particle system
  12917. */
  12918. removeDragGradient(gradient: number): IParticleSystem;
  12919. /**
  12920. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12921. * @param gradient defines the gradient to use (between 0 and 1)
  12922. * @param factor defines the emit rate value to affect to the specified gradient
  12923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12924. * @returns the current particle system
  12925. */
  12926. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12927. /**
  12928. * Remove a specific emit rate gradient
  12929. * @param gradient defines the gradient to remove
  12930. * @returns the current particle system
  12931. */
  12932. removeEmitRateGradient(gradient: number): IParticleSystem;
  12933. /**
  12934. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12935. * @param gradient defines the gradient to use (between 0 and 1)
  12936. * @param factor defines the start size value to affect to the specified gradient
  12937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12938. * @returns the current particle system
  12939. */
  12940. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12941. /**
  12942. * Remove a specific start size gradient
  12943. * @param gradient defines the gradient to remove
  12944. * @returns the current particle system
  12945. */
  12946. removeStartSizeGradient(gradient: number): IParticleSystem;
  12947. private _createRampGradientTexture;
  12948. /**
  12949. * Gets the current list of ramp gradients.
  12950. * You must use addRampGradient and removeRampGradient to udpate this list
  12951. * @returns the list of ramp gradients
  12952. */
  12953. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12954. /** Force the system to rebuild all gradients that need to be resync */
  12955. forceRefreshGradients(): void;
  12956. private _syncRampGradientTexture;
  12957. /**
  12958. * Adds a new ramp gradient used to remap particle colors
  12959. * @param gradient defines the gradient to use (between 0 and 1)
  12960. * @param color defines the color to affect to the specified gradient
  12961. * @returns the current particle system
  12962. */
  12963. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12964. /**
  12965. * Remove a specific ramp gradient
  12966. * @param gradient defines the gradient to remove
  12967. * @returns the current particle system
  12968. */
  12969. removeRampGradient(gradient: number): ParticleSystem;
  12970. /**
  12971. * Adds a new color gradient
  12972. * @param gradient defines the gradient to use (between 0 and 1)
  12973. * @param color1 defines the color to affect to the specified gradient
  12974. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12975. * @returns this particle system
  12976. */
  12977. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12978. /**
  12979. * Remove a specific color gradient
  12980. * @param gradient defines the gradient to remove
  12981. * @returns this particle system
  12982. */
  12983. removeColorGradient(gradient: number): IParticleSystem;
  12984. private _fetchR;
  12985. protected _reset(): void;
  12986. private _resetEffect;
  12987. private _createVertexBuffers;
  12988. private _createIndexBuffer;
  12989. /**
  12990. * Gets the maximum number of particles active at the same time.
  12991. * @returns The max number of active particles.
  12992. */
  12993. getCapacity(): number;
  12994. /**
  12995. * Gets whether there are still active particles in the system.
  12996. * @returns True if it is alive, otherwise false.
  12997. */
  12998. isAlive(): boolean;
  12999. /**
  13000. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13001. * @returns True if it has been started, otherwise false.
  13002. */
  13003. isStarted(): boolean;
  13004. private _prepareSubEmitterInternalArray;
  13005. /**
  13006. * Starts the particle system and begins to emit
  13007. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13008. */
  13009. start(delay?: number): void;
  13010. /**
  13011. * Stops the particle system.
  13012. * @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.
  13013. */
  13014. stop(stopSubEmitters?: boolean): void;
  13015. /**
  13016. * Remove all active particles
  13017. */
  13018. reset(): void;
  13019. /**
  13020. * @hidden (for internal use only)
  13021. */
  13022. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13023. /**
  13024. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13025. * Its lifetime will start back at 0.
  13026. */
  13027. recycleParticle: (particle: Particle) => void;
  13028. private _stopSubEmitters;
  13029. private _createParticle;
  13030. private _removeFromRoot;
  13031. private _emitFromParticle;
  13032. private _update;
  13033. /** @hidden */
  13034. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13035. /** @hidden */
  13036. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13037. /**
  13038. * Fill the defines array according to the current settings of the particle system
  13039. * @param defines Array to be updated
  13040. * @param blendMode blend mode to take into account when updating the array
  13041. */
  13042. fillDefines(defines: Array<string>, blendMode: number): void;
  13043. /**
  13044. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13045. * @param uniforms Uniforms array to fill
  13046. * @param attributes Attributes array to fill
  13047. * @param samplers Samplers array to fill
  13048. */
  13049. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13050. /** @hidden */
  13051. private _getEffect;
  13052. /**
  13053. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13054. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13055. */
  13056. animate(preWarmOnly?: boolean): void;
  13057. private _appendParticleVertices;
  13058. /**
  13059. * Rebuilds the particle system.
  13060. */
  13061. rebuild(): void;
  13062. /**
  13063. * Is this system ready to be used/rendered
  13064. * @return true if the system is ready
  13065. */
  13066. isReady(): boolean;
  13067. private _render;
  13068. /**
  13069. * Renders the particle system in its current state.
  13070. * @returns the current number of particles
  13071. */
  13072. render(): number;
  13073. /**
  13074. * Disposes the particle system and free the associated resources
  13075. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13076. */
  13077. dispose(disposeTexture?: boolean): void;
  13078. /**
  13079. * Clones the particle system.
  13080. * @param name The name of the cloned object
  13081. * @param newEmitter The new emitter to use
  13082. * @returns the cloned particle system
  13083. */
  13084. clone(name: string, newEmitter: any): ParticleSystem;
  13085. /**
  13086. * Serializes the particle system to a JSON object
  13087. * @param serializeTexture defines if the texture must be serialized as well
  13088. * @returns the JSON object
  13089. */
  13090. serialize(serializeTexture?: boolean): any;
  13091. /** @hidden */
  13092. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13093. /** @hidden */
  13094. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13095. /**
  13096. * Parses a JSON object to create a particle system.
  13097. * @param parsedParticleSystem The JSON object to parse
  13098. * @param sceneOrEngine The scene or the engine to create the particle system in
  13099. * @param rootUrl The root url to use to load external dependencies like texture
  13100. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13101. * @returns the Parsed particle system
  13102. */
  13103. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13104. }
  13105. }
  13106. declare module BABYLON {
  13107. /**
  13108. * A particle represents one of the element emitted by a particle system.
  13109. * This is mainly define by its coordinates, direction, velocity and age.
  13110. */
  13111. export class Particle {
  13112. /**
  13113. * The particle system the particle belongs to.
  13114. */
  13115. particleSystem: ParticleSystem;
  13116. private static _Count;
  13117. /**
  13118. * Unique ID of the particle
  13119. */
  13120. id: number;
  13121. /**
  13122. * The world position of the particle in the scene.
  13123. */
  13124. position: Vector3;
  13125. /**
  13126. * The world direction of the particle in the scene.
  13127. */
  13128. direction: Vector3;
  13129. /**
  13130. * The color of the particle.
  13131. */
  13132. color: Color4;
  13133. /**
  13134. * The color change of the particle per step.
  13135. */
  13136. colorStep: Color4;
  13137. /**
  13138. * Defines how long will the life of the particle be.
  13139. */
  13140. lifeTime: number;
  13141. /**
  13142. * The current age of the particle.
  13143. */
  13144. age: number;
  13145. /**
  13146. * The current size of the particle.
  13147. */
  13148. size: number;
  13149. /**
  13150. * The current scale of the particle.
  13151. */
  13152. scale: Vector2;
  13153. /**
  13154. * The current angle of the particle.
  13155. */
  13156. angle: number;
  13157. /**
  13158. * Defines how fast is the angle changing.
  13159. */
  13160. angularSpeed: number;
  13161. /**
  13162. * Defines the cell index used by the particle to be rendered from a sprite.
  13163. */
  13164. cellIndex: number;
  13165. /**
  13166. * The information required to support color remapping
  13167. */
  13168. remapData: Vector4;
  13169. /** @hidden */
  13170. _randomCellOffset?: number;
  13171. /** @hidden */
  13172. _initialDirection: Nullable<Vector3>;
  13173. /** @hidden */
  13174. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13175. /** @hidden */
  13176. _initialStartSpriteCellID: number;
  13177. /** @hidden */
  13178. _initialEndSpriteCellID: number;
  13179. /** @hidden */
  13180. _currentColorGradient: Nullable<ColorGradient>;
  13181. /** @hidden */
  13182. _currentColor1: Color4;
  13183. /** @hidden */
  13184. _currentColor2: Color4;
  13185. /** @hidden */
  13186. _currentSizeGradient: Nullable<FactorGradient>;
  13187. /** @hidden */
  13188. _currentSize1: number;
  13189. /** @hidden */
  13190. _currentSize2: number;
  13191. /** @hidden */
  13192. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13193. /** @hidden */
  13194. _currentAngularSpeed1: number;
  13195. /** @hidden */
  13196. _currentAngularSpeed2: number;
  13197. /** @hidden */
  13198. _currentVelocityGradient: Nullable<FactorGradient>;
  13199. /** @hidden */
  13200. _currentVelocity1: number;
  13201. /** @hidden */
  13202. _currentVelocity2: number;
  13203. /** @hidden */
  13204. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13205. /** @hidden */
  13206. _currentLimitVelocity1: number;
  13207. /** @hidden */
  13208. _currentLimitVelocity2: number;
  13209. /** @hidden */
  13210. _currentDragGradient: Nullable<FactorGradient>;
  13211. /** @hidden */
  13212. _currentDrag1: number;
  13213. /** @hidden */
  13214. _currentDrag2: number;
  13215. /** @hidden */
  13216. _randomNoiseCoordinates1: Vector3;
  13217. /** @hidden */
  13218. _randomNoiseCoordinates2: Vector3;
  13219. /** @hidden */
  13220. _localPosition?: Vector3;
  13221. /**
  13222. * Creates a new instance Particle
  13223. * @param particleSystem the particle system the particle belongs to
  13224. */
  13225. constructor(
  13226. /**
  13227. * The particle system the particle belongs to.
  13228. */
  13229. particleSystem: ParticleSystem);
  13230. private updateCellInfoFromSystem;
  13231. /**
  13232. * Defines how the sprite cell index is updated for the particle
  13233. */
  13234. updateCellIndex(): void;
  13235. /** @hidden */
  13236. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13237. /** @hidden */
  13238. _inheritParticleInfoToSubEmitters(): void;
  13239. /** @hidden */
  13240. _reset(): void;
  13241. /**
  13242. * Copy the properties of particle to another one.
  13243. * @param other the particle to copy the information to.
  13244. */
  13245. copyTo(other: Particle): void;
  13246. }
  13247. }
  13248. declare module BABYLON {
  13249. /**
  13250. * Particle emitter represents a volume emitting particles.
  13251. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13252. */
  13253. export interface IParticleEmitterType {
  13254. /**
  13255. * Called by the particle System when the direction is computed for the created particle.
  13256. * @param worldMatrix is the world matrix of the particle system
  13257. * @param directionToUpdate is the direction vector to update with the result
  13258. * @param particle is the particle we are computed the direction for
  13259. * @param isLocal defines if the direction should be set in local space
  13260. */
  13261. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13262. /**
  13263. * Called by the particle System when the position is computed for the created particle.
  13264. * @param worldMatrix is the world matrix of the particle system
  13265. * @param positionToUpdate is the position vector to update with the result
  13266. * @param particle is the particle we are computed the position for
  13267. * @param isLocal defines if the position should be set in local space
  13268. */
  13269. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13270. /**
  13271. * Clones the current emitter and returns a copy of it
  13272. * @returns the new emitter
  13273. */
  13274. clone(): IParticleEmitterType;
  13275. /**
  13276. * Called by the GPUParticleSystem to setup the update shader
  13277. * @param effect defines the update shader
  13278. */
  13279. applyToShader(effect: Effect): void;
  13280. /**
  13281. * Returns a string to use to update the GPU particles update shader
  13282. * @returns the effect defines string
  13283. */
  13284. getEffectDefines(): string;
  13285. /**
  13286. * Returns a string representing the class name
  13287. * @returns a string containing the class name
  13288. */
  13289. getClassName(): string;
  13290. /**
  13291. * Serializes the particle system to a JSON object.
  13292. * @returns the JSON object
  13293. */
  13294. serialize(): any;
  13295. /**
  13296. * Parse properties from a JSON object
  13297. * @param serializationObject defines the JSON object
  13298. * @param scene defines the hosting scene
  13299. */
  13300. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13301. }
  13302. }
  13303. declare module BABYLON {
  13304. /**
  13305. * Particle emitter emitting particles from the inside of a box.
  13306. * It emits the particles randomly between 2 given directions.
  13307. */
  13308. export class BoxParticleEmitter implements IParticleEmitterType {
  13309. /**
  13310. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13311. */
  13312. direction1: Vector3;
  13313. /**
  13314. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13315. */
  13316. direction2: Vector3;
  13317. /**
  13318. * 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.
  13319. */
  13320. minEmitBox: Vector3;
  13321. /**
  13322. * 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.
  13323. */
  13324. maxEmitBox: Vector3;
  13325. /**
  13326. * Creates a new instance BoxParticleEmitter
  13327. */
  13328. constructor();
  13329. /**
  13330. * Called by the particle System when the direction is computed for the created particle.
  13331. * @param worldMatrix is the world matrix of the particle system
  13332. * @param directionToUpdate is the direction vector to update with the result
  13333. * @param particle is the particle we are computed the direction for
  13334. * @param isLocal defines if the direction should be set in local space
  13335. */
  13336. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13337. /**
  13338. * Called by the particle System when the position is computed for the created particle.
  13339. * @param worldMatrix is the world matrix of the particle system
  13340. * @param positionToUpdate is the position vector to update with the result
  13341. * @param particle is the particle we are computed the position for
  13342. * @param isLocal defines if the position should be set in local space
  13343. */
  13344. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13345. /**
  13346. * Clones the current emitter and returns a copy of it
  13347. * @returns the new emitter
  13348. */
  13349. clone(): BoxParticleEmitter;
  13350. /**
  13351. * Called by the GPUParticleSystem to setup the update shader
  13352. * @param effect defines the update shader
  13353. */
  13354. applyToShader(effect: Effect): void;
  13355. /**
  13356. * Returns a string to use to update the GPU particles update shader
  13357. * @returns a string containng the defines string
  13358. */
  13359. getEffectDefines(): string;
  13360. /**
  13361. * Returns the string "BoxParticleEmitter"
  13362. * @returns a string containing the class name
  13363. */
  13364. getClassName(): string;
  13365. /**
  13366. * Serializes the particle system to a JSON object.
  13367. * @returns the JSON object
  13368. */
  13369. serialize(): any;
  13370. /**
  13371. * Parse properties from a JSON object
  13372. * @param serializationObject defines the JSON object
  13373. */
  13374. parse(serializationObject: any): void;
  13375. }
  13376. }
  13377. declare module BABYLON {
  13378. /**
  13379. * Particle emitter emitting particles from the inside of a cone.
  13380. * It emits the particles alongside the cone volume from the base to the particle.
  13381. * The emission direction might be randomized.
  13382. */
  13383. export class ConeParticleEmitter implements IParticleEmitterType {
  13384. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13385. directionRandomizer: number;
  13386. private _radius;
  13387. private _angle;
  13388. private _height;
  13389. /**
  13390. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13391. */
  13392. radiusRange: number;
  13393. /**
  13394. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13395. */
  13396. heightRange: number;
  13397. /**
  13398. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13399. */
  13400. emitFromSpawnPointOnly: boolean;
  13401. /**
  13402. * Gets or sets the radius of the emission cone
  13403. */
  13404. get radius(): number;
  13405. set radius(value: number);
  13406. /**
  13407. * Gets or sets the angle of the emission cone
  13408. */
  13409. get angle(): number;
  13410. set angle(value: number);
  13411. private _buildHeight;
  13412. /**
  13413. * Creates a new instance ConeParticleEmitter
  13414. * @param radius the radius of the emission cone (1 by default)
  13415. * @param angle the cone base angle (PI by default)
  13416. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13417. */
  13418. constructor(radius?: number, angle?: number,
  13419. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13420. directionRandomizer?: number);
  13421. /**
  13422. * Called by the particle System when the direction is computed for the created particle.
  13423. * @param worldMatrix is the world matrix of the particle system
  13424. * @param directionToUpdate is the direction vector to update with the result
  13425. * @param particle is the particle we are computed the direction for
  13426. * @param isLocal defines if the direction should be set in local space
  13427. */
  13428. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13429. /**
  13430. * Called by the particle System when the position is computed for the created particle.
  13431. * @param worldMatrix is the world matrix of the particle system
  13432. * @param positionToUpdate is the position vector to update with the result
  13433. * @param particle is the particle we are computed the position for
  13434. * @param isLocal defines if the position should be set in local space
  13435. */
  13436. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13437. /**
  13438. * Clones the current emitter and returns a copy of it
  13439. * @returns the new emitter
  13440. */
  13441. clone(): ConeParticleEmitter;
  13442. /**
  13443. * Called by the GPUParticleSystem to setup the update shader
  13444. * @param effect defines the update shader
  13445. */
  13446. applyToShader(effect: Effect): void;
  13447. /**
  13448. * Returns a string to use to update the GPU particles update shader
  13449. * @returns a string containng the defines string
  13450. */
  13451. getEffectDefines(): string;
  13452. /**
  13453. * Returns the string "ConeParticleEmitter"
  13454. * @returns a string containing the class name
  13455. */
  13456. getClassName(): string;
  13457. /**
  13458. * Serializes the particle system to a JSON object.
  13459. * @returns the JSON object
  13460. */
  13461. serialize(): any;
  13462. /**
  13463. * Parse properties from a JSON object
  13464. * @param serializationObject defines the JSON object
  13465. */
  13466. parse(serializationObject: any): void;
  13467. }
  13468. }
  13469. declare module BABYLON {
  13470. /**
  13471. * Particle emitter emitting particles from the inside of a cylinder.
  13472. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13473. */
  13474. export class CylinderParticleEmitter implements IParticleEmitterType {
  13475. /**
  13476. * The radius of the emission cylinder.
  13477. */
  13478. radius: number;
  13479. /**
  13480. * The height of the emission cylinder.
  13481. */
  13482. height: number;
  13483. /**
  13484. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13485. */
  13486. radiusRange: number;
  13487. /**
  13488. * How much to randomize the particle direction [0-1].
  13489. */
  13490. directionRandomizer: number;
  13491. /**
  13492. * Creates a new instance CylinderParticleEmitter
  13493. * @param radius the radius of the emission cylinder (1 by default)
  13494. * @param height the height of the emission cylinder (1 by default)
  13495. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13496. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13497. */
  13498. constructor(
  13499. /**
  13500. * The radius of the emission cylinder.
  13501. */
  13502. radius?: number,
  13503. /**
  13504. * The height of the emission cylinder.
  13505. */
  13506. height?: number,
  13507. /**
  13508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13509. */
  13510. radiusRange?: number,
  13511. /**
  13512. * How much to randomize the particle direction [0-1].
  13513. */
  13514. directionRandomizer?: number);
  13515. /**
  13516. * Called by the particle System when the direction is computed for the created particle.
  13517. * @param worldMatrix is the world matrix of the particle system
  13518. * @param directionToUpdate is the direction vector to update with the result
  13519. * @param particle is the particle we are computed the direction for
  13520. * @param isLocal defines if the direction should be set in local space
  13521. */
  13522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13523. /**
  13524. * Called by the particle System when the position is computed for the created particle.
  13525. * @param worldMatrix is the world matrix of the particle system
  13526. * @param positionToUpdate is the position vector to update with the result
  13527. * @param particle is the particle we are computed the position for
  13528. * @param isLocal defines if the position should be set in local space
  13529. */
  13530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13531. /**
  13532. * Clones the current emitter and returns a copy of it
  13533. * @returns the new emitter
  13534. */
  13535. clone(): CylinderParticleEmitter;
  13536. /**
  13537. * Called by the GPUParticleSystem to setup the update shader
  13538. * @param effect defines the update shader
  13539. */
  13540. applyToShader(effect: Effect): void;
  13541. /**
  13542. * Returns a string to use to update the GPU particles update shader
  13543. * @returns a string containng the defines string
  13544. */
  13545. getEffectDefines(): string;
  13546. /**
  13547. * Returns the string "CylinderParticleEmitter"
  13548. * @returns a string containing the class name
  13549. */
  13550. getClassName(): string;
  13551. /**
  13552. * Serializes the particle system to a JSON object.
  13553. * @returns the JSON object
  13554. */
  13555. serialize(): any;
  13556. /**
  13557. * Parse properties from a JSON object
  13558. * @param serializationObject defines the JSON object
  13559. */
  13560. parse(serializationObject: any): void;
  13561. }
  13562. /**
  13563. * Particle emitter emitting particles from the inside of a cylinder.
  13564. * It emits the particles randomly between two vectors.
  13565. */
  13566. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13567. /**
  13568. * The min limit of the emission direction.
  13569. */
  13570. direction1: Vector3;
  13571. /**
  13572. * The max limit of the emission direction.
  13573. */
  13574. direction2: Vector3;
  13575. /**
  13576. * Creates a new instance CylinderDirectedParticleEmitter
  13577. * @param radius the radius of the emission cylinder (1 by default)
  13578. * @param height the height of the emission cylinder (1 by default)
  13579. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13580. * @param direction1 the min limit of the emission direction (up vector by default)
  13581. * @param direction2 the max limit of the emission direction (up vector by default)
  13582. */
  13583. constructor(radius?: number, height?: number, radiusRange?: number,
  13584. /**
  13585. * The min limit of the emission direction.
  13586. */
  13587. direction1?: Vector3,
  13588. /**
  13589. * The max limit of the emission direction.
  13590. */
  13591. direction2?: Vector3);
  13592. /**
  13593. * Called by the particle System when the direction is computed for the created particle.
  13594. * @param worldMatrix is the world matrix of the particle system
  13595. * @param directionToUpdate is the direction vector to update with the result
  13596. * @param particle is the particle we are computed the direction for
  13597. */
  13598. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13599. /**
  13600. * Clones the current emitter and returns a copy of it
  13601. * @returns the new emitter
  13602. */
  13603. clone(): CylinderDirectedParticleEmitter;
  13604. /**
  13605. * Called by the GPUParticleSystem to setup the update shader
  13606. * @param effect defines the update shader
  13607. */
  13608. applyToShader(effect: Effect): void;
  13609. /**
  13610. * Returns a string to use to update the GPU particles update shader
  13611. * @returns a string containng the defines string
  13612. */
  13613. getEffectDefines(): string;
  13614. /**
  13615. * Returns the string "CylinderDirectedParticleEmitter"
  13616. * @returns a string containing the class name
  13617. */
  13618. getClassName(): string;
  13619. /**
  13620. * Serializes the particle system to a JSON object.
  13621. * @returns the JSON object
  13622. */
  13623. serialize(): any;
  13624. /**
  13625. * Parse properties from a JSON object
  13626. * @param serializationObject defines the JSON object
  13627. */
  13628. parse(serializationObject: any): void;
  13629. }
  13630. }
  13631. declare module BABYLON {
  13632. /**
  13633. * Particle emitter emitting particles from the inside of a hemisphere.
  13634. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13635. */
  13636. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13637. /**
  13638. * The radius of the emission hemisphere.
  13639. */
  13640. radius: number;
  13641. /**
  13642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13643. */
  13644. radiusRange: number;
  13645. /**
  13646. * How much to randomize the particle direction [0-1].
  13647. */
  13648. directionRandomizer: number;
  13649. /**
  13650. * Creates a new instance HemisphericParticleEmitter
  13651. * @param radius the radius of the emission hemisphere (1 by default)
  13652. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13653. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13654. */
  13655. constructor(
  13656. /**
  13657. * The radius of the emission hemisphere.
  13658. */
  13659. radius?: number,
  13660. /**
  13661. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13662. */
  13663. radiusRange?: number,
  13664. /**
  13665. * How much to randomize the particle direction [0-1].
  13666. */
  13667. directionRandomizer?: number);
  13668. /**
  13669. * Called by the particle System when the direction is computed for the created particle.
  13670. * @param worldMatrix is the world matrix of the particle system
  13671. * @param directionToUpdate is the direction vector to update with the result
  13672. * @param particle is the particle we are computed the direction for
  13673. * @param isLocal defines if the direction should be set in local space
  13674. */
  13675. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13676. /**
  13677. * Called by the particle System when the position is computed for the created particle.
  13678. * @param worldMatrix is the world matrix of the particle system
  13679. * @param positionToUpdate is the position vector to update with the result
  13680. * @param particle is the particle we are computed the position for
  13681. * @param isLocal defines if the position should be set in local space
  13682. */
  13683. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13684. /**
  13685. * Clones the current emitter and returns a copy of it
  13686. * @returns the new emitter
  13687. */
  13688. clone(): HemisphericParticleEmitter;
  13689. /**
  13690. * Called by the GPUParticleSystem to setup the update shader
  13691. * @param effect defines the update shader
  13692. */
  13693. applyToShader(effect: Effect): void;
  13694. /**
  13695. * Returns a string to use to update the GPU particles update shader
  13696. * @returns a string containng the defines string
  13697. */
  13698. getEffectDefines(): string;
  13699. /**
  13700. * Returns the string "HemisphericParticleEmitter"
  13701. * @returns a string containing the class name
  13702. */
  13703. getClassName(): string;
  13704. /**
  13705. * Serializes the particle system to a JSON object.
  13706. * @returns the JSON object
  13707. */
  13708. serialize(): any;
  13709. /**
  13710. * Parse properties from a JSON object
  13711. * @param serializationObject defines the JSON object
  13712. */
  13713. parse(serializationObject: any): void;
  13714. }
  13715. }
  13716. declare module BABYLON {
  13717. /**
  13718. * Particle emitter emitting particles from a point.
  13719. * It emits the particles randomly between 2 given directions.
  13720. */
  13721. export class PointParticleEmitter implements IParticleEmitterType {
  13722. /**
  13723. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13724. */
  13725. direction1: Vector3;
  13726. /**
  13727. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13728. */
  13729. direction2: Vector3;
  13730. /**
  13731. * Creates a new instance PointParticleEmitter
  13732. */
  13733. constructor();
  13734. /**
  13735. * Called by the particle System when the direction is computed for the created particle.
  13736. * @param worldMatrix is the world matrix of the particle system
  13737. * @param directionToUpdate is the direction vector to update with the result
  13738. * @param particle is the particle we are computed the direction for
  13739. * @param isLocal defines if the direction should be set in local space
  13740. */
  13741. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13742. /**
  13743. * Called by the particle System when the position is computed for the created particle.
  13744. * @param worldMatrix is the world matrix of the particle system
  13745. * @param positionToUpdate is the position vector to update with the result
  13746. * @param particle is the particle we are computed the position for
  13747. * @param isLocal defines if the position should be set in local space
  13748. */
  13749. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13750. /**
  13751. * Clones the current emitter and returns a copy of it
  13752. * @returns the new emitter
  13753. */
  13754. clone(): PointParticleEmitter;
  13755. /**
  13756. * Called by the GPUParticleSystem to setup the update shader
  13757. * @param effect defines the update shader
  13758. */
  13759. applyToShader(effect: Effect): void;
  13760. /**
  13761. * Returns a string to use to update the GPU particles update shader
  13762. * @returns a string containng the defines string
  13763. */
  13764. getEffectDefines(): string;
  13765. /**
  13766. * Returns the string "PointParticleEmitter"
  13767. * @returns a string containing the class name
  13768. */
  13769. getClassName(): string;
  13770. /**
  13771. * Serializes the particle system to a JSON object.
  13772. * @returns the JSON object
  13773. */
  13774. serialize(): any;
  13775. /**
  13776. * Parse properties from a JSON object
  13777. * @param serializationObject defines the JSON object
  13778. */
  13779. parse(serializationObject: any): void;
  13780. }
  13781. }
  13782. declare module BABYLON {
  13783. /**
  13784. * Particle emitter emitting particles from the inside of a sphere.
  13785. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13786. */
  13787. export class SphereParticleEmitter implements IParticleEmitterType {
  13788. /**
  13789. * The radius of the emission sphere.
  13790. */
  13791. radius: number;
  13792. /**
  13793. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13794. */
  13795. radiusRange: number;
  13796. /**
  13797. * How much to randomize the particle direction [0-1].
  13798. */
  13799. directionRandomizer: number;
  13800. /**
  13801. * Creates a new instance SphereParticleEmitter
  13802. * @param radius the radius of the emission sphere (1 by default)
  13803. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13804. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13805. */
  13806. constructor(
  13807. /**
  13808. * The radius of the emission sphere.
  13809. */
  13810. radius?: number,
  13811. /**
  13812. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13813. */
  13814. radiusRange?: number,
  13815. /**
  13816. * How much to randomize the particle direction [0-1].
  13817. */
  13818. directionRandomizer?: number);
  13819. /**
  13820. * Called by the particle System when the direction is computed for the created particle.
  13821. * @param worldMatrix is the world matrix of the particle system
  13822. * @param directionToUpdate is the direction vector to update with the result
  13823. * @param particle is the particle we are computed the direction for
  13824. * @param isLocal defines if the direction should be set in local space
  13825. */
  13826. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13827. /**
  13828. * Called by the particle System when the position is computed for the created particle.
  13829. * @param worldMatrix is the world matrix of the particle system
  13830. * @param positionToUpdate is the position vector to update with the result
  13831. * @param particle is the particle we are computed the position for
  13832. * @param isLocal defines if the position should be set in local space
  13833. */
  13834. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13835. /**
  13836. * Clones the current emitter and returns a copy of it
  13837. * @returns the new emitter
  13838. */
  13839. clone(): SphereParticleEmitter;
  13840. /**
  13841. * Called by the GPUParticleSystem to setup the update shader
  13842. * @param effect defines the update shader
  13843. */
  13844. applyToShader(effect: Effect): void;
  13845. /**
  13846. * Returns a string to use to update the GPU particles update shader
  13847. * @returns a string containng the defines string
  13848. */
  13849. getEffectDefines(): string;
  13850. /**
  13851. * Returns the string "SphereParticleEmitter"
  13852. * @returns a string containing the class name
  13853. */
  13854. getClassName(): string;
  13855. /**
  13856. * Serializes the particle system to a JSON object.
  13857. * @returns the JSON object
  13858. */
  13859. serialize(): any;
  13860. /**
  13861. * Parse properties from a JSON object
  13862. * @param serializationObject defines the JSON object
  13863. */
  13864. parse(serializationObject: any): void;
  13865. }
  13866. /**
  13867. * Particle emitter emitting particles from the inside of a sphere.
  13868. * It emits the particles randomly between two vectors.
  13869. */
  13870. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13871. /**
  13872. * The min limit of the emission direction.
  13873. */
  13874. direction1: Vector3;
  13875. /**
  13876. * The max limit of the emission direction.
  13877. */
  13878. direction2: Vector3;
  13879. /**
  13880. * Creates a new instance SphereDirectedParticleEmitter
  13881. * @param radius the radius of the emission sphere (1 by default)
  13882. * @param direction1 the min limit of the emission direction (up vector by default)
  13883. * @param direction2 the max limit of the emission direction (up vector by default)
  13884. */
  13885. constructor(radius?: number,
  13886. /**
  13887. * The min limit of the emission direction.
  13888. */
  13889. direction1?: Vector3,
  13890. /**
  13891. * The max limit of the emission direction.
  13892. */
  13893. direction2?: Vector3);
  13894. /**
  13895. * Called by the particle System when the direction is computed for the created particle.
  13896. * @param worldMatrix is the world matrix of the particle system
  13897. * @param directionToUpdate is the direction vector to update with the result
  13898. * @param particle is the particle we are computed the direction for
  13899. */
  13900. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13901. /**
  13902. * Clones the current emitter and returns a copy of it
  13903. * @returns the new emitter
  13904. */
  13905. clone(): SphereDirectedParticleEmitter;
  13906. /**
  13907. * Called by the GPUParticleSystem to setup the update shader
  13908. * @param effect defines the update shader
  13909. */
  13910. applyToShader(effect: Effect): void;
  13911. /**
  13912. * Returns a string to use to update the GPU particles update shader
  13913. * @returns a string containng the defines string
  13914. */
  13915. getEffectDefines(): string;
  13916. /**
  13917. * Returns the string "SphereDirectedParticleEmitter"
  13918. * @returns a string containing the class name
  13919. */
  13920. getClassName(): string;
  13921. /**
  13922. * Serializes the particle system to a JSON object.
  13923. * @returns the JSON object
  13924. */
  13925. serialize(): any;
  13926. /**
  13927. * Parse properties from a JSON object
  13928. * @param serializationObject defines the JSON object
  13929. */
  13930. parse(serializationObject: any): void;
  13931. }
  13932. }
  13933. declare module BABYLON {
  13934. /**
  13935. * Particle emitter emitting particles from a custom list of positions.
  13936. */
  13937. export class CustomParticleEmitter implements IParticleEmitterType {
  13938. /**
  13939. * Gets or sets the position generator that will create the inital position of each particle.
  13940. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13941. */
  13942. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13943. /**
  13944. * Gets or sets the destination generator that will create the final destination of each particle.
  13945. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13946. */
  13947. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13948. /**
  13949. * Creates a new instance CustomParticleEmitter
  13950. */
  13951. constructor();
  13952. /**
  13953. * Called by the particle System when the direction is computed for the created particle.
  13954. * @param worldMatrix is the world matrix of the particle system
  13955. * @param directionToUpdate is the direction vector to update with the result
  13956. * @param particle is the particle we are computed the direction for
  13957. * @param isLocal defines if the direction should be set in local space
  13958. */
  13959. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13960. /**
  13961. * Called by the particle System when the position is computed for the created particle.
  13962. * @param worldMatrix is the world matrix of the particle system
  13963. * @param positionToUpdate is the position vector to update with the result
  13964. * @param particle is the particle we are computed the position for
  13965. * @param isLocal defines if the position should be set in local space
  13966. */
  13967. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13968. /**
  13969. * Clones the current emitter and returns a copy of it
  13970. * @returns the new emitter
  13971. */
  13972. clone(): CustomParticleEmitter;
  13973. /**
  13974. * Called by the GPUParticleSystem to setup the update shader
  13975. * @param effect defines the update shader
  13976. */
  13977. applyToShader(effect: Effect): void;
  13978. /**
  13979. * Returns a string to use to update the GPU particles update shader
  13980. * @returns a string containng the defines string
  13981. */
  13982. getEffectDefines(): string;
  13983. /**
  13984. * Returns the string "PointParticleEmitter"
  13985. * @returns a string containing the class name
  13986. */
  13987. getClassName(): string;
  13988. /**
  13989. * Serializes the particle system to a JSON object.
  13990. * @returns the JSON object
  13991. */
  13992. serialize(): any;
  13993. /**
  13994. * Parse properties from a JSON object
  13995. * @param serializationObject defines the JSON object
  13996. */
  13997. parse(serializationObject: any): void;
  13998. }
  13999. }
  14000. declare module BABYLON {
  14001. /**
  14002. * Particle emitter emitting particles from the inside of a box.
  14003. * It emits the particles randomly between 2 given directions.
  14004. */
  14005. export class MeshParticleEmitter implements IParticleEmitterType {
  14006. private _indices;
  14007. private _positions;
  14008. private _normals;
  14009. private _storedNormal;
  14010. private _mesh;
  14011. /**
  14012. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14013. */
  14014. direction1: Vector3;
  14015. /**
  14016. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14017. */
  14018. direction2: Vector3;
  14019. /**
  14020. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14021. */
  14022. useMeshNormalsForDirection: boolean;
  14023. /** Defines the mesh to use as source */
  14024. get mesh(): Nullable<AbstractMesh>;
  14025. set mesh(value: Nullable<AbstractMesh>);
  14026. /**
  14027. * Creates a new instance MeshParticleEmitter
  14028. * @param mesh defines the mesh to use as source
  14029. */
  14030. constructor(mesh?: Nullable<AbstractMesh>);
  14031. /**
  14032. * Called by the particle System when the direction is computed for the created particle.
  14033. * @param worldMatrix is the world matrix of the particle system
  14034. * @param directionToUpdate is the direction vector to update with the result
  14035. * @param particle is the particle we are computed the direction for
  14036. * @param isLocal defines if the direction should be set in local space
  14037. */
  14038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14039. /**
  14040. * Called by the particle System when the position is computed for the created particle.
  14041. * @param worldMatrix is the world matrix of the particle system
  14042. * @param positionToUpdate is the position vector to update with the result
  14043. * @param particle is the particle we are computed the position for
  14044. * @param isLocal defines if the position should be set in local space
  14045. */
  14046. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14047. /**
  14048. * Clones the current emitter and returns a copy of it
  14049. * @returns the new emitter
  14050. */
  14051. clone(): MeshParticleEmitter;
  14052. /**
  14053. * Called by the GPUParticleSystem to setup the update shader
  14054. * @param effect defines the update shader
  14055. */
  14056. applyToShader(effect: Effect): void;
  14057. /**
  14058. * Returns a string to use to update the GPU particles update shader
  14059. * @returns a string containng the defines string
  14060. */
  14061. getEffectDefines(): string;
  14062. /**
  14063. * Returns the string "BoxParticleEmitter"
  14064. * @returns a string containing the class name
  14065. */
  14066. getClassName(): string;
  14067. /**
  14068. * Serializes the particle system to a JSON object.
  14069. * @returns the JSON object
  14070. */
  14071. serialize(): any;
  14072. /**
  14073. * Parse properties from a JSON object
  14074. * @param serializationObject defines the JSON object
  14075. * @param scene defines the hosting scene
  14076. */
  14077. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14078. }
  14079. }
  14080. declare module BABYLON {
  14081. /**
  14082. * Interface representing a particle system in Babylon.js.
  14083. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14084. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14085. */
  14086. export interface IParticleSystem {
  14087. /**
  14088. * List of animations used by the particle system.
  14089. */
  14090. animations: Animation[];
  14091. /**
  14092. * The id of the Particle system.
  14093. */
  14094. id: string;
  14095. /**
  14096. * The name of the Particle system.
  14097. */
  14098. name: string;
  14099. /**
  14100. * The emitter represents the Mesh or position we are attaching the particle system to.
  14101. */
  14102. emitter: Nullable<AbstractMesh | Vector3>;
  14103. /**
  14104. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14105. */
  14106. isBillboardBased: boolean;
  14107. /**
  14108. * The rendering group used by the Particle system to chose when to render.
  14109. */
  14110. renderingGroupId: number;
  14111. /**
  14112. * The layer mask we are rendering the particles through.
  14113. */
  14114. layerMask: number;
  14115. /**
  14116. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14117. */
  14118. updateSpeed: number;
  14119. /**
  14120. * The amount of time the particle system is running (depends of the overall update speed).
  14121. */
  14122. targetStopDuration: number;
  14123. /**
  14124. * The texture used to render each particle. (this can be a spritesheet)
  14125. */
  14126. particleTexture: Nullable<BaseTexture>;
  14127. /**
  14128. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14129. */
  14130. blendMode: number;
  14131. /**
  14132. * Minimum life time of emitting particles.
  14133. */
  14134. minLifeTime: number;
  14135. /**
  14136. * Maximum life time of emitting particles.
  14137. */
  14138. maxLifeTime: number;
  14139. /**
  14140. * Minimum Size of emitting particles.
  14141. */
  14142. minSize: number;
  14143. /**
  14144. * Maximum Size of emitting particles.
  14145. */
  14146. maxSize: number;
  14147. /**
  14148. * Minimum scale of emitting particles on X axis.
  14149. */
  14150. minScaleX: number;
  14151. /**
  14152. * Maximum scale of emitting particles on X axis.
  14153. */
  14154. maxScaleX: number;
  14155. /**
  14156. * Minimum scale of emitting particles on Y axis.
  14157. */
  14158. minScaleY: number;
  14159. /**
  14160. * Maximum scale of emitting particles on Y axis.
  14161. */
  14162. maxScaleY: number;
  14163. /**
  14164. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14165. */
  14166. color1: Color4;
  14167. /**
  14168. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14169. */
  14170. color2: Color4;
  14171. /**
  14172. * Color the particle will have at the end of its lifetime.
  14173. */
  14174. colorDead: Color4;
  14175. /**
  14176. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14177. */
  14178. emitRate: number;
  14179. /**
  14180. * You can use gravity if you want to give an orientation to your particles.
  14181. */
  14182. gravity: Vector3;
  14183. /**
  14184. * Minimum power of emitting particles.
  14185. */
  14186. minEmitPower: number;
  14187. /**
  14188. * Maximum power of emitting particles.
  14189. */
  14190. maxEmitPower: number;
  14191. /**
  14192. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14193. */
  14194. minAngularSpeed: number;
  14195. /**
  14196. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14197. */
  14198. maxAngularSpeed: number;
  14199. /**
  14200. * Gets or sets the minimal initial rotation in radians.
  14201. */
  14202. minInitialRotation: number;
  14203. /**
  14204. * Gets or sets the maximal initial rotation in radians.
  14205. */
  14206. maxInitialRotation: number;
  14207. /**
  14208. * The particle emitter type defines the emitter used by the particle system.
  14209. * It can be for example box, sphere, or cone...
  14210. */
  14211. particleEmitterType: Nullable<IParticleEmitterType>;
  14212. /**
  14213. * Defines the delay in milliseconds before starting the system (0 by default)
  14214. */
  14215. startDelay: number;
  14216. /**
  14217. * 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
  14218. */
  14219. preWarmCycles: number;
  14220. /**
  14221. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14222. */
  14223. preWarmStepOffset: number;
  14224. /**
  14225. * 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)
  14226. */
  14227. spriteCellChangeSpeed: number;
  14228. /**
  14229. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14230. */
  14231. startSpriteCellID: number;
  14232. /**
  14233. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14234. */
  14235. endSpriteCellID: number;
  14236. /**
  14237. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14238. */
  14239. spriteCellWidth: number;
  14240. /**
  14241. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14242. */
  14243. spriteCellHeight: number;
  14244. /**
  14245. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14246. */
  14247. spriteRandomStartCell: boolean;
  14248. /**
  14249. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14250. */
  14251. isAnimationSheetEnabled: boolean;
  14252. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14253. translationPivot: Vector2;
  14254. /**
  14255. * Gets or sets a texture used to add random noise to particle positions
  14256. */
  14257. noiseTexture: Nullable<BaseTexture>;
  14258. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14259. noiseStrength: Vector3;
  14260. /**
  14261. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14262. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14263. */
  14264. billboardMode: number;
  14265. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14266. limitVelocityDamping: number;
  14267. /**
  14268. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14269. */
  14270. beginAnimationOnStart: boolean;
  14271. /**
  14272. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14273. */
  14274. beginAnimationFrom: number;
  14275. /**
  14276. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14277. */
  14278. beginAnimationTo: number;
  14279. /**
  14280. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14281. */
  14282. beginAnimationLoop: boolean;
  14283. /**
  14284. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14285. */
  14286. disposeOnStop: boolean;
  14287. /**
  14288. * Specifies if the particles are updated in emitter local space or world space
  14289. */
  14290. isLocal: boolean;
  14291. /** Snippet ID if the particle system was created from the snippet server */
  14292. snippetId: string;
  14293. /** Gets or sets a matrix to use to compute projection */
  14294. defaultProjectionMatrix: Matrix;
  14295. /**
  14296. * Gets the maximum number of particles active at the same time.
  14297. * @returns The max number of active particles.
  14298. */
  14299. getCapacity(): number;
  14300. /**
  14301. * Gets the number of particles active at the same time.
  14302. * @returns The number of active particles.
  14303. */
  14304. getActiveCount(): number;
  14305. /**
  14306. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14307. * @returns True if it has been started, otherwise false.
  14308. */
  14309. isStarted(): boolean;
  14310. /**
  14311. * Animates the particle system for this frame.
  14312. */
  14313. animate(): void;
  14314. /**
  14315. * Renders the particle system in its current state.
  14316. * @returns the current number of particles
  14317. */
  14318. render(): number;
  14319. /**
  14320. * Dispose the particle system and frees its associated resources.
  14321. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14322. */
  14323. dispose(disposeTexture?: boolean): void;
  14324. /**
  14325. * An event triggered when the system is disposed
  14326. */
  14327. onDisposeObservable: Observable<IParticleSystem>;
  14328. /**
  14329. * An event triggered when the system is stopped
  14330. */
  14331. onStoppedObservable: Observable<IParticleSystem>;
  14332. /**
  14333. * Clones the particle system.
  14334. * @param name The name of the cloned object
  14335. * @param newEmitter The new emitter to use
  14336. * @returns the cloned particle system
  14337. */
  14338. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14339. /**
  14340. * Serializes the particle system to a JSON object
  14341. * @param serializeTexture defines if the texture must be serialized as well
  14342. * @returns the JSON object
  14343. */
  14344. serialize(serializeTexture: boolean): any;
  14345. /**
  14346. * Rebuild the particle system
  14347. */
  14348. rebuild(): void;
  14349. /** Force the system to rebuild all gradients that need to be resync */
  14350. forceRefreshGradients(): void;
  14351. /**
  14352. * Starts the particle system and begins to emit
  14353. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14354. */
  14355. start(delay?: number): void;
  14356. /**
  14357. * Stops the particle system.
  14358. */
  14359. stop(): void;
  14360. /**
  14361. * Remove all active particles
  14362. */
  14363. reset(): void;
  14364. /**
  14365. * Gets a boolean indicating that the system is stopping
  14366. * @returns true if the system is currently stopping
  14367. */
  14368. isStopping(): boolean;
  14369. /**
  14370. * Is this system ready to be used/rendered
  14371. * @return true if the system is ready
  14372. */
  14373. isReady(): boolean;
  14374. /**
  14375. * Returns the string "ParticleSystem"
  14376. * @returns a string containing the class name
  14377. */
  14378. getClassName(): string;
  14379. /**
  14380. * Gets the custom effect used to render the particles
  14381. * @param blendMode Blend mode for which the effect should be retrieved
  14382. * @returns The effect
  14383. */
  14384. getCustomEffect(blendMode: number): Nullable<Effect>;
  14385. /**
  14386. * Sets the custom effect used to render the particles
  14387. * @param effect The effect to set
  14388. * @param blendMode Blend mode for which the effect should be set
  14389. */
  14390. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14391. /**
  14392. * Fill the defines array according to the current settings of the particle system
  14393. * @param defines Array to be updated
  14394. * @param blendMode blend mode to take into account when updating the array
  14395. */
  14396. fillDefines(defines: Array<string>, blendMode: number): void;
  14397. /**
  14398. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14399. * @param uniforms Uniforms array to fill
  14400. * @param attributes Attributes array to fill
  14401. * @param samplers Samplers array to fill
  14402. */
  14403. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14404. /**
  14405. * Observable that will be called just before the particles are drawn
  14406. */
  14407. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14408. /**
  14409. * Gets the name of the particle vertex shader
  14410. */
  14411. vertexShaderName: string;
  14412. /**
  14413. * Adds a new color gradient
  14414. * @param gradient defines the gradient to use (between 0 and 1)
  14415. * @param color1 defines the color to affect to the specified gradient
  14416. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14417. * @returns the current particle system
  14418. */
  14419. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14420. /**
  14421. * Remove a specific color gradient
  14422. * @param gradient defines the gradient to remove
  14423. * @returns the current particle system
  14424. */
  14425. removeColorGradient(gradient: number): IParticleSystem;
  14426. /**
  14427. * Adds a new size gradient
  14428. * @param gradient defines the gradient to use (between 0 and 1)
  14429. * @param factor defines the size factor to affect to the specified gradient
  14430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14431. * @returns the current particle system
  14432. */
  14433. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14434. /**
  14435. * Remove a specific size gradient
  14436. * @param gradient defines the gradient to remove
  14437. * @returns the current particle system
  14438. */
  14439. removeSizeGradient(gradient: number): IParticleSystem;
  14440. /**
  14441. * Gets the current list of color gradients.
  14442. * You must use addColorGradient and removeColorGradient to udpate this list
  14443. * @returns the list of color gradients
  14444. */
  14445. getColorGradients(): Nullable<Array<ColorGradient>>;
  14446. /**
  14447. * Gets the current list of size gradients.
  14448. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14449. * @returns the list of size gradients
  14450. */
  14451. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14452. /**
  14453. * Gets the current list of angular speed gradients.
  14454. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14455. * @returns the list of angular speed gradients
  14456. */
  14457. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14458. /**
  14459. * Adds a new angular speed gradient
  14460. * @param gradient defines the gradient to use (between 0 and 1)
  14461. * @param factor defines the angular speed to affect to the specified gradient
  14462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14463. * @returns the current particle system
  14464. */
  14465. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14466. /**
  14467. * Remove a specific angular speed gradient
  14468. * @param gradient defines the gradient to remove
  14469. * @returns the current particle system
  14470. */
  14471. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14472. /**
  14473. * Gets the current list of velocity gradients.
  14474. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14475. * @returns the list of velocity gradients
  14476. */
  14477. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14478. /**
  14479. * Adds a new velocity gradient
  14480. * @param gradient defines the gradient to use (between 0 and 1)
  14481. * @param factor defines the velocity to affect to the specified gradient
  14482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14483. * @returns the current particle system
  14484. */
  14485. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14486. /**
  14487. * Remove a specific velocity gradient
  14488. * @param gradient defines the gradient to remove
  14489. * @returns the current particle system
  14490. */
  14491. removeVelocityGradient(gradient: number): IParticleSystem;
  14492. /**
  14493. * Gets the current list of limit velocity gradients.
  14494. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14495. * @returns the list of limit velocity gradients
  14496. */
  14497. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14498. /**
  14499. * Adds a new limit velocity gradient
  14500. * @param gradient defines the gradient to use (between 0 and 1)
  14501. * @param factor defines the limit velocity to affect to the specified gradient
  14502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14503. * @returns the current particle system
  14504. */
  14505. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14506. /**
  14507. * Remove a specific limit velocity gradient
  14508. * @param gradient defines the gradient to remove
  14509. * @returns the current particle system
  14510. */
  14511. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14512. /**
  14513. * Adds a new drag gradient
  14514. * @param gradient defines the gradient to use (between 0 and 1)
  14515. * @param factor defines the drag to affect to the specified gradient
  14516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14517. * @returns the current particle system
  14518. */
  14519. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14520. /**
  14521. * Remove a specific drag gradient
  14522. * @param gradient defines the gradient to remove
  14523. * @returns the current particle system
  14524. */
  14525. removeDragGradient(gradient: number): IParticleSystem;
  14526. /**
  14527. * Gets the current list of drag gradients.
  14528. * You must use addDragGradient and removeDragGradient to udpate this list
  14529. * @returns the list of drag gradients
  14530. */
  14531. getDragGradients(): Nullable<Array<FactorGradient>>;
  14532. /**
  14533. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14534. * @param gradient defines the gradient to use (between 0 and 1)
  14535. * @param factor defines the emit rate to affect to the specified gradient
  14536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14537. * @returns the current particle system
  14538. */
  14539. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14540. /**
  14541. * Remove a specific emit rate gradient
  14542. * @param gradient defines the gradient to remove
  14543. * @returns the current particle system
  14544. */
  14545. removeEmitRateGradient(gradient: number): IParticleSystem;
  14546. /**
  14547. * Gets the current list of emit rate gradients.
  14548. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14549. * @returns the list of emit rate gradients
  14550. */
  14551. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14552. /**
  14553. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14554. * @param gradient defines the gradient to use (between 0 and 1)
  14555. * @param factor defines the start size to affect to the specified gradient
  14556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14557. * @returns the current particle system
  14558. */
  14559. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14560. /**
  14561. * Remove a specific start size gradient
  14562. * @param gradient defines the gradient to remove
  14563. * @returns the current particle system
  14564. */
  14565. removeStartSizeGradient(gradient: number): IParticleSystem;
  14566. /**
  14567. * Gets the current list of start size gradients.
  14568. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14569. * @returns the list of start size gradients
  14570. */
  14571. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14572. /**
  14573. * Adds a new life time gradient
  14574. * @param gradient defines the gradient to use (between 0 and 1)
  14575. * @param factor defines the life time factor to affect to the specified gradient
  14576. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14577. * @returns the current particle system
  14578. */
  14579. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14580. /**
  14581. * Remove a specific life time gradient
  14582. * @param gradient defines the gradient to remove
  14583. * @returns the current particle system
  14584. */
  14585. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14586. /**
  14587. * Gets the current list of life time gradients.
  14588. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14589. * @returns the list of life time gradients
  14590. */
  14591. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14592. /**
  14593. * Gets the current list of color gradients.
  14594. * You must use addColorGradient and removeColorGradient to udpate this list
  14595. * @returns the list of color gradients
  14596. */
  14597. getColorGradients(): Nullable<Array<ColorGradient>>;
  14598. /**
  14599. * Adds a new ramp gradient used to remap particle colors
  14600. * @param gradient defines the gradient to use (between 0 and 1)
  14601. * @param color defines the color to affect to the specified gradient
  14602. * @returns the current particle system
  14603. */
  14604. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14605. /**
  14606. * Gets the current list of ramp gradients.
  14607. * You must use addRampGradient and removeRampGradient to udpate this list
  14608. * @returns the list of ramp gradients
  14609. */
  14610. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14611. /** Gets or sets a boolean indicating that ramp gradients must be used
  14612. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14613. */
  14614. useRampGradients: boolean;
  14615. /**
  14616. * Adds a new color remap gradient
  14617. * @param gradient defines the gradient to use (between 0 and 1)
  14618. * @param min defines the color remap minimal range
  14619. * @param max defines the color remap maximal range
  14620. * @returns the current particle system
  14621. */
  14622. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14623. /**
  14624. * Gets the current list of color remap gradients.
  14625. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14626. * @returns the list of color remap gradients
  14627. */
  14628. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14629. /**
  14630. * Adds a new alpha remap gradient
  14631. * @param gradient defines the gradient to use (between 0 and 1)
  14632. * @param min defines the alpha remap minimal range
  14633. * @param max defines the alpha remap maximal range
  14634. * @returns the current particle system
  14635. */
  14636. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14637. /**
  14638. * Gets the current list of alpha remap gradients.
  14639. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14640. * @returns the list of alpha remap gradients
  14641. */
  14642. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14643. /**
  14644. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14645. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14646. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14647. * @returns the emitter
  14648. */
  14649. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14650. /**
  14651. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14652. * @param radius The radius of the hemisphere to emit from
  14653. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14654. * @returns the emitter
  14655. */
  14656. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14657. /**
  14658. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14659. * @param radius The radius of the sphere to emit from
  14660. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14661. * @returns the emitter
  14662. */
  14663. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14664. /**
  14665. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14666. * @param radius The radius of the sphere to emit from
  14667. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14668. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14669. * @returns the emitter
  14670. */
  14671. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14672. /**
  14673. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14674. * @param radius The radius of the emission cylinder
  14675. * @param height The height of the emission cylinder
  14676. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14677. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14678. * @returns the emitter
  14679. */
  14680. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14681. /**
  14682. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14683. * @param radius The radius of the cylinder to emit from
  14684. * @param height The height of the emission cylinder
  14685. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14686. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14687. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14688. * @returns the emitter
  14689. */
  14690. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14691. /**
  14692. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14693. * @param radius The radius of the cone to emit from
  14694. * @param angle The base angle of the cone
  14695. * @returns the emitter
  14696. */
  14697. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14698. /**
  14699. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14700. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14701. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14702. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14703. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14704. * @returns the emitter
  14705. */
  14706. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14707. /**
  14708. * Get hosting scene
  14709. * @returns the scene
  14710. */
  14711. getScene(): Nullable<Scene>;
  14712. }
  14713. }
  14714. declare module BABYLON {
  14715. /**
  14716. * 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.
  14717. * @see https://doc.babylonjs.com/how_to/transformnode
  14718. */
  14719. export class TransformNode extends Node {
  14720. /**
  14721. * Object will not rotate to face the camera
  14722. */
  14723. static BILLBOARDMODE_NONE: number;
  14724. /**
  14725. * Object will rotate to face the camera but only on the x axis
  14726. */
  14727. static BILLBOARDMODE_X: number;
  14728. /**
  14729. * Object will rotate to face the camera but only on the y axis
  14730. */
  14731. static BILLBOARDMODE_Y: number;
  14732. /**
  14733. * Object will rotate to face the camera but only on the z axis
  14734. */
  14735. static BILLBOARDMODE_Z: number;
  14736. /**
  14737. * Object will rotate to face the camera
  14738. */
  14739. static BILLBOARDMODE_ALL: number;
  14740. /**
  14741. * Object will rotate to face the camera's position instead of orientation
  14742. */
  14743. static BILLBOARDMODE_USE_POSITION: number;
  14744. private static _TmpRotation;
  14745. private static _TmpScaling;
  14746. private static _TmpTranslation;
  14747. private _forward;
  14748. private _forwardInverted;
  14749. private _up;
  14750. private _right;
  14751. private _rightInverted;
  14752. private _position;
  14753. private _rotation;
  14754. private _rotationQuaternion;
  14755. protected _scaling: Vector3;
  14756. protected _isDirty: boolean;
  14757. private _transformToBoneReferal;
  14758. private _isAbsoluteSynced;
  14759. private _billboardMode;
  14760. /**
  14761. * Gets or sets the billboard mode. Default is 0.
  14762. *
  14763. * | Value | Type | Description |
  14764. * | --- | --- | --- |
  14765. * | 0 | BILLBOARDMODE_NONE | |
  14766. * | 1 | BILLBOARDMODE_X | |
  14767. * | 2 | BILLBOARDMODE_Y | |
  14768. * | 4 | BILLBOARDMODE_Z | |
  14769. * | 7 | BILLBOARDMODE_ALL | |
  14770. *
  14771. */
  14772. get billboardMode(): number;
  14773. set billboardMode(value: number);
  14774. private _preserveParentRotationForBillboard;
  14775. /**
  14776. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14777. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14778. */
  14779. get preserveParentRotationForBillboard(): boolean;
  14780. set preserveParentRotationForBillboard(value: boolean);
  14781. /**
  14782. * 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
  14783. */
  14784. scalingDeterminant: number;
  14785. private _infiniteDistance;
  14786. /**
  14787. * Gets or sets the distance of the object to max, often used by skybox
  14788. */
  14789. get infiniteDistance(): boolean;
  14790. set infiniteDistance(value: boolean);
  14791. /**
  14792. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14793. * By default the system will update normals to compensate
  14794. */
  14795. ignoreNonUniformScaling: boolean;
  14796. /**
  14797. * 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
  14798. */
  14799. reIntegrateRotationIntoRotationQuaternion: boolean;
  14800. /** @hidden */
  14801. _poseMatrix: Nullable<Matrix>;
  14802. /** @hidden */
  14803. _localMatrix: Matrix;
  14804. private _usePivotMatrix;
  14805. private _absolutePosition;
  14806. private _absoluteScaling;
  14807. private _absoluteRotationQuaternion;
  14808. private _pivotMatrix;
  14809. private _pivotMatrixInverse;
  14810. /** @hidden */
  14811. _postMultiplyPivotMatrix: boolean;
  14812. protected _isWorldMatrixFrozen: boolean;
  14813. /** @hidden */
  14814. _indexInSceneTransformNodesArray: number;
  14815. /**
  14816. * An event triggered after the world matrix is updated
  14817. */
  14818. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14819. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14820. /**
  14821. * Gets a string identifying the name of the class
  14822. * @returns "TransformNode" string
  14823. */
  14824. getClassName(): string;
  14825. /**
  14826. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14827. */
  14828. get position(): Vector3;
  14829. set position(newPosition: Vector3);
  14830. /**
  14831. * 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)).
  14832. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14833. */
  14834. get rotation(): Vector3;
  14835. set rotation(newRotation: Vector3);
  14836. /**
  14837. * 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)).
  14838. */
  14839. get scaling(): Vector3;
  14840. set scaling(newScaling: Vector3);
  14841. /**
  14842. * 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).
  14843. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14844. */
  14845. get rotationQuaternion(): Nullable<Quaternion>;
  14846. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14847. /**
  14848. * The forward direction of that transform in world space.
  14849. */
  14850. get forward(): Vector3;
  14851. /**
  14852. * The up direction of that transform in world space.
  14853. */
  14854. get up(): Vector3;
  14855. /**
  14856. * The right direction of that transform in world space.
  14857. */
  14858. get right(): Vector3;
  14859. /**
  14860. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14861. * @param matrix the matrix to copy the pose from
  14862. * @returns this TransformNode.
  14863. */
  14864. updatePoseMatrix(matrix: Matrix): TransformNode;
  14865. /**
  14866. * Returns the mesh Pose matrix.
  14867. * @returns the pose matrix
  14868. */
  14869. getPoseMatrix(): Matrix;
  14870. /** @hidden */
  14871. _isSynchronized(): boolean;
  14872. /** @hidden */
  14873. _initCache(): void;
  14874. /**
  14875. * Flag the transform node as dirty (Forcing it to update everything)
  14876. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14877. * @returns this transform node
  14878. */
  14879. markAsDirty(property: string): TransformNode;
  14880. /**
  14881. * Returns the current mesh absolute position.
  14882. * Returns a Vector3.
  14883. */
  14884. get absolutePosition(): Vector3;
  14885. /**
  14886. * Returns the current mesh absolute scaling.
  14887. * Returns a Vector3.
  14888. */
  14889. get absoluteScaling(): Vector3;
  14890. /**
  14891. * Returns the current mesh absolute rotation.
  14892. * Returns a Quaternion.
  14893. */
  14894. get absoluteRotationQuaternion(): Quaternion;
  14895. /**
  14896. * Sets a new matrix to apply before all other transformation
  14897. * @param matrix defines the transform matrix
  14898. * @returns the current TransformNode
  14899. */
  14900. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14901. /**
  14902. * Sets a new pivot matrix to the current node
  14903. * @param matrix defines the new pivot matrix to use
  14904. * @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
  14905. * @returns the current TransformNode
  14906. */
  14907. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14908. /**
  14909. * Returns the mesh pivot matrix.
  14910. * Default : Identity.
  14911. * @returns the matrix
  14912. */
  14913. getPivotMatrix(): Matrix;
  14914. /**
  14915. * Instantiate (when possible) or clone that node with its hierarchy
  14916. * @param newParent defines the new parent to use for the instance (or clone)
  14917. * @param options defines options to configure how copy is done
  14918. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14919. * @returns an instance (or a clone) of the current node with its hiearchy
  14920. */
  14921. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14922. doNotInstantiate: boolean;
  14923. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14924. /**
  14925. * Prevents the World matrix to be computed any longer
  14926. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14927. * @returns the TransformNode.
  14928. */
  14929. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14930. /**
  14931. * Allows back the World matrix computation.
  14932. * @returns the TransformNode.
  14933. */
  14934. unfreezeWorldMatrix(): this;
  14935. /**
  14936. * True if the World matrix has been frozen.
  14937. */
  14938. get isWorldMatrixFrozen(): boolean;
  14939. /**
  14940. * Retuns the mesh absolute position in the World.
  14941. * @returns a Vector3.
  14942. */
  14943. getAbsolutePosition(): Vector3;
  14944. /**
  14945. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14946. * @param absolutePosition the absolute position to set
  14947. * @returns the TransformNode.
  14948. */
  14949. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14950. /**
  14951. * Sets the mesh position in its local space.
  14952. * @param vector3 the position to set in localspace
  14953. * @returns the TransformNode.
  14954. */
  14955. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14956. /**
  14957. * Returns the mesh position in the local space from the current World matrix values.
  14958. * @returns a new Vector3.
  14959. */
  14960. getPositionExpressedInLocalSpace(): Vector3;
  14961. /**
  14962. * Translates the mesh along the passed Vector3 in its local space.
  14963. * @param vector3 the distance to translate in localspace
  14964. * @returns the TransformNode.
  14965. */
  14966. locallyTranslate(vector3: Vector3): TransformNode;
  14967. private static _lookAtVectorCache;
  14968. /**
  14969. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14970. * @param targetPoint the position (must be in same space as current mesh) to look at
  14971. * @param yawCor optional yaw (y-axis) correction in radians
  14972. * @param pitchCor optional pitch (x-axis) correction in radians
  14973. * @param rollCor optional roll (z-axis) correction in radians
  14974. * @param space the choosen space of the target
  14975. * @returns the TransformNode.
  14976. */
  14977. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14978. /**
  14979. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14980. * This Vector3 is expressed in the World space.
  14981. * @param localAxis axis to rotate
  14982. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14983. */
  14984. getDirection(localAxis: Vector3): Vector3;
  14985. /**
  14986. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14987. * localAxis is expressed in the mesh local space.
  14988. * result is computed in the Wordl space from the mesh World matrix.
  14989. * @param localAxis axis to rotate
  14990. * @param result the resulting transformnode
  14991. * @returns this TransformNode.
  14992. */
  14993. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14994. /**
  14995. * Sets this transform node rotation to the given local axis.
  14996. * @param localAxis the axis in local space
  14997. * @param yawCor optional yaw (y-axis) correction in radians
  14998. * @param pitchCor optional pitch (x-axis) correction in radians
  14999. * @param rollCor optional roll (z-axis) correction in radians
  15000. * @returns this TransformNode
  15001. */
  15002. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15003. /**
  15004. * Sets a new pivot point to the current node
  15005. * @param point defines the new pivot point to use
  15006. * @param space defines if the point is in world or local space (local by default)
  15007. * @returns the current TransformNode
  15008. */
  15009. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15010. /**
  15011. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15012. * @returns the pivot point
  15013. */
  15014. getPivotPoint(): Vector3;
  15015. /**
  15016. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15017. * @param result the vector3 to store the result
  15018. * @returns this TransformNode.
  15019. */
  15020. getPivotPointToRef(result: Vector3): TransformNode;
  15021. /**
  15022. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15023. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15024. */
  15025. getAbsolutePivotPoint(): Vector3;
  15026. /**
  15027. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15028. * @param result vector3 to store the result
  15029. * @returns this TransformNode.
  15030. */
  15031. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15032. /**
  15033. * Defines the passed node as the parent of the current node.
  15034. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15035. * @see https://doc.babylonjs.com/how_to/parenting
  15036. * @param node the node ot set as the parent
  15037. * @returns this TransformNode.
  15038. */
  15039. setParent(node: Nullable<Node>): TransformNode;
  15040. private _nonUniformScaling;
  15041. /**
  15042. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15043. */
  15044. get nonUniformScaling(): boolean;
  15045. /** @hidden */
  15046. _updateNonUniformScalingState(value: boolean): boolean;
  15047. /**
  15048. * Attach the current TransformNode to another TransformNode associated with a bone
  15049. * @param bone Bone affecting the TransformNode
  15050. * @param affectedTransformNode TransformNode associated with the bone
  15051. * @returns this object
  15052. */
  15053. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15054. /**
  15055. * Detach the transform node if its associated with a bone
  15056. * @returns this object
  15057. */
  15058. detachFromBone(): TransformNode;
  15059. private static _rotationAxisCache;
  15060. /**
  15061. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15062. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15063. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15064. * The passed axis is also normalized.
  15065. * @param axis the axis to rotate around
  15066. * @param amount the amount to rotate in radians
  15067. * @param space Space to rotate in (Default: local)
  15068. * @returns the TransformNode.
  15069. */
  15070. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15071. /**
  15072. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15073. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15074. * The passed axis is also normalized. .
  15075. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15076. * @param point the point to rotate around
  15077. * @param axis the axis to rotate around
  15078. * @param amount the amount to rotate in radians
  15079. * @returns the TransformNode
  15080. */
  15081. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15082. /**
  15083. * Translates the mesh along the axis vector for the passed distance in the given space.
  15084. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15085. * @param axis the axis to translate in
  15086. * @param distance the distance to translate
  15087. * @param space Space to rotate in (Default: local)
  15088. * @returns the TransformNode.
  15089. */
  15090. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15091. /**
  15092. * Adds a rotation step to the mesh current rotation.
  15093. * x, y, z are Euler angles expressed in radians.
  15094. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15095. * This means this rotation is made in the mesh local space only.
  15096. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15097. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15098. * ```javascript
  15099. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15100. * ```
  15101. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15102. * 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.
  15103. * @param x Rotation to add
  15104. * @param y Rotation to add
  15105. * @param z Rotation to add
  15106. * @returns the TransformNode.
  15107. */
  15108. addRotation(x: number, y: number, z: number): TransformNode;
  15109. /**
  15110. * @hidden
  15111. */
  15112. protected _getEffectiveParent(): Nullable<Node>;
  15113. /**
  15114. * Computes the world matrix of the node
  15115. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15116. * @returns the world matrix
  15117. */
  15118. computeWorldMatrix(force?: boolean): Matrix;
  15119. /**
  15120. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15121. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15122. */
  15123. resetLocalMatrix(independentOfChildren?: boolean): void;
  15124. protected _afterComputeWorldMatrix(): void;
  15125. /**
  15126. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15127. * @param func callback function to add
  15128. *
  15129. * @returns the TransformNode.
  15130. */
  15131. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15132. /**
  15133. * Removes a registered callback function.
  15134. * @param func callback function to remove
  15135. * @returns the TransformNode.
  15136. */
  15137. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15138. /**
  15139. * Gets the position of the current mesh in camera space
  15140. * @param camera defines the camera to use
  15141. * @returns a position
  15142. */
  15143. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15144. /**
  15145. * Returns the distance from the mesh to the active camera
  15146. * @param camera defines the camera to use
  15147. * @returns the distance
  15148. */
  15149. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15150. /**
  15151. * Clone the current transform node
  15152. * @param name Name of the new clone
  15153. * @param newParent New parent for the clone
  15154. * @param doNotCloneChildren Do not clone children hierarchy
  15155. * @returns the new transform node
  15156. */
  15157. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15158. /**
  15159. * Serializes the objects information.
  15160. * @param currentSerializationObject defines the object to serialize in
  15161. * @returns the serialized object
  15162. */
  15163. serialize(currentSerializationObject?: any): any;
  15164. /**
  15165. * Returns a new TransformNode object parsed from the source provided.
  15166. * @param parsedTransformNode is the source.
  15167. * @param scene the scne the object belongs to
  15168. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15169. * @returns a new TransformNode object parsed from the source provided.
  15170. */
  15171. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15172. /**
  15173. * Get all child-transformNodes of this node
  15174. * @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
  15175. * @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
  15176. * @returns an array of TransformNode
  15177. */
  15178. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15179. /**
  15180. * Releases resources associated with this transform node.
  15181. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15182. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15183. */
  15184. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15185. /**
  15186. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15187. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15188. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15189. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15190. * @returns the current mesh
  15191. */
  15192. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15193. private _syncAbsoluteScalingAndRotation;
  15194. }
  15195. }
  15196. declare module BABYLON {
  15197. /**
  15198. * Class used to override all child animations of a given target
  15199. */
  15200. export class AnimationPropertiesOverride {
  15201. /**
  15202. * Gets or sets a value indicating if animation blending must be used
  15203. */
  15204. enableBlending: boolean;
  15205. /**
  15206. * Gets or sets the blending speed to use when enableBlending is true
  15207. */
  15208. blendingSpeed: number;
  15209. /**
  15210. * Gets or sets the default loop mode to use
  15211. */
  15212. loopMode: number;
  15213. }
  15214. }
  15215. declare module BABYLON {
  15216. /**
  15217. * Class used to store bone information
  15218. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15219. */
  15220. export class Bone extends Node {
  15221. /**
  15222. * defines the bone name
  15223. */
  15224. name: string;
  15225. private static _tmpVecs;
  15226. private static _tmpQuat;
  15227. private static _tmpMats;
  15228. /**
  15229. * Gets the list of child bones
  15230. */
  15231. children: Bone[];
  15232. /** Gets the animations associated with this bone */
  15233. animations: Animation[];
  15234. /**
  15235. * Gets or sets bone length
  15236. */
  15237. length: number;
  15238. /**
  15239. * @hidden Internal only
  15240. * Set this value to map this bone to a different index in the transform matrices
  15241. * Set this value to -1 to exclude the bone from the transform matrices
  15242. */
  15243. _index: Nullable<number>;
  15244. private _skeleton;
  15245. private _localMatrix;
  15246. private _restPose;
  15247. private _bindPose;
  15248. private _baseMatrix;
  15249. private _absoluteTransform;
  15250. private _invertedAbsoluteTransform;
  15251. private _parent;
  15252. private _scalingDeterminant;
  15253. private _worldTransform;
  15254. private _localScaling;
  15255. private _localRotation;
  15256. private _localPosition;
  15257. private _needToDecompose;
  15258. private _needToCompose;
  15259. /** @hidden */
  15260. _linkedTransformNode: Nullable<TransformNode>;
  15261. /** @hidden */
  15262. _waitingTransformNodeId: Nullable<string>;
  15263. /** @hidden */
  15264. get _matrix(): Matrix;
  15265. /** @hidden */
  15266. set _matrix(value: Matrix);
  15267. /**
  15268. * Create a new bone
  15269. * @param name defines the bone name
  15270. * @param skeleton defines the parent skeleton
  15271. * @param parentBone defines the parent (can be null if the bone is the root)
  15272. * @param localMatrix defines the local matrix
  15273. * @param restPose defines the rest pose matrix
  15274. * @param baseMatrix defines the base matrix
  15275. * @param index defines index of the bone in the hiearchy
  15276. */
  15277. constructor(
  15278. /**
  15279. * defines the bone name
  15280. */
  15281. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15282. /**
  15283. * Gets the current object class name.
  15284. * @return the class name
  15285. */
  15286. getClassName(): string;
  15287. /**
  15288. * Gets the parent skeleton
  15289. * @returns a skeleton
  15290. */
  15291. getSkeleton(): Skeleton;
  15292. /**
  15293. * Gets parent bone
  15294. * @returns a bone or null if the bone is the root of the bone hierarchy
  15295. */
  15296. getParent(): Nullable<Bone>;
  15297. /**
  15298. * Returns an array containing the root bones
  15299. * @returns an array containing the root bones
  15300. */
  15301. getChildren(): Array<Bone>;
  15302. /**
  15303. * Gets the node index in matrix array generated for rendering
  15304. * @returns the node index
  15305. */
  15306. getIndex(): number;
  15307. /**
  15308. * Sets the parent bone
  15309. * @param parent defines the parent (can be null if the bone is the root)
  15310. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15311. */
  15312. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15313. /**
  15314. * Gets the local matrix
  15315. * @returns a matrix
  15316. */
  15317. getLocalMatrix(): Matrix;
  15318. /**
  15319. * Gets the base matrix (initial matrix which remains unchanged)
  15320. * @returns a matrix
  15321. */
  15322. getBaseMatrix(): Matrix;
  15323. /**
  15324. * Gets the rest pose matrix
  15325. * @returns a matrix
  15326. */
  15327. getRestPose(): Matrix;
  15328. /**
  15329. * Sets the rest pose matrix
  15330. * @param matrix the local-space rest pose to set for this bone
  15331. */
  15332. setRestPose(matrix: Matrix): void;
  15333. /**
  15334. * Gets the bind pose matrix
  15335. * @returns the bind pose matrix
  15336. */
  15337. getBindPose(): Matrix;
  15338. /**
  15339. * Sets the bind pose matrix
  15340. * @param matrix the local-space bind pose to set for this bone
  15341. */
  15342. setBindPose(matrix: Matrix): void;
  15343. /**
  15344. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15345. */
  15346. getWorldMatrix(): Matrix;
  15347. /**
  15348. * Sets the local matrix to rest pose matrix
  15349. */
  15350. returnToRest(): void;
  15351. /**
  15352. * Gets the inverse of the absolute transform matrix.
  15353. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15354. * @returns a matrix
  15355. */
  15356. getInvertedAbsoluteTransform(): Matrix;
  15357. /**
  15358. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15359. * @returns a matrix
  15360. */
  15361. getAbsoluteTransform(): Matrix;
  15362. /**
  15363. * Links with the given transform node.
  15364. * The local matrix of this bone is copied from the transform node every frame.
  15365. * @param transformNode defines the transform node to link to
  15366. */
  15367. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15368. /**
  15369. * Gets the node used to drive the bone's transformation
  15370. * @returns a transform node or null
  15371. */
  15372. getTransformNode(): Nullable<TransformNode>;
  15373. /** Gets or sets current position (in local space) */
  15374. get position(): Vector3;
  15375. set position(newPosition: Vector3);
  15376. /** Gets or sets current rotation (in local space) */
  15377. get rotation(): Vector3;
  15378. set rotation(newRotation: Vector3);
  15379. /** Gets or sets current rotation quaternion (in local space) */
  15380. get rotationQuaternion(): Quaternion;
  15381. set rotationQuaternion(newRotation: Quaternion);
  15382. /** Gets or sets current scaling (in local space) */
  15383. get scaling(): Vector3;
  15384. set scaling(newScaling: Vector3);
  15385. /**
  15386. * Gets the animation properties override
  15387. */
  15388. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15389. private _decompose;
  15390. private _compose;
  15391. /**
  15392. * Update the base and local matrices
  15393. * @param matrix defines the new base or local matrix
  15394. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15395. * @param updateLocalMatrix defines if the local matrix should be updated
  15396. */
  15397. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15398. /** @hidden */
  15399. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15400. /**
  15401. * Flag the bone as dirty (Forcing it to update everything)
  15402. */
  15403. markAsDirty(): void;
  15404. /** @hidden */
  15405. _markAsDirtyAndCompose(): void;
  15406. private _markAsDirtyAndDecompose;
  15407. /**
  15408. * Translate the bone in local or world space
  15409. * @param vec The amount to translate the bone
  15410. * @param space The space that the translation is in
  15411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15412. */
  15413. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15414. /**
  15415. * Set the postion of the bone in local or world space
  15416. * @param position The position to set the bone
  15417. * @param space The space that the position is in
  15418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15419. */
  15420. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15421. /**
  15422. * Set the absolute position of the bone (world space)
  15423. * @param position The position to set the bone
  15424. * @param mesh The mesh that this bone is attached to
  15425. */
  15426. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15427. /**
  15428. * Scale the bone on the x, y and z axes (in local space)
  15429. * @param x The amount to scale the bone on the x axis
  15430. * @param y The amount to scale the bone on the y axis
  15431. * @param z The amount to scale the bone on the z axis
  15432. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15433. */
  15434. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15435. /**
  15436. * Set the bone scaling in local space
  15437. * @param scale defines the scaling vector
  15438. */
  15439. setScale(scale: Vector3): void;
  15440. /**
  15441. * Gets the current scaling in local space
  15442. * @returns the current scaling vector
  15443. */
  15444. getScale(): Vector3;
  15445. /**
  15446. * Gets the current scaling in local space and stores it in a target vector
  15447. * @param result defines the target vector
  15448. */
  15449. getScaleToRef(result: Vector3): void;
  15450. /**
  15451. * Set the yaw, pitch, and roll of the bone in local or world space
  15452. * @param yaw The rotation of the bone on the y axis
  15453. * @param pitch The rotation of the bone on the x axis
  15454. * @param roll The rotation of the bone on the z axis
  15455. * @param space The space that the axes of rotation are in
  15456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15457. */
  15458. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15459. /**
  15460. * Add a rotation to the bone on an axis in local or world space
  15461. * @param axis The axis to rotate the bone on
  15462. * @param amount The amount to rotate the bone
  15463. * @param space The space that the axis is in
  15464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15465. */
  15466. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15467. /**
  15468. * Set the rotation of the bone to a particular axis angle in local or world space
  15469. * @param axis The axis to rotate the bone on
  15470. * @param angle The angle that the bone should be rotated to
  15471. * @param space The space that the axis is in
  15472. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15473. */
  15474. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15475. /**
  15476. * Set the euler rotation of the bone in local or world space
  15477. * @param rotation The euler rotation that the bone should be set to
  15478. * @param space The space that the rotation is in
  15479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15480. */
  15481. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15482. /**
  15483. * Set the quaternion rotation of the bone in local or world space
  15484. * @param quat The quaternion rotation that the bone should be set to
  15485. * @param space The space that the rotation is in
  15486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15487. */
  15488. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15489. /**
  15490. * Set the rotation matrix of the bone in local or world space
  15491. * @param rotMat The rotation matrix that the bone should be set to
  15492. * @param space The space that the rotation is in
  15493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15494. */
  15495. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15496. private _rotateWithMatrix;
  15497. private _getNegativeRotationToRef;
  15498. /**
  15499. * Get the position of the bone in local or world space
  15500. * @param space The space that the returned position is in
  15501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15502. * @returns The position of the bone
  15503. */
  15504. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15505. /**
  15506. * Copy the position of the bone to a vector3 in local or world space
  15507. * @param space The space that the returned position is in
  15508. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15509. * @param result The vector3 to copy the position to
  15510. */
  15511. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15512. /**
  15513. * Get the absolute position of the bone (world space)
  15514. * @param mesh The mesh that this bone is attached to
  15515. * @returns The absolute position of the bone
  15516. */
  15517. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15518. /**
  15519. * Copy the absolute position of the bone (world space) to the result param
  15520. * @param mesh The mesh that this bone is attached to
  15521. * @param result The vector3 to copy the absolute position to
  15522. */
  15523. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15524. /**
  15525. * Compute the absolute transforms of this bone and its children
  15526. */
  15527. computeAbsoluteTransforms(): void;
  15528. /**
  15529. * Get the world direction from an axis that is in the local space of the bone
  15530. * @param localAxis The local direction that is used to compute the world direction
  15531. * @param mesh The mesh that this bone is attached to
  15532. * @returns The world direction
  15533. */
  15534. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15535. /**
  15536. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15537. * @param localAxis The local direction that is used to compute the world direction
  15538. * @param mesh The mesh that this bone is attached to
  15539. * @param result The vector3 that the world direction will be copied to
  15540. */
  15541. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15542. /**
  15543. * Get the euler rotation of the bone in local or world space
  15544. * @param space The space that the rotation should be in
  15545. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15546. * @returns The euler rotation
  15547. */
  15548. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15549. /**
  15550. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15551. * @param space The space that the rotation should be in
  15552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15553. * @param result The vector3 that the rotation should be copied to
  15554. */
  15555. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15556. /**
  15557. * Get the quaternion rotation of the bone in either local or world space
  15558. * @param space The space that the rotation should be in
  15559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15560. * @returns The quaternion rotation
  15561. */
  15562. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15563. /**
  15564. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15565. * @param space The space that the rotation should be in
  15566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15567. * @param result The quaternion that the rotation should be copied to
  15568. */
  15569. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15570. /**
  15571. * Get the rotation matrix of the bone in local or world space
  15572. * @param space The space that the rotation should be in
  15573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15574. * @returns The rotation matrix
  15575. */
  15576. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15577. /**
  15578. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15579. * @param space The space that the rotation should be in
  15580. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15581. * @param result The quaternion that the rotation should be copied to
  15582. */
  15583. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15584. /**
  15585. * Get the world position of a point that is in the local space of the bone
  15586. * @param position The local position
  15587. * @param mesh The mesh that this bone is attached to
  15588. * @returns The world position
  15589. */
  15590. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15591. /**
  15592. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15593. * @param position The local position
  15594. * @param mesh The mesh that this bone is attached to
  15595. * @param result The vector3 that the world position should be copied to
  15596. */
  15597. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15598. /**
  15599. * Get the local position of a point that is in world space
  15600. * @param position The world position
  15601. * @param mesh The mesh that this bone is attached to
  15602. * @returns The local position
  15603. */
  15604. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15605. /**
  15606. * Get the local position of a point that is in world space and copy it to the result param
  15607. * @param position The world position
  15608. * @param mesh The mesh that this bone is attached to
  15609. * @param result The vector3 that the local position should be copied to
  15610. */
  15611. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15612. /**
  15613. * Set the current local matrix as the restPose for this bone.
  15614. */
  15615. setCurrentPoseAsRest(): void;
  15616. }
  15617. }
  15618. declare module BABYLON {
  15619. /**
  15620. * Defines a runtime animation
  15621. */
  15622. export class RuntimeAnimation {
  15623. private _events;
  15624. /**
  15625. * The current frame of the runtime animation
  15626. */
  15627. private _currentFrame;
  15628. /**
  15629. * The animation used by the runtime animation
  15630. */
  15631. private _animation;
  15632. /**
  15633. * The target of the runtime animation
  15634. */
  15635. private _target;
  15636. /**
  15637. * The initiating animatable
  15638. */
  15639. private _host;
  15640. /**
  15641. * The original value of the runtime animation
  15642. */
  15643. private _originalValue;
  15644. /**
  15645. * The original blend value of the runtime animation
  15646. */
  15647. private _originalBlendValue;
  15648. /**
  15649. * The offsets cache of the runtime animation
  15650. */
  15651. private _offsetsCache;
  15652. /**
  15653. * The high limits cache of the runtime animation
  15654. */
  15655. private _highLimitsCache;
  15656. /**
  15657. * Specifies if the runtime animation has been stopped
  15658. */
  15659. private _stopped;
  15660. /**
  15661. * The blending factor of the runtime animation
  15662. */
  15663. private _blendingFactor;
  15664. /**
  15665. * The BabylonJS scene
  15666. */
  15667. private _scene;
  15668. /**
  15669. * The current value of the runtime animation
  15670. */
  15671. private _currentValue;
  15672. /** @hidden */
  15673. _animationState: _IAnimationState;
  15674. /**
  15675. * The active target of the runtime animation
  15676. */
  15677. private _activeTargets;
  15678. private _currentActiveTarget;
  15679. private _directTarget;
  15680. /**
  15681. * The target path of the runtime animation
  15682. */
  15683. private _targetPath;
  15684. /**
  15685. * The weight of the runtime animation
  15686. */
  15687. private _weight;
  15688. /**
  15689. * The ratio offset of the runtime animation
  15690. */
  15691. private _ratioOffset;
  15692. /**
  15693. * The previous delay of the runtime animation
  15694. */
  15695. private _previousDelay;
  15696. /**
  15697. * The previous ratio of the runtime animation
  15698. */
  15699. private _previousRatio;
  15700. private _enableBlending;
  15701. private _keys;
  15702. private _minFrame;
  15703. private _maxFrame;
  15704. private _minValue;
  15705. private _maxValue;
  15706. private _targetIsArray;
  15707. /**
  15708. * Gets the current frame of the runtime animation
  15709. */
  15710. get currentFrame(): number;
  15711. /**
  15712. * Gets the weight of the runtime animation
  15713. */
  15714. get weight(): number;
  15715. /**
  15716. * Gets the current value of the runtime animation
  15717. */
  15718. get currentValue(): any;
  15719. /**
  15720. * Gets the target path of the runtime animation
  15721. */
  15722. get targetPath(): string;
  15723. /**
  15724. * Gets the actual target of the runtime animation
  15725. */
  15726. get target(): any;
  15727. /**
  15728. * Gets the additive state of the runtime animation
  15729. */
  15730. get isAdditive(): boolean;
  15731. /** @hidden */
  15732. _onLoop: () => void;
  15733. /**
  15734. * Create a new RuntimeAnimation object
  15735. * @param target defines the target of the animation
  15736. * @param animation defines the source animation object
  15737. * @param scene defines the hosting scene
  15738. * @param host defines the initiating Animatable
  15739. */
  15740. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15741. private _preparePath;
  15742. /**
  15743. * Gets the animation from the runtime animation
  15744. */
  15745. get animation(): Animation;
  15746. /**
  15747. * Resets the runtime animation to the beginning
  15748. * @param restoreOriginal defines whether to restore the target property to the original value
  15749. */
  15750. reset(restoreOriginal?: boolean): void;
  15751. /**
  15752. * Specifies if the runtime animation is stopped
  15753. * @returns Boolean specifying if the runtime animation is stopped
  15754. */
  15755. isStopped(): boolean;
  15756. /**
  15757. * Disposes of the runtime animation
  15758. */
  15759. dispose(): void;
  15760. /**
  15761. * Apply the interpolated value to the target
  15762. * @param currentValue defines the value computed by the animation
  15763. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15764. */
  15765. setValue(currentValue: any, weight: number): void;
  15766. private _getOriginalValues;
  15767. private _setValue;
  15768. /**
  15769. * Gets the loop pmode of the runtime animation
  15770. * @returns Loop Mode
  15771. */
  15772. private _getCorrectLoopMode;
  15773. /**
  15774. * Move the current animation to a given frame
  15775. * @param frame defines the frame to move to
  15776. */
  15777. goToFrame(frame: number): void;
  15778. /**
  15779. * @hidden Internal use only
  15780. */
  15781. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15782. /**
  15783. * Execute the current animation
  15784. * @param delay defines the delay to add to the current frame
  15785. * @param from defines the lower bound of the animation range
  15786. * @param to defines the upper bound of the animation range
  15787. * @param loop defines if the current animation must loop
  15788. * @param speedRatio defines the current speed ratio
  15789. * @param weight defines the weight of the animation (default is -1 so no weight)
  15790. * @param onLoop optional callback called when animation loops
  15791. * @returns a boolean indicating if the animation is running
  15792. */
  15793. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15794. }
  15795. }
  15796. declare module BABYLON {
  15797. /**
  15798. * Class used to store an actual running animation
  15799. */
  15800. export class Animatable {
  15801. /** defines the target object */
  15802. target: any;
  15803. /** defines the starting frame number (default is 0) */
  15804. fromFrame: number;
  15805. /** defines the ending frame number (default is 100) */
  15806. toFrame: number;
  15807. /** defines if the animation must loop (default is false) */
  15808. loopAnimation: boolean;
  15809. /** defines a callback to call when animation ends if it is not looping */
  15810. onAnimationEnd?: (() => void) | null | undefined;
  15811. /** defines a callback to call when animation loops */
  15812. onAnimationLoop?: (() => void) | null | undefined;
  15813. /** defines whether the animation should be evaluated additively */
  15814. isAdditive: boolean;
  15815. private _localDelayOffset;
  15816. private _pausedDelay;
  15817. private _runtimeAnimations;
  15818. private _paused;
  15819. private _scene;
  15820. private _speedRatio;
  15821. private _weight;
  15822. private _syncRoot;
  15823. /**
  15824. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15825. * This will only apply for non looping animation (default is true)
  15826. */
  15827. disposeOnEnd: boolean;
  15828. /**
  15829. * Gets a boolean indicating if the animation has started
  15830. */
  15831. animationStarted: boolean;
  15832. /**
  15833. * Observer raised when the animation ends
  15834. */
  15835. onAnimationEndObservable: Observable<Animatable>;
  15836. /**
  15837. * Observer raised when the animation loops
  15838. */
  15839. onAnimationLoopObservable: Observable<Animatable>;
  15840. /**
  15841. * Gets the root Animatable used to synchronize and normalize animations
  15842. */
  15843. get syncRoot(): Nullable<Animatable>;
  15844. /**
  15845. * Gets the current frame of the first RuntimeAnimation
  15846. * Used to synchronize Animatables
  15847. */
  15848. get masterFrame(): number;
  15849. /**
  15850. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15851. */
  15852. get weight(): number;
  15853. set weight(value: number);
  15854. /**
  15855. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15856. */
  15857. get speedRatio(): number;
  15858. set speedRatio(value: number);
  15859. /**
  15860. * Creates a new Animatable
  15861. * @param scene defines the hosting scene
  15862. * @param target defines the target object
  15863. * @param fromFrame defines the starting frame number (default is 0)
  15864. * @param toFrame defines the ending frame number (default is 100)
  15865. * @param loopAnimation defines if the animation must loop (default is false)
  15866. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15867. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15868. * @param animations defines a group of animation to add to the new Animatable
  15869. * @param onAnimationLoop defines a callback to call when animation loops
  15870. * @param isAdditive defines whether the animation should be evaluated additively
  15871. */
  15872. constructor(scene: Scene,
  15873. /** defines the target object */
  15874. target: any,
  15875. /** defines the starting frame number (default is 0) */
  15876. fromFrame?: number,
  15877. /** defines the ending frame number (default is 100) */
  15878. toFrame?: number,
  15879. /** defines if the animation must loop (default is false) */
  15880. loopAnimation?: boolean, speedRatio?: number,
  15881. /** defines a callback to call when animation ends if it is not looping */
  15882. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15883. /** defines a callback to call when animation loops */
  15884. onAnimationLoop?: (() => void) | null | undefined,
  15885. /** defines whether the animation should be evaluated additively */
  15886. isAdditive?: boolean);
  15887. /**
  15888. * Synchronize and normalize current Animatable with a source Animatable
  15889. * This is useful when using animation weights and when animations are not of the same length
  15890. * @param root defines the root Animatable to synchronize with
  15891. * @returns the current Animatable
  15892. */
  15893. syncWith(root: Animatable): Animatable;
  15894. /**
  15895. * Gets the list of runtime animations
  15896. * @returns an array of RuntimeAnimation
  15897. */
  15898. getAnimations(): RuntimeAnimation[];
  15899. /**
  15900. * Adds more animations to the current animatable
  15901. * @param target defines the target of the animations
  15902. * @param animations defines the new animations to add
  15903. */
  15904. appendAnimations(target: any, animations: Animation[]): void;
  15905. /**
  15906. * Gets the source animation for a specific property
  15907. * @param property defines the propertyu to look for
  15908. * @returns null or the source animation for the given property
  15909. */
  15910. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15911. /**
  15912. * Gets the runtime animation for a specific property
  15913. * @param property defines the propertyu to look for
  15914. * @returns null or the runtime animation for the given property
  15915. */
  15916. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15917. /**
  15918. * Resets the animatable to its original state
  15919. */
  15920. reset(): void;
  15921. /**
  15922. * Allows the animatable to blend with current running animations
  15923. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15924. * @param blendingSpeed defines the blending speed to use
  15925. */
  15926. enableBlending(blendingSpeed: number): void;
  15927. /**
  15928. * Disable animation blending
  15929. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15930. */
  15931. disableBlending(): void;
  15932. /**
  15933. * Jump directly to a given frame
  15934. * @param frame defines the frame to jump to
  15935. */
  15936. goToFrame(frame: number): void;
  15937. /**
  15938. * Pause the animation
  15939. */
  15940. pause(): void;
  15941. /**
  15942. * Restart the animation
  15943. */
  15944. restart(): void;
  15945. private _raiseOnAnimationEnd;
  15946. /**
  15947. * Stop and delete the current animation
  15948. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15949. * @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)
  15950. */
  15951. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15952. /**
  15953. * Wait asynchronously for the animation to end
  15954. * @returns a promise which will be fullfilled when the animation ends
  15955. */
  15956. waitAsync(): Promise<Animatable>;
  15957. /** @hidden */
  15958. _animate(delay: number): boolean;
  15959. }
  15960. interface Scene {
  15961. /** @hidden */
  15962. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15963. /** @hidden */
  15964. _processLateAnimationBindingsForMatrices(holder: {
  15965. totalWeight: number;
  15966. totalAdditiveWeight: number;
  15967. animations: RuntimeAnimation[];
  15968. additiveAnimations: RuntimeAnimation[];
  15969. originalValue: Matrix;
  15970. }): any;
  15971. /** @hidden */
  15972. _processLateAnimationBindingsForQuaternions(holder: {
  15973. totalWeight: number;
  15974. totalAdditiveWeight: number;
  15975. animations: RuntimeAnimation[];
  15976. additiveAnimations: RuntimeAnimation[];
  15977. originalValue: Quaternion;
  15978. }, refQuaternion: Quaternion): Quaternion;
  15979. /** @hidden */
  15980. _processLateAnimationBindings(): void;
  15981. /**
  15982. * Will start the animation sequence of a given target
  15983. * @param target defines the target
  15984. * @param from defines from which frame should animation start
  15985. * @param to defines until which frame should animation run.
  15986. * @param weight defines the weight to apply to the animation (1.0 by default)
  15987. * @param loop defines if the animation loops
  15988. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15989. * @param onAnimationEnd defines the function to be executed when the animation ends
  15990. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15991. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15992. * @param onAnimationLoop defines the callback to call when an animation loops
  15993. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15994. * @returns the animatable object created for this animation
  15995. */
  15996. 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;
  15997. /**
  15998. * Will start the animation sequence of a given target
  15999. * @param target defines the target
  16000. * @param from defines from which frame should animation start
  16001. * @param to defines until which frame should animation run.
  16002. * @param loop defines if the animation loops
  16003. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16004. * @param onAnimationEnd defines the function to be executed when the animation ends
  16005. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16006. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16007. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16008. * @param onAnimationLoop defines the callback to call when an animation loops
  16009. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16010. * @returns the animatable object created for this animation
  16011. */
  16012. 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;
  16013. /**
  16014. * Will start the animation sequence of a given target and its hierarchy
  16015. * @param target defines the target
  16016. * @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.
  16017. * @param from defines from which frame should animation start
  16018. * @param to defines until which frame should animation run.
  16019. * @param loop defines if the animation loops
  16020. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16021. * @param onAnimationEnd defines the function to be executed when the animation ends
  16022. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16023. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16024. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16025. * @param onAnimationLoop defines the callback to call when an animation loops
  16026. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16027. * @returns the list of created animatables
  16028. */
  16029. 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[];
  16030. /**
  16031. * Begin a new animation on a given node
  16032. * @param target defines the target where the animation will take place
  16033. * @param animations defines the list of animations to start
  16034. * @param from defines the initial value
  16035. * @param to defines the final value
  16036. * @param loop defines if you want animation to loop (off by default)
  16037. * @param speedRatio defines the speed ratio to apply to all animations
  16038. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16039. * @param onAnimationLoop defines the callback to call when an animation loops
  16040. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16041. * @returns the list of created animatables
  16042. */
  16043. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16044. /**
  16045. * Begin a new animation on a given node and its hierarchy
  16046. * @param target defines the root node where the animation will take place
  16047. * @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.
  16048. * @param animations defines the list of animations to start
  16049. * @param from defines the initial value
  16050. * @param to defines the final value
  16051. * @param loop defines if you want animation to loop (off by default)
  16052. * @param speedRatio defines the speed ratio to apply to all animations
  16053. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16054. * @param onAnimationLoop defines the callback to call when an animation loops
  16055. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16056. * @returns the list of animatables created for all nodes
  16057. */
  16058. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16059. /**
  16060. * Gets the animatable associated with a specific target
  16061. * @param target defines the target of the animatable
  16062. * @returns the required animatable if found
  16063. */
  16064. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16065. /**
  16066. * Gets all animatables associated with a given target
  16067. * @param target defines the target to look animatables for
  16068. * @returns an array of Animatables
  16069. */
  16070. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16071. /**
  16072. * Stops and removes all animations that have been applied to the scene
  16073. */
  16074. stopAllAnimations(): void;
  16075. /**
  16076. * Gets the current delta time used by animation engine
  16077. */
  16078. deltaTime: number;
  16079. }
  16080. interface Bone {
  16081. /**
  16082. * Copy an animation range from another bone
  16083. * @param source defines the source bone
  16084. * @param rangeName defines the range name to copy
  16085. * @param frameOffset defines the frame offset
  16086. * @param rescaleAsRequired defines if rescaling must be applied if required
  16087. * @param skelDimensionsRatio defines the scaling ratio
  16088. * @returns true if operation was successful
  16089. */
  16090. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16091. }
  16092. }
  16093. declare module BABYLON {
  16094. /**
  16095. * Class used to handle skinning animations
  16096. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16097. */
  16098. export class Skeleton implements IAnimatable {
  16099. /** defines the skeleton name */
  16100. name: string;
  16101. /** defines the skeleton Id */
  16102. id: string;
  16103. /**
  16104. * Defines the list of child bones
  16105. */
  16106. bones: Bone[];
  16107. /**
  16108. * Defines an estimate of the dimension of the skeleton at rest
  16109. */
  16110. dimensionsAtRest: Vector3;
  16111. /**
  16112. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16113. */
  16114. needInitialSkinMatrix: boolean;
  16115. /**
  16116. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16117. */
  16118. overrideMesh: Nullable<AbstractMesh>;
  16119. /**
  16120. * Gets the list of animations attached to this skeleton
  16121. */
  16122. animations: Array<Animation>;
  16123. private _scene;
  16124. private _isDirty;
  16125. private _transformMatrices;
  16126. private _transformMatrixTexture;
  16127. private _meshesWithPoseMatrix;
  16128. private _animatables;
  16129. private _identity;
  16130. private _synchronizedWithMesh;
  16131. private _ranges;
  16132. private _lastAbsoluteTransformsUpdateId;
  16133. private _canUseTextureForBones;
  16134. private _uniqueId;
  16135. /** @hidden */
  16136. _numBonesWithLinkedTransformNode: number;
  16137. /** @hidden */
  16138. _hasWaitingData: Nullable<boolean>;
  16139. /** @hidden */
  16140. _waitingOverrideMeshId: Nullable<string>;
  16141. /**
  16142. * Specifies if the skeleton should be serialized
  16143. */
  16144. doNotSerialize: boolean;
  16145. private _useTextureToStoreBoneMatrices;
  16146. /**
  16147. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16148. * Please note that this option is not available if the hardware does not support it
  16149. */
  16150. get useTextureToStoreBoneMatrices(): boolean;
  16151. set useTextureToStoreBoneMatrices(value: boolean);
  16152. private _animationPropertiesOverride;
  16153. /**
  16154. * Gets or sets the animation properties override
  16155. */
  16156. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16157. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16158. /**
  16159. * List of inspectable custom properties (used by the Inspector)
  16160. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16161. */
  16162. inspectableCustomProperties: IInspectable[];
  16163. /**
  16164. * An observable triggered before computing the skeleton's matrices
  16165. */
  16166. onBeforeComputeObservable: Observable<Skeleton>;
  16167. /**
  16168. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16169. */
  16170. get isUsingTextureForMatrices(): boolean;
  16171. /**
  16172. * Gets the unique ID of this skeleton
  16173. */
  16174. get uniqueId(): number;
  16175. /**
  16176. * Creates a new skeleton
  16177. * @param name defines the skeleton name
  16178. * @param id defines the skeleton Id
  16179. * @param scene defines the hosting scene
  16180. */
  16181. constructor(
  16182. /** defines the skeleton name */
  16183. name: string,
  16184. /** defines the skeleton Id */
  16185. id: string, scene: Scene);
  16186. /**
  16187. * Gets the current object class name.
  16188. * @return the class name
  16189. */
  16190. getClassName(): string;
  16191. /**
  16192. * Returns an array containing the root bones
  16193. * @returns an array containing the root bones
  16194. */
  16195. getChildren(): Array<Bone>;
  16196. /**
  16197. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16198. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16199. * @returns a Float32Array containing matrices data
  16200. */
  16201. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16202. /**
  16203. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16204. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16205. * @returns a raw texture containing the data
  16206. */
  16207. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16208. /**
  16209. * Gets the current hosting scene
  16210. * @returns a scene object
  16211. */
  16212. getScene(): Scene;
  16213. /**
  16214. * Gets a string representing the current skeleton data
  16215. * @param fullDetails defines a boolean indicating if we want a verbose version
  16216. * @returns a string representing the current skeleton data
  16217. */
  16218. toString(fullDetails?: boolean): string;
  16219. /**
  16220. * Get bone's index searching by name
  16221. * @param name defines bone's name to search for
  16222. * @return the indice of the bone. Returns -1 if not found
  16223. */
  16224. getBoneIndexByName(name: string): number;
  16225. /**
  16226. * Creater a new animation range
  16227. * @param name defines the name of the range
  16228. * @param from defines the start key
  16229. * @param to defines the end key
  16230. */
  16231. createAnimationRange(name: string, from: number, to: number): void;
  16232. /**
  16233. * Delete a specific animation range
  16234. * @param name defines the name of the range
  16235. * @param deleteFrames defines if frames must be removed as well
  16236. */
  16237. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16238. /**
  16239. * Gets a specific animation range
  16240. * @param name defines the name of the range to look for
  16241. * @returns the requested animation range or null if not found
  16242. */
  16243. getAnimationRange(name: string): Nullable<AnimationRange>;
  16244. /**
  16245. * Gets the list of all animation ranges defined on this skeleton
  16246. * @returns an array
  16247. */
  16248. getAnimationRanges(): Nullable<AnimationRange>[];
  16249. /**
  16250. * Copy animation range from a source skeleton.
  16251. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16252. * @param source defines the source skeleton
  16253. * @param name defines the name of the range to copy
  16254. * @param rescaleAsRequired defines if rescaling must be applied if required
  16255. * @returns true if operation was successful
  16256. */
  16257. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16258. /**
  16259. * Forces the skeleton to go to rest pose
  16260. */
  16261. returnToRest(): void;
  16262. private _getHighestAnimationFrame;
  16263. /**
  16264. * Begin a specific animation range
  16265. * @param name defines the name of the range to start
  16266. * @param loop defines if looping must be turned on (false by default)
  16267. * @param speedRatio defines the speed ratio to apply (1 by default)
  16268. * @param onAnimationEnd defines a callback which will be called when animation will end
  16269. * @returns a new animatable
  16270. */
  16271. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16272. /**
  16273. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16274. * @param skeleton defines the Skeleton containing the animation range to convert
  16275. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16276. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16277. * @returns the original skeleton
  16278. */
  16279. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16280. /** @hidden */
  16281. _markAsDirty(): void;
  16282. /** @hidden */
  16283. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16284. /** @hidden */
  16285. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16286. private _computeTransformMatrices;
  16287. /**
  16288. * Build all resources required to render a skeleton
  16289. */
  16290. prepare(): void;
  16291. /**
  16292. * Gets the list of animatables currently running for this skeleton
  16293. * @returns an array of animatables
  16294. */
  16295. getAnimatables(): IAnimatable[];
  16296. /**
  16297. * Clone the current skeleton
  16298. * @param name defines the name of the new skeleton
  16299. * @param id defines the id of the new skeleton
  16300. * @returns the new skeleton
  16301. */
  16302. clone(name: string, id?: string): Skeleton;
  16303. /**
  16304. * Enable animation blending for this skeleton
  16305. * @param blendingSpeed defines the blending speed to apply
  16306. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16307. */
  16308. enableBlending(blendingSpeed?: number): void;
  16309. /**
  16310. * Releases all resources associated with the current skeleton
  16311. */
  16312. dispose(): void;
  16313. /**
  16314. * Serialize the skeleton in a JSON object
  16315. * @returns a JSON object
  16316. */
  16317. serialize(): any;
  16318. /**
  16319. * Creates a new skeleton from serialized data
  16320. * @param parsedSkeleton defines the serialized data
  16321. * @param scene defines the hosting scene
  16322. * @returns a new skeleton
  16323. */
  16324. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16325. /**
  16326. * Compute all node absolute transforms
  16327. * @param forceUpdate defines if computation must be done even if cache is up to date
  16328. */
  16329. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16330. /**
  16331. * Gets the root pose matrix
  16332. * @returns a matrix
  16333. */
  16334. getPoseMatrix(): Nullable<Matrix>;
  16335. /**
  16336. * Sorts bones per internal index
  16337. */
  16338. sortBones(): void;
  16339. private _sortBones;
  16340. /**
  16341. * Set the current local matrix as the restPose for all bones in the skeleton.
  16342. */
  16343. setCurrentPoseAsRest(): void;
  16344. }
  16345. }
  16346. declare module BABYLON {
  16347. /**
  16348. * Creates an instance based on a source mesh.
  16349. */
  16350. export class InstancedMesh extends AbstractMesh {
  16351. private _sourceMesh;
  16352. private _currentLOD;
  16353. /** @hidden */
  16354. _indexInSourceMeshInstanceArray: number;
  16355. constructor(name: string, source: Mesh);
  16356. /**
  16357. * Returns the string "InstancedMesh".
  16358. */
  16359. getClassName(): string;
  16360. /** Gets the list of lights affecting that mesh */
  16361. get lightSources(): Light[];
  16362. _resyncLightSources(): void;
  16363. _resyncLightSource(light: Light): void;
  16364. _removeLightSource(light: Light, dispose: boolean): void;
  16365. /**
  16366. * If the source mesh receives shadows
  16367. */
  16368. get receiveShadows(): boolean;
  16369. /**
  16370. * The material of the source mesh
  16371. */
  16372. get material(): Nullable<Material>;
  16373. /**
  16374. * Visibility of the source mesh
  16375. */
  16376. get visibility(): number;
  16377. /**
  16378. * Skeleton of the source mesh
  16379. */
  16380. get skeleton(): Nullable<Skeleton>;
  16381. /**
  16382. * Rendering ground id of the source mesh
  16383. */
  16384. get renderingGroupId(): number;
  16385. set renderingGroupId(value: number);
  16386. /**
  16387. * Returns the total number of vertices (integer).
  16388. */
  16389. getTotalVertices(): number;
  16390. /**
  16391. * Returns a positive integer : the total number of indices in this mesh geometry.
  16392. * @returns the numner of indices or zero if the mesh has no geometry.
  16393. */
  16394. getTotalIndices(): number;
  16395. /**
  16396. * The source mesh of the instance
  16397. */
  16398. get sourceMesh(): Mesh;
  16399. /**
  16400. * Creates a new InstancedMesh object from the mesh model.
  16401. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16402. * @param name defines the name of the new instance
  16403. * @returns a new InstancedMesh
  16404. */
  16405. createInstance(name: string): InstancedMesh;
  16406. /**
  16407. * Is this node ready to be used/rendered
  16408. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16409. * @return {boolean} is it ready
  16410. */
  16411. isReady(completeCheck?: boolean): boolean;
  16412. /**
  16413. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16414. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16415. * @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.
  16416. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16417. */
  16418. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16419. /**
  16420. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16421. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16422. * The `data` are either a numeric array either a Float32Array.
  16423. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16424. * 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).
  16425. * Note that a new underlying VertexBuffer object is created each call.
  16426. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16427. *
  16428. * Possible `kind` values :
  16429. * - VertexBuffer.PositionKind
  16430. * - VertexBuffer.UVKind
  16431. * - VertexBuffer.UV2Kind
  16432. * - VertexBuffer.UV3Kind
  16433. * - VertexBuffer.UV4Kind
  16434. * - VertexBuffer.UV5Kind
  16435. * - VertexBuffer.UV6Kind
  16436. * - VertexBuffer.ColorKind
  16437. * - VertexBuffer.MatricesIndicesKind
  16438. * - VertexBuffer.MatricesIndicesExtraKind
  16439. * - VertexBuffer.MatricesWeightsKind
  16440. * - VertexBuffer.MatricesWeightsExtraKind
  16441. *
  16442. * Returns the Mesh.
  16443. */
  16444. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16445. /**
  16446. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16447. * If the mesh has no geometry, it is simply returned as it is.
  16448. * The `data` are either a numeric array either a Float32Array.
  16449. * No new underlying VertexBuffer object is created.
  16450. * 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.
  16451. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16452. *
  16453. * Possible `kind` values :
  16454. * - VertexBuffer.PositionKind
  16455. * - VertexBuffer.UVKind
  16456. * - VertexBuffer.UV2Kind
  16457. * - VertexBuffer.UV3Kind
  16458. * - VertexBuffer.UV4Kind
  16459. * - VertexBuffer.UV5Kind
  16460. * - VertexBuffer.UV6Kind
  16461. * - VertexBuffer.ColorKind
  16462. * - VertexBuffer.MatricesIndicesKind
  16463. * - VertexBuffer.MatricesIndicesExtraKind
  16464. * - VertexBuffer.MatricesWeightsKind
  16465. * - VertexBuffer.MatricesWeightsExtraKind
  16466. *
  16467. * Returns the Mesh.
  16468. */
  16469. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16470. /**
  16471. * Sets the mesh indices.
  16472. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16473. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16474. * This method creates a new index buffer each call.
  16475. * Returns the Mesh.
  16476. */
  16477. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16478. /**
  16479. * Boolean : True if the mesh owns the requested kind of data.
  16480. */
  16481. isVerticesDataPresent(kind: string): boolean;
  16482. /**
  16483. * Returns an array of indices (IndicesArray).
  16484. */
  16485. getIndices(): Nullable<IndicesArray>;
  16486. get _positions(): Nullable<Vector3[]>;
  16487. /**
  16488. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16489. * This means the mesh underlying bounding box and sphere are recomputed.
  16490. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16491. * @returns the current mesh
  16492. */
  16493. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16494. /** @hidden */
  16495. _preActivate(): InstancedMesh;
  16496. /** @hidden */
  16497. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16498. /** @hidden */
  16499. _postActivate(): void;
  16500. getWorldMatrix(): Matrix;
  16501. get isAnInstance(): boolean;
  16502. /**
  16503. * Returns the current associated LOD AbstractMesh.
  16504. */
  16505. getLOD(camera: Camera): AbstractMesh;
  16506. /** @hidden */
  16507. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16508. /** @hidden */
  16509. _syncSubMeshes(): InstancedMesh;
  16510. /** @hidden */
  16511. _generatePointsArray(): boolean;
  16512. /** @hidden */
  16513. _updateBoundingInfo(): AbstractMesh;
  16514. /**
  16515. * Creates a new InstancedMesh from the current mesh.
  16516. * - name (string) : the cloned mesh name
  16517. * - newParent (optional Node) : the optional Node to parent the clone to.
  16518. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16519. *
  16520. * Returns the clone.
  16521. */
  16522. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16523. /**
  16524. * Disposes the InstancedMesh.
  16525. * Returns nothing.
  16526. */
  16527. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16528. }
  16529. interface Mesh {
  16530. /**
  16531. * Register a custom buffer that will be instanced
  16532. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16533. * @param kind defines the buffer kind
  16534. * @param stride defines the stride in floats
  16535. */
  16536. registerInstancedBuffer(kind: string, stride: number): void;
  16537. /**
  16538. * true to use the edge renderer for all instances of this mesh
  16539. */
  16540. edgesShareWithInstances: boolean;
  16541. /** @hidden */
  16542. _userInstancedBuffersStorage: {
  16543. data: {
  16544. [key: string]: Float32Array;
  16545. };
  16546. sizes: {
  16547. [key: string]: number;
  16548. };
  16549. vertexBuffers: {
  16550. [key: string]: Nullable<VertexBuffer>;
  16551. };
  16552. strides: {
  16553. [key: string]: number;
  16554. };
  16555. };
  16556. }
  16557. interface AbstractMesh {
  16558. /**
  16559. * Object used to store instanced buffers defined by user
  16560. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16561. */
  16562. instancedBuffers: {
  16563. [key: string]: any;
  16564. };
  16565. }
  16566. }
  16567. declare module BABYLON {
  16568. /**
  16569. * Defines the options associated with the creation of a shader material.
  16570. */
  16571. export interface IShaderMaterialOptions {
  16572. /**
  16573. * Does the material work in alpha blend mode
  16574. */
  16575. needAlphaBlending: boolean;
  16576. /**
  16577. * Does the material work in alpha test mode
  16578. */
  16579. needAlphaTesting: boolean;
  16580. /**
  16581. * The list of attribute names used in the shader
  16582. */
  16583. attributes: string[];
  16584. /**
  16585. * The list of unifrom names used in the shader
  16586. */
  16587. uniforms: string[];
  16588. /**
  16589. * The list of UBO names used in the shader
  16590. */
  16591. uniformBuffers: string[];
  16592. /**
  16593. * The list of sampler names used in the shader
  16594. */
  16595. samplers: string[];
  16596. /**
  16597. * The list of defines used in the shader
  16598. */
  16599. defines: string[];
  16600. }
  16601. /**
  16602. * 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.
  16603. *
  16604. * This returned material effects how the mesh will look based on the code in the shaders.
  16605. *
  16606. * @see https://doc.babylonjs.com/how_to/shader_material
  16607. */
  16608. export class ShaderMaterial extends Material {
  16609. private _shaderPath;
  16610. private _options;
  16611. private _textures;
  16612. private _textureArrays;
  16613. private _floats;
  16614. private _ints;
  16615. private _floatsArrays;
  16616. private _colors3;
  16617. private _colors3Arrays;
  16618. private _colors4;
  16619. private _colors4Arrays;
  16620. private _vectors2;
  16621. private _vectors3;
  16622. private _vectors4;
  16623. private _matrices;
  16624. private _matrixArrays;
  16625. private _matrices3x3;
  16626. private _matrices2x2;
  16627. private _vectors2Arrays;
  16628. private _vectors3Arrays;
  16629. private _vectors4Arrays;
  16630. private _cachedWorldViewMatrix;
  16631. private _cachedWorldViewProjectionMatrix;
  16632. private _renderId;
  16633. private _multiview;
  16634. private _cachedDefines;
  16635. /** Define the Url to load snippets */
  16636. static SnippetUrl: string;
  16637. /** Snippet ID if the material was created from the snippet server */
  16638. snippetId: string;
  16639. /**
  16640. * Instantiate a new shader material.
  16641. * 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.
  16642. * This returned material effects how the mesh will look based on the code in the shaders.
  16643. * @see https://doc.babylonjs.com/how_to/shader_material
  16644. * @param name Define the name of the material in the scene
  16645. * @param scene Define the scene the material belongs to
  16646. * @param shaderPath Defines the route to the shader code in one of three ways:
  16647. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16648. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16649. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16650. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16651. * @param options Define the options used to create the shader
  16652. */
  16653. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16654. /**
  16655. * Gets the shader path used to define the shader code
  16656. * It can be modified to trigger a new compilation
  16657. */
  16658. get shaderPath(): any;
  16659. /**
  16660. * Sets the shader path used to define the shader code
  16661. * It can be modified to trigger a new compilation
  16662. */
  16663. set shaderPath(shaderPath: any);
  16664. /**
  16665. * Gets the options used to compile the shader.
  16666. * They can be modified to trigger a new compilation
  16667. */
  16668. get options(): IShaderMaterialOptions;
  16669. /**
  16670. * Gets the current class name of the material e.g. "ShaderMaterial"
  16671. * Mainly use in serialization.
  16672. * @returns the class name
  16673. */
  16674. getClassName(): string;
  16675. /**
  16676. * Specifies if the material will require alpha blending
  16677. * @returns a boolean specifying if alpha blending is needed
  16678. */
  16679. needAlphaBlending(): boolean;
  16680. /**
  16681. * Specifies if this material should be rendered in alpha test mode
  16682. * @returns a boolean specifying if an alpha test is needed.
  16683. */
  16684. needAlphaTesting(): boolean;
  16685. private _checkUniform;
  16686. /**
  16687. * Set a texture in the shader.
  16688. * @param name Define the name of the uniform samplers as defined in the shader
  16689. * @param texture Define the texture to bind to this sampler
  16690. * @return the material itself allowing "fluent" like uniform updates
  16691. */
  16692. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16693. /**
  16694. * Set a texture array in the shader.
  16695. * @param name Define the name of the uniform sampler array as defined in the shader
  16696. * @param textures Define the list of textures to bind to this sampler
  16697. * @return the material itself allowing "fluent" like uniform updates
  16698. */
  16699. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16700. /**
  16701. * Set a float in the shader.
  16702. * @param name Define the name of the uniform as defined in the shader
  16703. * @param value Define the value to give to the uniform
  16704. * @return the material itself allowing "fluent" like uniform updates
  16705. */
  16706. setFloat(name: string, value: number): ShaderMaterial;
  16707. /**
  16708. * Set a int in the shader.
  16709. * @param name Define the name of the uniform as defined in the shader
  16710. * @param value Define the value to give to the uniform
  16711. * @return the material itself allowing "fluent" like uniform updates
  16712. */
  16713. setInt(name: string, value: number): ShaderMaterial;
  16714. /**
  16715. * Set an array of floats in the shader.
  16716. * @param name Define the name of the uniform as defined in the shader
  16717. * @param value Define the value to give to the uniform
  16718. * @return the material itself allowing "fluent" like uniform updates
  16719. */
  16720. setFloats(name: string, value: number[]): ShaderMaterial;
  16721. /**
  16722. * Set a vec3 in the shader from a Color3.
  16723. * @param name Define the name of the uniform as defined in the shader
  16724. * @param value Define the value to give to the uniform
  16725. * @return the material itself allowing "fluent" like uniform updates
  16726. */
  16727. setColor3(name: string, value: Color3): ShaderMaterial;
  16728. /**
  16729. * Set a vec3 array in the shader from a Color3 array.
  16730. * @param name Define the name of the uniform as defined in the shader
  16731. * @param value Define the value to give to the uniform
  16732. * @return the material itself allowing "fluent" like uniform updates
  16733. */
  16734. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16735. /**
  16736. * Set a vec4 in the shader from a Color4.
  16737. * @param name Define the name of the uniform as defined in the shader
  16738. * @param value Define the value to give to the uniform
  16739. * @return the material itself allowing "fluent" like uniform updates
  16740. */
  16741. setColor4(name: string, value: Color4): ShaderMaterial;
  16742. /**
  16743. * Set a vec4 array in the shader from a Color4 array.
  16744. * @param name Define the name of the uniform as defined in the shader
  16745. * @param value Define the value to give to the uniform
  16746. * @return the material itself allowing "fluent" like uniform updates
  16747. */
  16748. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16749. /**
  16750. * Set a vec2 in the shader from a Vector2.
  16751. * @param name Define the name of the uniform as defined in the shader
  16752. * @param value Define the value to give to the uniform
  16753. * @return the material itself allowing "fluent" like uniform updates
  16754. */
  16755. setVector2(name: string, value: Vector2): ShaderMaterial;
  16756. /**
  16757. * Set a vec3 in the shader from a Vector3.
  16758. * @param name Define the name of the uniform as defined in the shader
  16759. * @param value Define the value to give to the uniform
  16760. * @return the material itself allowing "fluent" like uniform updates
  16761. */
  16762. setVector3(name: string, value: Vector3): ShaderMaterial;
  16763. /**
  16764. * Set a vec4 in the shader from a Vector4.
  16765. * @param name Define the name of the uniform as defined in the shader
  16766. * @param value Define the value to give to the uniform
  16767. * @return the material itself allowing "fluent" like uniform updates
  16768. */
  16769. setVector4(name: string, value: Vector4): ShaderMaterial;
  16770. /**
  16771. * Set a mat4 in the shader from a Matrix.
  16772. * @param name Define the name of the uniform as defined in the shader
  16773. * @param value Define the value to give to the uniform
  16774. * @return the material itself allowing "fluent" like uniform updates
  16775. */
  16776. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16777. /**
  16778. * Set a float32Array in the shader from a matrix array.
  16779. * @param name Define the name of the uniform as defined in the shader
  16780. * @param value Define the value to give to the uniform
  16781. * @return the material itself allowing "fluent" like uniform updates
  16782. */
  16783. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16784. /**
  16785. * Set a mat3 in the shader from a Float32Array.
  16786. * @param name Define the name of the uniform as defined in the shader
  16787. * @param value Define the value to give to the uniform
  16788. * @return the material itself allowing "fluent" like uniform updates
  16789. */
  16790. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16791. /**
  16792. * Set a mat2 in the shader from a Float32Array.
  16793. * @param name Define the name of the uniform as defined in the shader
  16794. * @param value Define the value to give to the uniform
  16795. * @return the material itself allowing "fluent" like uniform updates
  16796. */
  16797. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16798. /**
  16799. * Set a vec2 array in the shader from a number array.
  16800. * @param name Define the name of the uniform as defined in the shader
  16801. * @param value Define the value to give to the uniform
  16802. * @return the material itself allowing "fluent" like uniform updates
  16803. */
  16804. setArray2(name: string, value: number[]): ShaderMaterial;
  16805. /**
  16806. * Set a vec3 array in the shader from a number array.
  16807. * @param name Define the name of the uniform as defined in the shader
  16808. * @param value Define the value to give to the uniform
  16809. * @return the material itself allowing "fluent" like uniform updates
  16810. */
  16811. setArray3(name: string, value: number[]): ShaderMaterial;
  16812. /**
  16813. * Set a vec4 array in the shader from a number array.
  16814. * @param name Define the name of the uniform as defined in the shader
  16815. * @param value Define the value to give to the uniform
  16816. * @return the material itself allowing "fluent" like uniform updates
  16817. */
  16818. setArray4(name: string, value: number[]): ShaderMaterial;
  16819. private _checkCache;
  16820. /**
  16821. * Specifies that the submesh is ready to be used
  16822. * @param mesh defines the mesh to check
  16823. * @param subMesh defines which submesh to check
  16824. * @param useInstances specifies that instances should be used
  16825. * @returns a boolean indicating that the submesh is ready or not
  16826. */
  16827. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16828. /**
  16829. * Checks if the material is ready to render the requested mesh
  16830. * @param mesh Define the mesh to render
  16831. * @param useInstances Define whether or not the material is used with instances
  16832. * @returns true if ready, otherwise false
  16833. */
  16834. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16835. /**
  16836. * Binds the world matrix to the material
  16837. * @param world defines the world transformation matrix
  16838. * @param effectOverride - If provided, use this effect instead of internal effect
  16839. */
  16840. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16841. /**
  16842. * Binds the submesh to this material by preparing the effect and shader to draw
  16843. * @param world defines the world transformation matrix
  16844. * @param mesh defines the mesh containing the submesh
  16845. * @param subMesh defines the submesh to bind the material to
  16846. */
  16847. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16848. /**
  16849. * Binds the material to the mesh
  16850. * @param world defines the world transformation matrix
  16851. * @param mesh defines the mesh to bind the material to
  16852. * @param effectOverride - If provided, use this effect instead of internal effect
  16853. */
  16854. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16855. protected _afterBind(mesh?: Mesh): void;
  16856. /**
  16857. * Gets the active textures from the material
  16858. * @returns an array of textures
  16859. */
  16860. getActiveTextures(): BaseTexture[];
  16861. /**
  16862. * Specifies if the material uses a texture
  16863. * @param texture defines the texture to check against the material
  16864. * @returns a boolean specifying if the material uses the texture
  16865. */
  16866. hasTexture(texture: BaseTexture): boolean;
  16867. /**
  16868. * Makes a duplicate of the material, and gives it a new name
  16869. * @param name defines the new name for the duplicated material
  16870. * @returns the cloned material
  16871. */
  16872. clone(name: string): ShaderMaterial;
  16873. /**
  16874. * Disposes the material
  16875. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16876. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16877. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16878. */
  16879. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16880. /**
  16881. * Serializes this material in a JSON representation
  16882. * @returns the serialized material object
  16883. */
  16884. serialize(): any;
  16885. /**
  16886. * Creates a shader material from parsed shader material data
  16887. * @param source defines the JSON represnetation of the material
  16888. * @param scene defines the hosting scene
  16889. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16890. * @returns a new material
  16891. */
  16892. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16893. /**
  16894. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16895. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16896. * @param url defines the url to load from
  16897. * @param scene defines the hosting scene
  16898. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16899. * @returns a promise that will resolve to the new ShaderMaterial
  16900. */
  16901. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16902. /**
  16903. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16904. * @param snippetId defines the snippet to load
  16905. * @param scene defines the hosting scene
  16906. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16907. * @returns a promise that will resolve to the new ShaderMaterial
  16908. */
  16909. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16910. }
  16911. }
  16912. declare module BABYLON {
  16913. /** @hidden */
  16914. export var colorPixelShader: {
  16915. name: string;
  16916. shader: string;
  16917. };
  16918. }
  16919. declare module BABYLON {
  16920. /** @hidden */
  16921. export var colorVertexShader: {
  16922. name: string;
  16923. shader: string;
  16924. };
  16925. }
  16926. declare module BABYLON {
  16927. /**
  16928. * Line mesh
  16929. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16930. */
  16931. export class LinesMesh extends Mesh {
  16932. /**
  16933. * If vertex color should be applied to the mesh
  16934. */
  16935. readonly useVertexColor?: boolean | undefined;
  16936. /**
  16937. * If vertex alpha should be applied to the mesh
  16938. */
  16939. readonly useVertexAlpha?: boolean | undefined;
  16940. /**
  16941. * Color of the line (Default: White)
  16942. */
  16943. color: Color3;
  16944. /**
  16945. * Alpha of the line (Default: 1)
  16946. */
  16947. alpha: number;
  16948. /**
  16949. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16950. * This margin is expressed in world space coordinates, so its value may vary.
  16951. * Default value is 0.1
  16952. */
  16953. intersectionThreshold: number;
  16954. private _colorShader;
  16955. private color4;
  16956. /**
  16957. * Creates a new LinesMesh
  16958. * @param name defines the name
  16959. * @param scene defines the hosting scene
  16960. * @param parent defines the parent mesh if any
  16961. * @param source defines the optional source LinesMesh used to clone data from
  16962. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16963. * When false, achieved by calling a clone(), also passing False.
  16964. * This will make creation of children, recursive.
  16965. * @param useVertexColor defines if this LinesMesh supports vertex color
  16966. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16967. */
  16968. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16969. /**
  16970. * If vertex color should be applied to the mesh
  16971. */
  16972. useVertexColor?: boolean | undefined,
  16973. /**
  16974. * If vertex alpha should be applied to the mesh
  16975. */
  16976. useVertexAlpha?: boolean | undefined);
  16977. private _addClipPlaneDefine;
  16978. private _removeClipPlaneDefine;
  16979. isReady(): boolean;
  16980. /**
  16981. * Returns the string "LineMesh"
  16982. */
  16983. getClassName(): string;
  16984. /**
  16985. * @hidden
  16986. */
  16987. get material(): Material;
  16988. /**
  16989. * @hidden
  16990. */
  16991. set material(value: Material);
  16992. /**
  16993. * @hidden
  16994. */
  16995. get checkCollisions(): boolean;
  16996. /** @hidden */
  16997. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16998. /** @hidden */
  16999. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17000. /**
  17001. * Disposes of the line mesh
  17002. * @param doNotRecurse If children should be disposed
  17003. */
  17004. dispose(doNotRecurse?: boolean): void;
  17005. /**
  17006. * Returns a new LineMesh object cloned from the current one.
  17007. */
  17008. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17009. /**
  17010. * Creates a new InstancedLinesMesh object from the mesh model.
  17011. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17012. * @param name defines the name of the new instance
  17013. * @returns a new InstancedLinesMesh
  17014. */
  17015. createInstance(name: string): InstancedLinesMesh;
  17016. }
  17017. /**
  17018. * Creates an instance based on a source LinesMesh
  17019. */
  17020. export class InstancedLinesMesh extends InstancedMesh {
  17021. /**
  17022. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17023. * This margin is expressed in world space coordinates, so its value may vary.
  17024. * Initilized with the intersectionThreshold value of the source LinesMesh
  17025. */
  17026. intersectionThreshold: number;
  17027. constructor(name: string, source: LinesMesh);
  17028. /**
  17029. * Returns the string "InstancedLinesMesh".
  17030. */
  17031. getClassName(): string;
  17032. }
  17033. }
  17034. declare module BABYLON {
  17035. /** @hidden */
  17036. export var linePixelShader: {
  17037. name: string;
  17038. shader: string;
  17039. };
  17040. }
  17041. declare module BABYLON {
  17042. /** @hidden */
  17043. export var lineVertexShader: {
  17044. name: string;
  17045. shader: string;
  17046. };
  17047. }
  17048. declare module BABYLON {
  17049. interface Scene {
  17050. /** @hidden */
  17051. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17052. }
  17053. interface AbstractMesh {
  17054. /**
  17055. * Gets the edgesRenderer associated with the mesh
  17056. */
  17057. edgesRenderer: Nullable<EdgesRenderer>;
  17058. }
  17059. interface LinesMesh {
  17060. /**
  17061. * Enables the edge rendering mode on the mesh.
  17062. * This mode makes the mesh edges visible
  17063. * @param epsilon defines the maximal distance between two angles to detect a face
  17064. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17065. * @returns the currentAbstractMesh
  17066. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17067. */
  17068. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17069. }
  17070. interface InstancedLinesMesh {
  17071. /**
  17072. * Enables the edge rendering mode on the mesh.
  17073. * This mode makes the mesh edges visible
  17074. * @param epsilon defines the maximal distance between two angles to detect a face
  17075. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17076. * @returns the current InstancedLinesMesh
  17077. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17078. */
  17079. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17080. }
  17081. /**
  17082. * Defines the minimum contract an Edges renderer should follow.
  17083. */
  17084. export interface IEdgesRenderer extends IDisposable {
  17085. /**
  17086. * Gets or sets a boolean indicating if the edgesRenderer is active
  17087. */
  17088. isEnabled: boolean;
  17089. /**
  17090. * Renders the edges of the attached mesh,
  17091. */
  17092. render(): void;
  17093. /**
  17094. * Checks wether or not the edges renderer is ready to render.
  17095. * @return true if ready, otherwise false.
  17096. */
  17097. isReady(): boolean;
  17098. /**
  17099. * List of instances to render in case the source mesh has instances
  17100. */
  17101. customInstances: SmartArray<Matrix>;
  17102. }
  17103. /**
  17104. * Defines the additional options of the edges renderer
  17105. */
  17106. export interface IEdgesRendererOptions {
  17107. /**
  17108. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17109. * If not defined, the default value is true
  17110. */
  17111. useAlternateEdgeFinder?: boolean;
  17112. /**
  17113. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17114. * If not defined, the default value is true.
  17115. * 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)
  17116. * This option is used only if useAlternateEdgeFinder = true
  17117. */
  17118. useFastVertexMerger?: boolean;
  17119. /**
  17120. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17121. * The default value is 1e-6
  17122. * This option is used only if useAlternateEdgeFinder = true
  17123. */
  17124. epsilonVertexMerge?: number;
  17125. /**
  17126. * 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
  17127. * 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.
  17128. * This option is used only if useAlternateEdgeFinder = true
  17129. */
  17130. applyTessellation?: boolean;
  17131. /**
  17132. * 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
  17133. * The default value is 1e-6
  17134. * This option is used only if useAlternateEdgeFinder = true
  17135. */
  17136. epsilonVertexAligned?: number;
  17137. }
  17138. /**
  17139. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17140. */
  17141. export class EdgesRenderer implements IEdgesRenderer {
  17142. /**
  17143. * Define the size of the edges with an orthographic camera
  17144. */
  17145. edgesWidthScalerForOrthographic: number;
  17146. /**
  17147. * Define the size of the edges with a perspective camera
  17148. */
  17149. edgesWidthScalerForPerspective: number;
  17150. protected _source: AbstractMesh;
  17151. protected _linesPositions: number[];
  17152. protected _linesNormals: number[];
  17153. protected _linesIndices: number[];
  17154. protected _epsilon: number;
  17155. protected _indicesCount: number;
  17156. protected _lineShader: ShaderMaterial;
  17157. protected _ib: DataBuffer;
  17158. protected _buffers: {
  17159. [key: string]: Nullable<VertexBuffer>;
  17160. };
  17161. protected _buffersForInstances: {
  17162. [key: string]: Nullable<VertexBuffer>;
  17163. };
  17164. protected _checkVerticesInsteadOfIndices: boolean;
  17165. protected _options: Nullable<IEdgesRendererOptions>;
  17166. private _meshRebuildObserver;
  17167. private _meshDisposeObserver;
  17168. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17169. isEnabled: boolean;
  17170. /**
  17171. * List of instances to render in case the source mesh has instances
  17172. */
  17173. customInstances: SmartArray<Matrix>;
  17174. private static GetShader;
  17175. /**
  17176. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17177. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17178. * @param source Mesh used to create edges
  17179. * @param epsilon sum of angles in adjacency to check for edge
  17180. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17181. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17182. * @param options The options to apply when generating the edges
  17183. */
  17184. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17185. protected _prepareRessources(): void;
  17186. /** @hidden */
  17187. _rebuild(): void;
  17188. /**
  17189. * Releases the required resources for the edges renderer
  17190. */
  17191. dispose(): void;
  17192. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17193. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17194. /**
  17195. * Checks if the pair of p0 and p1 is en edge
  17196. * @param faceIndex
  17197. * @param edge
  17198. * @param faceNormals
  17199. * @param p0
  17200. * @param p1
  17201. * @private
  17202. */
  17203. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17204. /**
  17205. * push line into the position, normal and index buffer
  17206. * @protected
  17207. */
  17208. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17209. /**
  17210. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17211. */
  17212. private _tessellateTriangle;
  17213. private _generateEdgesLinesAlternate;
  17214. /**
  17215. * Generates lines edges from adjacencjes
  17216. * @private
  17217. */
  17218. _generateEdgesLines(): void;
  17219. /**
  17220. * Checks wether or not the edges renderer is ready to render.
  17221. * @return true if ready, otherwise false.
  17222. */
  17223. isReady(): boolean;
  17224. /**
  17225. * Renders the edges of the attached mesh,
  17226. */
  17227. render(): void;
  17228. }
  17229. /**
  17230. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17231. */
  17232. export class LineEdgesRenderer extends EdgesRenderer {
  17233. /**
  17234. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17235. * @param source LineMesh used to generate edges
  17236. * @param epsilon not important (specified angle for edge detection)
  17237. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17238. */
  17239. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17240. /**
  17241. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17242. */
  17243. _generateEdgesLines(): void;
  17244. }
  17245. }
  17246. declare module BABYLON {
  17247. /**
  17248. * This represents the object necessary to create a rendering group.
  17249. * This is exclusively used and created by the rendering manager.
  17250. * To modify the behavior, you use the available helpers in your scene or meshes.
  17251. * @hidden
  17252. */
  17253. export class RenderingGroup {
  17254. index: number;
  17255. private static _zeroVector;
  17256. private _scene;
  17257. private _opaqueSubMeshes;
  17258. private _transparentSubMeshes;
  17259. private _alphaTestSubMeshes;
  17260. private _depthOnlySubMeshes;
  17261. private _particleSystems;
  17262. private _spriteManagers;
  17263. private _opaqueSortCompareFn;
  17264. private _alphaTestSortCompareFn;
  17265. private _transparentSortCompareFn;
  17266. private _renderOpaque;
  17267. private _renderAlphaTest;
  17268. private _renderTransparent;
  17269. /** @hidden */
  17270. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17271. onBeforeTransparentRendering: () => void;
  17272. /**
  17273. * Set the opaque sort comparison function.
  17274. * If null the sub meshes will be render in the order they were created
  17275. */
  17276. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17277. /**
  17278. * Set the alpha test sort comparison function.
  17279. * If null the sub meshes will be render in the order they were created
  17280. */
  17281. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17282. /**
  17283. * Set the transparent sort comparison function.
  17284. * If null the sub meshes will be render in the order they were created
  17285. */
  17286. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17287. /**
  17288. * Creates a new rendering group.
  17289. * @param index The rendering group index
  17290. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17291. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17292. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17293. */
  17294. 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>);
  17295. /**
  17296. * Render all the sub meshes contained in the group.
  17297. * @param customRenderFunction Used to override the default render behaviour of the group.
  17298. * @returns true if rendered some submeshes.
  17299. */
  17300. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17301. /**
  17302. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17303. * @param subMeshes The submeshes to render
  17304. */
  17305. private renderOpaqueSorted;
  17306. /**
  17307. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17308. * @param subMeshes The submeshes to render
  17309. */
  17310. private renderAlphaTestSorted;
  17311. /**
  17312. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17313. * @param subMeshes The submeshes to render
  17314. */
  17315. private renderTransparentSorted;
  17316. /**
  17317. * Renders the submeshes in a specified order.
  17318. * @param subMeshes The submeshes to sort before render
  17319. * @param sortCompareFn The comparison function use to sort
  17320. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17321. * @param transparent Specifies to activate blending if true
  17322. */
  17323. private static renderSorted;
  17324. /**
  17325. * Renders the submeshes in the order they were dispatched (no sort applied).
  17326. * @param subMeshes The submeshes to render
  17327. */
  17328. private static renderUnsorted;
  17329. /**
  17330. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17331. * are rendered back to front if in the same alpha index.
  17332. *
  17333. * @param a The first submesh
  17334. * @param b The second submesh
  17335. * @returns The result of the comparison
  17336. */
  17337. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17338. /**
  17339. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17340. * are rendered back to front.
  17341. *
  17342. * @param a The first submesh
  17343. * @param b The second submesh
  17344. * @returns The result of the comparison
  17345. */
  17346. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17347. /**
  17348. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17349. * are rendered front to back (prevent overdraw).
  17350. *
  17351. * @param a The first submesh
  17352. * @param b The second submesh
  17353. * @returns The result of the comparison
  17354. */
  17355. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17356. /**
  17357. * Resets the different lists of submeshes to prepare a new frame.
  17358. */
  17359. prepare(): void;
  17360. dispose(): void;
  17361. /**
  17362. * Inserts the submesh in its correct queue depending on its material.
  17363. * @param subMesh The submesh to dispatch
  17364. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17365. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17366. */
  17367. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17368. dispatchSprites(spriteManager: ISpriteManager): void;
  17369. dispatchParticles(particleSystem: IParticleSystem): void;
  17370. private _renderParticles;
  17371. private _renderSprites;
  17372. }
  17373. }
  17374. declare module BABYLON {
  17375. /**
  17376. * Interface describing the different options available in the rendering manager
  17377. * regarding Auto Clear between groups.
  17378. */
  17379. export interface IRenderingManagerAutoClearSetup {
  17380. /**
  17381. * Defines whether or not autoclear is enable.
  17382. */
  17383. autoClear: boolean;
  17384. /**
  17385. * Defines whether or not to autoclear the depth buffer.
  17386. */
  17387. depth: boolean;
  17388. /**
  17389. * Defines whether or not to autoclear the stencil buffer.
  17390. */
  17391. stencil: boolean;
  17392. }
  17393. /**
  17394. * This class is used by the onRenderingGroupObservable
  17395. */
  17396. export class RenderingGroupInfo {
  17397. /**
  17398. * The Scene that being rendered
  17399. */
  17400. scene: Scene;
  17401. /**
  17402. * The camera currently used for the rendering pass
  17403. */
  17404. camera: Nullable<Camera>;
  17405. /**
  17406. * The ID of the renderingGroup being processed
  17407. */
  17408. renderingGroupId: number;
  17409. }
  17410. /**
  17411. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17412. * It is enable to manage the different groups as well as the different necessary sort functions.
  17413. * This should not be used directly aside of the few static configurations
  17414. */
  17415. export class RenderingManager {
  17416. /**
  17417. * The max id used for rendering groups (not included)
  17418. */
  17419. static MAX_RENDERINGGROUPS: number;
  17420. /**
  17421. * The min id used for rendering groups (included)
  17422. */
  17423. static MIN_RENDERINGGROUPS: number;
  17424. /**
  17425. * Used to globally prevent autoclearing scenes.
  17426. */
  17427. static AUTOCLEAR: boolean;
  17428. /**
  17429. * @hidden
  17430. */
  17431. _useSceneAutoClearSetup: boolean;
  17432. private _scene;
  17433. private _renderingGroups;
  17434. private _depthStencilBufferAlreadyCleaned;
  17435. private _autoClearDepthStencil;
  17436. private _customOpaqueSortCompareFn;
  17437. private _customAlphaTestSortCompareFn;
  17438. private _customTransparentSortCompareFn;
  17439. private _renderingGroupInfo;
  17440. /**
  17441. * Instantiates a new rendering group for a particular scene
  17442. * @param scene Defines the scene the groups belongs to
  17443. */
  17444. constructor(scene: Scene);
  17445. private _clearDepthStencilBuffer;
  17446. /**
  17447. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17448. * @hidden
  17449. */
  17450. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17451. /**
  17452. * Resets the different information of the group to prepare a new frame
  17453. * @hidden
  17454. */
  17455. reset(): void;
  17456. /**
  17457. * Dispose and release the group and its associated resources.
  17458. * @hidden
  17459. */
  17460. dispose(): void;
  17461. /**
  17462. * Clear the info related to rendering groups preventing retention points during dispose.
  17463. */
  17464. freeRenderingGroups(): void;
  17465. private _prepareRenderingGroup;
  17466. /**
  17467. * Add a sprite manager to the rendering manager in order to render it this frame.
  17468. * @param spriteManager Define the sprite manager to render
  17469. */
  17470. dispatchSprites(spriteManager: ISpriteManager): void;
  17471. /**
  17472. * Add a particle system to the rendering manager in order to render it this frame.
  17473. * @param particleSystem Define the particle system to render
  17474. */
  17475. dispatchParticles(particleSystem: IParticleSystem): void;
  17476. /**
  17477. * Add a submesh to the manager in order to render it this frame
  17478. * @param subMesh The submesh to dispatch
  17479. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17480. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17481. */
  17482. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17483. /**
  17484. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17485. * This allowed control for front to back rendering or reversly depending of the special needs.
  17486. *
  17487. * @param renderingGroupId The rendering group id corresponding to its index
  17488. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17489. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17490. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17491. */
  17492. 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;
  17493. /**
  17494. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17495. *
  17496. * @param renderingGroupId The rendering group id corresponding to its index
  17497. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17498. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17499. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17500. */
  17501. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17502. /**
  17503. * Gets the current auto clear configuration for one rendering group of the rendering
  17504. * manager.
  17505. * @param index the rendering group index to get the information for
  17506. * @returns The auto clear setup for the requested rendering group
  17507. */
  17508. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17509. }
  17510. }
  17511. declare module BABYLON {
  17512. /**
  17513. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17514. */
  17515. export interface ICustomShaderOptions {
  17516. /**
  17517. * Gets or sets the custom shader name to use
  17518. */
  17519. shaderName: string;
  17520. /**
  17521. * The list of attribute names used in the shader
  17522. */
  17523. attributes?: string[];
  17524. /**
  17525. * The list of unifrom names used in the shader
  17526. */
  17527. uniforms?: string[];
  17528. /**
  17529. * The list of sampler names used in the shader
  17530. */
  17531. samplers?: string[];
  17532. /**
  17533. * The list of defines used in the shader
  17534. */
  17535. defines?: string[];
  17536. }
  17537. /**
  17538. * Interface to implement to create a shadow generator compatible with BJS.
  17539. */
  17540. export interface IShadowGenerator {
  17541. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17542. id: string;
  17543. /**
  17544. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17545. * @returns The render target texture if present otherwise, null
  17546. */
  17547. getShadowMap(): Nullable<RenderTargetTexture>;
  17548. /**
  17549. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17550. * @param subMesh The submesh we want to render in the shadow map
  17551. * @param useInstances Defines wether will draw in the map using instances
  17552. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17553. * @returns true if ready otherwise, false
  17554. */
  17555. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17556. /**
  17557. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17558. * @param defines Defines of the material we want to update
  17559. * @param lightIndex Index of the light in the enabled light list of the material
  17560. */
  17561. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17562. /**
  17563. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17564. * defined in the generator but impacting the effect).
  17565. * It implies the unifroms available on the materials are the standard BJS ones.
  17566. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17567. * @param effect The effect we are binfing the information for
  17568. */
  17569. bindShadowLight(lightIndex: string, effect: Effect): void;
  17570. /**
  17571. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17572. * (eq to shadow prjection matrix * light transform matrix)
  17573. * @returns The transform matrix used to create the shadow map
  17574. */
  17575. getTransformMatrix(): Matrix;
  17576. /**
  17577. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17578. * Cube and 2D textures for instance.
  17579. */
  17580. recreateShadowMap(): void;
  17581. /**
  17582. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17583. * @param onCompiled Callback triggered at the and of the effects compilation
  17584. * @param options Sets of optional options forcing the compilation with different modes
  17585. */
  17586. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17587. useInstances: boolean;
  17588. }>): void;
  17589. /**
  17590. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17591. * @param options Sets of optional options forcing the compilation with different modes
  17592. * @returns A promise that resolves when the compilation completes
  17593. */
  17594. forceCompilationAsync(options?: Partial<{
  17595. useInstances: boolean;
  17596. }>): Promise<void>;
  17597. /**
  17598. * Serializes the shadow generator setup to a json object.
  17599. * @returns The serialized JSON object
  17600. */
  17601. serialize(): any;
  17602. /**
  17603. * Disposes the Shadow map and related Textures and effects.
  17604. */
  17605. dispose(): void;
  17606. }
  17607. /**
  17608. * Default implementation IShadowGenerator.
  17609. * This is the main object responsible of generating shadows in the framework.
  17610. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17611. */
  17612. export class ShadowGenerator implements IShadowGenerator {
  17613. /**
  17614. * Name of the shadow generator class
  17615. */
  17616. static CLASSNAME: string;
  17617. /**
  17618. * Shadow generator mode None: no filtering applied.
  17619. */
  17620. static readonly FILTER_NONE: number;
  17621. /**
  17622. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17623. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17624. */
  17625. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17626. /**
  17627. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17628. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17629. */
  17630. static readonly FILTER_POISSONSAMPLING: number;
  17631. /**
  17632. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17633. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17634. */
  17635. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17636. /**
  17637. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17638. * edge artifacts on steep falloff.
  17639. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17640. */
  17641. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17642. /**
  17643. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17644. * edge artifacts on steep falloff.
  17645. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17646. */
  17647. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17648. /**
  17649. * Shadow generator mode PCF: Percentage Closer Filtering
  17650. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17651. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17652. */
  17653. static readonly FILTER_PCF: number;
  17654. /**
  17655. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17656. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17657. * Contact Hardening
  17658. */
  17659. static readonly FILTER_PCSS: number;
  17660. /**
  17661. * Reserved for PCF and PCSS
  17662. * Highest Quality.
  17663. *
  17664. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17665. *
  17666. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17667. */
  17668. static readonly QUALITY_HIGH: number;
  17669. /**
  17670. * Reserved for PCF and PCSS
  17671. * Good tradeoff for quality/perf cross devices
  17672. *
  17673. * Execute PCF on a 3*3 kernel.
  17674. *
  17675. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17676. */
  17677. static readonly QUALITY_MEDIUM: number;
  17678. /**
  17679. * Reserved for PCF and PCSS
  17680. * The lowest quality but the fastest.
  17681. *
  17682. * Execute PCF on a 1*1 kernel.
  17683. *
  17684. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17685. */
  17686. static readonly QUALITY_LOW: number;
  17687. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17688. id: string;
  17689. /** Gets or sets the custom shader name to use */
  17690. customShaderOptions: ICustomShaderOptions;
  17691. /**
  17692. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17693. */
  17694. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17695. /**
  17696. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17697. */
  17698. onAfterShadowMapRenderObservable: Observable<Effect>;
  17699. /**
  17700. * Observable triggered before a mesh is rendered in the shadow map.
  17701. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17702. */
  17703. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17704. /**
  17705. * Observable triggered after a mesh is rendered in the shadow map.
  17706. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17707. */
  17708. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17709. protected _bias: number;
  17710. /**
  17711. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17712. */
  17713. get bias(): number;
  17714. /**
  17715. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17716. */
  17717. set bias(bias: number);
  17718. protected _normalBias: number;
  17719. /**
  17720. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17721. */
  17722. get normalBias(): number;
  17723. /**
  17724. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17725. */
  17726. set normalBias(normalBias: number);
  17727. protected _blurBoxOffset: number;
  17728. /**
  17729. * Gets the blur box offset: offset applied during the blur pass.
  17730. * Only useful if useKernelBlur = false
  17731. */
  17732. get blurBoxOffset(): number;
  17733. /**
  17734. * Sets the blur box offset: offset applied during the blur pass.
  17735. * Only useful if useKernelBlur = false
  17736. */
  17737. set blurBoxOffset(value: number);
  17738. protected _blurScale: number;
  17739. /**
  17740. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17741. * 2 means half of the size.
  17742. */
  17743. get blurScale(): number;
  17744. /**
  17745. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17746. * 2 means half of the size.
  17747. */
  17748. set blurScale(value: number);
  17749. protected _blurKernel: number;
  17750. /**
  17751. * Gets the blur kernel: kernel size of the blur pass.
  17752. * Only useful if useKernelBlur = true
  17753. */
  17754. get blurKernel(): number;
  17755. /**
  17756. * Sets the blur kernel: kernel size of the blur pass.
  17757. * Only useful if useKernelBlur = true
  17758. */
  17759. set blurKernel(value: number);
  17760. protected _useKernelBlur: boolean;
  17761. /**
  17762. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17763. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17764. */
  17765. get useKernelBlur(): boolean;
  17766. /**
  17767. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17768. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17769. */
  17770. set useKernelBlur(value: boolean);
  17771. protected _depthScale: number;
  17772. /**
  17773. * Gets the depth scale used in ESM mode.
  17774. */
  17775. get depthScale(): number;
  17776. /**
  17777. * Sets the depth scale used in ESM mode.
  17778. * This can override the scale stored on the light.
  17779. */
  17780. set depthScale(value: number);
  17781. protected _validateFilter(filter: number): number;
  17782. protected _filter: number;
  17783. /**
  17784. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17785. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17786. */
  17787. get filter(): number;
  17788. /**
  17789. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17790. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17791. */
  17792. set filter(value: number);
  17793. /**
  17794. * Gets if the current filter is set to Poisson Sampling.
  17795. */
  17796. get usePoissonSampling(): boolean;
  17797. /**
  17798. * Sets the current filter to Poisson Sampling.
  17799. */
  17800. set usePoissonSampling(value: boolean);
  17801. /**
  17802. * Gets if the current filter is set to ESM.
  17803. */
  17804. get useExponentialShadowMap(): boolean;
  17805. /**
  17806. * Sets the current filter is to ESM.
  17807. */
  17808. set useExponentialShadowMap(value: boolean);
  17809. /**
  17810. * Gets if the current filter is set to filtered ESM.
  17811. */
  17812. get useBlurExponentialShadowMap(): boolean;
  17813. /**
  17814. * Gets if the current filter is set to filtered ESM.
  17815. */
  17816. set useBlurExponentialShadowMap(value: boolean);
  17817. /**
  17818. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17819. * exponential to prevent steep falloff artifacts).
  17820. */
  17821. get useCloseExponentialShadowMap(): boolean;
  17822. /**
  17823. * Sets the current filter to "close ESM" (using the inverse of the
  17824. * exponential to prevent steep falloff artifacts).
  17825. */
  17826. set useCloseExponentialShadowMap(value: boolean);
  17827. /**
  17828. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17829. * exponential to prevent steep falloff artifacts).
  17830. */
  17831. get useBlurCloseExponentialShadowMap(): boolean;
  17832. /**
  17833. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17834. * exponential to prevent steep falloff artifacts).
  17835. */
  17836. set useBlurCloseExponentialShadowMap(value: boolean);
  17837. /**
  17838. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17839. */
  17840. get usePercentageCloserFiltering(): boolean;
  17841. /**
  17842. * Sets the current filter to "PCF" (percentage closer filtering).
  17843. */
  17844. set usePercentageCloserFiltering(value: boolean);
  17845. protected _filteringQuality: number;
  17846. /**
  17847. * Gets the PCF or PCSS Quality.
  17848. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17849. */
  17850. get filteringQuality(): number;
  17851. /**
  17852. * Sets the PCF or PCSS Quality.
  17853. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17854. */
  17855. set filteringQuality(filteringQuality: number);
  17856. /**
  17857. * Gets if the current filter is set to "PCSS" (contact hardening).
  17858. */
  17859. get useContactHardeningShadow(): boolean;
  17860. /**
  17861. * Sets the current filter to "PCSS" (contact hardening).
  17862. */
  17863. set useContactHardeningShadow(value: boolean);
  17864. protected _contactHardeningLightSizeUVRatio: number;
  17865. /**
  17866. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17867. * Using a ratio helps keeping shape stability independently of the map size.
  17868. *
  17869. * It does not account for the light projection as it was having too much
  17870. * instability during the light setup or during light position changes.
  17871. *
  17872. * Only valid if useContactHardeningShadow is true.
  17873. */
  17874. get contactHardeningLightSizeUVRatio(): number;
  17875. /**
  17876. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17877. * Using a ratio helps keeping shape stability independently of the map size.
  17878. *
  17879. * It does not account for the light projection as it was having too much
  17880. * instability during the light setup or during light position changes.
  17881. *
  17882. * Only valid if useContactHardeningShadow is true.
  17883. */
  17884. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17885. protected _darkness: number;
  17886. /** Gets or sets the actual darkness of a shadow */
  17887. get darkness(): number;
  17888. set darkness(value: number);
  17889. /**
  17890. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17891. * 0 means strongest and 1 would means no shadow.
  17892. * @returns the darkness.
  17893. */
  17894. getDarkness(): number;
  17895. /**
  17896. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17897. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17898. * @returns the shadow generator allowing fluent coding.
  17899. */
  17900. setDarkness(darkness: number): ShadowGenerator;
  17901. protected _transparencyShadow: boolean;
  17902. /** Gets or sets the ability to have transparent shadow */
  17903. get transparencyShadow(): boolean;
  17904. set transparencyShadow(value: boolean);
  17905. /**
  17906. * Sets the ability to have transparent shadow (boolean).
  17907. * @param transparent True if transparent else False
  17908. * @returns the shadow generator allowing fluent coding
  17909. */
  17910. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17911. /**
  17912. * Enables or disables shadows with varying strength based on the transparency
  17913. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17914. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17915. * mesh.visibility * alphaTexture.a
  17916. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17917. */
  17918. enableSoftTransparentShadow: boolean;
  17919. protected _shadowMap: Nullable<RenderTargetTexture>;
  17920. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17921. /**
  17922. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17923. * @returns The render target texture if present otherwise, null
  17924. */
  17925. getShadowMap(): Nullable<RenderTargetTexture>;
  17926. /**
  17927. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17928. * @returns The render target texture if the shadow map is present otherwise, null
  17929. */
  17930. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17931. /**
  17932. * Gets the class name of that object
  17933. * @returns "ShadowGenerator"
  17934. */
  17935. getClassName(): string;
  17936. /**
  17937. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17938. * @param mesh Mesh to add
  17939. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17940. * @returns the Shadow Generator itself
  17941. */
  17942. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17943. /**
  17944. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17945. * @param mesh Mesh to remove
  17946. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17947. * @returns the Shadow Generator itself
  17948. */
  17949. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17950. /**
  17951. * Controls the extent to which the shadows fade out at the edge of the frustum
  17952. */
  17953. frustumEdgeFalloff: number;
  17954. protected _light: IShadowLight;
  17955. /**
  17956. * Returns the associated light object.
  17957. * @returns the light generating the shadow
  17958. */
  17959. getLight(): IShadowLight;
  17960. /**
  17961. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17962. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17963. * It might on the other hand introduce peter panning.
  17964. */
  17965. forceBackFacesOnly: boolean;
  17966. protected _scene: Scene;
  17967. protected _lightDirection: Vector3;
  17968. protected _effect: Effect;
  17969. protected _viewMatrix: Matrix;
  17970. protected _projectionMatrix: Matrix;
  17971. protected _transformMatrix: Matrix;
  17972. protected _cachedPosition: Vector3;
  17973. protected _cachedDirection: Vector3;
  17974. protected _cachedDefines: string;
  17975. protected _currentRenderID: number;
  17976. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17977. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17978. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17979. protected _blurPostProcesses: PostProcess[];
  17980. protected _mapSize: number;
  17981. protected _currentFaceIndex: number;
  17982. protected _currentFaceIndexCache: number;
  17983. protected _textureType: number;
  17984. protected _defaultTextureMatrix: Matrix;
  17985. protected _storedUniqueId: Nullable<number>;
  17986. /** @hidden */
  17987. static _SceneComponentInitialization: (scene: Scene) => void;
  17988. /**
  17989. * Gets or sets the size of the texture what stores the shadows
  17990. */
  17991. get mapSize(): number;
  17992. set mapSize(size: number);
  17993. /**
  17994. * Creates a ShadowGenerator object.
  17995. * A ShadowGenerator is the required tool to use the shadows.
  17996. * Each light casting shadows needs to use its own ShadowGenerator.
  17997. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17998. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17999. * @param light The light object generating the shadows.
  18000. * @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.
  18001. */
  18002. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18003. protected _initializeGenerator(): void;
  18004. protected _createTargetRenderTexture(): void;
  18005. protected _initializeShadowMap(): void;
  18006. protected _initializeBlurRTTAndPostProcesses(): void;
  18007. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18008. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18009. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18010. protected _applyFilterValues(): void;
  18011. /**
  18012. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18013. * @param onCompiled Callback triggered at the and of the effects compilation
  18014. * @param options Sets of optional options forcing the compilation with different modes
  18015. */
  18016. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18017. useInstances: boolean;
  18018. }>): void;
  18019. /**
  18020. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18021. * @param options Sets of optional options forcing the compilation with different modes
  18022. * @returns A promise that resolves when the compilation completes
  18023. */
  18024. forceCompilationAsync(options?: Partial<{
  18025. useInstances: boolean;
  18026. }>): Promise<void>;
  18027. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18028. private _prepareShadowDefines;
  18029. /**
  18030. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18031. * @param subMesh The submesh we want to render in the shadow map
  18032. * @param useInstances Defines wether will draw in the map using instances
  18033. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18034. * @returns true if ready otherwise, false
  18035. */
  18036. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18037. /**
  18038. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18039. * @param defines Defines of the material we want to update
  18040. * @param lightIndex Index of the light in the enabled light list of the material
  18041. */
  18042. prepareDefines(defines: any, lightIndex: number): void;
  18043. /**
  18044. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18045. * defined in the generator but impacting the effect).
  18046. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18047. * @param effect The effect we are binfing the information for
  18048. */
  18049. bindShadowLight(lightIndex: string, effect: Effect): void;
  18050. /**
  18051. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18052. * (eq to shadow prjection matrix * light transform matrix)
  18053. * @returns The transform matrix used to create the shadow map
  18054. */
  18055. getTransformMatrix(): Matrix;
  18056. /**
  18057. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18058. * Cube and 2D textures for instance.
  18059. */
  18060. recreateShadowMap(): void;
  18061. protected _disposeBlurPostProcesses(): void;
  18062. protected _disposeRTTandPostProcesses(): void;
  18063. /**
  18064. * Disposes the ShadowGenerator.
  18065. * Returns nothing.
  18066. */
  18067. dispose(): void;
  18068. /**
  18069. * Serializes the shadow generator setup to a json object.
  18070. * @returns The serialized JSON object
  18071. */
  18072. serialize(): any;
  18073. /**
  18074. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18075. * @param parsedShadowGenerator The JSON object to parse
  18076. * @param scene The scene to create the shadow map for
  18077. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18078. * @returns The parsed shadow generator
  18079. */
  18080. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18081. }
  18082. }
  18083. declare module BABYLON {
  18084. /**
  18085. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18086. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18087. * 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.
  18088. */
  18089. export abstract class Light extends Node {
  18090. /**
  18091. * Falloff Default: light is falling off following the material specification:
  18092. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18093. */
  18094. static readonly FALLOFF_DEFAULT: number;
  18095. /**
  18096. * Falloff Physical: light is falling off following the inverse squared distance law.
  18097. */
  18098. static readonly FALLOFF_PHYSICAL: number;
  18099. /**
  18100. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18101. * to enhance interoperability with other engines.
  18102. */
  18103. static readonly FALLOFF_GLTF: number;
  18104. /**
  18105. * Falloff Standard: light is falling off like in the standard material
  18106. * to enhance interoperability with other materials.
  18107. */
  18108. static readonly FALLOFF_STANDARD: number;
  18109. /**
  18110. * If every light affecting the material is in this lightmapMode,
  18111. * material.lightmapTexture adds or multiplies
  18112. * (depends on material.useLightmapAsShadowmap)
  18113. * after every other light calculations.
  18114. */
  18115. static readonly LIGHTMAP_DEFAULT: number;
  18116. /**
  18117. * material.lightmapTexture as only diffuse lighting from this light
  18118. * adds only specular lighting from this light
  18119. * adds dynamic shadows
  18120. */
  18121. static readonly LIGHTMAP_SPECULAR: number;
  18122. /**
  18123. * material.lightmapTexture as only lighting
  18124. * no light calculation from this light
  18125. * only adds dynamic shadows from this light
  18126. */
  18127. static readonly LIGHTMAP_SHADOWSONLY: number;
  18128. /**
  18129. * Each light type uses the default quantity according to its type:
  18130. * point/spot lights use luminous intensity
  18131. * directional lights use illuminance
  18132. */
  18133. static readonly INTENSITYMODE_AUTOMATIC: number;
  18134. /**
  18135. * lumen (lm)
  18136. */
  18137. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18138. /**
  18139. * candela (lm/sr)
  18140. */
  18141. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18142. /**
  18143. * lux (lm/m^2)
  18144. */
  18145. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18146. /**
  18147. * nit (cd/m^2)
  18148. */
  18149. static readonly INTENSITYMODE_LUMINANCE: number;
  18150. /**
  18151. * Light type const id of the point light.
  18152. */
  18153. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18154. /**
  18155. * Light type const id of the directional light.
  18156. */
  18157. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18158. /**
  18159. * Light type const id of the spot light.
  18160. */
  18161. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18162. /**
  18163. * Light type const id of the hemispheric light.
  18164. */
  18165. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18166. /**
  18167. * Diffuse gives the basic color to an object.
  18168. */
  18169. diffuse: Color3;
  18170. /**
  18171. * Specular produces a highlight color on an object.
  18172. * Note: This is note affecting PBR materials.
  18173. */
  18174. specular: Color3;
  18175. /**
  18176. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18177. * falling off base on range or angle.
  18178. * This can be set to any values in Light.FALLOFF_x.
  18179. *
  18180. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18181. * other types of materials.
  18182. */
  18183. falloffType: number;
  18184. /**
  18185. * Strength of the light.
  18186. * Note: By default it is define in the framework own unit.
  18187. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18188. */
  18189. intensity: number;
  18190. private _range;
  18191. protected _inverseSquaredRange: number;
  18192. /**
  18193. * Defines how far from the source the light is impacting in scene units.
  18194. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18195. */
  18196. get range(): number;
  18197. /**
  18198. * Defines how far from the source the light is impacting in scene units.
  18199. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18200. */
  18201. set range(value: number);
  18202. /**
  18203. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18204. * of light.
  18205. */
  18206. private _photometricScale;
  18207. private _intensityMode;
  18208. /**
  18209. * Gets the photometric scale used to interpret the intensity.
  18210. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18211. */
  18212. get intensityMode(): number;
  18213. /**
  18214. * Sets the photometric scale used to interpret the intensity.
  18215. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18216. */
  18217. set intensityMode(value: number);
  18218. private _radius;
  18219. /**
  18220. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18221. */
  18222. get radius(): number;
  18223. /**
  18224. * sets the light radius used by PBR Materials to simulate soft area lights.
  18225. */
  18226. set radius(value: number);
  18227. private _renderPriority;
  18228. /**
  18229. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18230. * exceeding the number allowed of the materials.
  18231. */
  18232. renderPriority: number;
  18233. private _shadowEnabled;
  18234. /**
  18235. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18236. * the current shadow generator.
  18237. */
  18238. get shadowEnabled(): boolean;
  18239. /**
  18240. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18241. * the current shadow generator.
  18242. */
  18243. set shadowEnabled(value: boolean);
  18244. private _includedOnlyMeshes;
  18245. /**
  18246. * Gets the only meshes impacted by this light.
  18247. */
  18248. get includedOnlyMeshes(): AbstractMesh[];
  18249. /**
  18250. * Sets the only meshes impacted by this light.
  18251. */
  18252. set includedOnlyMeshes(value: AbstractMesh[]);
  18253. private _excludedMeshes;
  18254. /**
  18255. * Gets the meshes not impacted by this light.
  18256. */
  18257. get excludedMeshes(): AbstractMesh[];
  18258. /**
  18259. * Sets the meshes not impacted by this light.
  18260. */
  18261. set excludedMeshes(value: AbstractMesh[]);
  18262. private _excludeWithLayerMask;
  18263. /**
  18264. * Gets the layer id use to find what meshes are not impacted by the light.
  18265. * Inactive if 0
  18266. */
  18267. get excludeWithLayerMask(): number;
  18268. /**
  18269. * Sets the layer id use to find what meshes are not impacted by the light.
  18270. * Inactive if 0
  18271. */
  18272. set excludeWithLayerMask(value: number);
  18273. private _includeOnlyWithLayerMask;
  18274. /**
  18275. * Gets the layer id use to find what meshes are impacted by the light.
  18276. * Inactive if 0
  18277. */
  18278. get includeOnlyWithLayerMask(): number;
  18279. /**
  18280. * Sets the layer id use to find what meshes are impacted by the light.
  18281. * Inactive if 0
  18282. */
  18283. set includeOnlyWithLayerMask(value: number);
  18284. private _lightmapMode;
  18285. /**
  18286. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18287. */
  18288. get lightmapMode(): number;
  18289. /**
  18290. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18291. */
  18292. set lightmapMode(value: number);
  18293. /**
  18294. * Shadow generator associted to the light.
  18295. * @hidden Internal use only.
  18296. */
  18297. _shadowGenerator: Nullable<IShadowGenerator>;
  18298. /**
  18299. * @hidden Internal use only.
  18300. */
  18301. _excludedMeshesIds: string[];
  18302. /**
  18303. * @hidden Internal use only.
  18304. */
  18305. _includedOnlyMeshesIds: string[];
  18306. /**
  18307. * The current light unifom buffer.
  18308. * @hidden Internal use only.
  18309. */
  18310. _uniformBuffer: UniformBuffer;
  18311. /** @hidden */
  18312. _renderId: number;
  18313. /**
  18314. * Creates a Light object in the scene.
  18315. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18316. * @param name The firendly name of the light
  18317. * @param scene The scene the light belongs too
  18318. */
  18319. constructor(name: string, scene: Scene);
  18320. protected abstract _buildUniformLayout(): void;
  18321. /**
  18322. * Sets the passed Effect "effect" with the Light information.
  18323. * @param effect The effect to update
  18324. * @param lightIndex The index of the light in the effect to update
  18325. * @returns The light
  18326. */
  18327. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18328. /**
  18329. * Sets the passed Effect "effect" with the Light textures.
  18330. * @param effect The effect to update
  18331. * @param lightIndex The index of the light in the effect to update
  18332. * @returns The light
  18333. */
  18334. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18335. /**
  18336. * Binds the lights information from the scene to the effect for the given mesh.
  18337. * @param lightIndex Light index
  18338. * @param scene The scene where the light belongs to
  18339. * @param effect The effect we are binding the data to
  18340. * @param useSpecular Defines if specular is supported
  18341. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18342. */
  18343. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18344. /**
  18345. * Sets the passed Effect "effect" with the Light information.
  18346. * @param effect The effect to update
  18347. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18348. * @returns The light
  18349. */
  18350. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18351. /**
  18352. * Returns the string "Light".
  18353. * @returns the class name
  18354. */
  18355. getClassName(): string;
  18356. /** @hidden */
  18357. readonly _isLight: boolean;
  18358. /**
  18359. * Converts the light information to a readable string for debug purpose.
  18360. * @param fullDetails Supports for multiple levels of logging within scene loading
  18361. * @returns the human readable light info
  18362. */
  18363. toString(fullDetails?: boolean): string;
  18364. /** @hidden */
  18365. protected _syncParentEnabledState(): void;
  18366. /**
  18367. * Set the enabled state of this node.
  18368. * @param value - the new enabled state
  18369. */
  18370. setEnabled(value: boolean): void;
  18371. /**
  18372. * Returns the Light associated shadow generator if any.
  18373. * @return the associated shadow generator.
  18374. */
  18375. getShadowGenerator(): Nullable<IShadowGenerator>;
  18376. /**
  18377. * Returns a Vector3, the absolute light position in the World.
  18378. * @returns the world space position of the light
  18379. */
  18380. getAbsolutePosition(): Vector3;
  18381. /**
  18382. * Specifies if the light will affect the passed mesh.
  18383. * @param mesh The mesh to test against the light
  18384. * @return true the mesh is affected otherwise, false.
  18385. */
  18386. canAffectMesh(mesh: AbstractMesh): boolean;
  18387. /**
  18388. * Sort function to order lights for rendering.
  18389. * @param a First Light object to compare to second.
  18390. * @param b Second Light object to compare first.
  18391. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18392. */
  18393. static CompareLightsPriority(a: Light, b: Light): number;
  18394. /**
  18395. * Releases resources associated with this node.
  18396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18398. */
  18399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18400. /**
  18401. * Returns the light type ID (integer).
  18402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18403. */
  18404. getTypeID(): number;
  18405. /**
  18406. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18407. * @returns the scaled intensity in intensity mode unit
  18408. */
  18409. getScaledIntensity(): number;
  18410. /**
  18411. * Returns a new Light object, named "name", from the current one.
  18412. * @param name The name of the cloned light
  18413. * @param newParent The parent of this light, if it has one
  18414. * @returns the new created light
  18415. */
  18416. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18417. /**
  18418. * Serializes the current light into a Serialization object.
  18419. * @returns the serialized object.
  18420. */
  18421. serialize(): any;
  18422. /**
  18423. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18424. * This new light is named "name" and added to the passed scene.
  18425. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18426. * @param name The friendly name of the light
  18427. * @param scene The scene the new light will belong to
  18428. * @returns the constructor function
  18429. */
  18430. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18431. /**
  18432. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18433. * @param parsedLight The JSON representation of the light
  18434. * @param scene The scene to create the parsed light in
  18435. * @returns the created light after parsing
  18436. */
  18437. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18438. private _hookArrayForExcluded;
  18439. private _hookArrayForIncludedOnly;
  18440. private _resyncMeshes;
  18441. /**
  18442. * Forces the meshes to update their light related information in their rendering used effects
  18443. * @hidden Internal Use Only
  18444. */
  18445. _markMeshesAsLightDirty(): void;
  18446. /**
  18447. * Recomputes the cached photometric scale if needed.
  18448. */
  18449. private _computePhotometricScale;
  18450. /**
  18451. * Returns the Photometric Scale according to the light type and intensity mode.
  18452. */
  18453. private _getPhotometricScale;
  18454. /**
  18455. * Reorder the light in the scene according to their defined priority.
  18456. * @hidden Internal Use Only
  18457. */
  18458. _reorderLightsInScene(): void;
  18459. /**
  18460. * Prepares the list of defines specific to the light type.
  18461. * @param defines the list of defines
  18462. * @param lightIndex defines the index of the light for the effect
  18463. */
  18464. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18465. }
  18466. }
  18467. declare module BABYLON {
  18468. /**
  18469. * Configuration needed for prepass-capable materials
  18470. */
  18471. export class PrePassConfiguration {
  18472. /**
  18473. * Previous world matrices of meshes carrying this material
  18474. * Used for computing velocity
  18475. */
  18476. previousWorldMatrices: {
  18477. [index: number]: Matrix;
  18478. };
  18479. /**
  18480. * Previous view project matrix
  18481. * Used for computing velocity
  18482. */
  18483. previousViewProjection: Matrix;
  18484. /**
  18485. * Previous bones of meshes carrying this material
  18486. * Used for computing velocity
  18487. */
  18488. previousBones: {
  18489. [index: number]: Float32Array;
  18490. };
  18491. /**
  18492. * Add the required uniforms to the current list.
  18493. * @param uniforms defines the current uniform list.
  18494. */
  18495. static AddUniforms(uniforms: string[]): void;
  18496. /**
  18497. * Add the required samplers to the current list.
  18498. * @param samplers defines the current sampler list.
  18499. */
  18500. static AddSamplers(samplers: string[]): void;
  18501. /**
  18502. * Binds the material data.
  18503. * @param effect defines the effect to update
  18504. * @param scene defines the scene the material belongs to.
  18505. * @param mesh The mesh
  18506. * @param world World matrix of this mesh
  18507. * @param isFrozen Is the material frozen
  18508. */
  18509. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18510. }
  18511. }
  18512. declare module BABYLON {
  18513. /**
  18514. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18515. * This is the base of the follow, arc rotate cameras and Free camera
  18516. * @see https://doc.babylonjs.com/features/cameras
  18517. */
  18518. export class TargetCamera extends Camera {
  18519. private static _RigCamTransformMatrix;
  18520. private static _TargetTransformMatrix;
  18521. private static _TargetFocalPoint;
  18522. private _tmpUpVector;
  18523. private _tmpTargetVector;
  18524. /**
  18525. * Define the current direction the camera is moving to
  18526. */
  18527. cameraDirection: Vector3;
  18528. /**
  18529. * Define the current rotation the camera is rotating to
  18530. */
  18531. cameraRotation: Vector2;
  18532. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18533. ignoreParentScaling: boolean;
  18534. /**
  18535. * When set, the up vector of the camera will be updated by the rotation of the camera
  18536. */
  18537. updateUpVectorFromRotation: boolean;
  18538. private _tmpQuaternion;
  18539. /**
  18540. * Define the current rotation of the camera
  18541. */
  18542. rotation: Vector3;
  18543. /**
  18544. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18545. */
  18546. rotationQuaternion: Quaternion;
  18547. /**
  18548. * Define the current speed of the camera
  18549. */
  18550. speed: number;
  18551. /**
  18552. * Add constraint to the camera to prevent it to move freely in all directions and
  18553. * around all axis.
  18554. */
  18555. noRotationConstraint: boolean;
  18556. /**
  18557. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18558. * panning
  18559. */
  18560. invertRotation: boolean;
  18561. /**
  18562. * Speed multiplier for inverse camera panning
  18563. */
  18564. inverseRotationSpeed: number;
  18565. /**
  18566. * Define the current target of the camera as an object or a position.
  18567. */
  18568. lockedTarget: any;
  18569. /** @hidden */
  18570. _currentTarget: Vector3;
  18571. /** @hidden */
  18572. _initialFocalDistance: number;
  18573. /** @hidden */
  18574. _viewMatrix: Matrix;
  18575. /** @hidden */
  18576. _camMatrix: Matrix;
  18577. /** @hidden */
  18578. _cameraTransformMatrix: Matrix;
  18579. /** @hidden */
  18580. _cameraRotationMatrix: Matrix;
  18581. /** @hidden */
  18582. _referencePoint: Vector3;
  18583. /** @hidden */
  18584. _transformedReferencePoint: Vector3;
  18585. /** @hidden */
  18586. _reset: () => void;
  18587. private _defaultUp;
  18588. /**
  18589. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18590. * This is the base of the follow, arc rotate cameras and Free camera
  18591. * @see https://doc.babylonjs.com/features/cameras
  18592. * @param name Defines the name of the camera in the scene
  18593. * @param position Defines the start position of the camera in the scene
  18594. * @param scene Defines the scene the camera belongs to
  18595. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18596. */
  18597. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18598. /**
  18599. * Gets the position in front of the camera at a given distance.
  18600. * @param distance The distance from the camera we want the position to be
  18601. * @returns the position
  18602. */
  18603. getFrontPosition(distance: number): Vector3;
  18604. /** @hidden */
  18605. _getLockedTargetPosition(): Nullable<Vector3>;
  18606. private _storedPosition;
  18607. private _storedRotation;
  18608. private _storedRotationQuaternion;
  18609. /**
  18610. * Store current camera state of the camera (fov, position, rotation, etc..)
  18611. * @returns the camera
  18612. */
  18613. storeState(): Camera;
  18614. /**
  18615. * Restored camera state. You must call storeState() first
  18616. * @returns whether it was successful or not
  18617. * @hidden
  18618. */
  18619. _restoreStateValues(): boolean;
  18620. /** @hidden */
  18621. _initCache(): void;
  18622. /** @hidden */
  18623. _updateCache(ignoreParentClass?: boolean): void;
  18624. /** @hidden */
  18625. _isSynchronizedViewMatrix(): boolean;
  18626. /** @hidden */
  18627. _computeLocalCameraSpeed(): number;
  18628. /**
  18629. * Defines the target the camera should look at.
  18630. * @param target Defines the new target as a Vector or a mesh
  18631. */
  18632. setTarget(target: Vector3): void;
  18633. /**
  18634. * Defines the target point of the camera.
  18635. * The camera looks towards it form the radius distance.
  18636. */
  18637. get target(): Vector3;
  18638. set target(value: Vector3);
  18639. /**
  18640. * Return the current target position of the camera. This value is expressed in local space.
  18641. * @returns the target position
  18642. */
  18643. getTarget(): Vector3;
  18644. /** @hidden */
  18645. _decideIfNeedsToMove(): boolean;
  18646. /** @hidden */
  18647. _updatePosition(): void;
  18648. /** @hidden */
  18649. _checkInputs(): void;
  18650. protected _updateCameraRotationMatrix(): void;
  18651. /**
  18652. * 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)
  18653. * @returns the current camera
  18654. */
  18655. private _rotateUpVectorWithCameraRotationMatrix;
  18656. private _cachedRotationZ;
  18657. private _cachedQuaternionRotationZ;
  18658. /** @hidden */
  18659. _getViewMatrix(): Matrix;
  18660. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18661. /**
  18662. * @hidden
  18663. */
  18664. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18665. /**
  18666. * @hidden
  18667. */
  18668. _updateRigCameras(): void;
  18669. private _getRigCamPositionAndTarget;
  18670. /**
  18671. * Gets the current object class name.
  18672. * @return the class name
  18673. */
  18674. getClassName(): string;
  18675. }
  18676. }
  18677. declare module BABYLON {
  18678. /**
  18679. * Gather the list of keyboard event types as constants.
  18680. */
  18681. export class KeyboardEventTypes {
  18682. /**
  18683. * The keydown event is fired when a key becomes active (pressed).
  18684. */
  18685. static readonly KEYDOWN: number;
  18686. /**
  18687. * The keyup event is fired when a key has been released.
  18688. */
  18689. static readonly KEYUP: number;
  18690. }
  18691. /**
  18692. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18693. */
  18694. export class KeyboardInfo {
  18695. /**
  18696. * Defines the type of event (KeyboardEventTypes)
  18697. */
  18698. type: number;
  18699. /**
  18700. * Defines the related dom event
  18701. */
  18702. event: KeyboardEvent;
  18703. /**
  18704. * Instantiates a new keyboard info.
  18705. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18706. * @param type Defines the type of event (KeyboardEventTypes)
  18707. * @param event Defines the related dom event
  18708. */
  18709. constructor(
  18710. /**
  18711. * Defines the type of event (KeyboardEventTypes)
  18712. */
  18713. type: number,
  18714. /**
  18715. * Defines the related dom event
  18716. */
  18717. event: KeyboardEvent);
  18718. }
  18719. /**
  18720. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18721. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18722. */
  18723. export class KeyboardInfoPre extends KeyboardInfo {
  18724. /**
  18725. * Defines the type of event (KeyboardEventTypes)
  18726. */
  18727. type: number;
  18728. /**
  18729. * Defines the related dom event
  18730. */
  18731. event: KeyboardEvent;
  18732. /**
  18733. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18734. */
  18735. skipOnPointerObservable: boolean;
  18736. /**
  18737. * Instantiates a new keyboard pre info.
  18738. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18739. * @param type Defines the type of event (KeyboardEventTypes)
  18740. * @param event Defines the related dom event
  18741. */
  18742. constructor(
  18743. /**
  18744. * Defines the type of event (KeyboardEventTypes)
  18745. */
  18746. type: number,
  18747. /**
  18748. * Defines the related dom event
  18749. */
  18750. event: KeyboardEvent);
  18751. }
  18752. }
  18753. declare module BABYLON {
  18754. /**
  18755. * Manage the keyboard inputs to control the movement of a free camera.
  18756. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18757. */
  18758. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18759. /**
  18760. * Defines the camera the input is attached to.
  18761. */
  18762. camera: FreeCamera;
  18763. /**
  18764. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18765. */
  18766. keysUp: number[];
  18767. /**
  18768. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18769. */
  18770. keysUpward: number[];
  18771. /**
  18772. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18773. */
  18774. keysDown: number[];
  18775. /**
  18776. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18777. */
  18778. keysDownward: number[];
  18779. /**
  18780. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18781. */
  18782. keysLeft: number[];
  18783. /**
  18784. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18785. */
  18786. keysRight: number[];
  18787. private _keys;
  18788. private _onCanvasBlurObserver;
  18789. private _onKeyboardObserver;
  18790. private _engine;
  18791. private _scene;
  18792. /**
  18793. * Attach the input controls to a specific dom element to get the input from.
  18794. * @param element Defines the element the controls should be listened from
  18795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18796. */
  18797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18798. /**
  18799. * Detach the current controls from the specified dom element.
  18800. * @param element Defines the element to stop listening the inputs from
  18801. */
  18802. detachControl(element: Nullable<HTMLElement>): void;
  18803. /**
  18804. * Update the current camera state depending on the inputs that have been used this frame.
  18805. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18806. */
  18807. checkInputs(): void;
  18808. /**
  18809. * Gets the class name of the current intput.
  18810. * @returns the class name
  18811. */
  18812. getClassName(): string;
  18813. /** @hidden */
  18814. _onLostFocus(): void;
  18815. /**
  18816. * Get the friendly name associated with the input class.
  18817. * @returns the input friendly name
  18818. */
  18819. getSimpleName(): string;
  18820. }
  18821. }
  18822. declare module BABYLON {
  18823. /**
  18824. * Gather the list of pointer event types as constants.
  18825. */
  18826. export class PointerEventTypes {
  18827. /**
  18828. * 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.
  18829. */
  18830. static readonly POINTERDOWN: number;
  18831. /**
  18832. * The pointerup event is fired when a pointer is no longer active.
  18833. */
  18834. static readonly POINTERUP: number;
  18835. /**
  18836. * The pointermove event is fired when a pointer changes coordinates.
  18837. */
  18838. static readonly POINTERMOVE: number;
  18839. /**
  18840. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18841. */
  18842. static readonly POINTERWHEEL: number;
  18843. /**
  18844. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18845. */
  18846. static readonly POINTERPICK: number;
  18847. /**
  18848. * The pointertap event is fired when a the object has been touched and released without drag.
  18849. */
  18850. static readonly POINTERTAP: number;
  18851. /**
  18852. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18853. */
  18854. static readonly POINTERDOUBLETAP: number;
  18855. }
  18856. /**
  18857. * Base class of pointer info types.
  18858. */
  18859. export class PointerInfoBase {
  18860. /**
  18861. * Defines the type of event (PointerEventTypes)
  18862. */
  18863. type: number;
  18864. /**
  18865. * Defines the related dom event
  18866. */
  18867. event: PointerEvent | MouseWheelEvent;
  18868. /**
  18869. * Instantiates the base class of pointers info.
  18870. * @param type Defines the type of event (PointerEventTypes)
  18871. * @param event Defines the related dom event
  18872. */
  18873. constructor(
  18874. /**
  18875. * Defines the type of event (PointerEventTypes)
  18876. */
  18877. type: number,
  18878. /**
  18879. * Defines the related dom event
  18880. */
  18881. event: PointerEvent | MouseWheelEvent);
  18882. }
  18883. /**
  18884. * This class is used to store pointer related info for the onPrePointerObservable event.
  18885. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18886. */
  18887. export class PointerInfoPre extends PointerInfoBase {
  18888. /**
  18889. * Ray from a pointer if availible (eg. 6dof controller)
  18890. */
  18891. ray: Nullable<Ray>;
  18892. /**
  18893. * Defines the local position of the pointer on the canvas.
  18894. */
  18895. localPosition: Vector2;
  18896. /**
  18897. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18898. */
  18899. skipOnPointerObservable: boolean;
  18900. /**
  18901. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18902. * @param type Defines the type of event (PointerEventTypes)
  18903. * @param event Defines the related dom event
  18904. * @param localX Defines the local x coordinates of the pointer when the event occured
  18905. * @param localY Defines the local y coordinates of the pointer when the event occured
  18906. */
  18907. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18908. }
  18909. /**
  18910. * This type contains all the data related to a pointer event in Babylon.js.
  18911. * 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.
  18912. */
  18913. export class PointerInfo extends PointerInfoBase {
  18914. /**
  18915. * Defines the picking info associated to the info (if any)\
  18916. */
  18917. pickInfo: Nullable<PickingInfo>;
  18918. /**
  18919. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18920. * @param type Defines the type of event (PointerEventTypes)
  18921. * @param event Defines the related dom event
  18922. * @param pickInfo Defines the picking info associated to the info (if any)\
  18923. */
  18924. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18925. /**
  18926. * Defines the picking info associated to the info (if any)\
  18927. */
  18928. pickInfo: Nullable<PickingInfo>);
  18929. }
  18930. /**
  18931. * Data relating to a touch event on the screen.
  18932. */
  18933. export interface PointerTouch {
  18934. /**
  18935. * X coordinate of touch.
  18936. */
  18937. x: number;
  18938. /**
  18939. * Y coordinate of touch.
  18940. */
  18941. y: number;
  18942. /**
  18943. * Id of touch. Unique for each finger.
  18944. */
  18945. pointerId: number;
  18946. /**
  18947. * Event type passed from DOM.
  18948. */
  18949. type: any;
  18950. }
  18951. }
  18952. declare module BABYLON {
  18953. /**
  18954. * Manage the mouse inputs to control the movement of a free camera.
  18955. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18956. */
  18957. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18958. /**
  18959. * Define if touch is enabled in the mouse input
  18960. */
  18961. touchEnabled: boolean;
  18962. /**
  18963. * Defines the camera the input is attached to.
  18964. */
  18965. camera: FreeCamera;
  18966. /**
  18967. * Defines the buttons associated with the input to handle camera move.
  18968. */
  18969. buttons: number[];
  18970. /**
  18971. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18972. */
  18973. angularSensibility: number;
  18974. private _pointerInput;
  18975. private _onMouseMove;
  18976. private _observer;
  18977. private previousPosition;
  18978. /**
  18979. * Observable for when a pointer move event occurs containing the move offset
  18980. */
  18981. onPointerMovedObservable: Observable<{
  18982. offsetX: number;
  18983. offsetY: number;
  18984. }>;
  18985. /**
  18986. * @hidden
  18987. * If the camera should be rotated automatically based on pointer movement
  18988. */
  18989. _allowCameraRotation: boolean;
  18990. /**
  18991. * Manage the mouse inputs to control the movement of a free camera.
  18992. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18993. * @param touchEnabled Defines if touch is enabled or not
  18994. */
  18995. constructor(
  18996. /**
  18997. * Define if touch is enabled in the mouse input
  18998. */
  18999. touchEnabled?: boolean);
  19000. /**
  19001. * Attach the input controls to a specific dom element to get the input from.
  19002. * @param element Defines the element the controls should be listened from
  19003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19004. */
  19005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19006. /**
  19007. * Called on JS contextmenu event.
  19008. * Override this method to provide functionality.
  19009. */
  19010. protected onContextMenu(evt: PointerEvent): void;
  19011. /**
  19012. * Detach the current controls from the specified dom element.
  19013. * @param element Defines the element to stop listening the inputs from
  19014. */
  19015. detachControl(element: Nullable<HTMLElement>): void;
  19016. /**
  19017. * Gets the class name of the current intput.
  19018. * @returns the class name
  19019. */
  19020. getClassName(): string;
  19021. /**
  19022. * Get the friendly name associated with the input class.
  19023. * @returns the input friendly name
  19024. */
  19025. getSimpleName(): string;
  19026. }
  19027. }
  19028. declare module BABYLON {
  19029. /**
  19030. * Manage the touch inputs to control the movement of a free camera.
  19031. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19032. */
  19033. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19034. /**
  19035. * Define if mouse events can be treated as touch events
  19036. */
  19037. allowMouse: boolean;
  19038. /**
  19039. * Defines the camera the input is attached to.
  19040. */
  19041. camera: FreeCamera;
  19042. /**
  19043. * Defines the touch sensibility for rotation.
  19044. * The higher the faster.
  19045. */
  19046. touchAngularSensibility: number;
  19047. /**
  19048. * Defines the touch sensibility for move.
  19049. * The higher the faster.
  19050. */
  19051. touchMoveSensibility: number;
  19052. private _offsetX;
  19053. private _offsetY;
  19054. private _pointerPressed;
  19055. private _pointerInput;
  19056. private _observer;
  19057. private _onLostFocus;
  19058. /**
  19059. * Manage the touch inputs to control the movement of a free camera.
  19060. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19061. * @param allowMouse Defines if mouse events can be treated as touch events
  19062. */
  19063. constructor(
  19064. /**
  19065. * Define if mouse events can be treated as touch events
  19066. */
  19067. allowMouse?: boolean);
  19068. /**
  19069. * Attach the input controls to a specific dom element to get the input from.
  19070. * @param element Defines the element the controls should be listened from
  19071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19072. */
  19073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19074. /**
  19075. * Detach the current controls from the specified dom element.
  19076. * @param element Defines the element to stop listening the inputs from
  19077. */
  19078. detachControl(element: Nullable<HTMLElement>): void;
  19079. /**
  19080. * Update the current camera state depending on the inputs that have been used this frame.
  19081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19082. */
  19083. checkInputs(): void;
  19084. /**
  19085. * Gets the class name of the current intput.
  19086. * @returns the class name
  19087. */
  19088. getClassName(): string;
  19089. /**
  19090. * Get the friendly name associated with the input class.
  19091. * @returns the input friendly name
  19092. */
  19093. getSimpleName(): string;
  19094. }
  19095. }
  19096. declare module BABYLON {
  19097. /**
  19098. * Default Inputs manager for the FreeCamera.
  19099. * It groups all the default supported inputs for ease of use.
  19100. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19101. */
  19102. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19103. /**
  19104. * @hidden
  19105. */
  19106. _mouseInput: Nullable<FreeCameraMouseInput>;
  19107. /**
  19108. * Instantiates a new FreeCameraInputsManager.
  19109. * @param camera Defines the camera the inputs belong to
  19110. */
  19111. constructor(camera: FreeCamera);
  19112. /**
  19113. * Add keyboard input support to the input manager.
  19114. * @returns the current input manager
  19115. */
  19116. addKeyboard(): FreeCameraInputsManager;
  19117. /**
  19118. * Add mouse input support to the input manager.
  19119. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19120. * @returns the current input manager
  19121. */
  19122. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19123. /**
  19124. * Removes the mouse input support from the manager
  19125. * @returns the current input manager
  19126. */
  19127. removeMouse(): FreeCameraInputsManager;
  19128. /**
  19129. * Add touch input support to the input manager.
  19130. * @returns the current input manager
  19131. */
  19132. addTouch(): FreeCameraInputsManager;
  19133. /**
  19134. * Remove all attached input methods from a camera
  19135. */
  19136. clear(): void;
  19137. }
  19138. }
  19139. declare module BABYLON {
  19140. /**
  19141. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19142. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19143. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19144. */
  19145. export class FreeCamera extends TargetCamera {
  19146. /**
  19147. * Define the collision ellipsoid of the camera.
  19148. * This is helpful to simulate a camera body like the player body around the camera
  19149. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19150. */
  19151. ellipsoid: Vector3;
  19152. /**
  19153. * Define an offset for the position of the ellipsoid around the camera.
  19154. * This can be helpful to determine the center of the body near the gravity center of the body
  19155. * instead of its head.
  19156. */
  19157. ellipsoidOffset: Vector3;
  19158. /**
  19159. * Enable or disable collisions of the camera with the rest of the scene objects.
  19160. */
  19161. checkCollisions: boolean;
  19162. /**
  19163. * Enable or disable gravity on the camera.
  19164. */
  19165. applyGravity: boolean;
  19166. /**
  19167. * Define the input manager associated to the camera.
  19168. */
  19169. inputs: FreeCameraInputsManager;
  19170. /**
  19171. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19172. * Higher values reduce sensitivity.
  19173. */
  19174. get angularSensibility(): number;
  19175. /**
  19176. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19177. * Higher values reduce sensitivity.
  19178. */
  19179. set angularSensibility(value: number);
  19180. /**
  19181. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19182. */
  19183. get keysUp(): number[];
  19184. set keysUp(value: number[]);
  19185. /**
  19186. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19187. */
  19188. get keysUpward(): number[];
  19189. set keysUpward(value: number[]);
  19190. /**
  19191. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19192. */
  19193. get keysDown(): number[];
  19194. set keysDown(value: number[]);
  19195. /**
  19196. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19197. */
  19198. get keysDownward(): number[];
  19199. set keysDownward(value: number[]);
  19200. /**
  19201. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19202. */
  19203. get keysLeft(): number[];
  19204. set keysLeft(value: number[]);
  19205. /**
  19206. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19207. */
  19208. get keysRight(): number[];
  19209. set keysRight(value: number[]);
  19210. /**
  19211. * Event raised when the camera collide with a mesh in the scene.
  19212. */
  19213. onCollide: (collidedMesh: AbstractMesh) => void;
  19214. private _collider;
  19215. private _needMoveForGravity;
  19216. private _oldPosition;
  19217. private _diffPosition;
  19218. private _newPosition;
  19219. /** @hidden */
  19220. _localDirection: Vector3;
  19221. /** @hidden */
  19222. _transformedDirection: Vector3;
  19223. /**
  19224. * Instantiates a Free Camera.
  19225. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19226. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19227. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19228. * @param name Define the name of the camera in the scene
  19229. * @param position Define the start position of the camera in the scene
  19230. * @param scene Define the scene the camera belongs to
  19231. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19232. */
  19233. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19234. /**
  19235. * Attached controls to the current camera.
  19236. * @param element Defines the element the controls should be listened from
  19237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19238. */
  19239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19240. /**
  19241. * Detach the current controls from the camera.
  19242. * The camera will stop reacting to inputs.
  19243. * @param element Defines the element to stop listening the inputs from
  19244. */
  19245. detachControl(element: HTMLElement): void;
  19246. private _collisionMask;
  19247. /**
  19248. * Define a collision mask to limit the list of object the camera can collide with
  19249. */
  19250. get collisionMask(): number;
  19251. set collisionMask(mask: number);
  19252. /** @hidden */
  19253. _collideWithWorld(displacement: Vector3): void;
  19254. private _onCollisionPositionChange;
  19255. /** @hidden */
  19256. _checkInputs(): void;
  19257. /** @hidden */
  19258. _decideIfNeedsToMove(): boolean;
  19259. /** @hidden */
  19260. _updatePosition(): void;
  19261. /**
  19262. * Destroy the camera and release the current resources hold by it.
  19263. */
  19264. dispose(): void;
  19265. /**
  19266. * Gets the current object class name.
  19267. * @return the class name
  19268. */
  19269. getClassName(): string;
  19270. }
  19271. }
  19272. declare module BABYLON {
  19273. /**
  19274. * Represents a gamepad control stick position
  19275. */
  19276. export class StickValues {
  19277. /**
  19278. * The x component of the control stick
  19279. */
  19280. x: number;
  19281. /**
  19282. * The y component of the control stick
  19283. */
  19284. y: number;
  19285. /**
  19286. * Initializes the gamepad x and y control stick values
  19287. * @param x The x component of the gamepad control stick value
  19288. * @param y The y component of the gamepad control stick value
  19289. */
  19290. constructor(
  19291. /**
  19292. * The x component of the control stick
  19293. */
  19294. x: number,
  19295. /**
  19296. * The y component of the control stick
  19297. */
  19298. y: number);
  19299. }
  19300. /**
  19301. * An interface which manages callbacks for gamepad button changes
  19302. */
  19303. export interface GamepadButtonChanges {
  19304. /**
  19305. * Called when a gamepad has been changed
  19306. */
  19307. changed: boolean;
  19308. /**
  19309. * Called when a gamepad press event has been triggered
  19310. */
  19311. pressChanged: boolean;
  19312. /**
  19313. * Called when a touch event has been triggered
  19314. */
  19315. touchChanged: boolean;
  19316. /**
  19317. * Called when a value has changed
  19318. */
  19319. valueChanged: boolean;
  19320. }
  19321. /**
  19322. * Represents a gamepad
  19323. */
  19324. export class Gamepad {
  19325. /**
  19326. * The id of the gamepad
  19327. */
  19328. id: string;
  19329. /**
  19330. * The index of the gamepad
  19331. */
  19332. index: number;
  19333. /**
  19334. * The browser gamepad
  19335. */
  19336. browserGamepad: any;
  19337. /**
  19338. * Specifies what type of gamepad this represents
  19339. */
  19340. type: number;
  19341. private _leftStick;
  19342. private _rightStick;
  19343. /** @hidden */
  19344. _isConnected: boolean;
  19345. private _leftStickAxisX;
  19346. private _leftStickAxisY;
  19347. private _rightStickAxisX;
  19348. private _rightStickAxisY;
  19349. /**
  19350. * Triggered when the left control stick has been changed
  19351. */
  19352. private _onleftstickchanged;
  19353. /**
  19354. * Triggered when the right control stick has been changed
  19355. */
  19356. private _onrightstickchanged;
  19357. /**
  19358. * Represents a gamepad controller
  19359. */
  19360. static GAMEPAD: number;
  19361. /**
  19362. * Represents a generic controller
  19363. */
  19364. static GENERIC: number;
  19365. /**
  19366. * Represents an XBox controller
  19367. */
  19368. static XBOX: number;
  19369. /**
  19370. * Represents a pose-enabled controller
  19371. */
  19372. static POSE_ENABLED: number;
  19373. /**
  19374. * Represents an Dual Shock controller
  19375. */
  19376. static DUALSHOCK: number;
  19377. /**
  19378. * Specifies whether the left control stick should be Y-inverted
  19379. */
  19380. protected _invertLeftStickY: boolean;
  19381. /**
  19382. * Specifies if the gamepad has been connected
  19383. */
  19384. get isConnected(): boolean;
  19385. /**
  19386. * Initializes the gamepad
  19387. * @param id The id of the gamepad
  19388. * @param index The index of the gamepad
  19389. * @param browserGamepad The browser gamepad
  19390. * @param leftStickX The x component of the left joystick
  19391. * @param leftStickY The y component of the left joystick
  19392. * @param rightStickX The x component of the right joystick
  19393. * @param rightStickY The y component of the right joystick
  19394. */
  19395. constructor(
  19396. /**
  19397. * The id of the gamepad
  19398. */
  19399. id: string,
  19400. /**
  19401. * The index of the gamepad
  19402. */
  19403. index: number,
  19404. /**
  19405. * The browser gamepad
  19406. */
  19407. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19408. /**
  19409. * Callback triggered when the left joystick has changed
  19410. * @param callback
  19411. */
  19412. onleftstickchanged(callback: (values: StickValues) => void): void;
  19413. /**
  19414. * Callback triggered when the right joystick has changed
  19415. * @param callback
  19416. */
  19417. onrightstickchanged(callback: (values: StickValues) => void): void;
  19418. /**
  19419. * Gets the left joystick
  19420. */
  19421. get leftStick(): StickValues;
  19422. /**
  19423. * Sets the left joystick values
  19424. */
  19425. set leftStick(newValues: StickValues);
  19426. /**
  19427. * Gets the right joystick
  19428. */
  19429. get rightStick(): StickValues;
  19430. /**
  19431. * Sets the right joystick value
  19432. */
  19433. set rightStick(newValues: StickValues);
  19434. /**
  19435. * Updates the gamepad joystick positions
  19436. */
  19437. update(): void;
  19438. /**
  19439. * Disposes the gamepad
  19440. */
  19441. dispose(): void;
  19442. }
  19443. /**
  19444. * Represents a generic gamepad
  19445. */
  19446. export class GenericPad extends Gamepad {
  19447. private _buttons;
  19448. private _onbuttondown;
  19449. private _onbuttonup;
  19450. /**
  19451. * Observable triggered when a button has been pressed
  19452. */
  19453. onButtonDownObservable: Observable<number>;
  19454. /**
  19455. * Observable triggered when a button has been released
  19456. */
  19457. onButtonUpObservable: Observable<number>;
  19458. /**
  19459. * Callback triggered when a button has been pressed
  19460. * @param callback Called when a button has been pressed
  19461. */
  19462. onbuttondown(callback: (buttonPressed: number) => void): void;
  19463. /**
  19464. * Callback triggered when a button has been released
  19465. * @param callback Called when a button has been released
  19466. */
  19467. onbuttonup(callback: (buttonReleased: number) => void): void;
  19468. /**
  19469. * Initializes the generic gamepad
  19470. * @param id The id of the generic gamepad
  19471. * @param index The index of the generic gamepad
  19472. * @param browserGamepad The browser gamepad
  19473. */
  19474. constructor(id: string, index: number, browserGamepad: any);
  19475. private _setButtonValue;
  19476. /**
  19477. * Updates the generic gamepad
  19478. */
  19479. update(): void;
  19480. /**
  19481. * Disposes the generic gamepad
  19482. */
  19483. dispose(): void;
  19484. }
  19485. }
  19486. declare module BABYLON {
  19487. /**
  19488. * Defines the types of pose enabled controllers that are supported
  19489. */
  19490. export enum PoseEnabledControllerType {
  19491. /**
  19492. * HTC Vive
  19493. */
  19494. VIVE = 0,
  19495. /**
  19496. * Oculus Rift
  19497. */
  19498. OCULUS = 1,
  19499. /**
  19500. * Windows mixed reality
  19501. */
  19502. WINDOWS = 2,
  19503. /**
  19504. * Samsung gear VR
  19505. */
  19506. GEAR_VR = 3,
  19507. /**
  19508. * Google Daydream
  19509. */
  19510. DAYDREAM = 4,
  19511. /**
  19512. * Generic
  19513. */
  19514. GENERIC = 5
  19515. }
  19516. /**
  19517. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19518. */
  19519. export interface MutableGamepadButton {
  19520. /**
  19521. * Value of the button/trigger
  19522. */
  19523. value: number;
  19524. /**
  19525. * If the button/trigger is currently touched
  19526. */
  19527. touched: boolean;
  19528. /**
  19529. * If the button/trigger is currently pressed
  19530. */
  19531. pressed: boolean;
  19532. }
  19533. /**
  19534. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19535. * @hidden
  19536. */
  19537. export interface ExtendedGamepadButton extends GamepadButton {
  19538. /**
  19539. * If the button/trigger is currently pressed
  19540. */
  19541. readonly pressed: boolean;
  19542. /**
  19543. * If the button/trigger is currently touched
  19544. */
  19545. readonly touched: boolean;
  19546. /**
  19547. * Value of the button/trigger
  19548. */
  19549. readonly value: number;
  19550. }
  19551. /** @hidden */
  19552. export interface _GamePadFactory {
  19553. /**
  19554. * Returns whether or not the current gamepad can be created for this type of controller.
  19555. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19556. * @returns true if it can be created, otherwise false
  19557. */
  19558. canCreate(gamepadInfo: any): boolean;
  19559. /**
  19560. * Creates a new instance of the Gamepad.
  19561. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19562. * @returns the new gamepad instance
  19563. */
  19564. create(gamepadInfo: any): Gamepad;
  19565. }
  19566. /**
  19567. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19568. */
  19569. export class PoseEnabledControllerHelper {
  19570. /** @hidden */
  19571. static _ControllerFactories: _GamePadFactory[];
  19572. /** @hidden */
  19573. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19574. /**
  19575. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19576. * @param vrGamepad the gamepad to initialized
  19577. * @returns a vr controller of the type the gamepad identified as
  19578. */
  19579. static InitiateController(vrGamepad: any): Gamepad;
  19580. }
  19581. /**
  19582. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19583. */
  19584. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19585. /**
  19586. * If the controller is used in a webXR session
  19587. */
  19588. isXR: boolean;
  19589. private _deviceRoomPosition;
  19590. private _deviceRoomRotationQuaternion;
  19591. /**
  19592. * The device position in babylon space
  19593. */
  19594. devicePosition: Vector3;
  19595. /**
  19596. * The device rotation in babylon space
  19597. */
  19598. deviceRotationQuaternion: Quaternion;
  19599. /**
  19600. * The scale factor of the device in babylon space
  19601. */
  19602. deviceScaleFactor: number;
  19603. /**
  19604. * (Likely devicePosition should be used instead) The device position in its room space
  19605. */
  19606. position: Vector3;
  19607. /**
  19608. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19609. */
  19610. rotationQuaternion: Quaternion;
  19611. /**
  19612. * The type of controller (Eg. Windows mixed reality)
  19613. */
  19614. controllerType: PoseEnabledControllerType;
  19615. protected _calculatedPosition: Vector3;
  19616. private _calculatedRotation;
  19617. /**
  19618. * The raw pose from the device
  19619. */
  19620. rawPose: DevicePose;
  19621. private _trackPosition;
  19622. private _maxRotationDistFromHeadset;
  19623. private _draggedRoomRotation;
  19624. /**
  19625. * @hidden
  19626. */
  19627. _disableTrackPosition(fixedPosition: Vector3): void;
  19628. /**
  19629. * Internal, the mesh attached to the controller
  19630. * @hidden
  19631. */
  19632. _mesh: Nullable<AbstractMesh>;
  19633. private _poseControlledCamera;
  19634. private _leftHandSystemQuaternion;
  19635. /**
  19636. * Internal, matrix used to convert room space to babylon space
  19637. * @hidden
  19638. */
  19639. _deviceToWorld: Matrix;
  19640. /**
  19641. * Node to be used when casting a ray from the controller
  19642. * @hidden
  19643. */
  19644. _pointingPoseNode: Nullable<TransformNode>;
  19645. /**
  19646. * Name of the child mesh that can be used to cast a ray from the controller
  19647. */
  19648. static readonly POINTING_POSE: string;
  19649. /**
  19650. * Creates a new PoseEnabledController from a gamepad
  19651. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19652. */
  19653. constructor(browserGamepad: any);
  19654. private _workingMatrix;
  19655. /**
  19656. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19657. */
  19658. update(): void;
  19659. /**
  19660. * Updates only the pose device and mesh without doing any button event checking
  19661. */
  19662. protected _updatePoseAndMesh(): void;
  19663. /**
  19664. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19665. * @param poseData raw pose fromthe device
  19666. */
  19667. updateFromDevice(poseData: DevicePose): void;
  19668. /**
  19669. * @hidden
  19670. */
  19671. _meshAttachedObservable: Observable<AbstractMesh>;
  19672. /**
  19673. * Attaches a mesh to the controller
  19674. * @param mesh the mesh to be attached
  19675. */
  19676. attachToMesh(mesh: AbstractMesh): void;
  19677. /**
  19678. * Attaches the controllers mesh to a camera
  19679. * @param camera the camera the mesh should be attached to
  19680. */
  19681. attachToPoseControlledCamera(camera: TargetCamera): void;
  19682. /**
  19683. * Disposes of the controller
  19684. */
  19685. dispose(): void;
  19686. /**
  19687. * The mesh that is attached to the controller
  19688. */
  19689. get mesh(): Nullable<AbstractMesh>;
  19690. /**
  19691. * Gets the ray of the controller in the direction the controller is pointing
  19692. * @param length the length the resulting ray should be
  19693. * @returns a ray in the direction the controller is pointing
  19694. */
  19695. getForwardRay(length?: number): Ray;
  19696. }
  19697. }
  19698. declare module BABYLON {
  19699. /**
  19700. * Defines the WebVRController object that represents controllers tracked in 3D space
  19701. */
  19702. export abstract class WebVRController extends PoseEnabledController {
  19703. /**
  19704. * Internal, the default controller model for the controller
  19705. */
  19706. protected _defaultModel: Nullable<AbstractMesh>;
  19707. /**
  19708. * Fired when the trigger state has changed
  19709. */
  19710. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19711. /**
  19712. * Fired when the main button state has changed
  19713. */
  19714. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19715. /**
  19716. * Fired when the secondary button state has changed
  19717. */
  19718. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19719. /**
  19720. * Fired when the pad state has changed
  19721. */
  19722. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19723. /**
  19724. * Fired when controllers stick values have changed
  19725. */
  19726. onPadValuesChangedObservable: Observable<StickValues>;
  19727. /**
  19728. * Array of button availible on the controller
  19729. */
  19730. protected _buttons: Array<MutableGamepadButton>;
  19731. private _onButtonStateChange;
  19732. /**
  19733. * Fired when a controller button's state has changed
  19734. * @param callback the callback containing the button that was modified
  19735. */
  19736. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19737. /**
  19738. * X and Y axis corresponding to the controllers joystick
  19739. */
  19740. pad: StickValues;
  19741. /**
  19742. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19743. */
  19744. hand: string;
  19745. /**
  19746. * The default controller model for the controller
  19747. */
  19748. get defaultModel(): Nullable<AbstractMesh>;
  19749. /**
  19750. * Creates a new WebVRController from a gamepad
  19751. * @param vrGamepad the gamepad that the WebVRController should be created from
  19752. */
  19753. constructor(vrGamepad: any);
  19754. /**
  19755. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19756. */
  19757. update(): void;
  19758. /**
  19759. * Function to be called when a button is modified
  19760. */
  19761. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19762. /**
  19763. * Loads a mesh and attaches it to the controller
  19764. * @param scene the scene the mesh should be added to
  19765. * @param meshLoaded callback for when the mesh has been loaded
  19766. */
  19767. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19768. private _setButtonValue;
  19769. private _changes;
  19770. private _checkChanges;
  19771. /**
  19772. * Disposes of th webVRCOntroller
  19773. */
  19774. dispose(): void;
  19775. }
  19776. }
  19777. declare module BABYLON {
  19778. /**
  19779. * The HemisphericLight simulates the ambient environment light,
  19780. * so the passed direction is the light reflection direction, not the incoming direction.
  19781. */
  19782. export class HemisphericLight extends Light {
  19783. /**
  19784. * The groundColor is the light in the opposite direction to the one specified during creation.
  19785. * 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.
  19786. */
  19787. groundColor: Color3;
  19788. /**
  19789. * The light reflection direction, not the incoming direction.
  19790. */
  19791. direction: Vector3;
  19792. /**
  19793. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19794. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19795. * The HemisphericLight can't cast shadows.
  19796. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19797. * @param name The friendly name of the light
  19798. * @param direction The direction of the light reflection
  19799. * @param scene The scene the light belongs to
  19800. */
  19801. constructor(name: string, direction: Vector3, scene: Scene);
  19802. protected _buildUniformLayout(): void;
  19803. /**
  19804. * Returns the string "HemisphericLight".
  19805. * @return The class name
  19806. */
  19807. getClassName(): string;
  19808. /**
  19809. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19810. * Returns the updated direction.
  19811. * @param target The target the direction should point to
  19812. * @return The computed direction
  19813. */
  19814. setDirectionToTarget(target: Vector3): Vector3;
  19815. /**
  19816. * Returns the shadow generator associated to the light.
  19817. * @returns Always null for hemispheric lights because it does not support shadows.
  19818. */
  19819. getShadowGenerator(): Nullable<IShadowGenerator>;
  19820. /**
  19821. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19822. * @param effect The effect to update
  19823. * @param lightIndex The index of the light in the effect to update
  19824. * @returns The hemispheric light
  19825. */
  19826. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19827. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19828. /**
  19829. * Computes the world matrix of the node
  19830. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19831. * @param useWasUpdatedFlag defines a reserved property
  19832. * @returns the world matrix
  19833. */
  19834. computeWorldMatrix(): Matrix;
  19835. /**
  19836. * Returns the integer 3.
  19837. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19838. */
  19839. getTypeID(): number;
  19840. /**
  19841. * Prepares the list of defines specific to the light type.
  19842. * @param defines the list of defines
  19843. * @param lightIndex defines the index of the light for the effect
  19844. */
  19845. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19846. }
  19847. }
  19848. declare module BABYLON {
  19849. /** @hidden */
  19850. export var vrMultiviewToSingleviewPixelShader: {
  19851. name: string;
  19852. shader: string;
  19853. };
  19854. }
  19855. declare module BABYLON {
  19856. /**
  19857. * Renders to multiple views with a single draw call
  19858. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19859. */
  19860. export class MultiviewRenderTarget extends RenderTargetTexture {
  19861. /**
  19862. * Creates a multiview render target
  19863. * @param scene scene used with the render target
  19864. * @param size the size of the render target (used for each view)
  19865. */
  19866. constructor(scene: Scene, size?: number | {
  19867. width: number;
  19868. height: number;
  19869. } | {
  19870. ratio: number;
  19871. });
  19872. /**
  19873. * @hidden
  19874. * @param faceIndex the face index, if its a cube texture
  19875. */
  19876. _bindFrameBuffer(faceIndex?: number): void;
  19877. /**
  19878. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19879. * @returns the view count
  19880. */
  19881. getViewCount(): number;
  19882. }
  19883. }
  19884. declare module BABYLON {
  19885. interface Engine {
  19886. /**
  19887. * Creates a new multiview render target
  19888. * @param width defines the width of the texture
  19889. * @param height defines the height of the texture
  19890. * @returns the created multiview texture
  19891. */
  19892. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19893. /**
  19894. * Binds a multiview framebuffer to be drawn to
  19895. * @param multiviewTexture texture to bind
  19896. */
  19897. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19898. }
  19899. interface Camera {
  19900. /**
  19901. * @hidden
  19902. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19903. */
  19904. _useMultiviewToSingleView: boolean;
  19905. /**
  19906. * @hidden
  19907. * 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)
  19908. */
  19909. _multiviewTexture: Nullable<RenderTargetTexture>;
  19910. /**
  19911. * @hidden
  19912. * ensures the multiview texture of the camera exists and has the specified width/height
  19913. * @param width height to set on the multiview texture
  19914. * @param height width to set on the multiview texture
  19915. */
  19916. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19917. }
  19918. interface Scene {
  19919. /** @hidden */
  19920. _transformMatrixR: Matrix;
  19921. /** @hidden */
  19922. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19923. /** @hidden */
  19924. _createMultiviewUbo(): void;
  19925. /** @hidden */
  19926. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19927. /** @hidden */
  19928. _renderMultiviewToSingleView(camera: Camera): void;
  19929. }
  19930. }
  19931. declare module BABYLON {
  19932. /**
  19933. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19934. * This will not be used for webXR as it supports displaying texture arrays directly
  19935. */
  19936. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19937. /**
  19938. * Gets a string identifying the name of the class
  19939. * @returns "VRMultiviewToSingleviewPostProcess" string
  19940. */
  19941. getClassName(): string;
  19942. /**
  19943. * Initializes a VRMultiviewToSingleview
  19944. * @param name name of the post process
  19945. * @param camera camera to be applied to
  19946. * @param scaleFactor scaling factor to the size of the output texture
  19947. */
  19948. constructor(name: string, camera: Camera, scaleFactor: number);
  19949. }
  19950. }
  19951. declare module BABYLON {
  19952. /**
  19953. * Interface used to define additional presentation attributes
  19954. */
  19955. export interface IVRPresentationAttributes {
  19956. /**
  19957. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19958. */
  19959. highRefreshRate: boolean;
  19960. /**
  19961. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19962. */
  19963. foveationLevel: number;
  19964. }
  19965. interface Engine {
  19966. /** @hidden */
  19967. _vrDisplay: any;
  19968. /** @hidden */
  19969. _vrSupported: boolean;
  19970. /** @hidden */
  19971. _oldSize: Size;
  19972. /** @hidden */
  19973. _oldHardwareScaleFactor: number;
  19974. /** @hidden */
  19975. _vrExclusivePointerMode: boolean;
  19976. /** @hidden */
  19977. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19978. /** @hidden */
  19979. _onVRDisplayPointerRestricted: () => void;
  19980. /** @hidden */
  19981. _onVRDisplayPointerUnrestricted: () => void;
  19982. /** @hidden */
  19983. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19984. /** @hidden */
  19985. _onVrDisplayDisconnect: Nullable<() => void>;
  19986. /** @hidden */
  19987. _onVrDisplayPresentChange: Nullable<() => void>;
  19988. /**
  19989. * Observable signaled when VR display mode changes
  19990. */
  19991. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19992. /**
  19993. * Observable signaled when VR request present is complete
  19994. */
  19995. onVRRequestPresentComplete: Observable<boolean>;
  19996. /**
  19997. * Observable signaled when VR request present starts
  19998. */
  19999. onVRRequestPresentStart: Observable<Engine>;
  20000. /**
  20001. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20002. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20003. */
  20004. isInVRExclusivePointerMode: boolean;
  20005. /**
  20006. * Gets a boolean indicating if a webVR device was detected
  20007. * @returns true if a webVR device was detected
  20008. */
  20009. isVRDevicePresent(): boolean;
  20010. /**
  20011. * Gets the current webVR device
  20012. * @returns the current webVR device (or null)
  20013. */
  20014. getVRDevice(): any;
  20015. /**
  20016. * Initializes a webVR display and starts listening to display change events
  20017. * The onVRDisplayChangedObservable will be notified upon these changes
  20018. * @returns A promise containing a VRDisplay and if vr is supported
  20019. */
  20020. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20021. /** @hidden */
  20022. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20023. /**
  20024. * Gets or sets the presentation attributes used to configure VR rendering
  20025. */
  20026. vrPresentationAttributes?: IVRPresentationAttributes;
  20027. /**
  20028. * Call this function to switch to webVR mode
  20029. * Will do nothing if webVR is not supported or if there is no webVR device
  20030. * @param options the webvr options provided to the camera. mainly used for multiview
  20031. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20032. */
  20033. enableVR(options: WebVROptions): void;
  20034. /** @hidden */
  20035. _onVRFullScreenTriggered(): void;
  20036. }
  20037. }
  20038. declare module BABYLON {
  20039. /**
  20040. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20041. * IMPORTANT!! The data is right-hand data.
  20042. * @export
  20043. * @interface DevicePose
  20044. */
  20045. export interface DevicePose {
  20046. /**
  20047. * The position of the device, values in array are [x,y,z].
  20048. */
  20049. readonly position: Nullable<Float32Array>;
  20050. /**
  20051. * The linearVelocity of the device, values in array are [x,y,z].
  20052. */
  20053. readonly linearVelocity: Nullable<Float32Array>;
  20054. /**
  20055. * The linearAcceleration of the device, values in array are [x,y,z].
  20056. */
  20057. readonly linearAcceleration: Nullable<Float32Array>;
  20058. /**
  20059. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20060. */
  20061. readonly orientation: Nullable<Float32Array>;
  20062. /**
  20063. * The angularVelocity of the device, values in array are [x,y,z].
  20064. */
  20065. readonly angularVelocity: Nullable<Float32Array>;
  20066. /**
  20067. * The angularAcceleration of the device, values in array are [x,y,z].
  20068. */
  20069. readonly angularAcceleration: Nullable<Float32Array>;
  20070. }
  20071. /**
  20072. * Interface representing a pose controlled object in Babylon.
  20073. * A pose controlled object has both regular pose values as well as pose values
  20074. * from an external device such as a VR head mounted display
  20075. */
  20076. export interface PoseControlled {
  20077. /**
  20078. * The position of the object in babylon space.
  20079. */
  20080. position: Vector3;
  20081. /**
  20082. * The rotation quaternion of the object in babylon space.
  20083. */
  20084. rotationQuaternion: Quaternion;
  20085. /**
  20086. * The position of the device in babylon space.
  20087. */
  20088. devicePosition?: Vector3;
  20089. /**
  20090. * The rotation quaternion of the device in babylon space.
  20091. */
  20092. deviceRotationQuaternion: Quaternion;
  20093. /**
  20094. * The raw pose coming from the device.
  20095. */
  20096. rawPose: Nullable<DevicePose>;
  20097. /**
  20098. * The scale of the device to be used when translating from device space to babylon space.
  20099. */
  20100. deviceScaleFactor: number;
  20101. /**
  20102. * Updates the poseControlled values based on the input device pose.
  20103. * @param poseData the pose data to update the object with
  20104. */
  20105. updateFromDevice(poseData: DevicePose): void;
  20106. }
  20107. /**
  20108. * Set of options to customize the webVRCamera
  20109. */
  20110. export interface WebVROptions {
  20111. /**
  20112. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20113. */
  20114. trackPosition?: boolean;
  20115. /**
  20116. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20117. */
  20118. positionScale?: number;
  20119. /**
  20120. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20121. */
  20122. displayName?: string;
  20123. /**
  20124. * Should the native controller meshes be initialized. (default: true)
  20125. */
  20126. controllerMeshes?: boolean;
  20127. /**
  20128. * Creating a default HemiLight only on controllers. (default: true)
  20129. */
  20130. defaultLightingOnControllers?: boolean;
  20131. /**
  20132. * If you don't want to use the default VR button of the helper. (default: false)
  20133. */
  20134. useCustomVRButton?: boolean;
  20135. /**
  20136. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20137. */
  20138. customVRButton?: HTMLButtonElement;
  20139. /**
  20140. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20141. */
  20142. rayLength?: number;
  20143. /**
  20144. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20145. */
  20146. defaultHeight?: number;
  20147. /**
  20148. * If multiview should be used if availible (default: false)
  20149. */
  20150. useMultiview?: boolean;
  20151. }
  20152. /**
  20153. * This represents a WebVR camera.
  20154. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20155. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20156. */
  20157. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20158. private webVROptions;
  20159. /**
  20160. * @hidden
  20161. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20162. */
  20163. _vrDevice: any;
  20164. /**
  20165. * The rawPose of the vrDevice.
  20166. */
  20167. rawPose: Nullable<DevicePose>;
  20168. private _onVREnabled;
  20169. private _specsVersion;
  20170. private _attached;
  20171. private _frameData;
  20172. protected _descendants: Array<Node>;
  20173. private _deviceRoomPosition;
  20174. /** @hidden */
  20175. _deviceRoomRotationQuaternion: Quaternion;
  20176. private _standingMatrix;
  20177. /**
  20178. * Represents device position in babylon space.
  20179. */
  20180. devicePosition: Vector3;
  20181. /**
  20182. * Represents device rotation in babylon space.
  20183. */
  20184. deviceRotationQuaternion: Quaternion;
  20185. /**
  20186. * The scale of the device to be used when translating from device space to babylon space.
  20187. */
  20188. deviceScaleFactor: number;
  20189. private _deviceToWorld;
  20190. private _worldToDevice;
  20191. /**
  20192. * References to the webVR controllers for the vrDevice.
  20193. */
  20194. controllers: Array<WebVRController>;
  20195. /**
  20196. * Emits an event when a controller is attached.
  20197. */
  20198. onControllersAttachedObservable: Observable<WebVRController[]>;
  20199. /**
  20200. * Emits an event when a controller's mesh has been loaded;
  20201. */
  20202. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20203. /**
  20204. * Emits an event when the HMD's pose has been updated.
  20205. */
  20206. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20207. private _poseSet;
  20208. /**
  20209. * If the rig cameras be used as parent instead of this camera.
  20210. */
  20211. rigParenting: boolean;
  20212. private _lightOnControllers;
  20213. private _defaultHeight?;
  20214. /**
  20215. * Instantiates a WebVRFreeCamera.
  20216. * @param name The name of the WebVRFreeCamera
  20217. * @param position The starting anchor position for the camera
  20218. * @param scene The scene the camera belongs to
  20219. * @param webVROptions a set of customizable options for the webVRCamera
  20220. */
  20221. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20222. /**
  20223. * Gets the device distance from the ground in meters.
  20224. * @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.
  20225. */
  20226. deviceDistanceToRoomGround(): number;
  20227. /**
  20228. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20229. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20230. */
  20231. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20232. /**
  20233. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20234. * @returns A promise with a boolean set to if the standing matrix is supported.
  20235. */
  20236. useStandingMatrixAsync(): Promise<boolean>;
  20237. /**
  20238. * Disposes the camera
  20239. */
  20240. dispose(): void;
  20241. /**
  20242. * Gets a vrController by name.
  20243. * @param name The name of the controller to retreive
  20244. * @returns the controller matching the name specified or null if not found
  20245. */
  20246. getControllerByName(name: string): Nullable<WebVRController>;
  20247. private _leftController;
  20248. /**
  20249. * The controller corresponding to the users left hand.
  20250. */
  20251. get leftController(): Nullable<WebVRController>;
  20252. private _rightController;
  20253. /**
  20254. * The controller corresponding to the users right hand.
  20255. */
  20256. get rightController(): Nullable<WebVRController>;
  20257. /**
  20258. * Casts a ray forward from the vrCamera's gaze.
  20259. * @param length Length of the ray (default: 100)
  20260. * @returns the ray corresponding to the gaze
  20261. */
  20262. getForwardRay(length?: number): Ray;
  20263. /**
  20264. * @hidden
  20265. * Updates the camera based on device's frame data
  20266. */
  20267. _checkInputs(): void;
  20268. /**
  20269. * Updates the poseControlled values based on the input device pose.
  20270. * @param poseData Pose coming from the device
  20271. */
  20272. updateFromDevice(poseData: DevicePose): void;
  20273. private _htmlElementAttached;
  20274. private _detachIfAttached;
  20275. /**
  20276. * WebVR's attach control will start broadcasting frames to the device.
  20277. * Note that in certain browsers (chrome for example) this function must be called
  20278. * within a user-interaction callback. Example:
  20279. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20280. *
  20281. * @param element html element to attach the vrDevice to
  20282. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20283. */
  20284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20285. /**
  20286. * Detaches the camera from the html element and disables VR
  20287. *
  20288. * @param element html element to detach from
  20289. */
  20290. detachControl(element: HTMLElement): void;
  20291. /**
  20292. * @returns the name of this class
  20293. */
  20294. getClassName(): string;
  20295. /**
  20296. * Calls resetPose on the vrDisplay
  20297. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20298. */
  20299. resetToCurrentRotation(): void;
  20300. /**
  20301. * @hidden
  20302. * Updates the rig cameras (left and right eye)
  20303. */
  20304. _updateRigCameras(): void;
  20305. private _workingVector;
  20306. private _oneVector;
  20307. private _workingMatrix;
  20308. private updateCacheCalled;
  20309. private _correctPositionIfNotTrackPosition;
  20310. /**
  20311. * @hidden
  20312. * Updates the cached values of the camera
  20313. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20314. */
  20315. _updateCache(ignoreParentClass?: boolean): void;
  20316. /**
  20317. * @hidden
  20318. * Get current device position in babylon world
  20319. */
  20320. _computeDevicePosition(): void;
  20321. /**
  20322. * Updates the current device position and rotation in the babylon world
  20323. */
  20324. update(): void;
  20325. /**
  20326. * @hidden
  20327. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20328. * @returns an identity matrix
  20329. */
  20330. _getViewMatrix(): Matrix;
  20331. private _tmpMatrix;
  20332. /**
  20333. * This function is called by the two RIG cameras.
  20334. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20335. * @hidden
  20336. */
  20337. _getWebVRViewMatrix(): Matrix;
  20338. /** @hidden */
  20339. _getWebVRProjectionMatrix(): Matrix;
  20340. private _onGamepadConnectedObserver;
  20341. private _onGamepadDisconnectedObserver;
  20342. private _updateCacheWhenTrackingDisabledObserver;
  20343. /**
  20344. * Initializes the controllers and their meshes
  20345. */
  20346. initControllers(): void;
  20347. }
  20348. }
  20349. declare module BABYLON {
  20350. /**
  20351. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20352. *
  20353. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20354. *
  20355. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20356. */
  20357. export class MaterialHelper {
  20358. /**
  20359. * Bind the current view position to an effect.
  20360. * @param effect The effect to be bound
  20361. * @param scene The scene the eyes position is used from
  20362. * @param variableName name of the shader variable that will hold the eye position
  20363. */
  20364. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20365. /**
  20366. * Helps preparing the defines values about the UVs in used in the effect.
  20367. * UVs are shared as much as we can accross channels in the shaders.
  20368. * @param texture The texture we are preparing the UVs for
  20369. * @param defines The defines to update
  20370. * @param key The channel key "diffuse", "specular"... used in the shader
  20371. */
  20372. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20373. /**
  20374. * Binds a texture matrix value to its corrsponding uniform
  20375. * @param texture The texture to bind the matrix for
  20376. * @param uniformBuffer The uniform buffer receivin the data
  20377. * @param key The channel key "diffuse", "specular"... used in the shader
  20378. */
  20379. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20380. /**
  20381. * Gets the current status of the fog (should it be enabled?)
  20382. * @param mesh defines the mesh to evaluate for fog support
  20383. * @param scene defines the hosting scene
  20384. * @returns true if fog must be enabled
  20385. */
  20386. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20387. /**
  20388. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20389. * @param mesh defines the current mesh
  20390. * @param scene defines the current scene
  20391. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20392. * @param pointsCloud defines if point cloud rendering has to be turned on
  20393. * @param fogEnabled defines if fog has to be turned on
  20394. * @param alphaTest defines if alpha testing has to be turned on
  20395. * @param defines defines the current list of defines
  20396. */
  20397. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20398. /**
  20399. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20400. * @param scene defines the current scene
  20401. * @param engine defines the current engine
  20402. * @param defines specifies the list of active defines
  20403. * @param useInstances defines if instances have to be turned on
  20404. * @param useClipPlane defines if clip plane have to be turned on
  20405. * @param useInstances defines if instances have to be turned on
  20406. * @param useThinInstances defines if thin instances have to be turned on
  20407. */
  20408. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20409. /**
  20410. * Prepares the defines for bones
  20411. * @param mesh The mesh containing the geometry data we will draw
  20412. * @param defines The defines to update
  20413. */
  20414. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20415. /**
  20416. * Prepares the defines for morph targets
  20417. * @param mesh The mesh containing the geometry data we will draw
  20418. * @param defines The defines to update
  20419. */
  20420. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20421. /**
  20422. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20423. * @param mesh The mesh containing the geometry data we will draw
  20424. * @param defines The defines to update
  20425. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20426. * @param useBones Precise whether bones should be used or not (override mesh info)
  20427. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20428. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20429. * @returns false if defines are considered not dirty and have not been checked
  20430. */
  20431. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20432. /**
  20433. * Prepares the defines related to multiview
  20434. * @param scene The scene we are intending to draw
  20435. * @param defines The defines to update
  20436. */
  20437. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20438. /**
  20439. * Prepares the defines related to the prepass
  20440. * @param scene The scene we are intending to draw
  20441. * @param defines The defines to update
  20442. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20443. */
  20444. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20445. /**
  20446. * Prepares the defines related to the light information passed in parameter
  20447. * @param scene The scene we are intending to draw
  20448. * @param mesh The mesh the effect is compiling for
  20449. * @param light The light the effect is compiling for
  20450. * @param lightIndex The index of the light
  20451. * @param defines The defines to update
  20452. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20453. * @param state Defines the current state regarding what is needed (normals, etc...)
  20454. */
  20455. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20456. needNormals: boolean;
  20457. needRebuild: boolean;
  20458. shadowEnabled: boolean;
  20459. specularEnabled: boolean;
  20460. lightmapMode: boolean;
  20461. }): void;
  20462. /**
  20463. * Prepares the defines related to the light information passed in parameter
  20464. * @param scene The scene we are intending to draw
  20465. * @param mesh The mesh the effect is compiling for
  20466. * @param defines The defines to update
  20467. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20468. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20469. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20470. * @returns true if normals will be required for the rest of the effect
  20471. */
  20472. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20473. /**
  20474. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20475. * @param lightIndex defines the light index
  20476. * @param uniformsList The uniform list
  20477. * @param samplersList The sampler list
  20478. * @param projectedLightTexture defines if projected texture must be used
  20479. * @param uniformBuffersList defines an optional list of uniform buffers
  20480. */
  20481. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20482. /**
  20483. * Prepares the uniforms and samplers list to be used in the effect
  20484. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20485. * @param samplersList The sampler list
  20486. * @param defines The defines helping in the list generation
  20487. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20488. */
  20489. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20490. /**
  20491. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20492. * @param defines The defines to update while falling back
  20493. * @param fallbacks The authorized effect fallbacks
  20494. * @param maxSimultaneousLights The maximum number of lights allowed
  20495. * @param rank the current rank of the Effect
  20496. * @returns The newly affected rank
  20497. */
  20498. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20499. private static _TmpMorphInfluencers;
  20500. /**
  20501. * Prepares the list of attributes required for morph targets according to the effect defines.
  20502. * @param attribs The current list of supported attribs
  20503. * @param mesh The mesh to prepare the morph targets attributes for
  20504. * @param influencers The number of influencers
  20505. */
  20506. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20507. /**
  20508. * Prepares the list of attributes required for morph targets according to the effect defines.
  20509. * @param attribs The current list of supported attribs
  20510. * @param mesh The mesh to prepare the morph targets attributes for
  20511. * @param defines The current Defines of the effect
  20512. */
  20513. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20514. /**
  20515. * Prepares the list of attributes required for bones according to the effect defines.
  20516. * @param attribs The current list of supported attribs
  20517. * @param mesh The mesh to prepare the bones attributes for
  20518. * @param defines The current Defines of the effect
  20519. * @param fallbacks The current efffect fallback strategy
  20520. */
  20521. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20522. /**
  20523. * Check and prepare the list of attributes required for instances according to the effect defines.
  20524. * @param attribs The current list of supported attribs
  20525. * @param defines The current MaterialDefines of the effect
  20526. */
  20527. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20528. /**
  20529. * Add the list of attributes required for instances to the attribs array.
  20530. * @param attribs The current list of supported attribs
  20531. */
  20532. static PushAttributesForInstances(attribs: string[]): void;
  20533. /**
  20534. * Binds the light information to the effect.
  20535. * @param light The light containing the generator
  20536. * @param effect The effect we are binding the data to
  20537. * @param lightIndex The light index in the effect used to render
  20538. */
  20539. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20540. /**
  20541. * Binds the lights information from the scene to the effect for the given mesh.
  20542. * @param light Light to bind
  20543. * @param lightIndex Light index
  20544. * @param scene The scene where the light belongs to
  20545. * @param effect The effect we are binding the data to
  20546. * @param useSpecular Defines if specular is supported
  20547. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20548. */
  20549. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20550. /**
  20551. * Binds the lights information from the scene to the effect for the given mesh.
  20552. * @param scene The scene the lights belongs to
  20553. * @param mesh The mesh we are binding the information to render
  20554. * @param effect The effect we are binding the data to
  20555. * @param defines The generated defines for the effect
  20556. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20557. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20558. */
  20559. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20560. private static _tempFogColor;
  20561. /**
  20562. * Binds the fog information from the scene to the effect for the given mesh.
  20563. * @param scene The scene the lights belongs to
  20564. * @param mesh The mesh we are binding the information to render
  20565. * @param effect The effect we are binding the data to
  20566. * @param linearSpace Defines if the fog effect is applied in linear space
  20567. */
  20568. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20569. /**
  20570. * Binds the bones information from the mesh to the effect.
  20571. * @param mesh The mesh we are binding the information to render
  20572. * @param effect The effect we are binding the data to
  20573. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20574. */
  20575. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20576. private static _CopyBonesTransformationMatrices;
  20577. /**
  20578. * Binds the morph targets information from the mesh to the effect.
  20579. * @param abstractMesh The mesh we are binding the information to render
  20580. * @param effect The effect we are binding the data to
  20581. */
  20582. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20583. /**
  20584. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20585. * @param defines The generated defines used in the effect
  20586. * @param effect The effect we are binding the data to
  20587. * @param scene The scene we are willing to render with logarithmic scale for
  20588. */
  20589. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20590. /**
  20591. * Binds the clip plane information from the scene to the effect.
  20592. * @param scene The scene the clip plane information are extracted from
  20593. * @param effect The effect we are binding the data to
  20594. */
  20595. static BindClipPlane(effect: Effect, scene: Scene): void;
  20596. }
  20597. }
  20598. declare module BABYLON {
  20599. /**
  20600. * Block used to expose an input value
  20601. */
  20602. export class InputBlock extends NodeMaterialBlock {
  20603. private _mode;
  20604. private _associatedVariableName;
  20605. private _storedValue;
  20606. private _valueCallback;
  20607. private _type;
  20608. private _animationType;
  20609. /** Gets or set a value used to limit the range of float values */
  20610. min: number;
  20611. /** Gets or set a value used to limit the range of float values */
  20612. max: number;
  20613. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20614. isBoolean: boolean;
  20615. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20616. matrixMode: number;
  20617. /** @hidden */
  20618. _systemValue: Nullable<NodeMaterialSystemValues>;
  20619. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20620. isConstant: boolean;
  20621. /** Gets or sets the group to use to display this block in the Inspector */
  20622. groupInInspector: string;
  20623. /** Gets an observable raised when the value is changed */
  20624. onValueChangedObservable: Observable<InputBlock>;
  20625. /**
  20626. * Gets or sets the connection point type (default is float)
  20627. */
  20628. get type(): NodeMaterialBlockConnectionPointTypes;
  20629. /**
  20630. * Creates a new InputBlock
  20631. * @param name defines the block name
  20632. * @param target defines the target of that block (Vertex by default)
  20633. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20634. */
  20635. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20636. /**
  20637. * Validates if a name is a reserve word.
  20638. * @param newName the new name to be given to the node.
  20639. * @returns false if the name is a reserve word, else true.
  20640. */
  20641. validateBlockName(newName: string): boolean;
  20642. /**
  20643. * Gets the output component
  20644. */
  20645. get output(): NodeMaterialConnectionPoint;
  20646. /**
  20647. * Set the source of this connection point to a vertex attribute
  20648. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20649. * @returns the current connection point
  20650. */
  20651. setAsAttribute(attributeName?: string): InputBlock;
  20652. /**
  20653. * Set the source of this connection point to a system value
  20654. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20655. * @returns the current connection point
  20656. */
  20657. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20658. /**
  20659. * Gets or sets the value of that point.
  20660. * Please note that this value will be ignored if valueCallback is defined
  20661. */
  20662. get value(): any;
  20663. set value(value: any);
  20664. /**
  20665. * Gets or sets a callback used to get the value of that point.
  20666. * Please note that setting this value will force the connection point to ignore the value property
  20667. */
  20668. get valueCallback(): () => any;
  20669. set valueCallback(value: () => any);
  20670. /**
  20671. * Gets or sets the associated variable name in the shader
  20672. */
  20673. get associatedVariableName(): string;
  20674. set associatedVariableName(value: string);
  20675. /** Gets or sets the type of animation applied to the input */
  20676. get animationType(): AnimatedInputBlockTypes;
  20677. set animationType(value: AnimatedInputBlockTypes);
  20678. /**
  20679. * Gets a boolean indicating that this connection point not defined yet
  20680. */
  20681. get isUndefined(): boolean;
  20682. /**
  20683. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20684. * In this case the connection point name must be the name of the uniform to use.
  20685. * Can only be set on inputs
  20686. */
  20687. get isUniform(): boolean;
  20688. set isUniform(value: boolean);
  20689. /**
  20690. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20691. * In this case the connection point name must be the name of the attribute to use
  20692. * Can only be set on inputs
  20693. */
  20694. get isAttribute(): boolean;
  20695. set isAttribute(value: boolean);
  20696. /**
  20697. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20698. * Can only be set on exit points
  20699. */
  20700. get isVarying(): boolean;
  20701. set isVarying(value: boolean);
  20702. /**
  20703. * Gets a boolean indicating that the current connection point is a system value
  20704. */
  20705. get isSystemValue(): boolean;
  20706. /**
  20707. * Gets or sets the current well known value or null if not defined as a system value
  20708. */
  20709. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20710. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20711. /**
  20712. * Gets the current class name
  20713. * @returns the class name
  20714. */
  20715. getClassName(): string;
  20716. /**
  20717. * Animate the input if animationType !== None
  20718. * @param scene defines the rendering scene
  20719. */
  20720. animate(scene: Scene): void;
  20721. private _emitDefine;
  20722. initialize(state: NodeMaterialBuildState): void;
  20723. /**
  20724. * Set the input block to its default value (based on its type)
  20725. */
  20726. setDefaultValue(): void;
  20727. private _emitConstant;
  20728. /** @hidden */
  20729. get _noContextSwitch(): boolean;
  20730. private _emit;
  20731. /** @hidden */
  20732. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20733. /** @hidden */
  20734. _transmit(effect: Effect, scene: Scene): void;
  20735. protected _buildBlock(state: NodeMaterialBuildState): void;
  20736. protected _dumpPropertiesCode(): string;
  20737. dispose(): void;
  20738. serialize(): any;
  20739. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20740. }
  20741. }
  20742. declare module BABYLON {
  20743. /**
  20744. * Enum used to define the compatibility state between two connection points
  20745. */
  20746. export enum NodeMaterialConnectionPointCompatibilityStates {
  20747. /** Points are compatibles */
  20748. Compatible = 0,
  20749. /** Points are incompatible because of their types */
  20750. TypeIncompatible = 1,
  20751. /** Points are incompatible because of their targets (vertex vs fragment) */
  20752. TargetIncompatible = 2
  20753. }
  20754. /**
  20755. * Defines the direction of a connection point
  20756. */
  20757. export enum NodeMaterialConnectionPointDirection {
  20758. /** Input */
  20759. Input = 0,
  20760. /** Output */
  20761. Output = 1
  20762. }
  20763. /**
  20764. * Defines a connection point for a block
  20765. */
  20766. export class NodeMaterialConnectionPoint {
  20767. /** @hidden */
  20768. _ownerBlock: NodeMaterialBlock;
  20769. /** @hidden */
  20770. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20771. private _endpoints;
  20772. private _associatedVariableName;
  20773. private _direction;
  20774. /** @hidden */
  20775. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20776. /** @hidden */
  20777. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20778. private _type;
  20779. /** @hidden */
  20780. _enforceAssociatedVariableName: boolean;
  20781. /** Gets the direction of the point */
  20782. get direction(): NodeMaterialConnectionPointDirection;
  20783. /** Indicates that this connection point needs dual validation before being connected to another point */
  20784. needDualDirectionValidation: boolean;
  20785. /**
  20786. * Gets or sets the additional types supported by this connection point
  20787. */
  20788. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20789. /**
  20790. * Gets or sets the additional types excluded by this connection point
  20791. */
  20792. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20793. /**
  20794. * Observable triggered when this point is connected
  20795. */
  20796. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20797. /**
  20798. * Gets or sets the associated variable name in the shader
  20799. */
  20800. get associatedVariableName(): string;
  20801. set associatedVariableName(value: string);
  20802. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20803. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20804. /**
  20805. * Gets or sets the connection point type (default is float)
  20806. */
  20807. get type(): NodeMaterialBlockConnectionPointTypes;
  20808. set type(value: NodeMaterialBlockConnectionPointTypes);
  20809. /**
  20810. * Gets or sets the connection point name
  20811. */
  20812. name: string;
  20813. /**
  20814. * Gets or sets the connection point name
  20815. */
  20816. displayName: string;
  20817. /**
  20818. * Gets or sets a boolean indicating that this connection point can be omitted
  20819. */
  20820. isOptional: boolean;
  20821. /**
  20822. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20823. */
  20824. isExposedOnFrame: boolean;
  20825. /**
  20826. * Gets or sets number indicating the position that the port is exposed to on a frame
  20827. */
  20828. exposedPortPosition: number;
  20829. /**
  20830. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20831. */
  20832. define: string;
  20833. /** @hidden */
  20834. _prioritizeVertex: boolean;
  20835. private _target;
  20836. /** Gets or sets the target of that connection point */
  20837. get target(): NodeMaterialBlockTargets;
  20838. set target(value: NodeMaterialBlockTargets);
  20839. /**
  20840. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20841. */
  20842. get isConnected(): boolean;
  20843. /**
  20844. * Gets a boolean indicating that the current point is connected to an input block
  20845. */
  20846. get isConnectedToInputBlock(): boolean;
  20847. /**
  20848. * Gets a the connected input block (if any)
  20849. */
  20850. get connectInputBlock(): Nullable<InputBlock>;
  20851. /** Get the other side of the connection (if any) */
  20852. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20853. /** Get the block that owns this connection point */
  20854. get ownerBlock(): NodeMaterialBlock;
  20855. /** Get the block connected on the other side of this connection (if any) */
  20856. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20857. /** Get the block connected on the endpoints of this connection (if any) */
  20858. get connectedBlocks(): Array<NodeMaterialBlock>;
  20859. /** Gets the list of connected endpoints */
  20860. get endpoints(): NodeMaterialConnectionPoint[];
  20861. /** Gets a boolean indicating if that output point is connected to at least one input */
  20862. get hasEndpoints(): boolean;
  20863. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20864. get isConnectedInVertexShader(): boolean;
  20865. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20866. get isConnectedInFragmentShader(): boolean;
  20867. /**
  20868. * Creates a block suitable to be used as an input for this input point.
  20869. * If null is returned, a block based on the point type will be created.
  20870. * @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
  20871. */
  20872. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20873. /**
  20874. * Creates a new connection point
  20875. * @param name defines the connection point name
  20876. * @param ownerBlock defines the block hosting this connection point
  20877. * @param direction defines the direction of the connection point
  20878. */
  20879. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20880. /**
  20881. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20882. * @returns the class name
  20883. */
  20884. getClassName(): string;
  20885. /**
  20886. * Gets a boolean indicating if the current point can be connected to another point
  20887. * @param connectionPoint defines the other connection point
  20888. * @returns a boolean
  20889. */
  20890. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20891. /**
  20892. * Gets a number indicating if the current point can be connected to another point
  20893. * @param connectionPoint defines the other connection point
  20894. * @returns a number defining the compatibility state
  20895. */
  20896. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20897. /**
  20898. * Connect this point to another connection point
  20899. * @param connectionPoint defines the other connection point
  20900. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20901. * @returns the current connection point
  20902. */
  20903. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20904. /**
  20905. * Disconnect this point from one of his endpoint
  20906. * @param endpoint defines the other connection point
  20907. * @returns the current connection point
  20908. */
  20909. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20910. /**
  20911. * Serializes this point in a JSON representation
  20912. * @param isInput defines if the connection point is an input (default is true)
  20913. * @returns the serialized point object
  20914. */
  20915. serialize(isInput?: boolean): any;
  20916. /**
  20917. * Release resources
  20918. */
  20919. dispose(): void;
  20920. }
  20921. }
  20922. declare module BABYLON {
  20923. /**
  20924. * Enum used to define the material modes
  20925. */
  20926. export enum NodeMaterialModes {
  20927. /** Regular material */
  20928. Material = 0,
  20929. /** For post process */
  20930. PostProcess = 1,
  20931. /** For particle system */
  20932. Particle = 2,
  20933. /** For procedural texture */
  20934. ProceduralTexture = 3
  20935. }
  20936. }
  20937. declare module BABYLON {
  20938. /**
  20939. * Block used to read a texture from a sampler
  20940. */
  20941. export class TextureBlock extends NodeMaterialBlock {
  20942. private _defineName;
  20943. private _linearDefineName;
  20944. private _gammaDefineName;
  20945. private _tempTextureRead;
  20946. private _samplerName;
  20947. private _transformedUVName;
  20948. private _textureTransformName;
  20949. private _textureInfoName;
  20950. private _mainUVName;
  20951. private _mainUVDefineName;
  20952. private _fragmentOnly;
  20953. /**
  20954. * Gets or sets the texture associated with the node
  20955. */
  20956. texture: Nullable<Texture>;
  20957. /**
  20958. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20959. */
  20960. convertToGammaSpace: boolean;
  20961. /**
  20962. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20963. */
  20964. convertToLinearSpace: boolean;
  20965. /**
  20966. * Create a new TextureBlock
  20967. * @param name defines the block name
  20968. */
  20969. constructor(name: string, fragmentOnly?: boolean);
  20970. /**
  20971. * Gets the current class name
  20972. * @returns the class name
  20973. */
  20974. getClassName(): string;
  20975. /**
  20976. * Gets the uv input component
  20977. */
  20978. get uv(): NodeMaterialConnectionPoint;
  20979. /**
  20980. * Gets the rgba output component
  20981. */
  20982. get rgba(): NodeMaterialConnectionPoint;
  20983. /**
  20984. * Gets the rgb output component
  20985. */
  20986. get rgb(): NodeMaterialConnectionPoint;
  20987. /**
  20988. * Gets the r output component
  20989. */
  20990. get r(): NodeMaterialConnectionPoint;
  20991. /**
  20992. * Gets the g output component
  20993. */
  20994. get g(): NodeMaterialConnectionPoint;
  20995. /**
  20996. * Gets the b output component
  20997. */
  20998. get b(): NodeMaterialConnectionPoint;
  20999. /**
  21000. * Gets the a output component
  21001. */
  21002. get a(): NodeMaterialConnectionPoint;
  21003. get target(): NodeMaterialBlockTargets;
  21004. autoConfigure(material: NodeMaterial): void;
  21005. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21006. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21007. isReady(): boolean;
  21008. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21009. private get _isMixed();
  21010. private _injectVertexCode;
  21011. private _writeTextureRead;
  21012. private _writeOutput;
  21013. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21014. protected _dumpPropertiesCode(): string;
  21015. serialize(): any;
  21016. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21017. }
  21018. }
  21019. declare module BABYLON {
  21020. /** @hidden */
  21021. export var reflectionFunction: {
  21022. name: string;
  21023. shader: string;
  21024. };
  21025. }
  21026. declare module BABYLON {
  21027. /**
  21028. * Base block used to read a reflection texture from a sampler
  21029. */
  21030. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21031. /** @hidden */
  21032. _define3DName: string;
  21033. /** @hidden */
  21034. _defineCubicName: string;
  21035. /** @hidden */
  21036. _defineExplicitName: string;
  21037. /** @hidden */
  21038. _defineProjectionName: string;
  21039. /** @hidden */
  21040. _defineLocalCubicName: string;
  21041. /** @hidden */
  21042. _defineSphericalName: string;
  21043. /** @hidden */
  21044. _definePlanarName: string;
  21045. /** @hidden */
  21046. _defineEquirectangularName: string;
  21047. /** @hidden */
  21048. _defineMirroredEquirectangularFixedName: string;
  21049. /** @hidden */
  21050. _defineEquirectangularFixedName: string;
  21051. /** @hidden */
  21052. _defineSkyboxName: string;
  21053. /** @hidden */
  21054. _defineOppositeZ: string;
  21055. /** @hidden */
  21056. _cubeSamplerName: string;
  21057. /** @hidden */
  21058. _2DSamplerName: string;
  21059. protected _positionUVWName: string;
  21060. protected _directionWName: string;
  21061. protected _reflectionVectorName: string;
  21062. /** @hidden */
  21063. _reflectionCoordsName: string;
  21064. /** @hidden */
  21065. _reflectionMatrixName: string;
  21066. protected _reflectionColorName: string;
  21067. /**
  21068. * Gets or sets the texture associated with the node
  21069. */
  21070. texture: Nullable<BaseTexture>;
  21071. /**
  21072. * Create a new ReflectionTextureBaseBlock
  21073. * @param name defines the block name
  21074. */
  21075. constructor(name: string);
  21076. /**
  21077. * Gets the current class name
  21078. * @returns the class name
  21079. */
  21080. getClassName(): string;
  21081. /**
  21082. * Gets the world position input component
  21083. */
  21084. abstract get position(): NodeMaterialConnectionPoint;
  21085. /**
  21086. * Gets the world position input component
  21087. */
  21088. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21089. /**
  21090. * Gets the world normal input component
  21091. */
  21092. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21093. /**
  21094. * Gets the world input component
  21095. */
  21096. abstract get world(): NodeMaterialConnectionPoint;
  21097. /**
  21098. * Gets the camera (or eye) position component
  21099. */
  21100. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21101. /**
  21102. * Gets the view input component
  21103. */
  21104. abstract get view(): NodeMaterialConnectionPoint;
  21105. protected _getTexture(): Nullable<BaseTexture>;
  21106. autoConfigure(material: NodeMaterial): void;
  21107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21108. isReady(): boolean;
  21109. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21110. /**
  21111. * Gets the code to inject in the vertex shader
  21112. * @param state current state of the node material building
  21113. * @returns the shader code
  21114. */
  21115. handleVertexSide(state: NodeMaterialBuildState): string;
  21116. /**
  21117. * Handles the inits for the fragment code path
  21118. * @param state node material build state
  21119. */
  21120. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21121. /**
  21122. * Generates the reflection coords code for the fragment code path
  21123. * @param worldNormalVarName name of the world normal variable
  21124. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21125. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21126. * @returns the shader code
  21127. */
  21128. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21129. /**
  21130. * Generates the reflection color code for the fragment code path
  21131. * @param lodVarName name of the lod variable
  21132. * @param swizzleLookupTexture swizzle to use for the final color variable
  21133. * @returns the shader code
  21134. */
  21135. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21136. /**
  21137. * Generates the code corresponding to the connected output points
  21138. * @param state node material build state
  21139. * @param varName name of the variable to output
  21140. * @returns the shader code
  21141. */
  21142. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21143. protected _buildBlock(state: NodeMaterialBuildState): this;
  21144. protected _dumpPropertiesCode(): string;
  21145. serialize(): any;
  21146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21147. }
  21148. }
  21149. declare module BABYLON {
  21150. /**
  21151. * Defines a connection point to be used for points with a custom object type
  21152. */
  21153. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21154. private _blockType;
  21155. private _blockName;
  21156. private _nameForCheking?;
  21157. /**
  21158. * Creates a new connection point
  21159. * @param name defines the connection point name
  21160. * @param ownerBlock defines the block hosting this connection point
  21161. * @param direction defines the direction of the connection point
  21162. */
  21163. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21164. /**
  21165. * Gets a number indicating if the current point can be connected to another point
  21166. * @param connectionPoint defines the other connection point
  21167. * @returns a number defining the compatibility state
  21168. */
  21169. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21170. /**
  21171. * Creates a block suitable to be used as an input for this input point.
  21172. * If null is returned, a block based on the point type will be created.
  21173. * @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
  21174. */
  21175. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21176. }
  21177. }
  21178. declare module BABYLON {
  21179. /**
  21180. * Enum defining the type of properties that can be edited in the property pages in the NME
  21181. */
  21182. export enum PropertyTypeForEdition {
  21183. /** property is a boolean */
  21184. Boolean = 0,
  21185. /** property is a float */
  21186. Float = 1,
  21187. /** property is a Vector2 */
  21188. Vector2 = 2,
  21189. /** property is a list of values */
  21190. List = 3
  21191. }
  21192. /**
  21193. * Interface that defines an option in a variable of type list
  21194. */
  21195. export interface IEditablePropertyListOption {
  21196. /** label of the option */
  21197. "label": string;
  21198. /** value of the option */
  21199. "value": number;
  21200. }
  21201. /**
  21202. * Interface that defines the options available for an editable property
  21203. */
  21204. export interface IEditablePropertyOption {
  21205. /** min value */
  21206. "min"?: number;
  21207. /** max value */
  21208. "max"?: number;
  21209. /** notifiers: indicates which actions to take when the property is changed */
  21210. "notifiers"?: {
  21211. /** the material should be rebuilt */
  21212. "rebuild"?: boolean;
  21213. /** the preview should be updated */
  21214. "update"?: boolean;
  21215. };
  21216. /** list of the options for a variable of type list */
  21217. "options"?: IEditablePropertyListOption[];
  21218. }
  21219. /**
  21220. * Interface that describes an editable property
  21221. */
  21222. export interface IPropertyDescriptionForEdition {
  21223. /** name of the property */
  21224. "propertyName": string;
  21225. /** display name of the property */
  21226. "displayName": string;
  21227. /** type of the property */
  21228. "type": PropertyTypeForEdition;
  21229. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21230. "groupName": string;
  21231. /** options for the property */
  21232. "options": IEditablePropertyOption;
  21233. }
  21234. /**
  21235. * Decorator that flags a property in a node material block as being editable
  21236. */
  21237. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21238. }
  21239. declare module BABYLON {
  21240. /**
  21241. * Block used to implement the refraction part of the sub surface module of the PBR material
  21242. */
  21243. export class RefractionBlock extends NodeMaterialBlock {
  21244. /** @hidden */
  21245. _define3DName: string;
  21246. /** @hidden */
  21247. _refractionMatrixName: string;
  21248. /** @hidden */
  21249. _defineLODRefractionAlpha: string;
  21250. /** @hidden */
  21251. _defineLinearSpecularRefraction: string;
  21252. /** @hidden */
  21253. _defineOppositeZ: string;
  21254. /** @hidden */
  21255. _cubeSamplerName: string;
  21256. /** @hidden */
  21257. _2DSamplerName: string;
  21258. /** @hidden */
  21259. _vRefractionMicrosurfaceInfosName: string;
  21260. /** @hidden */
  21261. _vRefractionInfosName: string;
  21262. private _scene;
  21263. /**
  21264. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21265. * Materials half opaque for instance using refraction could benefit from this control.
  21266. */
  21267. linkRefractionWithTransparency: boolean;
  21268. /**
  21269. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21270. */
  21271. invertRefractionY: boolean;
  21272. /**
  21273. * Gets or sets the texture associated with the node
  21274. */
  21275. texture: Nullable<BaseTexture>;
  21276. /**
  21277. * Create a new RefractionBlock
  21278. * @param name defines the block name
  21279. */
  21280. constructor(name: string);
  21281. /**
  21282. * Gets the current class name
  21283. * @returns the class name
  21284. */
  21285. getClassName(): string;
  21286. /**
  21287. * Gets the intensity input component
  21288. */
  21289. get intensity(): NodeMaterialConnectionPoint;
  21290. /**
  21291. * Gets the index of refraction input component
  21292. */
  21293. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21294. /**
  21295. * Gets the tint at distance input component
  21296. */
  21297. get tintAtDistance(): NodeMaterialConnectionPoint;
  21298. /**
  21299. * Gets the view input component
  21300. */
  21301. get view(): NodeMaterialConnectionPoint;
  21302. /**
  21303. * Gets the refraction object output component
  21304. */
  21305. get refraction(): NodeMaterialConnectionPoint;
  21306. /**
  21307. * Returns true if the block has a texture
  21308. */
  21309. get hasTexture(): boolean;
  21310. protected _getTexture(): Nullable<BaseTexture>;
  21311. autoConfigure(material: NodeMaterial): void;
  21312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21313. isReady(): boolean;
  21314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21315. /**
  21316. * Gets the main code of the block (fragment side)
  21317. * @param state current state of the node material building
  21318. * @returns the shader code
  21319. */
  21320. getCode(state: NodeMaterialBuildState): string;
  21321. protected _buildBlock(state: NodeMaterialBuildState): this;
  21322. protected _dumpPropertiesCode(): string;
  21323. serialize(): any;
  21324. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21325. }
  21326. }
  21327. declare module BABYLON {
  21328. /**
  21329. * Base block used as input for post process
  21330. */
  21331. export class CurrentScreenBlock extends NodeMaterialBlock {
  21332. private _samplerName;
  21333. private _linearDefineName;
  21334. private _gammaDefineName;
  21335. private _mainUVName;
  21336. private _tempTextureRead;
  21337. /**
  21338. * Gets or sets the texture associated with the node
  21339. */
  21340. texture: Nullable<BaseTexture>;
  21341. /**
  21342. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21343. */
  21344. convertToGammaSpace: boolean;
  21345. /**
  21346. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21347. */
  21348. convertToLinearSpace: boolean;
  21349. /**
  21350. * Create a new CurrentScreenBlock
  21351. * @param name defines the block name
  21352. */
  21353. constructor(name: string);
  21354. /**
  21355. * Gets the current class name
  21356. * @returns the class name
  21357. */
  21358. getClassName(): string;
  21359. /**
  21360. * Gets the uv input component
  21361. */
  21362. get uv(): NodeMaterialConnectionPoint;
  21363. /**
  21364. * Gets the rgba output component
  21365. */
  21366. get rgba(): NodeMaterialConnectionPoint;
  21367. /**
  21368. * Gets the rgb output component
  21369. */
  21370. get rgb(): NodeMaterialConnectionPoint;
  21371. /**
  21372. * Gets the r output component
  21373. */
  21374. get r(): NodeMaterialConnectionPoint;
  21375. /**
  21376. * Gets the g output component
  21377. */
  21378. get g(): NodeMaterialConnectionPoint;
  21379. /**
  21380. * Gets the b output component
  21381. */
  21382. get b(): NodeMaterialConnectionPoint;
  21383. /**
  21384. * Gets the a output component
  21385. */
  21386. get a(): NodeMaterialConnectionPoint;
  21387. /**
  21388. * Initialize the block and prepare the context for build
  21389. * @param state defines the state that will be used for the build
  21390. */
  21391. initialize(state: NodeMaterialBuildState): void;
  21392. get target(): NodeMaterialBlockTargets;
  21393. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21394. isReady(): boolean;
  21395. private _injectVertexCode;
  21396. private _writeTextureRead;
  21397. private _writeOutput;
  21398. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21399. serialize(): any;
  21400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21401. }
  21402. }
  21403. declare module BABYLON {
  21404. /**
  21405. * Base block used for the particle texture
  21406. */
  21407. export class ParticleTextureBlock extends NodeMaterialBlock {
  21408. private _samplerName;
  21409. private _linearDefineName;
  21410. private _gammaDefineName;
  21411. private _tempTextureRead;
  21412. /**
  21413. * Gets or sets the texture associated with the node
  21414. */
  21415. texture: Nullable<BaseTexture>;
  21416. /**
  21417. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21418. */
  21419. convertToGammaSpace: boolean;
  21420. /**
  21421. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21422. */
  21423. convertToLinearSpace: boolean;
  21424. /**
  21425. * Create a new ParticleTextureBlock
  21426. * @param name defines the block name
  21427. */
  21428. constructor(name: string);
  21429. /**
  21430. * Gets the current class name
  21431. * @returns the class name
  21432. */
  21433. getClassName(): string;
  21434. /**
  21435. * Gets the uv input component
  21436. */
  21437. get uv(): NodeMaterialConnectionPoint;
  21438. /**
  21439. * Gets the rgba output component
  21440. */
  21441. get rgba(): NodeMaterialConnectionPoint;
  21442. /**
  21443. * Gets the rgb output component
  21444. */
  21445. get rgb(): NodeMaterialConnectionPoint;
  21446. /**
  21447. * Gets the r output component
  21448. */
  21449. get r(): NodeMaterialConnectionPoint;
  21450. /**
  21451. * Gets the g output component
  21452. */
  21453. get g(): NodeMaterialConnectionPoint;
  21454. /**
  21455. * Gets the b output component
  21456. */
  21457. get b(): NodeMaterialConnectionPoint;
  21458. /**
  21459. * Gets the a output component
  21460. */
  21461. get a(): NodeMaterialConnectionPoint;
  21462. /**
  21463. * Initialize the block and prepare the context for build
  21464. * @param state defines the state that will be used for the build
  21465. */
  21466. initialize(state: NodeMaterialBuildState): void;
  21467. autoConfigure(material: NodeMaterial): void;
  21468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21469. isReady(): boolean;
  21470. private _writeOutput;
  21471. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21472. serialize(): any;
  21473. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21474. }
  21475. }
  21476. declare module BABYLON {
  21477. /**
  21478. * Class used to store shared data between 2 NodeMaterialBuildState
  21479. */
  21480. export class NodeMaterialBuildStateSharedData {
  21481. /**
  21482. * Gets the list of emitted varyings
  21483. */
  21484. temps: string[];
  21485. /**
  21486. * Gets the list of emitted varyings
  21487. */
  21488. varyings: string[];
  21489. /**
  21490. * Gets the varying declaration string
  21491. */
  21492. varyingDeclaration: string;
  21493. /**
  21494. * Input blocks
  21495. */
  21496. inputBlocks: InputBlock[];
  21497. /**
  21498. * Input blocks
  21499. */
  21500. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21501. /**
  21502. * Bindable blocks (Blocks that need to set data to the effect)
  21503. */
  21504. bindableBlocks: NodeMaterialBlock[];
  21505. /**
  21506. * List of blocks that can provide a compilation fallback
  21507. */
  21508. blocksWithFallbacks: NodeMaterialBlock[];
  21509. /**
  21510. * List of blocks that can provide a define update
  21511. */
  21512. blocksWithDefines: NodeMaterialBlock[];
  21513. /**
  21514. * List of blocks that can provide a repeatable content
  21515. */
  21516. repeatableContentBlocks: NodeMaterialBlock[];
  21517. /**
  21518. * List of blocks that can provide a dynamic list of uniforms
  21519. */
  21520. dynamicUniformBlocks: NodeMaterialBlock[];
  21521. /**
  21522. * List of blocks that can block the isReady function for the material
  21523. */
  21524. blockingBlocks: NodeMaterialBlock[];
  21525. /**
  21526. * Gets the list of animated inputs
  21527. */
  21528. animatedInputs: InputBlock[];
  21529. /**
  21530. * Build Id used to avoid multiple recompilations
  21531. */
  21532. buildId: number;
  21533. /** List of emitted variables */
  21534. variableNames: {
  21535. [key: string]: number;
  21536. };
  21537. /** List of emitted defines */
  21538. defineNames: {
  21539. [key: string]: number;
  21540. };
  21541. /** Should emit comments? */
  21542. emitComments: boolean;
  21543. /** Emit build activity */
  21544. verbose: boolean;
  21545. /** Gets or sets the hosting scene */
  21546. scene: Scene;
  21547. /**
  21548. * Gets the compilation hints emitted at compilation time
  21549. */
  21550. hints: {
  21551. needWorldViewMatrix: boolean;
  21552. needWorldViewProjectionMatrix: boolean;
  21553. needAlphaBlending: boolean;
  21554. needAlphaTesting: boolean;
  21555. };
  21556. /**
  21557. * List of compilation checks
  21558. */
  21559. checks: {
  21560. emitVertex: boolean;
  21561. emitFragment: boolean;
  21562. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21563. };
  21564. /**
  21565. * Is vertex program allowed to be empty?
  21566. */
  21567. allowEmptyVertexProgram: boolean;
  21568. /** Creates a new shared data */
  21569. constructor();
  21570. /**
  21571. * Emits console errors and exceptions if there is a failing check
  21572. */
  21573. emitErrors(): void;
  21574. }
  21575. }
  21576. declare module BABYLON {
  21577. /**
  21578. * Class used to store node based material build state
  21579. */
  21580. export class NodeMaterialBuildState {
  21581. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21582. supportUniformBuffers: boolean;
  21583. /**
  21584. * Gets the list of emitted attributes
  21585. */
  21586. attributes: string[];
  21587. /**
  21588. * Gets the list of emitted uniforms
  21589. */
  21590. uniforms: string[];
  21591. /**
  21592. * Gets the list of emitted constants
  21593. */
  21594. constants: string[];
  21595. /**
  21596. * Gets the list of emitted samplers
  21597. */
  21598. samplers: string[];
  21599. /**
  21600. * Gets the list of emitted functions
  21601. */
  21602. functions: {
  21603. [key: string]: string;
  21604. };
  21605. /**
  21606. * Gets the list of emitted extensions
  21607. */
  21608. extensions: {
  21609. [key: string]: string;
  21610. };
  21611. /**
  21612. * Gets the target of the compilation state
  21613. */
  21614. target: NodeMaterialBlockTargets;
  21615. /**
  21616. * Gets the list of emitted counters
  21617. */
  21618. counters: {
  21619. [key: string]: number;
  21620. };
  21621. /**
  21622. * Shared data between multiple NodeMaterialBuildState instances
  21623. */
  21624. sharedData: NodeMaterialBuildStateSharedData;
  21625. /** @hidden */
  21626. _vertexState: NodeMaterialBuildState;
  21627. /** @hidden */
  21628. _attributeDeclaration: string;
  21629. /** @hidden */
  21630. _uniformDeclaration: string;
  21631. /** @hidden */
  21632. _constantDeclaration: string;
  21633. /** @hidden */
  21634. _samplerDeclaration: string;
  21635. /** @hidden */
  21636. _varyingTransfer: string;
  21637. /** @hidden */
  21638. _injectAtEnd: string;
  21639. private _repeatableContentAnchorIndex;
  21640. /** @hidden */
  21641. _builtCompilationString: string;
  21642. /**
  21643. * Gets the emitted compilation strings
  21644. */
  21645. compilationString: string;
  21646. /**
  21647. * Finalize the compilation strings
  21648. * @param state defines the current compilation state
  21649. */
  21650. finalize(state: NodeMaterialBuildState): void;
  21651. /** @hidden */
  21652. get _repeatableContentAnchor(): string;
  21653. /** @hidden */
  21654. _getFreeVariableName(prefix: string): string;
  21655. /** @hidden */
  21656. _getFreeDefineName(prefix: string): string;
  21657. /** @hidden */
  21658. _excludeVariableName(name: string): void;
  21659. /** @hidden */
  21660. _emit2DSampler(name: string): void;
  21661. /** @hidden */
  21662. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21663. /** @hidden */
  21664. _emitExtension(name: string, extension: string, define?: string): void;
  21665. /** @hidden */
  21666. _emitFunction(name: string, code: string, comments: string): void;
  21667. /** @hidden */
  21668. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21669. replaceStrings?: {
  21670. search: RegExp;
  21671. replace: string;
  21672. }[];
  21673. repeatKey?: string;
  21674. }): string;
  21675. /** @hidden */
  21676. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21677. repeatKey?: string;
  21678. removeAttributes?: boolean;
  21679. removeUniforms?: boolean;
  21680. removeVaryings?: boolean;
  21681. removeIfDef?: boolean;
  21682. replaceStrings?: {
  21683. search: RegExp;
  21684. replace: string;
  21685. }[];
  21686. }, storeKey?: string): void;
  21687. /** @hidden */
  21688. _registerTempVariable(name: string): boolean;
  21689. /** @hidden */
  21690. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21691. /** @hidden */
  21692. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21693. /** @hidden */
  21694. _emitFloat(value: number): string;
  21695. }
  21696. }
  21697. declare module BABYLON {
  21698. /**
  21699. * Helper class used to generate session unique ID
  21700. */
  21701. export class UniqueIdGenerator {
  21702. private static _UniqueIdCounter;
  21703. /**
  21704. * Gets an unique (relatively to the current scene) Id
  21705. */
  21706. static get UniqueId(): number;
  21707. }
  21708. }
  21709. declare module BABYLON {
  21710. /**
  21711. * Defines a block that can be used inside a node based material
  21712. */
  21713. export class NodeMaterialBlock {
  21714. private _buildId;
  21715. private _buildTarget;
  21716. private _target;
  21717. private _isFinalMerger;
  21718. private _isInput;
  21719. private _name;
  21720. protected _isUnique: boolean;
  21721. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21722. inputsAreExclusive: boolean;
  21723. /** @hidden */
  21724. _codeVariableName: string;
  21725. /** @hidden */
  21726. _inputs: NodeMaterialConnectionPoint[];
  21727. /** @hidden */
  21728. _outputs: NodeMaterialConnectionPoint[];
  21729. /** @hidden */
  21730. _preparationId: number;
  21731. /**
  21732. * Gets the name of the block
  21733. */
  21734. get name(): string;
  21735. /**
  21736. * Sets the name of the block. Will check if the name is valid.
  21737. */
  21738. set name(newName: string);
  21739. /**
  21740. * Gets or sets the unique id of the node
  21741. */
  21742. uniqueId: number;
  21743. /**
  21744. * Gets or sets the comments associated with this block
  21745. */
  21746. comments: string;
  21747. /**
  21748. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21749. */
  21750. get isUnique(): boolean;
  21751. /**
  21752. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21753. */
  21754. get isFinalMerger(): boolean;
  21755. /**
  21756. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21757. */
  21758. get isInput(): boolean;
  21759. /**
  21760. * Gets or sets the build Id
  21761. */
  21762. get buildId(): number;
  21763. set buildId(value: number);
  21764. /**
  21765. * Gets or sets the target of the block
  21766. */
  21767. get target(): NodeMaterialBlockTargets;
  21768. set target(value: NodeMaterialBlockTargets);
  21769. /**
  21770. * Gets the list of input points
  21771. */
  21772. get inputs(): NodeMaterialConnectionPoint[];
  21773. /** Gets the list of output points */
  21774. get outputs(): NodeMaterialConnectionPoint[];
  21775. /**
  21776. * Find an input by its name
  21777. * @param name defines the name of the input to look for
  21778. * @returns the input or null if not found
  21779. */
  21780. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21781. /**
  21782. * Find an output by its name
  21783. * @param name defines the name of the outputto look for
  21784. * @returns the output or null if not found
  21785. */
  21786. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21787. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21788. visibleInInspector: boolean;
  21789. /**
  21790. * Creates a new NodeMaterialBlock
  21791. * @param name defines the block name
  21792. * @param target defines the target of that block (Vertex by default)
  21793. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21794. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21795. */
  21796. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21797. /**
  21798. * Initialize the block and prepare the context for build
  21799. * @param state defines the state that will be used for the build
  21800. */
  21801. initialize(state: NodeMaterialBuildState): void;
  21802. /**
  21803. * Bind data to effect. Will only be called for blocks with isBindable === true
  21804. * @param effect defines the effect to bind data to
  21805. * @param nodeMaterial defines the hosting NodeMaterial
  21806. * @param mesh defines the mesh that will be rendered
  21807. * @param subMesh defines the submesh that will be rendered
  21808. */
  21809. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21810. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21811. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21812. protected _writeFloat(value: number): string;
  21813. /**
  21814. * Gets the current class name e.g. "NodeMaterialBlock"
  21815. * @returns the class name
  21816. */
  21817. getClassName(): string;
  21818. /**
  21819. * Register a new input. Must be called inside a block constructor
  21820. * @param name defines the connection point name
  21821. * @param type defines the connection point type
  21822. * @param isOptional defines a boolean indicating that this input can be omitted
  21823. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21824. * @param point an already created connection point. If not provided, create a new one
  21825. * @returns the current block
  21826. */
  21827. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21828. /**
  21829. * Register a new output. Must be called inside a block constructor
  21830. * @param name defines the connection point name
  21831. * @param type defines the connection point type
  21832. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21833. * @param point an already created connection point. If not provided, create a new one
  21834. * @returns the current block
  21835. */
  21836. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21837. /**
  21838. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21839. * @param forOutput defines an optional connection point to check compatibility with
  21840. * @returns the first available input or null
  21841. */
  21842. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21843. /**
  21844. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21845. * @param forBlock defines an optional block to check compatibility with
  21846. * @returns the first available input or null
  21847. */
  21848. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21849. /**
  21850. * Gets the sibling of the given output
  21851. * @param current defines the current output
  21852. * @returns the next output in the list or null
  21853. */
  21854. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21855. /**
  21856. * Connect current block with another block
  21857. * @param other defines the block to connect with
  21858. * @param options define the various options to help pick the right connections
  21859. * @returns the current block
  21860. */
  21861. connectTo(other: NodeMaterialBlock, options?: {
  21862. input?: string;
  21863. output?: string;
  21864. outputSwizzle?: string;
  21865. }): this | undefined;
  21866. protected _buildBlock(state: NodeMaterialBuildState): void;
  21867. /**
  21868. * Add uniforms, samplers and uniform buffers at compilation time
  21869. * @param state defines the state to update
  21870. * @param nodeMaterial defines the node material requesting the update
  21871. * @param defines defines the material defines to update
  21872. * @param uniformBuffers defines the list of uniform buffer names
  21873. */
  21874. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21875. /**
  21876. * Add potential fallbacks if shader compilation fails
  21877. * @param mesh defines the mesh to be rendered
  21878. * @param fallbacks defines the current prioritized list of fallbacks
  21879. */
  21880. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21881. /**
  21882. * Initialize defines for shader compilation
  21883. * @param mesh defines the mesh to be rendered
  21884. * @param nodeMaterial defines the node material requesting the update
  21885. * @param defines defines the material defines to update
  21886. * @param useInstances specifies that instances should be used
  21887. */
  21888. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21889. /**
  21890. * Update defines for shader compilation
  21891. * @param mesh defines the mesh to be rendered
  21892. * @param nodeMaterial defines the node material requesting the update
  21893. * @param defines defines the material defines to update
  21894. * @param useInstances specifies that instances should be used
  21895. * @param subMesh defines which submesh to render
  21896. */
  21897. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21898. /**
  21899. * Lets the block try to connect some inputs automatically
  21900. * @param material defines the hosting NodeMaterial
  21901. */
  21902. autoConfigure(material: NodeMaterial): void;
  21903. /**
  21904. * Function called when a block is declared as repeatable content generator
  21905. * @param vertexShaderState defines the current compilation state for the vertex shader
  21906. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21907. * @param mesh defines the mesh to be rendered
  21908. * @param defines defines the material defines to update
  21909. */
  21910. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21911. /**
  21912. * Checks if the block is ready
  21913. * @param mesh defines the mesh to be rendered
  21914. * @param nodeMaterial defines the node material requesting the update
  21915. * @param defines defines the material defines to update
  21916. * @param useInstances specifies that instances should be used
  21917. * @returns true if the block is ready
  21918. */
  21919. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21920. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21921. private _processBuild;
  21922. /**
  21923. * Validates the new name for the block node.
  21924. * @param newName the new name to be given to the node.
  21925. * @returns false if the name is a reserve word, else true.
  21926. */
  21927. validateBlockName(newName: string): boolean;
  21928. /**
  21929. * Compile the current node and generate the shader code
  21930. * @param state defines the current compilation state (uniforms, samplers, current string)
  21931. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21932. * @returns true if already built
  21933. */
  21934. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21935. protected _inputRename(name: string): string;
  21936. protected _outputRename(name: string): string;
  21937. protected _dumpPropertiesCode(): string;
  21938. /** @hidden */
  21939. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21940. /** @hidden */
  21941. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21942. /**
  21943. * Clone the current block to a new identical block
  21944. * @param scene defines the hosting scene
  21945. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21946. * @returns a copy of the current block
  21947. */
  21948. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21949. /**
  21950. * Serializes this block in a JSON representation
  21951. * @returns the serialized block object
  21952. */
  21953. serialize(): any;
  21954. /** @hidden */
  21955. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21956. private _deserializePortDisplayNamesAndExposedOnFrame;
  21957. /**
  21958. * Release resources
  21959. */
  21960. dispose(): void;
  21961. }
  21962. }
  21963. declare module BABYLON {
  21964. /**
  21965. * Base class of materials working in push mode in babylon JS
  21966. * @hidden
  21967. */
  21968. export class PushMaterial extends Material {
  21969. protected _activeEffect: Effect;
  21970. protected _normalMatrix: Matrix;
  21971. constructor(name: string, scene: Scene);
  21972. getEffect(): Effect;
  21973. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21974. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21975. /**
  21976. * Binds the given world matrix to the active effect
  21977. *
  21978. * @param world the matrix to bind
  21979. */
  21980. bindOnlyWorldMatrix(world: Matrix): void;
  21981. /**
  21982. * Binds the given normal matrix to the active effect
  21983. *
  21984. * @param normalMatrix the matrix to bind
  21985. */
  21986. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21987. bind(world: Matrix, mesh?: Mesh): void;
  21988. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21989. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21990. }
  21991. }
  21992. declare module BABYLON {
  21993. /**
  21994. * Root class for all node material optimizers
  21995. */
  21996. export class NodeMaterialOptimizer {
  21997. /**
  21998. * Function used to optimize a NodeMaterial graph
  21999. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22000. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22001. */
  22002. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22003. }
  22004. }
  22005. declare module BABYLON {
  22006. /**
  22007. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22008. */
  22009. export class TransformBlock extends NodeMaterialBlock {
  22010. /**
  22011. * Defines the value to use to complement W value to transform it to a Vector4
  22012. */
  22013. complementW: number;
  22014. /**
  22015. * Defines the value to use to complement z value to transform it to a Vector4
  22016. */
  22017. complementZ: number;
  22018. /**
  22019. * Creates a new TransformBlock
  22020. * @param name defines the block name
  22021. */
  22022. constructor(name: string);
  22023. /**
  22024. * Gets the current class name
  22025. * @returns the class name
  22026. */
  22027. getClassName(): string;
  22028. /**
  22029. * Gets the vector input
  22030. */
  22031. get vector(): NodeMaterialConnectionPoint;
  22032. /**
  22033. * Gets the output component
  22034. */
  22035. get output(): NodeMaterialConnectionPoint;
  22036. /**
  22037. * Gets the xyz output component
  22038. */
  22039. get xyz(): NodeMaterialConnectionPoint;
  22040. /**
  22041. * Gets the matrix transform input
  22042. */
  22043. get transform(): NodeMaterialConnectionPoint;
  22044. protected _buildBlock(state: NodeMaterialBuildState): this;
  22045. /**
  22046. * Update defines for shader compilation
  22047. * @param mesh defines the mesh to be rendered
  22048. * @param nodeMaterial defines the node material requesting the update
  22049. * @param defines defines the material defines to update
  22050. * @param useInstances specifies that instances should be used
  22051. * @param subMesh defines which submesh to render
  22052. */
  22053. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22054. serialize(): any;
  22055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22056. protected _dumpPropertiesCode(): string;
  22057. }
  22058. }
  22059. declare module BABYLON {
  22060. /**
  22061. * Block used to output the vertex position
  22062. */
  22063. export class VertexOutputBlock extends NodeMaterialBlock {
  22064. /**
  22065. * Creates a new VertexOutputBlock
  22066. * @param name defines the block name
  22067. */
  22068. constructor(name: string);
  22069. /**
  22070. * Gets the current class name
  22071. * @returns the class name
  22072. */
  22073. getClassName(): string;
  22074. /**
  22075. * Gets the vector input component
  22076. */
  22077. get vector(): NodeMaterialConnectionPoint;
  22078. protected _buildBlock(state: NodeMaterialBuildState): this;
  22079. }
  22080. }
  22081. declare module BABYLON {
  22082. /**
  22083. * Block used to output the final color
  22084. */
  22085. export class FragmentOutputBlock extends NodeMaterialBlock {
  22086. /**
  22087. * Create a new FragmentOutputBlock
  22088. * @param name defines the block name
  22089. */
  22090. constructor(name: string);
  22091. /**
  22092. * Gets the current class name
  22093. * @returns the class name
  22094. */
  22095. getClassName(): string;
  22096. /**
  22097. * Gets the rgba input component
  22098. */
  22099. get rgba(): NodeMaterialConnectionPoint;
  22100. /**
  22101. * Gets the rgb input component
  22102. */
  22103. get rgb(): NodeMaterialConnectionPoint;
  22104. /**
  22105. * Gets the a input component
  22106. */
  22107. get a(): NodeMaterialConnectionPoint;
  22108. protected _buildBlock(state: NodeMaterialBuildState): this;
  22109. }
  22110. }
  22111. declare module BABYLON {
  22112. /**
  22113. * Block used for the particle ramp gradient section
  22114. */
  22115. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22116. /**
  22117. * Create a new ParticleRampGradientBlock
  22118. * @param name defines the block name
  22119. */
  22120. constructor(name: string);
  22121. /**
  22122. * Gets the current class name
  22123. * @returns the class name
  22124. */
  22125. getClassName(): string;
  22126. /**
  22127. * Gets the color input component
  22128. */
  22129. get color(): NodeMaterialConnectionPoint;
  22130. /**
  22131. * Gets the rampColor output component
  22132. */
  22133. get rampColor(): NodeMaterialConnectionPoint;
  22134. /**
  22135. * Initialize the block and prepare the context for build
  22136. * @param state defines the state that will be used for the build
  22137. */
  22138. initialize(state: NodeMaterialBuildState): void;
  22139. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22140. }
  22141. }
  22142. declare module BABYLON {
  22143. /**
  22144. * Block used for the particle blend multiply section
  22145. */
  22146. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22147. /**
  22148. * Create a new ParticleBlendMultiplyBlock
  22149. * @param name defines the block name
  22150. */
  22151. constructor(name: string);
  22152. /**
  22153. * Gets the current class name
  22154. * @returns the class name
  22155. */
  22156. getClassName(): string;
  22157. /**
  22158. * Gets the color input component
  22159. */
  22160. get color(): NodeMaterialConnectionPoint;
  22161. /**
  22162. * Gets the alphaTexture input component
  22163. */
  22164. get alphaTexture(): NodeMaterialConnectionPoint;
  22165. /**
  22166. * Gets the alphaColor input component
  22167. */
  22168. get alphaColor(): NodeMaterialConnectionPoint;
  22169. /**
  22170. * Gets the blendColor output component
  22171. */
  22172. get blendColor(): NodeMaterialConnectionPoint;
  22173. /**
  22174. * Initialize the block and prepare the context for build
  22175. * @param state defines the state that will be used for the build
  22176. */
  22177. initialize(state: NodeMaterialBuildState): void;
  22178. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22179. }
  22180. }
  22181. declare module BABYLON {
  22182. /**
  22183. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22184. */
  22185. export class VectorMergerBlock extends NodeMaterialBlock {
  22186. /**
  22187. * Create a new VectorMergerBlock
  22188. * @param name defines the block name
  22189. */
  22190. constructor(name: string);
  22191. /**
  22192. * Gets the current class name
  22193. * @returns the class name
  22194. */
  22195. getClassName(): string;
  22196. /**
  22197. * Gets the xyz component (input)
  22198. */
  22199. get xyzIn(): NodeMaterialConnectionPoint;
  22200. /**
  22201. * Gets the xy component (input)
  22202. */
  22203. get xyIn(): NodeMaterialConnectionPoint;
  22204. /**
  22205. * Gets the x component (input)
  22206. */
  22207. get x(): NodeMaterialConnectionPoint;
  22208. /**
  22209. * Gets the y component (input)
  22210. */
  22211. get y(): NodeMaterialConnectionPoint;
  22212. /**
  22213. * Gets the z component (input)
  22214. */
  22215. get z(): NodeMaterialConnectionPoint;
  22216. /**
  22217. * Gets the w component (input)
  22218. */
  22219. get w(): NodeMaterialConnectionPoint;
  22220. /**
  22221. * Gets the xyzw component (output)
  22222. */
  22223. get xyzw(): NodeMaterialConnectionPoint;
  22224. /**
  22225. * Gets the xyz component (output)
  22226. */
  22227. get xyzOut(): NodeMaterialConnectionPoint;
  22228. /**
  22229. * Gets the xy component (output)
  22230. */
  22231. get xyOut(): NodeMaterialConnectionPoint;
  22232. /**
  22233. * Gets the xy component (output)
  22234. * @deprecated Please use xyOut instead.
  22235. */
  22236. get xy(): NodeMaterialConnectionPoint;
  22237. /**
  22238. * Gets the xyz component (output)
  22239. * @deprecated Please use xyzOut instead.
  22240. */
  22241. get xyz(): NodeMaterialConnectionPoint;
  22242. protected _buildBlock(state: NodeMaterialBuildState): this;
  22243. }
  22244. }
  22245. declare module BABYLON {
  22246. /**
  22247. * Block used to remap a float from a range to a new one
  22248. */
  22249. export class RemapBlock extends NodeMaterialBlock {
  22250. /**
  22251. * Gets or sets the source range
  22252. */
  22253. sourceRange: Vector2;
  22254. /**
  22255. * Gets or sets the target range
  22256. */
  22257. targetRange: Vector2;
  22258. /**
  22259. * Creates a new RemapBlock
  22260. * @param name defines the block name
  22261. */
  22262. constructor(name: string);
  22263. /**
  22264. * Gets the current class name
  22265. * @returns the class name
  22266. */
  22267. getClassName(): string;
  22268. /**
  22269. * Gets the input component
  22270. */
  22271. get input(): NodeMaterialConnectionPoint;
  22272. /**
  22273. * Gets the source min input component
  22274. */
  22275. get sourceMin(): NodeMaterialConnectionPoint;
  22276. /**
  22277. * Gets the source max input component
  22278. */
  22279. get sourceMax(): NodeMaterialConnectionPoint;
  22280. /**
  22281. * Gets the target min input component
  22282. */
  22283. get targetMin(): NodeMaterialConnectionPoint;
  22284. /**
  22285. * Gets the target max input component
  22286. */
  22287. get targetMax(): NodeMaterialConnectionPoint;
  22288. /**
  22289. * Gets the output component
  22290. */
  22291. get output(): NodeMaterialConnectionPoint;
  22292. protected _buildBlock(state: NodeMaterialBuildState): this;
  22293. protected _dumpPropertiesCode(): string;
  22294. serialize(): any;
  22295. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22296. }
  22297. }
  22298. declare module BABYLON {
  22299. /**
  22300. * Block used to multiply 2 values
  22301. */
  22302. export class MultiplyBlock extends NodeMaterialBlock {
  22303. /**
  22304. * Creates a new MultiplyBlock
  22305. * @param name defines the block name
  22306. */
  22307. constructor(name: string);
  22308. /**
  22309. * Gets the current class name
  22310. * @returns the class name
  22311. */
  22312. getClassName(): string;
  22313. /**
  22314. * Gets the left operand input component
  22315. */
  22316. get left(): NodeMaterialConnectionPoint;
  22317. /**
  22318. * Gets the right operand input component
  22319. */
  22320. get right(): NodeMaterialConnectionPoint;
  22321. /**
  22322. * Gets the output component
  22323. */
  22324. get output(): NodeMaterialConnectionPoint;
  22325. protected _buildBlock(state: NodeMaterialBuildState): this;
  22326. }
  22327. }
  22328. declare module BABYLON {
  22329. /**
  22330. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22331. */
  22332. export class ColorSplitterBlock extends NodeMaterialBlock {
  22333. /**
  22334. * Create a new ColorSplitterBlock
  22335. * @param name defines the block name
  22336. */
  22337. constructor(name: string);
  22338. /**
  22339. * Gets the current class name
  22340. * @returns the class name
  22341. */
  22342. getClassName(): string;
  22343. /**
  22344. * Gets the rgba component (input)
  22345. */
  22346. get rgba(): NodeMaterialConnectionPoint;
  22347. /**
  22348. * Gets the rgb component (input)
  22349. */
  22350. get rgbIn(): NodeMaterialConnectionPoint;
  22351. /**
  22352. * Gets the rgb component (output)
  22353. */
  22354. get rgbOut(): NodeMaterialConnectionPoint;
  22355. /**
  22356. * Gets the r component (output)
  22357. */
  22358. get r(): NodeMaterialConnectionPoint;
  22359. /**
  22360. * Gets the g component (output)
  22361. */
  22362. get g(): NodeMaterialConnectionPoint;
  22363. /**
  22364. * Gets the b component (output)
  22365. */
  22366. get b(): NodeMaterialConnectionPoint;
  22367. /**
  22368. * Gets the a component (output)
  22369. */
  22370. get a(): NodeMaterialConnectionPoint;
  22371. protected _inputRename(name: string): string;
  22372. protected _outputRename(name: string): string;
  22373. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22374. }
  22375. }
  22376. declare module BABYLON {
  22377. /**
  22378. * Operations supported by the Trigonometry block
  22379. */
  22380. export enum TrigonometryBlockOperations {
  22381. /** Cos */
  22382. Cos = 0,
  22383. /** Sin */
  22384. Sin = 1,
  22385. /** Abs */
  22386. Abs = 2,
  22387. /** Exp */
  22388. Exp = 3,
  22389. /** Exp2 */
  22390. Exp2 = 4,
  22391. /** Round */
  22392. Round = 5,
  22393. /** Floor */
  22394. Floor = 6,
  22395. /** Ceiling */
  22396. Ceiling = 7,
  22397. /** Square root */
  22398. Sqrt = 8,
  22399. /** Log */
  22400. Log = 9,
  22401. /** Tangent */
  22402. Tan = 10,
  22403. /** Arc tangent */
  22404. ArcTan = 11,
  22405. /** Arc cosinus */
  22406. ArcCos = 12,
  22407. /** Arc sinus */
  22408. ArcSin = 13,
  22409. /** Fraction */
  22410. Fract = 14,
  22411. /** Sign */
  22412. Sign = 15,
  22413. /** To radians (from degrees) */
  22414. Radians = 16,
  22415. /** To degrees (from radians) */
  22416. Degrees = 17
  22417. }
  22418. /**
  22419. * Block used to apply trigonometry operation to floats
  22420. */
  22421. export class TrigonometryBlock extends NodeMaterialBlock {
  22422. /**
  22423. * Gets or sets the operation applied by the block
  22424. */
  22425. operation: TrigonometryBlockOperations;
  22426. /**
  22427. * Creates a new TrigonometryBlock
  22428. * @param name defines the block name
  22429. */
  22430. constructor(name: string);
  22431. /**
  22432. * Gets the current class name
  22433. * @returns the class name
  22434. */
  22435. getClassName(): string;
  22436. /**
  22437. * Gets the input component
  22438. */
  22439. get input(): NodeMaterialConnectionPoint;
  22440. /**
  22441. * Gets the output component
  22442. */
  22443. get output(): NodeMaterialConnectionPoint;
  22444. protected _buildBlock(state: NodeMaterialBuildState): this;
  22445. serialize(): any;
  22446. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22447. protected _dumpPropertiesCode(): string;
  22448. }
  22449. }
  22450. declare module BABYLON {
  22451. /**
  22452. * Interface used to configure the node material editor
  22453. */
  22454. export interface INodeMaterialEditorOptions {
  22455. /** Define the URl to load node editor script */
  22456. editorURL?: string;
  22457. }
  22458. /** @hidden */
  22459. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22460. NORMAL: boolean;
  22461. TANGENT: boolean;
  22462. UV1: boolean;
  22463. /** BONES */
  22464. NUM_BONE_INFLUENCERS: number;
  22465. BonesPerMesh: number;
  22466. BONETEXTURE: boolean;
  22467. /** MORPH TARGETS */
  22468. MORPHTARGETS: boolean;
  22469. MORPHTARGETS_NORMAL: boolean;
  22470. MORPHTARGETS_TANGENT: boolean;
  22471. MORPHTARGETS_UV: boolean;
  22472. NUM_MORPH_INFLUENCERS: number;
  22473. /** IMAGE PROCESSING */
  22474. IMAGEPROCESSING: boolean;
  22475. VIGNETTE: boolean;
  22476. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22477. VIGNETTEBLENDMODEOPAQUE: boolean;
  22478. TONEMAPPING: boolean;
  22479. TONEMAPPING_ACES: boolean;
  22480. CONTRAST: boolean;
  22481. EXPOSURE: boolean;
  22482. COLORCURVES: boolean;
  22483. COLORGRADING: boolean;
  22484. COLORGRADING3D: boolean;
  22485. SAMPLER3DGREENDEPTH: boolean;
  22486. SAMPLER3DBGRMAP: boolean;
  22487. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22488. /** MISC. */
  22489. BUMPDIRECTUV: number;
  22490. constructor();
  22491. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22492. }
  22493. /**
  22494. * Class used to configure NodeMaterial
  22495. */
  22496. export interface INodeMaterialOptions {
  22497. /**
  22498. * Defines if blocks should emit comments
  22499. */
  22500. emitComments: boolean;
  22501. }
  22502. /**
  22503. * Class used to create a node based material built by assembling shader blocks
  22504. */
  22505. export class NodeMaterial extends PushMaterial {
  22506. private static _BuildIdGenerator;
  22507. private _options;
  22508. private _vertexCompilationState;
  22509. private _fragmentCompilationState;
  22510. private _sharedData;
  22511. private _buildId;
  22512. private _buildWasSuccessful;
  22513. private _cachedWorldViewMatrix;
  22514. private _cachedWorldViewProjectionMatrix;
  22515. private _optimizers;
  22516. private _animationFrame;
  22517. /** Define the Url to load node editor script */
  22518. static EditorURL: string;
  22519. /** Define the Url to load snippets */
  22520. static SnippetUrl: string;
  22521. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22522. static IgnoreTexturesAtLoadTime: boolean;
  22523. private BJSNODEMATERIALEDITOR;
  22524. /** Get the inspector from bundle or global */
  22525. private _getGlobalNodeMaterialEditor;
  22526. /**
  22527. * Snippet ID if the material was created from the snippet server
  22528. */
  22529. snippetId: string;
  22530. /**
  22531. * Gets or sets data used by visual editor
  22532. * @see https://nme.babylonjs.com
  22533. */
  22534. editorData: any;
  22535. /**
  22536. * 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)
  22537. */
  22538. ignoreAlpha: boolean;
  22539. /**
  22540. * Defines the maximum number of lights that can be used in the material
  22541. */
  22542. maxSimultaneousLights: number;
  22543. /**
  22544. * Observable raised when the material is built
  22545. */
  22546. onBuildObservable: Observable<NodeMaterial>;
  22547. /**
  22548. * Gets or sets the root nodes of the material vertex shader
  22549. */
  22550. _vertexOutputNodes: NodeMaterialBlock[];
  22551. /**
  22552. * Gets or sets the root nodes of the material fragment (pixel) shader
  22553. */
  22554. _fragmentOutputNodes: NodeMaterialBlock[];
  22555. /** Gets or sets options to control the node material overall behavior */
  22556. get options(): INodeMaterialOptions;
  22557. set options(options: INodeMaterialOptions);
  22558. /**
  22559. * Default configuration related to image processing available in the standard Material.
  22560. */
  22561. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22562. /**
  22563. * Gets the image processing configuration used either in this material.
  22564. */
  22565. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22566. /**
  22567. * Sets the Default image processing configuration used either in the this material.
  22568. *
  22569. * If sets to null, the scene one is in use.
  22570. */
  22571. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22572. /**
  22573. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22574. */
  22575. attachedBlocks: NodeMaterialBlock[];
  22576. /**
  22577. * Specifies the mode of the node material
  22578. * @hidden
  22579. */
  22580. _mode: NodeMaterialModes;
  22581. /**
  22582. * Gets the mode property
  22583. */
  22584. get mode(): NodeMaterialModes;
  22585. /**
  22586. * Create a new node based material
  22587. * @param name defines the material name
  22588. * @param scene defines the hosting scene
  22589. * @param options defines creation option
  22590. */
  22591. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22592. /**
  22593. * Gets the current class name of the material e.g. "NodeMaterial"
  22594. * @returns the class name
  22595. */
  22596. getClassName(): string;
  22597. /**
  22598. * Keep track of the image processing observer to allow dispose and replace.
  22599. */
  22600. private _imageProcessingObserver;
  22601. /**
  22602. * Attaches a new image processing configuration to the Standard Material.
  22603. * @param configuration
  22604. */
  22605. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22606. /**
  22607. * Get a block by its name
  22608. * @param name defines the name of the block to retrieve
  22609. * @returns the required block or null if not found
  22610. */
  22611. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22612. /**
  22613. * Get a block by its name
  22614. * @param predicate defines the predicate used to find the good candidate
  22615. * @returns the required block or null if not found
  22616. */
  22617. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22618. /**
  22619. * Get an input block by its name
  22620. * @param predicate defines the predicate used to find the good candidate
  22621. * @returns the required input block or null if not found
  22622. */
  22623. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22624. /**
  22625. * Gets the list of input blocks attached to this material
  22626. * @returns an array of InputBlocks
  22627. */
  22628. getInputBlocks(): InputBlock[];
  22629. /**
  22630. * Adds a new optimizer to the list of optimizers
  22631. * @param optimizer defines the optimizers to add
  22632. * @returns the current material
  22633. */
  22634. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22635. /**
  22636. * Remove an optimizer from the list of optimizers
  22637. * @param optimizer defines the optimizers to remove
  22638. * @returns the current material
  22639. */
  22640. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22641. /**
  22642. * Add a new block to the list of output nodes
  22643. * @param node defines the node to add
  22644. * @returns the current material
  22645. */
  22646. addOutputNode(node: NodeMaterialBlock): this;
  22647. /**
  22648. * Remove a block from the list of root nodes
  22649. * @param node defines the node to remove
  22650. * @returns the current material
  22651. */
  22652. removeOutputNode(node: NodeMaterialBlock): this;
  22653. private _addVertexOutputNode;
  22654. private _removeVertexOutputNode;
  22655. private _addFragmentOutputNode;
  22656. private _removeFragmentOutputNode;
  22657. /**
  22658. * Specifies if the material will require alpha blending
  22659. * @returns a boolean specifying if alpha blending is needed
  22660. */
  22661. needAlphaBlending(): boolean;
  22662. /**
  22663. * Specifies if this material should be rendered in alpha test mode
  22664. * @returns a boolean specifying if an alpha test is needed.
  22665. */
  22666. needAlphaTesting(): boolean;
  22667. private _initializeBlock;
  22668. private _resetDualBlocks;
  22669. /**
  22670. * Remove a block from the current node material
  22671. * @param block defines the block to remove
  22672. */
  22673. removeBlock(block: NodeMaterialBlock): void;
  22674. /**
  22675. * Build the material and generates the inner effect
  22676. * @param verbose defines if the build should log activity
  22677. */
  22678. build(verbose?: boolean): void;
  22679. /**
  22680. * Runs an otpimization phase to try to improve the shader code
  22681. */
  22682. optimize(): void;
  22683. private _prepareDefinesForAttributes;
  22684. /**
  22685. * Create a post process from the material
  22686. * @param camera The camera to apply the render pass to.
  22687. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22689. * @param engine The engine which the post process will be applied. (default: current engine)
  22690. * @param reusable If the post process can be reused on the same frame. (default: false)
  22691. * @param textureType Type of textures used when performing the post process. (default: 0)
  22692. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22693. * @returns the post process created
  22694. */
  22695. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22696. /**
  22697. * Create the post process effect from the material
  22698. * @param postProcess The post process to create the effect for
  22699. */
  22700. createEffectForPostProcess(postProcess: PostProcess): void;
  22701. private _createEffectForPostProcess;
  22702. /**
  22703. * Create a new procedural texture based on this node material
  22704. * @param size defines the size of the texture
  22705. * @param scene defines the hosting scene
  22706. * @returns the new procedural texture attached to this node material
  22707. */
  22708. createProceduralTexture(size: number | {
  22709. width: number;
  22710. height: number;
  22711. layers?: number;
  22712. }, scene: Scene): Nullable<ProceduralTexture>;
  22713. private _createEffectForParticles;
  22714. private _checkInternals;
  22715. /**
  22716. * Create the effect to be used as the custom effect for a particle system
  22717. * @param particleSystem Particle system to create the effect for
  22718. * @param onCompiled defines a function to call when the effect creation is successful
  22719. * @param onError defines a function to call when the effect creation has failed
  22720. */
  22721. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22722. private _processDefines;
  22723. /**
  22724. * Get if the submesh is ready to be used and all its information available.
  22725. * Child classes can use it to update shaders
  22726. * @param mesh defines the mesh to check
  22727. * @param subMesh defines which submesh to check
  22728. * @param useInstances specifies that instances should be used
  22729. * @returns a boolean indicating that the submesh is ready or not
  22730. */
  22731. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22732. /**
  22733. * Get a string representing the shaders built by the current node graph
  22734. */
  22735. get compiledShaders(): string;
  22736. /**
  22737. * Binds the world matrix to the material
  22738. * @param world defines the world transformation matrix
  22739. */
  22740. bindOnlyWorldMatrix(world: Matrix): void;
  22741. /**
  22742. * Binds the submesh to this material by preparing the effect and shader to draw
  22743. * @param world defines the world transformation matrix
  22744. * @param mesh defines the mesh containing the submesh
  22745. * @param subMesh defines the submesh to bind the material to
  22746. */
  22747. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22748. /**
  22749. * Gets the active textures from the material
  22750. * @returns an array of textures
  22751. */
  22752. getActiveTextures(): BaseTexture[];
  22753. /**
  22754. * Gets the list of texture blocks
  22755. * @returns an array of texture blocks
  22756. */
  22757. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22758. /**
  22759. * Specifies if the material uses a texture
  22760. * @param texture defines the texture to check against the material
  22761. * @returns a boolean specifying if the material uses the texture
  22762. */
  22763. hasTexture(texture: BaseTexture): boolean;
  22764. /**
  22765. * Disposes the material
  22766. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22767. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22768. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22769. */
  22770. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22771. /** Creates the node editor window. */
  22772. private _createNodeEditor;
  22773. /**
  22774. * Launch the node material editor
  22775. * @param config Define the configuration of the editor
  22776. * @return a promise fulfilled when the node editor is visible
  22777. */
  22778. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22779. /**
  22780. * Clear the current material
  22781. */
  22782. clear(): void;
  22783. /**
  22784. * Clear the current material and set it to a default state
  22785. */
  22786. setToDefault(): void;
  22787. /**
  22788. * Clear the current material and set it to a default state for post process
  22789. */
  22790. setToDefaultPostProcess(): void;
  22791. /**
  22792. * Clear the current material and set it to a default state for procedural texture
  22793. */
  22794. setToDefaultProceduralTexture(): void;
  22795. /**
  22796. * Clear the current material and set it to a default state for particle
  22797. */
  22798. setToDefaultParticle(): void;
  22799. /**
  22800. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22801. * @param url defines the url to load from
  22802. * @returns a promise that will fullfil when the material is fully loaded
  22803. */
  22804. loadAsync(url: string): Promise<void>;
  22805. private _gatherBlocks;
  22806. /**
  22807. * Generate a string containing the code declaration required to create an equivalent of this material
  22808. * @returns a string
  22809. */
  22810. generateCode(): string;
  22811. /**
  22812. * Serializes this material in a JSON representation
  22813. * @returns the serialized material object
  22814. */
  22815. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22816. private _restoreConnections;
  22817. /**
  22818. * Clear the current graph and load a new one from a serialization object
  22819. * @param source defines the JSON representation of the material
  22820. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22821. * @param merge defines whether or not the source must be merged or replace the current content
  22822. */
  22823. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22824. /**
  22825. * Makes a duplicate of the current material.
  22826. * @param name - name to use for the new material.
  22827. */
  22828. clone(name: string): NodeMaterial;
  22829. /**
  22830. * Creates a node material from parsed material data
  22831. * @param source defines the JSON representation of the material
  22832. * @param scene defines the hosting scene
  22833. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22834. * @returns a new node material
  22835. */
  22836. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22837. /**
  22838. * Creates a node material from a snippet saved in a remote file
  22839. * @param name defines the name of the material to create
  22840. * @param url defines the url to load from
  22841. * @param scene defines the hosting scene
  22842. * @returns a promise that will resolve to the new node material
  22843. */
  22844. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22845. /**
  22846. * Creates a node material from a snippet saved by the node material editor
  22847. * @param snippetId defines the snippet to load
  22848. * @param scene defines the hosting scene
  22849. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22850. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22851. * @returns a promise that will resolve to the new node material
  22852. */
  22853. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22854. /**
  22855. * Creates a new node material set to default basic configuration
  22856. * @param name defines the name of the material
  22857. * @param scene defines the hosting scene
  22858. * @returns a new NodeMaterial
  22859. */
  22860. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22861. }
  22862. }
  22863. declare module BABYLON {
  22864. interface ThinEngine {
  22865. /**
  22866. * Unbind a list of render target textures from the webGL context
  22867. * This is used only when drawBuffer extension or webGL2 are active
  22868. * @param textures defines the render target textures to unbind
  22869. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  22870. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  22871. */
  22872. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  22873. /**
  22874. * Create a multi render target texture
  22875. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  22876. * @param size defines the size of the texture
  22877. * @param options defines the creation options
  22878. * @returns the cube texture as an InternalTexture
  22879. */
  22880. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  22881. /**
  22882. * Update the sample count for a given multiple render target texture
  22883. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  22884. * @param textures defines the textures to update
  22885. * @param samples defines the sample count to set
  22886. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  22887. */
  22888. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  22889. /**
  22890. * Select a subsets of attachments to draw to.
  22891. * @param attachments gl attachments
  22892. */
  22893. bindAttachments(attachments: number[]): void;
  22894. /**
  22895. * Creates a layout object to draw/clear on specific textures in a MRT
  22896. * @param textureStatus textureStatus[i] indicates if the i-th is active
  22897. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  22898. */
  22899. buildTextureLayout(textureStatus: boolean[]): number[];
  22900. /**
  22901. * Restores the webgl state to only draw on the main color attachment
  22902. */
  22903. restoreSingleAttachment(): void;
  22904. }
  22905. }
  22906. declare module BABYLON {
  22907. /**
  22908. * Creation options of the multi render target texture.
  22909. */
  22910. export interface IMultiRenderTargetOptions {
  22911. /**
  22912. * Define if the texture needs to create mip maps after render.
  22913. */
  22914. generateMipMaps?: boolean;
  22915. /**
  22916. * Define the types of all the draw buffers we want to create
  22917. */
  22918. types?: number[];
  22919. /**
  22920. * Define the sampling modes of all the draw buffers we want to create
  22921. */
  22922. samplingModes?: number[];
  22923. /**
  22924. * Define if a depth buffer is required
  22925. */
  22926. generateDepthBuffer?: boolean;
  22927. /**
  22928. * Define if a stencil buffer is required
  22929. */
  22930. generateStencilBuffer?: boolean;
  22931. /**
  22932. * Define if a depth texture is required instead of a depth buffer
  22933. */
  22934. generateDepthTexture?: boolean;
  22935. /**
  22936. * Define the number of desired draw buffers
  22937. */
  22938. textureCount?: number;
  22939. /**
  22940. * Define if aspect ratio should be adapted to the texture or stay the scene one
  22941. */
  22942. doNotChangeAspectRatio?: boolean;
  22943. /**
  22944. * Define the default type of the buffers we are creating
  22945. */
  22946. defaultType?: number;
  22947. }
  22948. /**
  22949. * A multi render target, like a render target provides the ability to render to a texture.
  22950. * Unlike the render target, it can render to several draw buffers in one draw.
  22951. * This is specially interesting in deferred rendering or for any effects requiring more than
  22952. * just one color from a single pass.
  22953. */
  22954. export class MultiRenderTarget extends RenderTargetTexture {
  22955. private _internalTextures;
  22956. private _textures;
  22957. private _multiRenderTargetOptions;
  22958. private _count;
  22959. /**
  22960. * Get if draw buffers are currently supported by the used hardware and browser.
  22961. */
  22962. get isSupported(): boolean;
  22963. /**
  22964. * Get the list of textures generated by the multi render target.
  22965. */
  22966. get textures(): Texture[];
  22967. /**
  22968. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  22969. */
  22970. get count(): number;
  22971. /**
  22972. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  22973. */
  22974. get depthTexture(): Texture;
  22975. /**
  22976. * Set the wrapping mode on U of all the textures we are rendering to.
  22977. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22978. */
  22979. set wrapU(wrap: number);
  22980. /**
  22981. * Set the wrapping mode on V of all the textures we are rendering to.
  22982. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22983. */
  22984. set wrapV(wrap: number);
  22985. /**
  22986. * Instantiate a new multi render target texture.
  22987. * A multi render target, like a render target provides the ability to render to a texture.
  22988. * Unlike the render target, it can render to several draw buffers in one draw.
  22989. * This is specially interesting in deferred rendering or for any effects requiring more than
  22990. * just one color from a single pass.
  22991. * @param name Define the name of the texture
  22992. * @param size Define the size of the buffers to render to
  22993. * @param count Define the number of target we are rendering into
  22994. * @param scene Define the scene the texture belongs to
  22995. * @param options Define the options used to create the multi render target
  22996. */
  22997. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  22998. private _initTypes;
  22999. /** @hidden */
  23000. _rebuild(forceFullRebuild?: boolean): void;
  23001. private _createInternalTextures;
  23002. private _createTextures;
  23003. /**
  23004. * Replaces a texture within the MRT.
  23005. * @param texture The new texture to insert in the MRT
  23006. * @param index The index of the texture to replace
  23007. */
  23008. replaceTexture(texture: Texture, index: number): void;
  23009. /**
  23010. * Define the number of samples used if MSAA is enabled.
  23011. */
  23012. get samples(): number;
  23013. set samples(value: number);
  23014. /**
  23015. * Resize all the textures in the multi render target.
  23016. * Be careful as it will recreate all the data in the new texture.
  23017. * @param size Define the new size
  23018. */
  23019. resize(size: any): void;
  23020. /**
  23021. * Changes the number of render targets in this MRT
  23022. * Be careful as it will recreate all the data in the new texture.
  23023. * @param count new texture count
  23024. * @param options Specifies texture types and sampling modes for new textures
  23025. */
  23026. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23027. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23028. /**
  23029. * Dispose the render targets and their associated resources
  23030. */
  23031. dispose(): void;
  23032. /**
  23033. * Release all the underlying texture used as draw buffers.
  23034. */
  23035. releaseInternalTextures(): void;
  23036. }
  23037. }
  23038. declare module BABYLON {
  23039. /** @hidden */
  23040. export var imageProcessingPixelShader: {
  23041. name: string;
  23042. shader: string;
  23043. };
  23044. }
  23045. declare module BABYLON {
  23046. /**
  23047. * ImageProcessingPostProcess
  23048. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23049. */
  23050. export class ImageProcessingPostProcess extends PostProcess {
  23051. /**
  23052. * Default configuration related to image processing available in the PBR Material.
  23053. */
  23054. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23055. /**
  23056. * Gets the image processing configuration used either in this material.
  23057. */
  23058. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23059. /**
  23060. * Sets the Default image processing configuration used either in the this material.
  23061. *
  23062. * If sets to null, the scene one is in use.
  23063. */
  23064. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23065. /**
  23066. * Keep track of the image processing observer to allow dispose and replace.
  23067. */
  23068. private _imageProcessingObserver;
  23069. /**
  23070. * Attaches a new image processing configuration to the PBR Material.
  23071. * @param configuration
  23072. */
  23073. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23074. /**
  23075. * If the post process is supported.
  23076. */
  23077. get isSupported(): boolean;
  23078. /**
  23079. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23080. */
  23081. get colorCurves(): Nullable<ColorCurves>;
  23082. /**
  23083. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23084. */
  23085. set colorCurves(value: Nullable<ColorCurves>);
  23086. /**
  23087. * Gets wether the color curves effect is enabled.
  23088. */
  23089. get colorCurvesEnabled(): boolean;
  23090. /**
  23091. * Sets wether the color curves effect is enabled.
  23092. */
  23093. set colorCurvesEnabled(value: boolean);
  23094. /**
  23095. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23096. */
  23097. get colorGradingTexture(): Nullable<BaseTexture>;
  23098. /**
  23099. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23100. */
  23101. set colorGradingTexture(value: Nullable<BaseTexture>);
  23102. /**
  23103. * Gets wether the color grading effect is enabled.
  23104. */
  23105. get colorGradingEnabled(): boolean;
  23106. /**
  23107. * Gets wether the color grading effect is enabled.
  23108. */
  23109. set colorGradingEnabled(value: boolean);
  23110. /**
  23111. * Gets exposure used in the effect.
  23112. */
  23113. get exposure(): number;
  23114. /**
  23115. * Sets exposure used in the effect.
  23116. */
  23117. set exposure(value: number);
  23118. /**
  23119. * Gets wether tonemapping is enabled or not.
  23120. */
  23121. get toneMappingEnabled(): boolean;
  23122. /**
  23123. * Sets wether tonemapping is enabled or not
  23124. */
  23125. set toneMappingEnabled(value: boolean);
  23126. /**
  23127. * Gets the type of tone mapping effect.
  23128. */
  23129. get toneMappingType(): number;
  23130. /**
  23131. * Sets the type of tone mapping effect.
  23132. */
  23133. set toneMappingType(value: number);
  23134. /**
  23135. * Gets contrast used in the effect.
  23136. */
  23137. get contrast(): number;
  23138. /**
  23139. * Sets contrast used in the effect.
  23140. */
  23141. set contrast(value: number);
  23142. /**
  23143. * Gets Vignette stretch size.
  23144. */
  23145. get vignetteStretch(): number;
  23146. /**
  23147. * Sets Vignette stretch size.
  23148. */
  23149. set vignetteStretch(value: number);
  23150. /**
  23151. * Gets Vignette centre X Offset.
  23152. */
  23153. get vignetteCentreX(): number;
  23154. /**
  23155. * Sets Vignette centre X Offset.
  23156. */
  23157. set vignetteCentreX(value: number);
  23158. /**
  23159. * Gets Vignette centre Y Offset.
  23160. */
  23161. get vignetteCentreY(): number;
  23162. /**
  23163. * Sets Vignette centre Y Offset.
  23164. */
  23165. set vignetteCentreY(value: number);
  23166. /**
  23167. * Gets Vignette weight or intensity of the vignette effect.
  23168. */
  23169. get vignetteWeight(): number;
  23170. /**
  23171. * Sets Vignette weight or intensity of the vignette effect.
  23172. */
  23173. set vignetteWeight(value: number);
  23174. /**
  23175. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23176. * if vignetteEnabled is set to true.
  23177. */
  23178. get vignetteColor(): Color4;
  23179. /**
  23180. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23181. * if vignetteEnabled is set to true.
  23182. */
  23183. set vignetteColor(value: Color4);
  23184. /**
  23185. * Gets Camera field of view used by the Vignette effect.
  23186. */
  23187. get vignetteCameraFov(): number;
  23188. /**
  23189. * Sets Camera field of view used by the Vignette effect.
  23190. */
  23191. set vignetteCameraFov(value: number);
  23192. /**
  23193. * Gets the vignette blend mode allowing different kind of effect.
  23194. */
  23195. get vignetteBlendMode(): number;
  23196. /**
  23197. * Sets the vignette blend mode allowing different kind of effect.
  23198. */
  23199. set vignetteBlendMode(value: number);
  23200. /**
  23201. * Gets wether the vignette effect is enabled.
  23202. */
  23203. get vignetteEnabled(): boolean;
  23204. /**
  23205. * Sets wether the vignette effect is enabled.
  23206. */
  23207. set vignetteEnabled(value: boolean);
  23208. private _fromLinearSpace;
  23209. /**
  23210. * Gets wether the input of the processing is in Gamma or Linear Space.
  23211. */
  23212. get fromLinearSpace(): boolean;
  23213. /**
  23214. * Sets wether the input of the processing is in Gamma or Linear Space.
  23215. */
  23216. set fromLinearSpace(value: boolean);
  23217. /**
  23218. * Defines cache preventing GC.
  23219. */
  23220. private _defines;
  23221. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23222. /**
  23223. * "ImageProcessingPostProcess"
  23224. * @returns "ImageProcessingPostProcess"
  23225. */
  23226. getClassName(): string;
  23227. /**
  23228. * @hidden
  23229. */
  23230. _updateParameters(): void;
  23231. dispose(camera?: Camera): void;
  23232. }
  23233. }
  23234. declare module BABYLON {
  23235. /**
  23236. * Interface for defining prepass effects in the prepass post-process pipeline
  23237. */
  23238. export interface PrePassEffectConfiguration {
  23239. /**
  23240. * Name of the effect
  23241. */
  23242. name: string;
  23243. /**
  23244. * Post process to attach for this effect
  23245. */
  23246. postProcess?: PostProcess;
  23247. /**
  23248. * Textures required in the MRT
  23249. */
  23250. texturesRequired: number[];
  23251. /**
  23252. * Is the effect enabled
  23253. */
  23254. enabled: boolean;
  23255. /**
  23256. * Disposes the effect configuration
  23257. */
  23258. dispose?: () => void;
  23259. /**
  23260. * Creates the associated post process
  23261. */
  23262. createPostProcess?: () => PostProcess;
  23263. }
  23264. }
  23265. declare module BABYLON {
  23266. /**
  23267. * Options to be used when creating a FresnelParameters.
  23268. */
  23269. export type IFresnelParametersCreationOptions = {
  23270. /**
  23271. * Define the color used on edges (grazing angle)
  23272. */
  23273. leftColor?: Color3;
  23274. /**
  23275. * Define the color used on center
  23276. */
  23277. rightColor?: Color3;
  23278. /**
  23279. * Define bias applied to computed fresnel term
  23280. */
  23281. bias?: number;
  23282. /**
  23283. * Defined the power exponent applied to fresnel term
  23284. */
  23285. power?: number;
  23286. /**
  23287. * Define if the fresnel effect is enable or not.
  23288. */
  23289. isEnabled?: boolean;
  23290. };
  23291. /**
  23292. * Serialized format for FresnelParameters.
  23293. */
  23294. export type IFresnelParametersSerialized = {
  23295. /**
  23296. * Define the color used on edges (grazing angle) [as an array]
  23297. */
  23298. leftColor: number[];
  23299. /**
  23300. * Define the color used on center [as an array]
  23301. */
  23302. rightColor: number[];
  23303. /**
  23304. * Define bias applied to computed fresnel term
  23305. */
  23306. bias: number;
  23307. /**
  23308. * Defined the power exponent applied to fresnel term
  23309. */
  23310. power?: number;
  23311. /**
  23312. * Define if the fresnel effect is enable or not.
  23313. */
  23314. isEnabled: boolean;
  23315. };
  23316. /**
  23317. * This represents all the required information to add a fresnel effect on a material:
  23318. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23319. */
  23320. export class FresnelParameters {
  23321. private _isEnabled;
  23322. /**
  23323. * Define if the fresnel effect is enable or not.
  23324. */
  23325. get isEnabled(): boolean;
  23326. set isEnabled(value: boolean);
  23327. /**
  23328. * Define the color used on edges (grazing angle)
  23329. */
  23330. leftColor: Color3;
  23331. /**
  23332. * Define the color used on center
  23333. */
  23334. rightColor: Color3;
  23335. /**
  23336. * Define bias applied to computed fresnel term
  23337. */
  23338. bias: number;
  23339. /**
  23340. * Defined the power exponent applied to fresnel term
  23341. */
  23342. power: number;
  23343. /**
  23344. * Creates a new FresnelParameters object.
  23345. *
  23346. * @param options provide your own settings to optionally to override defaults
  23347. */
  23348. constructor(options?: IFresnelParametersCreationOptions);
  23349. /**
  23350. * Clones the current fresnel and its valuues
  23351. * @returns a clone fresnel configuration
  23352. */
  23353. clone(): FresnelParameters;
  23354. /**
  23355. * Determines equality between FresnelParameters objects
  23356. * @param otherFresnelParameters defines the second operand
  23357. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23358. */
  23359. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23360. /**
  23361. * Serializes the current fresnel parameters to a JSON representation.
  23362. * @return the JSON serialization
  23363. */
  23364. serialize(): IFresnelParametersSerialized;
  23365. /**
  23366. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23367. * @param parsedFresnelParameters Define the JSON representation
  23368. * @returns the parsed parameters
  23369. */
  23370. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23371. }
  23372. }
  23373. declare module BABYLON {
  23374. /**
  23375. * This groups all the flags used to control the materials channel.
  23376. */
  23377. export class MaterialFlags {
  23378. private static _DiffuseTextureEnabled;
  23379. /**
  23380. * Are diffuse textures enabled in the application.
  23381. */
  23382. static get DiffuseTextureEnabled(): boolean;
  23383. static set DiffuseTextureEnabled(value: boolean);
  23384. private static _DetailTextureEnabled;
  23385. /**
  23386. * Are detail textures enabled in the application.
  23387. */
  23388. static get DetailTextureEnabled(): boolean;
  23389. static set DetailTextureEnabled(value: boolean);
  23390. private static _AmbientTextureEnabled;
  23391. /**
  23392. * Are ambient textures enabled in the application.
  23393. */
  23394. static get AmbientTextureEnabled(): boolean;
  23395. static set AmbientTextureEnabled(value: boolean);
  23396. private static _OpacityTextureEnabled;
  23397. /**
  23398. * Are opacity textures enabled in the application.
  23399. */
  23400. static get OpacityTextureEnabled(): boolean;
  23401. static set OpacityTextureEnabled(value: boolean);
  23402. private static _ReflectionTextureEnabled;
  23403. /**
  23404. * Are reflection textures enabled in the application.
  23405. */
  23406. static get ReflectionTextureEnabled(): boolean;
  23407. static set ReflectionTextureEnabled(value: boolean);
  23408. private static _EmissiveTextureEnabled;
  23409. /**
  23410. * Are emissive textures enabled in the application.
  23411. */
  23412. static get EmissiveTextureEnabled(): boolean;
  23413. static set EmissiveTextureEnabled(value: boolean);
  23414. private static _SpecularTextureEnabled;
  23415. /**
  23416. * Are specular textures enabled in the application.
  23417. */
  23418. static get SpecularTextureEnabled(): boolean;
  23419. static set SpecularTextureEnabled(value: boolean);
  23420. private static _BumpTextureEnabled;
  23421. /**
  23422. * Are bump textures enabled in the application.
  23423. */
  23424. static get BumpTextureEnabled(): boolean;
  23425. static set BumpTextureEnabled(value: boolean);
  23426. private static _LightmapTextureEnabled;
  23427. /**
  23428. * Are lightmap textures enabled in the application.
  23429. */
  23430. static get LightmapTextureEnabled(): boolean;
  23431. static set LightmapTextureEnabled(value: boolean);
  23432. private static _RefractionTextureEnabled;
  23433. /**
  23434. * Are refraction textures enabled in the application.
  23435. */
  23436. static get RefractionTextureEnabled(): boolean;
  23437. static set RefractionTextureEnabled(value: boolean);
  23438. private static _ColorGradingTextureEnabled;
  23439. /**
  23440. * Are color grading textures enabled in the application.
  23441. */
  23442. static get ColorGradingTextureEnabled(): boolean;
  23443. static set ColorGradingTextureEnabled(value: boolean);
  23444. private static _FresnelEnabled;
  23445. /**
  23446. * Are fresnels enabled in the application.
  23447. */
  23448. static get FresnelEnabled(): boolean;
  23449. static set FresnelEnabled(value: boolean);
  23450. private static _ClearCoatTextureEnabled;
  23451. /**
  23452. * Are clear coat textures enabled in the application.
  23453. */
  23454. static get ClearCoatTextureEnabled(): boolean;
  23455. static set ClearCoatTextureEnabled(value: boolean);
  23456. private static _ClearCoatBumpTextureEnabled;
  23457. /**
  23458. * Are clear coat bump textures enabled in the application.
  23459. */
  23460. static get ClearCoatBumpTextureEnabled(): boolean;
  23461. static set ClearCoatBumpTextureEnabled(value: boolean);
  23462. private static _ClearCoatTintTextureEnabled;
  23463. /**
  23464. * Are clear coat tint textures enabled in the application.
  23465. */
  23466. static get ClearCoatTintTextureEnabled(): boolean;
  23467. static set ClearCoatTintTextureEnabled(value: boolean);
  23468. private static _SheenTextureEnabled;
  23469. /**
  23470. * Are sheen textures enabled in the application.
  23471. */
  23472. static get SheenTextureEnabled(): boolean;
  23473. static set SheenTextureEnabled(value: boolean);
  23474. private static _AnisotropicTextureEnabled;
  23475. /**
  23476. * Are anisotropic textures enabled in the application.
  23477. */
  23478. static get AnisotropicTextureEnabled(): boolean;
  23479. static set AnisotropicTextureEnabled(value: boolean);
  23480. private static _ThicknessTextureEnabled;
  23481. /**
  23482. * Are thickness textures enabled in the application.
  23483. */
  23484. static get ThicknessTextureEnabled(): boolean;
  23485. static set ThicknessTextureEnabled(value: boolean);
  23486. }
  23487. }
  23488. declare module BABYLON {
  23489. /** @hidden */
  23490. export var defaultFragmentDeclaration: {
  23491. name: string;
  23492. shader: string;
  23493. };
  23494. }
  23495. declare module BABYLON {
  23496. /** @hidden */
  23497. export var defaultUboDeclaration: {
  23498. name: string;
  23499. shader: string;
  23500. };
  23501. }
  23502. declare module BABYLON {
  23503. /** @hidden */
  23504. export var prePassDeclaration: {
  23505. name: string;
  23506. shader: string;
  23507. };
  23508. }
  23509. declare module BABYLON {
  23510. /** @hidden */
  23511. export var lightFragmentDeclaration: {
  23512. name: string;
  23513. shader: string;
  23514. };
  23515. }
  23516. declare module BABYLON {
  23517. /** @hidden */
  23518. export var lightUboDeclaration: {
  23519. name: string;
  23520. shader: string;
  23521. };
  23522. }
  23523. declare module BABYLON {
  23524. /** @hidden */
  23525. export var lightsFragmentFunctions: {
  23526. name: string;
  23527. shader: string;
  23528. };
  23529. }
  23530. declare module BABYLON {
  23531. /** @hidden */
  23532. export var shadowsFragmentFunctions: {
  23533. name: string;
  23534. shader: string;
  23535. };
  23536. }
  23537. declare module BABYLON {
  23538. /** @hidden */
  23539. export var fresnelFunction: {
  23540. name: string;
  23541. shader: string;
  23542. };
  23543. }
  23544. declare module BABYLON {
  23545. /** @hidden */
  23546. export var bumpFragmentMainFunctions: {
  23547. name: string;
  23548. shader: string;
  23549. };
  23550. }
  23551. declare module BABYLON {
  23552. /** @hidden */
  23553. export var bumpFragmentFunctions: {
  23554. name: string;
  23555. shader: string;
  23556. };
  23557. }
  23558. declare module BABYLON {
  23559. /** @hidden */
  23560. export var logDepthDeclaration: {
  23561. name: string;
  23562. shader: string;
  23563. };
  23564. }
  23565. declare module BABYLON {
  23566. /** @hidden */
  23567. export var bumpFragment: {
  23568. name: string;
  23569. shader: string;
  23570. };
  23571. }
  23572. declare module BABYLON {
  23573. /** @hidden */
  23574. export var depthPrePass: {
  23575. name: string;
  23576. shader: string;
  23577. };
  23578. }
  23579. declare module BABYLON {
  23580. /** @hidden */
  23581. export var lightFragment: {
  23582. name: string;
  23583. shader: string;
  23584. };
  23585. }
  23586. declare module BABYLON {
  23587. /** @hidden */
  23588. export var logDepthFragment: {
  23589. name: string;
  23590. shader: string;
  23591. };
  23592. }
  23593. declare module BABYLON {
  23594. /** @hidden */
  23595. export var defaultPixelShader: {
  23596. name: string;
  23597. shader: string;
  23598. };
  23599. }
  23600. declare module BABYLON {
  23601. /** @hidden */
  23602. export var defaultVertexDeclaration: {
  23603. name: string;
  23604. shader: string;
  23605. };
  23606. }
  23607. declare module BABYLON {
  23608. /** @hidden */
  23609. export var prePassVertexDeclaration: {
  23610. name: string;
  23611. shader: string;
  23612. };
  23613. }
  23614. declare module BABYLON {
  23615. /** @hidden */
  23616. export var bumpVertexDeclaration: {
  23617. name: string;
  23618. shader: string;
  23619. };
  23620. }
  23621. declare module BABYLON {
  23622. /** @hidden */
  23623. export var prePassVertex: {
  23624. name: string;
  23625. shader: string;
  23626. };
  23627. }
  23628. declare module BABYLON {
  23629. /** @hidden */
  23630. export var bumpVertex: {
  23631. name: string;
  23632. shader: string;
  23633. };
  23634. }
  23635. declare module BABYLON {
  23636. /** @hidden */
  23637. export var fogVertex: {
  23638. name: string;
  23639. shader: string;
  23640. };
  23641. }
  23642. declare module BABYLON {
  23643. /** @hidden */
  23644. export var shadowsVertex: {
  23645. name: string;
  23646. shader: string;
  23647. };
  23648. }
  23649. declare module BABYLON {
  23650. /** @hidden */
  23651. export var pointCloudVertex: {
  23652. name: string;
  23653. shader: string;
  23654. };
  23655. }
  23656. declare module BABYLON {
  23657. /** @hidden */
  23658. export var logDepthVertex: {
  23659. name: string;
  23660. shader: string;
  23661. };
  23662. }
  23663. declare module BABYLON {
  23664. /** @hidden */
  23665. export var defaultVertexShader: {
  23666. name: string;
  23667. shader: string;
  23668. };
  23669. }
  23670. declare module BABYLON {
  23671. /**
  23672. * @hidden
  23673. */
  23674. export interface IMaterialDetailMapDefines {
  23675. DETAIL: boolean;
  23676. DETAILDIRECTUV: number;
  23677. DETAIL_NORMALBLENDMETHOD: number;
  23678. /** @hidden */
  23679. _areTexturesDirty: boolean;
  23680. }
  23681. /**
  23682. * Define the code related to the detail map parameters of a material
  23683. *
  23684. * Inspired from:
  23685. * 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
  23686. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23687. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23688. */
  23689. export class DetailMapConfiguration {
  23690. private _texture;
  23691. /**
  23692. * The detail texture of the material.
  23693. */
  23694. texture: Nullable<BaseTexture>;
  23695. /**
  23696. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23697. * Bigger values mean stronger blending
  23698. */
  23699. diffuseBlendLevel: number;
  23700. /**
  23701. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23702. * Bigger values mean stronger blending. Only used with PBR materials
  23703. */
  23704. roughnessBlendLevel: number;
  23705. /**
  23706. * Defines how strong the bump effect from the detail map is
  23707. * Bigger values mean stronger effect
  23708. */
  23709. bumpLevel: number;
  23710. private _normalBlendMethod;
  23711. /**
  23712. * The method used to blend the bump and detail normals together
  23713. */
  23714. normalBlendMethod: number;
  23715. private _isEnabled;
  23716. /**
  23717. * Enable or disable the detail map on this material
  23718. */
  23719. isEnabled: boolean;
  23720. /** @hidden */
  23721. private _internalMarkAllSubMeshesAsTexturesDirty;
  23722. /** @hidden */
  23723. _markAllSubMeshesAsTexturesDirty(): void;
  23724. /**
  23725. * Instantiate a new detail map
  23726. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  23727. */
  23728. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  23729. /**
  23730. * Gets whether the submesh is ready to be used or not.
  23731. * @param defines the list of "defines" to update.
  23732. * @param scene defines the scene the material belongs to.
  23733. * @returns - boolean indicating that the submesh is ready or not.
  23734. */
  23735. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  23736. /**
  23737. * Update the defines for detail map usage
  23738. * @param defines the list of "defines" to update.
  23739. * @param scene defines the scene the material belongs to.
  23740. */
  23741. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  23742. /**
  23743. * Binds the material data.
  23744. * @param uniformBuffer defines the Uniform buffer to fill in.
  23745. * @param scene defines the scene the material belongs to.
  23746. * @param isFrozen defines whether the material is frozen or not.
  23747. */
  23748. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  23749. /**
  23750. * Checks to see if a texture is used in the material.
  23751. * @param texture - Base texture to use.
  23752. * @returns - Boolean specifying if a texture is used in the material.
  23753. */
  23754. hasTexture(texture: BaseTexture): boolean;
  23755. /**
  23756. * Returns an array of the actively used textures.
  23757. * @param activeTextures Array of BaseTextures
  23758. */
  23759. getActiveTextures(activeTextures: BaseTexture[]): void;
  23760. /**
  23761. * Returns the animatable textures.
  23762. * @param animatables Array of animatable textures.
  23763. */
  23764. getAnimatables(animatables: IAnimatable[]): void;
  23765. /**
  23766. * Disposes the resources of the material.
  23767. * @param forceDisposeTextures - Forces the disposal of all textures.
  23768. */
  23769. dispose(forceDisposeTextures?: boolean): void;
  23770. /**
  23771. * Get the current class name useful for serialization or dynamic coding.
  23772. * @returns "DetailMap"
  23773. */
  23774. getClassName(): string;
  23775. /**
  23776. * Add the required uniforms to the current list.
  23777. * @param uniforms defines the current uniform list.
  23778. */
  23779. static AddUniforms(uniforms: string[]): void;
  23780. /**
  23781. * Add the required samplers to the current list.
  23782. * @param samplers defines the current sampler list.
  23783. */
  23784. static AddSamplers(samplers: string[]): void;
  23785. /**
  23786. * Add the required uniforms to the current buffer.
  23787. * @param uniformBuffer defines the current uniform buffer.
  23788. */
  23789. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  23790. /**
  23791. * Makes a duplicate of the current instance into another one.
  23792. * @param detailMap define the instance where to copy the info
  23793. */
  23794. copyTo(detailMap: DetailMapConfiguration): void;
  23795. /**
  23796. * Serializes this detail map instance
  23797. * @returns - An object with the serialized instance.
  23798. */
  23799. serialize(): any;
  23800. /**
  23801. * Parses a detail map setting from a serialized object.
  23802. * @param source - Serialized object.
  23803. * @param scene Defines the scene we are parsing for
  23804. * @param rootUrl Defines the rootUrl to load from
  23805. */
  23806. parse(source: any, scene: Scene, rootUrl: string): void;
  23807. }
  23808. }
  23809. declare module BABYLON {
  23810. /** @hidden */
  23811. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  23812. MAINUV1: boolean;
  23813. MAINUV2: boolean;
  23814. DIFFUSE: boolean;
  23815. DIFFUSEDIRECTUV: number;
  23816. DETAIL: boolean;
  23817. DETAILDIRECTUV: number;
  23818. DETAIL_NORMALBLENDMETHOD: number;
  23819. AMBIENT: boolean;
  23820. AMBIENTDIRECTUV: number;
  23821. OPACITY: boolean;
  23822. OPACITYDIRECTUV: number;
  23823. OPACITYRGB: boolean;
  23824. REFLECTION: boolean;
  23825. EMISSIVE: boolean;
  23826. EMISSIVEDIRECTUV: number;
  23827. SPECULAR: boolean;
  23828. SPECULARDIRECTUV: number;
  23829. BUMP: boolean;
  23830. BUMPDIRECTUV: number;
  23831. PARALLAX: boolean;
  23832. PARALLAXOCCLUSION: boolean;
  23833. SPECULAROVERALPHA: boolean;
  23834. CLIPPLANE: boolean;
  23835. CLIPPLANE2: boolean;
  23836. CLIPPLANE3: boolean;
  23837. CLIPPLANE4: boolean;
  23838. CLIPPLANE5: boolean;
  23839. CLIPPLANE6: boolean;
  23840. ALPHATEST: boolean;
  23841. DEPTHPREPASS: boolean;
  23842. ALPHAFROMDIFFUSE: boolean;
  23843. POINTSIZE: boolean;
  23844. FOG: boolean;
  23845. SPECULARTERM: boolean;
  23846. DIFFUSEFRESNEL: boolean;
  23847. OPACITYFRESNEL: boolean;
  23848. REFLECTIONFRESNEL: boolean;
  23849. REFRACTIONFRESNEL: boolean;
  23850. EMISSIVEFRESNEL: boolean;
  23851. FRESNEL: boolean;
  23852. NORMAL: boolean;
  23853. UV1: boolean;
  23854. UV2: boolean;
  23855. VERTEXCOLOR: boolean;
  23856. VERTEXALPHA: boolean;
  23857. NUM_BONE_INFLUENCERS: number;
  23858. BonesPerMesh: number;
  23859. BONETEXTURE: boolean;
  23860. BONES_VELOCITY_ENABLED: boolean;
  23861. INSTANCES: boolean;
  23862. THIN_INSTANCES: boolean;
  23863. GLOSSINESS: boolean;
  23864. ROUGHNESS: boolean;
  23865. EMISSIVEASILLUMINATION: boolean;
  23866. LINKEMISSIVEWITHDIFFUSE: boolean;
  23867. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23868. LIGHTMAP: boolean;
  23869. LIGHTMAPDIRECTUV: number;
  23870. OBJECTSPACE_NORMALMAP: boolean;
  23871. USELIGHTMAPASSHADOWMAP: boolean;
  23872. REFLECTIONMAP_3D: boolean;
  23873. REFLECTIONMAP_SPHERICAL: boolean;
  23874. REFLECTIONMAP_PLANAR: boolean;
  23875. REFLECTIONMAP_CUBIC: boolean;
  23876. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23877. REFLECTIONMAP_PROJECTION: boolean;
  23878. REFLECTIONMAP_SKYBOX: boolean;
  23879. REFLECTIONMAP_EXPLICIT: boolean;
  23880. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23881. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23882. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23883. INVERTCUBICMAP: boolean;
  23884. LOGARITHMICDEPTH: boolean;
  23885. REFRACTION: boolean;
  23886. REFRACTIONMAP_3D: boolean;
  23887. REFLECTIONOVERALPHA: boolean;
  23888. TWOSIDEDLIGHTING: boolean;
  23889. SHADOWFLOAT: boolean;
  23890. MORPHTARGETS: boolean;
  23891. MORPHTARGETS_NORMAL: boolean;
  23892. MORPHTARGETS_TANGENT: boolean;
  23893. MORPHTARGETS_UV: boolean;
  23894. NUM_MORPH_INFLUENCERS: number;
  23895. NONUNIFORMSCALING: boolean;
  23896. PREMULTIPLYALPHA: boolean;
  23897. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  23898. ALPHABLEND: boolean;
  23899. PREPASS: boolean;
  23900. PREPASS_IRRADIANCE: boolean;
  23901. PREPASS_IRRADIANCE_INDEX: number;
  23902. PREPASS_ALBEDO: boolean;
  23903. PREPASS_ALBEDO_INDEX: number;
  23904. PREPASS_DEPTHNORMAL: boolean;
  23905. PREPASS_DEPTHNORMAL_INDEX: number;
  23906. PREPASS_POSITION: boolean;
  23907. PREPASS_POSITION_INDEX: number;
  23908. PREPASS_VELOCITY: boolean;
  23909. PREPASS_VELOCITY_INDEX: number;
  23910. PREPASS_REFLECTIVITY: boolean;
  23911. PREPASS_REFLECTIVITY_INDEX: number;
  23912. SCENE_MRT_COUNT: number;
  23913. RGBDLIGHTMAP: boolean;
  23914. RGBDREFLECTION: boolean;
  23915. RGBDREFRACTION: boolean;
  23916. IMAGEPROCESSING: boolean;
  23917. VIGNETTE: boolean;
  23918. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23919. VIGNETTEBLENDMODEOPAQUE: boolean;
  23920. TONEMAPPING: boolean;
  23921. TONEMAPPING_ACES: boolean;
  23922. CONTRAST: boolean;
  23923. COLORCURVES: boolean;
  23924. COLORGRADING: boolean;
  23925. COLORGRADING3D: boolean;
  23926. SAMPLER3DGREENDEPTH: boolean;
  23927. SAMPLER3DBGRMAP: boolean;
  23928. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23929. MULTIVIEW: boolean;
  23930. /**
  23931. * If the reflection texture on this material is in linear color space
  23932. * @hidden
  23933. */
  23934. IS_REFLECTION_LINEAR: boolean;
  23935. /**
  23936. * If the refraction texture on this material is in linear color space
  23937. * @hidden
  23938. */
  23939. IS_REFRACTION_LINEAR: boolean;
  23940. EXPOSURE: boolean;
  23941. constructor();
  23942. setReflectionMode(modeToEnable: string): void;
  23943. }
  23944. /**
  23945. * This is the default material used in Babylon. It is the best trade off between quality
  23946. * and performances.
  23947. * @see https://doc.babylonjs.com/babylon101/materials
  23948. */
  23949. export class StandardMaterial extends PushMaterial {
  23950. private _diffuseTexture;
  23951. /**
  23952. * The basic texture of the material as viewed under a light.
  23953. */
  23954. diffuseTexture: Nullable<BaseTexture>;
  23955. private _ambientTexture;
  23956. /**
  23957. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23958. */
  23959. ambientTexture: Nullable<BaseTexture>;
  23960. private _opacityTexture;
  23961. /**
  23962. * Define the transparency of the material from a texture.
  23963. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23964. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23965. */
  23966. opacityTexture: Nullable<BaseTexture>;
  23967. private _reflectionTexture;
  23968. /**
  23969. * Define the texture used to display the reflection.
  23970. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23971. */
  23972. reflectionTexture: Nullable<BaseTexture>;
  23973. private _emissiveTexture;
  23974. /**
  23975. * Define texture of the material as if self lit.
  23976. * This will be mixed in the final result even in the absence of light.
  23977. */
  23978. emissiveTexture: Nullable<BaseTexture>;
  23979. private _specularTexture;
  23980. /**
  23981. * Define how the color and intensity of the highlight given by the light in the material.
  23982. */
  23983. specularTexture: Nullable<BaseTexture>;
  23984. private _bumpTexture;
  23985. /**
  23986. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23987. * 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.
  23988. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  23989. */
  23990. bumpTexture: Nullable<BaseTexture>;
  23991. private _lightmapTexture;
  23992. /**
  23993. * Complex lighting can be computationally expensive to compute at runtime.
  23994. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23995. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  23996. */
  23997. lightmapTexture: Nullable<BaseTexture>;
  23998. private _refractionTexture;
  23999. /**
  24000. * Define the texture used to display the refraction.
  24001. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24002. */
  24003. refractionTexture: Nullable<BaseTexture>;
  24004. /**
  24005. * The color of the material lit by the environmental background lighting.
  24006. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24007. */
  24008. ambientColor: Color3;
  24009. /**
  24010. * The basic color of the material as viewed under a light.
  24011. */
  24012. diffuseColor: Color3;
  24013. /**
  24014. * Define how the color and intensity of the highlight given by the light in the material.
  24015. */
  24016. specularColor: Color3;
  24017. /**
  24018. * Define the color of the material as if self lit.
  24019. * This will be mixed in the final result even in the absence of light.
  24020. */
  24021. emissiveColor: Color3;
  24022. /**
  24023. * Defines how sharp are the highlights in the material.
  24024. * The bigger the value the sharper giving a more glossy feeling to the result.
  24025. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24026. */
  24027. specularPower: number;
  24028. private _useAlphaFromDiffuseTexture;
  24029. /**
  24030. * Does the transparency come from the diffuse texture alpha channel.
  24031. */
  24032. useAlphaFromDiffuseTexture: boolean;
  24033. private _useEmissiveAsIllumination;
  24034. /**
  24035. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24036. */
  24037. useEmissiveAsIllumination: boolean;
  24038. private _linkEmissiveWithDiffuse;
  24039. /**
  24040. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24041. * the emissive level when the final color is close to one.
  24042. */
  24043. linkEmissiveWithDiffuse: boolean;
  24044. private _useSpecularOverAlpha;
  24045. /**
  24046. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24047. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24048. */
  24049. useSpecularOverAlpha: boolean;
  24050. private _useReflectionOverAlpha;
  24051. /**
  24052. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24053. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24054. */
  24055. useReflectionOverAlpha: boolean;
  24056. private _disableLighting;
  24057. /**
  24058. * Does lights from the scene impacts this material.
  24059. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24060. */
  24061. disableLighting: boolean;
  24062. private _useObjectSpaceNormalMap;
  24063. /**
  24064. * Allows using an object space normal map (instead of tangent space).
  24065. */
  24066. useObjectSpaceNormalMap: boolean;
  24067. private _useParallax;
  24068. /**
  24069. * Is parallax enabled or not.
  24070. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24071. */
  24072. useParallax: boolean;
  24073. private _useParallaxOcclusion;
  24074. /**
  24075. * Is parallax occlusion enabled or not.
  24076. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24077. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24078. */
  24079. useParallaxOcclusion: boolean;
  24080. /**
  24081. * 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.
  24082. */
  24083. parallaxScaleBias: number;
  24084. private _roughness;
  24085. /**
  24086. * Helps to define how blurry the reflections should appears in the material.
  24087. */
  24088. roughness: number;
  24089. /**
  24090. * In case of refraction, define the value of the index of refraction.
  24091. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24092. */
  24093. indexOfRefraction: number;
  24094. /**
  24095. * Invert the refraction texture alongside the y axis.
  24096. * It can be useful with procedural textures or probe for instance.
  24097. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24098. */
  24099. invertRefractionY: boolean;
  24100. /**
  24101. * Defines the alpha limits in alpha test mode.
  24102. */
  24103. alphaCutOff: number;
  24104. private _useLightmapAsShadowmap;
  24105. /**
  24106. * In case of light mapping, define whether the map contains light or shadow informations.
  24107. */
  24108. useLightmapAsShadowmap: boolean;
  24109. private _diffuseFresnelParameters;
  24110. /**
  24111. * Define the diffuse fresnel parameters of the material.
  24112. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24113. */
  24114. diffuseFresnelParameters: FresnelParameters;
  24115. private _opacityFresnelParameters;
  24116. /**
  24117. * Define the opacity fresnel parameters of the material.
  24118. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24119. */
  24120. opacityFresnelParameters: FresnelParameters;
  24121. private _reflectionFresnelParameters;
  24122. /**
  24123. * Define the reflection fresnel parameters of the material.
  24124. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24125. */
  24126. reflectionFresnelParameters: FresnelParameters;
  24127. private _refractionFresnelParameters;
  24128. /**
  24129. * Define the refraction fresnel parameters of the material.
  24130. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24131. */
  24132. refractionFresnelParameters: FresnelParameters;
  24133. private _emissiveFresnelParameters;
  24134. /**
  24135. * Define the emissive fresnel parameters of the material.
  24136. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24137. */
  24138. emissiveFresnelParameters: FresnelParameters;
  24139. private _useReflectionFresnelFromSpecular;
  24140. /**
  24141. * If true automatically deducts the fresnels values from the material specularity.
  24142. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24143. */
  24144. useReflectionFresnelFromSpecular: boolean;
  24145. private _useGlossinessFromSpecularMapAlpha;
  24146. /**
  24147. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24148. */
  24149. useGlossinessFromSpecularMapAlpha: boolean;
  24150. private _maxSimultaneousLights;
  24151. /**
  24152. * Defines the maximum number of lights that can be used in the material
  24153. */
  24154. maxSimultaneousLights: number;
  24155. private _invertNormalMapX;
  24156. /**
  24157. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24158. */
  24159. invertNormalMapX: boolean;
  24160. private _invertNormalMapY;
  24161. /**
  24162. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24163. */
  24164. invertNormalMapY: boolean;
  24165. private _twoSidedLighting;
  24166. /**
  24167. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24168. */
  24169. twoSidedLighting: boolean;
  24170. /**
  24171. * Default configuration related to image processing available in the standard Material.
  24172. */
  24173. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24174. /**
  24175. * Gets the image processing configuration used either in this material.
  24176. */
  24177. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24178. /**
  24179. * Sets the Default image processing configuration used either in the this material.
  24180. *
  24181. * If sets to null, the scene one is in use.
  24182. */
  24183. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24184. /**
  24185. * Keep track of the image processing observer to allow dispose and replace.
  24186. */
  24187. private _imageProcessingObserver;
  24188. /**
  24189. * Attaches a new image processing configuration to the Standard Material.
  24190. * @param configuration
  24191. */
  24192. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24193. /**
  24194. * Defines additionnal PrePass parameters for the material.
  24195. */
  24196. readonly prePassConfiguration: PrePassConfiguration;
  24197. /**
  24198. * Gets wether the color curves effect is enabled.
  24199. */
  24200. get cameraColorCurvesEnabled(): boolean;
  24201. /**
  24202. * Sets wether the color curves effect is enabled.
  24203. */
  24204. set cameraColorCurvesEnabled(value: boolean);
  24205. /**
  24206. * Gets wether the color grading effect is enabled.
  24207. */
  24208. get cameraColorGradingEnabled(): boolean;
  24209. /**
  24210. * Gets wether the color grading effect is enabled.
  24211. */
  24212. set cameraColorGradingEnabled(value: boolean);
  24213. /**
  24214. * Gets wether tonemapping is enabled or not.
  24215. */
  24216. get cameraToneMappingEnabled(): boolean;
  24217. /**
  24218. * Sets wether tonemapping is enabled or not
  24219. */
  24220. set cameraToneMappingEnabled(value: boolean);
  24221. /**
  24222. * The camera exposure used on this material.
  24223. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24224. * This corresponds to a photographic exposure.
  24225. */
  24226. get cameraExposure(): number;
  24227. /**
  24228. * The camera exposure used on this material.
  24229. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24230. * This corresponds to a photographic exposure.
  24231. */
  24232. set cameraExposure(value: number);
  24233. /**
  24234. * Gets The camera contrast used on this material.
  24235. */
  24236. get cameraContrast(): number;
  24237. /**
  24238. * Sets The camera contrast used on this material.
  24239. */
  24240. set cameraContrast(value: number);
  24241. /**
  24242. * Gets the Color Grading 2D Lookup Texture.
  24243. */
  24244. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24245. /**
  24246. * Sets the Color Grading 2D Lookup Texture.
  24247. */
  24248. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24249. /**
  24250. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24251. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24252. * 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;
  24253. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24254. */
  24255. get cameraColorCurves(): Nullable<ColorCurves>;
  24256. /**
  24257. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24258. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24259. * 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;
  24260. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24261. */
  24262. set cameraColorCurves(value: Nullable<ColorCurves>);
  24263. /**
  24264. * Can this material render to several textures at once
  24265. */
  24266. get canRenderToMRT(): boolean;
  24267. /**
  24268. * Defines the detail map parameters for the material.
  24269. */
  24270. readonly detailMap: DetailMapConfiguration;
  24271. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24272. protected _worldViewProjectionMatrix: Matrix;
  24273. protected _globalAmbientColor: Color3;
  24274. protected _useLogarithmicDepth: boolean;
  24275. protected _rebuildInParallel: boolean;
  24276. /**
  24277. * Instantiates a new standard material.
  24278. * This is the default material used in Babylon. It is the best trade off between quality
  24279. * and performances.
  24280. * @see https://doc.babylonjs.com/babylon101/materials
  24281. * @param name Define the name of the material in the scene
  24282. * @param scene Define the scene the material belong to
  24283. */
  24284. constructor(name: string, scene: Scene);
  24285. /**
  24286. * Gets a boolean indicating that current material needs to register RTT
  24287. */
  24288. get hasRenderTargetTextures(): boolean;
  24289. /**
  24290. * Gets the current class name of the material e.g. "StandardMaterial"
  24291. * Mainly use in serialization.
  24292. * @returns the class name
  24293. */
  24294. getClassName(): string;
  24295. /**
  24296. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24297. * You can try switching to logarithmic depth.
  24298. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24299. */
  24300. get useLogarithmicDepth(): boolean;
  24301. set useLogarithmicDepth(value: boolean);
  24302. /**
  24303. * Specifies if the material will require alpha blending
  24304. * @returns a boolean specifying if alpha blending is needed
  24305. */
  24306. needAlphaBlending(): boolean;
  24307. /**
  24308. * Specifies if this material should be rendered in alpha test mode
  24309. * @returns a boolean specifying if an alpha test is needed.
  24310. */
  24311. needAlphaTesting(): boolean;
  24312. /**
  24313. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  24314. */
  24315. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24316. /**
  24317. * Specifies whether or not there is a usable alpha channel for transparency.
  24318. */
  24319. protected _hasAlphaChannel(): boolean;
  24320. /**
  24321. * Get the texture used for alpha test purpose.
  24322. * @returns the diffuse texture in case of the standard material.
  24323. */
  24324. getAlphaTestTexture(): Nullable<BaseTexture>;
  24325. /**
  24326. * Get if the submesh is ready to be used and all its information available.
  24327. * Child classes can use it to update shaders
  24328. * @param mesh defines the mesh to check
  24329. * @param subMesh defines which submesh to check
  24330. * @param useInstances specifies that instances should be used
  24331. * @returns a boolean indicating that the submesh is ready or not
  24332. */
  24333. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24334. /**
  24335. * Builds the material UBO layouts.
  24336. * Used internally during the effect preparation.
  24337. */
  24338. buildUniformLayout(): void;
  24339. /**
  24340. * Unbinds the material from the mesh
  24341. */
  24342. unbind(): void;
  24343. /**
  24344. * Binds the submesh to this material by preparing the effect and shader to draw
  24345. * @param world defines the world transformation matrix
  24346. * @param mesh defines the mesh containing the submesh
  24347. * @param subMesh defines the submesh to bind the material to
  24348. */
  24349. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24350. /**
  24351. * Get the list of animatables in the material.
  24352. * @returns the list of animatables object used in the material
  24353. */
  24354. getAnimatables(): IAnimatable[];
  24355. /**
  24356. * Gets the active textures from the material
  24357. * @returns an array of textures
  24358. */
  24359. getActiveTextures(): BaseTexture[];
  24360. /**
  24361. * Specifies if the material uses a texture
  24362. * @param texture defines the texture to check against the material
  24363. * @returns a boolean specifying if the material uses the texture
  24364. */
  24365. hasTexture(texture: BaseTexture): boolean;
  24366. /**
  24367. * Disposes the material
  24368. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24369. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24370. */
  24371. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24372. /**
  24373. * Makes a duplicate of the material, and gives it a new name
  24374. * @param name defines the new name for the duplicated material
  24375. * @returns the cloned material
  24376. */
  24377. clone(name: string): StandardMaterial;
  24378. /**
  24379. * Serializes this material in a JSON representation
  24380. * @returns the serialized material object
  24381. */
  24382. serialize(): any;
  24383. /**
  24384. * Creates a standard material from parsed material data
  24385. * @param source defines the JSON representation of the material
  24386. * @param scene defines the hosting scene
  24387. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24388. * @returns a new standard material
  24389. */
  24390. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24391. /**
  24392. * Are diffuse textures enabled in the application.
  24393. */
  24394. static get DiffuseTextureEnabled(): boolean;
  24395. static set DiffuseTextureEnabled(value: boolean);
  24396. /**
  24397. * Are detail textures enabled in the application.
  24398. */
  24399. static get DetailTextureEnabled(): boolean;
  24400. static set DetailTextureEnabled(value: boolean);
  24401. /**
  24402. * Are ambient textures enabled in the application.
  24403. */
  24404. static get AmbientTextureEnabled(): boolean;
  24405. static set AmbientTextureEnabled(value: boolean);
  24406. /**
  24407. * Are opacity textures enabled in the application.
  24408. */
  24409. static get OpacityTextureEnabled(): boolean;
  24410. static set OpacityTextureEnabled(value: boolean);
  24411. /**
  24412. * Are reflection textures enabled in the application.
  24413. */
  24414. static get ReflectionTextureEnabled(): boolean;
  24415. static set ReflectionTextureEnabled(value: boolean);
  24416. /**
  24417. * Are emissive textures enabled in the application.
  24418. */
  24419. static get EmissiveTextureEnabled(): boolean;
  24420. static set EmissiveTextureEnabled(value: boolean);
  24421. /**
  24422. * Are specular textures enabled in the application.
  24423. */
  24424. static get SpecularTextureEnabled(): boolean;
  24425. static set SpecularTextureEnabled(value: boolean);
  24426. /**
  24427. * Are bump textures enabled in the application.
  24428. */
  24429. static get BumpTextureEnabled(): boolean;
  24430. static set BumpTextureEnabled(value: boolean);
  24431. /**
  24432. * Are lightmap textures enabled in the application.
  24433. */
  24434. static get LightmapTextureEnabled(): boolean;
  24435. static set LightmapTextureEnabled(value: boolean);
  24436. /**
  24437. * Are refraction textures enabled in the application.
  24438. */
  24439. static get RefractionTextureEnabled(): boolean;
  24440. static set RefractionTextureEnabled(value: boolean);
  24441. /**
  24442. * Are color grading textures enabled in the application.
  24443. */
  24444. static get ColorGradingTextureEnabled(): boolean;
  24445. static set ColorGradingTextureEnabled(value: boolean);
  24446. /**
  24447. * Are fresnels enabled in the application.
  24448. */
  24449. static get FresnelEnabled(): boolean;
  24450. static set FresnelEnabled(value: boolean);
  24451. }
  24452. }
  24453. declare module BABYLON {
  24454. /** @hidden */
  24455. export var rgbdDecodePixelShader: {
  24456. name: string;
  24457. shader: string;
  24458. };
  24459. }
  24460. declare module BABYLON {
  24461. /**
  24462. * Class used to host RGBD texture specific utilities
  24463. */
  24464. export class RGBDTextureTools {
  24465. /**
  24466. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24467. * @param texture the texture to expand.
  24468. */
  24469. static ExpandRGBDTexture(texture: Texture): void;
  24470. }
  24471. }
  24472. declare module BABYLON {
  24473. /**
  24474. * Class used to host texture specific utilities
  24475. */
  24476. export class BRDFTextureTools {
  24477. /**
  24478. * Prevents texture cache collision
  24479. */
  24480. private static _instanceNumber;
  24481. /**
  24482. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24483. * @param scene defines the hosting scene
  24484. * @returns the environment BRDF texture
  24485. */
  24486. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24487. private static _environmentBRDFBase64Texture;
  24488. }
  24489. }
  24490. declare module BABYLON {
  24491. /**
  24492. * @hidden
  24493. */
  24494. export interface IMaterialClearCoatDefines {
  24495. CLEARCOAT: boolean;
  24496. CLEARCOAT_DEFAULTIOR: boolean;
  24497. CLEARCOAT_TEXTURE: boolean;
  24498. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  24499. CLEARCOAT_TEXTUREDIRECTUV: number;
  24500. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  24501. CLEARCOAT_BUMP: boolean;
  24502. CLEARCOAT_BUMPDIRECTUV: number;
  24503. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24504. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24505. CLEARCOAT_REMAP_F0: boolean;
  24506. CLEARCOAT_TINT: boolean;
  24507. CLEARCOAT_TINT_TEXTURE: boolean;
  24508. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24509. /** @hidden */
  24510. _areTexturesDirty: boolean;
  24511. }
  24512. /**
  24513. * Define the code related to the clear coat parameters of the pbr material.
  24514. */
  24515. export class PBRClearCoatConfiguration {
  24516. /**
  24517. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24518. * The default fits with a polyurethane material.
  24519. */
  24520. private static readonly _DefaultIndexOfRefraction;
  24521. private _isEnabled;
  24522. /**
  24523. * Defines if the clear coat is enabled in the material.
  24524. */
  24525. isEnabled: boolean;
  24526. /**
  24527. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24528. */
  24529. intensity: number;
  24530. /**
  24531. * Defines the clear coat layer roughness.
  24532. */
  24533. roughness: number;
  24534. private _indexOfRefraction;
  24535. /**
  24536. * Defines the index of refraction of the clear coat.
  24537. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24538. * The default fits with a polyurethane material.
  24539. * Changing the default value is more performance intensive.
  24540. */
  24541. indexOfRefraction: number;
  24542. private _texture;
  24543. /**
  24544. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  24545. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  24546. * if textureRoughness is not empty, else no texture roughness is used
  24547. */
  24548. texture: Nullable<BaseTexture>;
  24549. private _useRoughnessFromMainTexture;
  24550. /**
  24551. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  24552. * If false, the green channel from textureRoughness is used for roughness
  24553. */
  24554. useRoughnessFromMainTexture: boolean;
  24555. private _textureRoughness;
  24556. /**
  24557. * Stores the clear coat roughness in a texture (green channel)
  24558. * Not used if useRoughnessFromMainTexture is true
  24559. */
  24560. textureRoughness: Nullable<BaseTexture>;
  24561. private _remapF0OnInterfaceChange;
  24562. /**
  24563. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24564. */
  24565. remapF0OnInterfaceChange: boolean;
  24566. private _bumpTexture;
  24567. /**
  24568. * Define the clear coat specific bump texture.
  24569. */
  24570. bumpTexture: Nullable<BaseTexture>;
  24571. private _isTintEnabled;
  24572. /**
  24573. * Defines if the clear coat tint is enabled in the material.
  24574. */
  24575. isTintEnabled: boolean;
  24576. /**
  24577. * Defines the clear coat tint of the material.
  24578. * This is only use if tint is enabled
  24579. */
  24580. tintColor: Color3;
  24581. /**
  24582. * Defines the distance at which the tint color should be found in the
  24583. * clear coat media.
  24584. * This is only use if tint is enabled
  24585. */
  24586. tintColorAtDistance: number;
  24587. /**
  24588. * Defines the clear coat layer thickness.
  24589. * This is only use if tint is enabled
  24590. */
  24591. tintThickness: number;
  24592. private _tintTexture;
  24593. /**
  24594. * Stores the clear tint values in a texture.
  24595. * rgb is tint
  24596. * a is a thickness factor
  24597. */
  24598. tintTexture: Nullable<BaseTexture>;
  24599. /** @hidden */
  24600. private _internalMarkAllSubMeshesAsTexturesDirty;
  24601. /** @hidden */
  24602. _markAllSubMeshesAsTexturesDirty(): void;
  24603. /**
  24604. * Instantiate a new istance of clear coat configuration.
  24605. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24606. */
  24607. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24608. /**
  24609. * Gets wehter the submesh is ready to be used or not.
  24610. * @param defines the list of "defines" to update.
  24611. * @param scene defines the scene the material belongs to.
  24612. * @param engine defines the engine the material belongs to.
  24613. * @param disableBumpMap defines wether the material disables bump or not.
  24614. * @returns - boolean indicating that the submesh is ready or not.
  24615. */
  24616. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24617. /**
  24618. * Checks to see if a texture is used in the material.
  24619. * @param defines the list of "defines" to update.
  24620. * @param scene defines the scene to the material belongs to.
  24621. */
  24622. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24623. /**
  24624. * Binds the material data.
  24625. * @param uniformBuffer defines the Uniform buffer to fill in.
  24626. * @param scene defines the scene the material belongs to.
  24627. * @param engine defines the engine the material belongs to.
  24628. * @param disableBumpMap defines wether the material disables bump or not.
  24629. * @param isFrozen defines wether the material is frozen or not.
  24630. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24631. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24632. * @param subMesh the submesh to bind data for
  24633. */
  24634. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  24635. /**
  24636. * Checks to see if a texture is used in the material.
  24637. * @param texture - Base texture to use.
  24638. * @returns - Boolean specifying if a texture is used in the material.
  24639. */
  24640. hasTexture(texture: BaseTexture): boolean;
  24641. /**
  24642. * Returns an array of the actively used textures.
  24643. * @param activeTextures Array of BaseTextures
  24644. */
  24645. getActiveTextures(activeTextures: BaseTexture[]): void;
  24646. /**
  24647. * Returns the animatable textures.
  24648. * @param animatables Array of animatable textures.
  24649. */
  24650. getAnimatables(animatables: IAnimatable[]): void;
  24651. /**
  24652. * Disposes the resources of the material.
  24653. * @param forceDisposeTextures - Forces the disposal of all textures.
  24654. */
  24655. dispose(forceDisposeTextures?: boolean): void;
  24656. /**
  24657. * Get the current class name of the texture useful for serialization or dynamic coding.
  24658. * @returns "PBRClearCoatConfiguration"
  24659. */
  24660. getClassName(): string;
  24661. /**
  24662. * Add fallbacks to the effect fallbacks list.
  24663. * @param defines defines the Base texture to use.
  24664. * @param fallbacks defines the current fallback list.
  24665. * @param currentRank defines the current fallback rank.
  24666. * @returns the new fallback rank.
  24667. */
  24668. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24669. /**
  24670. * Add the required uniforms to the current list.
  24671. * @param uniforms defines the current uniform list.
  24672. */
  24673. static AddUniforms(uniforms: string[]): void;
  24674. /**
  24675. * Add the required samplers to the current list.
  24676. * @param samplers defines the current sampler list.
  24677. */
  24678. static AddSamplers(samplers: string[]): void;
  24679. /**
  24680. * Add the required uniforms to the current buffer.
  24681. * @param uniformBuffer defines the current uniform buffer.
  24682. */
  24683. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24684. /**
  24685. * Makes a duplicate of the current configuration into another one.
  24686. * @param clearCoatConfiguration define the config where to copy the info
  24687. */
  24688. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24689. /**
  24690. * Serializes this clear coat configuration.
  24691. * @returns - An object with the serialized config.
  24692. */
  24693. serialize(): any;
  24694. /**
  24695. * Parses a anisotropy Configuration from a serialized object.
  24696. * @param source - Serialized object.
  24697. * @param scene Defines the scene we are parsing for
  24698. * @param rootUrl Defines the rootUrl to load from
  24699. */
  24700. parse(source: any, scene: Scene, rootUrl: string): void;
  24701. }
  24702. }
  24703. declare module BABYLON {
  24704. /**
  24705. * @hidden
  24706. */
  24707. export interface IMaterialAnisotropicDefines {
  24708. ANISOTROPIC: boolean;
  24709. ANISOTROPIC_TEXTURE: boolean;
  24710. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24711. MAINUV1: boolean;
  24712. _areTexturesDirty: boolean;
  24713. _needUVs: boolean;
  24714. }
  24715. /**
  24716. * Define the code related to the anisotropic parameters of the pbr material.
  24717. */
  24718. export class PBRAnisotropicConfiguration {
  24719. private _isEnabled;
  24720. /**
  24721. * Defines if the anisotropy is enabled in the material.
  24722. */
  24723. isEnabled: boolean;
  24724. /**
  24725. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  24726. */
  24727. intensity: number;
  24728. /**
  24729. * Defines if the effect is along the tangents, bitangents or in between.
  24730. * By default, the effect is "strectching" the highlights along the tangents.
  24731. */
  24732. direction: Vector2;
  24733. private _texture;
  24734. /**
  24735. * Stores the anisotropy values in a texture.
  24736. * rg is direction (like normal from -1 to 1)
  24737. * b is a intensity
  24738. */
  24739. texture: Nullable<BaseTexture>;
  24740. /** @hidden */
  24741. private _internalMarkAllSubMeshesAsTexturesDirty;
  24742. /** @hidden */
  24743. _markAllSubMeshesAsTexturesDirty(): void;
  24744. /**
  24745. * Instantiate a new istance of anisotropy configuration.
  24746. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24747. */
  24748. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24749. /**
  24750. * Specifies that the submesh is ready to be used.
  24751. * @param defines the list of "defines" to update.
  24752. * @param scene defines the scene the material belongs to.
  24753. * @returns - boolean indicating that the submesh is ready or not.
  24754. */
  24755. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  24756. /**
  24757. * Checks to see if a texture is used in the material.
  24758. * @param defines the list of "defines" to update.
  24759. * @param mesh the mesh we are preparing the defines for.
  24760. * @param scene defines the scene the material belongs to.
  24761. */
  24762. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  24763. /**
  24764. * Binds the material data.
  24765. * @param uniformBuffer defines the Uniform buffer to fill in.
  24766. * @param scene defines the scene the material belongs to.
  24767. * @param isFrozen defines wether the material is frozen or not.
  24768. */
  24769. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24770. /**
  24771. * Checks to see if a texture is used in the material.
  24772. * @param texture - Base texture to use.
  24773. * @returns - Boolean specifying if a texture is used in the material.
  24774. */
  24775. hasTexture(texture: BaseTexture): boolean;
  24776. /**
  24777. * Returns an array of the actively used textures.
  24778. * @param activeTextures Array of BaseTextures
  24779. */
  24780. getActiveTextures(activeTextures: BaseTexture[]): void;
  24781. /**
  24782. * Returns the animatable textures.
  24783. * @param animatables Array of animatable textures.
  24784. */
  24785. getAnimatables(animatables: IAnimatable[]): void;
  24786. /**
  24787. * Disposes the resources of the material.
  24788. * @param forceDisposeTextures - Forces the disposal of all textures.
  24789. */
  24790. dispose(forceDisposeTextures?: boolean): void;
  24791. /**
  24792. * Get the current class name of the texture useful for serialization or dynamic coding.
  24793. * @returns "PBRAnisotropicConfiguration"
  24794. */
  24795. getClassName(): string;
  24796. /**
  24797. * Add fallbacks to the effect fallbacks list.
  24798. * @param defines defines the Base texture to use.
  24799. * @param fallbacks defines the current fallback list.
  24800. * @param currentRank defines the current fallback rank.
  24801. * @returns the new fallback rank.
  24802. */
  24803. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24804. /**
  24805. * Add the required uniforms to the current list.
  24806. * @param uniforms defines the current uniform list.
  24807. */
  24808. static AddUniforms(uniforms: string[]): void;
  24809. /**
  24810. * Add the required uniforms to the current buffer.
  24811. * @param uniformBuffer defines the current uniform buffer.
  24812. */
  24813. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24814. /**
  24815. * Add the required samplers to the current list.
  24816. * @param samplers defines the current sampler list.
  24817. */
  24818. static AddSamplers(samplers: string[]): void;
  24819. /**
  24820. * Makes a duplicate of the current configuration into another one.
  24821. * @param anisotropicConfiguration define the config where to copy the info
  24822. */
  24823. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  24824. /**
  24825. * Serializes this anisotropy configuration.
  24826. * @returns - An object with the serialized config.
  24827. */
  24828. serialize(): any;
  24829. /**
  24830. * Parses a anisotropy Configuration from a serialized object.
  24831. * @param source - Serialized object.
  24832. * @param scene Defines the scene we are parsing for
  24833. * @param rootUrl Defines the rootUrl to load from
  24834. */
  24835. parse(source: any, scene: Scene, rootUrl: string): void;
  24836. }
  24837. }
  24838. declare module BABYLON {
  24839. /**
  24840. * @hidden
  24841. */
  24842. export interface IMaterialBRDFDefines {
  24843. BRDF_V_HEIGHT_CORRELATED: boolean;
  24844. MS_BRDF_ENERGY_CONSERVATION: boolean;
  24845. SPHERICAL_HARMONICS: boolean;
  24846. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  24847. /** @hidden */
  24848. _areMiscDirty: boolean;
  24849. }
  24850. /**
  24851. * Define the code related to the BRDF parameters of the pbr material.
  24852. */
  24853. export class PBRBRDFConfiguration {
  24854. /**
  24855. * Default value used for the energy conservation.
  24856. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24857. */
  24858. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  24859. /**
  24860. * Default value used for the Smith Visibility Height Correlated mode.
  24861. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24862. */
  24863. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  24864. /**
  24865. * Default value used for the IBL diffuse part.
  24866. * This can help switching back to the polynomials mode globally which is a tiny bit
  24867. * less GPU intensive at the drawback of a lower quality.
  24868. */
  24869. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  24870. /**
  24871. * Default value used for activating energy conservation for the specular workflow.
  24872. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24873. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24874. */
  24875. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  24876. private _useEnergyConservation;
  24877. /**
  24878. * Defines if the material uses energy conservation.
  24879. */
  24880. useEnergyConservation: boolean;
  24881. private _useSmithVisibilityHeightCorrelated;
  24882. /**
  24883. * LEGACY Mode set to false
  24884. * Defines if the material uses height smith correlated visibility term.
  24885. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  24886. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  24887. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  24888. * Not relying on height correlated will also disable energy conservation.
  24889. */
  24890. useSmithVisibilityHeightCorrelated: boolean;
  24891. private _useSphericalHarmonics;
  24892. /**
  24893. * LEGACY Mode set to false
  24894. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  24895. * diffuse part of the IBL.
  24896. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  24897. * to the ground truth.
  24898. */
  24899. useSphericalHarmonics: boolean;
  24900. private _useSpecularGlossinessInputEnergyConservation;
  24901. /**
  24902. * Defines if the material uses energy conservation, when the specular workflow is active.
  24903. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24904. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24905. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  24906. */
  24907. useSpecularGlossinessInputEnergyConservation: boolean;
  24908. /** @hidden */
  24909. private _internalMarkAllSubMeshesAsMiscDirty;
  24910. /** @hidden */
  24911. _markAllSubMeshesAsMiscDirty(): void;
  24912. /**
  24913. * Instantiate a new istance of clear coat configuration.
  24914. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  24915. */
  24916. constructor(markAllSubMeshesAsMiscDirty: () => void);
  24917. /**
  24918. * Checks to see if a texture is used in the material.
  24919. * @param defines the list of "defines" to update.
  24920. */
  24921. prepareDefines(defines: IMaterialBRDFDefines): void;
  24922. /**
  24923. * Get the current class name of the texture useful for serialization or dynamic coding.
  24924. * @returns "PBRClearCoatConfiguration"
  24925. */
  24926. getClassName(): string;
  24927. /**
  24928. * Makes a duplicate of the current configuration into another one.
  24929. * @param brdfConfiguration define the config where to copy the info
  24930. */
  24931. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  24932. /**
  24933. * Serializes this BRDF configuration.
  24934. * @returns - An object with the serialized config.
  24935. */
  24936. serialize(): any;
  24937. /**
  24938. * Parses a anisotropy Configuration from a serialized object.
  24939. * @param source - Serialized object.
  24940. * @param scene Defines the scene we are parsing for
  24941. * @param rootUrl Defines the rootUrl to load from
  24942. */
  24943. parse(source: any, scene: Scene, rootUrl: string): void;
  24944. }
  24945. }
  24946. declare module BABYLON {
  24947. /**
  24948. * @hidden
  24949. */
  24950. export interface IMaterialSheenDefines {
  24951. SHEEN: boolean;
  24952. SHEEN_TEXTURE: boolean;
  24953. SHEEN_TEXTURE_ROUGHNESS: boolean;
  24954. SHEEN_TEXTUREDIRECTUV: number;
  24955. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  24956. SHEEN_LINKWITHALBEDO: boolean;
  24957. SHEEN_ROUGHNESS: boolean;
  24958. SHEEN_ALBEDOSCALING: boolean;
  24959. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24960. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24961. /** @hidden */
  24962. _areTexturesDirty: boolean;
  24963. }
  24964. /**
  24965. * Define the code related to the Sheen parameters of the pbr material.
  24966. */
  24967. export class PBRSheenConfiguration {
  24968. private _isEnabled;
  24969. /**
  24970. * Defines if the material uses sheen.
  24971. */
  24972. isEnabled: boolean;
  24973. private _linkSheenWithAlbedo;
  24974. /**
  24975. * Defines if the sheen is linked to the sheen color.
  24976. */
  24977. linkSheenWithAlbedo: boolean;
  24978. /**
  24979. * Defines the sheen intensity.
  24980. */
  24981. intensity: number;
  24982. /**
  24983. * Defines the sheen color.
  24984. */
  24985. color: Color3;
  24986. private _texture;
  24987. /**
  24988. * Stores the sheen tint values in a texture.
  24989. * rgb is tint
  24990. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  24991. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  24992. */
  24993. texture: Nullable<BaseTexture>;
  24994. private _useRoughnessFromMainTexture;
  24995. /**
  24996. * Indicates that the alpha channel of the texture property will be used for roughness.
  24997. * Has no effect if the roughness (and texture!) property is not defined
  24998. */
  24999. useRoughnessFromMainTexture: boolean;
  25000. private _roughness;
  25001. /**
  25002. * Defines the sheen roughness.
  25003. * It is not taken into account if linkSheenWithAlbedo is true.
  25004. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25005. */
  25006. roughness: Nullable<number>;
  25007. private _textureRoughness;
  25008. /**
  25009. * Stores the sheen roughness in a texture.
  25010. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25011. */
  25012. textureRoughness: Nullable<BaseTexture>;
  25013. private _albedoScaling;
  25014. /**
  25015. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25016. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25017. * making it easier to setup and tweak the effect
  25018. */
  25019. albedoScaling: boolean;
  25020. /** @hidden */
  25021. private _internalMarkAllSubMeshesAsTexturesDirty;
  25022. /** @hidden */
  25023. _markAllSubMeshesAsTexturesDirty(): void;
  25024. /**
  25025. * Instantiate a new istance of clear coat configuration.
  25026. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25027. */
  25028. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25029. /**
  25030. * Specifies that the submesh is ready to be used.
  25031. * @param defines the list of "defines" to update.
  25032. * @param scene defines the scene the material belongs to.
  25033. * @returns - boolean indicating that the submesh is ready or not.
  25034. */
  25035. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25036. /**
  25037. * Checks to see if a texture is used in the material.
  25038. * @param defines the list of "defines" to update.
  25039. * @param scene defines the scene the material belongs to.
  25040. */
  25041. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25042. /**
  25043. * Binds the material data.
  25044. * @param uniformBuffer defines the Uniform buffer to fill in.
  25045. * @param scene defines the scene the material belongs to.
  25046. * @param isFrozen defines wether the material is frozen or not.
  25047. * @param subMesh the submesh to bind data for
  25048. */
  25049. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25050. /**
  25051. * Checks to see if a texture is used in the material.
  25052. * @param texture - Base texture to use.
  25053. * @returns - Boolean specifying if a texture is used in the material.
  25054. */
  25055. hasTexture(texture: BaseTexture): boolean;
  25056. /**
  25057. * Returns an array of the actively used textures.
  25058. * @param activeTextures Array of BaseTextures
  25059. */
  25060. getActiveTextures(activeTextures: BaseTexture[]): void;
  25061. /**
  25062. * Returns the animatable textures.
  25063. * @param animatables Array of animatable textures.
  25064. */
  25065. getAnimatables(animatables: IAnimatable[]): void;
  25066. /**
  25067. * Disposes the resources of the material.
  25068. * @param forceDisposeTextures - Forces the disposal of all textures.
  25069. */
  25070. dispose(forceDisposeTextures?: boolean): void;
  25071. /**
  25072. * Get the current class name of the texture useful for serialization or dynamic coding.
  25073. * @returns "PBRSheenConfiguration"
  25074. */
  25075. getClassName(): string;
  25076. /**
  25077. * Add fallbacks to the effect fallbacks list.
  25078. * @param defines defines the Base texture to use.
  25079. * @param fallbacks defines the current fallback list.
  25080. * @param currentRank defines the current fallback rank.
  25081. * @returns the new fallback rank.
  25082. */
  25083. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25084. /**
  25085. * Add the required uniforms to the current list.
  25086. * @param uniforms defines the current uniform list.
  25087. */
  25088. static AddUniforms(uniforms: string[]): void;
  25089. /**
  25090. * Add the required uniforms to the current buffer.
  25091. * @param uniformBuffer defines the current uniform buffer.
  25092. */
  25093. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25094. /**
  25095. * Add the required samplers to the current list.
  25096. * @param samplers defines the current sampler list.
  25097. */
  25098. static AddSamplers(samplers: string[]): void;
  25099. /**
  25100. * Makes a duplicate of the current configuration into another one.
  25101. * @param sheenConfiguration define the config where to copy the info
  25102. */
  25103. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25104. /**
  25105. * Serializes this BRDF configuration.
  25106. * @returns - An object with the serialized config.
  25107. */
  25108. serialize(): any;
  25109. /**
  25110. * Parses a anisotropy Configuration from a serialized object.
  25111. * @param source - Serialized object.
  25112. * @param scene Defines the scene we are parsing for
  25113. * @param rootUrl Defines the rootUrl to load from
  25114. */
  25115. parse(source: any, scene: Scene, rootUrl: string): void;
  25116. }
  25117. }
  25118. declare module BABYLON {
  25119. /**
  25120. * @hidden
  25121. */
  25122. export interface IMaterialSubSurfaceDefines {
  25123. SUBSURFACE: boolean;
  25124. SS_REFRACTION: boolean;
  25125. SS_TRANSLUCENCY: boolean;
  25126. SS_SCATTERING: boolean;
  25127. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25128. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25129. SS_REFRACTIONMAP_3D: boolean;
  25130. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25131. SS_LODINREFRACTIONALPHA: boolean;
  25132. SS_GAMMAREFRACTION: boolean;
  25133. SS_RGBDREFRACTION: boolean;
  25134. SS_LINEARSPECULARREFRACTION: boolean;
  25135. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25136. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25137. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25138. /** @hidden */
  25139. _areTexturesDirty: boolean;
  25140. }
  25141. /**
  25142. * Define the code related to the sub surface parameters of the pbr material.
  25143. */
  25144. export class PBRSubSurfaceConfiguration {
  25145. private _isRefractionEnabled;
  25146. /**
  25147. * Defines if the refraction is enabled in the material.
  25148. */
  25149. isRefractionEnabled: boolean;
  25150. private _isTranslucencyEnabled;
  25151. /**
  25152. * Defines if the translucency is enabled in the material.
  25153. */
  25154. isTranslucencyEnabled: boolean;
  25155. private _isScatteringEnabled;
  25156. /**
  25157. * Defines if the sub surface scattering is enabled in the material.
  25158. */
  25159. isScatteringEnabled: boolean;
  25160. private _scatteringDiffusionProfileIndex;
  25161. /**
  25162. * Diffusion profile for subsurface scattering.
  25163. * Useful for better scattering in the skins or foliages.
  25164. */
  25165. get scatteringDiffusionProfile(): Nullable<Color3>;
  25166. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25167. /**
  25168. * Defines the refraction intensity of the material.
  25169. * The refraction when enabled replaces the Diffuse part of the material.
  25170. * The intensity helps transitionning between diffuse and refraction.
  25171. */
  25172. refractionIntensity: number;
  25173. /**
  25174. * Defines the translucency intensity of the material.
  25175. * When translucency has been enabled, this defines how much of the "translucency"
  25176. * is addded to the diffuse part of the material.
  25177. */
  25178. translucencyIntensity: number;
  25179. /**
  25180. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25181. */
  25182. useAlbedoToTintRefraction: boolean;
  25183. private _thicknessTexture;
  25184. /**
  25185. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25186. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25187. * 0 would mean minimumThickness
  25188. * 1 would mean maximumThickness
  25189. * The other channels might be use as a mask to vary the different effects intensity.
  25190. */
  25191. thicknessTexture: Nullable<BaseTexture>;
  25192. private _refractionTexture;
  25193. /**
  25194. * Defines the texture to use for refraction.
  25195. */
  25196. refractionTexture: Nullable<BaseTexture>;
  25197. private _indexOfRefraction;
  25198. /**
  25199. * Index of refraction of the material base layer.
  25200. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25201. *
  25202. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25203. *
  25204. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25205. */
  25206. indexOfRefraction: number;
  25207. private _volumeIndexOfRefraction;
  25208. /**
  25209. * Index of refraction of the material's volume.
  25210. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25211. *
  25212. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25213. * the volume will use the same IOR as the surface.
  25214. */
  25215. get volumeIndexOfRefraction(): number;
  25216. set volumeIndexOfRefraction(value: number);
  25217. private _invertRefractionY;
  25218. /**
  25219. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25220. */
  25221. invertRefractionY: boolean;
  25222. private _linkRefractionWithTransparency;
  25223. /**
  25224. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25225. * Materials half opaque for instance using refraction could benefit from this control.
  25226. */
  25227. linkRefractionWithTransparency: boolean;
  25228. /**
  25229. * Defines the minimum thickness stored in the thickness map.
  25230. * If no thickness map is defined, this value will be used to simulate thickness.
  25231. */
  25232. minimumThickness: number;
  25233. /**
  25234. * Defines the maximum thickness stored in the thickness map.
  25235. */
  25236. maximumThickness: number;
  25237. /**
  25238. * Defines the volume tint of the material.
  25239. * This is used for both translucency and scattering.
  25240. */
  25241. tintColor: Color3;
  25242. /**
  25243. * Defines the distance at which the tint color should be found in the media.
  25244. * This is used for refraction only.
  25245. */
  25246. tintColorAtDistance: number;
  25247. /**
  25248. * Defines how far each channel transmit through the media.
  25249. * It is defined as a color to simplify it selection.
  25250. */
  25251. diffusionDistance: Color3;
  25252. private _useMaskFromThicknessTexture;
  25253. /**
  25254. * Stores the intensity of the different subsurface effects in the thickness texture.
  25255. * * the green channel is the translucency intensity.
  25256. * * the blue channel is the scattering intensity.
  25257. * * the alpha channel is the refraction intensity.
  25258. */
  25259. useMaskFromThicknessTexture: boolean;
  25260. private _scene;
  25261. /** @hidden */
  25262. private _internalMarkAllSubMeshesAsTexturesDirty;
  25263. private _internalMarkScenePrePassDirty;
  25264. /** @hidden */
  25265. _markAllSubMeshesAsTexturesDirty(): void;
  25266. /** @hidden */
  25267. _markScenePrePassDirty(): void;
  25268. /**
  25269. * Instantiate a new istance of sub surface configuration.
  25270. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25271. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25272. * @param scene The scene
  25273. */
  25274. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25275. /**
  25276. * Gets wehter the submesh is ready to be used or not.
  25277. * @param defines the list of "defines" to update.
  25278. * @param scene defines the scene the material belongs to.
  25279. * @returns - boolean indicating that the submesh is ready or not.
  25280. */
  25281. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25282. /**
  25283. * Checks to see if a texture is used in the material.
  25284. * @param defines the list of "defines" to update.
  25285. * @param scene defines the scene to the material belongs to.
  25286. */
  25287. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25288. /**
  25289. * Binds the material data.
  25290. * @param uniformBuffer defines the Uniform buffer to fill in.
  25291. * @param scene defines the scene the material belongs to.
  25292. * @param engine defines the engine the material belongs to.
  25293. * @param isFrozen defines whether the material is frozen or not.
  25294. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25295. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25296. */
  25297. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25298. /**
  25299. * Unbinds the material from the mesh.
  25300. * @param activeEffect defines the effect that should be unbound from.
  25301. * @returns true if unbound, otherwise false
  25302. */
  25303. unbind(activeEffect: Effect): boolean;
  25304. /**
  25305. * Returns the texture used for refraction or null if none is used.
  25306. * @param scene defines the scene the material belongs to.
  25307. * @returns - Refraction texture if present. If no refraction texture and refraction
  25308. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25309. */
  25310. private _getRefractionTexture;
  25311. /**
  25312. * Returns true if alpha blending should be disabled.
  25313. */
  25314. get disableAlphaBlending(): boolean;
  25315. /**
  25316. * Fills the list of render target textures.
  25317. * @param renderTargets the list of render targets to update
  25318. */
  25319. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25320. /**
  25321. * Checks to see if a texture is used in the material.
  25322. * @param texture - Base texture to use.
  25323. * @returns - Boolean specifying if a texture is used in the material.
  25324. */
  25325. hasTexture(texture: BaseTexture): boolean;
  25326. /**
  25327. * Gets a boolean indicating that current material needs to register RTT
  25328. * @returns true if this uses a render target otherwise false.
  25329. */
  25330. hasRenderTargetTextures(): boolean;
  25331. /**
  25332. * Returns an array of the actively used textures.
  25333. * @param activeTextures Array of BaseTextures
  25334. */
  25335. getActiveTextures(activeTextures: BaseTexture[]): void;
  25336. /**
  25337. * Returns the animatable textures.
  25338. * @param animatables Array of animatable textures.
  25339. */
  25340. getAnimatables(animatables: IAnimatable[]): void;
  25341. /**
  25342. * Disposes the resources of the material.
  25343. * @param forceDisposeTextures - Forces the disposal of all textures.
  25344. */
  25345. dispose(forceDisposeTextures?: boolean): void;
  25346. /**
  25347. * Get the current class name of the texture useful for serialization or dynamic coding.
  25348. * @returns "PBRSubSurfaceConfiguration"
  25349. */
  25350. getClassName(): string;
  25351. /**
  25352. * Add fallbacks to the effect fallbacks list.
  25353. * @param defines defines the Base texture to use.
  25354. * @param fallbacks defines the current fallback list.
  25355. * @param currentRank defines the current fallback rank.
  25356. * @returns the new fallback rank.
  25357. */
  25358. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25359. /**
  25360. * Add the required uniforms to the current list.
  25361. * @param uniforms defines the current uniform list.
  25362. */
  25363. static AddUniforms(uniforms: string[]): void;
  25364. /**
  25365. * Add the required samplers to the current list.
  25366. * @param samplers defines the current sampler list.
  25367. */
  25368. static AddSamplers(samplers: string[]): void;
  25369. /**
  25370. * Add the required uniforms to the current buffer.
  25371. * @param uniformBuffer defines the current uniform buffer.
  25372. */
  25373. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25374. /**
  25375. * Makes a duplicate of the current configuration into another one.
  25376. * @param configuration define the config where to copy the info
  25377. */
  25378. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25379. /**
  25380. * Serializes this Sub Surface configuration.
  25381. * @returns - An object with the serialized config.
  25382. */
  25383. serialize(): any;
  25384. /**
  25385. * Parses a anisotropy Configuration from a serialized object.
  25386. * @param source - Serialized object.
  25387. * @param scene Defines the scene we are parsing for
  25388. * @param rootUrl Defines the rootUrl to load from
  25389. */
  25390. parse(source: any, scene: Scene, rootUrl: string): void;
  25391. }
  25392. }
  25393. declare module BABYLON {
  25394. /**
  25395. * Class representing spherical harmonics coefficients to the 3rd degree
  25396. */
  25397. export class SphericalHarmonics {
  25398. /**
  25399. * Defines whether or not the harmonics have been prescaled for rendering.
  25400. */
  25401. preScaled: boolean;
  25402. /**
  25403. * The l0,0 coefficients of the spherical harmonics
  25404. */
  25405. l00: Vector3;
  25406. /**
  25407. * The l1,-1 coefficients of the spherical harmonics
  25408. */
  25409. l1_1: Vector3;
  25410. /**
  25411. * The l1,0 coefficients of the spherical harmonics
  25412. */
  25413. l10: Vector3;
  25414. /**
  25415. * The l1,1 coefficients of the spherical harmonics
  25416. */
  25417. l11: Vector3;
  25418. /**
  25419. * The l2,-2 coefficients of the spherical harmonics
  25420. */
  25421. l2_2: Vector3;
  25422. /**
  25423. * The l2,-1 coefficients of the spherical harmonics
  25424. */
  25425. l2_1: Vector3;
  25426. /**
  25427. * The l2,0 coefficients of the spherical harmonics
  25428. */
  25429. l20: Vector3;
  25430. /**
  25431. * The l2,1 coefficients of the spherical harmonics
  25432. */
  25433. l21: Vector3;
  25434. /**
  25435. * The l2,2 coefficients of the spherical harmonics
  25436. */
  25437. l22: Vector3;
  25438. /**
  25439. * Adds a light to the spherical harmonics
  25440. * @param direction the direction of the light
  25441. * @param color the color of the light
  25442. * @param deltaSolidAngle the delta solid angle of the light
  25443. */
  25444. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25445. /**
  25446. * Scales the spherical harmonics by the given amount
  25447. * @param scale the amount to scale
  25448. */
  25449. scaleInPlace(scale: number): void;
  25450. /**
  25451. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25452. *
  25453. * ```
  25454. * E_lm = A_l * L_lm
  25455. * ```
  25456. *
  25457. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25458. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25459. * the scaling factors are given in equation 9.
  25460. */
  25461. convertIncidentRadianceToIrradiance(): void;
  25462. /**
  25463. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25464. *
  25465. * ```
  25466. * L = (1/pi) * E * rho
  25467. * ```
  25468. *
  25469. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25470. */
  25471. convertIrradianceToLambertianRadiance(): void;
  25472. /**
  25473. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25474. * required operations at run time.
  25475. *
  25476. * This is simply done by scaling back the SH with Ylm constants parameter.
  25477. * The trigonometric part being applied by the shader at run time.
  25478. */
  25479. preScaleForRendering(): void;
  25480. /**
  25481. * Constructs a spherical harmonics from an array.
  25482. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25483. * @returns the spherical harmonics
  25484. */
  25485. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25486. /**
  25487. * Gets the spherical harmonics from polynomial
  25488. * @param polynomial the spherical polynomial
  25489. * @returns the spherical harmonics
  25490. */
  25491. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25492. }
  25493. /**
  25494. * Class representing spherical polynomial coefficients to the 3rd degree
  25495. */
  25496. export class SphericalPolynomial {
  25497. private _harmonics;
  25498. /**
  25499. * The spherical harmonics used to create the polynomials.
  25500. */
  25501. get preScaledHarmonics(): SphericalHarmonics;
  25502. /**
  25503. * The x coefficients of the spherical polynomial
  25504. */
  25505. x: Vector3;
  25506. /**
  25507. * The y coefficients of the spherical polynomial
  25508. */
  25509. y: Vector3;
  25510. /**
  25511. * The z coefficients of the spherical polynomial
  25512. */
  25513. z: Vector3;
  25514. /**
  25515. * The xx coefficients of the spherical polynomial
  25516. */
  25517. xx: Vector3;
  25518. /**
  25519. * The yy coefficients of the spherical polynomial
  25520. */
  25521. yy: Vector3;
  25522. /**
  25523. * The zz coefficients of the spherical polynomial
  25524. */
  25525. zz: Vector3;
  25526. /**
  25527. * The xy coefficients of the spherical polynomial
  25528. */
  25529. xy: Vector3;
  25530. /**
  25531. * The yz coefficients of the spherical polynomial
  25532. */
  25533. yz: Vector3;
  25534. /**
  25535. * The zx coefficients of the spherical polynomial
  25536. */
  25537. zx: Vector3;
  25538. /**
  25539. * Adds an ambient color to the spherical polynomial
  25540. * @param color the color to add
  25541. */
  25542. addAmbient(color: Color3): void;
  25543. /**
  25544. * Scales the spherical polynomial by the given amount
  25545. * @param scale the amount to scale
  25546. */
  25547. scaleInPlace(scale: number): void;
  25548. /**
  25549. * Gets the spherical polynomial from harmonics
  25550. * @param harmonics the spherical harmonics
  25551. * @returns the spherical polynomial
  25552. */
  25553. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25554. /**
  25555. * Constructs a spherical polynomial from an array.
  25556. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25557. * @returns the spherical polynomial
  25558. */
  25559. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25560. }
  25561. }
  25562. declare module BABYLON {
  25563. /**
  25564. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25565. */
  25566. export interface CubeMapInfo {
  25567. /**
  25568. * The pixel array for the front face.
  25569. * This is stored in format, left to right, up to down format.
  25570. */
  25571. front: Nullable<ArrayBufferView>;
  25572. /**
  25573. * The pixel array for the back face.
  25574. * This is stored in format, left to right, up to down format.
  25575. */
  25576. back: Nullable<ArrayBufferView>;
  25577. /**
  25578. * The pixel array for the left face.
  25579. * This is stored in format, left to right, up to down format.
  25580. */
  25581. left: Nullable<ArrayBufferView>;
  25582. /**
  25583. * The pixel array for the right face.
  25584. * This is stored in format, left to right, up to down format.
  25585. */
  25586. right: Nullable<ArrayBufferView>;
  25587. /**
  25588. * The pixel array for the up face.
  25589. * This is stored in format, left to right, up to down format.
  25590. */
  25591. up: Nullable<ArrayBufferView>;
  25592. /**
  25593. * The pixel array for the down face.
  25594. * This is stored in format, left to right, up to down format.
  25595. */
  25596. down: Nullable<ArrayBufferView>;
  25597. /**
  25598. * The size of the cubemap stored.
  25599. *
  25600. * Each faces will be size * size pixels.
  25601. */
  25602. size: number;
  25603. /**
  25604. * The format of the texture.
  25605. *
  25606. * RGBA, RGB.
  25607. */
  25608. format: number;
  25609. /**
  25610. * The type of the texture data.
  25611. *
  25612. * UNSIGNED_INT, FLOAT.
  25613. */
  25614. type: number;
  25615. /**
  25616. * Specifies whether the texture is in gamma space.
  25617. */
  25618. gammaSpace: boolean;
  25619. }
  25620. /**
  25621. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25622. */
  25623. export class PanoramaToCubeMapTools {
  25624. private static FACE_LEFT;
  25625. private static FACE_RIGHT;
  25626. private static FACE_FRONT;
  25627. private static FACE_BACK;
  25628. private static FACE_DOWN;
  25629. private static FACE_UP;
  25630. /**
  25631. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25632. *
  25633. * @param float32Array The source data.
  25634. * @param inputWidth The width of the input panorama.
  25635. * @param inputHeight The height of the input panorama.
  25636. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25637. * @return The cubemap data
  25638. */
  25639. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25640. private static CreateCubemapTexture;
  25641. private static CalcProjectionSpherical;
  25642. }
  25643. }
  25644. declare module BABYLON {
  25645. /**
  25646. * Helper class dealing with the extraction of spherical polynomial dataArray
  25647. * from a cube map.
  25648. */
  25649. export class CubeMapToSphericalPolynomialTools {
  25650. private static FileFaces;
  25651. /**
  25652. * Converts a texture to the according Spherical Polynomial data.
  25653. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25654. *
  25655. * @param texture The texture to extract the information from.
  25656. * @return The Spherical Polynomial data.
  25657. */
  25658. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25659. /**
  25660. * Converts a cubemap to the according Spherical Polynomial data.
  25661. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25662. *
  25663. * @param cubeInfo The Cube map to extract the information from.
  25664. * @return The Spherical Polynomial data.
  25665. */
  25666. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25667. }
  25668. }
  25669. declare module BABYLON {
  25670. interface BaseTexture {
  25671. /**
  25672. * Get the polynomial representation of the texture data.
  25673. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25674. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25675. */
  25676. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25677. }
  25678. }
  25679. declare module BABYLON {
  25680. /** @hidden */
  25681. export var pbrFragmentDeclaration: {
  25682. name: string;
  25683. shader: string;
  25684. };
  25685. }
  25686. declare module BABYLON {
  25687. /** @hidden */
  25688. export var pbrUboDeclaration: {
  25689. name: string;
  25690. shader: string;
  25691. };
  25692. }
  25693. declare module BABYLON {
  25694. /** @hidden */
  25695. export var pbrFragmentExtraDeclaration: {
  25696. name: string;
  25697. shader: string;
  25698. };
  25699. }
  25700. declare module BABYLON {
  25701. /** @hidden */
  25702. export var pbrFragmentSamplersDeclaration: {
  25703. name: string;
  25704. shader: string;
  25705. };
  25706. }
  25707. declare module BABYLON {
  25708. /** @hidden */
  25709. export var subSurfaceScatteringFunctions: {
  25710. name: string;
  25711. shader: string;
  25712. };
  25713. }
  25714. declare module BABYLON {
  25715. /** @hidden */
  25716. export var importanceSampling: {
  25717. name: string;
  25718. shader: string;
  25719. };
  25720. }
  25721. declare module BABYLON {
  25722. /** @hidden */
  25723. export var pbrHelperFunctions: {
  25724. name: string;
  25725. shader: string;
  25726. };
  25727. }
  25728. declare module BABYLON {
  25729. /** @hidden */
  25730. export var harmonicsFunctions: {
  25731. name: string;
  25732. shader: string;
  25733. };
  25734. }
  25735. declare module BABYLON {
  25736. /** @hidden */
  25737. export var pbrDirectLightingSetupFunctions: {
  25738. name: string;
  25739. shader: string;
  25740. };
  25741. }
  25742. declare module BABYLON {
  25743. /** @hidden */
  25744. export var pbrDirectLightingFalloffFunctions: {
  25745. name: string;
  25746. shader: string;
  25747. };
  25748. }
  25749. declare module BABYLON {
  25750. /** @hidden */
  25751. export var pbrBRDFFunctions: {
  25752. name: string;
  25753. shader: string;
  25754. };
  25755. }
  25756. declare module BABYLON {
  25757. /** @hidden */
  25758. export var hdrFilteringFunctions: {
  25759. name: string;
  25760. shader: string;
  25761. };
  25762. }
  25763. declare module BABYLON {
  25764. /** @hidden */
  25765. export var pbrDirectLightingFunctions: {
  25766. name: string;
  25767. shader: string;
  25768. };
  25769. }
  25770. declare module BABYLON {
  25771. /** @hidden */
  25772. export var pbrIBLFunctions: {
  25773. name: string;
  25774. shader: string;
  25775. };
  25776. }
  25777. declare module BABYLON {
  25778. /** @hidden */
  25779. export var pbrBlockAlbedoOpacity: {
  25780. name: string;
  25781. shader: string;
  25782. };
  25783. }
  25784. declare module BABYLON {
  25785. /** @hidden */
  25786. export var pbrBlockReflectivity: {
  25787. name: string;
  25788. shader: string;
  25789. };
  25790. }
  25791. declare module BABYLON {
  25792. /** @hidden */
  25793. export var pbrBlockAmbientOcclusion: {
  25794. name: string;
  25795. shader: string;
  25796. };
  25797. }
  25798. declare module BABYLON {
  25799. /** @hidden */
  25800. export var pbrBlockAlphaFresnel: {
  25801. name: string;
  25802. shader: string;
  25803. };
  25804. }
  25805. declare module BABYLON {
  25806. /** @hidden */
  25807. export var pbrBlockAnisotropic: {
  25808. name: string;
  25809. shader: string;
  25810. };
  25811. }
  25812. declare module BABYLON {
  25813. /** @hidden */
  25814. export var pbrBlockReflection: {
  25815. name: string;
  25816. shader: string;
  25817. };
  25818. }
  25819. declare module BABYLON {
  25820. /** @hidden */
  25821. export var pbrBlockSheen: {
  25822. name: string;
  25823. shader: string;
  25824. };
  25825. }
  25826. declare module BABYLON {
  25827. /** @hidden */
  25828. export var pbrBlockClearcoat: {
  25829. name: string;
  25830. shader: string;
  25831. };
  25832. }
  25833. declare module BABYLON {
  25834. /** @hidden */
  25835. export var pbrBlockSubSurface: {
  25836. name: string;
  25837. shader: string;
  25838. };
  25839. }
  25840. declare module BABYLON {
  25841. /** @hidden */
  25842. export var pbrBlockNormalGeometric: {
  25843. name: string;
  25844. shader: string;
  25845. };
  25846. }
  25847. declare module BABYLON {
  25848. /** @hidden */
  25849. export var pbrBlockNormalFinal: {
  25850. name: string;
  25851. shader: string;
  25852. };
  25853. }
  25854. declare module BABYLON {
  25855. /** @hidden */
  25856. export var pbrBlockLightmapInit: {
  25857. name: string;
  25858. shader: string;
  25859. };
  25860. }
  25861. declare module BABYLON {
  25862. /** @hidden */
  25863. export var pbrBlockGeometryInfo: {
  25864. name: string;
  25865. shader: string;
  25866. };
  25867. }
  25868. declare module BABYLON {
  25869. /** @hidden */
  25870. export var pbrBlockReflectance0: {
  25871. name: string;
  25872. shader: string;
  25873. };
  25874. }
  25875. declare module BABYLON {
  25876. /** @hidden */
  25877. export var pbrBlockReflectance: {
  25878. name: string;
  25879. shader: string;
  25880. };
  25881. }
  25882. declare module BABYLON {
  25883. /** @hidden */
  25884. export var pbrBlockDirectLighting: {
  25885. name: string;
  25886. shader: string;
  25887. };
  25888. }
  25889. declare module BABYLON {
  25890. /** @hidden */
  25891. export var pbrBlockFinalLitComponents: {
  25892. name: string;
  25893. shader: string;
  25894. };
  25895. }
  25896. declare module BABYLON {
  25897. /** @hidden */
  25898. export var pbrBlockFinalUnlitComponents: {
  25899. name: string;
  25900. shader: string;
  25901. };
  25902. }
  25903. declare module BABYLON {
  25904. /** @hidden */
  25905. export var pbrBlockFinalColorComposition: {
  25906. name: string;
  25907. shader: string;
  25908. };
  25909. }
  25910. declare module BABYLON {
  25911. /** @hidden */
  25912. export var pbrBlockImageProcessing: {
  25913. name: string;
  25914. shader: string;
  25915. };
  25916. }
  25917. declare module BABYLON {
  25918. /** @hidden */
  25919. export var pbrDebug: {
  25920. name: string;
  25921. shader: string;
  25922. };
  25923. }
  25924. declare module BABYLON {
  25925. /** @hidden */
  25926. export var pbrPixelShader: {
  25927. name: string;
  25928. shader: string;
  25929. };
  25930. }
  25931. declare module BABYLON {
  25932. /** @hidden */
  25933. export var pbrVertexDeclaration: {
  25934. name: string;
  25935. shader: string;
  25936. };
  25937. }
  25938. declare module BABYLON {
  25939. /** @hidden */
  25940. export var pbrVertexShader: {
  25941. name: string;
  25942. shader: string;
  25943. };
  25944. }
  25945. declare module BABYLON {
  25946. /**
  25947. * Manages the defines for the PBR Material.
  25948. * @hidden
  25949. */
  25950. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  25951. PBR: boolean;
  25952. NUM_SAMPLES: string;
  25953. REALTIME_FILTERING: boolean;
  25954. MAINUV1: boolean;
  25955. MAINUV2: boolean;
  25956. UV1: boolean;
  25957. UV2: boolean;
  25958. ALBEDO: boolean;
  25959. GAMMAALBEDO: boolean;
  25960. ALBEDODIRECTUV: number;
  25961. VERTEXCOLOR: boolean;
  25962. DETAIL: boolean;
  25963. DETAILDIRECTUV: number;
  25964. DETAIL_NORMALBLENDMETHOD: number;
  25965. AMBIENT: boolean;
  25966. AMBIENTDIRECTUV: number;
  25967. AMBIENTINGRAYSCALE: boolean;
  25968. OPACITY: boolean;
  25969. VERTEXALPHA: boolean;
  25970. OPACITYDIRECTUV: number;
  25971. OPACITYRGB: boolean;
  25972. ALPHATEST: boolean;
  25973. DEPTHPREPASS: boolean;
  25974. ALPHABLEND: boolean;
  25975. ALPHAFROMALBEDO: boolean;
  25976. ALPHATESTVALUE: string;
  25977. SPECULAROVERALPHA: boolean;
  25978. RADIANCEOVERALPHA: boolean;
  25979. ALPHAFRESNEL: boolean;
  25980. LINEARALPHAFRESNEL: boolean;
  25981. PREMULTIPLYALPHA: boolean;
  25982. EMISSIVE: boolean;
  25983. EMISSIVEDIRECTUV: number;
  25984. REFLECTIVITY: boolean;
  25985. REFLECTIVITYDIRECTUV: number;
  25986. SPECULARTERM: boolean;
  25987. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  25988. MICROSURFACEAUTOMATIC: boolean;
  25989. LODBASEDMICROSFURACE: boolean;
  25990. MICROSURFACEMAP: boolean;
  25991. MICROSURFACEMAPDIRECTUV: number;
  25992. METALLICWORKFLOW: boolean;
  25993. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  25994. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  25995. METALLNESSSTOREINMETALMAPBLUE: boolean;
  25996. AOSTOREINMETALMAPRED: boolean;
  25997. METALLIC_REFLECTANCE: boolean;
  25998. METALLIC_REFLECTANCEDIRECTUV: number;
  25999. ENVIRONMENTBRDF: boolean;
  26000. ENVIRONMENTBRDF_RGBD: boolean;
  26001. NORMAL: boolean;
  26002. TANGENT: boolean;
  26003. BUMP: boolean;
  26004. BUMPDIRECTUV: number;
  26005. OBJECTSPACE_NORMALMAP: boolean;
  26006. PARALLAX: boolean;
  26007. PARALLAXOCCLUSION: boolean;
  26008. NORMALXYSCALE: boolean;
  26009. LIGHTMAP: boolean;
  26010. LIGHTMAPDIRECTUV: number;
  26011. USELIGHTMAPASSHADOWMAP: boolean;
  26012. GAMMALIGHTMAP: boolean;
  26013. RGBDLIGHTMAP: boolean;
  26014. REFLECTION: boolean;
  26015. REFLECTIONMAP_3D: boolean;
  26016. REFLECTIONMAP_SPHERICAL: boolean;
  26017. REFLECTIONMAP_PLANAR: boolean;
  26018. REFLECTIONMAP_CUBIC: boolean;
  26019. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26020. REFLECTIONMAP_PROJECTION: boolean;
  26021. REFLECTIONMAP_SKYBOX: boolean;
  26022. REFLECTIONMAP_EXPLICIT: boolean;
  26023. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26024. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26025. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26026. INVERTCUBICMAP: boolean;
  26027. USESPHERICALFROMREFLECTIONMAP: boolean;
  26028. USEIRRADIANCEMAP: boolean;
  26029. SPHERICAL_HARMONICS: boolean;
  26030. USESPHERICALINVERTEX: boolean;
  26031. REFLECTIONMAP_OPPOSITEZ: boolean;
  26032. LODINREFLECTIONALPHA: boolean;
  26033. GAMMAREFLECTION: boolean;
  26034. RGBDREFLECTION: boolean;
  26035. LINEARSPECULARREFLECTION: boolean;
  26036. RADIANCEOCCLUSION: boolean;
  26037. HORIZONOCCLUSION: boolean;
  26038. INSTANCES: boolean;
  26039. THIN_INSTANCES: boolean;
  26040. PREPASS: boolean;
  26041. PREPASS_IRRADIANCE: boolean;
  26042. PREPASS_IRRADIANCE_INDEX: number;
  26043. PREPASS_ALBEDO: boolean;
  26044. PREPASS_ALBEDO_INDEX: number;
  26045. PREPASS_DEPTHNORMAL: boolean;
  26046. PREPASS_DEPTHNORMAL_INDEX: number;
  26047. PREPASS_POSITION: boolean;
  26048. PREPASS_POSITION_INDEX: number;
  26049. PREPASS_VELOCITY: boolean;
  26050. PREPASS_VELOCITY_INDEX: number;
  26051. PREPASS_REFLECTIVITY: boolean;
  26052. PREPASS_REFLECTIVITY_INDEX: number;
  26053. SCENE_MRT_COUNT: number;
  26054. NUM_BONE_INFLUENCERS: number;
  26055. BonesPerMesh: number;
  26056. BONETEXTURE: boolean;
  26057. BONES_VELOCITY_ENABLED: boolean;
  26058. NONUNIFORMSCALING: boolean;
  26059. MORPHTARGETS: boolean;
  26060. MORPHTARGETS_NORMAL: boolean;
  26061. MORPHTARGETS_TANGENT: boolean;
  26062. MORPHTARGETS_UV: boolean;
  26063. NUM_MORPH_INFLUENCERS: number;
  26064. IMAGEPROCESSING: boolean;
  26065. VIGNETTE: boolean;
  26066. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26067. VIGNETTEBLENDMODEOPAQUE: boolean;
  26068. TONEMAPPING: boolean;
  26069. TONEMAPPING_ACES: boolean;
  26070. CONTRAST: boolean;
  26071. COLORCURVES: boolean;
  26072. COLORGRADING: boolean;
  26073. COLORGRADING3D: boolean;
  26074. SAMPLER3DGREENDEPTH: boolean;
  26075. SAMPLER3DBGRMAP: boolean;
  26076. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26077. EXPOSURE: boolean;
  26078. MULTIVIEW: boolean;
  26079. USEPHYSICALLIGHTFALLOFF: boolean;
  26080. USEGLTFLIGHTFALLOFF: boolean;
  26081. TWOSIDEDLIGHTING: boolean;
  26082. SHADOWFLOAT: boolean;
  26083. CLIPPLANE: boolean;
  26084. CLIPPLANE2: boolean;
  26085. CLIPPLANE3: boolean;
  26086. CLIPPLANE4: boolean;
  26087. CLIPPLANE5: boolean;
  26088. CLIPPLANE6: boolean;
  26089. POINTSIZE: boolean;
  26090. FOG: boolean;
  26091. LOGARITHMICDEPTH: boolean;
  26092. FORCENORMALFORWARD: boolean;
  26093. SPECULARAA: boolean;
  26094. CLEARCOAT: boolean;
  26095. CLEARCOAT_DEFAULTIOR: boolean;
  26096. CLEARCOAT_TEXTURE: boolean;
  26097. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  26098. CLEARCOAT_TEXTUREDIRECTUV: number;
  26099. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  26100. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26101. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26102. CLEARCOAT_BUMP: boolean;
  26103. CLEARCOAT_BUMPDIRECTUV: number;
  26104. CLEARCOAT_REMAP_F0: boolean;
  26105. CLEARCOAT_TINT: boolean;
  26106. CLEARCOAT_TINT_TEXTURE: boolean;
  26107. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26108. ANISOTROPIC: boolean;
  26109. ANISOTROPIC_TEXTURE: boolean;
  26110. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26111. BRDF_V_HEIGHT_CORRELATED: boolean;
  26112. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26113. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26114. SHEEN: boolean;
  26115. SHEEN_TEXTURE: boolean;
  26116. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26117. SHEEN_TEXTUREDIRECTUV: number;
  26118. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26119. SHEEN_LINKWITHALBEDO: boolean;
  26120. SHEEN_ROUGHNESS: boolean;
  26121. SHEEN_ALBEDOSCALING: boolean;
  26122. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26123. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26124. SUBSURFACE: boolean;
  26125. SS_REFRACTION: boolean;
  26126. SS_TRANSLUCENCY: boolean;
  26127. SS_SCATTERING: boolean;
  26128. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26129. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26130. SS_REFRACTIONMAP_3D: boolean;
  26131. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26132. SS_LODINREFRACTIONALPHA: boolean;
  26133. SS_GAMMAREFRACTION: boolean;
  26134. SS_RGBDREFRACTION: boolean;
  26135. SS_LINEARSPECULARREFRACTION: boolean;
  26136. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26137. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26138. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26139. UNLIT: boolean;
  26140. DEBUGMODE: number;
  26141. /**
  26142. * Initializes the PBR Material defines.
  26143. */
  26144. constructor();
  26145. /**
  26146. * Resets the PBR Material defines.
  26147. */
  26148. reset(): void;
  26149. }
  26150. /**
  26151. * The Physically based material base class of BJS.
  26152. *
  26153. * This offers the main features of a standard PBR material.
  26154. * For more information, please refer to the documentation :
  26155. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26156. */
  26157. export abstract class PBRBaseMaterial extends PushMaterial {
  26158. /**
  26159. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26160. */
  26161. static readonly PBRMATERIAL_OPAQUE: number;
  26162. /**
  26163. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26164. */
  26165. static readonly PBRMATERIAL_ALPHATEST: number;
  26166. /**
  26167. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26168. */
  26169. static readonly PBRMATERIAL_ALPHABLEND: number;
  26170. /**
  26171. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26172. * They are also discarded below the alpha cutoff threshold to improve performances.
  26173. */
  26174. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26175. /**
  26176. * Defines the default value of how much AO map is occluding the analytical lights
  26177. * (point spot...).
  26178. */
  26179. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26180. /**
  26181. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26182. */
  26183. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26184. /**
  26185. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26186. * to enhance interoperability with other engines.
  26187. */
  26188. static readonly LIGHTFALLOFF_GLTF: number;
  26189. /**
  26190. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26191. * to enhance interoperability with other materials.
  26192. */
  26193. static readonly LIGHTFALLOFF_STANDARD: number;
  26194. /**
  26195. * Intensity of the direct lights e.g. the four lights available in your scene.
  26196. * This impacts both the direct diffuse and specular highlights.
  26197. */
  26198. protected _directIntensity: number;
  26199. /**
  26200. * Intensity of the emissive part of the material.
  26201. * This helps controlling the emissive effect without modifying the emissive color.
  26202. */
  26203. protected _emissiveIntensity: number;
  26204. /**
  26205. * Intensity of the environment e.g. how much the environment will light the object
  26206. * either through harmonics for rough material or through the refelction for shiny ones.
  26207. */
  26208. protected _environmentIntensity: number;
  26209. /**
  26210. * This is a special control allowing the reduction of the specular highlights coming from the
  26211. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26212. */
  26213. protected _specularIntensity: number;
  26214. /**
  26215. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26216. */
  26217. private _lightingInfos;
  26218. /**
  26219. * Debug Control allowing disabling the bump map on this material.
  26220. */
  26221. protected _disableBumpMap: boolean;
  26222. /**
  26223. * AKA Diffuse Texture in standard nomenclature.
  26224. */
  26225. protected _albedoTexture: Nullable<BaseTexture>;
  26226. /**
  26227. * AKA Occlusion Texture in other nomenclature.
  26228. */
  26229. protected _ambientTexture: Nullable<BaseTexture>;
  26230. /**
  26231. * AKA Occlusion Texture Intensity in other nomenclature.
  26232. */
  26233. protected _ambientTextureStrength: number;
  26234. /**
  26235. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26236. * 1 means it completely occludes it
  26237. * 0 mean it has no impact
  26238. */
  26239. protected _ambientTextureImpactOnAnalyticalLights: number;
  26240. /**
  26241. * Stores the alpha values in a texture.
  26242. */
  26243. protected _opacityTexture: Nullable<BaseTexture>;
  26244. /**
  26245. * Stores the reflection values in a texture.
  26246. */
  26247. protected _reflectionTexture: Nullable<BaseTexture>;
  26248. /**
  26249. * Stores the emissive values in a texture.
  26250. */
  26251. protected _emissiveTexture: Nullable<BaseTexture>;
  26252. /**
  26253. * AKA Specular texture in other nomenclature.
  26254. */
  26255. protected _reflectivityTexture: Nullable<BaseTexture>;
  26256. /**
  26257. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26258. */
  26259. protected _metallicTexture: Nullable<BaseTexture>;
  26260. /**
  26261. * Specifies the metallic scalar of the metallic/roughness workflow.
  26262. * Can also be used to scale the metalness values of the metallic texture.
  26263. */
  26264. protected _metallic: Nullable<number>;
  26265. /**
  26266. * Specifies the roughness scalar of the metallic/roughness workflow.
  26267. * Can also be used to scale the roughness values of the metallic texture.
  26268. */
  26269. protected _roughness: Nullable<number>;
  26270. /**
  26271. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26272. * By default the indexOfrefraction is used to compute F0;
  26273. *
  26274. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26275. *
  26276. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26277. * F90 = metallicReflectanceColor;
  26278. */
  26279. protected _metallicF0Factor: number;
  26280. /**
  26281. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26282. * By default the F90 is always 1;
  26283. *
  26284. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26285. *
  26286. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26287. * F90 = metallicReflectanceColor;
  26288. */
  26289. protected _metallicReflectanceColor: Color3;
  26290. /**
  26291. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26292. * This is multiply against the scalar values defined in the material.
  26293. */
  26294. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26295. /**
  26296. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26297. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26298. */
  26299. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26300. /**
  26301. * Stores surface normal data used to displace a mesh in a texture.
  26302. */
  26303. protected _bumpTexture: Nullable<BaseTexture>;
  26304. /**
  26305. * Stores the pre-calculated light information of a mesh in a texture.
  26306. */
  26307. protected _lightmapTexture: Nullable<BaseTexture>;
  26308. /**
  26309. * The color of a material in ambient lighting.
  26310. */
  26311. protected _ambientColor: Color3;
  26312. /**
  26313. * AKA Diffuse Color in other nomenclature.
  26314. */
  26315. protected _albedoColor: Color3;
  26316. /**
  26317. * AKA Specular Color in other nomenclature.
  26318. */
  26319. protected _reflectivityColor: Color3;
  26320. /**
  26321. * The color applied when light is reflected from a material.
  26322. */
  26323. protected _reflectionColor: Color3;
  26324. /**
  26325. * The color applied when light is emitted from a material.
  26326. */
  26327. protected _emissiveColor: Color3;
  26328. /**
  26329. * AKA Glossiness in other nomenclature.
  26330. */
  26331. protected _microSurface: number;
  26332. /**
  26333. * Specifies that the material will use the light map as a show map.
  26334. */
  26335. protected _useLightmapAsShadowmap: boolean;
  26336. /**
  26337. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26338. * makes the reflect vector face the model (under horizon).
  26339. */
  26340. protected _useHorizonOcclusion: boolean;
  26341. /**
  26342. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26343. * too much the area relying on ambient texture to define their ambient occlusion.
  26344. */
  26345. protected _useRadianceOcclusion: boolean;
  26346. /**
  26347. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26348. */
  26349. protected _useAlphaFromAlbedoTexture: boolean;
  26350. /**
  26351. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26352. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26353. */
  26354. protected _useSpecularOverAlpha: boolean;
  26355. /**
  26356. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26357. */
  26358. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26359. /**
  26360. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26361. */
  26362. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26363. /**
  26364. * Specifies if the metallic texture contains the roughness information in its green channel.
  26365. */
  26366. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26367. /**
  26368. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26369. */
  26370. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26371. /**
  26372. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26373. */
  26374. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26375. /**
  26376. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26377. */
  26378. protected _useAmbientInGrayScale: boolean;
  26379. /**
  26380. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26381. * The material will try to infer what glossiness each pixel should be.
  26382. */
  26383. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26384. /**
  26385. * Defines the falloff type used in this material.
  26386. * It by default is Physical.
  26387. */
  26388. protected _lightFalloff: number;
  26389. /**
  26390. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26391. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26392. */
  26393. protected _useRadianceOverAlpha: boolean;
  26394. /**
  26395. * Allows using an object space normal map (instead of tangent space).
  26396. */
  26397. protected _useObjectSpaceNormalMap: boolean;
  26398. /**
  26399. * Allows using the bump map in parallax mode.
  26400. */
  26401. protected _useParallax: boolean;
  26402. /**
  26403. * Allows using the bump map in parallax occlusion mode.
  26404. */
  26405. protected _useParallaxOcclusion: boolean;
  26406. /**
  26407. * Controls the scale bias of the parallax mode.
  26408. */
  26409. protected _parallaxScaleBias: number;
  26410. /**
  26411. * If sets to true, disables all the lights affecting the material.
  26412. */
  26413. protected _disableLighting: boolean;
  26414. /**
  26415. * Number of Simultaneous lights allowed on the material.
  26416. */
  26417. protected _maxSimultaneousLights: number;
  26418. /**
  26419. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26420. */
  26421. protected _invertNormalMapX: boolean;
  26422. /**
  26423. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26424. */
  26425. protected _invertNormalMapY: boolean;
  26426. /**
  26427. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26428. */
  26429. protected _twoSidedLighting: boolean;
  26430. /**
  26431. * Defines the alpha limits in alpha test mode.
  26432. */
  26433. protected _alphaCutOff: number;
  26434. /**
  26435. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26436. */
  26437. protected _forceAlphaTest: boolean;
  26438. /**
  26439. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26440. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26441. */
  26442. protected _useAlphaFresnel: boolean;
  26443. /**
  26444. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26445. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26446. */
  26447. protected _useLinearAlphaFresnel: boolean;
  26448. /**
  26449. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26450. * from cos thetav and roughness:
  26451. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26452. */
  26453. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26454. /**
  26455. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26456. */
  26457. protected _forceIrradianceInFragment: boolean;
  26458. private _realTimeFiltering;
  26459. /**
  26460. * Enables realtime filtering on the texture.
  26461. */
  26462. get realTimeFiltering(): boolean;
  26463. set realTimeFiltering(b: boolean);
  26464. private _realTimeFilteringQuality;
  26465. /**
  26466. * Quality switch for realtime filtering
  26467. */
  26468. get realTimeFilteringQuality(): number;
  26469. set realTimeFilteringQuality(n: number);
  26470. /**
  26471. * Can this material render to several textures at once
  26472. */
  26473. get canRenderToMRT(): boolean;
  26474. /**
  26475. * Force normal to face away from face.
  26476. */
  26477. protected _forceNormalForward: boolean;
  26478. /**
  26479. * Enables specular anti aliasing in the PBR shader.
  26480. * It will both interacts on the Geometry for analytical and IBL lighting.
  26481. * It also prefilter the roughness map based on the bump values.
  26482. */
  26483. protected _enableSpecularAntiAliasing: boolean;
  26484. /**
  26485. * Default configuration related to image processing available in the PBR Material.
  26486. */
  26487. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26488. /**
  26489. * Keep track of the image processing observer to allow dispose and replace.
  26490. */
  26491. private _imageProcessingObserver;
  26492. /**
  26493. * Attaches a new image processing configuration to the PBR Material.
  26494. * @param configuration
  26495. */
  26496. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26497. /**
  26498. * Stores the available render targets.
  26499. */
  26500. private _renderTargets;
  26501. /**
  26502. * Sets the global ambient color for the material used in lighting calculations.
  26503. */
  26504. private _globalAmbientColor;
  26505. /**
  26506. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26507. */
  26508. private _useLogarithmicDepth;
  26509. /**
  26510. * If set to true, no lighting calculations will be applied.
  26511. */
  26512. private _unlit;
  26513. private _debugMode;
  26514. /**
  26515. * @hidden
  26516. * This is reserved for the inspector.
  26517. * Defines the material debug mode.
  26518. * It helps seeing only some components of the material while troubleshooting.
  26519. */
  26520. debugMode: number;
  26521. /**
  26522. * @hidden
  26523. * This is reserved for the inspector.
  26524. * Specify from where on screen the debug mode should start.
  26525. * The value goes from -1 (full screen) to 1 (not visible)
  26526. * It helps with side by side comparison against the final render
  26527. * This defaults to -1
  26528. */
  26529. private debugLimit;
  26530. /**
  26531. * @hidden
  26532. * This is reserved for the inspector.
  26533. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26534. * You can use the factor to better multiply the final value.
  26535. */
  26536. private debugFactor;
  26537. /**
  26538. * Defines the clear coat layer parameters for the material.
  26539. */
  26540. readonly clearCoat: PBRClearCoatConfiguration;
  26541. /**
  26542. * Defines the anisotropic parameters for the material.
  26543. */
  26544. readonly anisotropy: PBRAnisotropicConfiguration;
  26545. /**
  26546. * Defines the BRDF parameters for the material.
  26547. */
  26548. readonly brdf: PBRBRDFConfiguration;
  26549. /**
  26550. * Defines the Sheen parameters for the material.
  26551. */
  26552. readonly sheen: PBRSheenConfiguration;
  26553. /**
  26554. * Defines the SubSurface parameters for the material.
  26555. */
  26556. readonly subSurface: PBRSubSurfaceConfiguration;
  26557. /**
  26558. * Defines additionnal PrePass parameters for the material.
  26559. */
  26560. readonly prePassConfiguration: PrePassConfiguration;
  26561. /**
  26562. * Defines the detail map parameters for the material.
  26563. */
  26564. readonly detailMap: DetailMapConfiguration;
  26565. protected _rebuildInParallel: boolean;
  26566. /**
  26567. * Instantiates a new PBRMaterial instance.
  26568. *
  26569. * @param name The material name
  26570. * @param scene The scene the material will be use in.
  26571. */
  26572. constructor(name: string, scene: Scene);
  26573. /**
  26574. * Gets a boolean indicating that current material needs to register RTT
  26575. */
  26576. get hasRenderTargetTextures(): boolean;
  26577. /**
  26578. * Gets the name of the material class.
  26579. */
  26580. getClassName(): string;
  26581. /**
  26582. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26583. */
  26584. get useLogarithmicDepth(): boolean;
  26585. /**
  26586. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26587. */
  26588. set useLogarithmicDepth(value: boolean);
  26589. /**
  26590. * Returns true if alpha blending should be disabled.
  26591. */
  26592. protected get _disableAlphaBlending(): boolean;
  26593. /**
  26594. * Specifies whether or not this material should be rendered in alpha blend mode.
  26595. */
  26596. needAlphaBlending(): boolean;
  26597. /**
  26598. * Specifies whether or not this material should be rendered in alpha test mode.
  26599. */
  26600. needAlphaTesting(): boolean;
  26601. /**
  26602. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26603. */
  26604. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26605. /**
  26606. * Specifies whether or not there is a usable alpha channel for transparency.
  26607. */
  26608. protected _hasAlphaChannel(): boolean;
  26609. /**
  26610. * Gets the texture used for the alpha test.
  26611. */
  26612. getAlphaTestTexture(): Nullable<BaseTexture>;
  26613. /**
  26614. * Specifies that the submesh is ready to be used.
  26615. * @param mesh - BJS mesh.
  26616. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26617. * @param useInstances - Specifies that instances should be used.
  26618. * @returns - boolean indicating that the submesh is ready or not.
  26619. */
  26620. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26621. /**
  26622. * Specifies if the material uses metallic roughness workflow.
  26623. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26624. */
  26625. isMetallicWorkflow(): boolean;
  26626. private _prepareEffect;
  26627. private _prepareDefines;
  26628. /**
  26629. * Force shader compilation
  26630. */
  26631. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26632. /**
  26633. * Initializes the uniform buffer layout for the shader.
  26634. */
  26635. buildUniformLayout(): void;
  26636. /**
  26637. * Unbinds the material from the mesh
  26638. */
  26639. unbind(): void;
  26640. /**
  26641. * Binds the submesh data.
  26642. * @param world - The world matrix.
  26643. * @param mesh - The BJS mesh.
  26644. * @param subMesh - A submesh of the BJS mesh.
  26645. */
  26646. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26647. /**
  26648. * Returns the animatable textures.
  26649. * @returns - Array of animatable textures.
  26650. */
  26651. getAnimatables(): IAnimatable[];
  26652. /**
  26653. * Returns the texture used for reflections.
  26654. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26655. */
  26656. private _getReflectionTexture;
  26657. /**
  26658. * Returns an array of the actively used textures.
  26659. * @returns - Array of BaseTextures
  26660. */
  26661. getActiveTextures(): BaseTexture[];
  26662. /**
  26663. * Checks to see if a texture is used in the material.
  26664. * @param texture - Base texture to use.
  26665. * @returns - Boolean specifying if a texture is used in the material.
  26666. */
  26667. hasTexture(texture: BaseTexture): boolean;
  26668. /**
  26669. * Sets the required values to the prepass renderer.
  26670. * @param prePassRenderer defines the prepass renderer to setup
  26671. */
  26672. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26673. /**
  26674. * Disposes the resources of the material.
  26675. * @param forceDisposeEffect - Forces the disposal of effects.
  26676. * @param forceDisposeTextures - Forces the disposal of all textures.
  26677. */
  26678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26679. }
  26680. }
  26681. declare module BABYLON {
  26682. /**
  26683. * The Physically based material of BJS.
  26684. *
  26685. * This offers the main features of a standard PBR material.
  26686. * For more information, please refer to the documentation :
  26687. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26688. */
  26689. export class PBRMaterial extends PBRBaseMaterial {
  26690. /**
  26691. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26692. */
  26693. static readonly PBRMATERIAL_OPAQUE: number;
  26694. /**
  26695. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26696. */
  26697. static readonly PBRMATERIAL_ALPHATEST: number;
  26698. /**
  26699. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26700. */
  26701. static readonly PBRMATERIAL_ALPHABLEND: number;
  26702. /**
  26703. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26704. * They are also discarded below the alpha cutoff threshold to improve performances.
  26705. */
  26706. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26707. /**
  26708. * Defines the default value of how much AO map is occluding the analytical lights
  26709. * (point spot...).
  26710. */
  26711. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26712. /**
  26713. * Intensity of the direct lights e.g. the four lights available in your scene.
  26714. * This impacts both the direct diffuse and specular highlights.
  26715. */
  26716. directIntensity: number;
  26717. /**
  26718. * Intensity of the emissive part of the material.
  26719. * This helps controlling the emissive effect without modifying the emissive color.
  26720. */
  26721. emissiveIntensity: number;
  26722. /**
  26723. * Intensity of the environment e.g. how much the environment will light the object
  26724. * either through harmonics for rough material or through the refelction for shiny ones.
  26725. */
  26726. environmentIntensity: number;
  26727. /**
  26728. * This is a special control allowing the reduction of the specular highlights coming from the
  26729. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26730. */
  26731. specularIntensity: number;
  26732. /**
  26733. * Debug Control allowing disabling the bump map on this material.
  26734. */
  26735. disableBumpMap: boolean;
  26736. /**
  26737. * AKA Diffuse Texture in standard nomenclature.
  26738. */
  26739. albedoTexture: BaseTexture;
  26740. /**
  26741. * AKA Occlusion Texture in other nomenclature.
  26742. */
  26743. ambientTexture: BaseTexture;
  26744. /**
  26745. * AKA Occlusion Texture Intensity in other nomenclature.
  26746. */
  26747. ambientTextureStrength: number;
  26748. /**
  26749. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26750. * 1 means it completely occludes it
  26751. * 0 mean it has no impact
  26752. */
  26753. ambientTextureImpactOnAnalyticalLights: number;
  26754. /**
  26755. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  26756. */
  26757. opacityTexture: BaseTexture;
  26758. /**
  26759. * Stores the reflection values in a texture.
  26760. */
  26761. reflectionTexture: Nullable<BaseTexture>;
  26762. /**
  26763. * Stores the emissive values in a texture.
  26764. */
  26765. emissiveTexture: BaseTexture;
  26766. /**
  26767. * AKA Specular texture in other nomenclature.
  26768. */
  26769. reflectivityTexture: BaseTexture;
  26770. /**
  26771. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26772. */
  26773. metallicTexture: BaseTexture;
  26774. /**
  26775. * Specifies the metallic scalar of the metallic/roughness workflow.
  26776. * Can also be used to scale the metalness values of the metallic texture.
  26777. */
  26778. metallic: Nullable<number>;
  26779. /**
  26780. * Specifies the roughness scalar of the metallic/roughness workflow.
  26781. * Can also be used to scale the roughness values of the metallic texture.
  26782. */
  26783. roughness: Nullable<number>;
  26784. /**
  26785. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26786. * By default the indexOfrefraction is used to compute F0;
  26787. *
  26788. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26789. *
  26790. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26791. * F90 = metallicReflectanceColor;
  26792. */
  26793. metallicF0Factor: number;
  26794. /**
  26795. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26796. * By default the F90 is always 1;
  26797. *
  26798. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26799. *
  26800. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26801. * F90 = metallicReflectanceColor;
  26802. */
  26803. metallicReflectanceColor: Color3;
  26804. /**
  26805. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26806. * This is multiply against the scalar values defined in the material.
  26807. */
  26808. metallicReflectanceTexture: Nullable<BaseTexture>;
  26809. /**
  26810. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26811. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26812. */
  26813. microSurfaceTexture: BaseTexture;
  26814. /**
  26815. * Stores surface normal data used to displace a mesh in a texture.
  26816. */
  26817. bumpTexture: BaseTexture;
  26818. /**
  26819. * Stores the pre-calculated light information of a mesh in a texture.
  26820. */
  26821. lightmapTexture: BaseTexture;
  26822. /**
  26823. * Stores the refracted light information in a texture.
  26824. */
  26825. get refractionTexture(): Nullable<BaseTexture>;
  26826. set refractionTexture(value: Nullable<BaseTexture>);
  26827. /**
  26828. * The color of a material in ambient lighting.
  26829. */
  26830. ambientColor: Color3;
  26831. /**
  26832. * AKA Diffuse Color in other nomenclature.
  26833. */
  26834. albedoColor: Color3;
  26835. /**
  26836. * AKA Specular Color in other nomenclature.
  26837. */
  26838. reflectivityColor: Color3;
  26839. /**
  26840. * The color reflected from the material.
  26841. */
  26842. reflectionColor: Color3;
  26843. /**
  26844. * The color emitted from the material.
  26845. */
  26846. emissiveColor: Color3;
  26847. /**
  26848. * AKA Glossiness in other nomenclature.
  26849. */
  26850. microSurface: number;
  26851. /**
  26852. * Index of refraction of the material base layer.
  26853. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26854. *
  26855. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26856. *
  26857. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26858. */
  26859. get indexOfRefraction(): number;
  26860. set indexOfRefraction(value: number);
  26861. /**
  26862. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26863. */
  26864. get invertRefractionY(): boolean;
  26865. set invertRefractionY(value: boolean);
  26866. /**
  26867. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26868. * Materials half opaque for instance using refraction could benefit from this control.
  26869. */
  26870. get linkRefractionWithTransparency(): boolean;
  26871. set linkRefractionWithTransparency(value: boolean);
  26872. /**
  26873. * If true, the light map contains occlusion information instead of lighting info.
  26874. */
  26875. useLightmapAsShadowmap: boolean;
  26876. /**
  26877. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26878. */
  26879. useAlphaFromAlbedoTexture: boolean;
  26880. /**
  26881. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26882. */
  26883. forceAlphaTest: boolean;
  26884. /**
  26885. * Defines the alpha limits in alpha test mode.
  26886. */
  26887. alphaCutOff: number;
  26888. /**
  26889. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26890. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26891. */
  26892. useSpecularOverAlpha: boolean;
  26893. /**
  26894. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26895. */
  26896. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26897. /**
  26898. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26899. */
  26900. useRoughnessFromMetallicTextureAlpha: boolean;
  26901. /**
  26902. * Specifies if the metallic texture contains the roughness information in its green channel.
  26903. */
  26904. useRoughnessFromMetallicTextureGreen: boolean;
  26905. /**
  26906. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26907. */
  26908. useMetallnessFromMetallicTextureBlue: boolean;
  26909. /**
  26910. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26911. */
  26912. useAmbientOcclusionFromMetallicTextureRed: boolean;
  26913. /**
  26914. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26915. */
  26916. useAmbientInGrayScale: boolean;
  26917. /**
  26918. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26919. * The material will try to infer what glossiness each pixel should be.
  26920. */
  26921. useAutoMicroSurfaceFromReflectivityMap: boolean;
  26922. /**
  26923. * BJS is using an harcoded light falloff based on a manually sets up range.
  26924. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26925. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26926. */
  26927. get usePhysicalLightFalloff(): boolean;
  26928. /**
  26929. * BJS is using an harcoded light falloff based on a manually sets up range.
  26930. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26931. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26932. */
  26933. set usePhysicalLightFalloff(value: boolean);
  26934. /**
  26935. * In order to support the falloff compatibility with gltf, a special mode has been added
  26936. * to reproduce the gltf light falloff.
  26937. */
  26938. get useGLTFLightFalloff(): boolean;
  26939. /**
  26940. * In order to support the falloff compatibility with gltf, a special mode has been added
  26941. * to reproduce the gltf light falloff.
  26942. */
  26943. set useGLTFLightFalloff(value: boolean);
  26944. /**
  26945. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26946. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26947. */
  26948. useRadianceOverAlpha: boolean;
  26949. /**
  26950. * Allows using an object space normal map (instead of tangent space).
  26951. */
  26952. useObjectSpaceNormalMap: boolean;
  26953. /**
  26954. * Allows using the bump map in parallax mode.
  26955. */
  26956. useParallax: boolean;
  26957. /**
  26958. * Allows using the bump map in parallax occlusion mode.
  26959. */
  26960. useParallaxOcclusion: boolean;
  26961. /**
  26962. * Controls the scale bias of the parallax mode.
  26963. */
  26964. parallaxScaleBias: number;
  26965. /**
  26966. * If sets to true, disables all the lights affecting the material.
  26967. */
  26968. disableLighting: boolean;
  26969. /**
  26970. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26971. */
  26972. forceIrradianceInFragment: boolean;
  26973. /**
  26974. * Number of Simultaneous lights allowed on the material.
  26975. */
  26976. maxSimultaneousLights: number;
  26977. /**
  26978. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26979. */
  26980. invertNormalMapX: boolean;
  26981. /**
  26982. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26983. */
  26984. invertNormalMapY: boolean;
  26985. /**
  26986. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26987. */
  26988. twoSidedLighting: boolean;
  26989. /**
  26990. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26991. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26992. */
  26993. useAlphaFresnel: boolean;
  26994. /**
  26995. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26996. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26997. */
  26998. useLinearAlphaFresnel: boolean;
  26999. /**
  27000. * Let user defines the brdf lookup texture used for IBL.
  27001. * A default 8bit version is embedded but you could point at :
  27002. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  27003. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  27004. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27005. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27006. */
  27007. environmentBRDFTexture: Nullable<BaseTexture>;
  27008. /**
  27009. * Force normal to face away from face.
  27010. */
  27011. forceNormalForward: boolean;
  27012. /**
  27013. * Enables specular anti aliasing in the PBR shader.
  27014. * It will both interacts on the Geometry for analytical and IBL lighting.
  27015. * It also prefilter the roughness map based on the bump values.
  27016. */
  27017. enableSpecularAntiAliasing: boolean;
  27018. /**
  27019. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27020. * makes the reflect vector face the model (under horizon).
  27021. */
  27022. useHorizonOcclusion: boolean;
  27023. /**
  27024. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27025. * too much the area relying on ambient texture to define their ambient occlusion.
  27026. */
  27027. useRadianceOcclusion: boolean;
  27028. /**
  27029. * If set to true, no lighting calculations will be applied.
  27030. */
  27031. unlit: boolean;
  27032. /**
  27033. * Gets the image processing configuration used either in this material.
  27034. */
  27035. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27036. /**
  27037. * Sets the Default image processing configuration used either in the this material.
  27038. *
  27039. * If sets to null, the scene one is in use.
  27040. */
  27041. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27042. /**
  27043. * Gets wether the color curves effect is enabled.
  27044. */
  27045. get cameraColorCurvesEnabled(): boolean;
  27046. /**
  27047. * Sets wether the color curves effect is enabled.
  27048. */
  27049. set cameraColorCurvesEnabled(value: boolean);
  27050. /**
  27051. * Gets wether the color grading effect is enabled.
  27052. */
  27053. get cameraColorGradingEnabled(): boolean;
  27054. /**
  27055. * Gets wether the color grading effect is enabled.
  27056. */
  27057. set cameraColorGradingEnabled(value: boolean);
  27058. /**
  27059. * Gets wether tonemapping is enabled or not.
  27060. */
  27061. get cameraToneMappingEnabled(): boolean;
  27062. /**
  27063. * Sets wether tonemapping is enabled or not
  27064. */
  27065. set cameraToneMappingEnabled(value: boolean);
  27066. /**
  27067. * The camera exposure used on this material.
  27068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27069. * This corresponds to a photographic exposure.
  27070. */
  27071. get cameraExposure(): number;
  27072. /**
  27073. * The camera exposure used on this material.
  27074. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27075. * This corresponds to a photographic exposure.
  27076. */
  27077. set cameraExposure(value: number);
  27078. /**
  27079. * Gets The camera contrast used on this material.
  27080. */
  27081. get cameraContrast(): number;
  27082. /**
  27083. * Sets The camera contrast used on this material.
  27084. */
  27085. set cameraContrast(value: number);
  27086. /**
  27087. * Gets the Color Grading 2D Lookup Texture.
  27088. */
  27089. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27090. /**
  27091. * Sets the Color Grading 2D Lookup Texture.
  27092. */
  27093. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27094. /**
  27095. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27096. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27097. * 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;
  27098. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27099. */
  27100. get cameraColorCurves(): Nullable<ColorCurves>;
  27101. /**
  27102. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27103. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27104. * 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;
  27105. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27106. */
  27107. set cameraColorCurves(value: Nullable<ColorCurves>);
  27108. /**
  27109. * Instantiates a new PBRMaterial instance.
  27110. *
  27111. * @param name The material name
  27112. * @param scene The scene the material will be use in.
  27113. */
  27114. constructor(name: string, scene: Scene);
  27115. /**
  27116. * Returns the name of this material class.
  27117. */
  27118. getClassName(): string;
  27119. /**
  27120. * Makes a duplicate of the current material.
  27121. * @param name - name to use for the new material.
  27122. */
  27123. clone(name: string): PBRMaterial;
  27124. /**
  27125. * Serializes this PBR Material.
  27126. * @returns - An object with the serialized material.
  27127. */
  27128. serialize(): any;
  27129. /**
  27130. * Parses a PBR Material from a serialized object.
  27131. * @param source - Serialized object.
  27132. * @param scene - BJS scene instance.
  27133. * @param rootUrl - url for the scene object
  27134. * @returns - PBRMaterial
  27135. */
  27136. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27137. }
  27138. }
  27139. declare module BABYLON {
  27140. /** @hidden */
  27141. export var mrtFragmentDeclaration: {
  27142. name: string;
  27143. shader: string;
  27144. };
  27145. }
  27146. declare module BABYLON {
  27147. /** @hidden */
  27148. export var geometryPixelShader: {
  27149. name: string;
  27150. shader: string;
  27151. };
  27152. }
  27153. declare module BABYLON {
  27154. /** @hidden */
  27155. export var geometryVertexShader: {
  27156. name: string;
  27157. shader: string;
  27158. };
  27159. }
  27160. declare module BABYLON {
  27161. /** @hidden */
  27162. interface ISavedTransformationMatrix {
  27163. world: Matrix;
  27164. viewProjection: Matrix;
  27165. }
  27166. /**
  27167. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27168. */
  27169. export class GeometryBufferRenderer {
  27170. /**
  27171. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27172. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27173. */
  27174. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27175. /**
  27176. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27177. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27178. */
  27179. static readonly POSITION_TEXTURE_TYPE: number;
  27180. /**
  27181. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27182. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27183. */
  27184. static readonly VELOCITY_TEXTURE_TYPE: number;
  27185. /**
  27186. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27187. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27188. */
  27189. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27190. /**
  27191. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27192. * in order to compute objects velocities when enableVelocity is set to "true"
  27193. * @hidden
  27194. */
  27195. _previousTransformationMatrices: {
  27196. [index: number]: ISavedTransformationMatrix;
  27197. };
  27198. /**
  27199. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27200. * in order to compute objects velocities when enableVelocity is set to "true"
  27201. * @hidden
  27202. */
  27203. _previousBonesTransformationMatrices: {
  27204. [index: number]: Float32Array;
  27205. };
  27206. /**
  27207. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27208. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27209. */
  27210. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27211. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27212. renderTransparentMeshes: boolean;
  27213. private _scene;
  27214. private _resizeObserver;
  27215. private _multiRenderTarget;
  27216. private _ratio;
  27217. private _enablePosition;
  27218. private _enableVelocity;
  27219. private _enableReflectivity;
  27220. private _positionIndex;
  27221. private _velocityIndex;
  27222. private _reflectivityIndex;
  27223. private _depthNormalIndex;
  27224. private _linkedWithPrePass;
  27225. private _prePassRenderer;
  27226. private _attachments;
  27227. protected _effect: Effect;
  27228. protected _cachedDefines: string;
  27229. /**
  27230. * @hidden
  27231. * Sets up internal structures to share outputs with PrePassRenderer
  27232. * This method should only be called by the PrePassRenderer itself
  27233. */
  27234. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27235. /**
  27236. * @hidden
  27237. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27238. * This method should only be called by the PrePassRenderer itself
  27239. */
  27240. _unlinkPrePassRenderer(): void;
  27241. /**
  27242. * @hidden
  27243. * Resets the geometry buffer layout
  27244. */
  27245. _resetLayout(): void;
  27246. /**
  27247. * @hidden
  27248. * Replaces a texture in the geometry buffer renderer
  27249. * Useful when linking textures of the prepass renderer
  27250. */
  27251. _forceTextureType(geometryBufferType: number, index: number): void;
  27252. /**
  27253. * @hidden
  27254. * Sets texture attachments
  27255. * Useful when linking textures of the prepass renderer
  27256. */
  27257. _setAttachments(attachments: number[]): void;
  27258. /**
  27259. * @hidden
  27260. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27261. * Useful when linking textures of the prepass renderer
  27262. */
  27263. _linkInternalTexture(internalTexture: InternalTexture): void;
  27264. /**
  27265. * Gets the render list (meshes to be rendered) used in the G buffer.
  27266. */
  27267. get renderList(): Nullable<AbstractMesh[]>;
  27268. /**
  27269. * Set the render list (meshes to be rendered) used in the G buffer.
  27270. */
  27271. set renderList(meshes: Nullable<AbstractMesh[]>);
  27272. /**
  27273. * Gets wether or not G buffer are supported by the running hardware.
  27274. * This requires draw buffer supports
  27275. */
  27276. get isSupported(): boolean;
  27277. /**
  27278. * Returns the index of the given texture type in the G-Buffer textures array
  27279. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27280. * @returns the index of the given texture type in the G-Buffer textures array
  27281. */
  27282. getTextureIndex(textureType: number): number;
  27283. /**
  27284. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27285. */
  27286. get enablePosition(): boolean;
  27287. /**
  27288. * Sets whether or not objects positions are enabled for the G buffer.
  27289. */
  27290. set enablePosition(enable: boolean);
  27291. /**
  27292. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27293. */
  27294. get enableVelocity(): boolean;
  27295. /**
  27296. * Sets wether or not objects velocities are enabled for the G buffer.
  27297. */
  27298. set enableVelocity(enable: boolean);
  27299. /**
  27300. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27301. */
  27302. get enableReflectivity(): boolean;
  27303. /**
  27304. * Sets wether or not objects roughness are enabled for the G buffer.
  27305. */
  27306. set enableReflectivity(enable: boolean);
  27307. /**
  27308. * Gets the scene associated with the buffer.
  27309. */
  27310. get scene(): Scene;
  27311. /**
  27312. * Gets the ratio used by the buffer during its creation.
  27313. * How big is the buffer related to the main canvas.
  27314. */
  27315. get ratio(): number;
  27316. /** @hidden */
  27317. static _SceneComponentInitialization: (scene: Scene) => void;
  27318. /**
  27319. * Creates a new G Buffer for the scene
  27320. * @param scene The scene the buffer belongs to
  27321. * @param ratio How big is the buffer related to the main canvas.
  27322. */
  27323. constructor(scene: Scene, ratio?: number);
  27324. /**
  27325. * Checks wether everything is ready to render a submesh to the G buffer.
  27326. * @param subMesh the submesh to check readiness for
  27327. * @param useInstances is the mesh drawn using instance or not
  27328. * @returns true if ready otherwise false
  27329. */
  27330. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27331. /**
  27332. * Gets the current underlying G Buffer.
  27333. * @returns the buffer
  27334. */
  27335. getGBuffer(): MultiRenderTarget;
  27336. /**
  27337. * Gets the number of samples used to render the buffer (anti aliasing).
  27338. */
  27339. get samples(): number;
  27340. /**
  27341. * Sets the number of samples used to render the buffer (anti aliasing).
  27342. */
  27343. set samples(value: number);
  27344. /**
  27345. * Disposes the renderer and frees up associated resources.
  27346. */
  27347. dispose(): void;
  27348. private _assignRenderTargetIndices;
  27349. protected _createRenderTargets(): void;
  27350. private _copyBonesTransformationMatrices;
  27351. }
  27352. }
  27353. declare module BABYLON {
  27354. /**
  27355. * Renders a pre pass of the scene
  27356. * This means every mesh in the scene will be rendered to a render target texture
  27357. * And then this texture will be composited to the rendering canvas with post processes
  27358. * It is necessary for effects like subsurface scattering or deferred shading
  27359. */
  27360. export class PrePassRenderer {
  27361. /** @hidden */
  27362. static _SceneComponentInitialization: (scene: Scene) => void;
  27363. private _textureFormats;
  27364. /**
  27365. * To save performance, we can excluded skinned meshes from the prepass
  27366. */
  27367. excludedSkinnedMesh: AbstractMesh[];
  27368. /**
  27369. * Force material to be excluded from the prepass
  27370. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27371. * and you don't want a material to show in the effect.
  27372. */
  27373. excludedMaterials: Material[];
  27374. private _textureIndices;
  27375. private _scene;
  27376. private _engine;
  27377. private _isDirty;
  27378. /**
  27379. * Number of textures in the multi render target texture where the scene is directly rendered
  27380. */
  27381. mrtCount: number;
  27382. /**
  27383. * The render target where the scene is directly rendered
  27384. */
  27385. prePassRT: MultiRenderTarget;
  27386. private _multiRenderAttachments;
  27387. private _defaultAttachments;
  27388. private _clearAttachments;
  27389. private _postProcesses;
  27390. private readonly _clearColor;
  27391. /**
  27392. * Image processing post process for composition
  27393. */
  27394. imageProcessingPostProcess: ImageProcessingPostProcess;
  27395. /**
  27396. * Configuration for prepass effects
  27397. */
  27398. private _effectConfigurations;
  27399. private _mrtFormats;
  27400. private _mrtLayout;
  27401. private _enabled;
  27402. /**
  27403. * Indicates if the prepass is enabled
  27404. */
  27405. get enabled(): boolean;
  27406. /**
  27407. * How many samples are used for MSAA of the scene render target
  27408. */
  27409. get samples(): number;
  27410. set samples(n: number);
  27411. private _geometryBuffer;
  27412. private _useGeometryBufferFallback;
  27413. /**
  27414. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27415. */
  27416. get useGeometryBufferFallback(): boolean;
  27417. set useGeometryBufferFallback(value: boolean);
  27418. /**
  27419. * Instanciates a prepass renderer
  27420. * @param scene The scene
  27421. */
  27422. constructor(scene: Scene);
  27423. private _initializeAttachments;
  27424. private _createCompositionEffect;
  27425. /**
  27426. * Indicates if rendering a prepass is supported
  27427. */
  27428. get isSupported(): boolean;
  27429. /**
  27430. * Sets the proper output textures to draw in the engine.
  27431. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27432. * @param subMesh Submesh on which the effect is applied
  27433. */
  27434. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27435. /**
  27436. * @hidden
  27437. */
  27438. _beforeCameraDraw(): void;
  27439. /**
  27440. * @hidden
  27441. */
  27442. _afterCameraDraw(): void;
  27443. private _checkRTSize;
  27444. private _bindFrameBuffer;
  27445. /**
  27446. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27447. */
  27448. clear(): void;
  27449. private _setState;
  27450. private _updateGeometryBufferLayout;
  27451. /**
  27452. * Adds an effect configuration to the prepass.
  27453. * If an effect has already been added, it won't add it twice and will return the configuration
  27454. * already present.
  27455. * @param cfg the effect configuration
  27456. * @return the effect configuration now used by the prepass
  27457. */
  27458. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27459. /**
  27460. * Returns the index of a texture in the multi render target texture array.
  27461. * @param type Texture type
  27462. * @return The index
  27463. */
  27464. getIndex(type: number): number;
  27465. private _enable;
  27466. private _disable;
  27467. private _resetLayout;
  27468. private _resetPostProcessChain;
  27469. private _bindPostProcessChain;
  27470. /**
  27471. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27472. */
  27473. markAsDirty(): void;
  27474. /**
  27475. * Enables a texture on the MultiRenderTarget for prepass
  27476. */
  27477. private _enableTextures;
  27478. private _update;
  27479. private _markAllMaterialsAsPrePassDirty;
  27480. /**
  27481. * Disposes the prepass renderer.
  27482. */
  27483. dispose(): void;
  27484. }
  27485. }
  27486. declare module BABYLON {
  27487. /**
  27488. * Size options for a post process
  27489. */
  27490. export type PostProcessOptions = {
  27491. width: number;
  27492. height: number;
  27493. };
  27494. /**
  27495. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27496. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27497. */
  27498. export class PostProcess {
  27499. /**
  27500. * Gets or sets the unique id of the post process
  27501. */
  27502. uniqueId: number;
  27503. /** Name of the PostProcess. */
  27504. name: string;
  27505. /**
  27506. * Width of the texture to apply the post process on
  27507. */
  27508. width: number;
  27509. /**
  27510. * Height of the texture to apply the post process on
  27511. */
  27512. height: number;
  27513. /**
  27514. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27515. */
  27516. nodeMaterialSource: Nullable<NodeMaterial>;
  27517. /**
  27518. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27519. * @hidden
  27520. */
  27521. _outputTexture: Nullable<InternalTexture>;
  27522. /**
  27523. * Sampling mode used by the shader
  27524. * See https://doc.babylonjs.com/classes/3.1/texture
  27525. */
  27526. renderTargetSamplingMode: number;
  27527. /**
  27528. * Clear color to use when screen clearing
  27529. */
  27530. clearColor: Color4;
  27531. /**
  27532. * If the buffer needs to be cleared before applying the post process. (default: true)
  27533. * Should be set to false if shader will overwrite all previous pixels.
  27534. */
  27535. autoClear: boolean;
  27536. /**
  27537. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27538. */
  27539. alphaMode: number;
  27540. /**
  27541. * Sets the setAlphaBlendConstants of the babylon engine
  27542. */
  27543. alphaConstants: Color4;
  27544. /**
  27545. * Animations to be used for the post processing
  27546. */
  27547. animations: Animation[];
  27548. /**
  27549. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27550. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27551. */
  27552. enablePixelPerfectMode: boolean;
  27553. /**
  27554. * Force the postprocess to be applied without taking in account viewport
  27555. */
  27556. forceFullscreenViewport: boolean;
  27557. /**
  27558. * List of inspectable custom properties (used by the Inspector)
  27559. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27560. */
  27561. inspectableCustomProperties: IInspectable[];
  27562. /**
  27563. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27564. *
  27565. * | Value | Type | Description |
  27566. * | ----- | ----------------------------------- | ----------- |
  27567. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27568. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27569. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27570. *
  27571. */
  27572. scaleMode: number;
  27573. /**
  27574. * Force textures to be a power of two (default: false)
  27575. */
  27576. alwaysForcePOT: boolean;
  27577. private _samples;
  27578. /**
  27579. * Number of sample textures (default: 1)
  27580. */
  27581. get samples(): number;
  27582. set samples(n: number);
  27583. /**
  27584. * Modify the scale of the post process to be the same as the viewport (default: false)
  27585. */
  27586. adaptScaleToCurrentViewport: boolean;
  27587. private _camera;
  27588. protected _scene: Scene;
  27589. private _engine;
  27590. private _options;
  27591. private _reusable;
  27592. private _textureType;
  27593. private _textureFormat;
  27594. /**
  27595. * Smart array of input and output textures for the post process.
  27596. * @hidden
  27597. */
  27598. _textures: SmartArray<InternalTexture>;
  27599. /**
  27600. * The index in _textures that corresponds to the output texture.
  27601. * @hidden
  27602. */
  27603. _currentRenderTextureInd: number;
  27604. private _effect;
  27605. private _samplers;
  27606. private _fragmentUrl;
  27607. private _vertexUrl;
  27608. private _parameters;
  27609. private _scaleRatio;
  27610. protected _indexParameters: any;
  27611. private _shareOutputWithPostProcess;
  27612. private _texelSize;
  27613. private _forcedOutputTexture;
  27614. /**
  27615. * Prepass configuration in case this post process needs a texture from prepass
  27616. * @hidden
  27617. */
  27618. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27619. /**
  27620. * Returns the fragment url or shader name used in the post process.
  27621. * @returns the fragment url or name in the shader store.
  27622. */
  27623. getEffectName(): string;
  27624. /**
  27625. * An event triggered when the postprocess is activated.
  27626. */
  27627. onActivateObservable: Observable<Camera>;
  27628. private _onActivateObserver;
  27629. /**
  27630. * A function that is added to the onActivateObservable
  27631. */
  27632. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27633. /**
  27634. * An event triggered when the postprocess changes its size.
  27635. */
  27636. onSizeChangedObservable: Observable<PostProcess>;
  27637. private _onSizeChangedObserver;
  27638. /**
  27639. * A function that is added to the onSizeChangedObservable
  27640. */
  27641. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27642. /**
  27643. * An event triggered when the postprocess applies its effect.
  27644. */
  27645. onApplyObservable: Observable<Effect>;
  27646. private _onApplyObserver;
  27647. /**
  27648. * A function that is added to the onApplyObservable
  27649. */
  27650. set onApply(callback: (effect: Effect) => void);
  27651. /**
  27652. * An event triggered before rendering the postprocess
  27653. */
  27654. onBeforeRenderObservable: Observable<Effect>;
  27655. private _onBeforeRenderObserver;
  27656. /**
  27657. * A function that is added to the onBeforeRenderObservable
  27658. */
  27659. set onBeforeRender(callback: (effect: Effect) => void);
  27660. /**
  27661. * An event triggered after rendering the postprocess
  27662. */
  27663. onAfterRenderObservable: Observable<Effect>;
  27664. private _onAfterRenderObserver;
  27665. /**
  27666. * A function that is added to the onAfterRenderObservable
  27667. */
  27668. set onAfterRender(callback: (efect: Effect) => void);
  27669. /**
  27670. * 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
  27671. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27672. */
  27673. get inputTexture(): InternalTexture;
  27674. set inputTexture(value: InternalTexture);
  27675. /**
  27676. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27677. * the only way to unset it is to use this function to restore its internal state
  27678. */
  27679. restoreDefaultInputTexture(): void;
  27680. /**
  27681. * Gets the camera which post process is applied to.
  27682. * @returns The camera the post process is applied to.
  27683. */
  27684. getCamera(): Camera;
  27685. /**
  27686. * Gets the texel size of the postprocess.
  27687. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27688. */
  27689. get texelSize(): Vector2;
  27690. /**
  27691. * Creates a new instance PostProcess
  27692. * @param name The name of the PostProcess.
  27693. * @param fragmentUrl The url of the fragment shader to be used.
  27694. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27695. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27696. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27697. * @param camera The camera to apply the render pass to.
  27698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27699. * @param engine The engine which the post process will be applied. (default: current engine)
  27700. * @param reusable If the post process can be reused on the same frame. (default: false)
  27701. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27702. * @param textureType Type of textures used when performing the post process. (default: 0)
  27703. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27704. * @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
  27705. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27706. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27707. */
  27708. 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);
  27709. /**
  27710. * Gets a string identifying the name of the class
  27711. * @returns "PostProcess" string
  27712. */
  27713. getClassName(): string;
  27714. /**
  27715. * Gets the engine which this post process belongs to.
  27716. * @returns The engine the post process was enabled with.
  27717. */
  27718. getEngine(): Engine;
  27719. /**
  27720. * The effect that is created when initializing the post process.
  27721. * @returns The created effect corresponding the the postprocess.
  27722. */
  27723. getEffect(): Effect;
  27724. /**
  27725. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27726. * @param postProcess The post process to share the output with.
  27727. * @returns This post process.
  27728. */
  27729. shareOutputWith(postProcess: PostProcess): PostProcess;
  27730. /**
  27731. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27732. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27733. */
  27734. useOwnOutput(): void;
  27735. /**
  27736. * Updates the effect with the current post process compile time values and recompiles the shader.
  27737. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27738. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27739. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27740. * @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
  27741. * @param onCompiled Called when the shader has been compiled.
  27742. * @param onError Called if there is an error when compiling a shader.
  27743. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  27744. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  27745. */
  27746. 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;
  27747. /**
  27748. * The post process is reusable if it can be used multiple times within one frame.
  27749. * @returns If the post process is reusable
  27750. */
  27751. isReusable(): boolean;
  27752. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27753. markTextureDirty(): void;
  27754. /**
  27755. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27756. * 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.
  27757. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27758. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27759. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27760. * @returns The target texture that was bound to be written to.
  27761. */
  27762. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27763. /**
  27764. * If the post process is supported.
  27765. */
  27766. get isSupported(): boolean;
  27767. /**
  27768. * The aspect ratio of the output texture.
  27769. */
  27770. get aspectRatio(): number;
  27771. /**
  27772. * Get a value indicating if the post-process is ready to be used
  27773. * @returns true if the post-process is ready (shader is compiled)
  27774. */
  27775. isReady(): boolean;
  27776. /**
  27777. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27778. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  27779. */
  27780. apply(): Nullable<Effect>;
  27781. private _disposeTextures;
  27782. /**
  27783. * Sets the required values to the prepass renderer.
  27784. * @param prePassRenderer defines the prepass renderer to setup.
  27785. * @returns true if the pre pass is needed.
  27786. */
  27787. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27788. /**
  27789. * Disposes the post process.
  27790. * @param camera The camera to dispose the post process on.
  27791. */
  27792. dispose(camera?: Camera): void;
  27793. /**
  27794. * Serializes the particle system to a JSON object
  27795. * @returns the JSON object
  27796. */
  27797. serialize(): any;
  27798. /**
  27799. * Creates a material from parsed material data
  27800. * @param parsedPostProcess defines parsed post process data
  27801. * @param scene defines the hosting scene
  27802. * @param rootUrl defines the root URL to use to load textures
  27803. * @returns a new post process
  27804. */
  27805. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  27806. }
  27807. }
  27808. declare module BABYLON {
  27809. /** @hidden */
  27810. export var kernelBlurVaryingDeclaration: {
  27811. name: string;
  27812. shader: string;
  27813. };
  27814. }
  27815. declare module BABYLON {
  27816. /** @hidden */
  27817. export var kernelBlurFragment: {
  27818. name: string;
  27819. shader: string;
  27820. };
  27821. }
  27822. declare module BABYLON {
  27823. /** @hidden */
  27824. export var kernelBlurFragment2: {
  27825. name: string;
  27826. shader: string;
  27827. };
  27828. }
  27829. declare module BABYLON {
  27830. /** @hidden */
  27831. export var kernelBlurPixelShader: {
  27832. name: string;
  27833. shader: string;
  27834. };
  27835. }
  27836. declare module BABYLON {
  27837. /** @hidden */
  27838. export var kernelBlurVertex: {
  27839. name: string;
  27840. shader: string;
  27841. };
  27842. }
  27843. declare module BABYLON {
  27844. /** @hidden */
  27845. export var kernelBlurVertexShader: {
  27846. name: string;
  27847. shader: string;
  27848. };
  27849. }
  27850. declare module BABYLON {
  27851. /**
  27852. * The Blur Post Process which blurs an image based on a kernel and direction.
  27853. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27854. */
  27855. export class BlurPostProcess extends PostProcess {
  27856. private blockCompilation;
  27857. protected _kernel: number;
  27858. protected _idealKernel: number;
  27859. protected _packedFloat: boolean;
  27860. private _staticDefines;
  27861. /** The direction in which to blur the image. */
  27862. direction: Vector2;
  27863. /**
  27864. * Sets the length in pixels of the blur sample region
  27865. */
  27866. set kernel(v: number);
  27867. /**
  27868. * Gets the length in pixels of the blur sample region
  27869. */
  27870. get kernel(): number;
  27871. /**
  27872. * Sets wether or not the blur needs to unpack/repack floats
  27873. */
  27874. set packedFloat(v: boolean);
  27875. /**
  27876. * Gets wether or not the blur is unpacking/repacking floats
  27877. */
  27878. get packedFloat(): boolean;
  27879. /**
  27880. * Gets a string identifying the name of the class
  27881. * @returns "BlurPostProcess" string
  27882. */
  27883. getClassName(): string;
  27884. /**
  27885. * Creates a new instance BlurPostProcess
  27886. * @param name The name of the effect.
  27887. * @param direction The direction in which to blur the image.
  27888. * @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.
  27889. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27890. * @param camera The camera to apply the render pass to.
  27891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27892. * @param engine The engine which the post process will be applied. (default: current engine)
  27893. * @param reusable If the post process can be reused on the same frame. (default: false)
  27894. * @param textureType Type of textures used when performing the post process. (default: 0)
  27895. * @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)
  27896. */
  27897. 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);
  27898. /**
  27899. * Updates the effect with the current post process compile time values and recompiles the shader.
  27900. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27901. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27902. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27903. * @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
  27904. * @param onCompiled Called when the shader has been compiled.
  27905. * @param onError Called if there is an error when compiling a shader.
  27906. */
  27907. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27908. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27909. /**
  27910. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27911. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27912. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27913. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27914. * The gaps between physical kernels are compensated for in the weighting of the samples
  27915. * @param idealKernel Ideal blur kernel.
  27916. * @return Nearest best kernel.
  27917. */
  27918. protected _nearestBestKernel(idealKernel: number): number;
  27919. /**
  27920. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27921. * @param x The point on the Gaussian distribution to sample.
  27922. * @return the value of the Gaussian function at x.
  27923. */
  27924. protected _gaussianWeight(x: number): number;
  27925. /**
  27926. * Generates a string that can be used as a floating point number in GLSL.
  27927. * @param x Value to print.
  27928. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27929. * @return GLSL float string.
  27930. */
  27931. protected _glslFloat(x: number, decimalFigures?: number): string;
  27932. /** @hidden */
  27933. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  27934. }
  27935. }
  27936. declare module BABYLON {
  27937. /**
  27938. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27939. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27940. * You can then easily use it as a reflectionTexture on a flat surface.
  27941. * In case the surface is not a plane, please consider relying on reflection probes.
  27942. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27943. */
  27944. export class MirrorTexture extends RenderTargetTexture {
  27945. private scene;
  27946. /**
  27947. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  27948. * 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.
  27949. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27950. */
  27951. mirrorPlane: Plane;
  27952. /**
  27953. * Define the blur ratio used to blur the reflection if needed.
  27954. */
  27955. set blurRatio(value: number);
  27956. get blurRatio(): number;
  27957. /**
  27958. * Define the adaptive blur kernel used to blur the reflection if needed.
  27959. * This will autocompute the closest best match for the `blurKernel`
  27960. */
  27961. set adaptiveBlurKernel(value: number);
  27962. /**
  27963. * Define the blur kernel used to blur the reflection if needed.
  27964. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27965. */
  27966. set blurKernel(value: number);
  27967. /**
  27968. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  27969. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27970. */
  27971. set blurKernelX(value: number);
  27972. get blurKernelX(): number;
  27973. /**
  27974. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  27975. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27976. */
  27977. set blurKernelY(value: number);
  27978. get blurKernelY(): number;
  27979. private _autoComputeBlurKernel;
  27980. protected _onRatioRescale(): void;
  27981. private _updateGammaSpace;
  27982. private _imageProcessingConfigChangeObserver;
  27983. private _transformMatrix;
  27984. private _mirrorMatrix;
  27985. private _savedViewMatrix;
  27986. private _blurX;
  27987. private _blurY;
  27988. private _adaptiveBlurKernel;
  27989. private _blurKernelX;
  27990. private _blurKernelY;
  27991. private _blurRatio;
  27992. /**
  27993. * Instantiates a Mirror Texture.
  27994. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27995. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27996. * You can then easily use it as a reflectionTexture on a flat surface.
  27997. * In case the surface is not a plane, please consider relying on reflection probes.
  27998. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27999. * @param name
  28000. * @param size
  28001. * @param scene
  28002. * @param generateMipMaps
  28003. * @param type
  28004. * @param samplingMode
  28005. * @param generateDepthBuffer
  28006. */
  28007. constructor(name: string, size: number | {
  28008. width: number;
  28009. height: number;
  28010. } | {
  28011. ratio: number;
  28012. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  28013. private _preparePostProcesses;
  28014. /**
  28015. * Clone the mirror texture.
  28016. * @returns the cloned texture
  28017. */
  28018. clone(): MirrorTexture;
  28019. /**
  28020. * Serialize the texture to a JSON representation you could use in Parse later on
  28021. * @returns the serialized JSON representation
  28022. */
  28023. serialize(): any;
  28024. /**
  28025. * Dispose the texture and release its associated resources.
  28026. */
  28027. dispose(): void;
  28028. }
  28029. }
  28030. declare module BABYLON {
  28031. /**
  28032. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28033. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28034. */
  28035. export class Texture extends BaseTexture {
  28036. /**
  28037. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  28038. */
  28039. static SerializeBuffers: boolean;
  28040. /** @hidden */
  28041. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  28042. /** @hidden */
  28043. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  28044. /** @hidden */
  28045. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  28046. /** nearest is mag = nearest and min = nearest and mip = linear */
  28047. static readonly NEAREST_SAMPLINGMODE: number;
  28048. /** nearest is mag = nearest and min = nearest and mip = linear */
  28049. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  28050. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28051. static readonly BILINEAR_SAMPLINGMODE: number;
  28052. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28053. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  28054. /** Trilinear is mag = linear and min = linear and mip = linear */
  28055. static readonly TRILINEAR_SAMPLINGMODE: number;
  28056. /** Trilinear is mag = linear and min = linear and mip = linear */
  28057. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  28058. /** mag = nearest and min = nearest and mip = nearest */
  28059. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  28060. /** mag = nearest and min = linear and mip = nearest */
  28061. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  28062. /** mag = nearest and min = linear and mip = linear */
  28063. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  28064. /** mag = nearest and min = linear and mip = none */
  28065. static readonly NEAREST_LINEAR: number;
  28066. /** mag = nearest and min = nearest and mip = none */
  28067. static readonly NEAREST_NEAREST: number;
  28068. /** mag = linear and min = nearest and mip = nearest */
  28069. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  28070. /** mag = linear and min = nearest and mip = linear */
  28071. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28072. /** mag = linear and min = linear and mip = none */
  28073. static readonly LINEAR_LINEAR: number;
  28074. /** mag = linear and min = nearest and mip = none */
  28075. static readonly LINEAR_NEAREST: number;
  28076. /** Explicit coordinates mode */
  28077. static readonly EXPLICIT_MODE: number;
  28078. /** Spherical coordinates mode */
  28079. static readonly SPHERICAL_MODE: number;
  28080. /** Planar coordinates mode */
  28081. static readonly PLANAR_MODE: number;
  28082. /** Cubic coordinates mode */
  28083. static readonly CUBIC_MODE: number;
  28084. /** Projection coordinates mode */
  28085. static readonly PROJECTION_MODE: number;
  28086. /** Inverse Cubic coordinates mode */
  28087. static readonly SKYBOX_MODE: number;
  28088. /** Inverse Cubic coordinates mode */
  28089. static readonly INVCUBIC_MODE: number;
  28090. /** Equirectangular coordinates mode */
  28091. static readonly EQUIRECTANGULAR_MODE: number;
  28092. /** Equirectangular Fixed coordinates mode */
  28093. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28094. /** Equirectangular Fixed Mirrored coordinates mode */
  28095. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28096. /** Texture is not repeating outside of 0..1 UVs */
  28097. static readonly CLAMP_ADDRESSMODE: number;
  28098. /** Texture is repeating outside of 0..1 UVs */
  28099. static readonly WRAP_ADDRESSMODE: number;
  28100. /** Texture is repeating and mirrored */
  28101. static readonly MIRROR_ADDRESSMODE: number;
  28102. /**
  28103. * 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
  28104. */
  28105. static UseSerializedUrlIfAny: boolean;
  28106. /**
  28107. * Define the url of the texture.
  28108. */
  28109. url: Nullable<string>;
  28110. /**
  28111. * Define an offset on the texture to offset the u coordinates of the UVs
  28112. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28113. */
  28114. uOffset: number;
  28115. /**
  28116. * Define an offset on the texture to offset the v coordinates of the UVs
  28117. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28118. */
  28119. vOffset: number;
  28120. /**
  28121. * Define an offset on the texture to scale the u coordinates of the UVs
  28122. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28123. */
  28124. uScale: number;
  28125. /**
  28126. * Define an offset on the texture to scale the v coordinates of the UVs
  28127. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28128. */
  28129. vScale: number;
  28130. /**
  28131. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28132. * @see https://doc.babylonjs.com/how_to/more_materials
  28133. */
  28134. uAng: number;
  28135. /**
  28136. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28137. * @see https://doc.babylonjs.com/how_to/more_materials
  28138. */
  28139. vAng: number;
  28140. /**
  28141. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28142. * @see https://doc.babylonjs.com/how_to/more_materials
  28143. */
  28144. wAng: number;
  28145. /**
  28146. * Defines the center of rotation (U)
  28147. */
  28148. uRotationCenter: number;
  28149. /**
  28150. * Defines the center of rotation (V)
  28151. */
  28152. vRotationCenter: number;
  28153. /**
  28154. * Defines the center of rotation (W)
  28155. */
  28156. wRotationCenter: number;
  28157. /**
  28158. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28159. */
  28160. homogeneousRotationInUVTransform: boolean;
  28161. /**
  28162. * Are mip maps generated for this texture or not.
  28163. */
  28164. get noMipmap(): boolean;
  28165. /**
  28166. * List of inspectable custom properties (used by the Inspector)
  28167. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28168. */
  28169. inspectableCustomProperties: Nullable<IInspectable[]>;
  28170. private _noMipmap;
  28171. /** @hidden */
  28172. _invertY: boolean;
  28173. private _rowGenerationMatrix;
  28174. private _cachedTextureMatrix;
  28175. private _projectionModeMatrix;
  28176. private _t0;
  28177. private _t1;
  28178. private _t2;
  28179. private _cachedUOffset;
  28180. private _cachedVOffset;
  28181. private _cachedUScale;
  28182. private _cachedVScale;
  28183. private _cachedUAng;
  28184. private _cachedVAng;
  28185. private _cachedWAng;
  28186. private _cachedProjectionMatrixId;
  28187. private _cachedURotationCenter;
  28188. private _cachedVRotationCenter;
  28189. private _cachedWRotationCenter;
  28190. private _cachedHomogeneousRotationInUVTransform;
  28191. private _cachedCoordinatesMode;
  28192. /** @hidden */
  28193. protected _initialSamplingMode: number;
  28194. /** @hidden */
  28195. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28196. private _deleteBuffer;
  28197. protected _format: Nullable<number>;
  28198. private _delayedOnLoad;
  28199. private _delayedOnError;
  28200. private _mimeType?;
  28201. private _loaderOptions?;
  28202. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28203. get mimeType(): string | undefined;
  28204. /**
  28205. * Observable triggered once the texture has been loaded.
  28206. */
  28207. onLoadObservable: Observable<Texture>;
  28208. protected _isBlocking: boolean;
  28209. /**
  28210. * Is the texture preventing material to render while loading.
  28211. * If false, a default texture will be used instead of the loading one during the preparation step.
  28212. */
  28213. set isBlocking(value: boolean);
  28214. get isBlocking(): boolean;
  28215. /**
  28216. * Get the current sampling mode associated with the texture.
  28217. */
  28218. get samplingMode(): number;
  28219. /**
  28220. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28221. */
  28222. get invertY(): boolean;
  28223. /**
  28224. * Instantiates a new texture.
  28225. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28226. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28227. * @param url defines the url of the picture to load as a texture
  28228. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28229. * @param noMipmap defines if the texture will require mip maps or not
  28230. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28231. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28232. * @param onLoad defines a callback triggered when the texture has been loaded
  28233. * @param onError defines a callback triggered when an error occurred during the loading session
  28234. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28235. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28236. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28237. * @param mimeType defines an optional mime type information
  28238. * @param loaderOptions options to be passed to the loader
  28239. */
  28240. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  28241. /**
  28242. * Update the url (and optional buffer) of this texture if url was null during construction.
  28243. * @param url the url of the texture
  28244. * @param buffer the buffer of the texture (defaults to null)
  28245. * @param onLoad callback called when the texture is loaded (defaults to null)
  28246. */
  28247. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28248. /**
  28249. * Finish the loading sequence of a texture flagged as delayed load.
  28250. * @hidden
  28251. */
  28252. delayLoad(): void;
  28253. private _prepareRowForTextureGeneration;
  28254. /**
  28255. * Checks if the texture has the same transform matrix than another texture
  28256. * @param texture texture to check against
  28257. * @returns true if the transforms are the same, else false
  28258. */
  28259. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  28260. /**
  28261. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28262. * @returns the transform matrix of the texture.
  28263. */
  28264. getTextureMatrix(uBase?: number): Matrix;
  28265. /**
  28266. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28267. * @returns The reflection texture transform
  28268. */
  28269. getReflectionTextureMatrix(): Matrix;
  28270. /**
  28271. * Clones the texture.
  28272. * @returns the cloned texture
  28273. */
  28274. clone(): Texture;
  28275. /**
  28276. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28277. * @returns The JSON representation of the texture
  28278. */
  28279. serialize(): any;
  28280. /**
  28281. * Get the current class name of the texture useful for serialization or dynamic coding.
  28282. * @returns "Texture"
  28283. */
  28284. getClassName(): string;
  28285. /**
  28286. * Dispose the texture and release its associated resources.
  28287. */
  28288. dispose(): void;
  28289. /**
  28290. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28291. * @param parsedTexture Define the JSON representation of the texture
  28292. * @param scene Define the scene the parsed texture should be instantiated in
  28293. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28294. * @returns The parsed texture if successful
  28295. */
  28296. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28297. /**
  28298. * Creates a texture from its base 64 representation.
  28299. * @param data Define the base64 payload without the data: prefix
  28300. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28301. * @param scene Define the scene the texture should belong to
  28302. * @param noMipmap Forces the texture to not create mip map information if true
  28303. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28304. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28305. * @param onLoad define a callback triggered when the texture has been loaded
  28306. * @param onError define a callback triggered when an error occurred during the loading session
  28307. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28308. * @returns the created texture
  28309. */
  28310. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28311. /**
  28312. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28313. * @param data Define the base64 payload without the data: prefix
  28314. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28315. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28316. * @param scene Define the scene the texture should belong to
  28317. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28318. * @param noMipmap Forces the texture to not create mip map information if true
  28319. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28320. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28321. * @param onLoad define a callback triggered when the texture has been loaded
  28322. * @param onError define a callback triggered when an error occurred during the loading session
  28323. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28324. * @returns the created texture
  28325. */
  28326. 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;
  28327. }
  28328. }
  28329. declare module BABYLON {
  28330. /**
  28331. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28332. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28333. */
  28334. export class PostProcessManager {
  28335. private _scene;
  28336. private _indexBuffer;
  28337. private _vertexBuffers;
  28338. /**
  28339. * Creates a new instance PostProcess
  28340. * @param scene The scene that the post process is associated with.
  28341. */
  28342. constructor(scene: Scene);
  28343. private _prepareBuffers;
  28344. private _buildIndexBuffer;
  28345. /**
  28346. * Rebuilds the vertex buffers of the manager.
  28347. * @hidden
  28348. */
  28349. _rebuild(): void;
  28350. /**
  28351. * Prepares a frame to be run through a post process.
  28352. * @param sourceTexture The input texture to the post procesess. (default: null)
  28353. * @param postProcesses An array of post processes to be run. (default: null)
  28354. * @returns True if the post processes were able to be run.
  28355. * @hidden
  28356. */
  28357. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28358. /**
  28359. * Manually render a set of post processes to a texture.
  28360. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28361. * @param postProcesses An array of post processes to be run.
  28362. * @param targetTexture The target texture to render to.
  28363. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28364. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28365. * @param lodLevel defines which lod of the texture to render to
  28366. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28367. */
  28368. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28369. /**
  28370. * Finalize the result of the output of the postprocesses.
  28371. * @param doNotPresent If true the result will not be displayed to the screen.
  28372. * @param targetTexture The target texture to render to.
  28373. * @param faceIndex The index of the face to bind the target texture to.
  28374. * @param postProcesses The array of post processes to render.
  28375. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28376. * @hidden
  28377. */
  28378. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28379. /**
  28380. * Disposes of the post process manager.
  28381. */
  28382. dispose(): void;
  28383. }
  28384. }
  28385. declare module BABYLON {
  28386. /**
  28387. * This Helps creating a texture that will be created from a camera in your scene.
  28388. * It is basically a dynamic texture that could be used to create special effects for instance.
  28389. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28390. */
  28391. export class RenderTargetTexture extends Texture {
  28392. /**
  28393. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28394. */
  28395. static readonly REFRESHRATE_RENDER_ONCE: number;
  28396. /**
  28397. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28398. */
  28399. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28400. /**
  28401. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28402. * the central point of your effect and can save a lot of performances.
  28403. */
  28404. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28405. /**
  28406. * Use this predicate to dynamically define the list of mesh you want to render.
  28407. * If set, the renderList property will be overwritten.
  28408. */
  28409. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28410. private _renderList;
  28411. /**
  28412. * Use this list to define the list of mesh you want to render.
  28413. */
  28414. get renderList(): Nullable<Array<AbstractMesh>>;
  28415. set renderList(value: Nullable<Array<AbstractMesh>>);
  28416. /**
  28417. * Use this function to overload the renderList array at rendering time.
  28418. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28419. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28420. * the cube (if the RTT is a cube, else layerOrFace=0).
  28421. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28422. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28423. * hold dummy elements!
  28424. */
  28425. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28426. private _hookArray;
  28427. /**
  28428. * Define if particles should be rendered in your texture.
  28429. */
  28430. renderParticles: boolean;
  28431. /**
  28432. * Define if sprites should be rendered in your texture.
  28433. */
  28434. renderSprites: boolean;
  28435. /**
  28436. * Define the camera used to render the texture.
  28437. */
  28438. activeCamera: Nullable<Camera>;
  28439. /**
  28440. * Override the mesh isReady function with your own one.
  28441. */
  28442. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28443. /**
  28444. * Override the render function of the texture with your own one.
  28445. */
  28446. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28447. /**
  28448. * Define if camera post processes should be use while rendering the texture.
  28449. */
  28450. useCameraPostProcesses: boolean;
  28451. /**
  28452. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28453. */
  28454. ignoreCameraViewport: boolean;
  28455. private _postProcessManager;
  28456. private _postProcesses;
  28457. private _resizeObserver;
  28458. /**
  28459. * An event triggered when the texture is unbind.
  28460. */
  28461. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28462. /**
  28463. * An event triggered when the texture is unbind.
  28464. */
  28465. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28466. private _onAfterUnbindObserver;
  28467. /**
  28468. * Set a after unbind callback in the texture.
  28469. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28470. */
  28471. set onAfterUnbind(callback: () => void);
  28472. /**
  28473. * An event triggered before rendering the texture
  28474. */
  28475. onBeforeRenderObservable: Observable<number>;
  28476. private _onBeforeRenderObserver;
  28477. /**
  28478. * Set a before render callback in the texture.
  28479. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28480. */
  28481. set onBeforeRender(callback: (faceIndex: number) => void);
  28482. /**
  28483. * An event triggered after rendering the texture
  28484. */
  28485. onAfterRenderObservable: Observable<number>;
  28486. private _onAfterRenderObserver;
  28487. /**
  28488. * Set a after render callback in the texture.
  28489. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28490. */
  28491. set onAfterRender(callback: (faceIndex: number) => void);
  28492. /**
  28493. * An event triggered after the texture clear
  28494. */
  28495. onClearObservable: Observable<Engine>;
  28496. private _onClearObserver;
  28497. /**
  28498. * Set a clear callback in the texture.
  28499. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28500. */
  28501. set onClear(callback: (Engine: Engine) => void);
  28502. /**
  28503. * An event triggered when the texture is resized.
  28504. */
  28505. onResizeObservable: Observable<RenderTargetTexture>;
  28506. /**
  28507. * Define the clear color of the Render Target if it should be different from the scene.
  28508. */
  28509. clearColor: Color4;
  28510. protected _size: number | {
  28511. width: number;
  28512. height: number;
  28513. layers?: number;
  28514. };
  28515. protected _initialSizeParameter: number | {
  28516. width: number;
  28517. height: number;
  28518. } | {
  28519. ratio: number;
  28520. };
  28521. protected _sizeRatio: Nullable<number>;
  28522. /** @hidden */
  28523. _generateMipMaps: boolean;
  28524. protected _renderingManager: RenderingManager;
  28525. /** @hidden */
  28526. _waitingRenderList?: string[];
  28527. protected _doNotChangeAspectRatio: boolean;
  28528. protected _currentRefreshId: number;
  28529. protected _refreshRate: number;
  28530. protected _textureMatrix: Matrix;
  28531. protected _samples: number;
  28532. protected _renderTargetOptions: RenderTargetCreationOptions;
  28533. /**
  28534. * Gets render target creation options that were used.
  28535. */
  28536. get renderTargetOptions(): RenderTargetCreationOptions;
  28537. protected _onRatioRescale(): void;
  28538. /**
  28539. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28540. * It must define where the camera used to render the texture is set
  28541. */
  28542. boundingBoxPosition: Vector3;
  28543. private _boundingBoxSize;
  28544. /**
  28545. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28546. * When defined, the cubemap will switch to local mode
  28547. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28548. * @example https://www.babylonjs-playground.com/#RNASML
  28549. */
  28550. set boundingBoxSize(value: Vector3);
  28551. get boundingBoxSize(): Vector3;
  28552. /**
  28553. * In case the RTT has been created with a depth texture, get the associated
  28554. * depth texture.
  28555. * Otherwise, return null.
  28556. */
  28557. get depthStencilTexture(): Nullable<InternalTexture>;
  28558. /**
  28559. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28560. * or used a shadow, depth texture...
  28561. * @param name The friendly name of the texture
  28562. * @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)
  28563. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28564. * @param generateMipMaps True if mip maps need to be generated after render.
  28565. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28566. * @param type The type of the buffer in the RTT (int, half float, float...)
  28567. * @param isCube True if a cube texture needs to be created
  28568. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28569. * @param generateDepthBuffer True to generate a depth buffer
  28570. * @param generateStencilBuffer True to generate a stencil buffer
  28571. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28572. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28573. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28574. */
  28575. constructor(name: string, size: number | {
  28576. width: number;
  28577. height: number;
  28578. layers?: number;
  28579. } | {
  28580. ratio: number;
  28581. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28582. /**
  28583. * Creates a depth stencil texture.
  28584. * This is only available in WebGL 2 or with the depth texture extension available.
  28585. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28586. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28587. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28588. */
  28589. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28590. private _processSizeParameter;
  28591. /**
  28592. * Define the number of samples to use in case of MSAA.
  28593. * It defaults to one meaning no MSAA has been enabled.
  28594. */
  28595. get samples(): number;
  28596. set samples(value: number);
  28597. /**
  28598. * Resets the refresh counter of the texture and start bak from scratch.
  28599. * Could be useful to regenerate the texture if it is setup to render only once.
  28600. */
  28601. resetRefreshCounter(): void;
  28602. /**
  28603. * Define the refresh rate of the texture or the rendering frequency.
  28604. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28605. */
  28606. get refreshRate(): number;
  28607. set refreshRate(value: number);
  28608. /**
  28609. * Adds a post process to the render target rendering passes.
  28610. * @param postProcess define the post process to add
  28611. */
  28612. addPostProcess(postProcess: PostProcess): void;
  28613. /**
  28614. * Clear all the post processes attached to the render target
  28615. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28616. */
  28617. clearPostProcesses(dispose?: boolean): void;
  28618. /**
  28619. * Remove one of the post process from the list of attached post processes to the texture
  28620. * @param postProcess define the post process to remove from the list
  28621. */
  28622. removePostProcess(postProcess: PostProcess): void;
  28623. /** @hidden */
  28624. _shouldRender(): boolean;
  28625. /**
  28626. * Gets the actual render size of the texture.
  28627. * @returns the width of the render size
  28628. */
  28629. getRenderSize(): number;
  28630. /**
  28631. * Gets the actual render width of the texture.
  28632. * @returns the width of the render size
  28633. */
  28634. getRenderWidth(): number;
  28635. /**
  28636. * Gets the actual render height of the texture.
  28637. * @returns the height of the render size
  28638. */
  28639. getRenderHeight(): number;
  28640. /**
  28641. * Gets the actual number of layers of the texture.
  28642. * @returns the number of layers
  28643. */
  28644. getRenderLayers(): number;
  28645. /**
  28646. * Get if the texture can be rescaled or not.
  28647. */
  28648. get canRescale(): boolean;
  28649. /**
  28650. * Resize the texture using a ratio.
  28651. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28652. */
  28653. scale(ratio: number): void;
  28654. /**
  28655. * Get the texture reflection matrix used to rotate/transform the reflection.
  28656. * @returns the reflection matrix
  28657. */
  28658. getReflectionTextureMatrix(): Matrix;
  28659. /**
  28660. * Resize the texture to a new desired size.
  28661. * Be carrefull as it will recreate all the data in the new texture.
  28662. * @param size Define the new size. It can be:
  28663. * - a number for squared texture,
  28664. * - an object containing { width: number, height: number }
  28665. * - or an object containing a ratio { ratio: number }
  28666. */
  28667. resize(size: number | {
  28668. width: number;
  28669. height: number;
  28670. } | {
  28671. ratio: number;
  28672. }): void;
  28673. private _defaultRenderListPrepared;
  28674. /**
  28675. * Renders all the objects from the render list into the texture.
  28676. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28677. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28678. */
  28679. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28680. private _bestReflectionRenderTargetDimension;
  28681. private _prepareRenderingManager;
  28682. /**
  28683. * @hidden
  28684. * @param faceIndex face index to bind to if this is a cubetexture
  28685. * @param layer defines the index of the texture to bind in the array
  28686. */
  28687. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28688. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28689. private renderToTarget;
  28690. /**
  28691. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28692. * This allowed control for front to back rendering or reversly depending of the special needs.
  28693. *
  28694. * @param renderingGroupId The rendering group id corresponding to its index
  28695. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28696. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28697. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28698. */
  28699. 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;
  28700. /**
  28701. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28702. *
  28703. * @param renderingGroupId The rendering group id corresponding to its index
  28704. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28705. */
  28706. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28707. /**
  28708. * Clones the texture.
  28709. * @returns the cloned texture
  28710. */
  28711. clone(): RenderTargetTexture;
  28712. /**
  28713. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28714. * @returns The JSON representation of the texture
  28715. */
  28716. serialize(): any;
  28717. /**
  28718. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  28719. */
  28720. disposeFramebufferObjects(): void;
  28721. /**
  28722. * Dispose the texture and release its associated resources.
  28723. */
  28724. dispose(): void;
  28725. /** @hidden */
  28726. _rebuild(): void;
  28727. /**
  28728. * Clear the info related to rendering groups preventing retention point in material dispose.
  28729. */
  28730. freeRenderingGroups(): void;
  28731. /**
  28732. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28733. * @returns the view count
  28734. */
  28735. getViewCount(): number;
  28736. }
  28737. }
  28738. declare module BABYLON {
  28739. /**
  28740. * Class used to manipulate GUIDs
  28741. */
  28742. export class GUID {
  28743. /**
  28744. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28745. * Be aware Math.random() could cause collisions, but:
  28746. * "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"
  28747. * @returns a pseudo random id
  28748. */
  28749. static RandomId(): string;
  28750. }
  28751. }
  28752. declare module BABYLON {
  28753. /**
  28754. * Options to be used when creating a shadow depth material
  28755. */
  28756. export interface IIOptionShadowDepthMaterial {
  28757. /** Variables in the vertex shader code that need to have their names remapped.
  28758. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  28759. * "var_name" should be either: worldPos or vNormalW
  28760. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  28761. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  28762. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  28763. */
  28764. remappedVariables?: string[];
  28765. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  28766. standalone?: boolean;
  28767. }
  28768. /**
  28769. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  28770. */
  28771. export class ShadowDepthWrapper {
  28772. private _scene;
  28773. private _options?;
  28774. private _baseMaterial;
  28775. private _onEffectCreatedObserver;
  28776. private _subMeshToEffect;
  28777. private _subMeshToDepthEffect;
  28778. private _meshes;
  28779. /** @hidden */
  28780. _matriceNames: any;
  28781. /** Gets the standalone status of the wrapper */
  28782. get standalone(): boolean;
  28783. /** Gets the base material the wrapper is built upon */
  28784. get baseMaterial(): Material;
  28785. /**
  28786. * Instantiate a new shadow depth wrapper.
  28787. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  28788. * generate the shadow depth map. For more information, please refer to the documentation:
  28789. * https://doc.babylonjs.com/babylon101/shadows
  28790. * @param baseMaterial Material to wrap
  28791. * @param scene Define the scene the material belongs to
  28792. * @param options Options used to create the wrapper
  28793. */
  28794. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  28795. /**
  28796. * Gets the effect to use to generate the depth map
  28797. * @param subMesh subMesh to get the effect for
  28798. * @param shadowGenerator shadow generator to get the effect for
  28799. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  28800. */
  28801. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  28802. /**
  28803. * Specifies that the submesh is ready to be used for depth rendering
  28804. * @param subMesh submesh to check
  28805. * @param defines the list of defines to take into account when checking the effect
  28806. * @param shadowGenerator combined with subMesh, it defines the effect to check
  28807. * @param useInstances specifies that instances should be used
  28808. * @returns a boolean indicating that the submesh is ready or not
  28809. */
  28810. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  28811. /**
  28812. * Disposes the resources
  28813. */
  28814. dispose(): void;
  28815. private _makeEffect;
  28816. }
  28817. }
  28818. declare module BABYLON {
  28819. /**
  28820. * Options for compiling materials.
  28821. */
  28822. export interface IMaterialCompilationOptions {
  28823. /**
  28824. * Defines whether clip planes are enabled.
  28825. */
  28826. clipPlane: boolean;
  28827. /**
  28828. * Defines whether instances are enabled.
  28829. */
  28830. useInstances: boolean;
  28831. }
  28832. /**
  28833. * Options passed when calling customShaderNameResolve
  28834. */
  28835. export interface ICustomShaderNameResolveOptions {
  28836. /**
  28837. * 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
  28838. */
  28839. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  28840. }
  28841. /**
  28842. * Base class for the main features of a material in Babylon.js
  28843. */
  28844. export class Material implements IAnimatable {
  28845. /**
  28846. * Returns the triangle fill mode
  28847. */
  28848. static readonly TriangleFillMode: number;
  28849. /**
  28850. * Returns the wireframe mode
  28851. */
  28852. static readonly WireFrameFillMode: number;
  28853. /**
  28854. * Returns the point fill mode
  28855. */
  28856. static readonly PointFillMode: number;
  28857. /**
  28858. * Returns the point list draw mode
  28859. */
  28860. static readonly PointListDrawMode: number;
  28861. /**
  28862. * Returns the line list draw mode
  28863. */
  28864. static readonly LineListDrawMode: number;
  28865. /**
  28866. * Returns the line loop draw mode
  28867. */
  28868. static readonly LineLoopDrawMode: number;
  28869. /**
  28870. * Returns the line strip draw mode
  28871. */
  28872. static readonly LineStripDrawMode: number;
  28873. /**
  28874. * Returns the triangle strip draw mode
  28875. */
  28876. static readonly TriangleStripDrawMode: number;
  28877. /**
  28878. * Returns the triangle fan draw mode
  28879. */
  28880. static readonly TriangleFanDrawMode: number;
  28881. /**
  28882. * Stores the clock-wise side orientation
  28883. */
  28884. static readonly ClockWiseSideOrientation: number;
  28885. /**
  28886. * Stores the counter clock-wise side orientation
  28887. */
  28888. static readonly CounterClockWiseSideOrientation: number;
  28889. /**
  28890. * The dirty texture flag value
  28891. */
  28892. static readonly TextureDirtyFlag: number;
  28893. /**
  28894. * The dirty light flag value
  28895. */
  28896. static readonly LightDirtyFlag: number;
  28897. /**
  28898. * The dirty fresnel flag value
  28899. */
  28900. static readonly FresnelDirtyFlag: number;
  28901. /**
  28902. * The dirty attribute flag value
  28903. */
  28904. static readonly AttributesDirtyFlag: number;
  28905. /**
  28906. * The dirty misc flag value
  28907. */
  28908. static readonly MiscDirtyFlag: number;
  28909. /**
  28910. * The dirty prepass flag value
  28911. */
  28912. static readonly PrePassDirtyFlag: number;
  28913. /**
  28914. * The all dirty flag value
  28915. */
  28916. static readonly AllDirtyFlag: number;
  28917. /**
  28918. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  28919. */
  28920. static readonly MATERIAL_OPAQUE: number;
  28921. /**
  28922. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  28923. */
  28924. static readonly MATERIAL_ALPHATEST: number;
  28925. /**
  28926. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28927. */
  28928. static readonly MATERIAL_ALPHABLEND: number;
  28929. /**
  28930. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28931. * They are also discarded below the alpha cutoff threshold to improve performances.
  28932. */
  28933. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  28934. /**
  28935. * The Whiteout method is used to blend normals.
  28936. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28937. */
  28938. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  28939. /**
  28940. * The Reoriented Normal Mapping method is used to blend normals.
  28941. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28942. */
  28943. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  28944. /**
  28945. * Custom callback helping to override the default shader used in the material.
  28946. */
  28947. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  28948. /**
  28949. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  28950. */
  28951. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  28952. /**
  28953. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  28954. * This means that the material can keep using a previous shader while a new one is being compiled.
  28955. * This is mostly used when shader parallel compilation is supported (true by default)
  28956. */
  28957. allowShaderHotSwapping: boolean;
  28958. /**
  28959. * The ID of the material
  28960. */
  28961. id: string;
  28962. /**
  28963. * Gets or sets the unique id of the material
  28964. */
  28965. uniqueId: number;
  28966. /**
  28967. * The name of the material
  28968. */
  28969. name: string;
  28970. /**
  28971. * Gets or sets user defined metadata
  28972. */
  28973. metadata: any;
  28974. /**
  28975. * For internal use only. Please do not use.
  28976. */
  28977. reservedDataStore: any;
  28978. /**
  28979. * Specifies if the ready state should be checked on each call
  28980. */
  28981. checkReadyOnEveryCall: boolean;
  28982. /**
  28983. * Specifies if the ready state should be checked once
  28984. */
  28985. checkReadyOnlyOnce: boolean;
  28986. /**
  28987. * The state of the material
  28988. */
  28989. state: string;
  28990. /**
  28991. * If the material can be rendered to several textures with MRT extension
  28992. */
  28993. get canRenderToMRT(): boolean;
  28994. /**
  28995. * The alpha value of the material
  28996. */
  28997. protected _alpha: number;
  28998. /**
  28999. * List of inspectable custom properties (used by the Inspector)
  29000. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29001. */
  29002. inspectableCustomProperties: IInspectable[];
  29003. /**
  29004. * Sets the alpha value of the material
  29005. */
  29006. set alpha(value: number);
  29007. /**
  29008. * Gets the alpha value of the material
  29009. */
  29010. get alpha(): number;
  29011. /**
  29012. * Specifies if back face culling is enabled
  29013. */
  29014. protected _backFaceCulling: boolean;
  29015. /**
  29016. * Sets the back-face culling state
  29017. */
  29018. set backFaceCulling(value: boolean);
  29019. /**
  29020. * Gets the back-face culling state
  29021. */
  29022. get backFaceCulling(): boolean;
  29023. /**
  29024. * Stores the value for side orientation
  29025. */
  29026. sideOrientation: number;
  29027. /**
  29028. * Callback triggered when the material is compiled
  29029. */
  29030. onCompiled: Nullable<(effect: Effect) => void>;
  29031. /**
  29032. * Callback triggered when an error occurs
  29033. */
  29034. onError: Nullable<(effect: Effect, errors: string) => void>;
  29035. /**
  29036. * Callback triggered to get the render target textures
  29037. */
  29038. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29039. /**
  29040. * Gets a boolean indicating that current material needs to register RTT
  29041. */
  29042. get hasRenderTargetTextures(): boolean;
  29043. /**
  29044. * Specifies if the material should be serialized
  29045. */
  29046. doNotSerialize: boolean;
  29047. /**
  29048. * @hidden
  29049. */
  29050. _storeEffectOnSubMeshes: boolean;
  29051. /**
  29052. * Stores the animations for the material
  29053. */
  29054. animations: Nullable<Array<Animation>>;
  29055. /**
  29056. * An event triggered when the material is disposed
  29057. */
  29058. onDisposeObservable: Observable<Material>;
  29059. /**
  29060. * An observer which watches for dispose events
  29061. */
  29062. private _onDisposeObserver;
  29063. private _onUnBindObservable;
  29064. /**
  29065. * Called during a dispose event
  29066. */
  29067. set onDispose(callback: () => void);
  29068. private _onBindObservable;
  29069. /**
  29070. * An event triggered when the material is bound
  29071. */
  29072. get onBindObservable(): Observable<AbstractMesh>;
  29073. /**
  29074. * An observer which watches for bind events
  29075. */
  29076. private _onBindObserver;
  29077. /**
  29078. * Called during a bind event
  29079. */
  29080. set onBind(callback: (Mesh: AbstractMesh) => void);
  29081. /**
  29082. * An event triggered when the material is unbound
  29083. */
  29084. get onUnBindObservable(): Observable<Material>;
  29085. protected _onEffectCreatedObservable: Nullable<Observable<{
  29086. effect: Effect;
  29087. subMesh: Nullable<SubMesh>;
  29088. }>>;
  29089. /**
  29090. * An event triggered when the effect is (re)created
  29091. */
  29092. get onEffectCreatedObservable(): Observable<{
  29093. effect: Effect;
  29094. subMesh: Nullable<SubMesh>;
  29095. }>;
  29096. /**
  29097. * Stores the value of the alpha mode
  29098. */
  29099. private _alphaMode;
  29100. /**
  29101. * Sets the value of the alpha mode.
  29102. *
  29103. * | Value | Type | Description |
  29104. * | --- | --- | --- |
  29105. * | 0 | ALPHA_DISABLE | |
  29106. * | 1 | ALPHA_ADD | |
  29107. * | 2 | ALPHA_COMBINE | |
  29108. * | 3 | ALPHA_SUBTRACT | |
  29109. * | 4 | ALPHA_MULTIPLY | |
  29110. * | 5 | ALPHA_MAXIMIZED | |
  29111. * | 6 | ALPHA_ONEONE | |
  29112. * | 7 | ALPHA_PREMULTIPLIED | |
  29113. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29114. * | 9 | ALPHA_INTERPOLATE | |
  29115. * | 10 | ALPHA_SCREENMODE | |
  29116. *
  29117. */
  29118. set alphaMode(value: number);
  29119. /**
  29120. * Gets the value of the alpha mode
  29121. */
  29122. get alphaMode(): number;
  29123. /**
  29124. * Stores the state of the need depth pre-pass value
  29125. */
  29126. private _needDepthPrePass;
  29127. /**
  29128. * Sets the need depth pre-pass value
  29129. */
  29130. set needDepthPrePass(value: boolean);
  29131. /**
  29132. * Gets the depth pre-pass value
  29133. */
  29134. get needDepthPrePass(): boolean;
  29135. /**
  29136. * Specifies if depth writing should be disabled
  29137. */
  29138. disableDepthWrite: boolean;
  29139. /**
  29140. * Specifies if color writing should be disabled
  29141. */
  29142. disableColorWrite: boolean;
  29143. /**
  29144. * Specifies if depth writing should be forced
  29145. */
  29146. forceDepthWrite: boolean;
  29147. /**
  29148. * Specifies the depth function that should be used. 0 means the default engine function
  29149. */
  29150. depthFunction: number;
  29151. /**
  29152. * Specifies if there should be a separate pass for culling
  29153. */
  29154. separateCullingPass: boolean;
  29155. /**
  29156. * Stores the state specifing if fog should be enabled
  29157. */
  29158. private _fogEnabled;
  29159. /**
  29160. * Sets the state for enabling fog
  29161. */
  29162. set fogEnabled(value: boolean);
  29163. /**
  29164. * Gets the value of the fog enabled state
  29165. */
  29166. get fogEnabled(): boolean;
  29167. /**
  29168. * Stores the size of points
  29169. */
  29170. pointSize: number;
  29171. /**
  29172. * Stores the z offset value
  29173. */
  29174. zOffset: number;
  29175. get wireframe(): boolean;
  29176. /**
  29177. * Sets the state of wireframe mode
  29178. */
  29179. set wireframe(value: boolean);
  29180. /**
  29181. * Gets the value specifying if point clouds are enabled
  29182. */
  29183. get pointsCloud(): boolean;
  29184. /**
  29185. * Sets the state of point cloud mode
  29186. */
  29187. set pointsCloud(value: boolean);
  29188. /**
  29189. * Gets the material fill mode
  29190. */
  29191. get fillMode(): number;
  29192. /**
  29193. * Sets the material fill mode
  29194. */
  29195. set fillMode(value: number);
  29196. /**
  29197. * @hidden
  29198. * Stores the effects for the material
  29199. */
  29200. _effect: Nullable<Effect>;
  29201. /**
  29202. * Specifies if uniform buffers should be used
  29203. */
  29204. private _useUBO;
  29205. /**
  29206. * Stores a reference to the scene
  29207. */
  29208. private _scene;
  29209. /**
  29210. * Stores the fill mode state
  29211. */
  29212. private _fillMode;
  29213. /**
  29214. * Specifies if the depth write state should be cached
  29215. */
  29216. private _cachedDepthWriteState;
  29217. /**
  29218. * Specifies if the color write state should be cached
  29219. */
  29220. private _cachedColorWriteState;
  29221. /**
  29222. * Specifies if the depth function state should be cached
  29223. */
  29224. private _cachedDepthFunctionState;
  29225. /**
  29226. * Stores the uniform buffer
  29227. */
  29228. protected _uniformBuffer: UniformBuffer;
  29229. /** @hidden */
  29230. _indexInSceneMaterialArray: number;
  29231. /** @hidden */
  29232. meshMap: Nullable<{
  29233. [id: string]: AbstractMesh | undefined;
  29234. }>;
  29235. /**
  29236. * Creates a material instance
  29237. * @param name defines the name of the material
  29238. * @param scene defines the scene to reference
  29239. * @param doNotAdd specifies if the material should be added to the scene
  29240. */
  29241. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29242. /**
  29243. * Returns a string representation of the current material
  29244. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29245. * @returns a string with material information
  29246. */
  29247. toString(fullDetails?: boolean): string;
  29248. /**
  29249. * Gets the class name of the material
  29250. * @returns a string with the class name of the material
  29251. */
  29252. getClassName(): string;
  29253. /**
  29254. * Specifies if updates for the material been locked
  29255. */
  29256. get isFrozen(): boolean;
  29257. /**
  29258. * Locks updates for the material
  29259. */
  29260. freeze(): void;
  29261. /**
  29262. * Unlocks updates for the material
  29263. */
  29264. unfreeze(): void;
  29265. /**
  29266. * Specifies if the material is ready to be used
  29267. * @param mesh defines the mesh to check
  29268. * @param useInstances specifies if instances should be used
  29269. * @returns a boolean indicating if the material is ready to be used
  29270. */
  29271. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29272. /**
  29273. * Specifies that the submesh is ready to be used
  29274. * @param mesh defines the mesh to check
  29275. * @param subMesh defines which submesh to check
  29276. * @param useInstances specifies that instances should be used
  29277. * @returns a boolean indicating that the submesh is ready or not
  29278. */
  29279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29280. /**
  29281. * Returns the material effect
  29282. * @returns the effect associated with the material
  29283. */
  29284. getEffect(): Nullable<Effect>;
  29285. /**
  29286. * Returns the current scene
  29287. * @returns a Scene
  29288. */
  29289. getScene(): Scene;
  29290. /**
  29291. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29292. */
  29293. protected _forceAlphaTest: boolean;
  29294. /**
  29295. * The transparency mode of the material.
  29296. */
  29297. protected _transparencyMode: Nullable<number>;
  29298. /**
  29299. * Gets the current transparency mode.
  29300. */
  29301. get transparencyMode(): Nullable<number>;
  29302. /**
  29303. * Sets the transparency mode of the material.
  29304. *
  29305. * | Value | Type | Description |
  29306. * | ----- | ----------------------------------- | ----------- |
  29307. * | 0 | OPAQUE | |
  29308. * | 1 | ALPHATEST | |
  29309. * | 2 | ALPHABLEND | |
  29310. * | 3 | ALPHATESTANDBLEND | |
  29311. *
  29312. */
  29313. set transparencyMode(value: Nullable<number>);
  29314. /**
  29315. * Returns true if alpha blending should be disabled.
  29316. */
  29317. protected get _disableAlphaBlending(): boolean;
  29318. /**
  29319. * Specifies whether or not this material should be rendered in alpha blend mode.
  29320. * @returns a boolean specifying if alpha blending is needed
  29321. */
  29322. needAlphaBlending(): boolean;
  29323. /**
  29324. * Specifies if the mesh will require alpha blending
  29325. * @param mesh defines the mesh to check
  29326. * @returns a boolean specifying if alpha blending is needed for the mesh
  29327. */
  29328. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29329. /**
  29330. * Specifies whether or not this material should be rendered in alpha test mode.
  29331. * @returns a boolean specifying if an alpha test is needed.
  29332. */
  29333. needAlphaTesting(): boolean;
  29334. /**
  29335. * Specifies if material alpha testing should be turned on for the mesh
  29336. * @param mesh defines the mesh to check
  29337. */
  29338. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29339. /**
  29340. * Gets the texture used for the alpha test
  29341. * @returns the texture to use for alpha testing
  29342. */
  29343. getAlphaTestTexture(): Nullable<BaseTexture>;
  29344. /**
  29345. * Marks the material to indicate that it needs to be re-calculated
  29346. */
  29347. markDirty(): void;
  29348. /** @hidden */
  29349. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29350. /**
  29351. * Binds the material to the mesh
  29352. * @param world defines the world transformation matrix
  29353. * @param mesh defines the mesh to bind the material to
  29354. */
  29355. bind(world: Matrix, mesh?: Mesh): void;
  29356. /**
  29357. * Binds the submesh to the material
  29358. * @param world defines the world transformation matrix
  29359. * @param mesh defines the mesh containing the submesh
  29360. * @param subMesh defines the submesh to bind the material to
  29361. */
  29362. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29363. /**
  29364. * Binds the world matrix to the material
  29365. * @param world defines the world transformation matrix
  29366. */
  29367. bindOnlyWorldMatrix(world: Matrix): void;
  29368. /**
  29369. * Binds the scene's uniform buffer to the effect.
  29370. * @param effect defines the effect to bind to the scene uniform buffer
  29371. * @param sceneUbo defines the uniform buffer storing scene data
  29372. */
  29373. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29374. /**
  29375. * Binds the view matrix to the effect
  29376. * @param effect defines the effect to bind the view matrix to
  29377. */
  29378. bindView(effect: Effect): void;
  29379. /**
  29380. * Binds the view projection matrix to the effect
  29381. * @param effect defines the effect to bind the view projection matrix to
  29382. */
  29383. bindViewProjection(effect: Effect): void;
  29384. /**
  29385. * Processes to execute after binding the material to a mesh
  29386. * @param mesh defines the rendered mesh
  29387. */
  29388. protected _afterBind(mesh?: Mesh): void;
  29389. /**
  29390. * Unbinds the material from the mesh
  29391. */
  29392. unbind(): void;
  29393. /**
  29394. * Gets the active textures from the material
  29395. * @returns an array of textures
  29396. */
  29397. getActiveTextures(): BaseTexture[];
  29398. /**
  29399. * Specifies if the material uses a texture
  29400. * @param texture defines the texture to check against the material
  29401. * @returns a boolean specifying if the material uses the texture
  29402. */
  29403. hasTexture(texture: BaseTexture): boolean;
  29404. /**
  29405. * Makes a duplicate of the material, and gives it a new name
  29406. * @param name defines the new name for the duplicated material
  29407. * @returns the cloned material
  29408. */
  29409. clone(name: string): Nullable<Material>;
  29410. /**
  29411. * Gets the meshes bound to the material
  29412. * @returns an array of meshes bound to the material
  29413. */
  29414. getBindedMeshes(): AbstractMesh[];
  29415. /**
  29416. * Force shader compilation
  29417. * @param mesh defines the mesh associated with this material
  29418. * @param onCompiled defines a function to execute once the material is compiled
  29419. * @param options defines the options to configure the compilation
  29420. * @param onError defines a function to execute if the material fails compiling
  29421. */
  29422. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29423. /**
  29424. * Force shader compilation
  29425. * @param mesh defines the mesh that will use this material
  29426. * @param options defines additional options for compiling the shaders
  29427. * @returns a promise that resolves when the compilation completes
  29428. */
  29429. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29430. private static readonly _AllDirtyCallBack;
  29431. private static readonly _ImageProcessingDirtyCallBack;
  29432. private static readonly _TextureDirtyCallBack;
  29433. private static readonly _FresnelDirtyCallBack;
  29434. private static readonly _MiscDirtyCallBack;
  29435. private static readonly _PrePassDirtyCallBack;
  29436. private static readonly _LightsDirtyCallBack;
  29437. private static readonly _AttributeDirtyCallBack;
  29438. private static _FresnelAndMiscDirtyCallBack;
  29439. private static _TextureAndMiscDirtyCallBack;
  29440. private static readonly _DirtyCallbackArray;
  29441. private static readonly _RunDirtyCallBacks;
  29442. /**
  29443. * Marks a define in the material to indicate that it needs to be re-computed
  29444. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29445. */
  29446. markAsDirty(flag: number): void;
  29447. /**
  29448. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29449. * @param func defines a function which checks material defines against the submeshes
  29450. */
  29451. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29452. /**
  29453. * Indicates that the scene should check if the rendering now needs a prepass
  29454. */
  29455. protected _markScenePrePassDirty(): void;
  29456. /**
  29457. * Indicates that we need to re-calculated for all submeshes
  29458. */
  29459. protected _markAllSubMeshesAsAllDirty(): void;
  29460. /**
  29461. * Indicates that image processing needs to be re-calculated for all submeshes
  29462. */
  29463. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29464. /**
  29465. * Indicates that textures need to be re-calculated for all submeshes
  29466. */
  29467. protected _markAllSubMeshesAsTexturesDirty(): void;
  29468. /**
  29469. * Indicates that fresnel needs to be re-calculated for all submeshes
  29470. */
  29471. protected _markAllSubMeshesAsFresnelDirty(): void;
  29472. /**
  29473. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29474. */
  29475. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29476. /**
  29477. * Indicates that lights need to be re-calculated for all submeshes
  29478. */
  29479. protected _markAllSubMeshesAsLightsDirty(): void;
  29480. /**
  29481. * Indicates that attributes need to be re-calculated for all submeshes
  29482. */
  29483. protected _markAllSubMeshesAsAttributesDirty(): void;
  29484. /**
  29485. * Indicates that misc needs to be re-calculated for all submeshes
  29486. */
  29487. protected _markAllSubMeshesAsMiscDirty(): void;
  29488. /**
  29489. * Indicates that prepass needs to be re-calculated for all submeshes
  29490. */
  29491. protected _markAllSubMeshesAsPrePassDirty(): void;
  29492. /**
  29493. * Indicates that textures and misc need to be re-calculated for all submeshes
  29494. */
  29495. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29496. /**
  29497. * Sets the required values to the prepass renderer.
  29498. * @param prePassRenderer defines the prepass renderer to setup.
  29499. * @returns true if the pre pass is needed.
  29500. */
  29501. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29502. /**
  29503. * Disposes the material
  29504. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29505. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29506. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29507. */
  29508. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29509. /** @hidden */
  29510. private releaseVertexArrayObject;
  29511. /**
  29512. * Serializes this material
  29513. * @returns the serialized material object
  29514. */
  29515. serialize(): any;
  29516. /**
  29517. * Creates a material from parsed material data
  29518. * @param parsedMaterial defines parsed material data
  29519. * @param scene defines the hosting scene
  29520. * @param rootUrl defines the root URL to use to load textures
  29521. * @returns a new material
  29522. */
  29523. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29524. }
  29525. }
  29526. declare module BABYLON {
  29527. /**
  29528. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29529. * separate meshes. This can be use to improve performances.
  29530. * @see https://doc.babylonjs.com/how_to/multi_materials
  29531. */
  29532. export class MultiMaterial extends Material {
  29533. private _subMaterials;
  29534. /**
  29535. * Gets or Sets the list of Materials used within the multi material.
  29536. * They need to be ordered according to the submeshes order in the associated mesh
  29537. */
  29538. get subMaterials(): Nullable<Material>[];
  29539. set subMaterials(value: Nullable<Material>[]);
  29540. /**
  29541. * Function used to align with Node.getChildren()
  29542. * @returns the list of Materials used within the multi material
  29543. */
  29544. getChildren(): Nullable<Material>[];
  29545. /**
  29546. * Instantiates a new Multi Material
  29547. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29548. * separate meshes. This can be use to improve performances.
  29549. * @see https://doc.babylonjs.com/how_to/multi_materials
  29550. * @param name Define the name in the scene
  29551. * @param scene Define the scene the material belongs to
  29552. */
  29553. constructor(name: string, scene: Scene);
  29554. private _hookArray;
  29555. /**
  29556. * Get one of the submaterial by its index in the submaterials array
  29557. * @param index The index to look the sub material at
  29558. * @returns The Material if the index has been defined
  29559. */
  29560. getSubMaterial(index: number): Nullable<Material>;
  29561. /**
  29562. * Get the list of active textures for the whole sub materials list.
  29563. * @returns All the textures that will be used during the rendering
  29564. */
  29565. getActiveTextures(): BaseTexture[];
  29566. /**
  29567. * Gets the current class name of the material e.g. "MultiMaterial"
  29568. * Mainly use in serialization.
  29569. * @returns the class name
  29570. */
  29571. getClassName(): string;
  29572. /**
  29573. * Checks if the material is ready to render the requested sub mesh
  29574. * @param mesh Define the mesh the submesh belongs to
  29575. * @param subMesh Define the sub mesh to look readyness for
  29576. * @param useInstances Define whether or not the material is used with instances
  29577. * @returns true if ready, otherwise false
  29578. */
  29579. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29580. /**
  29581. * Clones the current material and its related sub materials
  29582. * @param name Define the name of the newly cloned material
  29583. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29584. * @returns the cloned material
  29585. */
  29586. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29587. /**
  29588. * Serializes the materials into a JSON representation.
  29589. * @returns the JSON representation
  29590. */
  29591. serialize(): any;
  29592. /**
  29593. * Dispose the material and release its associated resources
  29594. * @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)
  29595. * @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)
  29596. * @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)
  29597. */
  29598. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29599. /**
  29600. * Creates a MultiMaterial from parsed MultiMaterial data.
  29601. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29602. * @param scene defines the hosting scene
  29603. * @returns a new MultiMaterial
  29604. */
  29605. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29606. }
  29607. }
  29608. declare module BABYLON {
  29609. /**
  29610. * Defines a subdivision inside a mesh
  29611. */
  29612. export class SubMesh implements ICullable {
  29613. /** the material index to use */
  29614. materialIndex: number;
  29615. /** vertex index start */
  29616. verticesStart: number;
  29617. /** vertices count */
  29618. verticesCount: number;
  29619. /** index start */
  29620. indexStart: number;
  29621. /** indices count */
  29622. indexCount: number;
  29623. /** @hidden */
  29624. _materialDefines: Nullable<MaterialDefines>;
  29625. /** @hidden */
  29626. _materialEffect: Nullable<Effect>;
  29627. /** @hidden */
  29628. _effectOverride: Nullable<Effect>;
  29629. /**
  29630. * Gets material defines used by the effect associated to the sub mesh
  29631. */
  29632. get materialDefines(): Nullable<MaterialDefines>;
  29633. /**
  29634. * Sets material defines used by the effect associated to the sub mesh
  29635. */
  29636. set materialDefines(defines: Nullable<MaterialDefines>);
  29637. /**
  29638. * Gets associated effect
  29639. */
  29640. get effect(): Nullable<Effect>;
  29641. /**
  29642. * Sets associated effect (effect used to render this submesh)
  29643. * @param effect defines the effect to associate with
  29644. * @param defines defines the set of defines used to compile this effect
  29645. */
  29646. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29647. /** @hidden */
  29648. _linesIndexCount: number;
  29649. private _mesh;
  29650. private _renderingMesh;
  29651. private _boundingInfo;
  29652. private _linesIndexBuffer;
  29653. /** @hidden */
  29654. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29655. /** @hidden */
  29656. _trianglePlanes: Plane[];
  29657. /** @hidden */
  29658. _lastColliderTransformMatrix: Nullable<Matrix>;
  29659. /** @hidden */
  29660. _renderId: number;
  29661. /** @hidden */
  29662. _alphaIndex: number;
  29663. /** @hidden */
  29664. _distanceToCamera: number;
  29665. /** @hidden */
  29666. _id: number;
  29667. private _currentMaterial;
  29668. /**
  29669. * Add a new submesh to a mesh
  29670. * @param materialIndex defines the material index to use
  29671. * @param verticesStart defines vertex index start
  29672. * @param verticesCount defines vertices count
  29673. * @param indexStart defines index start
  29674. * @param indexCount defines indices count
  29675. * @param mesh defines the parent mesh
  29676. * @param renderingMesh defines an optional rendering mesh
  29677. * @param createBoundingBox defines if bounding box should be created for this submesh
  29678. * @returns the new submesh
  29679. */
  29680. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29681. /**
  29682. * Creates a new submesh
  29683. * @param materialIndex defines the material index to use
  29684. * @param verticesStart defines vertex index start
  29685. * @param verticesCount defines vertices count
  29686. * @param indexStart defines index start
  29687. * @param indexCount defines indices count
  29688. * @param mesh defines the parent mesh
  29689. * @param renderingMesh defines an optional rendering mesh
  29690. * @param createBoundingBox defines if bounding box should be created for this submesh
  29691. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29692. */
  29693. constructor(
  29694. /** the material index to use */
  29695. materialIndex: number,
  29696. /** vertex index start */
  29697. verticesStart: number,
  29698. /** vertices count */
  29699. verticesCount: number,
  29700. /** index start */
  29701. indexStart: number,
  29702. /** indices count */
  29703. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29704. /**
  29705. * Returns true if this submesh covers the entire parent mesh
  29706. * @ignorenaming
  29707. */
  29708. get IsGlobal(): boolean;
  29709. /**
  29710. * Returns the submesh BoudingInfo object
  29711. * @returns current bounding info (or mesh's one if the submesh is global)
  29712. */
  29713. getBoundingInfo(): BoundingInfo;
  29714. /**
  29715. * Sets the submesh BoundingInfo
  29716. * @param boundingInfo defines the new bounding info to use
  29717. * @returns the SubMesh
  29718. */
  29719. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29720. /**
  29721. * Returns the mesh of the current submesh
  29722. * @return the parent mesh
  29723. */
  29724. getMesh(): AbstractMesh;
  29725. /**
  29726. * Returns the rendering mesh of the submesh
  29727. * @returns the rendering mesh (could be different from parent mesh)
  29728. */
  29729. getRenderingMesh(): Mesh;
  29730. /**
  29731. * Returns the replacement mesh of the submesh
  29732. * @returns the replacement mesh (could be different from parent mesh)
  29733. */
  29734. getReplacementMesh(): Nullable<AbstractMesh>;
  29735. /**
  29736. * Returns the effective mesh of the submesh
  29737. * @returns the effective mesh (could be different from parent mesh)
  29738. */
  29739. getEffectiveMesh(): AbstractMesh;
  29740. /**
  29741. * Returns the submesh material
  29742. * @returns null or the current material
  29743. */
  29744. getMaterial(): Nullable<Material>;
  29745. private _IsMultiMaterial;
  29746. /**
  29747. * Sets a new updated BoundingInfo object to the submesh
  29748. * @param data defines an optional position array to use to determine the bounding info
  29749. * @returns the SubMesh
  29750. */
  29751. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  29752. /** @hidden */
  29753. _checkCollision(collider: Collider): boolean;
  29754. /**
  29755. * Updates the submesh BoundingInfo
  29756. * @param world defines the world matrix to use to update the bounding info
  29757. * @returns the submesh
  29758. */
  29759. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29760. /**
  29761. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29762. * @param frustumPlanes defines the frustum planes
  29763. * @returns true if the submesh is intersecting with the frustum
  29764. */
  29765. isInFrustum(frustumPlanes: Plane[]): boolean;
  29766. /**
  29767. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29768. * @param frustumPlanes defines the frustum planes
  29769. * @returns true if the submesh is inside the frustum
  29770. */
  29771. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29772. /**
  29773. * Renders the submesh
  29774. * @param enableAlphaMode defines if alpha needs to be used
  29775. * @returns the submesh
  29776. */
  29777. render(enableAlphaMode: boolean): SubMesh;
  29778. /**
  29779. * @hidden
  29780. */
  29781. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  29782. /**
  29783. * Checks if the submesh intersects with a ray
  29784. * @param ray defines the ray to test
  29785. * @returns true is the passed ray intersects the submesh bounding box
  29786. */
  29787. canIntersects(ray: Ray): boolean;
  29788. /**
  29789. * Intersects current submesh with a ray
  29790. * @param ray defines the ray to test
  29791. * @param positions defines mesh's positions array
  29792. * @param indices defines mesh's indices array
  29793. * @param fastCheck defines if the first intersection will be used (and not the closest)
  29794. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29795. * @returns intersection info or null if no intersection
  29796. */
  29797. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  29798. /** @hidden */
  29799. private _intersectLines;
  29800. /** @hidden */
  29801. private _intersectUnIndexedLines;
  29802. /** @hidden */
  29803. private _intersectTriangles;
  29804. /** @hidden */
  29805. private _intersectUnIndexedTriangles;
  29806. /** @hidden */
  29807. _rebuild(): void;
  29808. /**
  29809. * Creates a new submesh from the passed mesh
  29810. * @param newMesh defines the new hosting mesh
  29811. * @param newRenderingMesh defines an optional rendering mesh
  29812. * @returns the new submesh
  29813. */
  29814. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29815. /**
  29816. * Release associated resources
  29817. */
  29818. dispose(): void;
  29819. /**
  29820. * Gets the class name
  29821. * @returns the string "SubMesh".
  29822. */
  29823. getClassName(): string;
  29824. /**
  29825. * Creates a new submesh from indices data
  29826. * @param materialIndex the index of the main mesh material
  29827. * @param startIndex the index where to start the copy in the mesh indices array
  29828. * @param indexCount the number of indices to copy then from the startIndex
  29829. * @param mesh the main mesh to create the submesh from
  29830. * @param renderingMesh the optional rendering mesh
  29831. * @returns a new submesh
  29832. */
  29833. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29834. }
  29835. }
  29836. declare module BABYLON {
  29837. /**
  29838. * Class used to represent data loading progression
  29839. */
  29840. export class SceneLoaderFlags {
  29841. private static _ForceFullSceneLoadingForIncremental;
  29842. private static _ShowLoadingScreen;
  29843. private static _CleanBoneMatrixWeights;
  29844. private static _loggingLevel;
  29845. /**
  29846. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  29847. */
  29848. static get ForceFullSceneLoadingForIncremental(): boolean;
  29849. static set ForceFullSceneLoadingForIncremental(value: boolean);
  29850. /**
  29851. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  29852. */
  29853. static get ShowLoadingScreen(): boolean;
  29854. static set ShowLoadingScreen(value: boolean);
  29855. /**
  29856. * Defines the current logging level (while loading the scene)
  29857. * @ignorenaming
  29858. */
  29859. static get loggingLevel(): number;
  29860. static set loggingLevel(value: number);
  29861. /**
  29862. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  29863. */
  29864. static get CleanBoneMatrixWeights(): boolean;
  29865. static set CleanBoneMatrixWeights(value: boolean);
  29866. }
  29867. }
  29868. declare module BABYLON {
  29869. /**
  29870. * Class used to store geometry data (vertex buffers + index buffer)
  29871. */
  29872. export class Geometry implements IGetSetVerticesData {
  29873. /**
  29874. * Gets or sets the ID of the geometry
  29875. */
  29876. id: string;
  29877. /**
  29878. * Gets or sets the unique ID of the geometry
  29879. */
  29880. uniqueId: number;
  29881. /**
  29882. * Gets the delay loading state of the geometry (none by default which means not delayed)
  29883. */
  29884. delayLoadState: number;
  29885. /**
  29886. * Gets the file containing the data to load when running in delay load state
  29887. */
  29888. delayLoadingFile: Nullable<string>;
  29889. /**
  29890. * Callback called when the geometry is updated
  29891. */
  29892. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  29893. private _scene;
  29894. private _engine;
  29895. private _meshes;
  29896. private _totalVertices;
  29897. /** @hidden */
  29898. _indices: IndicesArray;
  29899. /** @hidden */
  29900. _vertexBuffers: {
  29901. [key: string]: VertexBuffer;
  29902. };
  29903. private _isDisposed;
  29904. private _extend;
  29905. private _boundingBias;
  29906. /** @hidden */
  29907. _delayInfo: Array<string>;
  29908. private _indexBuffer;
  29909. private _indexBufferIsUpdatable;
  29910. /** @hidden */
  29911. _boundingInfo: Nullable<BoundingInfo>;
  29912. /** @hidden */
  29913. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  29914. /** @hidden */
  29915. _softwareSkinningFrameId: number;
  29916. private _vertexArrayObjects;
  29917. private _updatable;
  29918. /** @hidden */
  29919. _positions: Nullable<Vector3[]>;
  29920. private _positionsCache;
  29921. /**
  29922. * 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
  29923. */
  29924. get boundingBias(): Vector2;
  29925. /**
  29926. * 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
  29927. */
  29928. set boundingBias(value: Vector2);
  29929. /**
  29930. * Static function used to attach a new empty geometry to a mesh
  29931. * @param mesh defines the mesh to attach the geometry to
  29932. * @returns the new Geometry
  29933. */
  29934. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  29935. /** Get the list of meshes using this geometry */
  29936. get meshes(): Mesh[];
  29937. /**
  29938. * 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
  29939. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  29940. */
  29941. useBoundingInfoFromGeometry: boolean;
  29942. /**
  29943. * Creates a new geometry
  29944. * @param id defines the unique ID
  29945. * @param scene defines the hosting scene
  29946. * @param vertexData defines the VertexData used to get geometry data
  29947. * @param updatable defines if geometry must be updatable (false by default)
  29948. * @param mesh defines the mesh that will be associated with the geometry
  29949. */
  29950. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  29951. /**
  29952. * Gets the current extend of the geometry
  29953. */
  29954. get extend(): {
  29955. minimum: Vector3;
  29956. maximum: Vector3;
  29957. };
  29958. /**
  29959. * Gets the hosting scene
  29960. * @returns the hosting Scene
  29961. */
  29962. getScene(): Scene;
  29963. /**
  29964. * Gets the hosting engine
  29965. * @returns the hosting Engine
  29966. */
  29967. getEngine(): Engine;
  29968. /**
  29969. * Defines if the geometry is ready to use
  29970. * @returns true if the geometry is ready to be used
  29971. */
  29972. isReady(): boolean;
  29973. /**
  29974. * Gets a value indicating that the geometry should not be serialized
  29975. */
  29976. get doNotSerialize(): boolean;
  29977. /** @hidden */
  29978. _rebuild(): void;
  29979. /**
  29980. * Affects all geometry data in one call
  29981. * @param vertexData defines the geometry data
  29982. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  29983. */
  29984. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  29985. /**
  29986. * Set specific vertex data
  29987. * @param kind defines the data kind (Position, normal, etc...)
  29988. * @param data defines the vertex data to use
  29989. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  29990. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  29991. */
  29992. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  29993. /**
  29994. * Removes a specific vertex data
  29995. * @param kind defines the data kind (Position, normal, etc...)
  29996. */
  29997. removeVerticesData(kind: string): void;
  29998. /**
  29999. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30000. * @param buffer defines the vertex buffer to use
  30001. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30002. */
  30003. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30004. /**
  30005. * Update a specific vertex buffer
  30006. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30007. * It will do nothing if the buffer is not updatable
  30008. * @param kind defines the data kind (Position, normal, etc...)
  30009. * @param data defines the data to use
  30010. * @param offset defines the offset in the target buffer where to store the data
  30011. * @param useBytes set to true if the offset is in bytes
  30012. */
  30013. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30014. /**
  30015. * Update a specific vertex buffer
  30016. * This function will create a new buffer if the current one is not updatable
  30017. * @param kind defines the data kind (Position, normal, etc...)
  30018. * @param data defines the data to use
  30019. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30020. */
  30021. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30022. private _updateBoundingInfo;
  30023. /** @hidden */
  30024. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30025. /**
  30026. * Gets total number of vertices
  30027. * @returns the total number of vertices
  30028. */
  30029. getTotalVertices(): number;
  30030. /**
  30031. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30032. * @param kind defines the data kind (Position, normal, etc...)
  30033. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30034. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30035. * @returns a float array containing vertex data
  30036. */
  30037. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30038. /**
  30039. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30040. * @param kind defines the data kind (Position, normal, etc...)
  30041. * @returns true if the vertex buffer with the specified kind is updatable
  30042. */
  30043. isVertexBufferUpdatable(kind: string): boolean;
  30044. /**
  30045. * Gets a specific vertex buffer
  30046. * @param kind defines the data kind (Position, normal, etc...)
  30047. * @returns a VertexBuffer
  30048. */
  30049. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30050. /**
  30051. * Returns all vertex buffers
  30052. * @return an object holding all vertex buffers indexed by kind
  30053. */
  30054. getVertexBuffers(): Nullable<{
  30055. [key: string]: VertexBuffer;
  30056. }>;
  30057. /**
  30058. * Gets a boolean indicating if specific vertex buffer is present
  30059. * @param kind defines the data kind (Position, normal, etc...)
  30060. * @returns true if data is present
  30061. */
  30062. isVerticesDataPresent(kind: string): boolean;
  30063. /**
  30064. * Gets a list of all attached data kinds (Position, normal, etc...)
  30065. * @returns a list of string containing all kinds
  30066. */
  30067. getVerticesDataKinds(): string[];
  30068. /**
  30069. * Update index buffer
  30070. * @param indices defines the indices to store in the index buffer
  30071. * @param offset defines the offset in the target buffer where to store the data
  30072. * @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)
  30073. */
  30074. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30075. /**
  30076. * Creates a new index buffer
  30077. * @param indices defines the indices to store in the index buffer
  30078. * @param totalVertices defines the total number of vertices (could be null)
  30079. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30080. */
  30081. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30082. /**
  30083. * Return the total number of indices
  30084. * @returns the total number of indices
  30085. */
  30086. getTotalIndices(): number;
  30087. /**
  30088. * Gets the index buffer array
  30089. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30090. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30091. * @returns the index buffer array
  30092. */
  30093. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30094. /**
  30095. * Gets the index buffer
  30096. * @return the index buffer
  30097. */
  30098. getIndexBuffer(): Nullable<DataBuffer>;
  30099. /** @hidden */
  30100. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30101. /**
  30102. * Release the associated resources for a specific mesh
  30103. * @param mesh defines the source mesh
  30104. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30105. */
  30106. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30107. /**
  30108. * Apply current geometry to a given mesh
  30109. * @param mesh defines the mesh to apply geometry to
  30110. */
  30111. applyToMesh(mesh: Mesh): void;
  30112. private _updateExtend;
  30113. private _applyToMesh;
  30114. private notifyUpdate;
  30115. /**
  30116. * Load the geometry if it was flagged as delay loaded
  30117. * @param scene defines the hosting scene
  30118. * @param onLoaded defines a callback called when the geometry is loaded
  30119. */
  30120. load(scene: Scene, onLoaded?: () => void): void;
  30121. private _queueLoad;
  30122. /**
  30123. * Invert the geometry to move from a right handed system to a left handed one.
  30124. */
  30125. toLeftHanded(): void;
  30126. /** @hidden */
  30127. _resetPointsArrayCache(): void;
  30128. /** @hidden */
  30129. _generatePointsArray(): boolean;
  30130. /**
  30131. * Gets a value indicating if the geometry is disposed
  30132. * @returns true if the geometry was disposed
  30133. */
  30134. isDisposed(): boolean;
  30135. private _disposeVertexArrayObjects;
  30136. /**
  30137. * Free all associated resources
  30138. */
  30139. dispose(): void;
  30140. /**
  30141. * Clone the current geometry into a new geometry
  30142. * @param id defines the unique ID of the new geometry
  30143. * @returns a new geometry object
  30144. */
  30145. copy(id: string): Geometry;
  30146. /**
  30147. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30148. * @return a JSON representation of the current geometry data (without the vertices data)
  30149. */
  30150. serialize(): any;
  30151. private toNumberArray;
  30152. /**
  30153. * Serialize all vertices data into a JSON oject
  30154. * @returns a JSON representation of the current geometry data
  30155. */
  30156. serializeVerticeData(): any;
  30157. /**
  30158. * Extracts a clone of a mesh geometry
  30159. * @param mesh defines the source mesh
  30160. * @param id defines the unique ID of the new geometry object
  30161. * @returns the new geometry object
  30162. */
  30163. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30164. /**
  30165. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30166. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30167. * Be aware Math.random() could cause collisions, but:
  30168. * "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"
  30169. * @returns a string containing a new GUID
  30170. */
  30171. static RandomId(): string;
  30172. /** @hidden */
  30173. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30174. private static _CleanMatricesWeights;
  30175. /**
  30176. * Create a new geometry from persisted data (Using .babylon file format)
  30177. * @param parsedVertexData defines the persisted data
  30178. * @param scene defines the hosting scene
  30179. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30180. * @returns the new geometry object
  30181. */
  30182. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30183. }
  30184. }
  30185. declare module BABYLON {
  30186. /**
  30187. * Define an interface for all classes that will get and set the data on vertices
  30188. */
  30189. export interface IGetSetVerticesData {
  30190. /**
  30191. * Gets a boolean indicating if specific vertex data is present
  30192. * @param kind defines the vertex data kind to use
  30193. * @returns true is data kind is present
  30194. */
  30195. isVerticesDataPresent(kind: string): boolean;
  30196. /**
  30197. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30198. * @param kind defines the data kind (Position, normal, etc...)
  30199. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30200. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30201. * @returns a float array containing vertex data
  30202. */
  30203. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30204. /**
  30205. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30206. * @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.
  30207. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30208. * @returns the indices array or an empty array if the mesh has no geometry
  30209. */
  30210. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30211. /**
  30212. * Set specific vertex data
  30213. * @param kind defines the data kind (Position, normal, etc...)
  30214. * @param data defines the vertex data to use
  30215. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30216. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30217. */
  30218. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30219. /**
  30220. * Update a specific associated vertex buffer
  30221. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30222. * - VertexBuffer.PositionKind
  30223. * - VertexBuffer.UVKind
  30224. * - VertexBuffer.UV2Kind
  30225. * - VertexBuffer.UV3Kind
  30226. * - VertexBuffer.UV4Kind
  30227. * - VertexBuffer.UV5Kind
  30228. * - VertexBuffer.UV6Kind
  30229. * - VertexBuffer.ColorKind
  30230. * - VertexBuffer.MatricesIndicesKind
  30231. * - VertexBuffer.MatricesIndicesExtraKind
  30232. * - VertexBuffer.MatricesWeightsKind
  30233. * - VertexBuffer.MatricesWeightsExtraKind
  30234. * @param data defines the data source
  30235. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30236. * @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)
  30237. */
  30238. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30239. /**
  30240. * Creates a new index buffer
  30241. * @param indices defines the indices to store in the index buffer
  30242. * @param totalVertices defines the total number of vertices (could be null)
  30243. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30244. */
  30245. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30246. }
  30247. /**
  30248. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30249. */
  30250. export class VertexData {
  30251. /**
  30252. * Mesh side orientation : usually the external or front surface
  30253. */
  30254. static readonly FRONTSIDE: number;
  30255. /**
  30256. * Mesh side orientation : usually the internal or back surface
  30257. */
  30258. static readonly BACKSIDE: number;
  30259. /**
  30260. * Mesh side orientation : both internal and external or front and back surfaces
  30261. */
  30262. static readonly DOUBLESIDE: number;
  30263. /**
  30264. * Mesh side orientation : by default, `FRONTSIDE`
  30265. */
  30266. static readonly DEFAULTSIDE: number;
  30267. /**
  30268. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30269. */
  30270. positions: Nullable<FloatArray>;
  30271. /**
  30272. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30273. */
  30274. normals: Nullable<FloatArray>;
  30275. /**
  30276. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30277. */
  30278. tangents: Nullable<FloatArray>;
  30279. /**
  30280. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30281. */
  30282. uvs: Nullable<FloatArray>;
  30283. /**
  30284. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30285. */
  30286. uvs2: Nullable<FloatArray>;
  30287. /**
  30288. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30289. */
  30290. uvs3: Nullable<FloatArray>;
  30291. /**
  30292. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30293. */
  30294. uvs4: Nullable<FloatArray>;
  30295. /**
  30296. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30297. */
  30298. uvs5: Nullable<FloatArray>;
  30299. /**
  30300. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30301. */
  30302. uvs6: Nullable<FloatArray>;
  30303. /**
  30304. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30305. */
  30306. colors: Nullable<FloatArray>;
  30307. /**
  30308. * 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).
  30309. */
  30310. matricesIndices: Nullable<FloatArray>;
  30311. /**
  30312. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30313. */
  30314. matricesWeights: Nullable<FloatArray>;
  30315. /**
  30316. * An array extending the number of possible indices
  30317. */
  30318. matricesIndicesExtra: Nullable<FloatArray>;
  30319. /**
  30320. * An array extending the number of possible weights when the number of indices is extended
  30321. */
  30322. matricesWeightsExtra: Nullable<FloatArray>;
  30323. /**
  30324. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30325. */
  30326. indices: Nullable<IndicesArray>;
  30327. /**
  30328. * Uses the passed data array to set the set the values for the specified kind of data
  30329. * @param data a linear array of floating numbers
  30330. * @param kind the type of data that is being set, eg positions, colors etc
  30331. */
  30332. set(data: FloatArray, kind: string): void;
  30333. /**
  30334. * Associates the vertexData to the passed Mesh.
  30335. * Sets it as updatable or not (default `false`)
  30336. * @param mesh the mesh the vertexData is applied to
  30337. * @param updatable when used and having the value true allows new data to update the vertexData
  30338. * @returns the VertexData
  30339. */
  30340. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30341. /**
  30342. * Associates the vertexData to the passed Geometry.
  30343. * Sets it as updatable or not (default `false`)
  30344. * @param geometry the geometry the vertexData is applied to
  30345. * @param updatable when used and having the value true allows new data to update the vertexData
  30346. * @returns VertexData
  30347. */
  30348. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30349. /**
  30350. * Updates the associated mesh
  30351. * @param mesh the mesh to be updated
  30352. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30353. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  30354. * @returns VertexData
  30355. */
  30356. updateMesh(mesh: Mesh): VertexData;
  30357. /**
  30358. * Updates the associated geometry
  30359. * @param geometry the geometry to be updated
  30360. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30361. * @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
  30362. * @returns VertexData.
  30363. */
  30364. updateGeometry(geometry: Geometry): VertexData;
  30365. private _applyTo;
  30366. private _update;
  30367. /**
  30368. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30369. * @param matrix the transforming matrix
  30370. * @returns the VertexData
  30371. */
  30372. transform(matrix: Matrix): VertexData;
  30373. /**
  30374. * Merges the passed VertexData into the current one
  30375. * @param other the VertexData to be merged into the current one
  30376. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30377. * @returns the modified VertexData
  30378. */
  30379. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30380. private _mergeElement;
  30381. private _validate;
  30382. /**
  30383. * Serializes the VertexData
  30384. * @returns a serialized object
  30385. */
  30386. serialize(): any;
  30387. /**
  30388. * Extracts the vertexData from a mesh
  30389. * @param mesh the mesh from which to extract the VertexData
  30390. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30391. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30392. * @returns the object VertexData associated to the passed mesh
  30393. */
  30394. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30395. /**
  30396. * Extracts the vertexData from the geometry
  30397. * @param geometry the geometry from which to extract the VertexData
  30398. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30399. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30400. * @returns the object VertexData associated to the passed mesh
  30401. */
  30402. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30403. private static _ExtractFrom;
  30404. /**
  30405. * Creates the VertexData for a Ribbon
  30406. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30407. * * pathArray array of paths, each of which an array of successive Vector3
  30408. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30409. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30410. * * 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
  30411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30412. * * 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)
  30413. * * 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)
  30414. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30415. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30416. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30417. * @returns the VertexData of the ribbon
  30418. */
  30419. static CreateRibbon(options: {
  30420. pathArray: Vector3[][];
  30421. closeArray?: boolean;
  30422. closePath?: boolean;
  30423. offset?: number;
  30424. sideOrientation?: number;
  30425. frontUVs?: Vector4;
  30426. backUVs?: Vector4;
  30427. invertUV?: boolean;
  30428. uvs?: Vector2[];
  30429. colors?: Color4[];
  30430. }): VertexData;
  30431. /**
  30432. * Creates the VertexData for a box
  30433. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30434. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30435. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30436. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30437. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30438. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30439. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30440. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30441. * * 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)
  30442. * * 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)
  30443. * @returns the VertexData of the box
  30444. */
  30445. static CreateBox(options: {
  30446. size?: number;
  30447. width?: number;
  30448. height?: number;
  30449. depth?: number;
  30450. faceUV?: Vector4[];
  30451. faceColors?: Color4[];
  30452. sideOrientation?: number;
  30453. frontUVs?: Vector4;
  30454. backUVs?: Vector4;
  30455. }): VertexData;
  30456. /**
  30457. * Creates the VertexData for a tiled box
  30458. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30459. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30460. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30461. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30462. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30463. * @returns the VertexData of the box
  30464. */
  30465. static CreateTiledBox(options: {
  30466. pattern?: number;
  30467. width?: number;
  30468. height?: number;
  30469. depth?: number;
  30470. tileSize?: number;
  30471. tileWidth?: number;
  30472. tileHeight?: number;
  30473. alignHorizontal?: number;
  30474. alignVertical?: number;
  30475. faceUV?: Vector4[];
  30476. faceColors?: Color4[];
  30477. sideOrientation?: number;
  30478. }): VertexData;
  30479. /**
  30480. * Creates the VertexData for a tiled plane
  30481. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30482. * * pattern a limited pattern arrangement depending on the number
  30483. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30484. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30485. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30487. * * 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)
  30488. * * 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)
  30489. * @returns the VertexData of the tiled plane
  30490. */
  30491. static CreateTiledPlane(options: {
  30492. pattern?: number;
  30493. tileSize?: number;
  30494. tileWidth?: number;
  30495. tileHeight?: number;
  30496. size?: number;
  30497. width?: number;
  30498. height?: number;
  30499. alignHorizontal?: number;
  30500. alignVertical?: number;
  30501. sideOrientation?: number;
  30502. frontUVs?: Vector4;
  30503. backUVs?: Vector4;
  30504. }): VertexData;
  30505. /**
  30506. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30507. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30508. * * segments sets the number of horizontal strips optional, default 32
  30509. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30510. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30511. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30512. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30513. * * 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
  30514. * * 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
  30515. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30516. * * 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)
  30517. * * 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)
  30518. * @returns the VertexData of the ellipsoid
  30519. */
  30520. static CreateSphere(options: {
  30521. segments?: number;
  30522. diameter?: number;
  30523. diameterX?: number;
  30524. diameterY?: number;
  30525. diameterZ?: number;
  30526. arc?: number;
  30527. slice?: number;
  30528. sideOrientation?: number;
  30529. frontUVs?: Vector4;
  30530. backUVs?: Vector4;
  30531. }): VertexData;
  30532. /**
  30533. * Creates the VertexData for a cylinder, cone or prism
  30534. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30535. * * height sets the height (y direction) of the cylinder, optional, default 2
  30536. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30537. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30538. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30539. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30540. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30541. * * 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
  30542. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30543. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30544. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30545. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30547. * * 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)
  30548. * * 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)
  30549. * @returns the VertexData of the cylinder, cone or prism
  30550. */
  30551. static CreateCylinder(options: {
  30552. height?: number;
  30553. diameterTop?: number;
  30554. diameterBottom?: number;
  30555. diameter?: number;
  30556. tessellation?: number;
  30557. subdivisions?: number;
  30558. arc?: number;
  30559. faceColors?: Color4[];
  30560. faceUV?: Vector4[];
  30561. hasRings?: boolean;
  30562. enclose?: boolean;
  30563. sideOrientation?: number;
  30564. frontUVs?: Vector4;
  30565. backUVs?: Vector4;
  30566. }): VertexData;
  30567. /**
  30568. * Creates the VertexData for a torus
  30569. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30570. * * diameter the diameter of the torus, optional default 1
  30571. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30572. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30574. * * 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)
  30575. * * 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)
  30576. * @returns the VertexData of the torus
  30577. */
  30578. static CreateTorus(options: {
  30579. diameter?: number;
  30580. thickness?: number;
  30581. tessellation?: number;
  30582. sideOrientation?: number;
  30583. frontUVs?: Vector4;
  30584. backUVs?: Vector4;
  30585. }): VertexData;
  30586. /**
  30587. * Creates the VertexData of the LineSystem
  30588. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30589. * - lines an array of lines, each line being an array of successive Vector3
  30590. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30591. * @returns the VertexData of the LineSystem
  30592. */
  30593. static CreateLineSystem(options: {
  30594. lines: Vector3[][];
  30595. colors?: Nullable<Color4[][]>;
  30596. }): VertexData;
  30597. /**
  30598. * Create the VertexData for a DashedLines
  30599. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30600. * - points an array successive Vector3
  30601. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30602. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30603. * - dashNb the intended total number of dashes, optional, default 200
  30604. * @returns the VertexData for the DashedLines
  30605. */
  30606. static CreateDashedLines(options: {
  30607. points: Vector3[];
  30608. dashSize?: number;
  30609. gapSize?: number;
  30610. dashNb?: number;
  30611. }): VertexData;
  30612. /**
  30613. * Creates the VertexData for a Ground
  30614. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30615. * - width the width (x direction) of the ground, optional, default 1
  30616. * - height the height (z direction) of the ground, optional, default 1
  30617. * - subdivisions the number of subdivisions per side, optional, default 1
  30618. * @returns the VertexData of the Ground
  30619. */
  30620. static CreateGround(options: {
  30621. width?: number;
  30622. height?: number;
  30623. subdivisions?: number;
  30624. subdivisionsX?: number;
  30625. subdivisionsY?: number;
  30626. }): VertexData;
  30627. /**
  30628. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30629. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30630. * * xmin the ground minimum X coordinate, optional, default -1
  30631. * * zmin the ground minimum Z coordinate, optional, default -1
  30632. * * xmax the ground maximum X coordinate, optional, default 1
  30633. * * zmax the ground maximum Z coordinate, optional, default 1
  30634. * * 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}
  30635. * * 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}
  30636. * @returns the VertexData of the TiledGround
  30637. */
  30638. static CreateTiledGround(options: {
  30639. xmin: number;
  30640. zmin: number;
  30641. xmax: number;
  30642. zmax: number;
  30643. subdivisions?: {
  30644. w: number;
  30645. h: number;
  30646. };
  30647. precision?: {
  30648. w: number;
  30649. h: number;
  30650. };
  30651. }): VertexData;
  30652. /**
  30653. * Creates the VertexData of the Ground designed from a heightmap
  30654. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30655. * * width the width (x direction) of the ground
  30656. * * height the height (z direction) of the ground
  30657. * * subdivisions the number of subdivisions per side
  30658. * * minHeight the minimum altitude on the ground, optional, default 0
  30659. * * maxHeight the maximum altitude on the ground, optional default 1
  30660. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30661. * * buffer the array holding the image color data
  30662. * * bufferWidth the width of image
  30663. * * bufferHeight the height of image
  30664. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30665. * @returns the VertexData of the Ground designed from a heightmap
  30666. */
  30667. static CreateGroundFromHeightMap(options: {
  30668. width: number;
  30669. height: number;
  30670. subdivisions: number;
  30671. minHeight: number;
  30672. maxHeight: number;
  30673. colorFilter: Color3;
  30674. buffer: Uint8Array;
  30675. bufferWidth: number;
  30676. bufferHeight: number;
  30677. alphaFilter: number;
  30678. }): VertexData;
  30679. /**
  30680. * Creates the VertexData for a Plane
  30681. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30682. * * size sets the width and height of the plane to the value of size, optional default 1
  30683. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30684. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30686. * * 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)
  30687. * * 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)
  30688. * @returns the VertexData of the box
  30689. */
  30690. static CreatePlane(options: {
  30691. size?: number;
  30692. width?: number;
  30693. height?: number;
  30694. sideOrientation?: number;
  30695. frontUVs?: Vector4;
  30696. backUVs?: Vector4;
  30697. }): VertexData;
  30698. /**
  30699. * Creates the VertexData of the Disc or regular Polygon
  30700. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30701. * * radius the radius of the disc, optional default 0.5
  30702. * * tessellation the number of polygon sides, optional, default 64
  30703. * * 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
  30704. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30705. * * 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)
  30706. * * 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)
  30707. * @returns the VertexData of the box
  30708. */
  30709. static CreateDisc(options: {
  30710. radius?: number;
  30711. tessellation?: number;
  30712. arc?: number;
  30713. sideOrientation?: number;
  30714. frontUVs?: Vector4;
  30715. backUVs?: Vector4;
  30716. }): VertexData;
  30717. /**
  30718. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  30719. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  30720. * @param polygon a mesh built from polygonTriangulation.build()
  30721. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30722. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30723. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30724. * @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)
  30725. * @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)
  30726. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  30727. * @returns the VertexData of the Polygon
  30728. */
  30729. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  30730. /**
  30731. * Creates the VertexData of the IcoSphere
  30732. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  30733. * * radius the radius of the IcoSphere, optional default 1
  30734. * * radiusX allows stretching in the x direction, optional, default radius
  30735. * * radiusY allows stretching in the y direction, optional, default radius
  30736. * * radiusZ allows stretching in the z direction, optional, default radius
  30737. * * flat when true creates a flat shaded mesh, optional, default true
  30738. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30739. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30740. * * 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)
  30741. * * 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)
  30742. * @returns the VertexData of the IcoSphere
  30743. */
  30744. static CreateIcoSphere(options: {
  30745. radius?: number;
  30746. radiusX?: number;
  30747. radiusY?: number;
  30748. radiusZ?: number;
  30749. flat?: boolean;
  30750. subdivisions?: number;
  30751. sideOrientation?: number;
  30752. frontUVs?: Vector4;
  30753. backUVs?: Vector4;
  30754. }): VertexData;
  30755. /**
  30756. * Creates the VertexData for a Polyhedron
  30757. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  30758. * * type provided types are:
  30759. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  30760. * * 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)
  30761. * * size the size of the IcoSphere, optional default 1
  30762. * * sizeX allows stretching in the x direction, optional, default size
  30763. * * sizeY allows stretching in the y direction, optional, default size
  30764. * * sizeZ allows stretching in the z direction, optional, default size
  30765. * * 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
  30766. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30767. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30768. * * flat when true creates a flat shaded mesh, optional, default true
  30769. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30770. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30771. * * 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)
  30772. * * 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)
  30773. * @returns the VertexData of the Polyhedron
  30774. */
  30775. static CreatePolyhedron(options: {
  30776. type?: number;
  30777. size?: number;
  30778. sizeX?: number;
  30779. sizeY?: number;
  30780. sizeZ?: number;
  30781. custom?: any;
  30782. faceUV?: Vector4[];
  30783. faceColors?: Color4[];
  30784. flat?: boolean;
  30785. sideOrientation?: number;
  30786. frontUVs?: Vector4;
  30787. backUVs?: Vector4;
  30788. }): VertexData;
  30789. /**
  30790. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  30791. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  30792. * @returns the VertexData of the Capsule
  30793. */
  30794. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  30795. /**
  30796. * Creates the VertexData for a TorusKnot
  30797. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  30798. * * radius the radius of the torus knot, optional, default 2
  30799. * * tube the thickness of the tube, optional, default 0.5
  30800. * * radialSegments the number of sides on each tube segments, optional, default 32
  30801. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  30802. * * p the number of windings around the z axis, optional, default 2
  30803. * * q the number of windings around the x axis, optional, default 3
  30804. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30805. * * 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)
  30806. * * 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)
  30807. * @returns the VertexData of the Torus Knot
  30808. */
  30809. static CreateTorusKnot(options: {
  30810. radius?: number;
  30811. tube?: number;
  30812. radialSegments?: number;
  30813. tubularSegments?: number;
  30814. p?: number;
  30815. q?: number;
  30816. sideOrientation?: number;
  30817. frontUVs?: Vector4;
  30818. backUVs?: Vector4;
  30819. }): VertexData;
  30820. /**
  30821. * Compute normals for given positions and indices
  30822. * @param positions an array of vertex positions, [...., x, y, z, ......]
  30823. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  30824. * @param normals an array of vertex normals, [...., x, y, z, ......]
  30825. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  30826. * * facetNormals : optional array of facet normals (vector3)
  30827. * * facetPositions : optional array of facet positions (vector3)
  30828. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  30829. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  30830. * * bInfo : optional bounding info, required for facetPartitioning computation
  30831. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  30832. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  30833. * * useRightHandedSystem: optional boolean to for right handed system computation
  30834. * * depthSort : optional boolean to enable the facet depth sort computation
  30835. * * distanceTo : optional Vector3 to compute the facet depth from this location
  30836. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  30837. */
  30838. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  30839. facetNormals?: any;
  30840. facetPositions?: any;
  30841. facetPartitioning?: any;
  30842. ratio?: number;
  30843. bInfo?: any;
  30844. bbSize?: Vector3;
  30845. subDiv?: any;
  30846. useRightHandedSystem?: boolean;
  30847. depthSort?: boolean;
  30848. distanceTo?: Vector3;
  30849. depthSortedFacets?: any;
  30850. }): void;
  30851. /** @hidden */
  30852. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  30853. /**
  30854. * Applies VertexData created from the imported parameters to the geometry
  30855. * @param parsedVertexData the parsed data from an imported file
  30856. * @param geometry the geometry to apply the VertexData to
  30857. */
  30858. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  30859. }
  30860. }
  30861. declare module BABYLON {
  30862. /**
  30863. * Defines a target to use with MorphTargetManager
  30864. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30865. */
  30866. export class MorphTarget implements IAnimatable {
  30867. /** defines the name of the target */
  30868. name: string;
  30869. /**
  30870. * Gets or sets the list of animations
  30871. */
  30872. animations: Animation[];
  30873. private _scene;
  30874. private _positions;
  30875. private _normals;
  30876. private _tangents;
  30877. private _uvs;
  30878. private _influence;
  30879. private _uniqueId;
  30880. /**
  30881. * Observable raised when the influence changes
  30882. */
  30883. onInfluenceChanged: Observable<boolean>;
  30884. /** @hidden */
  30885. _onDataLayoutChanged: Observable<void>;
  30886. /**
  30887. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30888. */
  30889. get influence(): number;
  30890. set influence(influence: number);
  30891. /**
  30892. * Gets or sets the id of the morph Target
  30893. */
  30894. id: string;
  30895. private _animationPropertiesOverride;
  30896. /**
  30897. * Gets or sets the animation properties override
  30898. */
  30899. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30900. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30901. /**
  30902. * Creates a new MorphTarget
  30903. * @param name defines the name of the target
  30904. * @param influence defines the influence to use
  30905. * @param scene defines the scene the morphtarget belongs to
  30906. */
  30907. constructor(
  30908. /** defines the name of the target */
  30909. name: string, influence?: number, scene?: Nullable<Scene>);
  30910. /**
  30911. * Gets the unique ID of this manager
  30912. */
  30913. get uniqueId(): number;
  30914. /**
  30915. * Gets a boolean defining if the target contains position data
  30916. */
  30917. get hasPositions(): boolean;
  30918. /**
  30919. * Gets a boolean defining if the target contains normal data
  30920. */
  30921. get hasNormals(): boolean;
  30922. /**
  30923. * Gets a boolean defining if the target contains tangent data
  30924. */
  30925. get hasTangents(): boolean;
  30926. /**
  30927. * Gets a boolean defining if the target contains texture coordinates data
  30928. */
  30929. get hasUVs(): boolean;
  30930. /**
  30931. * Affects position data to this target
  30932. * @param data defines the position data to use
  30933. */
  30934. setPositions(data: Nullable<FloatArray>): void;
  30935. /**
  30936. * Gets the position data stored in this target
  30937. * @returns a FloatArray containing the position data (or null if not present)
  30938. */
  30939. getPositions(): Nullable<FloatArray>;
  30940. /**
  30941. * Affects normal data to this target
  30942. * @param data defines the normal data to use
  30943. */
  30944. setNormals(data: Nullable<FloatArray>): void;
  30945. /**
  30946. * Gets the normal data stored in this target
  30947. * @returns a FloatArray containing the normal data (or null if not present)
  30948. */
  30949. getNormals(): Nullable<FloatArray>;
  30950. /**
  30951. * Affects tangent data to this target
  30952. * @param data defines the tangent data to use
  30953. */
  30954. setTangents(data: Nullable<FloatArray>): void;
  30955. /**
  30956. * Gets the tangent data stored in this target
  30957. * @returns a FloatArray containing the tangent data (or null if not present)
  30958. */
  30959. getTangents(): Nullable<FloatArray>;
  30960. /**
  30961. * Affects texture coordinates data to this target
  30962. * @param data defines the texture coordinates data to use
  30963. */
  30964. setUVs(data: Nullable<FloatArray>): void;
  30965. /**
  30966. * Gets the texture coordinates data stored in this target
  30967. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30968. */
  30969. getUVs(): Nullable<FloatArray>;
  30970. /**
  30971. * Clone the current target
  30972. * @returns a new MorphTarget
  30973. */
  30974. clone(): MorphTarget;
  30975. /**
  30976. * Serializes the current target into a Serialization object
  30977. * @returns the serialized object
  30978. */
  30979. serialize(): any;
  30980. /**
  30981. * Returns the string "MorphTarget"
  30982. * @returns "MorphTarget"
  30983. */
  30984. getClassName(): string;
  30985. /**
  30986. * Creates a new target from serialized data
  30987. * @param serializationObject defines the serialized data to use
  30988. * @returns a new MorphTarget
  30989. */
  30990. static Parse(serializationObject: any): MorphTarget;
  30991. /**
  30992. * Creates a MorphTarget from mesh data
  30993. * @param mesh defines the source mesh
  30994. * @param name defines the name to use for the new target
  30995. * @param influence defines the influence to attach to the target
  30996. * @returns a new MorphTarget
  30997. */
  30998. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30999. }
  31000. }
  31001. declare module BABYLON {
  31002. /**
  31003. * This class is used to deform meshes using morphing between different targets
  31004. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31005. */
  31006. export class MorphTargetManager {
  31007. private _targets;
  31008. private _targetInfluenceChangedObservers;
  31009. private _targetDataLayoutChangedObservers;
  31010. private _activeTargets;
  31011. private _scene;
  31012. private _influences;
  31013. private _supportsNormals;
  31014. private _supportsTangents;
  31015. private _supportsUVs;
  31016. private _vertexCount;
  31017. private _uniqueId;
  31018. private _tempInfluences;
  31019. /**
  31020. * Gets or sets a boolean indicating if normals must be morphed
  31021. */
  31022. enableNormalMorphing: boolean;
  31023. /**
  31024. * Gets or sets a boolean indicating if tangents must be morphed
  31025. */
  31026. enableTangentMorphing: boolean;
  31027. /**
  31028. * Gets or sets a boolean indicating if UV must be morphed
  31029. */
  31030. enableUVMorphing: boolean;
  31031. /**
  31032. * Creates a new MorphTargetManager
  31033. * @param scene defines the current scene
  31034. */
  31035. constructor(scene?: Nullable<Scene>);
  31036. /**
  31037. * Gets the unique ID of this manager
  31038. */
  31039. get uniqueId(): number;
  31040. /**
  31041. * Gets the number of vertices handled by this manager
  31042. */
  31043. get vertexCount(): number;
  31044. /**
  31045. * Gets a boolean indicating if this manager supports morphing of normals
  31046. */
  31047. get supportsNormals(): boolean;
  31048. /**
  31049. * Gets a boolean indicating if this manager supports morphing of tangents
  31050. */
  31051. get supportsTangents(): boolean;
  31052. /**
  31053. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31054. */
  31055. get supportsUVs(): boolean;
  31056. /**
  31057. * Gets the number of targets stored in this manager
  31058. */
  31059. get numTargets(): number;
  31060. /**
  31061. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31062. */
  31063. get numInfluencers(): number;
  31064. /**
  31065. * Gets the list of influences (one per target)
  31066. */
  31067. get influences(): Float32Array;
  31068. /**
  31069. * Gets the active target at specified index. An active target is a target with an influence > 0
  31070. * @param index defines the index to check
  31071. * @returns the requested target
  31072. */
  31073. getActiveTarget(index: number): MorphTarget;
  31074. /**
  31075. * Gets the target at specified index
  31076. * @param index defines the index to check
  31077. * @returns the requested target
  31078. */
  31079. getTarget(index: number): MorphTarget;
  31080. /**
  31081. * Add a new target to this manager
  31082. * @param target defines the target to add
  31083. */
  31084. addTarget(target: MorphTarget): void;
  31085. /**
  31086. * Removes a target from the manager
  31087. * @param target defines the target to remove
  31088. */
  31089. removeTarget(target: MorphTarget): void;
  31090. /**
  31091. * Clone the current manager
  31092. * @returns a new MorphTargetManager
  31093. */
  31094. clone(): MorphTargetManager;
  31095. /**
  31096. * Serializes the current manager into a Serialization object
  31097. * @returns the serialized object
  31098. */
  31099. serialize(): any;
  31100. private _syncActiveTargets;
  31101. /**
  31102. * Syncrhonize the targets with all the meshes using this morph target manager
  31103. */
  31104. synchronize(): void;
  31105. /**
  31106. * Creates a new MorphTargetManager from serialized data
  31107. * @param serializationObject defines the serialized data
  31108. * @param scene defines the hosting scene
  31109. * @returns the new MorphTargetManager
  31110. */
  31111. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31112. }
  31113. }
  31114. declare module BABYLON {
  31115. /**
  31116. * Class used to represent a specific level of detail of a mesh
  31117. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31118. */
  31119. export class MeshLODLevel {
  31120. /** Defines the distance where this level should start being displayed */
  31121. distance: number;
  31122. /** Defines the mesh to use to render this level */
  31123. mesh: Nullable<Mesh>;
  31124. /**
  31125. * Creates a new LOD level
  31126. * @param distance defines the distance where this level should star being displayed
  31127. * @param mesh defines the mesh to use to render this level
  31128. */
  31129. constructor(
  31130. /** Defines the distance where this level should start being displayed */
  31131. distance: number,
  31132. /** Defines the mesh to use to render this level */
  31133. mesh: Nullable<Mesh>);
  31134. }
  31135. }
  31136. declare module BABYLON {
  31137. /**
  31138. * Helper class used to generate a canvas to manipulate images
  31139. */
  31140. export class CanvasGenerator {
  31141. /**
  31142. * Create a new canvas (or offscreen canvas depending on the context)
  31143. * @param width defines the expected width
  31144. * @param height defines the expected height
  31145. * @return a new canvas or offscreen canvas
  31146. */
  31147. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31148. }
  31149. }
  31150. declare module BABYLON {
  31151. /**
  31152. * Mesh representing the gorund
  31153. */
  31154. export class GroundMesh extends Mesh {
  31155. /** If octree should be generated */
  31156. generateOctree: boolean;
  31157. private _heightQuads;
  31158. /** @hidden */
  31159. _subdivisionsX: number;
  31160. /** @hidden */
  31161. _subdivisionsY: number;
  31162. /** @hidden */
  31163. _width: number;
  31164. /** @hidden */
  31165. _height: number;
  31166. /** @hidden */
  31167. _minX: number;
  31168. /** @hidden */
  31169. _maxX: number;
  31170. /** @hidden */
  31171. _minZ: number;
  31172. /** @hidden */
  31173. _maxZ: number;
  31174. constructor(name: string, scene: Scene);
  31175. /**
  31176. * "GroundMesh"
  31177. * @returns "GroundMesh"
  31178. */
  31179. getClassName(): string;
  31180. /**
  31181. * The minimum of x and y subdivisions
  31182. */
  31183. get subdivisions(): number;
  31184. /**
  31185. * X subdivisions
  31186. */
  31187. get subdivisionsX(): number;
  31188. /**
  31189. * Y subdivisions
  31190. */
  31191. get subdivisionsY(): number;
  31192. /**
  31193. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31194. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31195. * @param chunksCount the number of subdivisions for x and y
  31196. * @param octreeBlocksSize (Default: 32)
  31197. */
  31198. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31199. /**
  31200. * Returns a height (y) value in the Worl system :
  31201. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31202. * @param x x coordinate
  31203. * @param z z coordinate
  31204. * @returns the ground y position if (x, z) are outside the ground surface.
  31205. */
  31206. getHeightAtCoordinates(x: number, z: number): number;
  31207. /**
  31208. * Returns a normalized vector (Vector3) orthogonal to the ground
  31209. * at the ground coordinates (x, z) expressed in the World system.
  31210. * @param x x coordinate
  31211. * @param z z coordinate
  31212. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31213. */
  31214. getNormalAtCoordinates(x: number, z: number): Vector3;
  31215. /**
  31216. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31217. * at the ground coordinates (x, z) expressed in the World system.
  31218. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31219. * @param x x coordinate
  31220. * @param z z coordinate
  31221. * @param ref vector to store the result
  31222. * @returns the GroundMesh.
  31223. */
  31224. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31225. /**
  31226. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31227. * if the ground has been updated.
  31228. * This can be used in the render loop.
  31229. * @returns the GroundMesh.
  31230. */
  31231. updateCoordinateHeights(): GroundMesh;
  31232. private _getFacetAt;
  31233. private _initHeightQuads;
  31234. private _computeHeightQuads;
  31235. /**
  31236. * Serializes this ground mesh
  31237. * @param serializationObject object to write serialization to
  31238. */
  31239. serialize(serializationObject: any): void;
  31240. /**
  31241. * Parses a serialized ground mesh
  31242. * @param parsedMesh the serialized mesh
  31243. * @param scene the scene to create the ground mesh in
  31244. * @returns the created ground mesh
  31245. */
  31246. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31247. }
  31248. }
  31249. declare module BABYLON {
  31250. /**
  31251. * Interface for Physics-Joint data
  31252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31253. */
  31254. export interface PhysicsJointData {
  31255. /**
  31256. * The main pivot of the joint
  31257. */
  31258. mainPivot?: Vector3;
  31259. /**
  31260. * The connected pivot of the joint
  31261. */
  31262. connectedPivot?: Vector3;
  31263. /**
  31264. * The main axis of the joint
  31265. */
  31266. mainAxis?: Vector3;
  31267. /**
  31268. * The connected axis of the joint
  31269. */
  31270. connectedAxis?: Vector3;
  31271. /**
  31272. * The collision of the joint
  31273. */
  31274. collision?: boolean;
  31275. /**
  31276. * Native Oimo/Cannon/Energy data
  31277. */
  31278. nativeParams?: any;
  31279. }
  31280. /**
  31281. * This is a holder class for the physics joint created by the physics plugin
  31282. * It holds a set of functions to control the underlying joint
  31283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31284. */
  31285. export class PhysicsJoint {
  31286. /**
  31287. * The type of the physics joint
  31288. */
  31289. type: number;
  31290. /**
  31291. * The data for the physics joint
  31292. */
  31293. jointData: PhysicsJointData;
  31294. private _physicsJoint;
  31295. protected _physicsPlugin: IPhysicsEnginePlugin;
  31296. /**
  31297. * Initializes the physics joint
  31298. * @param type The type of the physics joint
  31299. * @param jointData The data for the physics joint
  31300. */
  31301. constructor(
  31302. /**
  31303. * The type of the physics joint
  31304. */
  31305. type: number,
  31306. /**
  31307. * The data for the physics joint
  31308. */
  31309. jointData: PhysicsJointData);
  31310. /**
  31311. * Gets the physics joint
  31312. */
  31313. get physicsJoint(): any;
  31314. /**
  31315. * Sets the physics joint
  31316. */
  31317. set physicsJoint(newJoint: any);
  31318. /**
  31319. * Sets the physics plugin
  31320. */
  31321. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31322. /**
  31323. * Execute a function that is physics-plugin specific.
  31324. * @param {Function} func the function that will be executed.
  31325. * It accepts two parameters: the physics world and the physics joint
  31326. */
  31327. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31328. /**
  31329. * Distance-Joint type
  31330. */
  31331. static DistanceJoint: number;
  31332. /**
  31333. * Hinge-Joint type
  31334. */
  31335. static HingeJoint: number;
  31336. /**
  31337. * Ball-and-Socket joint type
  31338. */
  31339. static BallAndSocketJoint: number;
  31340. /**
  31341. * Wheel-Joint type
  31342. */
  31343. static WheelJoint: number;
  31344. /**
  31345. * Slider-Joint type
  31346. */
  31347. static SliderJoint: number;
  31348. /**
  31349. * Prismatic-Joint type
  31350. */
  31351. static PrismaticJoint: number;
  31352. /**
  31353. * Universal-Joint type
  31354. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31355. */
  31356. static UniversalJoint: number;
  31357. /**
  31358. * Hinge-Joint 2 type
  31359. */
  31360. static Hinge2Joint: number;
  31361. /**
  31362. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31363. */
  31364. static PointToPointJoint: number;
  31365. /**
  31366. * Spring-Joint type
  31367. */
  31368. static SpringJoint: number;
  31369. /**
  31370. * Lock-Joint type
  31371. */
  31372. static LockJoint: number;
  31373. }
  31374. /**
  31375. * A class representing a physics distance joint
  31376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31377. */
  31378. export class DistanceJoint extends PhysicsJoint {
  31379. /**
  31380. *
  31381. * @param jointData The data for the Distance-Joint
  31382. */
  31383. constructor(jointData: DistanceJointData);
  31384. /**
  31385. * Update the predefined distance.
  31386. * @param maxDistance The maximum preferred distance
  31387. * @param minDistance The minimum preferred distance
  31388. */
  31389. updateDistance(maxDistance: number, minDistance?: number): void;
  31390. }
  31391. /**
  31392. * Represents a Motor-Enabled Joint
  31393. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31394. */
  31395. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31396. /**
  31397. * Initializes the Motor-Enabled Joint
  31398. * @param type The type of the joint
  31399. * @param jointData The physica joint data for the joint
  31400. */
  31401. constructor(type: number, jointData: PhysicsJointData);
  31402. /**
  31403. * Set the motor values.
  31404. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31405. * @param force the force to apply
  31406. * @param maxForce max force for this motor.
  31407. */
  31408. setMotor(force?: number, maxForce?: number): void;
  31409. /**
  31410. * Set the motor's limits.
  31411. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31412. * @param upperLimit The upper limit of the motor
  31413. * @param lowerLimit The lower limit of the motor
  31414. */
  31415. setLimit(upperLimit: number, lowerLimit?: number): void;
  31416. }
  31417. /**
  31418. * This class represents a single physics Hinge-Joint
  31419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31420. */
  31421. export class HingeJoint extends MotorEnabledJoint {
  31422. /**
  31423. * Initializes the Hinge-Joint
  31424. * @param jointData The joint data for the Hinge-Joint
  31425. */
  31426. constructor(jointData: PhysicsJointData);
  31427. /**
  31428. * Set the motor values.
  31429. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31430. * @param {number} force the force to apply
  31431. * @param {number} maxForce max force for this motor.
  31432. */
  31433. setMotor(force?: number, maxForce?: number): void;
  31434. /**
  31435. * Set the motor's limits.
  31436. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31437. * @param upperLimit The upper limit of the motor
  31438. * @param lowerLimit The lower limit of the motor
  31439. */
  31440. setLimit(upperLimit: number, lowerLimit?: number): void;
  31441. }
  31442. /**
  31443. * This class represents a dual hinge physics joint (same as wheel joint)
  31444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31445. */
  31446. export class Hinge2Joint extends MotorEnabledJoint {
  31447. /**
  31448. * Initializes the Hinge2-Joint
  31449. * @param jointData The joint data for the Hinge2-Joint
  31450. */
  31451. constructor(jointData: PhysicsJointData);
  31452. /**
  31453. * Set the motor values.
  31454. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31455. * @param {number} targetSpeed the speed the motor is to reach
  31456. * @param {number} maxForce max force for this motor.
  31457. * @param {motorIndex} the motor's index, 0 or 1.
  31458. */
  31459. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31460. /**
  31461. * Set the motor limits.
  31462. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31463. * @param {number} upperLimit the upper limit
  31464. * @param {number} lowerLimit lower limit
  31465. * @param {motorIndex} the motor's index, 0 or 1.
  31466. */
  31467. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31468. }
  31469. /**
  31470. * Interface for a motor enabled joint
  31471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31472. */
  31473. export interface IMotorEnabledJoint {
  31474. /**
  31475. * Physics joint
  31476. */
  31477. physicsJoint: any;
  31478. /**
  31479. * Sets the motor of the motor-enabled joint
  31480. * @param force The force of the motor
  31481. * @param maxForce The maximum force of the motor
  31482. * @param motorIndex The index of the motor
  31483. */
  31484. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31485. /**
  31486. * Sets the limit of the motor
  31487. * @param upperLimit The upper limit of the motor
  31488. * @param lowerLimit The lower limit of the motor
  31489. * @param motorIndex The index of the motor
  31490. */
  31491. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31492. }
  31493. /**
  31494. * Joint data for a Distance-Joint
  31495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31496. */
  31497. export interface DistanceJointData extends PhysicsJointData {
  31498. /**
  31499. * Max distance the 2 joint objects can be apart
  31500. */
  31501. maxDistance: number;
  31502. }
  31503. /**
  31504. * Joint data from a spring joint
  31505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31506. */
  31507. export interface SpringJointData extends PhysicsJointData {
  31508. /**
  31509. * Length of the spring
  31510. */
  31511. length: number;
  31512. /**
  31513. * Stiffness of the spring
  31514. */
  31515. stiffness: number;
  31516. /**
  31517. * Damping of the spring
  31518. */
  31519. damping: number;
  31520. /** this callback will be called when applying the force to the impostors. */
  31521. forceApplicationCallback: () => void;
  31522. }
  31523. }
  31524. declare module BABYLON {
  31525. /**
  31526. * Holds the data for the raycast result
  31527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31528. */
  31529. export class PhysicsRaycastResult {
  31530. private _hasHit;
  31531. private _hitDistance;
  31532. private _hitNormalWorld;
  31533. private _hitPointWorld;
  31534. private _rayFromWorld;
  31535. private _rayToWorld;
  31536. /**
  31537. * Gets if there was a hit
  31538. */
  31539. get hasHit(): boolean;
  31540. /**
  31541. * Gets the distance from the hit
  31542. */
  31543. get hitDistance(): number;
  31544. /**
  31545. * Gets the hit normal/direction in the world
  31546. */
  31547. get hitNormalWorld(): Vector3;
  31548. /**
  31549. * Gets the hit point in the world
  31550. */
  31551. get hitPointWorld(): Vector3;
  31552. /**
  31553. * Gets the ray "start point" of the ray in the world
  31554. */
  31555. get rayFromWorld(): Vector3;
  31556. /**
  31557. * Gets the ray "end point" of the ray in the world
  31558. */
  31559. get rayToWorld(): Vector3;
  31560. /**
  31561. * Sets the hit data (normal & point in world space)
  31562. * @param hitNormalWorld defines the normal in world space
  31563. * @param hitPointWorld defines the point in world space
  31564. */
  31565. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31566. /**
  31567. * Sets the distance from the start point to the hit point
  31568. * @param distance
  31569. */
  31570. setHitDistance(distance: number): void;
  31571. /**
  31572. * Calculates the distance manually
  31573. */
  31574. calculateHitDistance(): void;
  31575. /**
  31576. * Resets all the values to default
  31577. * @param from The from point on world space
  31578. * @param to The to point on world space
  31579. */
  31580. reset(from?: Vector3, to?: Vector3): void;
  31581. }
  31582. /**
  31583. * Interface for the size containing width and height
  31584. */
  31585. interface IXYZ {
  31586. /**
  31587. * X
  31588. */
  31589. x: number;
  31590. /**
  31591. * Y
  31592. */
  31593. y: number;
  31594. /**
  31595. * Z
  31596. */
  31597. z: number;
  31598. }
  31599. }
  31600. declare module BABYLON {
  31601. /**
  31602. * Interface used to describe a physics joint
  31603. */
  31604. export interface PhysicsImpostorJoint {
  31605. /** Defines the main impostor to which the joint is linked */
  31606. mainImpostor: PhysicsImpostor;
  31607. /** Defines the impostor that is connected to the main impostor using this joint */
  31608. connectedImpostor: PhysicsImpostor;
  31609. /** Defines the joint itself */
  31610. joint: PhysicsJoint;
  31611. }
  31612. /** @hidden */
  31613. export interface IPhysicsEnginePlugin {
  31614. world: any;
  31615. name: string;
  31616. setGravity(gravity: Vector3): void;
  31617. setTimeStep(timeStep: number): void;
  31618. getTimeStep(): number;
  31619. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31620. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31621. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31622. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31623. removePhysicsBody(impostor: PhysicsImpostor): void;
  31624. generateJoint(joint: PhysicsImpostorJoint): void;
  31625. removeJoint(joint: PhysicsImpostorJoint): void;
  31626. isSupported(): boolean;
  31627. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31628. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31629. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31630. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31631. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31632. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31633. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31634. getBodyMass(impostor: PhysicsImpostor): number;
  31635. getBodyFriction(impostor: PhysicsImpostor): number;
  31636. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31637. getBodyRestitution(impostor: PhysicsImpostor): number;
  31638. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31639. getBodyPressure?(impostor: PhysicsImpostor): number;
  31640. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31641. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31642. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31643. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31644. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31645. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31646. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31647. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31648. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31649. sleepBody(impostor: PhysicsImpostor): void;
  31650. wakeUpBody(impostor: PhysicsImpostor): void;
  31651. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31652. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31653. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31654. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31655. getRadius(impostor: PhysicsImpostor): number;
  31656. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31657. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31658. dispose(): void;
  31659. }
  31660. /**
  31661. * Interface used to define a physics engine
  31662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31663. */
  31664. export interface IPhysicsEngine {
  31665. /**
  31666. * Gets the gravity vector used by the simulation
  31667. */
  31668. gravity: Vector3;
  31669. /**
  31670. * Sets the gravity vector used by the simulation
  31671. * @param gravity defines the gravity vector to use
  31672. */
  31673. setGravity(gravity: Vector3): void;
  31674. /**
  31675. * Set the time step of the physics engine.
  31676. * Default is 1/60.
  31677. * To slow it down, enter 1/600 for example.
  31678. * To speed it up, 1/30
  31679. * @param newTimeStep the new timestep to apply to this world.
  31680. */
  31681. setTimeStep(newTimeStep: number): void;
  31682. /**
  31683. * Get the time step of the physics engine.
  31684. * @returns the current time step
  31685. */
  31686. getTimeStep(): number;
  31687. /**
  31688. * Set the sub time step of the physics engine.
  31689. * Default is 0 meaning there is no sub steps
  31690. * To increase physics resolution precision, set a small value (like 1 ms)
  31691. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31692. */
  31693. setSubTimeStep(subTimeStep: number): void;
  31694. /**
  31695. * Get the sub time step of the physics engine.
  31696. * @returns the current sub time step
  31697. */
  31698. getSubTimeStep(): number;
  31699. /**
  31700. * Release all resources
  31701. */
  31702. dispose(): void;
  31703. /**
  31704. * Gets the name of the current physics plugin
  31705. * @returns the name of the plugin
  31706. */
  31707. getPhysicsPluginName(): string;
  31708. /**
  31709. * Adding a new impostor for the impostor tracking.
  31710. * This will be done by the impostor itself.
  31711. * @param impostor the impostor to add
  31712. */
  31713. addImpostor(impostor: PhysicsImpostor): void;
  31714. /**
  31715. * Remove an impostor from the engine.
  31716. * This impostor and its mesh will not longer be updated by the physics engine.
  31717. * @param impostor the impostor to remove
  31718. */
  31719. removeImpostor(impostor: PhysicsImpostor): void;
  31720. /**
  31721. * Add a joint to the physics engine
  31722. * @param mainImpostor defines the main impostor to which the joint is added.
  31723. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31724. * @param joint defines the joint that will connect both impostors.
  31725. */
  31726. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31727. /**
  31728. * Removes a joint from the simulation
  31729. * @param mainImpostor defines the impostor used with the joint
  31730. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31731. * @param joint defines the joint to remove
  31732. */
  31733. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31734. /**
  31735. * Gets the current plugin used to run the simulation
  31736. * @returns current plugin
  31737. */
  31738. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31739. /**
  31740. * Gets the list of physic impostors
  31741. * @returns an array of PhysicsImpostor
  31742. */
  31743. getImpostors(): Array<PhysicsImpostor>;
  31744. /**
  31745. * Gets the impostor for a physics enabled object
  31746. * @param object defines the object impersonated by the impostor
  31747. * @returns the PhysicsImpostor or null if not found
  31748. */
  31749. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31750. /**
  31751. * Gets the impostor for a physics body object
  31752. * @param body defines physics body used by the impostor
  31753. * @returns the PhysicsImpostor or null if not found
  31754. */
  31755. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31756. /**
  31757. * Does a raycast in the physics world
  31758. * @param from when should the ray start?
  31759. * @param to when should the ray end?
  31760. * @returns PhysicsRaycastResult
  31761. */
  31762. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31763. /**
  31764. * Called by the scene. No need to call it.
  31765. * @param delta defines the timespam between frames
  31766. */
  31767. _step(delta: number): void;
  31768. }
  31769. }
  31770. declare module BABYLON {
  31771. /**
  31772. * The interface for the physics imposter parameters
  31773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31774. */
  31775. export interface PhysicsImpostorParameters {
  31776. /**
  31777. * The mass of the physics imposter
  31778. */
  31779. mass: number;
  31780. /**
  31781. * The friction of the physics imposter
  31782. */
  31783. friction?: number;
  31784. /**
  31785. * The coefficient of restitution of the physics imposter
  31786. */
  31787. restitution?: number;
  31788. /**
  31789. * The native options of the physics imposter
  31790. */
  31791. nativeOptions?: any;
  31792. /**
  31793. * Specifies if the parent should be ignored
  31794. */
  31795. ignoreParent?: boolean;
  31796. /**
  31797. * Specifies if bi-directional transformations should be disabled
  31798. */
  31799. disableBidirectionalTransformation?: boolean;
  31800. /**
  31801. * The pressure inside the physics imposter, soft object only
  31802. */
  31803. pressure?: number;
  31804. /**
  31805. * The stiffness the physics imposter, soft object only
  31806. */
  31807. stiffness?: number;
  31808. /**
  31809. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31810. */
  31811. velocityIterations?: number;
  31812. /**
  31813. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31814. */
  31815. positionIterations?: number;
  31816. /**
  31817. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31818. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31819. * Add to fix multiple points
  31820. */
  31821. fixedPoints?: number;
  31822. /**
  31823. * The collision margin around a soft object
  31824. */
  31825. margin?: number;
  31826. /**
  31827. * The collision margin around a soft object
  31828. */
  31829. damping?: number;
  31830. /**
  31831. * The path for a rope based on an extrusion
  31832. */
  31833. path?: any;
  31834. /**
  31835. * The shape of an extrusion used for a rope based on an extrusion
  31836. */
  31837. shape?: any;
  31838. }
  31839. /**
  31840. * Interface for a physics-enabled object
  31841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31842. */
  31843. export interface IPhysicsEnabledObject {
  31844. /**
  31845. * The position of the physics-enabled object
  31846. */
  31847. position: Vector3;
  31848. /**
  31849. * The rotation of the physics-enabled object
  31850. */
  31851. rotationQuaternion: Nullable<Quaternion>;
  31852. /**
  31853. * The scale of the physics-enabled object
  31854. */
  31855. scaling: Vector3;
  31856. /**
  31857. * The rotation of the physics-enabled object
  31858. */
  31859. rotation?: Vector3;
  31860. /**
  31861. * The parent of the physics-enabled object
  31862. */
  31863. parent?: any;
  31864. /**
  31865. * The bounding info of the physics-enabled object
  31866. * @returns The bounding info of the physics-enabled object
  31867. */
  31868. getBoundingInfo(): BoundingInfo;
  31869. /**
  31870. * Computes the world matrix
  31871. * @param force Specifies if the world matrix should be computed by force
  31872. * @returns A world matrix
  31873. */
  31874. computeWorldMatrix(force: boolean): Matrix;
  31875. /**
  31876. * Gets the world matrix
  31877. * @returns A world matrix
  31878. */
  31879. getWorldMatrix?(): Matrix;
  31880. /**
  31881. * Gets the child meshes
  31882. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31883. * @returns An array of abstract meshes
  31884. */
  31885. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31886. /**
  31887. * Gets the vertex data
  31888. * @param kind The type of vertex data
  31889. * @returns A nullable array of numbers, or a float32 array
  31890. */
  31891. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31892. /**
  31893. * Gets the indices from the mesh
  31894. * @returns A nullable array of index arrays
  31895. */
  31896. getIndices?(): Nullable<IndicesArray>;
  31897. /**
  31898. * Gets the scene from the mesh
  31899. * @returns the indices array or null
  31900. */
  31901. getScene?(): Scene;
  31902. /**
  31903. * Gets the absolute position from the mesh
  31904. * @returns the absolute position
  31905. */
  31906. getAbsolutePosition(): Vector3;
  31907. /**
  31908. * Gets the absolute pivot point from the mesh
  31909. * @returns the absolute pivot point
  31910. */
  31911. getAbsolutePivotPoint(): Vector3;
  31912. /**
  31913. * Rotates the mesh
  31914. * @param axis The axis of rotation
  31915. * @param amount The amount of rotation
  31916. * @param space The space of the rotation
  31917. * @returns The rotation transform node
  31918. */
  31919. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31920. /**
  31921. * Translates the mesh
  31922. * @param axis The axis of translation
  31923. * @param distance The distance of translation
  31924. * @param space The space of the translation
  31925. * @returns The transform node
  31926. */
  31927. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31928. /**
  31929. * Sets the absolute position of the mesh
  31930. * @param absolutePosition The absolute position of the mesh
  31931. * @returns The transform node
  31932. */
  31933. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31934. /**
  31935. * Gets the class name of the mesh
  31936. * @returns The class name
  31937. */
  31938. getClassName(): string;
  31939. }
  31940. /**
  31941. * Represents a physics imposter
  31942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31943. */
  31944. export class PhysicsImpostor {
  31945. /**
  31946. * The physics-enabled object used as the physics imposter
  31947. */
  31948. object: IPhysicsEnabledObject;
  31949. /**
  31950. * The type of the physics imposter
  31951. */
  31952. type: number;
  31953. private _options;
  31954. private _scene?;
  31955. /**
  31956. * The default object size of the imposter
  31957. */
  31958. static DEFAULT_OBJECT_SIZE: Vector3;
  31959. /**
  31960. * The identity quaternion of the imposter
  31961. */
  31962. static IDENTITY_QUATERNION: Quaternion;
  31963. /** @hidden */
  31964. _pluginData: any;
  31965. private _physicsEngine;
  31966. private _physicsBody;
  31967. private _bodyUpdateRequired;
  31968. private _onBeforePhysicsStepCallbacks;
  31969. private _onAfterPhysicsStepCallbacks;
  31970. /** @hidden */
  31971. _onPhysicsCollideCallbacks: Array<{
  31972. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31973. otherImpostors: Array<PhysicsImpostor>;
  31974. }>;
  31975. private _deltaPosition;
  31976. private _deltaRotation;
  31977. private _deltaRotationConjugated;
  31978. /** @hidden */
  31979. _isFromLine: boolean;
  31980. private _parent;
  31981. private _isDisposed;
  31982. private static _tmpVecs;
  31983. private static _tmpQuat;
  31984. /**
  31985. * Specifies if the physics imposter is disposed
  31986. */
  31987. get isDisposed(): boolean;
  31988. /**
  31989. * Gets the mass of the physics imposter
  31990. */
  31991. get mass(): number;
  31992. set mass(value: number);
  31993. /**
  31994. * Gets the coefficient of friction
  31995. */
  31996. get friction(): number;
  31997. /**
  31998. * Sets the coefficient of friction
  31999. */
  32000. set friction(value: number);
  32001. /**
  32002. * Gets the coefficient of restitution
  32003. */
  32004. get restitution(): number;
  32005. /**
  32006. * Sets the coefficient of restitution
  32007. */
  32008. set restitution(value: number);
  32009. /**
  32010. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32011. */
  32012. get pressure(): number;
  32013. /**
  32014. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32015. */
  32016. set pressure(value: number);
  32017. /**
  32018. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32019. */
  32020. get stiffness(): number;
  32021. /**
  32022. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32023. */
  32024. set stiffness(value: number);
  32025. /**
  32026. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32027. */
  32028. get velocityIterations(): number;
  32029. /**
  32030. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32031. */
  32032. set velocityIterations(value: number);
  32033. /**
  32034. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32035. */
  32036. get positionIterations(): number;
  32037. /**
  32038. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32039. */
  32040. set positionIterations(value: number);
  32041. /**
  32042. * The unique id of the physics imposter
  32043. * set by the physics engine when adding this impostor to the array
  32044. */
  32045. uniqueId: number;
  32046. /**
  32047. * @hidden
  32048. */
  32049. soft: boolean;
  32050. /**
  32051. * @hidden
  32052. */
  32053. segments: number;
  32054. private _joints;
  32055. /**
  32056. * Initializes the physics imposter
  32057. * @param object The physics-enabled object used as the physics imposter
  32058. * @param type The type of the physics imposter
  32059. * @param _options The options for the physics imposter
  32060. * @param _scene The Babylon scene
  32061. */
  32062. constructor(
  32063. /**
  32064. * The physics-enabled object used as the physics imposter
  32065. */
  32066. object: IPhysicsEnabledObject,
  32067. /**
  32068. * The type of the physics imposter
  32069. */
  32070. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32071. /**
  32072. * This function will completly initialize this impostor.
  32073. * It will create a new body - but only if this mesh has no parent.
  32074. * If it has, this impostor will not be used other than to define the impostor
  32075. * of the child mesh.
  32076. * @hidden
  32077. */
  32078. _init(): void;
  32079. private _getPhysicsParent;
  32080. /**
  32081. * Should a new body be generated.
  32082. * @returns boolean specifying if body initialization is required
  32083. */
  32084. isBodyInitRequired(): boolean;
  32085. /**
  32086. * Sets the updated scaling
  32087. * @param updated Specifies if the scaling is updated
  32088. */
  32089. setScalingUpdated(): void;
  32090. /**
  32091. * Force a regeneration of this or the parent's impostor's body.
  32092. * Use under cautious - This will remove all joints already implemented.
  32093. */
  32094. forceUpdate(): void;
  32095. /**
  32096. * Gets the body that holds this impostor. Either its own, or its parent.
  32097. */
  32098. get physicsBody(): any;
  32099. /**
  32100. * Get the parent of the physics imposter
  32101. * @returns Physics imposter or null
  32102. */
  32103. get parent(): Nullable<PhysicsImpostor>;
  32104. /**
  32105. * Sets the parent of the physics imposter
  32106. */
  32107. set parent(value: Nullable<PhysicsImpostor>);
  32108. /**
  32109. * Set the physics body. Used mainly by the physics engine/plugin
  32110. */
  32111. set physicsBody(physicsBody: any);
  32112. /**
  32113. * Resets the update flags
  32114. */
  32115. resetUpdateFlags(): void;
  32116. /**
  32117. * Gets the object extend size
  32118. * @returns the object extend size
  32119. */
  32120. getObjectExtendSize(): Vector3;
  32121. /**
  32122. * Gets the object center
  32123. * @returns The object center
  32124. */
  32125. getObjectCenter(): Vector3;
  32126. /**
  32127. * Get a specific parameter from the options parameters
  32128. * @param paramName The object parameter name
  32129. * @returns The object parameter
  32130. */
  32131. getParam(paramName: string): any;
  32132. /**
  32133. * Sets a specific parameter in the options given to the physics plugin
  32134. * @param paramName The parameter name
  32135. * @param value The value of the parameter
  32136. */
  32137. setParam(paramName: string, value: number): void;
  32138. /**
  32139. * Specifically change the body's mass option. Won't recreate the physics body object
  32140. * @param mass The mass of the physics imposter
  32141. */
  32142. setMass(mass: number): void;
  32143. /**
  32144. * Gets the linear velocity
  32145. * @returns linear velocity or null
  32146. */
  32147. getLinearVelocity(): Nullable<Vector3>;
  32148. /**
  32149. * Sets the linear velocity
  32150. * @param velocity linear velocity or null
  32151. */
  32152. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32153. /**
  32154. * Gets the angular velocity
  32155. * @returns angular velocity or null
  32156. */
  32157. getAngularVelocity(): Nullable<Vector3>;
  32158. /**
  32159. * Sets the angular velocity
  32160. * @param velocity The velocity or null
  32161. */
  32162. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32163. /**
  32164. * Execute a function with the physics plugin native code
  32165. * Provide a function the will have two variables - the world object and the physics body object
  32166. * @param func The function to execute with the physics plugin native code
  32167. */
  32168. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32169. /**
  32170. * Register a function that will be executed before the physics world is stepping forward
  32171. * @param func The function to execute before the physics world is stepped forward
  32172. */
  32173. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32174. /**
  32175. * Unregister a function that will be executed before the physics world is stepping forward
  32176. * @param func The function to execute before the physics world is stepped forward
  32177. */
  32178. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32179. /**
  32180. * Register a function that will be executed after the physics step
  32181. * @param func The function to execute after physics step
  32182. */
  32183. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32184. /**
  32185. * Unregisters a function that will be executed after the physics step
  32186. * @param func The function to execute after physics step
  32187. */
  32188. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32189. /**
  32190. * register a function that will be executed when this impostor collides against a different body
  32191. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32192. * @param func Callback that is executed on collision
  32193. */
  32194. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32195. /**
  32196. * Unregisters the physics imposter on contact
  32197. * @param collideAgainst The physics object to collide against
  32198. * @param func Callback to execute on collision
  32199. */
  32200. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32201. private _tmpQuat;
  32202. private _tmpQuat2;
  32203. /**
  32204. * Get the parent rotation
  32205. * @returns The parent rotation
  32206. */
  32207. getParentsRotation(): Quaternion;
  32208. /**
  32209. * this function is executed by the physics engine.
  32210. */
  32211. beforeStep: () => void;
  32212. /**
  32213. * this function is executed by the physics engine
  32214. */
  32215. afterStep: () => void;
  32216. /**
  32217. * Legacy collision detection event support
  32218. */
  32219. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32220. /**
  32221. * event and body object due to cannon's event-based architecture.
  32222. */
  32223. onCollide: (e: {
  32224. body: any;
  32225. point: Nullable<Vector3>;
  32226. }) => void;
  32227. /**
  32228. * Apply a force
  32229. * @param force The force to apply
  32230. * @param contactPoint The contact point for the force
  32231. * @returns The physics imposter
  32232. */
  32233. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32234. /**
  32235. * Apply an impulse
  32236. * @param force The impulse force
  32237. * @param contactPoint The contact point for the impulse force
  32238. * @returns The physics imposter
  32239. */
  32240. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32241. /**
  32242. * A help function to create a joint
  32243. * @param otherImpostor A physics imposter used to create a joint
  32244. * @param jointType The type of joint
  32245. * @param jointData The data for the joint
  32246. * @returns The physics imposter
  32247. */
  32248. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32249. /**
  32250. * Add a joint to this impostor with a different impostor
  32251. * @param otherImpostor A physics imposter used to add a joint
  32252. * @param joint The joint to add
  32253. * @returns The physics imposter
  32254. */
  32255. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32256. /**
  32257. * Add an anchor to a cloth impostor
  32258. * @param otherImpostor rigid impostor to anchor to
  32259. * @param width ratio across width from 0 to 1
  32260. * @param height ratio up height from 0 to 1
  32261. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32262. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32263. * @returns impostor the soft imposter
  32264. */
  32265. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32266. /**
  32267. * Add a hook to a rope impostor
  32268. * @param otherImpostor rigid impostor to anchor to
  32269. * @param length ratio across rope from 0 to 1
  32270. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32271. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32272. * @returns impostor the rope imposter
  32273. */
  32274. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32275. /**
  32276. * Will keep this body still, in a sleep mode.
  32277. * @returns the physics imposter
  32278. */
  32279. sleep(): PhysicsImpostor;
  32280. /**
  32281. * Wake the body up.
  32282. * @returns The physics imposter
  32283. */
  32284. wakeUp(): PhysicsImpostor;
  32285. /**
  32286. * Clones the physics imposter
  32287. * @param newObject The physics imposter clones to this physics-enabled object
  32288. * @returns A nullable physics imposter
  32289. */
  32290. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32291. /**
  32292. * Disposes the physics imposter
  32293. */
  32294. dispose(): void;
  32295. /**
  32296. * Sets the delta position
  32297. * @param position The delta position amount
  32298. */
  32299. setDeltaPosition(position: Vector3): void;
  32300. /**
  32301. * Sets the delta rotation
  32302. * @param rotation The delta rotation amount
  32303. */
  32304. setDeltaRotation(rotation: Quaternion): void;
  32305. /**
  32306. * Gets the box size of the physics imposter and stores the result in the input parameter
  32307. * @param result Stores the box size
  32308. * @returns The physics imposter
  32309. */
  32310. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32311. /**
  32312. * Gets the radius of the physics imposter
  32313. * @returns Radius of the physics imposter
  32314. */
  32315. getRadius(): number;
  32316. /**
  32317. * Sync a bone with this impostor
  32318. * @param bone The bone to sync to the impostor.
  32319. * @param boneMesh The mesh that the bone is influencing.
  32320. * @param jointPivot The pivot of the joint / bone in local space.
  32321. * @param distToJoint Optional distance from the impostor to the joint.
  32322. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32323. */
  32324. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32325. /**
  32326. * Sync impostor to a bone
  32327. * @param bone The bone that the impostor will be synced to.
  32328. * @param boneMesh The mesh that the bone is influencing.
  32329. * @param jointPivot The pivot of the joint / bone in local space.
  32330. * @param distToJoint Optional distance from the impostor to the joint.
  32331. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32332. * @param boneAxis Optional vector3 axis the bone is aligned with
  32333. */
  32334. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32335. /**
  32336. * No-Imposter type
  32337. */
  32338. static NoImpostor: number;
  32339. /**
  32340. * Sphere-Imposter type
  32341. */
  32342. static SphereImpostor: number;
  32343. /**
  32344. * Box-Imposter type
  32345. */
  32346. static BoxImpostor: number;
  32347. /**
  32348. * Plane-Imposter type
  32349. */
  32350. static PlaneImpostor: number;
  32351. /**
  32352. * Mesh-imposter type
  32353. */
  32354. static MeshImpostor: number;
  32355. /**
  32356. * Capsule-Impostor type (Ammo.js plugin only)
  32357. */
  32358. static CapsuleImpostor: number;
  32359. /**
  32360. * Cylinder-Imposter type
  32361. */
  32362. static CylinderImpostor: number;
  32363. /**
  32364. * Particle-Imposter type
  32365. */
  32366. static ParticleImpostor: number;
  32367. /**
  32368. * Heightmap-Imposter type
  32369. */
  32370. static HeightmapImpostor: number;
  32371. /**
  32372. * ConvexHull-Impostor type (Ammo.js plugin only)
  32373. */
  32374. static ConvexHullImpostor: number;
  32375. /**
  32376. * Custom-Imposter type (Ammo.js plugin only)
  32377. */
  32378. static CustomImpostor: number;
  32379. /**
  32380. * Rope-Imposter type
  32381. */
  32382. static RopeImpostor: number;
  32383. /**
  32384. * Cloth-Imposter type
  32385. */
  32386. static ClothImpostor: number;
  32387. /**
  32388. * Softbody-Imposter type
  32389. */
  32390. static SoftbodyImpostor: number;
  32391. }
  32392. }
  32393. declare module BABYLON {
  32394. /**
  32395. * @hidden
  32396. **/
  32397. export class _CreationDataStorage {
  32398. closePath?: boolean;
  32399. closeArray?: boolean;
  32400. idx: number[];
  32401. dashSize: number;
  32402. gapSize: number;
  32403. path3D: Path3D;
  32404. pathArray: Vector3[][];
  32405. arc: number;
  32406. radius: number;
  32407. cap: number;
  32408. tessellation: number;
  32409. }
  32410. /**
  32411. * @hidden
  32412. **/
  32413. class _InstanceDataStorage {
  32414. visibleInstances: any;
  32415. batchCache: _InstancesBatch;
  32416. instancesBufferSize: number;
  32417. instancesBuffer: Nullable<Buffer>;
  32418. instancesData: Float32Array;
  32419. overridenInstanceCount: number;
  32420. isFrozen: boolean;
  32421. previousBatch: Nullable<_InstancesBatch>;
  32422. hardwareInstancedRendering: boolean;
  32423. sideOrientation: number;
  32424. manualUpdate: boolean;
  32425. previousRenderId: number;
  32426. }
  32427. /**
  32428. * @hidden
  32429. **/
  32430. export class _InstancesBatch {
  32431. mustReturn: boolean;
  32432. visibleInstances: Nullable<InstancedMesh[]>[];
  32433. renderSelf: boolean[];
  32434. hardwareInstancedRendering: boolean[];
  32435. }
  32436. /**
  32437. * @hidden
  32438. **/
  32439. class _ThinInstanceDataStorage {
  32440. instancesCount: number;
  32441. matrixBuffer: Nullable<Buffer>;
  32442. matrixBufferSize: number;
  32443. matrixData: Nullable<Float32Array>;
  32444. boundingVectors: Array<Vector3>;
  32445. worldMatrices: Nullable<Matrix[]>;
  32446. }
  32447. /**
  32448. * Class used to represent renderable models
  32449. */
  32450. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32451. /**
  32452. * Mesh side orientation : usually the external or front surface
  32453. */
  32454. static readonly FRONTSIDE: number;
  32455. /**
  32456. * Mesh side orientation : usually the internal or back surface
  32457. */
  32458. static readonly BACKSIDE: number;
  32459. /**
  32460. * Mesh side orientation : both internal and external or front and back surfaces
  32461. */
  32462. static readonly DOUBLESIDE: number;
  32463. /**
  32464. * Mesh side orientation : by default, `FRONTSIDE`
  32465. */
  32466. static readonly DEFAULTSIDE: number;
  32467. /**
  32468. * Mesh cap setting : no cap
  32469. */
  32470. static readonly NO_CAP: number;
  32471. /**
  32472. * Mesh cap setting : one cap at the beginning of the mesh
  32473. */
  32474. static readonly CAP_START: number;
  32475. /**
  32476. * Mesh cap setting : one cap at the end of the mesh
  32477. */
  32478. static readonly CAP_END: number;
  32479. /**
  32480. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32481. */
  32482. static readonly CAP_ALL: number;
  32483. /**
  32484. * Mesh pattern setting : no flip or rotate
  32485. */
  32486. static readonly NO_FLIP: number;
  32487. /**
  32488. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32489. */
  32490. static readonly FLIP_TILE: number;
  32491. /**
  32492. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32493. */
  32494. static readonly ROTATE_TILE: number;
  32495. /**
  32496. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32497. */
  32498. static readonly FLIP_ROW: number;
  32499. /**
  32500. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32501. */
  32502. static readonly ROTATE_ROW: number;
  32503. /**
  32504. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32505. */
  32506. static readonly FLIP_N_ROTATE_TILE: number;
  32507. /**
  32508. * Mesh pattern setting : rotate pattern and rotate
  32509. */
  32510. static readonly FLIP_N_ROTATE_ROW: number;
  32511. /**
  32512. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32513. */
  32514. static readonly CENTER: number;
  32515. /**
  32516. * Mesh tile positioning : part tiles on left
  32517. */
  32518. static readonly LEFT: number;
  32519. /**
  32520. * Mesh tile positioning : part tiles on right
  32521. */
  32522. static readonly RIGHT: number;
  32523. /**
  32524. * Mesh tile positioning : part tiles on top
  32525. */
  32526. static readonly TOP: number;
  32527. /**
  32528. * Mesh tile positioning : part tiles on bottom
  32529. */
  32530. static readonly BOTTOM: number;
  32531. /**
  32532. * Gets the default side orientation.
  32533. * @param orientation the orientation to value to attempt to get
  32534. * @returns the default orientation
  32535. * @hidden
  32536. */
  32537. static _GetDefaultSideOrientation(orientation?: number): number;
  32538. private _internalMeshDataInfo;
  32539. get computeBonesUsingShaders(): boolean;
  32540. set computeBonesUsingShaders(value: boolean);
  32541. /**
  32542. * An event triggered before rendering the mesh
  32543. */
  32544. get onBeforeRenderObservable(): Observable<Mesh>;
  32545. /**
  32546. * An event triggered before binding the mesh
  32547. */
  32548. get onBeforeBindObservable(): Observable<Mesh>;
  32549. /**
  32550. * An event triggered after rendering the mesh
  32551. */
  32552. get onAfterRenderObservable(): Observable<Mesh>;
  32553. /**
  32554. * An event triggered before drawing the mesh
  32555. */
  32556. get onBeforeDrawObservable(): Observable<Mesh>;
  32557. private _onBeforeDrawObserver;
  32558. /**
  32559. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32560. */
  32561. set onBeforeDraw(callback: () => void);
  32562. get hasInstances(): boolean;
  32563. get hasThinInstances(): boolean;
  32564. /**
  32565. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32566. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32567. */
  32568. delayLoadState: number;
  32569. /**
  32570. * Gets the list of instances created from this mesh
  32571. * it is not supposed to be modified manually.
  32572. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32573. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32574. */
  32575. instances: InstancedMesh[];
  32576. /**
  32577. * Gets the file containing delay loading data for this mesh
  32578. */
  32579. delayLoadingFile: string;
  32580. /** @hidden */
  32581. _binaryInfo: any;
  32582. /**
  32583. * User defined function used to change how LOD level selection is done
  32584. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32585. */
  32586. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32587. /**
  32588. * Gets or sets the morph target manager
  32589. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32590. */
  32591. get morphTargetManager(): Nullable<MorphTargetManager>;
  32592. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32593. /** @hidden */
  32594. _creationDataStorage: Nullable<_CreationDataStorage>;
  32595. /** @hidden */
  32596. _geometry: Nullable<Geometry>;
  32597. /** @hidden */
  32598. _delayInfo: Array<string>;
  32599. /** @hidden */
  32600. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32601. /** @hidden */
  32602. _instanceDataStorage: _InstanceDataStorage;
  32603. /** @hidden */
  32604. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32605. private _effectiveMaterial;
  32606. /** @hidden */
  32607. _shouldGenerateFlatShading: boolean;
  32608. /** @hidden */
  32609. _originalBuilderSideOrientation: number;
  32610. /**
  32611. * Use this property to change the original side orientation defined at construction time
  32612. */
  32613. overrideMaterialSideOrientation: Nullable<number>;
  32614. /**
  32615. * Gets the source mesh (the one used to clone this one from)
  32616. */
  32617. get source(): Nullable<Mesh>;
  32618. /**
  32619. * Gets the list of clones of this mesh
  32620. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32621. * Note that useClonedMeshMap=true is the default setting
  32622. */
  32623. get cloneMeshMap(): Nullable<{
  32624. [id: string]: Mesh | undefined;
  32625. }>;
  32626. /**
  32627. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32628. */
  32629. get isUnIndexed(): boolean;
  32630. set isUnIndexed(value: boolean);
  32631. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32632. get worldMatrixInstancedBuffer(): Float32Array;
  32633. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32634. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32635. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32636. /**
  32637. * @constructor
  32638. * @param name The value used by scene.getMeshByName() to do a lookup.
  32639. * @param scene The scene to add this mesh to.
  32640. * @param parent The parent of this mesh, if it has one
  32641. * @param source An optional Mesh from which geometry is shared, cloned.
  32642. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32643. * When false, achieved by calling a clone(), also passing False.
  32644. * This will make creation of children, recursive.
  32645. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32646. */
  32647. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32648. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32649. doNotInstantiate: boolean;
  32650. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32651. /**
  32652. * Gets the class name
  32653. * @returns the string "Mesh".
  32654. */
  32655. getClassName(): string;
  32656. /** @hidden */
  32657. get _isMesh(): boolean;
  32658. /**
  32659. * Returns a description of this mesh
  32660. * @param fullDetails define if full details about this mesh must be used
  32661. * @returns a descriptive string representing this mesh
  32662. */
  32663. toString(fullDetails?: boolean): string;
  32664. /** @hidden */
  32665. _unBindEffect(): void;
  32666. /**
  32667. * Gets a boolean indicating if this mesh has LOD
  32668. */
  32669. get hasLODLevels(): boolean;
  32670. /**
  32671. * Gets the list of MeshLODLevel associated with the current mesh
  32672. * @returns an array of MeshLODLevel
  32673. */
  32674. getLODLevels(): MeshLODLevel[];
  32675. private _sortLODLevels;
  32676. /**
  32677. * Add a mesh as LOD level triggered at the given distance.
  32678. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32679. * @param distance The distance from the center of the object to show this level
  32680. * @param mesh The mesh to be added as LOD level (can be null)
  32681. * @return This mesh (for chaining)
  32682. */
  32683. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32684. /**
  32685. * Returns the LOD level mesh at the passed distance or null if not found.
  32686. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32687. * @param distance The distance from the center of the object to show this level
  32688. * @returns a Mesh or `null`
  32689. */
  32690. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32691. /**
  32692. * Remove a mesh from the LOD array
  32693. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32694. * @param mesh defines the mesh to be removed
  32695. * @return This mesh (for chaining)
  32696. */
  32697. removeLODLevel(mesh: Mesh): Mesh;
  32698. /**
  32699. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32700. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32701. * @param camera defines the camera to use to compute distance
  32702. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32703. * @return This mesh (for chaining)
  32704. */
  32705. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32706. /**
  32707. * Gets the mesh internal Geometry object
  32708. */
  32709. get geometry(): Nullable<Geometry>;
  32710. /**
  32711. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32712. * @returns the total number of vertices
  32713. */
  32714. getTotalVertices(): number;
  32715. /**
  32716. * Returns the content of an associated vertex buffer
  32717. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32718. * - VertexBuffer.PositionKind
  32719. * - VertexBuffer.UVKind
  32720. * - VertexBuffer.UV2Kind
  32721. * - VertexBuffer.UV3Kind
  32722. * - VertexBuffer.UV4Kind
  32723. * - VertexBuffer.UV5Kind
  32724. * - VertexBuffer.UV6Kind
  32725. * - VertexBuffer.ColorKind
  32726. * - VertexBuffer.MatricesIndicesKind
  32727. * - VertexBuffer.MatricesIndicesExtraKind
  32728. * - VertexBuffer.MatricesWeightsKind
  32729. * - VertexBuffer.MatricesWeightsExtraKind
  32730. * @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
  32731. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32732. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32733. */
  32734. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32735. /**
  32736. * Returns the mesh VertexBuffer object from the requested `kind`
  32737. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32738. * - VertexBuffer.PositionKind
  32739. * - VertexBuffer.NormalKind
  32740. * - VertexBuffer.UVKind
  32741. * - VertexBuffer.UV2Kind
  32742. * - VertexBuffer.UV3Kind
  32743. * - VertexBuffer.UV4Kind
  32744. * - VertexBuffer.UV5Kind
  32745. * - VertexBuffer.UV6Kind
  32746. * - VertexBuffer.ColorKind
  32747. * - VertexBuffer.MatricesIndicesKind
  32748. * - VertexBuffer.MatricesIndicesExtraKind
  32749. * - VertexBuffer.MatricesWeightsKind
  32750. * - VertexBuffer.MatricesWeightsExtraKind
  32751. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32752. */
  32753. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32754. /**
  32755. * Tests if a specific vertex buffer is associated with this mesh
  32756. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32757. * - VertexBuffer.PositionKind
  32758. * - VertexBuffer.NormalKind
  32759. * - VertexBuffer.UVKind
  32760. * - VertexBuffer.UV2Kind
  32761. * - VertexBuffer.UV3Kind
  32762. * - VertexBuffer.UV4Kind
  32763. * - VertexBuffer.UV5Kind
  32764. * - VertexBuffer.UV6Kind
  32765. * - VertexBuffer.ColorKind
  32766. * - VertexBuffer.MatricesIndicesKind
  32767. * - VertexBuffer.MatricesIndicesExtraKind
  32768. * - VertexBuffer.MatricesWeightsKind
  32769. * - VertexBuffer.MatricesWeightsExtraKind
  32770. * @returns a boolean
  32771. */
  32772. isVerticesDataPresent(kind: string): boolean;
  32773. /**
  32774. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32775. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32776. * - VertexBuffer.PositionKind
  32777. * - VertexBuffer.UVKind
  32778. * - VertexBuffer.UV2Kind
  32779. * - VertexBuffer.UV3Kind
  32780. * - VertexBuffer.UV4Kind
  32781. * - VertexBuffer.UV5Kind
  32782. * - VertexBuffer.UV6Kind
  32783. * - VertexBuffer.ColorKind
  32784. * - VertexBuffer.MatricesIndicesKind
  32785. * - VertexBuffer.MatricesIndicesExtraKind
  32786. * - VertexBuffer.MatricesWeightsKind
  32787. * - VertexBuffer.MatricesWeightsExtraKind
  32788. * @returns a boolean
  32789. */
  32790. isVertexBufferUpdatable(kind: string): boolean;
  32791. /**
  32792. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32793. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32794. * - VertexBuffer.PositionKind
  32795. * - VertexBuffer.NormalKind
  32796. * - VertexBuffer.UVKind
  32797. * - VertexBuffer.UV2Kind
  32798. * - VertexBuffer.UV3Kind
  32799. * - VertexBuffer.UV4Kind
  32800. * - VertexBuffer.UV5Kind
  32801. * - VertexBuffer.UV6Kind
  32802. * - VertexBuffer.ColorKind
  32803. * - VertexBuffer.MatricesIndicesKind
  32804. * - VertexBuffer.MatricesIndicesExtraKind
  32805. * - VertexBuffer.MatricesWeightsKind
  32806. * - VertexBuffer.MatricesWeightsExtraKind
  32807. * @returns an array of strings
  32808. */
  32809. getVerticesDataKinds(): string[];
  32810. /**
  32811. * Returns a positive integer : the total number of indices in this mesh geometry.
  32812. * @returns the numner of indices or zero if the mesh has no geometry.
  32813. */
  32814. getTotalIndices(): number;
  32815. /**
  32816. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32817. * @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.
  32818. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32819. * @returns the indices array or an empty array if the mesh has no geometry
  32820. */
  32821. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32822. get isBlocked(): boolean;
  32823. /**
  32824. * Determine if the current mesh is ready to be rendered
  32825. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32826. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32827. * @returns true if all associated assets are ready (material, textures, shaders)
  32828. */
  32829. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32830. /**
  32831. * 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.
  32832. */
  32833. get areNormalsFrozen(): boolean;
  32834. /**
  32835. * 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.
  32836. * @returns the current mesh
  32837. */
  32838. freezeNormals(): Mesh;
  32839. /**
  32840. * 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
  32841. * @returns the current mesh
  32842. */
  32843. unfreezeNormals(): Mesh;
  32844. /**
  32845. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32846. */
  32847. set overridenInstanceCount(count: number);
  32848. /** @hidden */
  32849. _preActivate(): Mesh;
  32850. /** @hidden */
  32851. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32852. /** @hidden */
  32853. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32854. protected _afterComputeWorldMatrix(): void;
  32855. /** @hidden */
  32856. _postActivate(): void;
  32857. /**
  32858. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32859. * This means the mesh underlying bounding box and sphere are recomputed.
  32860. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32861. * @returns the current mesh
  32862. */
  32863. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32864. /** @hidden */
  32865. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32866. /**
  32867. * This function will subdivide the mesh into multiple submeshes
  32868. * @param count defines the expected number of submeshes
  32869. */
  32870. subdivide(count: number): void;
  32871. /**
  32872. * Copy a FloatArray into a specific associated vertex buffer
  32873. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32874. * - VertexBuffer.PositionKind
  32875. * - VertexBuffer.UVKind
  32876. * - VertexBuffer.UV2Kind
  32877. * - VertexBuffer.UV3Kind
  32878. * - VertexBuffer.UV4Kind
  32879. * - VertexBuffer.UV5Kind
  32880. * - VertexBuffer.UV6Kind
  32881. * - VertexBuffer.ColorKind
  32882. * - VertexBuffer.MatricesIndicesKind
  32883. * - VertexBuffer.MatricesIndicesExtraKind
  32884. * - VertexBuffer.MatricesWeightsKind
  32885. * - VertexBuffer.MatricesWeightsExtraKind
  32886. * @param data defines the data source
  32887. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32888. * @param stride defines the data stride size (can be null)
  32889. * @returns the current mesh
  32890. */
  32891. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32892. /**
  32893. * Delete a vertex buffer associated with this mesh
  32894. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32895. * - VertexBuffer.PositionKind
  32896. * - VertexBuffer.UVKind
  32897. * - VertexBuffer.UV2Kind
  32898. * - VertexBuffer.UV3Kind
  32899. * - VertexBuffer.UV4Kind
  32900. * - VertexBuffer.UV5Kind
  32901. * - VertexBuffer.UV6Kind
  32902. * - VertexBuffer.ColorKind
  32903. * - VertexBuffer.MatricesIndicesKind
  32904. * - VertexBuffer.MatricesIndicesExtraKind
  32905. * - VertexBuffer.MatricesWeightsKind
  32906. * - VertexBuffer.MatricesWeightsExtraKind
  32907. */
  32908. removeVerticesData(kind: string): void;
  32909. /**
  32910. * Flags an associated vertex buffer as updatable
  32911. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32912. * - VertexBuffer.PositionKind
  32913. * - VertexBuffer.UVKind
  32914. * - VertexBuffer.UV2Kind
  32915. * - VertexBuffer.UV3Kind
  32916. * - VertexBuffer.UV4Kind
  32917. * - VertexBuffer.UV5Kind
  32918. * - VertexBuffer.UV6Kind
  32919. * - VertexBuffer.ColorKind
  32920. * - VertexBuffer.MatricesIndicesKind
  32921. * - VertexBuffer.MatricesIndicesExtraKind
  32922. * - VertexBuffer.MatricesWeightsKind
  32923. * - VertexBuffer.MatricesWeightsExtraKind
  32924. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32925. */
  32926. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32927. /**
  32928. * Sets the mesh global Vertex Buffer
  32929. * @param buffer defines the buffer to use
  32930. * @returns the current mesh
  32931. */
  32932. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32933. /**
  32934. * Update a specific associated vertex buffer
  32935. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32936. * - VertexBuffer.PositionKind
  32937. * - VertexBuffer.UVKind
  32938. * - VertexBuffer.UV2Kind
  32939. * - VertexBuffer.UV3Kind
  32940. * - VertexBuffer.UV4Kind
  32941. * - VertexBuffer.UV5Kind
  32942. * - VertexBuffer.UV6Kind
  32943. * - VertexBuffer.ColorKind
  32944. * - VertexBuffer.MatricesIndicesKind
  32945. * - VertexBuffer.MatricesIndicesExtraKind
  32946. * - VertexBuffer.MatricesWeightsKind
  32947. * - VertexBuffer.MatricesWeightsExtraKind
  32948. * @param data defines the data source
  32949. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32950. * @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)
  32951. * @returns the current mesh
  32952. */
  32953. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32954. /**
  32955. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32956. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32957. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32958. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32959. * @returns the current mesh
  32960. */
  32961. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32962. /**
  32963. * Creates a un-shared specific occurence of the geometry for the mesh.
  32964. * @returns the current mesh
  32965. */
  32966. makeGeometryUnique(): Mesh;
  32967. /**
  32968. * Set the index buffer of this mesh
  32969. * @param indices defines the source data
  32970. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32971. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32972. * @returns the current mesh
  32973. */
  32974. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32975. /**
  32976. * Update the current index buffer
  32977. * @param indices defines the source data
  32978. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32979. * @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)
  32980. * @returns the current mesh
  32981. */
  32982. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32983. /**
  32984. * Invert the geometry to move from a right handed system to a left handed one.
  32985. * @returns the current mesh
  32986. */
  32987. toLeftHanded(): Mesh;
  32988. /** @hidden */
  32989. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32990. /** @hidden */
  32991. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32992. /**
  32993. * Registers for this mesh a javascript function called just before the rendering process
  32994. * @param func defines the function to call before rendering this mesh
  32995. * @returns the current mesh
  32996. */
  32997. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32998. /**
  32999. * Disposes a previously registered javascript function called before the rendering
  33000. * @param func defines the function to remove
  33001. * @returns the current mesh
  33002. */
  33003. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33004. /**
  33005. * Registers for this mesh a javascript function called just after the rendering is complete
  33006. * @param func defines the function to call after rendering this mesh
  33007. * @returns the current mesh
  33008. */
  33009. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33010. /**
  33011. * Disposes a previously registered javascript function called after the rendering.
  33012. * @param func defines the function to remove
  33013. * @returns the current mesh
  33014. */
  33015. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33016. /** @hidden */
  33017. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33018. /** @hidden */
  33019. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33020. /** @hidden */
  33021. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33022. /** @hidden */
  33023. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33024. /** @hidden */
  33025. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33026. /** @hidden */
  33027. _rebuild(): void;
  33028. /** @hidden */
  33029. _freeze(): void;
  33030. /** @hidden */
  33031. _unFreeze(): void;
  33032. /**
  33033. * 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
  33034. * @param subMesh defines the subMesh to render
  33035. * @param enableAlphaMode defines if alpha mode can be changed
  33036. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33037. * @returns the current mesh
  33038. */
  33039. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33040. private _onBeforeDraw;
  33041. /**
  33042. * Renormalize the mesh and patch it up if there are no weights
  33043. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33044. * However in the case of zero weights then we set just a single influence to 1.
  33045. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33046. */
  33047. cleanMatrixWeights(): void;
  33048. private normalizeSkinFourWeights;
  33049. private normalizeSkinWeightsAndExtra;
  33050. /**
  33051. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33052. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33053. * the user know there was an issue with importing the mesh
  33054. * @returns a validation object with skinned, valid and report string
  33055. */
  33056. validateSkinning(): {
  33057. skinned: boolean;
  33058. valid: boolean;
  33059. report: string;
  33060. };
  33061. /** @hidden */
  33062. _checkDelayState(): Mesh;
  33063. private _queueLoad;
  33064. /**
  33065. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33066. * A mesh is in the frustum if its bounding box intersects the frustum
  33067. * @param frustumPlanes defines the frustum to test
  33068. * @returns true if the mesh is in the frustum planes
  33069. */
  33070. isInFrustum(frustumPlanes: Plane[]): boolean;
  33071. /**
  33072. * Sets the mesh material by the material or multiMaterial `id` property
  33073. * @param id is a string identifying the material or the multiMaterial
  33074. * @returns the current mesh
  33075. */
  33076. setMaterialByID(id: string): Mesh;
  33077. /**
  33078. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33079. * @returns an array of IAnimatable
  33080. */
  33081. getAnimatables(): IAnimatable[];
  33082. /**
  33083. * Modifies the mesh geometry according to the passed transformation matrix.
  33084. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33085. * The mesh normals are modified using the same transformation.
  33086. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33087. * @param transform defines the transform matrix to use
  33088. * @see https://doc.babylonjs.com/resources/baking_transformations
  33089. * @returns the current mesh
  33090. */
  33091. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33092. /**
  33093. * Modifies the mesh geometry according to its own current World Matrix.
  33094. * The mesh World Matrix is then reset.
  33095. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33096. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33097. * @see https://doc.babylonjs.com/resources/baking_transformations
  33098. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33099. * @returns the current mesh
  33100. */
  33101. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33102. /** @hidden */
  33103. get _positions(): Nullable<Vector3[]>;
  33104. /** @hidden */
  33105. _resetPointsArrayCache(): Mesh;
  33106. /** @hidden */
  33107. _generatePointsArray(): boolean;
  33108. /**
  33109. * Returns a new Mesh object generated from the current mesh properties.
  33110. * This method must not get confused with createInstance()
  33111. * @param name is a string, the name given to the new mesh
  33112. * @param newParent can be any Node object (default `null`)
  33113. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33114. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33115. * @returns a new mesh
  33116. */
  33117. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33118. /**
  33119. * Releases resources associated with this mesh.
  33120. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33121. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33122. */
  33123. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33124. /** @hidden */
  33125. _disposeInstanceSpecificData(): void;
  33126. /** @hidden */
  33127. _disposeThinInstanceSpecificData(): void;
  33128. /**
  33129. * Modifies the mesh geometry according to a displacement map.
  33130. * 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.
  33131. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33132. * @param url is a string, the URL from the image file is to be downloaded.
  33133. * @param minHeight is the lower limit of the displacement.
  33134. * @param maxHeight is the upper limit of the displacement.
  33135. * @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.
  33136. * @param uvOffset is an optional vector2 used to offset UV.
  33137. * @param uvScale is an optional vector2 used to scale UV.
  33138. * @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.
  33139. * @returns the Mesh.
  33140. */
  33141. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33142. /**
  33143. * Modifies the mesh geometry according to a displacementMap buffer.
  33144. * 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.
  33145. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33146. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33147. * @param heightMapWidth is the width of the buffer image.
  33148. * @param heightMapHeight is the height of the buffer image.
  33149. * @param minHeight is the lower limit of the displacement.
  33150. * @param maxHeight is the upper limit of the displacement.
  33151. * @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.
  33152. * @param uvOffset is an optional vector2 used to offset UV.
  33153. * @param uvScale is an optional vector2 used to scale UV.
  33154. * @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.
  33155. * @returns the Mesh.
  33156. */
  33157. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33158. /**
  33159. * Modify the mesh to get a flat shading rendering.
  33160. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33161. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33162. * @returns current mesh
  33163. */
  33164. convertToFlatShadedMesh(): Mesh;
  33165. /**
  33166. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33167. * In other words, more vertices, no more indices and a single bigger VBO.
  33168. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33169. * @returns current mesh
  33170. */
  33171. convertToUnIndexedMesh(): Mesh;
  33172. /**
  33173. * Inverses facet orientations.
  33174. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33175. * @param flipNormals will also inverts the normals
  33176. * @returns current mesh
  33177. */
  33178. flipFaces(flipNormals?: boolean): Mesh;
  33179. /**
  33180. * Increase the number of facets and hence vertices in a mesh
  33181. * Vertex normals are interpolated from existing vertex normals
  33182. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33183. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33184. */
  33185. increaseVertices(numberPerEdge: number): void;
  33186. /**
  33187. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33188. * This will undo any application of covertToFlatShadedMesh
  33189. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33190. */
  33191. forceSharedVertices(): void;
  33192. /** @hidden */
  33193. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33194. /** @hidden */
  33195. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33196. /**
  33197. * Creates a new InstancedMesh object from the mesh model.
  33198. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33199. * @param name defines the name of the new instance
  33200. * @returns a new InstancedMesh
  33201. */
  33202. createInstance(name: string): InstancedMesh;
  33203. /**
  33204. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33205. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33206. * @returns the current mesh
  33207. */
  33208. synchronizeInstances(): Mesh;
  33209. /**
  33210. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33211. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33212. * This should be used together with the simplification to avoid disappearing triangles.
  33213. * @param successCallback an optional success callback to be called after the optimization finished.
  33214. * @returns the current mesh
  33215. */
  33216. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33217. /**
  33218. * Serialize current mesh
  33219. * @param serializationObject defines the object which will receive the serialization data
  33220. */
  33221. serialize(serializationObject: any): void;
  33222. /** @hidden */
  33223. _syncGeometryWithMorphTargetManager(): void;
  33224. /** @hidden */
  33225. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33226. /**
  33227. * Returns a new Mesh object parsed from the source provided.
  33228. * @param parsedMesh is the source
  33229. * @param scene defines the hosting scene
  33230. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33231. * @returns a new Mesh
  33232. */
  33233. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33234. /**
  33235. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33236. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33237. * @param name defines the name of the mesh to create
  33238. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33239. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33240. * @param closePath creates a seam between the first and the last points of each path of the path array
  33241. * @param offset is taken in account only if the `pathArray` is containing a single path
  33242. * @param scene defines the hosting scene
  33243. * @param updatable defines if the mesh must be flagged as updatable
  33244. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33245. * @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)
  33246. * @returns a new Mesh
  33247. */
  33248. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33249. /**
  33250. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33251. * @param name defines the name of the mesh to create
  33252. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33253. * @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
  33254. * @param scene defines the hosting scene
  33255. * @param updatable defines if the mesh must be flagged as updatable
  33256. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33257. * @returns a new Mesh
  33258. */
  33259. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33260. /**
  33261. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33262. * @param name defines the name of the mesh to create
  33263. * @param size sets the size (float) of each box side (default 1)
  33264. * @param scene defines the hosting scene
  33265. * @param updatable defines if the mesh must be flagged as updatable
  33266. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33267. * @returns a new Mesh
  33268. */
  33269. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33270. /**
  33271. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33272. * @param name defines the name of the mesh to create
  33273. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33274. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33275. * @param scene defines the hosting scene
  33276. * @param updatable defines if the mesh must be flagged as updatable
  33277. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33278. * @returns a new Mesh
  33279. */
  33280. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33281. /**
  33282. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33283. * @param name defines the name of the mesh to create
  33284. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33285. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33286. * @param scene defines the hosting scene
  33287. * @returns a new Mesh
  33288. */
  33289. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33290. /**
  33291. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33292. * @param name defines the name of the mesh to create
  33293. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33294. * @param diameterTop set the top cap diameter (floats, default 1)
  33295. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33296. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33297. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33298. * @param scene defines the hosting scene
  33299. * @param updatable defines if the mesh must be flagged as updatable
  33300. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33301. * @returns a new Mesh
  33302. */
  33303. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33304. /**
  33305. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33306. * @param name defines the name of the mesh to create
  33307. * @param diameter sets the diameter size (float) of the torus (default 1)
  33308. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33309. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33310. * @param scene defines the hosting scene
  33311. * @param updatable defines if the mesh must be flagged as updatable
  33312. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33313. * @returns a new Mesh
  33314. */
  33315. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33316. /**
  33317. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33318. * @param name defines the name of the mesh to create
  33319. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33320. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33321. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33322. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33323. * @param p the number of windings on X axis (positive integers, default 2)
  33324. * @param q the number of windings on Y axis (positive integers, default 3)
  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. * @returns a new Mesh
  33329. */
  33330. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33331. /**
  33332. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33333. * @param name defines the name of the mesh to create
  33334. * @param points is an array successive Vector3
  33335. * @param scene defines the hosting scene
  33336. * @param updatable defines if the mesh must be flagged as updatable
  33337. * @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).
  33338. * @returns a new Mesh
  33339. */
  33340. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33341. /**
  33342. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33343. * @param name defines the name of the mesh to create
  33344. * @param points is an array successive Vector3
  33345. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33346. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33347. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33348. * @param scene defines the hosting scene
  33349. * @param updatable defines if the mesh must be flagged as updatable
  33350. * @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)
  33351. * @returns a new Mesh
  33352. */
  33353. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33354. /**
  33355. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33356. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33357. * 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.
  33358. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33359. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33360. * Remember you can only change the shape positions, not their number when updating a polygon.
  33361. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33362. * @param name defines the name of the mesh to create
  33363. * @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
  33364. * @param scene defines the hosting scene
  33365. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33366. * @param updatable defines if the mesh must be flagged as updatable
  33367. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33368. * @param earcutInjection can be used to inject your own earcut reference
  33369. * @returns a new Mesh
  33370. */
  33371. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33372. /**
  33373. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33375. * @param name defines the name of the mesh to create
  33376. * @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
  33377. * @param depth defines the height of extrusion
  33378. * @param scene defines the hosting scene
  33379. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33380. * @param updatable defines if the mesh must be flagged as updatable
  33381. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33382. * @param earcutInjection can be used to inject your own earcut reference
  33383. * @returns a new Mesh
  33384. */
  33385. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33386. /**
  33387. * Creates an extruded shape mesh.
  33388. * 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
  33389. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33391. * @param name defines the name of the mesh to create
  33392. * @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
  33393. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33394. * @param scale is the value to scale the shape
  33395. * @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
  33396. * @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
  33397. * @param scene defines the hosting scene
  33398. * @param updatable defines if the mesh must be flagged as updatable
  33399. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33400. * @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)
  33401. * @returns a new Mesh
  33402. */
  33403. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33404. /**
  33405. * Creates an custom extruded shape mesh.
  33406. * The custom extrusion is a parametric shape.
  33407. * It has no predefined shape. Its final shape will depend on the input parameters.
  33408. * Please consider using the same method from the MeshBuilder class instead
  33409. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33410. * @param name defines the name of the mesh to create
  33411. * @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
  33412. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33413. * @param scaleFunction is a custom Javascript function called on each path point
  33414. * @param rotationFunction is a custom Javascript function called on each path point
  33415. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33416. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33417. * @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
  33418. * @param scene defines the hosting scene
  33419. * @param updatable defines if the mesh must be flagged as updatable
  33420. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33421. * @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)
  33422. * @returns a new Mesh
  33423. */
  33424. 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;
  33425. /**
  33426. * Creates lathe mesh.
  33427. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33428. * Please consider using the same method from the MeshBuilder class instead
  33429. * @param name defines the name of the mesh to create
  33430. * @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
  33431. * @param radius is the radius value of the lathe
  33432. * @param tessellation is the side number of the lathe.
  33433. * @param scene defines the hosting scene
  33434. * @param updatable defines if the mesh must be flagged as updatable
  33435. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33436. * @returns a new Mesh
  33437. */
  33438. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33439. /**
  33440. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33441. * @param name defines the name of the mesh to create
  33442. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33443. * @param scene defines the hosting scene
  33444. * @param updatable defines if the mesh must be flagged as updatable
  33445. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33446. * @returns a new Mesh
  33447. */
  33448. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33449. /**
  33450. * Creates a ground mesh.
  33451. * Please consider using the same method from the MeshBuilder class instead
  33452. * @param name defines the name of the mesh to create
  33453. * @param width set the width of the ground
  33454. * @param height set the height of the ground
  33455. * @param subdivisions sets the number of subdivisions per side
  33456. * @param scene defines the hosting scene
  33457. * @param updatable defines if the mesh must be flagged as updatable
  33458. * @returns a new Mesh
  33459. */
  33460. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33461. /**
  33462. * Creates a tiled ground mesh.
  33463. * Please consider using the same method from the MeshBuilder class instead
  33464. * @param name defines the name of the mesh to create
  33465. * @param xmin set the ground minimum X coordinate
  33466. * @param zmin set the ground minimum Y coordinate
  33467. * @param xmax set the ground maximum X coordinate
  33468. * @param zmax set the ground maximum Z coordinate
  33469. * @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
  33470. * @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
  33471. * @param scene defines the hosting scene
  33472. * @param updatable defines if the mesh must be flagged as updatable
  33473. * @returns a new Mesh
  33474. */
  33475. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33476. w: number;
  33477. h: number;
  33478. }, precision: {
  33479. w: number;
  33480. h: number;
  33481. }, scene: Scene, updatable?: boolean): Mesh;
  33482. /**
  33483. * Creates a ground mesh from a height map.
  33484. * Please consider using the same method from the MeshBuilder class instead
  33485. * @see https://doc.babylonjs.com/babylon101/height_map
  33486. * @param name defines the name of the mesh to create
  33487. * @param url sets the URL of the height map image resource
  33488. * @param width set the ground width size
  33489. * @param height set the ground height size
  33490. * @param subdivisions sets the number of subdivision per side
  33491. * @param minHeight is the minimum altitude on the ground
  33492. * @param maxHeight is the maximum altitude on the ground
  33493. * @param scene defines the hosting scene
  33494. * @param updatable defines if the mesh must be flagged as updatable
  33495. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33496. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33497. * @returns a new Mesh
  33498. */
  33499. 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;
  33500. /**
  33501. * Creates a tube mesh.
  33502. * The tube is a parametric shape.
  33503. * It has no predefined shape. Its final shape will depend on the input parameters.
  33504. * Please consider using the same method from the MeshBuilder class instead
  33505. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33506. * @param name defines the name of the mesh to create
  33507. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33508. * @param radius sets the tube radius size
  33509. * @param tessellation is the number of sides on the tubular surface
  33510. * @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
  33511. * @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
  33512. * @param scene defines the hosting scene
  33513. * @param updatable defines if the mesh must be flagged as updatable
  33514. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33515. * @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)
  33516. * @returns a new Mesh
  33517. */
  33518. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33519. (i: number, distance: number): number;
  33520. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33521. /**
  33522. * Creates a polyhedron mesh.
  33523. * Please consider using the same method from the MeshBuilder class instead.
  33524. * * 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
  33525. * * The parameter `size` (positive float, default 1) sets the polygon size
  33526. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33527. * * 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`
  33528. * * 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
  33529. * * 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)`)
  33530. * * 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
  33531. * * 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
  33532. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33533. * * 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
  33534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33535. * @param name defines the name of the mesh to create
  33536. * @param options defines the options used to create the mesh
  33537. * @param scene defines the hosting scene
  33538. * @returns a new Mesh
  33539. */
  33540. static CreatePolyhedron(name: string, options: {
  33541. type?: number;
  33542. size?: number;
  33543. sizeX?: number;
  33544. sizeY?: number;
  33545. sizeZ?: number;
  33546. custom?: any;
  33547. faceUV?: Vector4[];
  33548. faceColors?: Color4[];
  33549. updatable?: boolean;
  33550. sideOrientation?: number;
  33551. }, scene: Scene): Mesh;
  33552. /**
  33553. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33554. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33555. * * 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`)
  33556. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33557. * * 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
  33558. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33559. * * 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
  33560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33561. * @param name defines the name of the mesh
  33562. * @param options defines the options used to create the mesh
  33563. * @param scene defines the hosting scene
  33564. * @returns a new Mesh
  33565. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33566. */
  33567. static CreateIcoSphere(name: string, options: {
  33568. radius?: number;
  33569. flat?: boolean;
  33570. subdivisions?: number;
  33571. sideOrientation?: number;
  33572. updatable?: boolean;
  33573. }, scene: Scene): Mesh;
  33574. /**
  33575. * Creates a decal mesh.
  33576. * Please consider using the same method from the MeshBuilder class instead.
  33577. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33578. * @param name defines the name of the mesh
  33579. * @param sourceMesh defines the mesh receiving the decal
  33580. * @param position sets the position of the decal in world coordinates
  33581. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33582. * @param size sets the decal scaling
  33583. * @param angle sets the angle to rotate the decal
  33584. * @returns a new Mesh
  33585. */
  33586. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33587. /** Creates a Capsule Mesh
  33588. * @param name defines the name of the mesh.
  33589. * @param options the constructors options used to shape the mesh.
  33590. * @param scene defines the scene the mesh is scoped to.
  33591. * @returns the capsule mesh
  33592. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33593. */
  33594. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33595. /**
  33596. * Prepare internal position array for software CPU skinning
  33597. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33598. */
  33599. setPositionsForCPUSkinning(): Float32Array;
  33600. /**
  33601. * Prepare internal normal array for software CPU skinning
  33602. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33603. */
  33604. setNormalsForCPUSkinning(): Float32Array;
  33605. /**
  33606. * Updates the vertex buffer by applying transformation from the bones
  33607. * @param skeleton defines the skeleton to apply to current mesh
  33608. * @returns the current mesh
  33609. */
  33610. applySkeleton(skeleton: Skeleton): Mesh;
  33611. /**
  33612. * 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
  33613. * @param meshes defines the list of meshes to scan
  33614. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33615. */
  33616. static MinMax(meshes: AbstractMesh[]): {
  33617. min: Vector3;
  33618. max: Vector3;
  33619. };
  33620. /**
  33621. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33622. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33623. * @returns a vector3
  33624. */
  33625. static Center(meshesOrMinMaxVector: {
  33626. min: Vector3;
  33627. max: Vector3;
  33628. } | AbstractMesh[]): Vector3;
  33629. /**
  33630. * Merge the array of meshes into a single mesh for performance reasons.
  33631. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33632. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33633. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33634. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33635. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33636. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33637. * @returns a new mesh
  33638. */
  33639. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33640. /** @hidden */
  33641. addInstance(instance: InstancedMesh): void;
  33642. /** @hidden */
  33643. removeInstance(instance: InstancedMesh): void;
  33644. }
  33645. }
  33646. declare module BABYLON {
  33647. /**
  33648. * This is the base class of all the camera used in the application.
  33649. * @see https://doc.babylonjs.com/features/cameras
  33650. */
  33651. export class Camera extends Node {
  33652. /** @hidden */
  33653. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33654. /**
  33655. * This is the default projection mode used by the cameras.
  33656. * It helps recreating a feeling of perspective and better appreciate depth.
  33657. * This is the best way to simulate real life cameras.
  33658. */
  33659. static readonly PERSPECTIVE_CAMERA: number;
  33660. /**
  33661. * This helps creating camera with an orthographic mode.
  33662. * 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.
  33663. */
  33664. static readonly ORTHOGRAPHIC_CAMERA: number;
  33665. /**
  33666. * This is the default FOV mode for perspective cameras.
  33667. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33668. */
  33669. static readonly FOVMODE_VERTICAL_FIXED: number;
  33670. /**
  33671. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33672. */
  33673. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33674. /**
  33675. * This specifies ther is no need for a camera rig.
  33676. * Basically only one eye is rendered corresponding to the camera.
  33677. */
  33678. static readonly RIG_MODE_NONE: number;
  33679. /**
  33680. * Simulates a camera Rig with one blue eye and one red eye.
  33681. * This can be use with 3d blue and red glasses.
  33682. */
  33683. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33684. /**
  33685. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33686. */
  33687. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33688. /**
  33689. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33690. */
  33691. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33692. /**
  33693. * Defines that both eyes of the camera will be rendered over under each other.
  33694. */
  33695. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33696. /**
  33697. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33698. */
  33699. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33700. /**
  33701. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33702. */
  33703. static readonly RIG_MODE_VR: number;
  33704. /**
  33705. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33706. */
  33707. static readonly RIG_MODE_WEBVR: number;
  33708. /**
  33709. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33710. */
  33711. static readonly RIG_MODE_CUSTOM: number;
  33712. /**
  33713. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33714. */
  33715. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33716. /**
  33717. * Define the input manager associated with the camera.
  33718. */
  33719. inputs: CameraInputsManager<Camera>;
  33720. /** @hidden */
  33721. _position: Vector3;
  33722. /**
  33723. * Define the current local position of the camera in the scene
  33724. */
  33725. get position(): Vector3;
  33726. set position(newPosition: Vector3);
  33727. protected _upVector: Vector3;
  33728. /**
  33729. * The vector the camera should consider as up.
  33730. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  33731. */
  33732. set upVector(vec: Vector3);
  33733. get upVector(): Vector3;
  33734. /**
  33735. * Define the current limit on the left side for an orthographic camera
  33736. * In scene unit
  33737. */
  33738. orthoLeft: Nullable<number>;
  33739. /**
  33740. * Define the current limit on the right side for an orthographic camera
  33741. * In scene unit
  33742. */
  33743. orthoRight: Nullable<number>;
  33744. /**
  33745. * Define the current limit on the bottom side for an orthographic camera
  33746. * In scene unit
  33747. */
  33748. orthoBottom: Nullable<number>;
  33749. /**
  33750. * Define the current limit on the top side for an orthographic camera
  33751. * In scene unit
  33752. */
  33753. orthoTop: Nullable<number>;
  33754. /**
  33755. * Field Of View is set in Radians. (default is 0.8)
  33756. */
  33757. fov: number;
  33758. /**
  33759. * Define the minimum distance the camera can see from.
  33760. * This is important to note that the depth buffer are not infinite and the closer it starts
  33761. * the more your scene might encounter depth fighting issue.
  33762. */
  33763. minZ: number;
  33764. /**
  33765. * Define the maximum distance the camera can see to.
  33766. * This is important to note that the depth buffer are not infinite and the further it end
  33767. * the more your scene might encounter depth fighting issue.
  33768. */
  33769. maxZ: number;
  33770. /**
  33771. * Define the default inertia of the camera.
  33772. * This helps giving a smooth feeling to the camera movement.
  33773. */
  33774. inertia: number;
  33775. /**
  33776. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  33777. */
  33778. mode: number;
  33779. /**
  33780. * Define whether the camera is intermediate.
  33781. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  33782. */
  33783. isIntermediate: boolean;
  33784. /**
  33785. * Define the viewport of the camera.
  33786. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  33787. */
  33788. viewport: Viewport;
  33789. /**
  33790. * Restricts the camera to viewing objects with the same layerMask.
  33791. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  33792. */
  33793. layerMask: number;
  33794. /**
  33795. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  33796. */
  33797. fovMode: number;
  33798. /**
  33799. * Rig mode of the camera.
  33800. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  33801. * This is normally controlled byt the camera themselves as internal use.
  33802. */
  33803. cameraRigMode: number;
  33804. /**
  33805. * Defines the distance between both "eyes" in case of a RIG
  33806. */
  33807. interaxialDistance: number;
  33808. /**
  33809. * Defines if stereoscopic rendering is done side by side or over under.
  33810. */
  33811. isStereoscopicSideBySide: boolean;
  33812. /**
  33813. * 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
  33814. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  33815. * else in the scene. (Eg. security camera)
  33816. *
  33817. * 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)
  33818. */
  33819. customRenderTargets: RenderTargetTexture[];
  33820. /**
  33821. * When set, the camera will render to this render target instead of the default canvas
  33822. *
  33823. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  33824. */
  33825. outputRenderTarget: Nullable<RenderTargetTexture>;
  33826. /**
  33827. * Observable triggered when the camera view matrix has changed.
  33828. */
  33829. onViewMatrixChangedObservable: Observable<Camera>;
  33830. /**
  33831. * Observable triggered when the camera Projection matrix has changed.
  33832. */
  33833. onProjectionMatrixChangedObservable: Observable<Camera>;
  33834. /**
  33835. * Observable triggered when the inputs have been processed.
  33836. */
  33837. onAfterCheckInputsObservable: Observable<Camera>;
  33838. /**
  33839. * Observable triggered when reset has been called and applied to the camera.
  33840. */
  33841. onRestoreStateObservable: Observable<Camera>;
  33842. /**
  33843. * Is this camera a part of a rig system?
  33844. */
  33845. isRigCamera: boolean;
  33846. /**
  33847. * If isRigCamera set to true this will be set with the parent camera.
  33848. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  33849. */
  33850. rigParent?: Camera;
  33851. /** @hidden */
  33852. _cameraRigParams: any;
  33853. /** @hidden */
  33854. _rigCameras: Camera[];
  33855. /** @hidden */
  33856. _rigPostProcess: Nullable<PostProcess>;
  33857. protected _webvrViewMatrix: Matrix;
  33858. /** @hidden */
  33859. _skipRendering: boolean;
  33860. /** @hidden */
  33861. _projectionMatrix: Matrix;
  33862. /** @hidden */
  33863. _postProcesses: Nullable<PostProcess>[];
  33864. /** @hidden */
  33865. _activeMeshes: SmartArray<AbstractMesh>;
  33866. protected _globalPosition: Vector3;
  33867. /** @hidden */
  33868. _computedViewMatrix: Matrix;
  33869. private _doNotComputeProjectionMatrix;
  33870. private _transformMatrix;
  33871. private _frustumPlanes;
  33872. private _refreshFrustumPlanes;
  33873. private _storedFov;
  33874. private _stateStored;
  33875. /**
  33876. * Instantiates a new camera object.
  33877. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  33878. * @see https://doc.babylonjs.com/features/cameras
  33879. * @param name Defines the name of the camera in the scene
  33880. * @param position Defines the position of the camera
  33881. * @param scene Defines the scene the camera belongs too
  33882. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  33883. */
  33884. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  33885. /**
  33886. * Store current camera state (fov, position, etc..)
  33887. * @returns the camera
  33888. */
  33889. storeState(): Camera;
  33890. /**
  33891. * Restores the camera state values if it has been stored. You must call storeState() first
  33892. */
  33893. protected _restoreStateValues(): boolean;
  33894. /**
  33895. * Restored camera state. You must call storeState() first.
  33896. * @returns true if restored and false otherwise
  33897. */
  33898. restoreState(): boolean;
  33899. /**
  33900. * Gets the class name of the camera.
  33901. * @returns the class name
  33902. */
  33903. getClassName(): string;
  33904. /** @hidden */
  33905. readonly _isCamera: boolean;
  33906. /**
  33907. * Gets a string representation of the camera useful for debug purpose.
  33908. * @param fullDetails Defines that a more verboe level of logging is required
  33909. * @returns the string representation
  33910. */
  33911. toString(fullDetails?: boolean): string;
  33912. /**
  33913. * Gets the current world space position of the camera.
  33914. */
  33915. get globalPosition(): Vector3;
  33916. /**
  33917. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  33918. * @returns the active meshe list
  33919. */
  33920. getActiveMeshes(): SmartArray<AbstractMesh>;
  33921. /**
  33922. * Check whether a mesh is part of the current active mesh list of the camera
  33923. * @param mesh Defines the mesh to check
  33924. * @returns true if active, false otherwise
  33925. */
  33926. isActiveMesh(mesh: Mesh): boolean;
  33927. /**
  33928. * Is this camera ready to be used/rendered
  33929. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  33930. * @return true if the camera is ready
  33931. */
  33932. isReady(completeCheck?: boolean): boolean;
  33933. /** @hidden */
  33934. _initCache(): void;
  33935. /** @hidden */
  33936. _updateCache(ignoreParentClass?: boolean): void;
  33937. /** @hidden */
  33938. _isSynchronized(): boolean;
  33939. /** @hidden */
  33940. _isSynchronizedViewMatrix(): boolean;
  33941. /** @hidden */
  33942. _isSynchronizedProjectionMatrix(): boolean;
  33943. /**
  33944. * Attach the input controls to a specific dom element to get the input from.
  33945. * @param element Defines the element the controls should be listened from
  33946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33947. */
  33948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33949. /**
  33950. * Detach the current controls from the specified dom element.
  33951. * @param element Defines the element to stop listening the inputs from
  33952. */
  33953. detachControl(element: HTMLElement): void;
  33954. /**
  33955. * Update the camera state according to the different inputs gathered during the frame.
  33956. */
  33957. update(): void;
  33958. /** @hidden */
  33959. _checkInputs(): void;
  33960. /** @hidden */
  33961. get rigCameras(): Camera[];
  33962. /**
  33963. * Gets the post process used by the rig cameras
  33964. */
  33965. get rigPostProcess(): Nullable<PostProcess>;
  33966. /**
  33967. * Internal, gets the first post proces.
  33968. * @returns the first post process to be run on this camera.
  33969. */
  33970. _getFirstPostProcess(): Nullable<PostProcess>;
  33971. private _cascadePostProcessesToRigCams;
  33972. /**
  33973. * Attach a post process to the camera.
  33974. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33975. * @param postProcess The post process to attach to the camera
  33976. * @param insertAt The position of the post process in case several of them are in use in the scene
  33977. * @returns the position the post process has been inserted at
  33978. */
  33979. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  33980. /**
  33981. * Detach a post process to the camera.
  33982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33983. * @param postProcess The post process to detach from the camera
  33984. */
  33985. detachPostProcess(postProcess: PostProcess): void;
  33986. /**
  33987. * Gets the current world matrix of the camera
  33988. */
  33989. getWorldMatrix(): Matrix;
  33990. /** @hidden */
  33991. _getViewMatrix(): Matrix;
  33992. /**
  33993. * Gets the current view matrix of the camera.
  33994. * @param force forces the camera to recompute the matrix without looking at the cached state
  33995. * @returns the view matrix
  33996. */
  33997. getViewMatrix(force?: boolean): Matrix;
  33998. /**
  33999. * Freeze the projection matrix.
  34000. * It will prevent the cache check of the camera projection compute and can speed up perf
  34001. * if no parameter of the camera are meant to change
  34002. * @param projection Defines manually a projection if necessary
  34003. */
  34004. freezeProjectionMatrix(projection?: Matrix): void;
  34005. /**
  34006. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  34007. */
  34008. unfreezeProjectionMatrix(): void;
  34009. /**
  34010. * Gets the current projection matrix of the camera.
  34011. * @param force forces the camera to recompute the matrix without looking at the cached state
  34012. * @returns the projection matrix
  34013. */
  34014. getProjectionMatrix(force?: boolean): Matrix;
  34015. /**
  34016. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  34017. * @returns a Matrix
  34018. */
  34019. getTransformationMatrix(): Matrix;
  34020. private _updateFrustumPlanes;
  34021. /**
  34022. * Checks if a cullable object (mesh...) is in the camera frustum
  34023. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  34024. * @param target The object to check
  34025. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  34026. * @returns true if the object is in frustum otherwise false
  34027. */
  34028. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  34029. /**
  34030. * Checks if a cullable object (mesh...) is in the camera frustum
  34031. * Unlike isInFrustum this cheks the full bounding box
  34032. * @param target The object to check
  34033. * @returns true if the object is in frustum otherwise false
  34034. */
  34035. isCompletelyInFrustum(target: ICullable): boolean;
  34036. /**
  34037. * Gets a ray in the forward direction from the camera.
  34038. * @param length Defines the length of the ray to create
  34039. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34040. * @param origin Defines the start point of the ray which defaults to the camera position
  34041. * @returns the forward ray
  34042. */
  34043. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34044. /**
  34045. * Gets a ray in the forward direction from the camera.
  34046. * @param refRay the ray to (re)use when setting the values
  34047. * @param length Defines the length of the ray to create
  34048. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34049. * @param origin Defines the start point of the ray which defaults to the camera position
  34050. * @returns the forward ray
  34051. */
  34052. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34053. /**
  34054. * Releases resources associated with this node.
  34055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34057. */
  34058. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34059. /** @hidden */
  34060. _isLeftCamera: boolean;
  34061. /**
  34062. * Gets the left camera of a rig setup in case of Rigged Camera
  34063. */
  34064. get isLeftCamera(): boolean;
  34065. /** @hidden */
  34066. _isRightCamera: boolean;
  34067. /**
  34068. * Gets the right camera of a rig setup in case of Rigged Camera
  34069. */
  34070. get isRightCamera(): boolean;
  34071. /**
  34072. * Gets the left camera of a rig setup in case of Rigged Camera
  34073. */
  34074. get leftCamera(): Nullable<FreeCamera>;
  34075. /**
  34076. * Gets the right camera of a rig setup in case of Rigged Camera
  34077. */
  34078. get rightCamera(): Nullable<FreeCamera>;
  34079. /**
  34080. * Gets the left camera target of a rig setup in case of Rigged Camera
  34081. * @returns the target position
  34082. */
  34083. getLeftTarget(): Nullable<Vector3>;
  34084. /**
  34085. * Gets the right camera target of a rig setup in case of Rigged Camera
  34086. * @returns the target position
  34087. */
  34088. getRightTarget(): Nullable<Vector3>;
  34089. /**
  34090. * @hidden
  34091. */
  34092. setCameraRigMode(mode: number, rigParams: any): void;
  34093. /** @hidden */
  34094. static _setStereoscopicRigMode(camera: Camera): void;
  34095. /** @hidden */
  34096. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34097. /** @hidden */
  34098. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34099. /** @hidden */
  34100. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34101. /** @hidden */
  34102. _getVRProjectionMatrix(): Matrix;
  34103. protected _updateCameraRotationMatrix(): void;
  34104. protected _updateWebVRCameraRotationMatrix(): void;
  34105. /**
  34106. * This function MUST be overwritten by the different WebVR cameras available.
  34107. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34108. * @hidden
  34109. */
  34110. _getWebVRProjectionMatrix(): Matrix;
  34111. /**
  34112. * This function MUST be overwritten by the different WebVR cameras available.
  34113. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34114. * @hidden
  34115. */
  34116. _getWebVRViewMatrix(): Matrix;
  34117. /** @hidden */
  34118. setCameraRigParameter(name: string, value: any): void;
  34119. /**
  34120. * needs to be overridden by children so sub has required properties to be copied
  34121. * @hidden
  34122. */
  34123. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34124. /**
  34125. * May need to be overridden by children
  34126. * @hidden
  34127. */
  34128. _updateRigCameras(): void;
  34129. /** @hidden */
  34130. _setupInputs(): void;
  34131. /**
  34132. * Serialiaze the camera setup to a json represention
  34133. * @returns the JSON representation
  34134. */
  34135. serialize(): any;
  34136. /**
  34137. * Clones the current camera.
  34138. * @param name The cloned camera name
  34139. * @returns the cloned camera
  34140. */
  34141. clone(name: string): Camera;
  34142. /**
  34143. * Gets the direction of the camera relative to a given local axis.
  34144. * @param localAxis Defines the reference axis to provide a relative direction.
  34145. * @return the direction
  34146. */
  34147. getDirection(localAxis: Vector3): Vector3;
  34148. /**
  34149. * Returns the current camera absolute rotation
  34150. */
  34151. get absoluteRotation(): Quaternion;
  34152. /**
  34153. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34154. * @param localAxis Defines the reference axis to provide a relative direction.
  34155. * @param result Defines the vector to store the result in
  34156. */
  34157. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34158. /**
  34159. * Gets a camera constructor for a given camera type
  34160. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34161. * @param name The name of the camera the result will be able to instantiate
  34162. * @param scene The scene the result will construct the camera in
  34163. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34164. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34165. * @returns a factory method to construc the camera
  34166. */
  34167. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34168. /**
  34169. * Compute the world matrix of the camera.
  34170. * @returns the camera world matrix
  34171. */
  34172. computeWorldMatrix(): Matrix;
  34173. /**
  34174. * Parse a JSON and creates the camera from the parsed information
  34175. * @param parsedCamera The JSON to parse
  34176. * @param scene The scene to instantiate the camera in
  34177. * @returns the newly constructed camera
  34178. */
  34179. static Parse(parsedCamera: any, scene: Scene): Camera;
  34180. }
  34181. }
  34182. declare module BABYLON {
  34183. /**
  34184. * Class containing static functions to help procedurally build meshes
  34185. */
  34186. export class DiscBuilder {
  34187. /**
  34188. * Creates a plane polygonal mesh. By default, this is a disc
  34189. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34190. * * 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
  34191. * * 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
  34192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34193. * * 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
  34194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34195. * @param name defines the name of the mesh
  34196. * @param options defines the options used to create the mesh
  34197. * @param scene defines the hosting scene
  34198. * @returns the plane polygonal mesh
  34199. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34200. */
  34201. static CreateDisc(name: string, options: {
  34202. radius?: number;
  34203. tessellation?: number;
  34204. arc?: number;
  34205. updatable?: boolean;
  34206. sideOrientation?: number;
  34207. frontUVs?: Vector4;
  34208. backUVs?: Vector4;
  34209. }, scene?: Nullable<Scene>): Mesh;
  34210. }
  34211. }
  34212. declare module BABYLON {
  34213. /**
  34214. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34215. *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.
  34216. * The SPS is also a particle system. It provides some methods to manage the particles.
  34217. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34218. *
  34219. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34220. */
  34221. export class SolidParticleSystem implements IDisposable {
  34222. /**
  34223. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34224. * Example : var p = SPS.particles[i];
  34225. */
  34226. particles: SolidParticle[];
  34227. /**
  34228. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34229. */
  34230. nbParticles: number;
  34231. /**
  34232. * If the particles must ever face the camera (default false). Useful for planar particles.
  34233. */
  34234. billboard: boolean;
  34235. /**
  34236. * Recompute normals when adding a shape
  34237. */
  34238. recomputeNormals: boolean;
  34239. /**
  34240. * This a counter ofr your own usage. It's not set by any SPS functions.
  34241. */
  34242. counter: number;
  34243. /**
  34244. * The SPS name. This name is also given to the underlying mesh.
  34245. */
  34246. name: string;
  34247. /**
  34248. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34249. */
  34250. mesh: Mesh;
  34251. /**
  34252. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34253. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34254. */
  34255. vars: any;
  34256. /**
  34257. * This array is populated when the SPS is set as 'pickable'.
  34258. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34259. * Each element of this array is an object `{idx: int, faceId: int}`.
  34260. * `idx` is the picked particle index in the `SPS.particles` array
  34261. * `faceId` is the picked face index counted within this particle.
  34262. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34263. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34264. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34265. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34266. */
  34267. pickedParticles: {
  34268. idx: number;
  34269. faceId: number;
  34270. }[];
  34271. /**
  34272. * This array is populated when the SPS is set as 'pickable'
  34273. * Each key of this array is a submesh index.
  34274. * Each element of this array is a second array defined like this :
  34275. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34276. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34277. * `idx` is the picked particle index in the `SPS.particles` array
  34278. * `faceId` is the picked face index counted within this particle.
  34279. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34280. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34281. */
  34282. pickedBySubMesh: {
  34283. idx: number;
  34284. faceId: number;
  34285. }[][];
  34286. /**
  34287. * This array is populated when `enableDepthSort` is set to true.
  34288. * Each element of this array is an instance of the class DepthSortedParticle.
  34289. */
  34290. depthSortedParticles: DepthSortedParticle[];
  34291. /**
  34292. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34293. * @hidden
  34294. */
  34295. _bSphereOnly: boolean;
  34296. /**
  34297. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34298. * @hidden
  34299. */
  34300. _bSphereRadiusFactor: number;
  34301. private _scene;
  34302. private _positions;
  34303. private _indices;
  34304. private _normals;
  34305. private _colors;
  34306. private _uvs;
  34307. private _indices32;
  34308. private _positions32;
  34309. private _normals32;
  34310. private _fixedNormal32;
  34311. private _colors32;
  34312. private _uvs32;
  34313. private _index;
  34314. private _updatable;
  34315. private _pickable;
  34316. private _isVisibilityBoxLocked;
  34317. private _alwaysVisible;
  34318. private _depthSort;
  34319. private _expandable;
  34320. private _shapeCounter;
  34321. private _copy;
  34322. private _color;
  34323. private _computeParticleColor;
  34324. private _computeParticleTexture;
  34325. private _computeParticleRotation;
  34326. private _computeParticleVertex;
  34327. private _computeBoundingBox;
  34328. private _depthSortParticles;
  34329. private _camera;
  34330. private _mustUnrotateFixedNormals;
  34331. private _particlesIntersect;
  34332. private _needs32Bits;
  34333. private _isNotBuilt;
  34334. private _lastParticleId;
  34335. private _idxOfId;
  34336. private _multimaterialEnabled;
  34337. private _useModelMaterial;
  34338. private _indicesByMaterial;
  34339. private _materialIndexes;
  34340. private _depthSortFunction;
  34341. private _materialSortFunction;
  34342. private _materials;
  34343. private _multimaterial;
  34344. private _materialIndexesById;
  34345. private _defaultMaterial;
  34346. private _autoUpdateSubMeshes;
  34347. private _tmpVertex;
  34348. /**
  34349. * Creates a SPS (Solid Particle System) object.
  34350. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34351. * @param scene (Scene) is the scene in which the SPS is added.
  34352. * @param options defines the options of the sps e.g.
  34353. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34354. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34355. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34356. * * 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.
  34357. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34358. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34359. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34360. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34361. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34362. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34363. */
  34364. constructor(name: string, scene: Scene, options?: {
  34365. updatable?: boolean;
  34366. isPickable?: boolean;
  34367. enableDepthSort?: boolean;
  34368. particleIntersection?: boolean;
  34369. boundingSphereOnly?: boolean;
  34370. bSphereRadiusFactor?: number;
  34371. expandable?: boolean;
  34372. useModelMaterial?: boolean;
  34373. enableMultiMaterial?: boolean;
  34374. });
  34375. /**
  34376. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34377. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34378. * @returns the created mesh
  34379. */
  34380. buildMesh(): Mesh;
  34381. /**
  34382. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34383. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34384. * Thus the particles generated from `digest()` have their property `position` set yet.
  34385. * @param mesh ( Mesh ) is the mesh to be digested
  34386. * @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
  34387. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34388. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34389. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34390. * @returns the current SPS
  34391. */
  34392. digest(mesh: Mesh, options?: {
  34393. facetNb?: number;
  34394. number?: number;
  34395. delta?: number;
  34396. storage?: [];
  34397. }): SolidParticleSystem;
  34398. /**
  34399. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34400. * @hidden
  34401. */
  34402. private _unrotateFixedNormals;
  34403. /**
  34404. * Resets the temporary working copy particle
  34405. * @hidden
  34406. */
  34407. private _resetCopy;
  34408. /**
  34409. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34410. * @param p the current index in the positions array to be updated
  34411. * @param ind the current index in the indices array
  34412. * @param shape a Vector3 array, the shape geometry
  34413. * @param positions the positions array to be updated
  34414. * @param meshInd the shape indices array
  34415. * @param indices the indices array to be updated
  34416. * @param meshUV the shape uv array
  34417. * @param uvs the uv array to be updated
  34418. * @param meshCol the shape color array
  34419. * @param colors the color array to be updated
  34420. * @param meshNor the shape normals array
  34421. * @param normals the normals array to be updated
  34422. * @param idx the particle index
  34423. * @param idxInShape the particle index in its shape
  34424. * @param options the addShape() method passed options
  34425. * @model the particle model
  34426. * @hidden
  34427. */
  34428. private _meshBuilder;
  34429. /**
  34430. * Returns a shape Vector3 array from positions float array
  34431. * @param positions float array
  34432. * @returns a vector3 array
  34433. * @hidden
  34434. */
  34435. private _posToShape;
  34436. /**
  34437. * Returns a shapeUV array from a float uvs (array deep copy)
  34438. * @param uvs as a float array
  34439. * @returns a shapeUV array
  34440. * @hidden
  34441. */
  34442. private _uvsToShapeUV;
  34443. /**
  34444. * Adds a new particle object in the particles array
  34445. * @param idx particle index in particles array
  34446. * @param id particle id
  34447. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34448. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34449. * @param model particle ModelShape object
  34450. * @param shapeId model shape identifier
  34451. * @param idxInShape index of the particle in the current model
  34452. * @param bInfo model bounding info object
  34453. * @param storage target storage array, if any
  34454. * @hidden
  34455. */
  34456. private _addParticle;
  34457. /**
  34458. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34459. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34460. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34461. * @param nb (positive integer) the number of particles to be created from this model
  34462. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34463. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34464. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34465. * @returns the number of shapes in the system
  34466. */
  34467. addShape(mesh: Mesh, nb: number, options?: {
  34468. positionFunction?: any;
  34469. vertexFunction?: any;
  34470. storage?: [];
  34471. }): number;
  34472. /**
  34473. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34474. * @hidden
  34475. */
  34476. private _rebuildParticle;
  34477. /**
  34478. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34479. * @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.
  34480. * @returns the SPS.
  34481. */
  34482. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34483. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34484. * Returns an array with the removed particles.
  34485. * 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.
  34486. * The SPS can't be empty so at least one particle needs to remain in place.
  34487. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34488. * @param start index of the first particle to remove
  34489. * @param end index of the last particle to remove (included)
  34490. * @returns an array populated with the removed particles
  34491. */
  34492. removeParticles(start: number, end: number): SolidParticle[];
  34493. /**
  34494. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34495. * @param solidParticleArray an array populated with Solid Particles objects
  34496. * @returns the SPS
  34497. */
  34498. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34499. /**
  34500. * Creates a new particle and modifies the SPS mesh geometry :
  34501. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34502. * - calls _addParticle() to populate the particle array
  34503. * factorized code from addShape() and insertParticlesFromArray()
  34504. * @param idx particle index in the particles array
  34505. * @param i particle index in its shape
  34506. * @param modelShape particle ModelShape object
  34507. * @param shape shape vertex array
  34508. * @param meshInd shape indices array
  34509. * @param meshUV shape uv array
  34510. * @param meshCol shape color array
  34511. * @param meshNor shape normals array
  34512. * @param bbInfo shape bounding info
  34513. * @param storage target particle storage
  34514. * @options addShape() passed options
  34515. * @hidden
  34516. */
  34517. private _insertNewParticle;
  34518. /**
  34519. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34520. * This method calls `updateParticle()` for each particle of the SPS.
  34521. * For an animated SPS, it is usually called within the render loop.
  34522. * 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.
  34523. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34524. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34525. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34526. * @returns the SPS.
  34527. */
  34528. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34529. /**
  34530. * Disposes the SPS.
  34531. */
  34532. dispose(): void;
  34533. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34534. * idx is the particle index in the SPS
  34535. * faceId is the picked face index counted within this particle.
  34536. * Returns null if the pickInfo can't identify a picked particle.
  34537. * @param pickingInfo (PickingInfo object)
  34538. * @returns {idx: number, faceId: number} or null
  34539. */
  34540. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34541. idx: number;
  34542. faceId: number;
  34543. }>;
  34544. /**
  34545. * Returns a SolidParticle object from its identifier : particle.id
  34546. * @param id (integer) the particle Id
  34547. * @returns the searched particle or null if not found in the SPS.
  34548. */
  34549. getParticleById(id: number): Nullable<SolidParticle>;
  34550. /**
  34551. * Returns a new array populated with the particles having the passed shapeId.
  34552. * @param shapeId (integer) the shape identifier
  34553. * @returns a new solid particle array
  34554. */
  34555. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34556. /**
  34557. * Populates the passed array "ref" with the particles having the passed shapeId.
  34558. * @param shapeId the shape identifier
  34559. * @returns the SPS
  34560. * @param ref
  34561. */
  34562. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34563. /**
  34564. * Computes the required SubMeshes according the materials assigned to the particles.
  34565. * @returns the solid particle system.
  34566. * Does nothing if called before the SPS mesh is built.
  34567. */
  34568. computeSubMeshes(): SolidParticleSystem;
  34569. /**
  34570. * Sorts the solid particles by material when MultiMaterial is enabled.
  34571. * Updates the indices32 array.
  34572. * Updates the indicesByMaterial array.
  34573. * Updates the mesh indices array.
  34574. * @returns the SPS
  34575. * @hidden
  34576. */
  34577. private _sortParticlesByMaterial;
  34578. /**
  34579. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34580. * @hidden
  34581. */
  34582. private _setMaterialIndexesById;
  34583. /**
  34584. * Returns an array with unique values of Materials from the passed array
  34585. * @param array the material array to be checked and filtered
  34586. * @hidden
  34587. */
  34588. private _filterUniqueMaterialId;
  34589. /**
  34590. * Sets a new Standard Material as _defaultMaterial if not already set.
  34591. * @hidden
  34592. */
  34593. private _setDefaultMaterial;
  34594. /**
  34595. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34596. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34597. * @returns the SPS.
  34598. */
  34599. refreshVisibleSize(): SolidParticleSystem;
  34600. /**
  34601. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34602. * @param size the size (float) of the visibility box
  34603. * note : this doesn't lock the SPS mesh bounding box.
  34604. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34605. */
  34606. setVisibilityBox(size: number): void;
  34607. /**
  34608. * Gets whether the SPS as always visible or not
  34609. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34610. */
  34611. get isAlwaysVisible(): boolean;
  34612. /**
  34613. * Sets the SPS as always visible or not
  34614. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34615. */
  34616. set isAlwaysVisible(val: boolean);
  34617. /**
  34618. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34619. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34620. */
  34621. set isVisibilityBoxLocked(val: boolean);
  34622. /**
  34623. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34624. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34625. */
  34626. get isVisibilityBoxLocked(): boolean;
  34627. /**
  34628. * Tells to `setParticles()` to compute the particle rotations or not.
  34629. * Default value : true. The SPS is faster when it's set to false.
  34630. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34631. */
  34632. set computeParticleRotation(val: boolean);
  34633. /**
  34634. * Tells to `setParticles()` to compute the particle colors or not.
  34635. * Default value : true. The SPS is faster when it's set to false.
  34636. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34637. */
  34638. set computeParticleColor(val: boolean);
  34639. set computeParticleTexture(val: boolean);
  34640. /**
  34641. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34642. * Default value : false. The SPS is faster when it's set to false.
  34643. * Note : the particle custom vertex positions aren't stored values.
  34644. */
  34645. set computeParticleVertex(val: boolean);
  34646. /**
  34647. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34648. */
  34649. set computeBoundingBox(val: boolean);
  34650. /**
  34651. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34652. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34653. * Default : `true`
  34654. */
  34655. set depthSortParticles(val: boolean);
  34656. /**
  34657. * Gets if `setParticles()` computes the particle rotations or not.
  34658. * Default value : true. The SPS is faster when it's set to false.
  34659. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34660. */
  34661. get computeParticleRotation(): boolean;
  34662. /**
  34663. * Gets if `setParticles()` computes the particle colors or not.
  34664. * Default value : true. The SPS is faster when it's set to false.
  34665. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34666. */
  34667. get computeParticleColor(): boolean;
  34668. /**
  34669. * Gets if `setParticles()` computes the particle textures or not.
  34670. * Default value : true. The SPS is faster when it's set to false.
  34671. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34672. */
  34673. get computeParticleTexture(): boolean;
  34674. /**
  34675. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34676. * Default value : false. The SPS is faster when it's set to false.
  34677. * Note : the particle custom vertex positions aren't stored values.
  34678. */
  34679. get computeParticleVertex(): boolean;
  34680. /**
  34681. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34682. */
  34683. get computeBoundingBox(): boolean;
  34684. /**
  34685. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34686. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34687. * Default : `true`
  34688. */
  34689. get depthSortParticles(): boolean;
  34690. /**
  34691. * Gets if the SPS is created as expandable at construction time.
  34692. * Default : `false`
  34693. */
  34694. get expandable(): boolean;
  34695. /**
  34696. * Gets if the SPS supports the Multi Materials
  34697. */
  34698. get multimaterialEnabled(): boolean;
  34699. /**
  34700. * Gets if the SPS uses the model materials for its own multimaterial.
  34701. */
  34702. get useModelMaterial(): boolean;
  34703. /**
  34704. * The SPS used material array.
  34705. */
  34706. get materials(): Material[];
  34707. /**
  34708. * Sets the SPS MultiMaterial from the passed materials.
  34709. * Note : the passed array is internally copied and not used then by reference.
  34710. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34711. */
  34712. setMultiMaterial(materials: Material[]): void;
  34713. /**
  34714. * The SPS computed multimaterial object
  34715. */
  34716. get multimaterial(): MultiMaterial;
  34717. set multimaterial(mm: MultiMaterial);
  34718. /**
  34719. * If the subMeshes must be updated on the next call to setParticles()
  34720. */
  34721. get autoUpdateSubMeshes(): boolean;
  34722. set autoUpdateSubMeshes(val: boolean);
  34723. /**
  34724. * This function does nothing. It may be overwritten to set all the particle first values.
  34725. * The SPS doesn't call this function, you may have to call it by your own.
  34726. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34727. */
  34728. initParticles(): void;
  34729. /**
  34730. * This function does nothing. It may be overwritten to recycle a particle.
  34731. * The SPS doesn't call this function, you may have to call it by your own.
  34732. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34733. * @param particle The particle to recycle
  34734. * @returns the recycled particle
  34735. */
  34736. recycleParticle(particle: SolidParticle): SolidParticle;
  34737. /**
  34738. * Updates a particle : this function should be overwritten by the user.
  34739. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34740. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34741. * @example : just set a particle position or velocity and recycle conditions
  34742. * @param particle The particle to update
  34743. * @returns the updated particle
  34744. */
  34745. updateParticle(particle: SolidParticle): SolidParticle;
  34746. /**
  34747. * Updates a vertex of a particle : it can be overwritten by the user.
  34748. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34749. * @param particle the current particle
  34750. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34751. * @param pt the index of the current vertex in the particle shape
  34752. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34753. * @example : just set a vertex particle position or color
  34754. * @returns the sps
  34755. */
  34756. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34757. /**
  34758. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34759. * This does nothing and may be overwritten by the user.
  34760. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34761. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34762. * @param update the boolean update value actually passed to setParticles()
  34763. */
  34764. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34765. /**
  34766. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34767. * This will be passed three parameters.
  34768. * This does nothing and may be overwritten by the user.
  34769. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34770. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34771. * @param update the boolean update value actually passed to setParticles()
  34772. */
  34773. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34774. }
  34775. }
  34776. declare module BABYLON {
  34777. /**
  34778. * Represents one particle of a solid particle system.
  34779. */
  34780. export class SolidParticle {
  34781. /**
  34782. * particle global index
  34783. */
  34784. idx: number;
  34785. /**
  34786. * particle identifier
  34787. */
  34788. id: number;
  34789. /**
  34790. * The color of the particle
  34791. */
  34792. color: Nullable<Color4>;
  34793. /**
  34794. * The world space position of the particle.
  34795. */
  34796. position: Vector3;
  34797. /**
  34798. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34799. */
  34800. rotation: Vector3;
  34801. /**
  34802. * The world space rotation quaternion of the particle.
  34803. */
  34804. rotationQuaternion: Nullable<Quaternion>;
  34805. /**
  34806. * The scaling of the particle.
  34807. */
  34808. scaling: Vector3;
  34809. /**
  34810. * The uvs of the particle.
  34811. */
  34812. uvs: Vector4;
  34813. /**
  34814. * The current speed of the particle.
  34815. */
  34816. velocity: Vector3;
  34817. /**
  34818. * The pivot point in the particle local space.
  34819. */
  34820. pivot: Vector3;
  34821. /**
  34822. * Must the particle be translated from its pivot point in its local space ?
  34823. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34824. * Default : false
  34825. */
  34826. translateFromPivot: boolean;
  34827. /**
  34828. * Is the particle active or not ?
  34829. */
  34830. alive: boolean;
  34831. /**
  34832. * Is the particle visible or not ?
  34833. */
  34834. isVisible: boolean;
  34835. /**
  34836. * Index of this particle in the global "positions" array (Internal use)
  34837. * @hidden
  34838. */
  34839. _pos: number;
  34840. /**
  34841. * @hidden Index of this particle in the global "indices" array (Internal use)
  34842. */
  34843. _ind: number;
  34844. /**
  34845. * @hidden ModelShape of this particle (Internal use)
  34846. */
  34847. _model: ModelShape;
  34848. /**
  34849. * ModelShape id of this particle
  34850. */
  34851. shapeId: number;
  34852. /**
  34853. * Index of the particle in its shape id
  34854. */
  34855. idxInShape: number;
  34856. /**
  34857. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34858. */
  34859. _modelBoundingInfo: BoundingInfo;
  34860. /**
  34861. * @hidden Particle BoundingInfo object (Internal use)
  34862. */
  34863. _boundingInfo: BoundingInfo;
  34864. /**
  34865. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34866. */
  34867. _sps: SolidParticleSystem;
  34868. /**
  34869. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34870. */
  34871. _stillInvisible: boolean;
  34872. /**
  34873. * @hidden Last computed particle rotation matrix
  34874. */
  34875. _rotationMatrix: number[];
  34876. /**
  34877. * Parent particle Id, if any.
  34878. * Default null.
  34879. */
  34880. parentId: Nullable<number>;
  34881. /**
  34882. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34883. */
  34884. materialIndex: Nullable<number>;
  34885. /**
  34886. * Custom object or properties.
  34887. */
  34888. props: Nullable<any>;
  34889. /**
  34890. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34891. * The possible values are :
  34892. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34893. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34894. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34895. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34896. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34897. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34898. * */
  34899. cullingStrategy: number;
  34900. /**
  34901. * @hidden Internal global position in the SPS.
  34902. */
  34903. _globalPosition: Vector3;
  34904. /**
  34905. * Creates a Solid Particle object.
  34906. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34907. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34908. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34909. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34910. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34911. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34912. * @param shapeId (integer) is the model shape identifier in the SPS.
  34913. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34914. * @param sps defines the sps it is associated to
  34915. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34916. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34917. */
  34918. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34919. /**
  34920. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34921. * @param target the particle target
  34922. * @returns the current particle
  34923. */
  34924. copyToRef(target: SolidParticle): SolidParticle;
  34925. /**
  34926. * Legacy support, changed scale to scaling
  34927. */
  34928. get scale(): Vector3;
  34929. /**
  34930. * Legacy support, changed scale to scaling
  34931. */
  34932. set scale(scale: Vector3);
  34933. /**
  34934. * Legacy support, changed quaternion to rotationQuaternion
  34935. */
  34936. get quaternion(): Nullable<Quaternion>;
  34937. /**
  34938. * Legacy support, changed quaternion to rotationQuaternion
  34939. */
  34940. set quaternion(q: Nullable<Quaternion>);
  34941. /**
  34942. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34943. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34944. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34945. * @returns true if it intersects
  34946. */
  34947. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34948. /**
  34949. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34950. * A particle is in the frustum if its bounding box intersects the frustum
  34951. * @param frustumPlanes defines the frustum to test
  34952. * @returns true if the particle is in the frustum planes
  34953. */
  34954. isInFrustum(frustumPlanes: Plane[]): boolean;
  34955. /**
  34956. * get the rotation matrix of the particle
  34957. * @hidden
  34958. */
  34959. getRotationMatrix(m: Matrix): void;
  34960. }
  34961. /**
  34962. * Represents the shape of the model used by one particle of a solid particle system.
  34963. * SPS internal tool, don't use it manually.
  34964. */
  34965. export class ModelShape {
  34966. /**
  34967. * The shape id
  34968. * @hidden
  34969. */
  34970. shapeID: number;
  34971. /**
  34972. * flat array of model positions (internal use)
  34973. * @hidden
  34974. */
  34975. _shape: Vector3[];
  34976. /**
  34977. * flat array of model UVs (internal use)
  34978. * @hidden
  34979. */
  34980. _shapeUV: number[];
  34981. /**
  34982. * color array of the model
  34983. * @hidden
  34984. */
  34985. _shapeColors: number[];
  34986. /**
  34987. * indices array of the model
  34988. * @hidden
  34989. */
  34990. _indices: number[];
  34991. /**
  34992. * normals array of the model
  34993. * @hidden
  34994. */
  34995. _normals: number[];
  34996. /**
  34997. * length of the shape in the model indices array (internal use)
  34998. * @hidden
  34999. */
  35000. _indicesLength: number;
  35001. /**
  35002. * Custom position function (internal use)
  35003. * @hidden
  35004. */
  35005. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35006. /**
  35007. * Custom vertex function (internal use)
  35008. * @hidden
  35009. */
  35010. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35011. /**
  35012. * Model material (internal use)
  35013. * @hidden
  35014. */
  35015. _material: Nullable<Material>;
  35016. /**
  35017. * 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.
  35018. * SPS internal tool, don't use it manually.
  35019. * @hidden
  35020. */
  35021. 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>);
  35022. }
  35023. /**
  35024. * Represents a Depth Sorted Particle in the solid particle system.
  35025. * @hidden
  35026. */
  35027. export class DepthSortedParticle {
  35028. /**
  35029. * Particle index
  35030. */
  35031. idx: number;
  35032. /**
  35033. * Index of the particle in the "indices" array
  35034. */
  35035. ind: number;
  35036. /**
  35037. * Length of the particle shape in the "indices" array
  35038. */
  35039. indicesLength: number;
  35040. /**
  35041. * Squared distance from the particle to the camera
  35042. */
  35043. sqDistance: number;
  35044. /**
  35045. * Material index when used with MultiMaterials
  35046. */
  35047. materialIndex: number;
  35048. /**
  35049. * Creates a new sorted particle
  35050. * @param materialIndex
  35051. */
  35052. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35053. }
  35054. /**
  35055. * Represents a solid particle vertex
  35056. */
  35057. export class SolidParticleVertex {
  35058. /**
  35059. * Vertex position
  35060. */
  35061. position: Vector3;
  35062. /**
  35063. * Vertex color
  35064. */
  35065. color: Color4;
  35066. /**
  35067. * Vertex UV
  35068. */
  35069. uv: Vector2;
  35070. /**
  35071. * Creates a new solid particle vertex
  35072. */
  35073. constructor();
  35074. /** Vertex x coordinate */
  35075. get x(): number;
  35076. set x(val: number);
  35077. /** Vertex y coordinate */
  35078. get y(): number;
  35079. set y(val: number);
  35080. /** Vertex z coordinate */
  35081. get z(): number;
  35082. set z(val: number);
  35083. }
  35084. }
  35085. declare module BABYLON {
  35086. /**
  35087. * @hidden
  35088. */
  35089. export class _MeshCollisionData {
  35090. _checkCollisions: boolean;
  35091. _collisionMask: number;
  35092. _collisionGroup: number;
  35093. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35094. _collider: Nullable<Collider>;
  35095. _oldPositionForCollisions: Vector3;
  35096. _diffPositionForCollisions: Vector3;
  35097. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35098. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35099. _collisionResponse: boolean;
  35100. }
  35101. }
  35102. declare module BABYLON {
  35103. /** @hidden */
  35104. class _FacetDataStorage {
  35105. facetPositions: Vector3[];
  35106. facetNormals: Vector3[];
  35107. facetPartitioning: number[][];
  35108. facetNb: number;
  35109. partitioningSubdivisions: number;
  35110. partitioningBBoxRatio: number;
  35111. facetDataEnabled: boolean;
  35112. facetParameters: any;
  35113. bbSize: Vector3;
  35114. subDiv: {
  35115. max: number;
  35116. X: number;
  35117. Y: number;
  35118. Z: number;
  35119. };
  35120. facetDepthSort: boolean;
  35121. facetDepthSortEnabled: boolean;
  35122. depthSortedIndices: IndicesArray;
  35123. depthSortedFacets: {
  35124. ind: number;
  35125. sqDistance: number;
  35126. }[];
  35127. facetDepthSortFunction: (f1: {
  35128. ind: number;
  35129. sqDistance: number;
  35130. }, f2: {
  35131. ind: number;
  35132. sqDistance: number;
  35133. }) => number;
  35134. facetDepthSortFrom: Vector3;
  35135. facetDepthSortOrigin: Vector3;
  35136. invertedMatrix: Matrix;
  35137. }
  35138. /**
  35139. * @hidden
  35140. **/
  35141. class _InternalAbstractMeshDataInfo {
  35142. _hasVertexAlpha: boolean;
  35143. _useVertexColors: boolean;
  35144. _numBoneInfluencers: number;
  35145. _applyFog: boolean;
  35146. _receiveShadows: boolean;
  35147. _facetData: _FacetDataStorage;
  35148. _visibility: number;
  35149. _skeleton: Nullable<Skeleton>;
  35150. _layerMask: number;
  35151. _computeBonesUsingShaders: boolean;
  35152. _isActive: boolean;
  35153. _onlyForInstances: boolean;
  35154. _isActiveIntermediate: boolean;
  35155. _onlyForInstancesIntermediate: boolean;
  35156. _actAsRegularMesh: boolean;
  35157. _currentLOD: Nullable<AbstractMesh>;
  35158. }
  35159. /**
  35160. * Class used to store all common mesh properties
  35161. */
  35162. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35163. /** No occlusion */
  35164. static OCCLUSION_TYPE_NONE: number;
  35165. /** Occlusion set to optimisitic */
  35166. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35167. /** Occlusion set to strict */
  35168. static OCCLUSION_TYPE_STRICT: number;
  35169. /** Use an accurante occlusion algorithm */
  35170. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35171. /** Use a conservative occlusion algorithm */
  35172. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35173. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35174. * Test order :
  35175. * Is the bounding sphere outside the frustum ?
  35176. * If not, are the bounding box vertices outside the frustum ?
  35177. * It not, then the cullable object is in the frustum.
  35178. */
  35179. static readonly CULLINGSTRATEGY_STANDARD: number;
  35180. /** Culling strategy : Bounding Sphere Only.
  35181. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35182. * It's also less accurate than the standard because some not visible objects can still be selected.
  35183. * Test : is the bounding sphere outside the frustum ?
  35184. * If not, then the cullable object is in the frustum.
  35185. */
  35186. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35187. /** Culling strategy : Optimistic Inclusion.
  35188. * This in an inclusion test first, then the standard exclusion test.
  35189. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35190. * 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.
  35191. * Anyway, it's as accurate as the standard strategy.
  35192. * Test :
  35193. * Is the cullable object bounding sphere center in the frustum ?
  35194. * If not, apply the default culling strategy.
  35195. */
  35196. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35197. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35198. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35199. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35200. * 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.
  35201. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35202. * Test :
  35203. * Is the cullable object bounding sphere center in the frustum ?
  35204. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35205. */
  35206. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35207. /**
  35208. * No billboard
  35209. */
  35210. static get BILLBOARDMODE_NONE(): number;
  35211. /** Billboard on X axis */
  35212. static get BILLBOARDMODE_X(): number;
  35213. /** Billboard on Y axis */
  35214. static get BILLBOARDMODE_Y(): number;
  35215. /** Billboard on Z axis */
  35216. static get BILLBOARDMODE_Z(): number;
  35217. /** Billboard on all axes */
  35218. static get BILLBOARDMODE_ALL(): number;
  35219. /** Billboard on using position instead of orientation */
  35220. static get BILLBOARDMODE_USE_POSITION(): number;
  35221. /** @hidden */
  35222. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35223. /**
  35224. * The culling strategy to use to check whether the mesh must be rendered or not.
  35225. * This value can be changed at any time and will be used on the next render mesh selection.
  35226. * The possible values are :
  35227. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35228. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35229. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35230. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35231. * Please read each static variable documentation to get details about the culling process.
  35232. * */
  35233. cullingStrategy: number;
  35234. /**
  35235. * Gets the number of facets in the mesh
  35236. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35237. */
  35238. get facetNb(): number;
  35239. /**
  35240. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35241. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35242. */
  35243. get partitioningSubdivisions(): number;
  35244. set partitioningSubdivisions(nb: number);
  35245. /**
  35246. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35247. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35248. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35249. */
  35250. get partitioningBBoxRatio(): number;
  35251. set partitioningBBoxRatio(ratio: number);
  35252. /**
  35253. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35254. * Works only for updatable meshes.
  35255. * Doesn't work with multi-materials
  35256. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35257. */
  35258. get mustDepthSortFacets(): boolean;
  35259. set mustDepthSortFacets(sort: boolean);
  35260. /**
  35261. * The location (Vector3) where the facet depth sort must be computed from.
  35262. * By default, the active camera position.
  35263. * Used only when facet depth sort is enabled
  35264. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35265. */
  35266. get facetDepthSortFrom(): Vector3;
  35267. set facetDepthSortFrom(location: Vector3);
  35268. /**
  35269. * gets a boolean indicating if facetData is enabled
  35270. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35271. */
  35272. get isFacetDataEnabled(): boolean;
  35273. /** @hidden */
  35274. _updateNonUniformScalingState(value: boolean): boolean;
  35275. /**
  35276. * An event triggered when this mesh collides with another one
  35277. */
  35278. onCollideObservable: Observable<AbstractMesh>;
  35279. /** Set a function to call when this mesh collides with another one */
  35280. set onCollide(callback: () => void);
  35281. /**
  35282. * An event triggered when the collision's position changes
  35283. */
  35284. onCollisionPositionChangeObservable: Observable<Vector3>;
  35285. /** Set a function to call when the collision's position changes */
  35286. set onCollisionPositionChange(callback: () => void);
  35287. /**
  35288. * An event triggered when material is changed
  35289. */
  35290. onMaterialChangedObservable: Observable<AbstractMesh>;
  35291. /**
  35292. * Gets or sets the orientation for POV movement & rotation
  35293. */
  35294. definedFacingForward: boolean;
  35295. /** @hidden */
  35296. _occlusionQuery: Nullable<WebGLQuery>;
  35297. /** @hidden */
  35298. _renderingGroup: Nullable<RenderingGroup>;
  35299. /**
  35300. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35301. */
  35302. get visibility(): number;
  35303. /**
  35304. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35305. */
  35306. set visibility(value: number);
  35307. /** Gets or sets the alpha index used to sort transparent meshes
  35308. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35309. */
  35310. alphaIndex: number;
  35311. /**
  35312. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35313. */
  35314. isVisible: boolean;
  35315. /**
  35316. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35317. */
  35318. isPickable: boolean;
  35319. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35320. showSubMeshesBoundingBox: boolean;
  35321. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35322. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35323. */
  35324. isBlocker: boolean;
  35325. /**
  35326. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35327. */
  35328. enablePointerMoveEvents: boolean;
  35329. private _renderingGroupId;
  35330. /**
  35331. * Specifies the rendering group id for this mesh (0 by default)
  35332. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35333. */
  35334. get renderingGroupId(): number;
  35335. set renderingGroupId(value: number);
  35336. private _material;
  35337. /** Gets or sets current material */
  35338. get material(): Nullable<Material>;
  35339. set material(value: Nullable<Material>);
  35340. /**
  35341. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35342. * @see https://doc.babylonjs.com/babylon101/shadows
  35343. */
  35344. get receiveShadows(): boolean;
  35345. set receiveShadows(value: boolean);
  35346. /** Defines color to use when rendering outline */
  35347. outlineColor: Color3;
  35348. /** Define width to use when rendering outline */
  35349. outlineWidth: number;
  35350. /** Defines color to use when rendering overlay */
  35351. overlayColor: Color3;
  35352. /** Defines alpha to use when rendering overlay */
  35353. overlayAlpha: number;
  35354. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35355. get hasVertexAlpha(): boolean;
  35356. set hasVertexAlpha(value: boolean);
  35357. /** 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) */
  35358. get useVertexColors(): boolean;
  35359. set useVertexColors(value: boolean);
  35360. /**
  35361. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35362. */
  35363. get computeBonesUsingShaders(): boolean;
  35364. set computeBonesUsingShaders(value: boolean);
  35365. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35366. get numBoneInfluencers(): number;
  35367. set numBoneInfluencers(value: number);
  35368. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35369. get applyFog(): boolean;
  35370. set applyFog(value: boolean);
  35371. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35372. useOctreeForRenderingSelection: boolean;
  35373. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35374. useOctreeForPicking: boolean;
  35375. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35376. useOctreeForCollisions: boolean;
  35377. /**
  35378. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35379. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35380. */
  35381. get layerMask(): number;
  35382. set layerMask(value: number);
  35383. /**
  35384. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35385. */
  35386. alwaysSelectAsActiveMesh: boolean;
  35387. /**
  35388. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35389. */
  35390. doNotSyncBoundingInfo: boolean;
  35391. /**
  35392. * Gets or sets the current action manager
  35393. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35394. */
  35395. actionManager: Nullable<AbstractActionManager>;
  35396. private _meshCollisionData;
  35397. /**
  35398. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35399. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35400. */
  35401. ellipsoid: Vector3;
  35402. /**
  35403. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35404. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35405. */
  35406. ellipsoidOffset: Vector3;
  35407. /**
  35408. * Gets or sets a collision mask used to mask collisions (default is -1).
  35409. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35410. */
  35411. get collisionMask(): number;
  35412. set collisionMask(mask: number);
  35413. /**
  35414. * Gets or sets a collision response flag (default is true).
  35415. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35416. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35417. * to respond to the collision.
  35418. */
  35419. get collisionResponse(): boolean;
  35420. set collisionResponse(response: boolean);
  35421. /**
  35422. * Gets or sets the current collision group mask (-1 by default).
  35423. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35424. */
  35425. get collisionGroup(): number;
  35426. set collisionGroup(mask: number);
  35427. /**
  35428. * Gets or sets current surrounding meshes (null by default).
  35429. *
  35430. * By default collision detection is tested against every mesh in the scene.
  35431. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35432. * meshes will be tested for the collision.
  35433. *
  35434. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35435. */
  35436. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35437. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35438. /**
  35439. * Defines edge width used when edgesRenderer is enabled
  35440. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35441. */
  35442. edgesWidth: number;
  35443. /**
  35444. * Defines edge color used when edgesRenderer is enabled
  35445. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35446. */
  35447. edgesColor: Color4;
  35448. /** @hidden */
  35449. _edgesRenderer: Nullable<IEdgesRenderer>;
  35450. /** @hidden */
  35451. _masterMesh: Nullable<AbstractMesh>;
  35452. /** @hidden */
  35453. _boundingInfo: Nullable<BoundingInfo>;
  35454. /** @hidden */
  35455. _renderId: number;
  35456. /**
  35457. * Gets or sets the list of subMeshes
  35458. * @see https://doc.babylonjs.com/how_to/multi_materials
  35459. */
  35460. subMeshes: SubMesh[];
  35461. /** @hidden */
  35462. _intersectionsInProgress: AbstractMesh[];
  35463. /** @hidden */
  35464. _unIndexed: boolean;
  35465. /** @hidden */
  35466. _lightSources: Light[];
  35467. /** Gets the list of lights affecting that mesh */
  35468. get lightSources(): Light[];
  35469. /** @hidden */
  35470. get _positions(): Nullable<Vector3[]>;
  35471. /** @hidden */
  35472. _waitingData: {
  35473. lods: Nullable<any>;
  35474. actions: Nullable<any>;
  35475. freezeWorldMatrix: Nullable<boolean>;
  35476. };
  35477. /** @hidden */
  35478. _bonesTransformMatrices: Nullable<Float32Array>;
  35479. /** @hidden */
  35480. _transformMatrixTexture: Nullable<RawTexture>;
  35481. /**
  35482. * Gets or sets a skeleton to apply skining transformations
  35483. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35484. */
  35485. set skeleton(value: Nullable<Skeleton>);
  35486. get skeleton(): Nullable<Skeleton>;
  35487. /**
  35488. * An event triggered when the mesh is rebuilt.
  35489. */
  35490. onRebuildObservable: Observable<AbstractMesh>;
  35491. /**
  35492. * Creates a new AbstractMesh
  35493. * @param name defines the name of the mesh
  35494. * @param scene defines the hosting scene
  35495. */
  35496. constructor(name: string, scene?: Nullable<Scene>);
  35497. /**
  35498. * Returns the string "AbstractMesh"
  35499. * @returns "AbstractMesh"
  35500. */
  35501. getClassName(): string;
  35502. /**
  35503. * Gets a string representation of the current mesh
  35504. * @param fullDetails defines a boolean indicating if full details must be included
  35505. * @returns a string representation of the current mesh
  35506. */
  35507. toString(fullDetails?: boolean): string;
  35508. /**
  35509. * @hidden
  35510. */
  35511. protected _getEffectiveParent(): Nullable<Node>;
  35512. /** @hidden */
  35513. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35514. /** @hidden */
  35515. _rebuild(): void;
  35516. /** @hidden */
  35517. _resyncLightSources(): void;
  35518. /** @hidden */
  35519. _resyncLightSource(light: Light): void;
  35520. /** @hidden */
  35521. _unBindEffect(): void;
  35522. /** @hidden */
  35523. _removeLightSource(light: Light, dispose: boolean): void;
  35524. private _markSubMeshesAsDirty;
  35525. /** @hidden */
  35526. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35527. /** @hidden */
  35528. _markSubMeshesAsAttributesDirty(): void;
  35529. /** @hidden */
  35530. _markSubMeshesAsMiscDirty(): void;
  35531. /**
  35532. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35533. */
  35534. get scaling(): Vector3;
  35535. set scaling(newScaling: Vector3);
  35536. /**
  35537. * Returns true if the mesh is blocked. Implemented by child classes
  35538. */
  35539. get isBlocked(): boolean;
  35540. /**
  35541. * Returns the mesh itself by default. Implemented by child classes
  35542. * @param camera defines the camera to use to pick the right LOD level
  35543. * @returns the currentAbstractMesh
  35544. */
  35545. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35546. /**
  35547. * Returns 0 by default. Implemented by child classes
  35548. * @returns an integer
  35549. */
  35550. getTotalVertices(): number;
  35551. /**
  35552. * Returns a positive integer : the total number of indices in this mesh geometry.
  35553. * @returns the numner of indices or zero if the mesh has no geometry.
  35554. */
  35555. getTotalIndices(): number;
  35556. /**
  35557. * Returns null by default. Implemented by child classes
  35558. * @returns null
  35559. */
  35560. getIndices(): Nullable<IndicesArray>;
  35561. /**
  35562. * Returns the array of the requested vertex data kind. Implemented by child classes
  35563. * @param kind defines the vertex data kind to use
  35564. * @returns null
  35565. */
  35566. getVerticesData(kind: string): Nullable<FloatArray>;
  35567. /**
  35568. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35569. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35570. * Note that a new underlying VertexBuffer object is created each call.
  35571. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35572. * @param kind defines vertex data kind:
  35573. * * VertexBuffer.PositionKind
  35574. * * VertexBuffer.UVKind
  35575. * * VertexBuffer.UV2Kind
  35576. * * VertexBuffer.UV3Kind
  35577. * * VertexBuffer.UV4Kind
  35578. * * VertexBuffer.UV5Kind
  35579. * * VertexBuffer.UV6Kind
  35580. * * VertexBuffer.ColorKind
  35581. * * VertexBuffer.MatricesIndicesKind
  35582. * * VertexBuffer.MatricesIndicesExtraKind
  35583. * * VertexBuffer.MatricesWeightsKind
  35584. * * VertexBuffer.MatricesWeightsExtraKind
  35585. * @param data defines the data source
  35586. * @param updatable defines if the data must be flagged as updatable (or static)
  35587. * @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
  35588. * @returns the current mesh
  35589. */
  35590. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35591. /**
  35592. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35593. * If the mesh has no geometry, it is simply returned as it is.
  35594. * @param kind defines vertex data kind:
  35595. * * VertexBuffer.PositionKind
  35596. * * VertexBuffer.UVKind
  35597. * * VertexBuffer.UV2Kind
  35598. * * VertexBuffer.UV3Kind
  35599. * * VertexBuffer.UV4Kind
  35600. * * VertexBuffer.UV5Kind
  35601. * * VertexBuffer.UV6Kind
  35602. * * VertexBuffer.ColorKind
  35603. * * VertexBuffer.MatricesIndicesKind
  35604. * * VertexBuffer.MatricesIndicesExtraKind
  35605. * * VertexBuffer.MatricesWeightsKind
  35606. * * VertexBuffer.MatricesWeightsExtraKind
  35607. * @param data defines the data source
  35608. * @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
  35609. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35610. * @returns the current mesh
  35611. */
  35612. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35613. /**
  35614. * Sets the mesh indices,
  35615. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35616. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35617. * @param totalVertices Defines the total number of vertices
  35618. * @returns the current mesh
  35619. */
  35620. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35621. /**
  35622. * Gets a boolean indicating if specific vertex data is present
  35623. * @param kind defines the vertex data kind to use
  35624. * @returns true is data kind is present
  35625. */
  35626. isVerticesDataPresent(kind: string): boolean;
  35627. /**
  35628. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35629. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35630. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35631. * @returns a BoundingInfo
  35632. */
  35633. getBoundingInfo(): BoundingInfo;
  35634. /**
  35635. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35636. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35637. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35638. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35639. * @returns the current mesh
  35640. */
  35641. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35642. /**
  35643. * Overwrite the current bounding info
  35644. * @param boundingInfo defines the new bounding info
  35645. * @returns the current mesh
  35646. */
  35647. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35648. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35649. get useBones(): boolean;
  35650. /** @hidden */
  35651. _preActivate(): void;
  35652. /** @hidden */
  35653. _preActivateForIntermediateRendering(renderId: number): void;
  35654. /** @hidden */
  35655. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35656. /** @hidden */
  35657. _postActivate(): void;
  35658. /** @hidden */
  35659. _freeze(): void;
  35660. /** @hidden */
  35661. _unFreeze(): void;
  35662. /**
  35663. * Gets the current world matrix
  35664. * @returns a Matrix
  35665. */
  35666. getWorldMatrix(): Matrix;
  35667. /** @hidden */
  35668. _getWorldMatrixDeterminant(): number;
  35669. /**
  35670. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35671. */
  35672. get isAnInstance(): boolean;
  35673. /**
  35674. * Gets a boolean indicating if this mesh has instances
  35675. */
  35676. get hasInstances(): boolean;
  35677. /**
  35678. * Gets a boolean indicating if this mesh has thin instances
  35679. */
  35680. get hasThinInstances(): boolean;
  35681. /**
  35682. * Perform relative position change from the point of view of behind the front of the mesh.
  35683. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35684. * Supports definition of mesh facing forward or backward
  35685. * @param amountRight defines the distance on the right axis
  35686. * @param amountUp defines the distance on the up axis
  35687. * @param amountForward defines the distance on the forward axis
  35688. * @returns the current mesh
  35689. */
  35690. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35691. /**
  35692. * Calculate relative position change from the point of view of behind the front of the mesh.
  35693. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35694. * Supports definition of mesh facing forward or backward
  35695. * @param amountRight defines the distance on the right axis
  35696. * @param amountUp defines the distance on the up axis
  35697. * @param amountForward defines the distance on the forward axis
  35698. * @returns the new displacement vector
  35699. */
  35700. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35701. /**
  35702. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35703. * Supports definition of mesh facing forward or backward
  35704. * @param flipBack defines the flip
  35705. * @param twirlClockwise defines the twirl
  35706. * @param tiltRight defines the tilt
  35707. * @returns the current mesh
  35708. */
  35709. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35710. /**
  35711. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35712. * Supports definition of mesh facing forward or backward.
  35713. * @param flipBack defines the flip
  35714. * @param twirlClockwise defines the twirl
  35715. * @param tiltRight defines the tilt
  35716. * @returns the new rotation vector
  35717. */
  35718. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35719. /**
  35720. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35721. * This means the mesh underlying bounding box and sphere are recomputed.
  35722. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35723. * @returns the current mesh
  35724. */
  35725. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35726. /** @hidden */
  35727. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35728. /** @hidden */
  35729. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35730. /** @hidden */
  35731. _updateBoundingInfo(): AbstractMesh;
  35732. /** @hidden */
  35733. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35734. /** @hidden */
  35735. protected _afterComputeWorldMatrix(): void;
  35736. /** @hidden */
  35737. get _effectiveMesh(): AbstractMesh;
  35738. /**
  35739. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35740. * A mesh is in the frustum if its bounding box intersects the frustum
  35741. * @param frustumPlanes defines the frustum to test
  35742. * @returns true if the mesh is in the frustum planes
  35743. */
  35744. isInFrustum(frustumPlanes: Plane[]): boolean;
  35745. /**
  35746. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35747. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35748. * @param frustumPlanes defines the frustum to test
  35749. * @returns true if the mesh is completely in the frustum planes
  35750. */
  35751. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35752. /**
  35753. * True if the mesh intersects another mesh or a SolidParticle object
  35754. * @param mesh defines a target mesh or SolidParticle to test
  35755. * @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)
  35756. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35757. * @returns true if there is an intersection
  35758. */
  35759. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35760. /**
  35761. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35762. * @param point defines the point to test
  35763. * @returns true if there is an intersection
  35764. */
  35765. intersectsPoint(point: Vector3): boolean;
  35766. /**
  35767. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35768. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35769. */
  35770. get checkCollisions(): boolean;
  35771. set checkCollisions(collisionEnabled: boolean);
  35772. /**
  35773. * Gets Collider object used to compute collisions (not physics)
  35774. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35775. */
  35776. get collider(): Nullable<Collider>;
  35777. /**
  35778. * Move the mesh using collision engine
  35779. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35780. * @param displacement defines the requested displacement vector
  35781. * @returns the current mesh
  35782. */
  35783. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35784. private _onCollisionPositionChange;
  35785. /** @hidden */
  35786. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35787. /** @hidden */
  35788. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35789. /** @hidden */
  35790. _checkCollision(collider: Collider): AbstractMesh;
  35791. /** @hidden */
  35792. _generatePointsArray(): boolean;
  35793. /**
  35794. * Checks if the passed Ray intersects with the mesh
  35795. * @param ray defines the ray to use
  35796. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35797. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35798. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35799. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35800. * @returns the picking info
  35801. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35802. */
  35803. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  35804. /**
  35805. * Clones the current mesh
  35806. * @param name defines the mesh name
  35807. * @param newParent defines the new mesh parent
  35808. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35809. * @returns the new mesh
  35810. */
  35811. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35812. /**
  35813. * Disposes all the submeshes of the current meshnp
  35814. * @returns the current mesh
  35815. */
  35816. releaseSubMeshes(): AbstractMesh;
  35817. /**
  35818. * Releases resources associated with this abstract mesh.
  35819. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35820. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35821. */
  35822. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35823. /**
  35824. * Adds the passed mesh as a child to the current mesh
  35825. * @param mesh defines the child mesh
  35826. * @returns the current mesh
  35827. */
  35828. addChild(mesh: AbstractMesh): AbstractMesh;
  35829. /**
  35830. * Removes the passed mesh from the current mesh children list
  35831. * @param mesh defines the child mesh
  35832. * @returns the current mesh
  35833. */
  35834. removeChild(mesh: AbstractMesh): AbstractMesh;
  35835. /** @hidden */
  35836. private _initFacetData;
  35837. /**
  35838. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35839. * This method can be called within the render loop.
  35840. * 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
  35841. * @returns the current mesh
  35842. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35843. */
  35844. updateFacetData(): AbstractMesh;
  35845. /**
  35846. * Returns the facetLocalNormals array.
  35847. * The normals are expressed in the mesh local spac
  35848. * @returns an array of Vector3
  35849. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35850. */
  35851. getFacetLocalNormals(): Vector3[];
  35852. /**
  35853. * Returns the facetLocalPositions array.
  35854. * The facet positions are expressed in the mesh local space
  35855. * @returns an array of Vector3
  35856. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35857. */
  35858. getFacetLocalPositions(): Vector3[];
  35859. /**
  35860. * Returns the facetLocalPartioning array
  35861. * @returns an array of array of numbers
  35862. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35863. */
  35864. getFacetLocalPartitioning(): number[][];
  35865. /**
  35866. * Returns the i-th facet position in the world system.
  35867. * This method allocates a new Vector3 per call
  35868. * @param i defines the facet index
  35869. * @returns a new Vector3
  35870. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35871. */
  35872. getFacetPosition(i: number): Vector3;
  35873. /**
  35874. * Sets the reference Vector3 with the i-th facet position in the world system
  35875. * @param i defines the facet index
  35876. * @param ref defines the target vector
  35877. * @returns the current mesh
  35878. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35879. */
  35880. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35881. /**
  35882. * Returns the i-th facet normal in the world system.
  35883. * This method allocates a new Vector3 per call
  35884. * @param i defines the facet index
  35885. * @returns a new Vector3
  35886. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35887. */
  35888. getFacetNormal(i: number): Vector3;
  35889. /**
  35890. * Sets the reference Vector3 with the i-th facet normal in the world system
  35891. * @param i defines the facet index
  35892. * @param ref defines the target vector
  35893. * @returns the current mesh
  35894. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35895. */
  35896. getFacetNormalToRef(i: number, ref: Vector3): this;
  35897. /**
  35898. * 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)
  35899. * @param x defines x coordinate
  35900. * @param y defines y coordinate
  35901. * @param z defines z coordinate
  35902. * @returns the array of facet indexes
  35903. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35904. */
  35905. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35906. /**
  35907. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35908. * @param projected sets as the (x,y,z) world projection on the facet
  35909. * @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
  35910. * @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
  35911. * @param x defines x coordinate
  35912. * @param y defines y coordinate
  35913. * @param z defines z coordinate
  35914. * @returns the face index if found (or null instead)
  35915. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35916. */
  35917. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35918. /**
  35919. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35920. * @param projected sets as the (x,y,z) local projection on the facet
  35921. * @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
  35922. * @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
  35923. * @param x defines x coordinate
  35924. * @param y defines y coordinate
  35925. * @param z defines z coordinate
  35926. * @returns the face index if found (or null instead)
  35927. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35928. */
  35929. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35930. /**
  35931. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35932. * @returns the parameters
  35933. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35934. */
  35935. getFacetDataParameters(): any;
  35936. /**
  35937. * Disables the feature FacetData and frees the related memory
  35938. * @returns the current mesh
  35939. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35940. */
  35941. disableFacetData(): AbstractMesh;
  35942. /**
  35943. * Updates the AbstractMesh indices array
  35944. * @param indices defines the data source
  35945. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35946. * @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)
  35947. * @returns the current mesh
  35948. */
  35949. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35950. /**
  35951. * Creates new normals data for the mesh
  35952. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35953. * @returns the current mesh
  35954. */
  35955. createNormals(updatable: boolean): AbstractMesh;
  35956. /**
  35957. * Align the mesh with a normal
  35958. * @param normal defines the normal to use
  35959. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35960. * @returns the current mesh
  35961. */
  35962. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35963. /** @hidden */
  35964. _checkOcclusionQuery(): boolean;
  35965. /**
  35966. * Disables the mesh edge rendering mode
  35967. * @returns the currentAbstractMesh
  35968. */
  35969. disableEdgesRendering(): AbstractMesh;
  35970. /**
  35971. * Enables the edge rendering mode on the mesh.
  35972. * This mode makes the mesh edges visible
  35973. * @param epsilon defines the maximal distance between two angles to detect a face
  35974. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35975. * @returns the currentAbstractMesh
  35976. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35977. */
  35978. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35979. /**
  35980. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35981. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35982. */
  35983. getConnectedParticleSystems(): IParticleSystem[];
  35984. }
  35985. }
  35986. declare module BABYLON {
  35987. /**
  35988. * Interface used to define ActionEvent
  35989. */
  35990. export interface IActionEvent {
  35991. /** The mesh or sprite that triggered the action */
  35992. source: any;
  35993. /** The X mouse cursor position at the time of the event */
  35994. pointerX: number;
  35995. /** The Y mouse cursor position at the time of the event */
  35996. pointerY: number;
  35997. /** The mesh that is currently pointed at (can be null) */
  35998. meshUnderPointer: Nullable<AbstractMesh>;
  35999. /** the original (browser) event that triggered the ActionEvent */
  36000. sourceEvent?: any;
  36001. /** additional data for the event */
  36002. additionalData?: any;
  36003. }
  36004. /**
  36005. * ActionEvent is the event being sent when an action is triggered.
  36006. */
  36007. export class ActionEvent implements IActionEvent {
  36008. /** The mesh or sprite that triggered the action */
  36009. source: any;
  36010. /** The X mouse cursor position at the time of the event */
  36011. pointerX: number;
  36012. /** The Y mouse cursor position at the time of the event */
  36013. pointerY: number;
  36014. /** The mesh that is currently pointed at (can be null) */
  36015. meshUnderPointer: Nullable<AbstractMesh>;
  36016. /** the original (browser) event that triggered the ActionEvent */
  36017. sourceEvent?: any;
  36018. /** additional data for the event */
  36019. additionalData?: any;
  36020. /**
  36021. * Creates a new ActionEvent
  36022. * @param source The mesh or sprite that triggered the action
  36023. * @param pointerX The X mouse cursor position at the time of the event
  36024. * @param pointerY The Y mouse cursor position at the time of the event
  36025. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36026. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36027. * @param additionalData additional data for the event
  36028. */
  36029. constructor(
  36030. /** The mesh or sprite that triggered the action */
  36031. source: any,
  36032. /** The X mouse cursor position at the time of the event */
  36033. pointerX: number,
  36034. /** The Y mouse cursor position at the time of the event */
  36035. pointerY: number,
  36036. /** The mesh that is currently pointed at (can be null) */
  36037. meshUnderPointer: Nullable<AbstractMesh>,
  36038. /** the original (browser) event that triggered the ActionEvent */
  36039. sourceEvent?: any,
  36040. /** additional data for the event */
  36041. additionalData?: any);
  36042. /**
  36043. * Helper function to auto-create an ActionEvent from a source mesh.
  36044. * @param source The source mesh that triggered the event
  36045. * @param evt The original (browser) event
  36046. * @param additionalData additional data for the event
  36047. * @returns the new ActionEvent
  36048. */
  36049. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36050. /**
  36051. * Helper function to auto-create an ActionEvent from a source sprite
  36052. * @param source The source sprite that triggered the event
  36053. * @param scene Scene associated with the sprite
  36054. * @param evt The original (browser) event
  36055. * @param additionalData additional data for the event
  36056. * @returns the new ActionEvent
  36057. */
  36058. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36059. /**
  36060. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36061. * @param scene the scene where the event occurred
  36062. * @param evt The original (browser) event
  36063. * @returns the new ActionEvent
  36064. */
  36065. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36066. /**
  36067. * Helper function to auto-create an ActionEvent from a primitive
  36068. * @param prim defines the target primitive
  36069. * @param pointerPos defines the pointer position
  36070. * @param evt The original (browser) event
  36071. * @param additionalData additional data for the event
  36072. * @returns the new ActionEvent
  36073. */
  36074. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36075. }
  36076. }
  36077. declare module BABYLON {
  36078. /**
  36079. * Abstract class used to decouple action Manager from scene and meshes.
  36080. * Do not instantiate.
  36081. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36082. */
  36083. export abstract class AbstractActionManager implements IDisposable {
  36084. /** Gets the list of active triggers */
  36085. static Triggers: {
  36086. [key: string]: number;
  36087. };
  36088. /** Gets the cursor to use when hovering items */
  36089. hoverCursor: string;
  36090. /** Gets the list of actions */
  36091. actions: IAction[];
  36092. /**
  36093. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36094. */
  36095. isRecursive: boolean;
  36096. /**
  36097. * Releases all associated resources
  36098. */
  36099. abstract dispose(): void;
  36100. /**
  36101. * Does this action manager has pointer triggers
  36102. */
  36103. abstract get hasPointerTriggers(): boolean;
  36104. /**
  36105. * Does this action manager has pick triggers
  36106. */
  36107. abstract get hasPickTriggers(): boolean;
  36108. /**
  36109. * Process a specific trigger
  36110. * @param trigger defines the trigger to process
  36111. * @param evt defines the event details to be processed
  36112. */
  36113. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36114. /**
  36115. * Does this action manager handles actions of any of the given triggers
  36116. * @param triggers defines the triggers to be tested
  36117. * @return a boolean indicating whether one (or more) of the triggers is handled
  36118. */
  36119. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36120. /**
  36121. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36122. * speed.
  36123. * @param triggerA defines the trigger to be tested
  36124. * @param triggerB defines the trigger to be tested
  36125. * @return a boolean indicating whether one (or more) of the triggers is handled
  36126. */
  36127. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36128. /**
  36129. * Does this action manager handles actions of a given trigger
  36130. * @param trigger defines the trigger to be tested
  36131. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36132. * @return whether the trigger is handled
  36133. */
  36134. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36135. /**
  36136. * Serialize this manager to a JSON object
  36137. * @param name defines the property name to store this manager
  36138. * @returns a JSON representation of this manager
  36139. */
  36140. abstract serialize(name: string): any;
  36141. /**
  36142. * Registers an action to this action manager
  36143. * @param action defines the action to be registered
  36144. * @return the action amended (prepared) after registration
  36145. */
  36146. abstract registerAction(action: IAction): Nullable<IAction>;
  36147. /**
  36148. * Unregisters an action to this action manager
  36149. * @param action defines the action to be unregistered
  36150. * @return a boolean indicating whether the action has been unregistered
  36151. */
  36152. abstract unregisterAction(action: IAction): Boolean;
  36153. /**
  36154. * Does exist one action manager with at least one trigger
  36155. **/
  36156. static get HasTriggers(): boolean;
  36157. /**
  36158. * Does exist one action manager with at least one pick trigger
  36159. **/
  36160. static get HasPickTriggers(): boolean;
  36161. /**
  36162. * Does exist one action manager that handles actions of a given trigger
  36163. * @param trigger defines the trigger to be tested
  36164. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36165. **/
  36166. static HasSpecificTrigger(trigger: number): boolean;
  36167. }
  36168. }
  36169. declare module BABYLON {
  36170. /**
  36171. * Defines how a node can be built from a string name.
  36172. */
  36173. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36174. /**
  36175. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36176. */
  36177. export class Node implements IBehaviorAware<Node> {
  36178. /** @hidden */
  36179. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36180. private static _NodeConstructors;
  36181. /**
  36182. * Add a new node constructor
  36183. * @param type defines the type name of the node to construct
  36184. * @param constructorFunc defines the constructor function
  36185. */
  36186. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36187. /**
  36188. * Returns a node constructor based on type name
  36189. * @param type defines the type name
  36190. * @param name defines the new node name
  36191. * @param scene defines the hosting scene
  36192. * @param options defines optional options to transmit to constructors
  36193. * @returns the new constructor or null
  36194. */
  36195. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36196. /**
  36197. * Gets or sets the name of the node
  36198. */
  36199. name: string;
  36200. /**
  36201. * Gets or sets the id of the node
  36202. */
  36203. id: string;
  36204. /**
  36205. * Gets or sets the unique id of the node
  36206. */
  36207. uniqueId: number;
  36208. /**
  36209. * Gets or sets a string used to store user defined state for the node
  36210. */
  36211. state: string;
  36212. /**
  36213. * Gets or sets an object used to store user defined information for the node
  36214. */
  36215. metadata: any;
  36216. /**
  36217. * For internal use only. Please do not use.
  36218. */
  36219. reservedDataStore: any;
  36220. /**
  36221. * List of inspectable custom properties (used by the Inspector)
  36222. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36223. */
  36224. inspectableCustomProperties: IInspectable[];
  36225. private _doNotSerialize;
  36226. /**
  36227. * Gets or sets a boolean used to define if the node must be serialized
  36228. */
  36229. get doNotSerialize(): boolean;
  36230. set doNotSerialize(value: boolean);
  36231. /** @hidden */
  36232. _isDisposed: boolean;
  36233. /**
  36234. * Gets a list of Animations associated with the node
  36235. */
  36236. animations: Animation[];
  36237. protected _ranges: {
  36238. [name: string]: Nullable<AnimationRange>;
  36239. };
  36240. /**
  36241. * Callback raised when the node is ready to be used
  36242. */
  36243. onReady: Nullable<(node: Node) => void>;
  36244. private _isEnabled;
  36245. private _isParentEnabled;
  36246. private _isReady;
  36247. /** @hidden */
  36248. _currentRenderId: number;
  36249. private _parentUpdateId;
  36250. /** @hidden */
  36251. _childUpdateId: number;
  36252. /** @hidden */
  36253. _waitingParentId: Nullable<string>;
  36254. /** @hidden */
  36255. _scene: Scene;
  36256. /** @hidden */
  36257. _cache: any;
  36258. private _parentNode;
  36259. private _children;
  36260. /** @hidden */
  36261. _worldMatrix: Matrix;
  36262. /** @hidden */
  36263. _worldMatrixDeterminant: number;
  36264. /** @hidden */
  36265. _worldMatrixDeterminantIsDirty: boolean;
  36266. /** @hidden */
  36267. private _sceneRootNodesIndex;
  36268. /**
  36269. * Gets a boolean indicating if the node has been disposed
  36270. * @returns true if the node was disposed
  36271. */
  36272. isDisposed(): boolean;
  36273. /**
  36274. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36275. * @see https://doc.babylonjs.com/how_to/parenting
  36276. */
  36277. set parent(parent: Nullable<Node>);
  36278. get parent(): Nullable<Node>;
  36279. /** @hidden */
  36280. _addToSceneRootNodes(): void;
  36281. /** @hidden */
  36282. _removeFromSceneRootNodes(): void;
  36283. private _animationPropertiesOverride;
  36284. /**
  36285. * Gets or sets the animation properties override
  36286. */
  36287. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36288. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36289. /**
  36290. * Gets a string identifying the name of the class
  36291. * @returns "Node" string
  36292. */
  36293. getClassName(): string;
  36294. /** @hidden */
  36295. readonly _isNode: boolean;
  36296. /**
  36297. * An event triggered when the mesh is disposed
  36298. */
  36299. onDisposeObservable: Observable<Node>;
  36300. private _onDisposeObserver;
  36301. /**
  36302. * Sets a callback that will be raised when the node will be disposed
  36303. */
  36304. set onDispose(callback: () => void);
  36305. /**
  36306. * Creates a new Node
  36307. * @param name the name and id to be given to this node
  36308. * @param scene the scene this node will be added to
  36309. */
  36310. constructor(name: string, scene?: Nullable<Scene>);
  36311. /**
  36312. * Gets the scene of the node
  36313. * @returns a scene
  36314. */
  36315. getScene(): Scene;
  36316. /**
  36317. * Gets the engine of the node
  36318. * @returns a Engine
  36319. */
  36320. getEngine(): Engine;
  36321. private _behaviors;
  36322. /**
  36323. * Attach a behavior to the node
  36324. * @see https://doc.babylonjs.com/features/behaviour
  36325. * @param behavior defines the behavior to attach
  36326. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36327. * @returns the current Node
  36328. */
  36329. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36330. /**
  36331. * Remove an attached behavior
  36332. * @see https://doc.babylonjs.com/features/behaviour
  36333. * @param behavior defines the behavior to attach
  36334. * @returns the current Node
  36335. */
  36336. removeBehavior(behavior: Behavior<Node>): Node;
  36337. /**
  36338. * Gets the list of attached behaviors
  36339. * @see https://doc.babylonjs.com/features/behaviour
  36340. */
  36341. get behaviors(): Behavior<Node>[];
  36342. /**
  36343. * Gets an attached behavior by name
  36344. * @param name defines the name of the behavior to look for
  36345. * @see https://doc.babylonjs.com/features/behaviour
  36346. * @returns null if behavior was not found else the requested behavior
  36347. */
  36348. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36349. /**
  36350. * Returns the latest update of the World matrix
  36351. * @returns a Matrix
  36352. */
  36353. getWorldMatrix(): Matrix;
  36354. /** @hidden */
  36355. _getWorldMatrixDeterminant(): number;
  36356. /**
  36357. * Returns directly the latest state of the mesh World matrix.
  36358. * A Matrix is returned.
  36359. */
  36360. get worldMatrixFromCache(): Matrix;
  36361. /** @hidden */
  36362. _initCache(): void;
  36363. /** @hidden */
  36364. updateCache(force?: boolean): void;
  36365. /** @hidden */
  36366. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36367. /** @hidden */
  36368. _updateCache(ignoreParentClass?: boolean): void;
  36369. /** @hidden */
  36370. _isSynchronized(): boolean;
  36371. /** @hidden */
  36372. _markSyncedWithParent(): void;
  36373. /** @hidden */
  36374. isSynchronizedWithParent(): boolean;
  36375. /** @hidden */
  36376. isSynchronized(): boolean;
  36377. /**
  36378. * Is this node ready to be used/rendered
  36379. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36380. * @return true if the node is ready
  36381. */
  36382. isReady(completeCheck?: boolean): boolean;
  36383. /**
  36384. * Is this node enabled?
  36385. * 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
  36386. * @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
  36387. * @return whether this node (and its parent) is enabled
  36388. */
  36389. isEnabled(checkAncestors?: boolean): boolean;
  36390. /** @hidden */
  36391. protected _syncParentEnabledState(): void;
  36392. /**
  36393. * Set the enabled state of this node
  36394. * @param value defines the new enabled state
  36395. */
  36396. setEnabled(value: boolean): void;
  36397. /**
  36398. * Is this node a descendant of the given node?
  36399. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36400. * @param ancestor defines the parent node to inspect
  36401. * @returns a boolean indicating if this node is a descendant of the given node
  36402. */
  36403. isDescendantOf(ancestor: Node): boolean;
  36404. /** @hidden */
  36405. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36406. /**
  36407. * Will return all nodes that have this node as ascendant
  36408. * @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
  36409. * @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
  36410. * @return all children nodes of all types
  36411. */
  36412. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36413. /**
  36414. * Get all child-meshes of this node
  36415. * @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)
  36416. * @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
  36417. * @returns an array of AbstractMesh
  36418. */
  36419. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36420. /**
  36421. * Get all direct children of this node
  36422. * @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
  36423. * @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)
  36424. * @returns an array of Node
  36425. */
  36426. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36427. /** @hidden */
  36428. _setReady(state: boolean): void;
  36429. /**
  36430. * Get an animation by name
  36431. * @param name defines the name of the animation to look for
  36432. * @returns null if not found else the requested animation
  36433. */
  36434. getAnimationByName(name: string): Nullable<Animation>;
  36435. /**
  36436. * Creates an animation range for this node
  36437. * @param name defines the name of the range
  36438. * @param from defines the starting key
  36439. * @param to defines the end key
  36440. */
  36441. createAnimationRange(name: string, from: number, to: number): void;
  36442. /**
  36443. * Delete a specific animation range
  36444. * @param name defines the name of the range to delete
  36445. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36446. */
  36447. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36448. /**
  36449. * Get an animation range by name
  36450. * @param name defines the name of the animation range to look for
  36451. * @returns null if not found else the requested animation range
  36452. */
  36453. getAnimationRange(name: string): Nullable<AnimationRange>;
  36454. /**
  36455. * Gets the list of all animation ranges defined on this node
  36456. * @returns an array
  36457. */
  36458. getAnimationRanges(): Nullable<AnimationRange>[];
  36459. /**
  36460. * Will start the animation sequence
  36461. * @param name defines the range frames for animation sequence
  36462. * @param loop defines if the animation should loop (false by default)
  36463. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36464. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36465. * @returns the object created for this animation. If range does not exist, it will return null
  36466. */
  36467. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36468. /**
  36469. * Serialize animation ranges into a JSON compatible object
  36470. * @returns serialization object
  36471. */
  36472. serializeAnimationRanges(): any;
  36473. /**
  36474. * Computes the world matrix of the node
  36475. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36476. * @returns the world matrix
  36477. */
  36478. computeWorldMatrix(force?: boolean): Matrix;
  36479. /**
  36480. * Releases resources associated with this node.
  36481. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36482. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36483. */
  36484. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36485. /**
  36486. * Parse animation range data from a serialization object and store them into a given node
  36487. * @param node defines where to store the animation ranges
  36488. * @param parsedNode defines the serialization object to read data from
  36489. * @param scene defines the hosting scene
  36490. */
  36491. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36492. /**
  36493. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36494. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36495. * @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
  36496. * @returns the new bounding vectors
  36497. */
  36498. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36499. min: Vector3;
  36500. max: Vector3;
  36501. };
  36502. }
  36503. }
  36504. declare module BABYLON {
  36505. /**
  36506. * @hidden
  36507. */
  36508. export class _IAnimationState {
  36509. key: number;
  36510. repeatCount: number;
  36511. workValue?: any;
  36512. loopMode?: number;
  36513. offsetValue?: any;
  36514. highLimitValue?: any;
  36515. }
  36516. /**
  36517. * Class used to store any kind of animation
  36518. */
  36519. export class Animation {
  36520. /**Name of the animation */
  36521. name: string;
  36522. /**Property to animate */
  36523. targetProperty: string;
  36524. /**The frames per second of the animation */
  36525. framePerSecond: number;
  36526. /**The data type of the animation */
  36527. dataType: number;
  36528. /**The loop mode of the animation */
  36529. loopMode?: number | undefined;
  36530. /**Specifies if blending should be enabled */
  36531. enableBlending?: boolean | undefined;
  36532. /**
  36533. * Use matrix interpolation instead of using direct key value when animating matrices
  36534. */
  36535. static AllowMatricesInterpolation: boolean;
  36536. /**
  36537. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36538. */
  36539. static AllowMatrixDecomposeForInterpolation: boolean;
  36540. /** Define the Url to load snippets */
  36541. static SnippetUrl: string;
  36542. /** Snippet ID if the animation was created from the snippet server */
  36543. snippetId: string;
  36544. /**
  36545. * Stores the key frames of the animation
  36546. */
  36547. private _keys;
  36548. /**
  36549. * Stores the easing function of the animation
  36550. */
  36551. private _easingFunction;
  36552. /**
  36553. * @hidden Internal use only
  36554. */
  36555. _runtimeAnimations: RuntimeAnimation[];
  36556. /**
  36557. * The set of event that will be linked to this animation
  36558. */
  36559. private _events;
  36560. /**
  36561. * Stores an array of target property paths
  36562. */
  36563. targetPropertyPath: string[];
  36564. /**
  36565. * Stores the blending speed of the animation
  36566. */
  36567. blendingSpeed: number;
  36568. /**
  36569. * Stores the animation ranges for the animation
  36570. */
  36571. private _ranges;
  36572. /**
  36573. * @hidden Internal use
  36574. */
  36575. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36576. /**
  36577. * Sets up an animation
  36578. * @param property The property to animate
  36579. * @param animationType The animation type to apply
  36580. * @param framePerSecond The frames per second of the animation
  36581. * @param easingFunction The easing function used in the animation
  36582. * @returns The created animation
  36583. */
  36584. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36585. /**
  36586. * Create and start an animation on a node
  36587. * @param name defines the name of the global animation that will be run on all nodes
  36588. * @param node defines the root node where the animation will take place
  36589. * @param targetProperty defines property to animate
  36590. * @param framePerSecond defines the number of frame per second yo use
  36591. * @param totalFrame defines the number of frames in total
  36592. * @param from defines the initial value
  36593. * @param to defines the final value
  36594. * @param loopMode defines which loop mode you want to use (off by default)
  36595. * @param easingFunction defines the easing function to use (linear by default)
  36596. * @param onAnimationEnd defines the callback to call when animation end
  36597. * @returns the animatable created for this animation
  36598. */
  36599. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36600. /**
  36601. * Create and start an animation on a node and its descendants
  36602. * @param name defines the name of the global animation that will be run on all nodes
  36603. * @param node defines the root node where the animation will take place
  36604. * @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
  36605. * @param targetProperty defines property to animate
  36606. * @param framePerSecond defines the number of frame per second to use
  36607. * @param totalFrame defines the number of frames in total
  36608. * @param from defines the initial value
  36609. * @param to defines the final value
  36610. * @param loopMode defines which loop mode you want to use (off by default)
  36611. * @param easingFunction defines the easing function to use (linear by default)
  36612. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36613. * @returns the list of animatables created for all nodes
  36614. * @example https://www.babylonjs-playground.com/#MH0VLI
  36615. */
  36616. 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[]>;
  36617. /**
  36618. * Creates a new animation, merges it with the existing animations and starts it
  36619. * @param name Name of the animation
  36620. * @param node Node which contains the scene that begins the animations
  36621. * @param targetProperty Specifies which property to animate
  36622. * @param framePerSecond The frames per second of the animation
  36623. * @param totalFrame The total number of frames
  36624. * @param from The frame at the beginning of the animation
  36625. * @param to The frame at the end of the animation
  36626. * @param loopMode Specifies the loop mode of the animation
  36627. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36628. * @param onAnimationEnd Callback to run once the animation is complete
  36629. * @returns Nullable animation
  36630. */
  36631. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36632. /**
  36633. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36634. * @param sourceAnimation defines the Animation containing keyframes to convert
  36635. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36636. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36637. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36638. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36639. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36640. */
  36641. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36642. /**
  36643. * Transition property of an host to the target Value
  36644. * @param property The property to transition
  36645. * @param targetValue The target Value of the property
  36646. * @param host The object where the property to animate belongs
  36647. * @param scene Scene used to run the animation
  36648. * @param frameRate Framerate (in frame/s) to use
  36649. * @param transition The transition type we want to use
  36650. * @param duration The duration of the animation, in milliseconds
  36651. * @param onAnimationEnd Callback trigger at the end of the animation
  36652. * @returns Nullable animation
  36653. */
  36654. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36655. /**
  36656. * Return the array of runtime animations currently using this animation
  36657. */
  36658. get runtimeAnimations(): RuntimeAnimation[];
  36659. /**
  36660. * Specifies if any of the runtime animations are currently running
  36661. */
  36662. get hasRunningRuntimeAnimations(): boolean;
  36663. /**
  36664. * Initializes the animation
  36665. * @param name Name of the animation
  36666. * @param targetProperty Property to animate
  36667. * @param framePerSecond The frames per second of the animation
  36668. * @param dataType The data type of the animation
  36669. * @param loopMode The loop mode of the animation
  36670. * @param enableBlending Specifies if blending should be enabled
  36671. */
  36672. constructor(
  36673. /**Name of the animation */
  36674. name: string,
  36675. /**Property to animate */
  36676. targetProperty: string,
  36677. /**The frames per second of the animation */
  36678. framePerSecond: number,
  36679. /**The data type of the animation */
  36680. dataType: number,
  36681. /**The loop mode of the animation */
  36682. loopMode?: number | undefined,
  36683. /**Specifies if blending should be enabled */
  36684. enableBlending?: boolean | undefined);
  36685. /**
  36686. * Converts the animation to a string
  36687. * @param fullDetails support for multiple levels of logging within scene loading
  36688. * @returns String form of the animation
  36689. */
  36690. toString(fullDetails?: boolean): string;
  36691. /**
  36692. * Add an event to this animation
  36693. * @param event Event to add
  36694. */
  36695. addEvent(event: AnimationEvent): void;
  36696. /**
  36697. * Remove all events found at the given frame
  36698. * @param frame The frame to remove events from
  36699. */
  36700. removeEvents(frame: number): void;
  36701. /**
  36702. * Retrieves all the events from the animation
  36703. * @returns Events from the animation
  36704. */
  36705. getEvents(): AnimationEvent[];
  36706. /**
  36707. * Creates an animation range
  36708. * @param name Name of the animation range
  36709. * @param from Starting frame of the animation range
  36710. * @param to Ending frame of the animation
  36711. */
  36712. createRange(name: string, from: number, to: number): void;
  36713. /**
  36714. * Deletes an animation range by name
  36715. * @param name Name of the animation range to delete
  36716. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36717. */
  36718. deleteRange(name: string, deleteFrames?: boolean): void;
  36719. /**
  36720. * Gets the animation range by name, or null if not defined
  36721. * @param name Name of the animation range
  36722. * @returns Nullable animation range
  36723. */
  36724. getRange(name: string): Nullable<AnimationRange>;
  36725. /**
  36726. * Gets the key frames from the animation
  36727. * @returns The key frames of the animation
  36728. */
  36729. getKeys(): Array<IAnimationKey>;
  36730. /**
  36731. * Gets the highest frame rate of the animation
  36732. * @returns Highest frame rate of the animation
  36733. */
  36734. getHighestFrame(): number;
  36735. /**
  36736. * Gets the easing function of the animation
  36737. * @returns Easing function of the animation
  36738. */
  36739. getEasingFunction(): IEasingFunction;
  36740. /**
  36741. * Sets the easing function of the animation
  36742. * @param easingFunction A custom mathematical formula for animation
  36743. */
  36744. setEasingFunction(easingFunction: EasingFunction): void;
  36745. /**
  36746. * Interpolates a scalar linearly
  36747. * @param startValue Start value of the animation curve
  36748. * @param endValue End value of the animation curve
  36749. * @param gradient Scalar amount to interpolate
  36750. * @returns Interpolated scalar value
  36751. */
  36752. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36753. /**
  36754. * Interpolates a scalar cubically
  36755. * @param startValue Start value of the animation curve
  36756. * @param outTangent End tangent of the animation
  36757. * @param endValue End value of the animation curve
  36758. * @param inTangent Start tangent of the animation curve
  36759. * @param gradient Scalar amount to interpolate
  36760. * @returns Interpolated scalar value
  36761. */
  36762. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36763. /**
  36764. * Interpolates a quaternion using a spherical linear interpolation
  36765. * @param startValue Start value of the animation curve
  36766. * @param endValue End value of the animation curve
  36767. * @param gradient Scalar amount to interpolate
  36768. * @returns Interpolated quaternion value
  36769. */
  36770. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36771. /**
  36772. * Interpolates a quaternion cubically
  36773. * @param startValue Start value of the animation curve
  36774. * @param outTangent End tangent of the animation curve
  36775. * @param endValue End value of the animation curve
  36776. * @param inTangent Start tangent of the animation curve
  36777. * @param gradient Scalar amount to interpolate
  36778. * @returns Interpolated quaternion value
  36779. */
  36780. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36781. /**
  36782. * Interpolates a Vector3 linearl
  36783. * @param startValue Start value of the animation curve
  36784. * @param endValue End value of the animation curve
  36785. * @param gradient Scalar amount to interpolate
  36786. * @returns Interpolated scalar value
  36787. */
  36788. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36789. /**
  36790. * Interpolates a Vector3 cubically
  36791. * @param startValue Start value of the animation curve
  36792. * @param outTangent End tangent of the animation
  36793. * @param endValue End value of the animation curve
  36794. * @param inTangent Start tangent of the animation curve
  36795. * @param gradient Scalar amount to interpolate
  36796. * @returns InterpolatedVector3 value
  36797. */
  36798. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36799. /**
  36800. * Interpolates a Vector2 linearly
  36801. * @param startValue Start value of the animation curve
  36802. * @param endValue End value of the animation curve
  36803. * @param gradient Scalar amount to interpolate
  36804. * @returns Interpolated Vector2 value
  36805. */
  36806. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36807. /**
  36808. * Interpolates a Vector2 cubically
  36809. * @param startValue Start value of the animation curve
  36810. * @param outTangent End tangent of the animation
  36811. * @param endValue End value of the animation curve
  36812. * @param inTangent Start tangent of the animation curve
  36813. * @param gradient Scalar amount to interpolate
  36814. * @returns Interpolated Vector2 value
  36815. */
  36816. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36817. /**
  36818. * Interpolates a size linearly
  36819. * @param startValue Start value of the animation curve
  36820. * @param endValue End value of the animation curve
  36821. * @param gradient Scalar amount to interpolate
  36822. * @returns Interpolated Size value
  36823. */
  36824. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36825. /**
  36826. * Interpolates a Color3 linearly
  36827. * @param startValue Start value of the animation curve
  36828. * @param endValue End value of the animation curve
  36829. * @param gradient Scalar amount to interpolate
  36830. * @returns Interpolated Color3 value
  36831. */
  36832. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36833. /**
  36834. * Interpolates a Color4 linearly
  36835. * @param startValue Start value of the animation curve
  36836. * @param endValue End value of the animation curve
  36837. * @param gradient Scalar amount to interpolate
  36838. * @returns Interpolated Color3 value
  36839. */
  36840. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36841. /**
  36842. * @hidden Internal use only
  36843. */
  36844. _getKeyValue(value: any): any;
  36845. /**
  36846. * @hidden Internal use only
  36847. */
  36848. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36849. /**
  36850. * Defines the function to use to interpolate matrices
  36851. * @param startValue defines the start matrix
  36852. * @param endValue defines the end matrix
  36853. * @param gradient defines the gradient between both matrices
  36854. * @param result defines an optional target matrix where to store the interpolation
  36855. * @returns the interpolated matrix
  36856. */
  36857. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36858. /**
  36859. * Makes a copy of the animation
  36860. * @returns Cloned animation
  36861. */
  36862. clone(): Animation;
  36863. /**
  36864. * Sets the key frames of the animation
  36865. * @param values The animation key frames to set
  36866. */
  36867. setKeys(values: Array<IAnimationKey>): void;
  36868. /**
  36869. * Serializes the animation to an object
  36870. * @returns Serialized object
  36871. */
  36872. serialize(): any;
  36873. /**
  36874. * Float animation type
  36875. */
  36876. static readonly ANIMATIONTYPE_FLOAT: number;
  36877. /**
  36878. * Vector3 animation type
  36879. */
  36880. static readonly ANIMATIONTYPE_VECTOR3: number;
  36881. /**
  36882. * Quaternion animation type
  36883. */
  36884. static readonly ANIMATIONTYPE_QUATERNION: number;
  36885. /**
  36886. * Matrix animation type
  36887. */
  36888. static readonly ANIMATIONTYPE_MATRIX: number;
  36889. /**
  36890. * Color3 animation type
  36891. */
  36892. static readonly ANIMATIONTYPE_COLOR3: number;
  36893. /**
  36894. * Color3 animation type
  36895. */
  36896. static readonly ANIMATIONTYPE_COLOR4: number;
  36897. /**
  36898. * Vector2 animation type
  36899. */
  36900. static readonly ANIMATIONTYPE_VECTOR2: number;
  36901. /**
  36902. * Size animation type
  36903. */
  36904. static readonly ANIMATIONTYPE_SIZE: number;
  36905. /**
  36906. * Relative Loop Mode
  36907. */
  36908. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36909. /**
  36910. * Cycle Loop Mode
  36911. */
  36912. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36913. /**
  36914. * Constant Loop Mode
  36915. */
  36916. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36917. /** @hidden */
  36918. static _UniversalLerp(left: any, right: any, amount: number): any;
  36919. /**
  36920. * Parses an animation object and creates an animation
  36921. * @param parsedAnimation Parsed animation object
  36922. * @returns Animation object
  36923. */
  36924. static Parse(parsedAnimation: any): Animation;
  36925. /**
  36926. * Appends the serialized animations from the source animations
  36927. * @param source Source containing the animations
  36928. * @param destination Target to store the animations
  36929. */
  36930. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36931. /**
  36932. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36933. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36934. * @param url defines the url to load from
  36935. * @returns a promise that will resolve to the new animation or an array of animations
  36936. */
  36937. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36938. /**
  36939. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36940. * @param snippetId defines the snippet to load
  36941. * @returns a promise that will resolve to the new animation or a new array of animations
  36942. */
  36943. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36944. }
  36945. }
  36946. declare module BABYLON {
  36947. /**
  36948. * Interface containing an array of animations
  36949. */
  36950. export interface IAnimatable {
  36951. /**
  36952. * Array of animations
  36953. */
  36954. animations: Nullable<Array<Animation>>;
  36955. }
  36956. }
  36957. declare module BABYLON {
  36958. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36959. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36960. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36961. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36962. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36963. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36964. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36965. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36966. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36967. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36968. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36969. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36970. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36971. /**
  36972. * Decorator used to define property that can be serialized as reference to a camera
  36973. * @param sourceName defines the name of the property to decorate
  36974. */
  36975. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36976. /**
  36977. * Class used to help serialization objects
  36978. */
  36979. export class SerializationHelper {
  36980. /** @hidden */
  36981. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36982. /** @hidden */
  36983. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36984. /** @hidden */
  36985. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36986. /** @hidden */
  36987. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36988. /**
  36989. * Appends the serialized animations from the source animations
  36990. * @param source Source containing the animations
  36991. * @param destination Target to store the animations
  36992. */
  36993. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36994. /**
  36995. * Static function used to serialized a specific entity
  36996. * @param entity defines the entity to serialize
  36997. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36998. * @returns a JSON compatible object representing the serialization of the entity
  36999. */
  37000. static Serialize<T>(entity: T, serializationObject?: any): any;
  37001. /**
  37002. * Creates a new entity from a serialization data object
  37003. * @param creationFunction defines a function used to instanciated the new entity
  37004. * @param source defines the source serialization data
  37005. * @param scene defines the hosting scene
  37006. * @param rootUrl defines the root url for resources
  37007. * @returns a new entity
  37008. */
  37009. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37010. /**
  37011. * Clones an object
  37012. * @param creationFunction defines the function used to instanciate the new object
  37013. * @param source defines the source object
  37014. * @returns the cloned object
  37015. */
  37016. static Clone<T>(creationFunction: () => T, source: T): T;
  37017. /**
  37018. * Instanciates a new object based on a source one (some data will be shared between both object)
  37019. * @param creationFunction defines the function used to instanciate the new object
  37020. * @param source defines the source object
  37021. * @returns the new object
  37022. */
  37023. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37024. }
  37025. }
  37026. declare module BABYLON {
  37027. /**
  37028. * Base class of all the textures in babylon.
  37029. * It groups all the common properties the materials, post process, lights... might need
  37030. * in order to make a correct use of the texture.
  37031. */
  37032. export class BaseTexture implements IAnimatable {
  37033. /**
  37034. * Default anisotropic filtering level for the application.
  37035. * It is set to 4 as a good tradeoff between perf and quality.
  37036. */
  37037. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37038. /**
  37039. * Gets or sets the unique id of the texture
  37040. */
  37041. uniqueId: number;
  37042. /**
  37043. * Define the name of the texture.
  37044. */
  37045. name: string;
  37046. /**
  37047. * Gets or sets an object used to store user defined information.
  37048. */
  37049. metadata: any;
  37050. /**
  37051. * For internal use only. Please do not use.
  37052. */
  37053. reservedDataStore: any;
  37054. private _hasAlpha;
  37055. /**
  37056. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  37057. */
  37058. set hasAlpha(value: boolean);
  37059. get hasAlpha(): boolean;
  37060. /**
  37061. * Defines if the alpha value should be determined via the rgb values.
  37062. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  37063. */
  37064. getAlphaFromRGB: boolean;
  37065. /**
  37066. * Intensity or strength of the texture.
  37067. * It is commonly used by materials to fine tune the intensity of the texture
  37068. */
  37069. level: number;
  37070. /**
  37071. * Define the UV chanel to use starting from 0 and defaulting to 0.
  37072. * This is part of the texture as textures usually maps to one uv set.
  37073. */
  37074. coordinatesIndex: number;
  37075. protected _coordinatesMode: number;
  37076. /**
  37077. * How a texture is mapped.
  37078. *
  37079. * | Value | Type | Description |
  37080. * | ----- | ----------------------------------- | ----------- |
  37081. * | 0 | EXPLICIT_MODE | |
  37082. * | 1 | SPHERICAL_MODE | |
  37083. * | 2 | PLANAR_MODE | |
  37084. * | 3 | CUBIC_MODE | |
  37085. * | 4 | PROJECTION_MODE | |
  37086. * | 5 | SKYBOX_MODE | |
  37087. * | 6 | INVCUBIC_MODE | |
  37088. * | 7 | EQUIRECTANGULAR_MODE | |
  37089. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37090. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37091. */
  37092. set coordinatesMode(value: number);
  37093. get coordinatesMode(): number;
  37094. private _wrapU;
  37095. /**
  37096. * | Value | Type | Description |
  37097. * | ----- | ------------------ | ----------- |
  37098. * | 0 | CLAMP_ADDRESSMODE | |
  37099. * | 1 | WRAP_ADDRESSMODE | |
  37100. * | 2 | MIRROR_ADDRESSMODE | |
  37101. */
  37102. get wrapU(): number;
  37103. set wrapU(value: number);
  37104. private _wrapV;
  37105. /**
  37106. * | Value | Type | Description |
  37107. * | ----- | ------------------ | ----------- |
  37108. * | 0 | CLAMP_ADDRESSMODE | |
  37109. * | 1 | WRAP_ADDRESSMODE | |
  37110. * | 2 | MIRROR_ADDRESSMODE | |
  37111. */
  37112. get wrapV(): number;
  37113. set wrapV(value: number);
  37114. /**
  37115. * | Value | Type | Description |
  37116. * | ----- | ------------------ | ----------- |
  37117. * | 0 | CLAMP_ADDRESSMODE | |
  37118. * | 1 | WRAP_ADDRESSMODE | |
  37119. * | 2 | MIRROR_ADDRESSMODE | |
  37120. */
  37121. wrapR: number;
  37122. /**
  37123. * With compliant hardware and browser (supporting anisotropic filtering)
  37124. * this defines the level of anisotropic filtering in the texture.
  37125. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37126. */
  37127. anisotropicFilteringLevel: number;
  37128. /**
  37129. * Define if the texture is a cube texture or if false a 2d texture.
  37130. */
  37131. get isCube(): boolean;
  37132. set isCube(value: boolean);
  37133. /**
  37134. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37135. */
  37136. get is3D(): boolean;
  37137. set is3D(value: boolean);
  37138. /**
  37139. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37140. */
  37141. get is2DArray(): boolean;
  37142. set is2DArray(value: boolean);
  37143. private _gammaSpace;
  37144. /**
  37145. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37146. * HDR texture are usually stored in linear space.
  37147. * This only impacts the PBR and Background materials
  37148. */
  37149. get gammaSpace(): boolean;
  37150. set gammaSpace(gamma: boolean);
  37151. /**
  37152. * Gets or sets whether or not the texture contains RGBD data.
  37153. */
  37154. get isRGBD(): boolean;
  37155. set isRGBD(value: boolean);
  37156. /**
  37157. * Is Z inverted in the texture (useful in a cube texture).
  37158. */
  37159. invertZ: boolean;
  37160. /**
  37161. * Are mip maps generated for this texture or not.
  37162. */
  37163. get noMipmap(): boolean;
  37164. /**
  37165. * @hidden
  37166. */
  37167. lodLevelInAlpha: boolean;
  37168. /**
  37169. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37170. */
  37171. get lodGenerationOffset(): number;
  37172. set lodGenerationOffset(value: number);
  37173. /**
  37174. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37175. */
  37176. get lodGenerationScale(): number;
  37177. set lodGenerationScale(value: number);
  37178. /**
  37179. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37180. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37181. * average roughness values.
  37182. */
  37183. get linearSpecularLOD(): boolean;
  37184. set linearSpecularLOD(value: boolean);
  37185. /**
  37186. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37187. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37188. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37189. */
  37190. get irradianceTexture(): Nullable<BaseTexture>;
  37191. set irradianceTexture(value: Nullable<BaseTexture>);
  37192. /**
  37193. * Define if the texture is a render target.
  37194. */
  37195. isRenderTarget: boolean;
  37196. /**
  37197. * Define the unique id of the texture in the scene.
  37198. */
  37199. get uid(): string;
  37200. /** @hidden */
  37201. _prefiltered: boolean;
  37202. /**
  37203. * Return a string representation of the texture.
  37204. * @returns the texture as a string
  37205. */
  37206. toString(): string;
  37207. /**
  37208. * Get the class name of the texture.
  37209. * @returns "BaseTexture"
  37210. */
  37211. getClassName(): string;
  37212. /**
  37213. * Define the list of animation attached to the texture.
  37214. */
  37215. animations: Animation[];
  37216. /**
  37217. * An event triggered when the texture is disposed.
  37218. */
  37219. onDisposeObservable: Observable<BaseTexture>;
  37220. private _onDisposeObserver;
  37221. /**
  37222. * Callback triggered when the texture has been disposed.
  37223. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37224. */
  37225. set onDispose(callback: () => void);
  37226. /**
  37227. * Define the current state of the loading sequence when in delayed load mode.
  37228. */
  37229. delayLoadState: number;
  37230. protected _scene: Nullable<Scene>;
  37231. protected _engine: Nullable<ThinEngine>;
  37232. /** @hidden */
  37233. _texture: Nullable<InternalTexture>;
  37234. private _uid;
  37235. /**
  37236. * Define if the texture is preventinga material to render or not.
  37237. * If not and the texture is not ready, the engine will use a default black texture instead.
  37238. */
  37239. get isBlocking(): boolean;
  37240. /**
  37241. * Instantiates a new BaseTexture.
  37242. * Base class of all the textures in babylon.
  37243. * It groups all the common properties the materials, post process, lights... might need
  37244. * in order to make a correct use of the texture.
  37245. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37246. */
  37247. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37248. /**
  37249. * Get the scene the texture belongs to.
  37250. * @returns the scene or null if undefined
  37251. */
  37252. getScene(): Nullable<Scene>;
  37253. /** @hidden */
  37254. protected _getEngine(): Nullable<ThinEngine>;
  37255. /**
  37256. * Checks if the texture has the same transform matrix than another texture
  37257. * @param texture texture to check against
  37258. * @returns true if the transforms are the same, else false
  37259. */
  37260. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  37261. /**
  37262. * Get the texture transform matrix used to offset tile the texture for istance.
  37263. * @returns the transformation matrix
  37264. */
  37265. getTextureMatrix(): Matrix;
  37266. /**
  37267. * Get the texture reflection matrix used to rotate/transform the reflection.
  37268. * @returns the reflection matrix
  37269. */
  37270. getReflectionTextureMatrix(): Matrix;
  37271. /**
  37272. * Get the underlying lower level texture from Babylon.
  37273. * @returns the insternal texture
  37274. */
  37275. getInternalTexture(): Nullable<InternalTexture>;
  37276. /**
  37277. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37278. * @returns true if ready or not blocking
  37279. */
  37280. isReadyOrNotBlocking(): boolean;
  37281. /**
  37282. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37283. * @returns true if fully ready
  37284. */
  37285. isReady(): boolean;
  37286. private _cachedSize;
  37287. /**
  37288. * Get the size of the texture.
  37289. * @returns the texture size.
  37290. */
  37291. getSize(): ISize;
  37292. /**
  37293. * Get the base size of the texture.
  37294. * It can be different from the size if the texture has been resized for POT for instance
  37295. * @returns the base size
  37296. */
  37297. getBaseSize(): ISize;
  37298. /**
  37299. * Update the sampling mode of the texture.
  37300. * Default is Trilinear mode.
  37301. *
  37302. * | Value | Type | Description |
  37303. * | ----- | ------------------ | ----------- |
  37304. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37305. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37306. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37307. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37308. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37309. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37310. * | 7 | NEAREST_LINEAR | |
  37311. * | 8 | NEAREST_NEAREST | |
  37312. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37313. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37314. * | 11 | LINEAR_LINEAR | |
  37315. * | 12 | LINEAR_NEAREST | |
  37316. *
  37317. * > _mag_: magnification filter (close to the viewer)
  37318. * > _min_: minification filter (far from the viewer)
  37319. * > _mip_: filter used between mip map levels
  37320. *@param samplingMode Define the new sampling mode of the texture
  37321. */
  37322. updateSamplingMode(samplingMode: number): void;
  37323. /**
  37324. * Scales the texture if is `canRescale()`
  37325. * @param ratio the resize factor we want to use to rescale
  37326. */
  37327. scale(ratio: number): void;
  37328. /**
  37329. * Get if the texture can rescale.
  37330. */
  37331. get canRescale(): boolean;
  37332. /** @hidden */
  37333. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37334. /** @hidden */
  37335. _rebuild(): void;
  37336. /**
  37337. * Triggers the load sequence in delayed load mode.
  37338. */
  37339. delayLoad(): void;
  37340. /**
  37341. * Clones the texture.
  37342. * @returns the cloned texture
  37343. */
  37344. clone(): Nullable<BaseTexture>;
  37345. /**
  37346. * Get the texture underlying type (INT, FLOAT...)
  37347. */
  37348. get textureType(): number;
  37349. /**
  37350. * Get the texture underlying format (RGB, RGBA...)
  37351. */
  37352. get textureFormat(): number;
  37353. /**
  37354. * Indicates that textures need to be re-calculated for all materials
  37355. */
  37356. protected _markAllSubMeshesAsTexturesDirty(): void;
  37357. /**
  37358. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37359. * This will returns an RGBA array buffer containing either in values (0-255) or
  37360. * float values (0-1) depending of the underlying buffer type.
  37361. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37362. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37363. * @param buffer defines a user defined buffer to fill with data (can be null)
  37364. * @returns The Array buffer containing the pixels data.
  37365. */
  37366. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37367. /**
  37368. * Release and destroy the underlying lower level texture aka internalTexture.
  37369. */
  37370. releaseInternalTexture(): void;
  37371. /** @hidden */
  37372. get _lodTextureHigh(): Nullable<BaseTexture>;
  37373. /** @hidden */
  37374. get _lodTextureMid(): Nullable<BaseTexture>;
  37375. /** @hidden */
  37376. get _lodTextureLow(): Nullable<BaseTexture>;
  37377. /**
  37378. * Dispose the texture and release its associated resources.
  37379. */
  37380. dispose(): void;
  37381. /**
  37382. * Serialize the texture into a JSON representation that can be parsed later on.
  37383. * @returns the JSON representation of the texture
  37384. */
  37385. serialize(): any;
  37386. /**
  37387. * Helper function to be called back once a list of texture contains only ready textures.
  37388. * @param textures Define the list of textures to wait for
  37389. * @param callback Define the callback triggered once the entire list will be ready
  37390. */
  37391. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37392. private static _isScene;
  37393. }
  37394. }
  37395. declare module BABYLON {
  37396. /**
  37397. * Options to be used when creating an effect.
  37398. */
  37399. export interface IEffectCreationOptions {
  37400. /**
  37401. * Atrributes that will be used in the shader.
  37402. */
  37403. attributes: string[];
  37404. /**
  37405. * Uniform varible names that will be set in the shader.
  37406. */
  37407. uniformsNames: string[];
  37408. /**
  37409. * Uniform buffer variable names that will be set in the shader.
  37410. */
  37411. uniformBuffersNames: string[];
  37412. /**
  37413. * Sampler texture variable names that will be set in the shader.
  37414. */
  37415. samplers: string[];
  37416. /**
  37417. * Define statements that will be set in the shader.
  37418. */
  37419. defines: any;
  37420. /**
  37421. * Possible fallbacks for this effect to improve performance when needed.
  37422. */
  37423. fallbacks: Nullable<IEffectFallbacks>;
  37424. /**
  37425. * Callback that will be called when the shader is compiled.
  37426. */
  37427. onCompiled: Nullable<(effect: Effect) => void>;
  37428. /**
  37429. * Callback that will be called if an error occurs during shader compilation.
  37430. */
  37431. onError: Nullable<(effect: Effect, errors: string) => void>;
  37432. /**
  37433. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37434. */
  37435. indexParameters?: any;
  37436. /**
  37437. * Max number of lights that can be used in the shader.
  37438. */
  37439. maxSimultaneousLights?: number;
  37440. /**
  37441. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37442. */
  37443. transformFeedbackVaryings?: Nullable<string[]>;
  37444. /**
  37445. * 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
  37446. */
  37447. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37448. /**
  37449. * Is this effect rendering to several color attachments ?
  37450. */
  37451. multiTarget?: boolean;
  37452. }
  37453. /**
  37454. * Effect containing vertex and fragment shader that can be executed on an object.
  37455. */
  37456. export class Effect implements IDisposable {
  37457. /**
  37458. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37459. */
  37460. static ShadersRepository: string;
  37461. /**
  37462. * Enable logging of the shader code when a compilation error occurs
  37463. */
  37464. static LogShaderCodeOnCompilationError: boolean;
  37465. /**
  37466. * Name of the effect.
  37467. */
  37468. name: any;
  37469. /**
  37470. * String container all the define statements that should be set on the shader.
  37471. */
  37472. defines: string;
  37473. /**
  37474. * Callback that will be called when the shader is compiled.
  37475. */
  37476. onCompiled: Nullable<(effect: Effect) => void>;
  37477. /**
  37478. * Callback that will be called if an error occurs during shader compilation.
  37479. */
  37480. onError: Nullable<(effect: Effect, errors: string) => void>;
  37481. /**
  37482. * Callback that will be called when effect is bound.
  37483. */
  37484. onBind: Nullable<(effect: Effect) => void>;
  37485. /**
  37486. * Unique ID of the effect.
  37487. */
  37488. uniqueId: number;
  37489. /**
  37490. * Observable that will be called when the shader is compiled.
  37491. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37492. */
  37493. onCompileObservable: Observable<Effect>;
  37494. /**
  37495. * Observable that will be called if an error occurs during shader compilation.
  37496. */
  37497. onErrorObservable: Observable<Effect>;
  37498. /** @hidden */
  37499. _onBindObservable: Nullable<Observable<Effect>>;
  37500. /**
  37501. * @hidden
  37502. * Specifies if the effect was previously ready
  37503. */
  37504. _wasPreviouslyReady: boolean;
  37505. /**
  37506. * Observable that will be called when effect is bound.
  37507. */
  37508. get onBindObservable(): Observable<Effect>;
  37509. /** @hidden */
  37510. _bonesComputationForcedToCPU: boolean;
  37511. /** @hidden */
  37512. _multiTarget: boolean;
  37513. private static _uniqueIdSeed;
  37514. private _engine;
  37515. private _uniformBuffersNames;
  37516. private _uniformBuffersNamesList;
  37517. private _uniformsNames;
  37518. private _samplerList;
  37519. private _samplers;
  37520. private _isReady;
  37521. private _compilationError;
  37522. private _allFallbacksProcessed;
  37523. private _attributesNames;
  37524. private _attributes;
  37525. private _attributeLocationByName;
  37526. private _uniforms;
  37527. /**
  37528. * Key for the effect.
  37529. * @hidden
  37530. */
  37531. _key: string;
  37532. private _indexParameters;
  37533. private _fallbacks;
  37534. private _vertexSourceCode;
  37535. private _fragmentSourceCode;
  37536. private _vertexSourceCodeOverride;
  37537. private _fragmentSourceCodeOverride;
  37538. private _transformFeedbackVaryings;
  37539. /**
  37540. * Compiled shader to webGL program.
  37541. * @hidden
  37542. */
  37543. _pipelineContext: Nullable<IPipelineContext>;
  37544. private _valueCache;
  37545. private static _baseCache;
  37546. /**
  37547. * Instantiates an effect.
  37548. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37549. * @param baseName Name of the effect.
  37550. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37551. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37552. * @param samplers List of sampler variables that will be passed to the shader.
  37553. * @param engine Engine to be used to render the effect
  37554. * @param defines Define statements to be added to the shader.
  37555. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37556. * @param onCompiled Callback that will be called when the shader is compiled.
  37557. * @param onError Callback that will be called if an error occurs during shader compilation.
  37558. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37559. */
  37560. 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);
  37561. private _useFinalCode;
  37562. /**
  37563. * Unique key for this effect
  37564. */
  37565. get key(): string;
  37566. /**
  37567. * If the effect has been compiled and prepared.
  37568. * @returns if the effect is compiled and prepared.
  37569. */
  37570. isReady(): boolean;
  37571. private _isReadyInternal;
  37572. /**
  37573. * The engine the effect was initialized with.
  37574. * @returns the engine.
  37575. */
  37576. getEngine(): Engine;
  37577. /**
  37578. * The pipeline context for this effect
  37579. * @returns the associated pipeline context
  37580. */
  37581. getPipelineContext(): Nullable<IPipelineContext>;
  37582. /**
  37583. * The set of names of attribute variables for the shader.
  37584. * @returns An array of attribute names.
  37585. */
  37586. getAttributesNames(): string[];
  37587. /**
  37588. * Returns the attribute at the given index.
  37589. * @param index The index of the attribute.
  37590. * @returns The location of the attribute.
  37591. */
  37592. getAttributeLocation(index: number): number;
  37593. /**
  37594. * Returns the attribute based on the name of the variable.
  37595. * @param name of the attribute to look up.
  37596. * @returns the attribute location.
  37597. */
  37598. getAttributeLocationByName(name: string): number;
  37599. /**
  37600. * The number of attributes.
  37601. * @returns the numnber of attributes.
  37602. */
  37603. getAttributesCount(): number;
  37604. /**
  37605. * Gets the index of a uniform variable.
  37606. * @param uniformName of the uniform to look up.
  37607. * @returns the index.
  37608. */
  37609. getUniformIndex(uniformName: string): number;
  37610. /**
  37611. * Returns the attribute based on the name of the variable.
  37612. * @param uniformName of the uniform to look up.
  37613. * @returns the location of the uniform.
  37614. */
  37615. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37616. /**
  37617. * Returns an array of sampler variable names
  37618. * @returns The array of sampler variable names.
  37619. */
  37620. getSamplers(): string[];
  37621. /**
  37622. * Returns an array of uniform variable names
  37623. * @returns The array of uniform variable names.
  37624. */
  37625. getUniformNames(): string[];
  37626. /**
  37627. * Returns an array of uniform buffer variable names
  37628. * @returns The array of uniform buffer variable names.
  37629. */
  37630. getUniformBuffersNames(): string[];
  37631. /**
  37632. * Returns the index parameters used to create the effect
  37633. * @returns The index parameters object
  37634. */
  37635. getIndexParameters(): any;
  37636. /**
  37637. * The error from the last compilation.
  37638. * @returns the error string.
  37639. */
  37640. getCompilationError(): string;
  37641. /**
  37642. * Gets a boolean indicating that all fallbacks were used during compilation
  37643. * @returns true if all fallbacks were used
  37644. */
  37645. allFallbacksProcessed(): boolean;
  37646. /**
  37647. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37648. * @param func The callback to be used.
  37649. */
  37650. executeWhenCompiled(func: (effect: Effect) => void): void;
  37651. private _checkIsReady;
  37652. private _loadShader;
  37653. /**
  37654. * Gets the vertex shader source code of this effect
  37655. */
  37656. get vertexSourceCode(): string;
  37657. /**
  37658. * Gets the fragment shader source code of this effect
  37659. */
  37660. get fragmentSourceCode(): string;
  37661. /**
  37662. * Recompiles the webGL program
  37663. * @param vertexSourceCode The source code for the vertex shader.
  37664. * @param fragmentSourceCode The source code for the fragment shader.
  37665. * @param onCompiled Callback called when completed.
  37666. * @param onError Callback called on error.
  37667. * @hidden
  37668. */
  37669. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37670. /**
  37671. * Prepares the effect
  37672. * @hidden
  37673. */
  37674. _prepareEffect(): void;
  37675. private _getShaderCodeAndErrorLine;
  37676. private _processCompilationErrors;
  37677. /**
  37678. * Checks if the effect is supported. (Must be called after compilation)
  37679. */
  37680. get isSupported(): boolean;
  37681. /**
  37682. * Binds a texture to the engine to be used as output of the shader.
  37683. * @param channel Name of the output variable.
  37684. * @param texture Texture to bind.
  37685. * @hidden
  37686. */
  37687. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37688. /**
  37689. * Sets a texture on the engine to be used in the shader.
  37690. * @param channel Name of the sampler variable.
  37691. * @param texture Texture to set.
  37692. */
  37693. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37694. /**
  37695. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37696. * @param channel Name of the sampler variable.
  37697. * @param texture Texture to set.
  37698. */
  37699. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37700. /**
  37701. * Sets an array of textures on the engine to be used in the shader.
  37702. * @param channel Name of the variable.
  37703. * @param textures Textures to set.
  37704. */
  37705. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37706. /**
  37707. * 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)
  37708. * @param channel Name of the sampler variable.
  37709. * @param postProcess Post process to get the input texture from.
  37710. */
  37711. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  37712. /**
  37713. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  37714. * 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)
  37715. * @param channel Name of the sampler variable.
  37716. * @param postProcess Post process to get the output texture from.
  37717. */
  37718. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  37719. /** @hidden */
  37720. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  37721. /** @hidden */
  37722. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  37723. /** @hidden */
  37724. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  37725. /** @hidden */
  37726. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  37727. /**
  37728. * Binds a buffer to a uniform.
  37729. * @param buffer Buffer to bind.
  37730. * @param name Name of the uniform variable to bind to.
  37731. */
  37732. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  37733. /**
  37734. * Binds block to a uniform.
  37735. * @param blockName Name of the block to bind.
  37736. * @param index Index to bind.
  37737. */
  37738. bindUniformBlock(blockName: string, index: number): void;
  37739. /**
  37740. * Sets an interger value on a uniform variable.
  37741. * @param uniformName Name of the variable.
  37742. * @param value Value to be set.
  37743. * @returns this effect.
  37744. */
  37745. setInt(uniformName: string, value: number): Effect;
  37746. /**
  37747. * Sets an int array on a uniform variable.
  37748. * @param uniformName Name of the variable.
  37749. * @param array array to be set.
  37750. * @returns this effect.
  37751. */
  37752. setIntArray(uniformName: string, array: Int32Array): Effect;
  37753. /**
  37754. * 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)
  37755. * @param uniformName Name of the variable.
  37756. * @param array array to be set.
  37757. * @returns this effect.
  37758. */
  37759. setIntArray2(uniformName: string, array: Int32Array): Effect;
  37760. /**
  37761. * 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)
  37762. * @param uniformName Name of the variable.
  37763. * @param array array to be set.
  37764. * @returns this effect.
  37765. */
  37766. setIntArray3(uniformName: string, array: Int32Array): Effect;
  37767. /**
  37768. * 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)
  37769. * @param uniformName Name of the variable.
  37770. * @param array array to be set.
  37771. * @returns this effect.
  37772. */
  37773. setIntArray4(uniformName: string, array: Int32Array): Effect;
  37774. /**
  37775. * Sets an float array on a uniform variable.
  37776. * @param uniformName Name of the variable.
  37777. * @param array array to be set.
  37778. * @returns this effect.
  37779. */
  37780. setFloatArray(uniformName: string, array: Float32Array): Effect;
  37781. /**
  37782. * 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)
  37783. * @param uniformName Name of the variable.
  37784. * @param array array to be set.
  37785. * @returns this effect.
  37786. */
  37787. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  37788. /**
  37789. * 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)
  37790. * @param uniformName Name of the variable.
  37791. * @param array array to be set.
  37792. * @returns this effect.
  37793. */
  37794. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  37795. /**
  37796. * 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)
  37797. * @param uniformName Name of the variable.
  37798. * @param array array to be set.
  37799. * @returns this effect.
  37800. */
  37801. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  37802. /**
  37803. * Sets an array on a uniform variable.
  37804. * @param uniformName Name of the variable.
  37805. * @param array array to be set.
  37806. * @returns this effect.
  37807. */
  37808. setArray(uniformName: string, array: number[]): Effect;
  37809. /**
  37810. * 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)
  37811. * @param uniformName Name of the variable.
  37812. * @param array array to be set.
  37813. * @returns this effect.
  37814. */
  37815. setArray2(uniformName: string, array: number[]): Effect;
  37816. /**
  37817. * 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)
  37818. * @param uniformName Name of the variable.
  37819. * @param array array to be set.
  37820. * @returns this effect.
  37821. */
  37822. setArray3(uniformName: string, array: number[]): Effect;
  37823. /**
  37824. * 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)
  37825. * @param uniformName Name of the variable.
  37826. * @param array array to be set.
  37827. * @returns this effect.
  37828. */
  37829. setArray4(uniformName: string, array: number[]): Effect;
  37830. /**
  37831. * Sets matrices on a uniform variable.
  37832. * @param uniformName Name of the variable.
  37833. * @param matrices matrices to be set.
  37834. * @returns this effect.
  37835. */
  37836. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  37837. /**
  37838. * Sets matrix on a uniform variable.
  37839. * @param uniformName Name of the variable.
  37840. * @param matrix matrix to be set.
  37841. * @returns this effect.
  37842. */
  37843. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  37844. /**
  37845. * 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)
  37846. * @param uniformName Name of the variable.
  37847. * @param matrix matrix to be set.
  37848. * @returns this effect.
  37849. */
  37850. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37851. /**
  37852. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  37853. * @param uniformName Name of the variable.
  37854. * @param matrix matrix to be set.
  37855. * @returns this effect.
  37856. */
  37857. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37858. /**
  37859. * Sets a float on a uniform variable.
  37860. * @param uniformName Name of the variable.
  37861. * @param value value to be set.
  37862. * @returns this effect.
  37863. */
  37864. setFloat(uniformName: string, value: number): Effect;
  37865. /**
  37866. * Sets a boolean on a uniform variable.
  37867. * @param uniformName Name of the variable.
  37868. * @param bool value to be set.
  37869. * @returns this effect.
  37870. */
  37871. setBool(uniformName: string, bool: boolean): Effect;
  37872. /**
  37873. * Sets a Vector2 on a uniform variable.
  37874. * @param uniformName Name of the variable.
  37875. * @param vector2 vector2 to be set.
  37876. * @returns this effect.
  37877. */
  37878. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  37879. /**
  37880. * Sets a float2 on a uniform variable.
  37881. * @param uniformName Name of the variable.
  37882. * @param x First float in float2.
  37883. * @param y Second float in float2.
  37884. * @returns this effect.
  37885. */
  37886. setFloat2(uniformName: string, x: number, y: number): Effect;
  37887. /**
  37888. * Sets a Vector3 on a uniform variable.
  37889. * @param uniformName Name of the variable.
  37890. * @param vector3 Value to be set.
  37891. * @returns this effect.
  37892. */
  37893. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  37894. /**
  37895. * Sets a float3 on a uniform variable.
  37896. * @param uniformName Name of the variable.
  37897. * @param x First float in float3.
  37898. * @param y Second float in float3.
  37899. * @param z Third float in float3.
  37900. * @returns this effect.
  37901. */
  37902. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  37903. /**
  37904. * Sets a Vector4 on a uniform variable.
  37905. * @param uniformName Name of the variable.
  37906. * @param vector4 Value to be set.
  37907. * @returns this effect.
  37908. */
  37909. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  37910. /**
  37911. * Sets a float4 on a uniform variable.
  37912. * @param uniformName Name of the variable.
  37913. * @param x First float in float4.
  37914. * @param y Second float in float4.
  37915. * @param z Third float in float4.
  37916. * @param w Fourth float in float4.
  37917. * @returns this effect.
  37918. */
  37919. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  37920. /**
  37921. * Sets a Color3 on a uniform variable.
  37922. * @param uniformName Name of the variable.
  37923. * @param color3 Value to be set.
  37924. * @returns this effect.
  37925. */
  37926. setColor3(uniformName: string, color3: IColor3Like): Effect;
  37927. /**
  37928. * Sets a Color4 on a uniform variable.
  37929. * @param uniformName Name of the variable.
  37930. * @param color3 Value to be set.
  37931. * @param alpha Alpha value to be set.
  37932. * @returns this effect.
  37933. */
  37934. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  37935. /**
  37936. * Sets a Color4 on a uniform variable
  37937. * @param uniformName defines the name of the variable
  37938. * @param color4 defines the value to be set
  37939. * @returns this effect.
  37940. */
  37941. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  37942. /** Release all associated resources */
  37943. dispose(): void;
  37944. /**
  37945. * This function will add a new shader to the shader store
  37946. * @param name the name of the shader
  37947. * @param pixelShader optional pixel shader content
  37948. * @param vertexShader optional vertex shader content
  37949. */
  37950. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  37951. /**
  37952. * Store of each shader (The can be looked up using effect.key)
  37953. */
  37954. static ShadersStore: {
  37955. [key: string]: string;
  37956. };
  37957. /**
  37958. * Store of each included file for a shader (The can be looked up using effect.key)
  37959. */
  37960. static IncludesShadersStore: {
  37961. [key: string]: string;
  37962. };
  37963. /**
  37964. * Resets the cache of effects.
  37965. */
  37966. static ResetCache(): void;
  37967. }
  37968. }
  37969. declare module BABYLON {
  37970. /**
  37971. * Interface used to describe the capabilities of the engine relatively to the current browser
  37972. */
  37973. export interface EngineCapabilities {
  37974. /** Maximum textures units per fragment shader */
  37975. maxTexturesImageUnits: number;
  37976. /** Maximum texture units per vertex shader */
  37977. maxVertexTextureImageUnits: number;
  37978. /** Maximum textures units in the entire pipeline */
  37979. maxCombinedTexturesImageUnits: number;
  37980. /** Maximum texture size */
  37981. maxTextureSize: number;
  37982. /** Maximum texture samples */
  37983. maxSamples?: number;
  37984. /** Maximum cube texture size */
  37985. maxCubemapTextureSize: number;
  37986. /** Maximum render texture size */
  37987. maxRenderTextureSize: number;
  37988. /** Maximum number of vertex attributes */
  37989. maxVertexAttribs: number;
  37990. /** Maximum number of varyings */
  37991. maxVaryingVectors: number;
  37992. /** Maximum number of uniforms per vertex shader */
  37993. maxVertexUniformVectors: number;
  37994. /** Maximum number of uniforms per fragment shader */
  37995. maxFragmentUniformVectors: number;
  37996. /** Defines if standard derivates (dx/dy) are supported */
  37997. standardDerivatives: boolean;
  37998. /** Defines if s3tc texture compression is supported */
  37999. s3tc?: WEBGL_compressed_texture_s3tc;
  38000. /** Defines if pvrtc texture compression is supported */
  38001. pvrtc: any;
  38002. /** Defines if etc1 texture compression is supported */
  38003. etc1: any;
  38004. /** Defines if etc2 texture compression is supported */
  38005. etc2: any;
  38006. /** Defines if astc texture compression is supported */
  38007. astc: any;
  38008. /** Defines if bptc texture compression is supported */
  38009. bptc: any;
  38010. /** Defines if float textures are supported */
  38011. textureFloat: boolean;
  38012. /** Defines if vertex array objects are supported */
  38013. vertexArrayObject: boolean;
  38014. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38015. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38016. /** Gets the maximum level of anisotropy supported */
  38017. maxAnisotropy: number;
  38018. /** Defines if instancing is supported */
  38019. instancedArrays: boolean;
  38020. /** Defines if 32 bits indices are supported */
  38021. uintIndices: boolean;
  38022. /** Defines if high precision shaders are supported */
  38023. highPrecisionShaderSupported: boolean;
  38024. /** Defines if depth reading in the fragment shader is supported */
  38025. fragmentDepthSupported: boolean;
  38026. /** Defines if float texture linear filtering is supported*/
  38027. textureFloatLinearFiltering: boolean;
  38028. /** Defines if rendering to float textures is supported */
  38029. textureFloatRender: boolean;
  38030. /** Defines if half float textures are supported*/
  38031. textureHalfFloat: boolean;
  38032. /** Defines if half float texture linear filtering is supported*/
  38033. textureHalfFloatLinearFiltering: boolean;
  38034. /** Defines if rendering to half float textures is supported */
  38035. textureHalfFloatRender: boolean;
  38036. /** Defines if textureLOD shader command is supported */
  38037. textureLOD: boolean;
  38038. /** Defines if draw buffers extension is supported */
  38039. drawBuffersExtension: boolean;
  38040. /** Defines if depth textures are supported */
  38041. depthTextureExtension: boolean;
  38042. /** Defines if float color buffer are supported */
  38043. colorBufferFloat: boolean;
  38044. /** Gets disjoint timer query extension (null if not supported) */
  38045. timerQuery?: EXT_disjoint_timer_query;
  38046. /** Defines if timestamp can be used with timer query */
  38047. canUseTimestampForTimerQuery: boolean;
  38048. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38049. multiview?: any;
  38050. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38051. oculusMultiview?: any;
  38052. /** Function used to let the system compiles shaders in background */
  38053. parallelShaderCompile?: {
  38054. COMPLETION_STATUS_KHR: number;
  38055. };
  38056. /** Max number of texture samples for MSAA */
  38057. maxMSAASamples: number;
  38058. /** Defines if the blend min max extension is supported */
  38059. blendMinMax: boolean;
  38060. }
  38061. }
  38062. declare module BABYLON {
  38063. /**
  38064. * @hidden
  38065. **/
  38066. export class DepthCullingState {
  38067. private _isDepthTestDirty;
  38068. private _isDepthMaskDirty;
  38069. private _isDepthFuncDirty;
  38070. private _isCullFaceDirty;
  38071. private _isCullDirty;
  38072. private _isZOffsetDirty;
  38073. private _isFrontFaceDirty;
  38074. private _depthTest;
  38075. private _depthMask;
  38076. private _depthFunc;
  38077. private _cull;
  38078. private _cullFace;
  38079. private _zOffset;
  38080. private _frontFace;
  38081. /**
  38082. * Initializes the state.
  38083. */
  38084. constructor();
  38085. get isDirty(): boolean;
  38086. get zOffset(): number;
  38087. set zOffset(value: number);
  38088. get cullFace(): Nullable<number>;
  38089. set cullFace(value: Nullable<number>);
  38090. get cull(): Nullable<boolean>;
  38091. set cull(value: Nullable<boolean>);
  38092. get depthFunc(): Nullable<number>;
  38093. set depthFunc(value: Nullable<number>);
  38094. get depthMask(): boolean;
  38095. set depthMask(value: boolean);
  38096. get depthTest(): boolean;
  38097. set depthTest(value: boolean);
  38098. get frontFace(): Nullable<number>;
  38099. set frontFace(value: Nullable<number>);
  38100. reset(): void;
  38101. apply(gl: WebGLRenderingContext): void;
  38102. }
  38103. }
  38104. declare module BABYLON {
  38105. /**
  38106. * @hidden
  38107. **/
  38108. export class StencilState {
  38109. /** 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 */
  38110. static readonly ALWAYS: number;
  38111. /** Passed to stencilOperation to specify that stencil value must be kept */
  38112. static readonly KEEP: number;
  38113. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38114. static readonly REPLACE: number;
  38115. private _isStencilTestDirty;
  38116. private _isStencilMaskDirty;
  38117. private _isStencilFuncDirty;
  38118. private _isStencilOpDirty;
  38119. private _stencilTest;
  38120. private _stencilMask;
  38121. private _stencilFunc;
  38122. private _stencilFuncRef;
  38123. private _stencilFuncMask;
  38124. private _stencilOpStencilFail;
  38125. private _stencilOpDepthFail;
  38126. private _stencilOpStencilDepthPass;
  38127. get isDirty(): boolean;
  38128. get stencilFunc(): number;
  38129. set stencilFunc(value: number);
  38130. get stencilFuncRef(): number;
  38131. set stencilFuncRef(value: number);
  38132. get stencilFuncMask(): number;
  38133. set stencilFuncMask(value: number);
  38134. get stencilOpStencilFail(): number;
  38135. set stencilOpStencilFail(value: number);
  38136. get stencilOpDepthFail(): number;
  38137. set stencilOpDepthFail(value: number);
  38138. get stencilOpStencilDepthPass(): number;
  38139. set stencilOpStencilDepthPass(value: number);
  38140. get stencilMask(): number;
  38141. set stencilMask(value: number);
  38142. get stencilTest(): boolean;
  38143. set stencilTest(value: boolean);
  38144. constructor();
  38145. reset(): void;
  38146. apply(gl: WebGLRenderingContext): void;
  38147. }
  38148. }
  38149. declare module BABYLON {
  38150. /**
  38151. * @hidden
  38152. **/
  38153. export class AlphaState {
  38154. private _isAlphaBlendDirty;
  38155. private _isBlendFunctionParametersDirty;
  38156. private _isBlendEquationParametersDirty;
  38157. private _isBlendConstantsDirty;
  38158. private _alphaBlend;
  38159. private _blendFunctionParameters;
  38160. private _blendEquationParameters;
  38161. private _blendConstants;
  38162. /**
  38163. * Initializes the state.
  38164. */
  38165. constructor();
  38166. get isDirty(): boolean;
  38167. get alphaBlend(): boolean;
  38168. set alphaBlend(value: boolean);
  38169. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38170. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38171. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38172. reset(): void;
  38173. apply(gl: WebGLRenderingContext): void;
  38174. }
  38175. }
  38176. declare module BABYLON {
  38177. /** @hidden */
  38178. export class WebGLShaderProcessor implements IShaderProcessor {
  38179. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38180. }
  38181. }
  38182. declare module BABYLON {
  38183. /** @hidden */
  38184. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38185. attributeProcessor(attribute: string): string;
  38186. varyingProcessor(varying: string, isFragment: boolean): string;
  38187. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38188. }
  38189. }
  38190. declare module BABYLON {
  38191. /**
  38192. * Interface for attribute information associated with buffer instanciation
  38193. */
  38194. export interface InstancingAttributeInfo {
  38195. /**
  38196. * Name of the GLSL attribute
  38197. * if attribute index is not specified, this is used to retrieve the index from the effect
  38198. */
  38199. attributeName: string;
  38200. /**
  38201. * Index/offset of the attribute in the vertex shader
  38202. * if not specified, this will be computes from the name.
  38203. */
  38204. index?: number;
  38205. /**
  38206. * size of the attribute, 1, 2, 3 or 4
  38207. */
  38208. attributeSize: number;
  38209. /**
  38210. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38211. */
  38212. offset: number;
  38213. /**
  38214. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38215. * default to 1
  38216. */
  38217. divisor?: number;
  38218. /**
  38219. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38220. * default is FLOAT
  38221. */
  38222. attributeType?: number;
  38223. /**
  38224. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38225. */
  38226. normalized?: boolean;
  38227. }
  38228. }
  38229. declare module BABYLON {
  38230. interface ThinEngine {
  38231. /**
  38232. * Update a video texture
  38233. * @param texture defines the texture to update
  38234. * @param video defines the video element to use
  38235. * @param invertY defines if data must be stored with Y axis inverted
  38236. */
  38237. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38238. }
  38239. }
  38240. declare module BABYLON {
  38241. interface ThinEngine {
  38242. /**
  38243. * Creates a dynamic texture
  38244. * @param width defines the width of the texture
  38245. * @param height defines the height of the texture
  38246. * @param generateMipMaps defines if the engine should generate the mip levels
  38247. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38248. * @returns the dynamic texture inside an InternalTexture
  38249. */
  38250. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38251. /**
  38252. * Update the content of a dynamic texture
  38253. * @param texture defines the texture to update
  38254. * @param canvas defines the canvas containing the source
  38255. * @param invertY defines if data must be stored with Y axis inverted
  38256. * @param premulAlpha defines if alpha is stored as premultiplied
  38257. * @param format defines the format of the data
  38258. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38259. */
  38260. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38261. }
  38262. }
  38263. declare module BABYLON {
  38264. /**
  38265. * Settings for finer control over video usage
  38266. */
  38267. export interface VideoTextureSettings {
  38268. /**
  38269. * Applies `autoplay` to video, if specified
  38270. */
  38271. autoPlay?: boolean;
  38272. /**
  38273. * Applies `muted` to video, if specified
  38274. */
  38275. muted?: boolean;
  38276. /**
  38277. * Applies `loop` to video, if specified
  38278. */
  38279. loop?: boolean;
  38280. /**
  38281. * Automatically updates internal texture from video at every frame in the render loop
  38282. */
  38283. autoUpdateTexture: boolean;
  38284. /**
  38285. * Image src displayed during the video loading or until the user interacts with the video.
  38286. */
  38287. poster?: string;
  38288. }
  38289. /**
  38290. * If you want to display a video in your scene, this is the special texture for that.
  38291. * This special texture works similar to other textures, with the exception of a few parameters.
  38292. * @see https://doc.babylonjs.com/how_to/video_texture
  38293. */
  38294. export class VideoTexture extends Texture {
  38295. /**
  38296. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38297. */
  38298. readonly autoUpdateTexture: boolean;
  38299. /**
  38300. * The video instance used by the texture internally
  38301. */
  38302. readonly video: HTMLVideoElement;
  38303. private _onUserActionRequestedObservable;
  38304. /**
  38305. * Event triggerd when a dom action is required by the user to play the video.
  38306. * This happens due to recent changes in browser policies preventing video to auto start.
  38307. */
  38308. get onUserActionRequestedObservable(): Observable<Texture>;
  38309. private _generateMipMaps;
  38310. private _stillImageCaptured;
  38311. private _displayingPosterTexture;
  38312. private _settings;
  38313. private _createInternalTextureOnEvent;
  38314. private _frameId;
  38315. private _currentSrc;
  38316. /**
  38317. * Creates a video texture.
  38318. * If you want to display a video in your scene, this is the special texture for that.
  38319. * This special texture works similar to other textures, with the exception of a few parameters.
  38320. * @see https://doc.babylonjs.com/how_to/video_texture
  38321. * @param name optional name, will detect from video source, if not defined
  38322. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38323. * @param scene is obviously the current scene.
  38324. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38325. * @param invertY is false by default but can be used to invert video on Y axis
  38326. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38327. * @param settings allows finer control over video usage
  38328. */
  38329. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38330. private _getName;
  38331. private _getVideo;
  38332. private _createInternalTexture;
  38333. private reset;
  38334. /**
  38335. * @hidden Internal method to initiate `update`.
  38336. */
  38337. _rebuild(): void;
  38338. /**
  38339. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38340. */
  38341. update(): void;
  38342. /**
  38343. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38344. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38345. */
  38346. updateTexture(isVisible: boolean): void;
  38347. protected _updateInternalTexture: () => void;
  38348. /**
  38349. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38350. * @param url New url.
  38351. */
  38352. updateURL(url: string): void;
  38353. /**
  38354. * Clones the texture.
  38355. * @returns the cloned texture
  38356. */
  38357. clone(): VideoTexture;
  38358. /**
  38359. * Dispose the texture and release its associated resources.
  38360. */
  38361. dispose(): void;
  38362. /**
  38363. * Creates a video texture straight from a stream.
  38364. * @param scene Define the scene the texture should be created in
  38365. * @param stream Define the stream the texture should be created from
  38366. * @returns The created video texture as a promise
  38367. */
  38368. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38369. /**
  38370. * Creates a video texture straight from your WebCam video feed.
  38371. * @param scene Define the scene the texture should be created in
  38372. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38373. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38374. * @returns The created video texture as a promise
  38375. */
  38376. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38377. minWidth: number;
  38378. maxWidth: number;
  38379. minHeight: number;
  38380. maxHeight: number;
  38381. deviceId: string;
  38382. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38383. /**
  38384. * Creates a video texture straight from your WebCam video feed.
  38385. * @param scene Define the scene the texture should be created in
  38386. * @param onReady Define a callback to triggered once the texture will be ready
  38387. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38388. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38389. */
  38390. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38391. minWidth: number;
  38392. maxWidth: number;
  38393. minHeight: number;
  38394. maxHeight: number;
  38395. deviceId: string;
  38396. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38397. }
  38398. }
  38399. declare module BABYLON {
  38400. /**
  38401. * Defines the interface used by objects working like Scene
  38402. * @hidden
  38403. */
  38404. export interface ISceneLike {
  38405. _addPendingData(data: any): void;
  38406. _removePendingData(data: any): void;
  38407. offlineProvider: IOfflineProvider;
  38408. }
  38409. /**
  38410. * Information about the current host
  38411. */
  38412. export interface HostInformation {
  38413. /**
  38414. * Defines if the current host is a mobile
  38415. */
  38416. isMobile: boolean;
  38417. }
  38418. /** Interface defining initialization parameters for Engine class */
  38419. export interface EngineOptions extends WebGLContextAttributes {
  38420. /**
  38421. * Defines if the engine should no exceed a specified device ratio
  38422. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38423. */
  38424. limitDeviceRatio?: number;
  38425. /**
  38426. * Defines if webvr should be enabled automatically
  38427. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38428. */
  38429. autoEnableWebVR?: boolean;
  38430. /**
  38431. * Defines if webgl2 should be turned off even if supported
  38432. * @see https://doc.babylonjs.com/features/webgl2
  38433. */
  38434. disableWebGL2Support?: boolean;
  38435. /**
  38436. * Defines if webaudio should be initialized as well
  38437. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38438. */
  38439. audioEngine?: boolean;
  38440. /**
  38441. * Defines if animations should run using a deterministic lock step
  38442. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38443. */
  38444. deterministicLockstep?: boolean;
  38445. /** Defines the maximum steps to use with deterministic lock step mode */
  38446. lockstepMaxSteps?: number;
  38447. /** Defines the seconds between each deterministic lock step */
  38448. timeStep?: number;
  38449. /**
  38450. * Defines that engine should ignore context lost events
  38451. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38452. */
  38453. doNotHandleContextLost?: boolean;
  38454. /**
  38455. * Defines that engine should ignore modifying touch action attribute and style
  38456. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38457. */
  38458. doNotHandleTouchAction?: boolean;
  38459. /**
  38460. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38461. */
  38462. useHighPrecisionFloats?: boolean;
  38463. /**
  38464. * Make the canvas XR Compatible for XR sessions
  38465. */
  38466. xrCompatible?: boolean;
  38467. /**
  38468. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38469. */
  38470. useHighPrecisionMatrix?: boolean;
  38471. /**
  38472. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38473. */
  38474. failIfMajorPerformanceCaveat?: boolean;
  38475. }
  38476. /**
  38477. * The base engine class (root of all engines)
  38478. */
  38479. export class ThinEngine {
  38480. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38481. static ExceptionList: ({
  38482. key: string;
  38483. capture: string;
  38484. captureConstraint: number;
  38485. targets: string[];
  38486. } | {
  38487. key: string;
  38488. capture: null;
  38489. captureConstraint: null;
  38490. targets: string[];
  38491. })[];
  38492. /** @hidden */
  38493. static _TextureLoaders: IInternalTextureLoader[];
  38494. /**
  38495. * Returns the current npm package of the sdk
  38496. */
  38497. static get NpmPackage(): string;
  38498. /**
  38499. * Returns the current version of the framework
  38500. */
  38501. static get Version(): string;
  38502. /**
  38503. * Returns a string describing the current engine
  38504. */
  38505. get description(): string;
  38506. /**
  38507. * Gets or sets the epsilon value used by collision engine
  38508. */
  38509. static CollisionsEpsilon: number;
  38510. /**
  38511. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38512. */
  38513. static get ShadersRepository(): string;
  38514. static set ShadersRepository(value: string);
  38515. /** @hidden */
  38516. _shaderProcessor: IShaderProcessor;
  38517. /**
  38518. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38519. */
  38520. forcePOTTextures: boolean;
  38521. /**
  38522. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38523. */
  38524. isFullscreen: boolean;
  38525. /**
  38526. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38527. */
  38528. cullBackFaces: boolean;
  38529. /**
  38530. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38531. */
  38532. renderEvenInBackground: boolean;
  38533. /**
  38534. * Gets or sets a boolean indicating that cache can be kept between frames
  38535. */
  38536. preventCacheWipeBetweenFrames: boolean;
  38537. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38538. validateShaderPrograms: boolean;
  38539. /**
  38540. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38541. * This can provide greater z depth for distant objects.
  38542. */
  38543. useReverseDepthBuffer: boolean;
  38544. /**
  38545. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38546. */
  38547. disableUniformBuffers: boolean;
  38548. /** @hidden */
  38549. _uniformBuffers: UniformBuffer[];
  38550. /**
  38551. * Gets a boolean indicating that the engine supports uniform buffers
  38552. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38553. */
  38554. get supportsUniformBuffers(): boolean;
  38555. /** @hidden */
  38556. _gl: WebGLRenderingContext;
  38557. /** @hidden */
  38558. _webGLVersion: number;
  38559. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38560. protected _windowIsBackground: boolean;
  38561. protected _creationOptions: EngineOptions;
  38562. protected _highPrecisionShadersAllowed: boolean;
  38563. /** @hidden */
  38564. get _shouldUseHighPrecisionShader(): boolean;
  38565. /**
  38566. * Gets a boolean indicating that only power of 2 textures are supported
  38567. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38568. */
  38569. get needPOTTextures(): boolean;
  38570. /** @hidden */
  38571. _badOS: boolean;
  38572. /** @hidden */
  38573. _badDesktopOS: boolean;
  38574. private _hardwareScalingLevel;
  38575. /** @hidden */
  38576. _caps: EngineCapabilities;
  38577. private _isStencilEnable;
  38578. private _glVersion;
  38579. private _glRenderer;
  38580. private _glVendor;
  38581. /** @hidden */
  38582. _videoTextureSupported: boolean;
  38583. protected _renderingQueueLaunched: boolean;
  38584. protected _activeRenderLoops: (() => void)[];
  38585. /**
  38586. * Observable signaled when a context lost event is raised
  38587. */
  38588. onContextLostObservable: Observable<ThinEngine>;
  38589. /**
  38590. * Observable signaled when a context restored event is raised
  38591. */
  38592. onContextRestoredObservable: Observable<ThinEngine>;
  38593. private _onContextLost;
  38594. private _onContextRestored;
  38595. protected _contextWasLost: boolean;
  38596. /** @hidden */
  38597. _doNotHandleContextLost: boolean;
  38598. /**
  38599. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38600. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38601. */
  38602. get doNotHandleContextLost(): boolean;
  38603. set doNotHandleContextLost(value: boolean);
  38604. /**
  38605. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38606. */
  38607. disableVertexArrayObjects: boolean;
  38608. /** @hidden */
  38609. protected _colorWrite: boolean;
  38610. /** @hidden */
  38611. protected _colorWriteChanged: boolean;
  38612. /** @hidden */
  38613. protected _depthCullingState: DepthCullingState;
  38614. /** @hidden */
  38615. protected _stencilState: StencilState;
  38616. /** @hidden */
  38617. _alphaState: AlphaState;
  38618. /** @hidden */
  38619. _alphaMode: number;
  38620. /** @hidden */
  38621. _alphaEquation: number;
  38622. /** @hidden */
  38623. _internalTexturesCache: InternalTexture[];
  38624. /** @hidden */
  38625. protected _activeChannel: number;
  38626. private _currentTextureChannel;
  38627. /** @hidden */
  38628. protected _boundTexturesCache: {
  38629. [key: string]: Nullable<InternalTexture>;
  38630. };
  38631. /** @hidden */
  38632. protected _currentEffect: Nullable<Effect>;
  38633. /** @hidden */
  38634. protected _currentProgram: Nullable<WebGLProgram>;
  38635. private _compiledEffects;
  38636. private _vertexAttribArraysEnabled;
  38637. /** @hidden */
  38638. protected _cachedViewport: Nullable<IViewportLike>;
  38639. private _cachedVertexArrayObject;
  38640. /** @hidden */
  38641. protected _cachedVertexBuffers: any;
  38642. /** @hidden */
  38643. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38644. /** @hidden */
  38645. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38646. /** @hidden */
  38647. _currentRenderTarget: Nullable<InternalTexture>;
  38648. private _uintIndicesCurrentlySet;
  38649. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38650. /** @hidden */
  38651. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38652. /** @hidden */
  38653. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38654. private _currentBufferPointers;
  38655. private _currentInstanceLocations;
  38656. private _currentInstanceBuffers;
  38657. private _textureUnits;
  38658. /** @hidden */
  38659. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38660. /** @hidden */
  38661. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38662. /** @hidden */
  38663. _boundRenderFunction: any;
  38664. private _vaoRecordInProgress;
  38665. private _mustWipeVertexAttributes;
  38666. private _emptyTexture;
  38667. private _emptyCubeTexture;
  38668. private _emptyTexture3D;
  38669. private _emptyTexture2DArray;
  38670. /** @hidden */
  38671. _frameHandler: number;
  38672. private _nextFreeTextureSlots;
  38673. private _maxSimultaneousTextures;
  38674. private _activeRequests;
  38675. /** @hidden */
  38676. _transformTextureUrl: Nullable<(url: string) => string>;
  38677. /**
  38678. * Gets information about the current host
  38679. */
  38680. hostInformation: HostInformation;
  38681. protected get _supportsHardwareTextureRescaling(): boolean;
  38682. private _framebufferDimensionsObject;
  38683. /**
  38684. * sets the object from which width and height will be taken from when getting render width and height
  38685. * Will fallback to the gl object
  38686. * @param dimensions the framebuffer width and height that will be used.
  38687. */
  38688. set framebufferDimensionsObject(dimensions: Nullable<{
  38689. framebufferWidth: number;
  38690. framebufferHeight: number;
  38691. }>);
  38692. /**
  38693. * Gets the current viewport
  38694. */
  38695. get currentViewport(): Nullable<IViewportLike>;
  38696. /**
  38697. * Gets the default empty texture
  38698. */
  38699. get emptyTexture(): InternalTexture;
  38700. /**
  38701. * Gets the default empty 3D texture
  38702. */
  38703. get emptyTexture3D(): InternalTexture;
  38704. /**
  38705. * Gets the default empty 2D array texture
  38706. */
  38707. get emptyTexture2DArray(): InternalTexture;
  38708. /**
  38709. * Gets the default empty cube texture
  38710. */
  38711. get emptyCubeTexture(): InternalTexture;
  38712. /**
  38713. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  38714. */
  38715. readonly premultipliedAlpha: boolean;
  38716. /**
  38717. * Observable event triggered before each texture is initialized
  38718. */
  38719. onBeforeTextureInitObservable: Observable<Texture>;
  38720. /**
  38721. * Creates a new engine
  38722. * @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
  38723. * @param antialias defines enable antialiasing (default: false)
  38724. * @param options defines further options to be sent to the getContext() function
  38725. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38726. */
  38727. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38728. private _rebuildInternalTextures;
  38729. private _rebuildEffects;
  38730. /**
  38731. * Gets a boolean indicating if all created effects are ready
  38732. * @returns true if all effects are ready
  38733. */
  38734. areAllEffectsReady(): boolean;
  38735. protected _rebuildBuffers(): void;
  38736. protected _initGLContext(): void;
  38737. /**
  38738. * Gets version of the current webGL context
  38739. */
  38740. get webGLVersion(): number;
  38741. /**
  38742. * Gets a string identifying the name of the class
  38743. * @returns "Engine" string
  38744. */
  38745. getClassName(): string;
  38746. /**
  38747. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  38748. */
  38749. get isStencilEnable(): boolean;
  38750. /** @hidden */
  38751. _prepareWorkingCanvas(): void;
  38752. /**
  38753. * Reset the texture cache to empty state
  38754. */
  38755. resetTextureCache(): void;
  38756. /**
  38757. * Gets an object containing information about the current webGL context
  38758. * @returns an object containing the vender, the renderer and the version of the current webGL context
  38759. */
  38760. getGlInfo(): {
  38761. vendor: string;
  38762. renderer: string;
  38763. version: string;
  38764. };
  38765. /**
  38766. * Defines the hardware scaling level.
  38767. * By default the hardware scaling level is computed from the window device ratio.
  38768. * 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.
  38769. * @param level defines the level to use
  38770. */
  38771. setHardwareScalingLevel(level: number): void;
  38772. /**
  38773. * Gets the current hardware scaling level.
  38774. * By default the hardware scaling level is computed from the window device ratio.
  38775. * 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.
  38776. * @returns a number indicating the current hardware scaling level
  38777. */
  38778. getHardwareScalingLevel(): number;
  38779. /**
  38780. * Gets the list of loaded textures
  38781. * @returns an array containing all loaded textures
  38782. */
  38783. getLoadedTexturesCache(): InternalTexture[];
  38784. /**
  38785. * Gets the object containing all engine capabilities
  38786. * @returns the EngineCapabilities object
  38787. */
  38788. getCaps(): EngineCapabilities;
  38789. /**
  38790. * stop executing a render loop function and remove it from the execution array
  38791. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  38792. */
  38793. stopRenderLoop(renderFunction?: () => void): void;
  38794. /** @hidden */
  38795. _renderLoop(): void;
  38796. /**
  38797. * Gets the HTML canvas attached with the current webGL context
  38798. * @returns a HTML canvas
  38799. */
  38800. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  38801. /**
  38802. * Gets host window
  38803. * @returns the host window object
  38804. */
  38805. getHostWindow(): Nullable<Window>;
  38806. /**
  38807. * Gets the current render width
  38808. * @param useScreen defines if screen size must be used (or the current render target if any)
  38809. * @returns a number defining the current render width
  38810. */
  38811. getRenderWidth(useScreen?: boolean): number;
  38812. /**
  38813. * Gets the current render height
  38814. * @param useScreen defines if screen size must be used (or the current render target if any)
  38815. * @returns a number defining the current render height
  38816. */
  38817. getRenderHeight(useScreen?: boolean): number;
  38818. /**
  38819. * Can be used to override the current requestAnimationFrame requester.
  38820. * @hidden
  38821. */
  38822. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  38823. /**
  38824. * Register and execute a render loop. The engine can have more than one render function
  38825. * @param renderFunction defines the function to continuously execute
  38826. */
  38827. runRenderLoop(renderFunction: () => void): void;
  38828. /**
  38829. * Clear the current render buffer or the current render target (if any is set up)
  38830. * @param color defines the color to use
  38831. * @param backBuffer defines if the back buffer must be cleared
  38832. * @param depth defines if the depth buffer must be cleared
  38833. * @param stencil defines if the stencil buffer must be cleared
  38834. */
  38835. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  38836. private _viewportCached;
  38837. /** @hidden */
  38838. _viewport(x: number, y: number, width: number, height: number): void;
  38839. /**
  38840. * Set the WebGL's viewport
  38841. * @param viewport defines the viewport element to be used
  38842. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  38843. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  38844. */
  38845. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  38846. /**
  38847. * Begin a new frame
  38848. */
  38849. beginFrame(): void;
  38850. /**
  38851. * Enf the current frame
  38852. */
  38853. endFrame(): void;
  38854. /**
  38855. * Resize the view according to the canvas' size
  38856. */
  38857. resize(): void;
  38858. /**
  38859. * Force a specific size of the canvas
  38860. * @param width defines the new canvas' width
  38861. * @param height defines the new canvas' height
  38862. * @returns true if the size was changed
  38863. */
  38864. setSize(width: number, height: number): boolean;
  38865. /**
  38866. * Binds the frame buffer to the specified texture.
  38867. * @param texture The texture to render to or null for the default canvas
  38868. * @param faceIndex The face of the texture to render to in case of cube texture
  38869. * @param requiredWidth The width of the target to render to
  38870. * @param requiredHeight The height of the target to render to
  38871. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  38872. * @param lodLevel defines the lod level to bind to the frame buffer
  38873. * @param layer defines the 2d array index to bind to frame buffer to
  38874. */
  38875. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  38876. /** @hidden */
  38877. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  38878. /**
  38879. * Unbind the current render target texture from the webGL context
  38880. * @param texture defines the render target texture to unbind
  38881. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  38882. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  38883. */
  38884. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  38885. /**
  38886. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  38887. */
  38888. flushFramebuffer(): void;
  38889. /**
  38890. * Unbind the current render target and bind the default framebuffer
  38891. */
  38892. restoreDefaultFramebuffer(): void;
  38893. /** @hidden */
  38894. protected _resetVertexBufferBinding(): void;
  38895. /**
  38896. * Creates a vertex buffer
  38897. * @param data the data for the vertex buffer
  38898. * @returns the new WebGL static buffer
  38899. */
  38900. createVertexBuffer(data: DataArray): DataBuffer;
  38901. private _createVertexBuffer;
  38902. /**
  38903. * Creates a dynamic vertex buffer
  38904. * @param data the data for the dynamic vertex buffer
  38905. * @returns the new WebGL dynamic buffer
  38906. */
  38907. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  38908. protected _resetIndexBufferBinding(): void;
  38909. /**
  38910. * Creates a new index buffer
  38911. * @param indices defines the content of the index buffer
  38912. * @param updatable defines if the index buffer must be updatable
  38913. * @returns a new webGL buffer
  38914. */
  38915. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  38916. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  38917. /**
  38918. * Bind a webGL buffer to the webGL context
  38919. * @param buffer defines the buffer to bind
  38920. */
  38921. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  38922. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  38923. private bindBuffer;
  38924. /**
  38925. * update the bound buffer with the given data
  38926. * @param data defines the data to update
  38927. */
  38928. updateArrayBuffer(data: Float32Array): void;
  38929. private _vertexAttribPointer;
  38930. /** @hidden */
  38931. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  38932. private _bindVertexBuffersAttributes;
  38933. /**
  38934. * Records a vertex array object
  38935. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38936. * @param vertexBuffers defines the list of vertex buffers to store
  38937. * @param indexBuffer defines the index buffer to store
  38938. * @param effect defines the effect to store
  38939. * @returns the new vertex array object
  38940. */
  38941. recordVertexArrayObject(vertexBuffers: {
  38942. [key: string]: VertexBuffer;
  38943. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  38944. /**
  38945. * Bind a specific vertex array object
  38946. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38947. * @param vertexArrayObject defines the vertex array object to bind
  38948. * @param indexBuffer defines the index buffer to bind
  38949. */
  38950. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  38951. /**
  38952. * Bind webGl buffers directly to the webGL context
  38953. * @param vertexBuffer defines the vertex buffer to bind
  38954. * @param indexBuffer defines the index buffer to bind
  38955. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  38956. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  38957. * @param effect defines the effect associated with the vertex buffer
  38958. */
  38959. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  38960. private _unbindVertexArrayObject;
  38961. /**
  38962. * Bind a list of vertex buffers to the webGL context
  38963. * @param vertexBuffers defines the list of vertex buffers to bind
  38964. * @param indexBuffer defines the index buffer to bind
  38965. * @param effect defines the effect associated with the vertex buffers
  38966. */
  38967. bindBuffers(vertexBuffers: {
  38968. [key: string]: Nullable<VertexBuffer>;
  38969. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  38970. /**
  38971. * Unbind all instance attributes
  38972. */
  38973. unbindInstanceAttributes(): void;
  38974. /**
  38975. * Release and free the memory of a vertex array object
  38976. * @param vao defines the vertex array object to delete
  38977. */
  38978. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  38979. /** @hidden */
  38980. _releaseBuffer(buffer: DataBuffer): boolean;
  38981. protected _deleteBuffer(buffer: DataBuffer): void;
  38982. /**
  38983. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  38984. * @param instancesBuffer defines the webGL buffer to update and bind
  38985. * @param data defines the data to store in the buffer
  38986. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  38987. */
  38988. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  38989. /**
  38990. * Bind the content of a webGL buffer used with instantiation
  38991. * @param instancesBuffer defines the webGL buffer to bind
  38992. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  38993. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  38994. */
  38995. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  38996. /**
  38997. * Disable the instance attribute corresponding to the name in parameter
  38998. * @param name defines the name of the attribute to disable
  38999. */
  39000. disableInstanceAttributeByName(name: string): void;
  39001. /**
  39002. * Disable the instance attribute corresponding to the location in parameter
  39003. * @param attributeLocation defines the attribute location of the attribute to disable
  39004. */
  39005. disableInstanceAttribute(attributeLocation: number): void;
  39006. /**
  39007. * Disable the attribute corresponding to the location in parameter
  39008. * @param attributeLocation defines the attribute location of the attribute to disable
  39009. */
  39010. disableAttributeByIndex(attributeLocation: number): void;
  39011. /**
  39012. * Send a draw order
  39013. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39014. * @param indexStart defines the starting index
  39015. * @param indexCount defines the number of index to draw
  39016. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39017. */
  39018. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39019. /**
  39020. * Draw a list of points
  39021. * @param verticesStart defines the index of first vertex to draw
  39022. * @param verticesCount defines the count of vertices to draw
  39023. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39024. */
  39025. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39026. /**
  39027. * Draw a list of unindexed primitives
  39028. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39029. * @param verticesStart defines the index of first vertex to draw
  39030. * @param verticesCount defines the count of vertices to draw
  39031. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39032. */
  39033. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39034. /**
  39035. * Draw a list of indexed primitives
  39036. * @param fillMode defines the primitive to use
  39037. * @param indexStart defines the starting index
  39038. * @param indexCount defines the number of index to draw
  39039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39040. */
  39041. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39042. /**
  39043. * Draw a list of unindexed primitives
  39044. * @param fillMode defines the primitive to use
  39045. * @param verticesStart defines the index of first vertex to draw
  39046. * @param verticesCount defines the count of vertices to draw
  39047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39048. */
  39049. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39050. private _drawMode;
  39051. /** @hidden */
  39052. protected _reportDrawCall(): void;
  39053. /** @hidden */
  39054. _releaseEffect(effect: Effect): void;
  39055. /** @hidden */
  39056. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39057. /**
  39058. * Create a new effect (used to store vertex/fragment shaders)
  39059. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39060. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39061. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39062. * @param samplers defines an array of string used to represent textures
  39063. * @param defines defines the string containing the defines to use to compile the shaders
  39064. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39065. * @param onCompiled defines a function to call when the effect creation is successful
  39066. * @param onError defines a function to call when the effect creation has failed
  39067. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39068. * @returns the new Effect
  39069. */
  39070. 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;
  39071. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39072. private _compileShader;
  39073. private _compileRawShader;
  39074. /** @hidden */
  39075. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39076. /**
  39077. * Directly creates a webGL program
  39078. * @param pipelineContext defines the pipeline context to attach to
  39079. * @param vertexCode defines the vertex shader code to use
  39080. * @param fragmentCode defines the fragment shader code to use
  39081. * @param context defines the webGL context to use (if not set, the current one will be used)
  39082. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39083. * @returns the new webGL program
  39084. */
  39085. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39086. /**
  39087. * Creates a webGL program
  39088. * @param pipelineContext defines the pipeline context to attach to
  39089. * @param vertexCode defines the vertex shader code to use
  39090. * @param fragmentCode defines the fragment shader code to use
  39091. * @param defines defines the string containing the defines to use to compile the shaders
  39092. * @param context defines the webGL context to use (if not set, the current one will be used)
  39093. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39094. * @returns the new webGL program
  39095. */
  39096. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39097. /**
  39098. * Creates a new pipeline context
  39099. * @returns the new pipeline
  39100. */
  39101. createPipelineContext(): IPipelineContext;
  39102. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39103. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39104. /** @hidden */
  39105. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39106. /** @hidden */
  39107. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39108. /** @hidden */
  39109. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39110. /**
  39111. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39112. * @param pipelineContext defines the pipeline context to use
  39113. * @param uniformsNames defines the list of uniform names
  39114. * @returns an array of webGL uniform locations
  39115. */
  39116. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39117. /**
  39118. * Gets the lsit of active attributes for a given webGL program
  39119. * @param pipelineContext defines the pipeline context to use
  39120. * @param attributesNames defines the list of attribute names to get
  39121. * @returns an array of indices indicating the offset of each attribute
  39122. */
  39123. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39124. /**
  39125. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39126. * @param effect defines the effect to activate
  39127. */
  39128. enableEffect(effect: Nullable<Effect>): void;
  39129. /**
  39130. * Set the value of an uniform to a number (int)
  39131. * @param uniform defines the webGL uniform location where to store the value
  39132. * @param value defines the int number to store
  39133. * @returns true if the value was set
  39134. */
  39135. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39136. /**
  39137. * Set the value of an uniform to an array of int32
  39138. * @param uniform defines the webGL uniform location where to store the value
  39139. * @param array defines the array of int32 to store
  39140. * @returns true if the value was set
  39141. */
  39142. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39143. /**
  39144. * Set the value of an uniform to an array of int32 (stored as vec2)
  39145. * @param uniform defines the webGL uniform location where to store the value
  39146. * @param array defines the array of int32 to store
  39147. * @returns true if the value was set
  39148. */
  39149. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39150. /**
  39151. * Set the value of an uniform to an array of int32 (stored as vec3)
  39152. * @param uniform defines the webGL uniform location where to store the value
  39153. * @param array defines the array of int32 to store
  39154. * @returns true if the value was set
  39155. */
  39156. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39157. /**
  39158. * Set the value of an uniform to an array of int32 (stored as vec4)
  39159. * @param uniform defines the webGL uniform location where to store the value
  39160. * @param array defines the array of int32 to store
  39161. * @returns true if the value was set
  39162. */
  39163. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39164. /**
  39165. * Set the value of an uniform to an array of number
  39166. * @param uniform defines the webGL uniform location where to store the value
  39167. * @param array defines the array of number to store
  39168. * @returns true if the value was set
  39169. */
  39170. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39171. /**
  39172. * Set the value of an uniform to an array of number (stored as vec2)
  39173. * @param uniform defines the webGL uniform location where to store the value
  39174. * @param array defines the array of number to store
  39175. * @returns true if the value was set
  39176. */
  39177. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39178. /**
  39179. * Set the value of an uniform to an array of number (stored as vec3)
  39180. * @param uniform defines the webGL uniform location where to store the value
  39181. * @param array defines the array of number to store
  39182. * @returns true if the value was set
  39183. */
  39184. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39185. /**
  39186. * Set the value of an uniform to an array of number (stored as vec4)
  39187. * @param uniform defines the webGL uniform location where to store the value
  39188. * @param array defines the array of number to store
  39189. * @returns true if the value was set
  39190. */
  39191. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39192. /**
  39193. * Set the value of an uniform to an array of float32 (stored as matrices)
  39194. * @param uniform defines the webGL uniform location where to store the value
  39195. * @param matrices defines the array of float32 to store
  39196. * @returns true if the value was set
  39197. */
  39198. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39199. /**
  39200. * Set the value of an uniform to a matrix (3x3)
  39201. * @param uniform defines the webGL uniform location where to store the value
  39202. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39203. * @returns true if the value was set
  39204. */
  39205. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39206. /**
  39207. * Set the value of an uniform to a matrix (2x2)
  39208. * @param uniform defines the webGL uniform location where to store the value
  39209. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39210. * @returns true if the value was set
  39211. */
  39212. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39213. /**
  39214. * Set the value of an uniform to a number (float)
  39215. * @param uniform defines the webGL uniform location where to store the value
  39216. * @param value defines the float number to store
  39217. * @returns true if the value was transfered
  39218. */
  39219. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39220. /**
  39221. * Set the value of an uniform to a vec2
  39222. * @param uniform defines the webGL uniform location where to store the value
  39223. * @param x defines the 1st component of the value
  39224. * @param y defines the 2nd component of the value
  39225. * @returns true if the value was set
  39226. */
  39227. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39228. /**
  39229. * Set the value of an uniform to a vec3
  39230. * @param uniform defines the webGL uniform location where to store the value
  39231. * @param x defines the 1st component of the value
  39232. * @param y defines the 2nd component of the value
  39233. * @param z defines the 3rd component of the value
  39234. * @returns true if the value was set
  39235. */
  39236. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39237. /**
  39238. * Set the value of an uniform to a vec4
  39239. * @param uniform defines the webGL uniform location where to store the value
  39240. * @param x defines the 1st component of the value
  39241. * @param y defines the 2nd component of the value
  39242. * @param z defines the 3rd component of the value
  39243. * @param w defines the 4th component of the value
  39244. * @returns true if the value was set
  39245. */
  39246. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39247. /**
  39248. * Apply all cached states (depth, culling, stencil and alpha)
  39249. */
  39250. applyStates(): void;
  39251. /**
  39252. * Enable or disable color writing
  39253. * @param enable defines the state to set
  39254. */
  39255. setColorWrite(enable: boolean): void;
  39256. /**
  39257. * Gets a boolean indicating if color writing is enabled
  39258. * @returns the current color writing state
  39259. */
  39260. getColorWrite(): boolean;
  39261. /**
  39262. * Gets the depth culling state manager
  39263. */
  39264. get depthCullingState(): DepthCullingState;
  39265. /**
  39266. * Gets the alpha state manager
  39267. */
  39268. get alphaState(): AlphaState;
  39269. /**
  39270. * Gets the stencil state manager
  39271. */
  39272. get stencilState(): StencilState;
  39273. /**
  39274. * Clears the list of texture accessible through engine.
  39275. * This can help preventing texture load conflict due to name collision.
  39276. */
  39277. clearInternalTexturesCache(): void;
  39278. /**
  39279. * Force the entire cache to be cleared
  39280. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39281. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39282. */
  39283. wipeCaches(bruteForce?: boolean): void;
  39284. /** @hidden */
  39285. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39286. min: number;
  39287. mag: number;
  39288. };
  39289. /** @hidden */
  39290. _createTexture(): WebGLTexture;
  39291. /**
  39292. * Usually called from Texture.ts.
  39293. * Passed information to create a WebGLTexture
  39294. * @param url defines a value which contains one of the following:
  39295. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39296. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39297. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39298. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39299. * @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)
  39300. * @param scene needed for loading to the correct scene
  39301. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39302. * @param onLoad optional callback to be called upon successful completion
  39303. * @param onError optional callback to be called upon failure
  39304. * @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
  39305. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39306. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39307. * @param forcedExtension defines the extension to use to pick the right loader
  39308. * @param mimeType defines an optional mime type
  39309. * @param loaderOptions options to be passed to the loader
  39310. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39311. */
  39312. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  39313. /**
  39314. * Loads an image as an HTMLImageElement.
  39315. * @param input url string, ArrayBuffer, or Blob to load
  39316. * @param onLoad callback called when the image successfully loads
  39317. * @param onError callback called when the image fails to load
  39318. * @param offlineProvider offline provider for caching
  39319. * @param mimeType optional mime type
  39320. * @returns the HTMLImageElement of the loaded image
  39321. * @hidden
  39322. */
  39323. 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>;
  39324. /**
  39325. * @hidden
  39326. */
  39327. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39328. private _unpackFlipYCached;
  39329. /**
  39330. * In case you are sharing the context with other applications, it might
  39331. * be interested to not cache the unpack flip y state to ensure a consistent
  39332. * value would be set.
  39333. */
  39334. enableUnpackFlipYCached: boolean;
  39335. /** @hidden */
  39336. _unpackFlipY(value: boolean): void;
  39337. /** @hidden */
  39338. _getUnpackAlignement(): number;
  39339. private _getTextureTarget;
  39340. /**
  39341. * Update the sampling mode of a given texture
  39342. * @param samplingMode defines the required sampling mode
  39343. * @param texture defines the texture to update
  39344. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39345. */
  39346. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39347. /**
  39348. * Update the sampling mode of a given texture
  39349. * @param texture defines the texture to update
  39350. * @param wrapU defines the texture wrap mode of the u coordinates
  39351. * @param wrapV defines the texture wrap mode of the v coordinates
  39352. * @param wrapR defines the texture wrap mode of the r coordinates
  39353. */
  39354. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39355. /** @hidden */
  39356. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39357. width: number;
  39358. height: number;
  39359. layers?: number;
  39360. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39361. /** @hidden */
  39362. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39363. /** @hidden */
  39364. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39365. /**
  39366. * Update a portion of an internal texture
  39367. * @param texture defines the texture to update
  39368. * @param imageData defines the data to store into the texture
  39369. * @param xOffset defines the x coordinates of the update rectangle
  39370. * @param yOffset defines the y coordinates of the update rectangle
  39371. * @param width defines the width of the update rectangle
  39372. * @param height defines the height of the update rectangle
  39373. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39374. * @param lod defines the lod level to update (0 by default)
  39375. */
  39376. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39377. /** @hidden */
  39378. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39379. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39380. private _prepareWebGLTexture;
  39381. /** @hidden */
  39382. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39383. private _getDepthStencilBuffer;
  39384. /** @hidden */
  39385. _releaseFramebufferObjects(texture: InternalTexture): void;
  39386. /** @hidden */
  39387. _releaseTexture(texture: InternalTexture): void;
  39388. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39389. protected _setProgram(program: WebGLProgram): void;
  39390. protected _boundUniforms: {
  39391. [key: number]: WebGLUniformLocation;
  39392. };
  39393. /**
  39394. * Binds an effect to the webGL context
  39395. * @param effect defines the effect to bind
  39396. */
  39397. bindSamplers(effect: Effect): void;
  39398. private _activateCurrentTexture;
  39399. /** @hidden */
  39400. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39401. /** @hidden */
  39402. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39403. /**
  39404. * Unbind all textures from the webGL context
  39405. */
  39406. unbindAllTextures(): void;
  39407. /**
  39408. * Sets a texture to the according uniform.
  39409. * @param channel The texture channel
  39410. * @param uniform The uniform to set
  39411. * @param texture The texture to apply
  39412. */
  39413. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39414. private _bindSamplerUniformToChannel;
  39415. private _getTextureWrapMode;
  39416. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39417. /**
  39418. * Sets an array of texture to the webGL context
  39419. * @param channel defines the channel where the texture array must be set
  39420. * @param uniform defines the associated uniform location
  39421. * @param textures defines the array of textures to bind
  39422. */
  39423. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39424. /** @hidden */
  39425. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39426. private _setTextureParameterFloat;
  39427. private _setTextureParameterInteger;
  39428. /**
  39429. * Unbind all vertex attributes from the webGL context
  39430. */
  39431. unbindAllAttributes(): void;
  39432. /**
  39433. * 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
  39434. */
  39435. releaseEffects(): void;
  39436. /**
  39437. * Dispose and release all associated resources
  39438. */
  39439. dispose(): void;
  39440. /**
  39441. * Attach a new callback raised when context lost event is fired
  39442. * @param callback defines the callback to call
  39443. */
  39444. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39445. /**
  39446. * Attach a new callback raised when context restored event is fired
  39447. * @param callback defines the callback to call
  39448. */
  39449. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39450. /**
  39451. * Get the current error code of the webGL context
  39452. * @returns the error code
  39453. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39454. */
  39455. getError(): number;
  39456. private _canRenderToFloatFramebuffer;
  39457. private _canRenderToHalfFloatFramebuffer;
  39458. private _canRenderToFramebuffer;
  39459. /** @hidden */
  39460. _getWebGLTextureType(type: number): number;
  39461. /** @hidden */
  39462. _getInternalFormat(format: number): number;
  39463. /** @hidden */
  39464. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39465. /** @hidden */
  39466. _getRGBAMultiSampleBufferFormat(type: number): number;
  39467. /** @hidden */
  39468. _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;
  39469. /**
  39470. * Loads a file from a url
  39471. * @param url url to load
  39472. * @param onSuccess callback called when the file successfully loads
  39473. * @param onProgress callback called while file is loading (if the server supports this mode)
  39474. * @param offlineProvider defines the offline provider for caching
  39475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39476. * @param onError callback called when the file fails to load
  39477. * @returns a file request object
  39478. * @hidden
  39479. */
  39480. 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;
  39481. /**
  39482. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39483. * @param x defines the x coordinate of the rectangle where pixels must be read
  39484. * @param y defines the y coordinate of the rectangle where pixels must be read
  39485. * @param width defines the width of the rectangle where pixels must be read
  39486. * @param height defines the height of the rectangle where pixels must be read
  39487. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39488. * @returns a Uint8Array containing RGBA colors
  39489. */
  39490. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39491. private static _IsSupported;
  39492. private static _HasMajorPerformanceCaveat;
  39493. /**
  39494. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39495. */
  39496. static get IsSupported(): boolean;
  39497. /**
  39498. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39499. * @returns true if the engine can be created
  39500. * @ignorenaming
  39501. */
  39502. static isSupported(): boolean;
  39503. /**
  39504. * 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)
  39505. */
  39506. static get HasMajorPerformanceCaveat(): boolean;
  39507. /**
  39508. * Find the next highest power of two.
  39509. * @param x Number to start search from.
  39510. * @return Next highest power of two.
  39511. */
  39512. static CeilingPOT(x: number): number;
  39513. /**
  39514. * Find the next lowest power of two.
  39515. * @param x Number to start search from.
  39516. * @return Next lowest power of two.
  39517. */
  39518. static FloorPOT(x: number): number;
  39519. /**
  39520. * Find the nearest power of two.
  39521. * @param x Number to start search from.
  39522. * @return Next nearest power of two.
  39523. */
  39524. static NearestPOT(x: number): number;
  39525. /**
  39526. * Get the closest exponent of two
  39527. * @param value defines the value to approximate
  39528. * @param max defines the maximum value to return
  39529. * @param mode defines how to define the closest value
  39530. * @returns closest exponent of two of the given value
  39531. */
  39532. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39533. /**
  39534. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39535. * @param func - the function to be called
  39536. * @param requester - the object that will request the next frame. Falls back to window.
  39537. * @returns frame number
  39538. */
  39539. static QueueNewFrame(func: () => void, requester?: any): number;
  39540. /**
  39541. * Gets host document
  39542. * @returns the host document object
  39543. */
  39544. getHostDocument(): Nullable<Document>;
  39545. }
  39546. }
  39547. declare module BABYLON {
  39548. /**
  39549. * Defines the source of the internal texture
  39550. */
  39551. export enum InternalTextureSource {
  39552. /**
  39553. * The source of the texture data is unknown
  39554. */
  39555. Unknown = 0,
  39556. /**
  39557. * Texture data comes from an URL
  39558. */
  39559. Url = 1,
  39560. /**
  39561. * Texture data is only used for temporary storage
  39562. */
  39563. Temp = 2,
  39564. /**
  39565. * Texture data comes from raw data (ArrayBuffer)
  39566. */
  39567. Raw = 3,
  39568. /**
  39569. * Texture content is dynamic (video or dynamic texture)
  39570. */
  39571. Dynamic = 4,
  39572. /**
  39573. * Texture content is generated by rendering to it
  39574. */
  39575. RenderTarget = 5,
  39576. /**
  39577. * Texture content is part of a multi render target process
  39578. */
  39579. MultiRenderTarget = 6,
  39580. /**
  39581. * Texture data comes from a cube data file
  39582. */
  39583. Cube = 7,
  39584. /**
  39585. * Texture data comes from a raw cube data
  39586. */
  39587. CubeRaw = 8,
  39588. /**
  39589. * Texture data come from a prefiltered cube data file
  39590. */
  39591. CubePrefiltered = 9,
  39592. /**
  39593. * Texture content is raw 3D data
  39594. */
  39595. Raw3D = 10,
  39596. /**
  39597. * Texture content is raw 2D array data
  39598. */
  39599. Raw2DArray = 11,
  39600. /**
  39601. * Texture content is a depth texture
  39602. */
  39603. Depth = 12,
  39604. /**
  39605. * Texture data comes from a raw cube data encoded with RGBD
  39606. */
  39607. CubeRawRGBD = 13
  39608. }
  39609. /**
  39610. * Class used to store data associated with WebGL texture data for the engine
  39611. * This class should not be used directly
  39612. */
  39613. export class InternalTexture {
  39614. /** @hidden */
  39615. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39616. /**
  39617. * Defines if the texture is ready
  39618. */
  39619. isReady: boolean;
  39620. /**
  39621. * Defines if the texture is a cube texture
  39622. */
  39623. isCube: boolean;
  39624. /**
  39625. * Defines if the texture contains 3D data
  39626. */
  39627. is3D: boolean;
  39628. /**
  39629. * Defines if the texture contains 2D array data
  39630. */
  39631. is2DArray: boolean;
  39632. /**
  39633. * Defines if the texture contains multiview data
  39634. */
  39635. isMultiview: boolean;
  39636. /**
  39637. * Gets the URL used to load this texture
  39638. */
  39639. url: string;
  39640. /**
  39641. * Gets the sampling mode of the texture
  39642. */
  39643. samplingMode: number;
  39644. /**
  39645. * Gets a boolean indicating if the texture needs mipmaps generation
  39646. */
  39647. generateMipMaps: boolean;
  39648. /**
  39649. * Gets the number of samples used by the texture (WebGL2+ only)
  39650. */
  39651. samples: number;
  39652. /**
  39653. * Gets the type of the texture (int, float...)
  39654. */
  39655. type: number;
  39656. /**
  39657. * Gets the format of the texture (RGB, RGBA...)
  39658. */
  39659. format: number;
  39660. /**
  39661. * Observable called when the texture is loaded
  39662. */
  39663. onLoadedObservable: Observable<InternalTexture>;
  39664. /**
  39665. * Gets the width of the texture
  39666. */
  39667. width: number;
  39668. /**
  39669. * Gets the height of the texture
  39670. */
  39671. height: number;
  39672. /**
  39673. * Gets the depth of the texture
  39674. */
  39675. depth: number;
  39676. /**
  39677. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39678. */
  39679. baseWidth: number;
  39680. /**
  39681. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39682. */
  39683. baseHeight: number;
  39684. /**
  39685. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39686. */
  39687. baseDepth: number;
  39688. /**
  39689. * Gets a boolean indicating if the texture is inverted on Y axis
  39690. */
  39691. invertY: boolean;
  39692. /** @hidden */
  39693. _invertVScale: boolean;
  39694. /** @hidden */
  39695. _associatedChannel: number;
  39696. /** @hidden */
  39697. _source: InternalTextureSource;
  39698. /** @hidden */
  39699. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39700. /** @hidden */
  39701. _bufferView: Nullable<ArrayBufferView>;
  39702. /** @hidden */
  39703. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39704. /** @hidden */
  39705. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39706. /** @hidden */
  39707. _size: number;
  39708. /** @hidden */
  39709. _extension: string;
  39710. /** @hidden */
  39711. _files: Nullable<string[]>;
  39712. /** @hidden */
  39713. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39714. /** @hidden */
  39715. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39716. /** @hidden */
  39717. _framebuffer: Nullable<WebGLFramebuffer>;
  39718. /** @hidden */
  39719. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  39720. /** @hidden */
  39721. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  39722. /** @hidden */
  39723. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  39724. /** @hidden */
  39725. _attachments: Nullable<number[]>;
  39726. /** @hidden */
  39727. _textureArray: Nullable<InternalTexture[]>;
  39728. /** @hidden */
  39729. _cachedCoordinatesMode: Nullable<number>;
  39730. /** @hidden */
  39731. _cachedWrapU: Nullable<number>;
  39732. /** @hidden */
  39733. _cachedWrapV: Nullable<number>;
  39734. /** @hidden */
  39735. _cachedWrapR: Nullable<number>;
  39736. /** @hidden */
  39737. _cachedAnisotropicFilteringLevel: Nullable<number>;
  39738. /** @hidden */
  39739. _isDisabled: boolean;
  39740. /** @hidden */
  39741. _compression: Nullable<string>;
  39742. /** @hidden */
  39743. _generateStencilBuffer: boolean;
  39744. /** @hidden */
  39745. _generateDepthBuffer: boolean;
  39746. /** @hidden */
  39747. _comparisonFunction: number;
  39748. /** @hidden */
  39749. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  39750. /** @hidden */
  39751. _lodGenerationScale: number;
  39752. /** @hidden */
  39753. _lodGenerationOffset: number;
  39754. /** @hidden */
  39755. _depthStencilTexture: Nullable<InternalTexture>;
  39756. /** @hidden */
  39757. _colorTextureArray: Nullable<WebGLTexture>;
  39758. /** @hidden */
  39759. _depthStencilTextureArray: Nullable<WebGLTexture>;
  39760. /** @hidden */
  39761. _lodTextureHigh: Nullable<BaseTexture>;
  39762. /** @hidden */
  39763. _lodTextureMid: Nullable<BaseTexture>;
  39764. /** @hidden */
  39765. _lodTextureLow: Nullable<BaseTexture>;
  39766. /** @hidden */
  39767. _isRGBD: boolean;
  39768. /** @hidden */
  39769. _linearSpecularLOD: boolean;
  39770. /** @hidden */
  39771. _irradianceTexture: Nullable<BaseTexture>;
  39772. /** @hidden */
  39773. _webGLTexture: Nullable<WebGLTexture>;
  39774. /** @hidden */
  39775. _references: number;
  39776. /** @hidden */
  39777. _gammaSpace: Nullable<boolean>;
  39778. private _engine;
  39779. /**
  39780. * Gets the Engine the texture belongs to.
  39781. * @returns The babylon engine
  39782. */
  39783. getEngine(): ThinEngine;
  39784. /**
  39785. * Gets the data source type of the texture
  39786. */
  39787. get source(): InternalTextureSource;
  39788. /**
  39789. * Creates a new InternalTexture
  39790. * @param engine defines the engine to use
  39791. * @param source defines the type of data that will be used
  39792. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39793. */
  39794. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  39795. /**
  39796. * Increments the number of references (ie. the number of Texture that point to it)
  39797. */
  39798. incrementReferences(): void;
  39799. /**
  39800. * Change the size of the texture (not the size of the content)
  39801. * @param width defines the new width
  39802. * @param height defines the new height
  39803. * @param depth defines the new depth (1 by default)
  39804. */
  39805. updateSize(width: int, height: int, depth?: int): void;
  39806. /** @hidden */
  39807. _rebuild(): void;
  39808. /** @hidden */
  39809. _swapAndDie(target: InternalTexture): void;
  39810. /**
  39811. * Dispose the current allocated resources
  39812. */
  39813. dispose(): void;
  39814. }
  39815. }
  39816. declare module BABYLON {
  39817. /**
  39818. * Class used to work with sound analyzer using fast fourier transform (FFT)
  39819. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39820. */
  39821. export class Analyser {
  39822. /**
  39823. * Gets or sets the smoothing
  39824. * @ignorenaming
  39825. */
  39826. SMOOTHING: number;
  39827. /**
  39828. * Gets or sets the FFT table size
  39829. * @ignorenaming
  39830. */
  39831. FFT_SIZE: number;
  39832. /**
  39833. * Gets or sets the bar graph amplitude
  39834. * @ignorenaming
  39835. */
  39836. BARGRAPHAMPLITUDE: number;
  39837. /**
  39838. * Gets or sets the position of the debug canvas
  39839. * @ignorenaming
  39840. */
  39841. DEBUGCANVASPOS: {
  39842. x: number;
  39843. y: number;
  39844. };
  39845. /**
  39846. * Gets or sets the debug canvas size
  39847. * @ignorenaming
  39848. */
  39849. DEBUGCANVASSIZE: {
  39850. width: number;
  39851. height: number;
  39852. };
  39853. private _byteFreqs;
  39854. private _byteTime;
  39855. private _floatFreqs;
  39856. private _webAudioAnalyser;
  39857. private _debugCanvas;
  39858. private _debugCanvasContext;
  39859. private _scene;
  39860. private _registerFunc;
  39861. private _audioEngine;
  39862. /**
  39863. * Creates a new analyser
  39864. * @param scene defines hosting scene
  39865. */
  39866. constructor(scene: Scene);
  39867. /**
  39868. * Get the number of data values you will have to play with for the visualization
  39869. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  39870. * @returns a number
  39871. */
  39872. getFrequencyBinCount(): number;
  39873. /**
  39874. * Gets the current frequency data as a byte array
  39875. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39876. * @returns a Uint8Array
  39877. */
  39878. getByteFrequencyData(): Uint8Array;
  39879. /**
  39880. * Gets the current waveform as a byte array
  39881. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  39882. * @returns a Uint8Array
  39883. */
  39884. getByteTimeDomainData(): Uint8Array;
  39885. /**
  39886. * Gets the current frequency data as a float array
  39887. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39888. * @returns a Float32Array
  39889. */
  39890. getFloatFrequencyData(): Float32Array;
  39891. /**
  39892. * Renders the debug canvas
  39893. */
  39894. drawDebugCanvas(): void;
  39895. /**
  39896. * Stops rendering the debug canvas and removes it
  39897. */
  39898. stopDebugCanvas(): void;
  39899. /**
  39900. * Connects two audio nodes
  39901. * @param inputAudioNode defines first node to connect
  39902. * @param outputAudioNode defines second node to connect
  39903. */
  39904. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  39905. /**
  39906. * Releases all associated resources
  39907. */
  39908. dispose(): void;
  39909. }
  39910. }
  39911. declare module BABYLON {
  39912. /**
  39913. * This represents an audio engine and it is responsible
  39914. * to play, synchronize and analyse sounds throughout the application.
  39915. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39916. */
  39917. export interface IAudioEngine extends IDisposable {
  39918. /**
  39919. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39920. */
  39921. readonly canUseWebAudio: boolean;
  39922. /**
  39923. * Gets the current AudioContext if available.
  39924. */
  39925. readonly audioContext: Nullable<AudioContext>;
  39926. /**
  39927. * The master gain node defines the global audio volume of your audio engine.
  39928. */
  39929. readonly masterGain: GainNode;
  39930. /**
  39931. * Gets whether or not mp3 are supported by your browser.
  39932. */
  39933. readonly isMP3supported: boolean;
  39934. /**
  39935. * Gets whether or not ogg are supported by your browser.
  39936. */
  39937. readonly isOGGsupported: boolean;
  39938. /**
  39939. * Defines if Babylon should emit a warning if WebAudio is not supported.
  39940. * @ignoreNaming
  39941. */
  39942. WarnedWebAudioUnsupported: boolean;
  39943. /**
  39944. * Defines if the audio engine relies on a custom unlocked button.
  39945. * In this case, the embedded button will not be displayed.
  39946. */
  39947. useCustomUnlockedButton: boolean;
  39948. /**
  39949. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  39950. */
  39951. readonly unlocked: boolean;
  39952. /**
  39953. * Event raised when audio has been unlocked on the browser.
  39954. */
  39955. onAudioUnlockedObservable: Observable<AudioEngine>;
  39956. /**
  39957. * Event raised when audio has been locked on the browser.
  39958. */
  39959. onAudioLockedObservable: Observable<AudioEngine>;
  39960. /**
  39961. * Flags the audio engine in Locked state.
  39962. * This happens due to new browser policies preventing audio to autoplay.
  39963. */
  39964. lock(): void;
  39965. /**
  39966. * Unlocks the audio engine once a user action has been done on the dom.
  39967. * This is helpful to resume play once browser policies have been satisfied.
  39968. */
  39969. unlock(): void;
  39970. /**
  39971. * Gets the global volume sets on the master gain.
  39972. * @returns the global volume if set or -1 otherwise
  39973. */
  39974. getGlobalVolume(): number;
  39975. /**
  39976. * Sets the global volume of your experience (sets on the master gain).
  39977. * @param newVolume Defines the new global volume of the application
  39978. */
  39979. setGlobalVolume(newVolume: number): void;
  39980. /**
  39981. * Connect the audio engine to an audio analyser allowing some amazing
  39982. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39983. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39984. * @param analyser The analyser to connect to the engine
  39985. */
  39986. connectToAnalyser(analyser: Analyser): void;
  39987. }
  39988. /**
  39989. * This represents the default audio engine used in babylon.
  39990. * It is responsible to play, synchronize and analyse sounds throughout the application.
  39991. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39992. */
  39993. export class AudioEngine implements IAudioEngine {
  39994. private _audioContext;
  39995. private _audioContextInitialized;
  39996. private _muteButton;
  39997. private _hostElement;
  39998. /**
  39999. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40000. */
  40001. canUseWebAudio: boolean;
  40002. /**
  40003. * The master gain node defines the global audio volume of your audio engine.
  40004. */
  40005. masterGain: GainNode;
  40006. /**
  40007. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40008. * @ignoreNaming
  40009. */
  40010. WarnedWebAudioUnsupported: boolean;
  40011. /**
  40012. * Gets whether or not mp3 are supported by your browser.
  40013. */
  40014. isMP3supported: boolean;
  40015. /**
  40016. * Gets whether or not ogg are supported by your browser.
  40017. */
  40018. isOGGsupported: boolean;
  40019. /**
  40020. * Gets whether audio has been unlocked on the device.
  40021. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  40022. * a user interaction has happened.
  40023. */
  40024. unlocked: boolean;
  40025. /**
  40026. * Defines if the audio engine relies on a custom unlocked button.
  40027. * In this case, the embedded button will not be displayed.
  40028. */
  40029. useCustomUnlockedButton: boolean;
  40030. /**
  40031. * Event raised when audio has been unlocked on the browser.
  40032. */
  40033. onAudioUnlockedObservable: Observable<AudioEngine>;
  40034. /**
  40035. * Event raised when audio has been locked on the browser.
  40036. */
  40037. onAudioLockedObservable: Observable<AudioEngine>;
  40038. /**
  40039. * Gets the current AudioContext if available.
  40040. */
  40041. get audioContext(): Nullable<AudioContext>;
  40042. private _connectedAnalyser;
  40043. /**
  40044. * Instantiates a new audio engine.
  40045. *
  40046. * There should be only one per page as some browsers restrict the number
  40047. * of audio contexts you can create.
  40048. * @param hostElement defines the host element where to display the mute icon if necessary
  40049. */
  40050. constructor(hostElement?: Nullable<HTMLElement>);
  40051. /**
  40052. * Flags the audio engine in Locked state.
  40053. * This happens due to new browser policies preventing audio to autoplay.
  40054. */
  40055. lock(): void;
  40056. /**
  40057. * Unlocks the audio engine once a user action has been done on the dom.
  40058. * This is helpful to resume play once browser policies have been satisfied.
  40059. */
  40060. unlock(): void;
  40061. private _resumeAudioContext;
  40062. private _initializeAudioContext;
  40063. private _tryToRun;
  40064. private _triggerRunningState;
  40065. private _triggerSuspendedState;
  40066. private _displayMuteButton;
  40067. private _moveButtonToTopLeft;
  40068. private _onResize;
  40069. private _hideMuteButton;
  40070. /**
  40071. * Destroy and release the resources associated with the audio ccontext.
  40072. */
  40073. dispose(): void;
  40074. /**
  40075. * Gets the global volume sets on the master gain.
  40076. * @returns the global volume if set or -1 otherwise
  40077. */
  40078. getGlobalVolume(): number;
  40079. /**
  40080. * Sets the global volume of your experience (sets on the master gain).
  40081. * @param newVolume Defines the new global volume of the application
  40082. */
  40083. setGlobalVolume(newVolume: number): void;
  40084. /**
  40085. * Connect the audio engine to an audio analyser allowing some amazing
  40086. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40087. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40088. * @param analyser The analyser to connect to the engine
  40089. */
  40090. connectToAnalyser(analyser: Analyser): void;
  40091. }
  40092. }
  40093. declare module BABYLON {
  40094. /**
  40095. * Interface used to present a loading screen while loading a scene
  40096. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40097. */
  40098. export interface ILoadingScreen {
  40099. /**
  40100. * Function called to display the loading screen
  40101. */
  40102. displayLoadingUI: () => void;
  40103. /**
  40104. * Function called to hide the loading screen
  40105. */
  40106. hideLoadingUI: () => void;
  40107. /**
  40108. * Gets or sets the color to use for the background
  40109. */
  40110. loadingUIBackgroundColor: string;
  40111. /**
  40112. * Gets or sets the text to display while loading
  40113. */
  40114. loadingUIText: string;
  40115. }
  40116. /**
  40117. * Class used for the default loading screen
  40118. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40119. */
  40120. export class DefaultLoadingScreen implements ILoadingScreen {
  40121. private _renderingCanvas;
  40122. private _loadingText;
  40123. private _loadingDivBackgroundColor;
  40124. private _loadingDiv;
  40125. private _loadingTextDiv;
  40126. /** Gets or sets the logo url to use for the default loading screen */
  40127. static DefaultLogoUrl: string;
  40128. /** Gets or sets the spinner url to use for the default loading screen */
  40129. static DefaultSpinnerUrl: string;
  40130. /**
  40131. * Creates a new default loading screen
  40132. * @param _renderingCanvas defines the canvas used to render the scene
  40133. * @param _loadingText defines the default text to display
  40134. * @param _loadingDivBackgroundColor defines the default background color
  40135. */
  40136. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40137. /**
  40138. * Function called to display the loading screen
  40139. */
  40140. displayLoadingUI(): void;
  40141. /**
  40142. * Function called to hide the loading screen
  40143. */
  40144. hideLoadingUI(): void;
  40145. /**
  40146. * Gets or sets the text to display while loading
  40147. */
  40148. set loadingUIText(text: string);
  40149. get loadingUIText(): string;
  40150. /**
  40151. * Gets or sets the color to use for the background
  40152. */
  40153. get loadingUIBackgroundColor(): string;
  40154. set loadingUIBackgroundColor(color: string);
  40155. private _resizeLoadingUI;
  40156. }
  40157. }
  40158. declare module BABYLON {
  40159. /**
  40160. * Interface for any object that can request an animation frame
  40161. */
  40162. export interface ICustomAnimationFrameRequester {
  40163. /**
  40164. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40165. */
  40166. renderFunction?: Function;
  40167. /**
  40168. * Called to request the next frame to render to
  40169. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40170. */
  40171. requestAnimationFrame: Function;
  40172. /**
  40173. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40174. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40175. */
  40176. requestID?: number;
  40177. }
  40178. }
  40179. declare module BABYLON {
  40180. /**
  40181. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40182. */
  40183. export class PerformanceMonitor {
  40184. private _enabled;
  40185. private _rollingFrameTime;
  40186. private _lastFrameTimeMs;
  40187. /**
  40188. * constructor
  40189. * @param frameSampleSize The number of samples required to saturate the sliding window
  40190. */
  40191. constructor(frameSampleSize?: number);
  40192. /**
  40193. * Samples current frame
  40194. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40195. */
  40196. sampleFrame(timeMs?: number): void;
  40197. /**
  40198. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40199. */
  40200. get averageFrameTime(): number;
  40201. /**
  40202. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40203. */
  40204. get averageFrameTimeVariance(): number;
  40205. /**
  40206. * Returns the frame time of the most recent frame
  40207. */
  40208. get instantaneousFrameTime(): number;
  40209. /**
  40210. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40211. */
  40212. get averageFPS(): number;
  40213. /**
  40214. * Returns the average framerate in frames per second using the most recent frame time
  40215. */
  40216. get instantaneousFPS(): number;
  40217. /**
  40218. * Returns true if enough samples have been taken to completely fill the sliding window
  40219. */
  40220. get isSaturated(): boolean;
  40221. /**
  40222. * Enables contributions to the sliding window sample set
  40223. */
  40224. enable(): void;
  40225. /**
  40226. * Disables contributions to the sliding window sample set
  40227. * Samples will not be interpolated over the disabled period
  40228. */
  40229. disable(): void;
  40230. /**
  40231. * Returns true if sampling is enabled
  40232. */
  40233. get isEnabled(): boolean;
  40234. /**
  40235. * Resets performance monitor
  40236. */
  40237. reset(): void;
  40238. }
  40239. /**
  40240. * RollingAverage
  40241. *
  40242. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40243. */
  40244. export class RollingAverage {
  40245. /**
  40246. * Current average
  40247. */
  40248. average: number;
  40249. /**
  40250. * Current variance
  40251. */
  40252. variance: number;
  40253. protected _samples: Array<number>;
  40254. protected _sampleCount: number;
  40255. protected _pos: number;
  40256. protected _m2: number;
  40257. /**
  40258. * constructor
  40259. * @param length The number of samples required to saturate the sliding window
  40260. */
  40261. constructor(length: number);
  40262. /**
  40263. * Adds a sample to the sample set
  40264. * @param v The sample value
  40265. */
  40266. add(v: number): void;
  40267. /**
  40268. * Returns previously added values or null if outside of history or outside the sliding window domain
  40269. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40270. * @return Value previously recorded with add() or null if outside of range
  40271. */
  40272. history(i: number): number;
  40273. /**
  40274. * Returns true if enough samples have been taken to completely fill the sliding window
  40275. * @return true if sample-set saturated
  40276. */
  40277. isSaturated(): boolean;
  40278. /**
  40279. * Resets the rolling average (equivalent to 0 samples taken so far)
  40280. */
  40281. reset(): void;
  40282. /**
  40283. * Wraps a value around the sample range boundaries
  40284. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40285. * @return Wrapped position in sample range
  40286. */
  40287. protected _wrapPosition(i: number): number;
  40288. }
  40289. }
  40290. declare module BABYLON {
  40291. /**
  40292. * This class is used to track a performance counter which is number based.
  40293. * The user has access to many properties which give statistics of different nature.
  40294. *
  40295. * The implementer can track two kinds of Performance Counter: time and count.
  40296. * 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.
  40297. * 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.
  40298. */
  40299. export class PerfCounter {
  40300. /**
  40301. * Gets or sets a global boolean to turn on and off all the counters
  40302. */
  40303. static Enabled: boolean;
  40304. /**
  40305. * Returns the smallest value ever
  40306. */
  40307. get min(): number;
  40308. /**
  40309. * Returns the biggest value ever
  40310. */
  40311. get max(): number;
  40312. /**
  40313. * Returns the average value since the performance counter is running
  40314. */
  40315. get average(): number;
  40316. /**
  40317. * Returns the average value of the last second the counter was monitored
  40318. */
  40319. get lastSecAverage(): number;
  40320. /**
  40321. * Returns the current value
  40322. */
  40323. get current(): number;
  40324. /**
  40325. * Gets the accumulated total
  40326. */
  40327. get total(): number;
  40328. /**
  40329. * Gets the total value count
  40330. */
  40331. get count(): number;
  40332. /**
  40333. * Creates a new counter
  40334. */
  40335. constructor();
  40336. /**
  40337. * Call this method to start monitoring a new frame.
  40338. * 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.
  40339. */
  40340. fetchNewFrame(): void;
  40341. /**
  40342. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40343. * @param newCount the count value to add to the monitored count
  40344. * @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.
  40345. */
  40346. addCount(newCount: number, fetchResult: boolean): void;
  40347. /**
  40348. * Start monitoring this performance counter
  40349. */
  40350. beginMonitoring(): void;
  40351. /**
  40352. * Compute the time lapsed since the previous beginMonitoring() call.
  40353. * @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
  40354. */
  40355. endMonitoring(newFrame?: boolean): void;
  40356. private _fetchResult;
  40357. private _startMonitoringTime;
  40358. private _min;
  40359. private _max;
  40360. private _average;
  40361. private _current;
  40362. private _totalValueCount;
  40363. private _totalAccumulated;
  40364. private _lastSecAverage;
  40365. private _lastSecAccumulated;
  40366. private _lastSecTime;
  40367. private _lastSecValueCount;
  40368. }
  40369. }
  40370. declare module BABYLON {
  40371. interface ThinEngine {
  40372. /** @hidden */
  40373. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40374. }
  40375. }
  40376. declare module BABYLON {
  40377. /**
  40378. * Defines the interface used by display changed events
  40379. */
  40380. export interface IDisplayChangedEventArgs {
  40381. /** Gets the vrDisplay object (if any) */
  40382. vrDisplay: Nullable<any>;
  40383. /** Gets a boolean indicating if webVR is supported */
  40384. vrSupported: boolean;
  40385. }
  40386. /**
  40387. * Defines the interface used by objects containing a viewport (like a camera)
  40388. */
  40389. interface IViewportOwnerLike {
  40390. /**
  40391. * Gets or sets the viewport
  40392. */
  40393. viewport: IViewportLike;
  40394. }
  40395. /**
  40396. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40397. */
  40398. export class Engine extends ThinEngine {
  40399. /** Defines that alpha blending is disabled */
  40400. static readonly ALPHA_DISABLE: number;
  40401. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40402. static readonly ALPHA_ADD: number;
  40403. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40404. static readonly ALPHA_COMBINE: number;
  40405. /** Defines that alpha blending to DEST - SRC * DEST */
  40406. static readonly ALPHA_SUBTRACT: number;
  40407. /** Defines that alpha blending to SRC * DEST */
  40408. static readonly ALPHA_MULTIPLY: number;
  40409. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40410. static readonly ALPHA_MAXIMIZED: number;
  40411. /** Defines that alpha blending to SRC + DEST */
  40412. static readonly ALPHA_ONEONE: number;
  40413. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40414. static readonly ALPHA_PREMULTIPLIED: number;
  40415. /**
  40416. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40417. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40418. */
  40419. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40420. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40421. static readonly ALPHA_INTERPOLATE: number;
  40422. /**
  40423. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40424. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40425. */
  40426. static readonly ALPHA_SCREENMODE: number;
  40427. /** Defines that the ressource is not delayed*/
  40428. static readonly DELAYLOADSTATE_NONE: number;
  40429. /** Defines that the ressource was successfully delay loaded */
  40430. static readonly DELAYLOADSTATE_LOADED: number;
  40431. /** Defines that the ressource is currently delay loading */
  40432. static readonly DELAYLOADSTATE_LOADING: number;
  40433. /** Defines that the ressource is delayed and has not started loading */
  40434. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40435. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40436. static readonly NEVER: number;
  40437. /** 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 */
  40438. static readonly ALWAYS: number;
  40439. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40440. static readonly LESS: number;
  40441. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40442. static readonly EQUAL: number;
  40443. /** 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 */
  40444. static readonly LEQUAL: number;
  40445. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40446. static readonly GREATER: number;
  40447. /** 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 */
  40448. static readonly GEQUAL: number;
  40449. /** 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 */
  40450. static readonly NOTEQUAL: number;
  40451. /** Passed to stencilOperation to specify that stencil value must be kept */
  40452. static readonly KEEP: number;
  40453. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40454. static readonly REPLACE: number;
  40455. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40456. static readonly INCR: number;
  40457. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40458. static readonly DECR: number;
  40459. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40460. static readonly INVERT: number;
  40461. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40462. static readonly INCR_WRAP: number;
  40463. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40464. static readonly DECR_WRAP: number;
  40465. /** Texture is not repeating outside of 0..1 UVs */
  40466. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40467. /** Texture is repeating outside of 0..1 UVs */
  40468. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40469. /** Texture is repeating and mirrored */
  40470. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40471. /** ALPHA */
  40472. static readonly TEXTUREFORMAT_ALPHA: number;
  40473. /** LUMINANCE */
  40474. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40475. /** LUMINANCE_ALPHA */
  40476. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40477. /** RGB */
  40478. static readonly TEXTUREFORMAT_RGB: number;
  40479. /** RGBA */
  40480. static readonly TEXTUREFORMAT_RGBA: number;
  40481. /** RED */
  40482. static readonly TEXTUREFORMAT_RED: number;
  40483. /** RED (2nd reference) */
  40484. static readonly TEXTUREFORMAT_R: number;
  40485. /** RG */
  40486. static readonly TEXTUREFORMAT_RG: number;
  40487. /** RED_INTEGER */
  40488. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40489. /** RED_INTEGER (2nd reference) */
  40490. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40491. /** RG_INTEGER */
  40492. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40493. /** RGB_INTEGER */
  40494. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40495. /** RGBA_INTEGER */
  40496. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40497. /** UNSIGNED_BYTE */
  40498. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40499. /** UNSIGNED_BYTE (2nd reference) */
  40500. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40501. /** FLOAT */
  40502. static readonly TEXTURETYPE_FLOAT: number;
  40503. /** HALF_FLOAT */
  40504. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40505. /** BYTE */
  40506. static readonly TEXTURETYPE_BYTE: number;
  40507. /** SHORT */
  40508. static readonly TEXTURETYPE_SHORT: number;
  40509. /** UNSIGNED_SHORT */
  40510. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40511. /** INT */
  40512. static readonly TEXTURETYPE_INT: number;
  40513. /** UNSIGNED_INT */
  40514. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40515. /** UNSIGNED_SHORT_4_4_4_4 */
  40516. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40517. /** UNSIGNED_SHORT_5_5_5_1 */
  40518. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40519. /** UNSIGNED_SHORT_5_6_5 */
  40520. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40521. /** UNSIGNED_INT_2_10_10_10_REV */
  40522. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40523. /** UNSIGNED_INT_24_8 */
  40524. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40525. /** UNSIGNED_INT_10F_11F_11F_REV */
  40526. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40527. /** UNSIGNED_INT_5_9_9_9_REV */
  40528. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40529. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40530. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40531. /** nearest is mag = nearest and min = nearest and mip = linear */
  40532. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40533. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40534. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40535. /** Trilinear is mag = linear and min = linear and mip = linear */
  40536. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40537. /** nearest is mag = nearest and min = nearest and mip = linear */
  40538. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40539. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40540. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40541. /** Trilinear is mag = linear and min = linear and mip = linear */
  40542. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40543. /** mag = nearest and min = nearest and mip = nearest */
  40544. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40545. /** mag = nearest and min = linear and mip = nearest */
  40546. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40547. /** mag = nearest and min = linear and mip = linear */
  40548. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40549. /** mag = nearest and min = linear and mip = none */
  40550. static readonly TEXTURE_NEAREST_LINEAR: number;
  40551. /** mag = nearest and min = nearest and mip = none */
  40552. static readonly TEXTURE_NEAREST_NEAREST: number;
  40553. /** mag = linear and min = nearest and mip = nearest */
  40554. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40555. /** mag = linear and min = nearest and mip = linear */
  40556. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40557. /** mag = linear and min = linear and mip = none */
  40558. static readonly TEXTURE_LINEAR_LINEAR: number;
  40559. /** mag = linear and min = nearest and mip = none */
  40560. static readonly TEXTURE_LINEAR_NEAREST: number;
  40561. /** Explicit coordinates mode */
  40562. static readonly TEXTURE_EXPLICIT_MODE: number;
  40563. /** Spherical coordinates mode */
  40564. static readonly TEXTURE_SPHERICAL_MODE: number;
  40565. /** Planar coordinates mode */
  40566. static readonly TEXTURE_PLANAR_MODE: number;
  40567. /** Cubic coordinates mode */
  40568. static readonly TEXTURE_CUBIC_MODE: number;
  40569. /** Projection coordinates mode */
  40570. static readonly TEXTURE_PROJECTION_MODE: number;
  40571. /** Skybox coordinates mode */
  40572. static readonly TEXTURE_SKYBOX_MODE: number;
  40573. /** Inverse Cubic coordinates mode */
  40574. static readonly TEXTURE_INVCUBIC_MODE: number;
  40575. /** Equirectangular coordinates mode */
  40576. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40577. /** Equirectangular Fixed coordinates mode */
  40578. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40579. /** Equirectangular Fixed Mirrored coordinates mode */
  40580. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40581. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40582. static readonly SCALEMODE_FLOOR: number;
  40583. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40584. static readonly SCALEMODE_NEAREST: number;
  40585. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40586. static readonly SCALEMODE_CEILING: number;
  40587. /**
  40588. * Returns the current npm package of the sdk
  40589. */
  40590. static get NpmPackage(): string;
  40591. /**
  40592. * Returns the current version of the framework
  40593. */
  40594. static get Version(): string;
  40595. /** Gets the list of created engines */
  40596. static get Instances(): Engine[];
  40597. /**
  40598. * Gets the latest created engine
  40599. */
  40600. static get LastCreatedEngine(): Nullable<Engine>;
  40601. /**
  40602. * Gets the latest created scene
  40603. */
  40604. static get LastCreatedScene(): Nullable<Scene>;
  40605. /**
  40606. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40607. * @param flag defines which part of the materials must be marked as dirty
  40608. * @param predicate defines a predicate used to filter which materials should be affected
  40609. */
  40610. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40611. /**
  40612. * Method called to create the default loading screen.
  40613. * This can be overriden in your own app.
  40614. * @param canvas The rendering canvas element
  40615. * @returns The loading screen
  40616. */
  40617. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40618. /**
  40619. * Method called to create the default rescale post process on each engine.
  40620. */
  40621. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40622. /**
  40623. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40624. **/
  40625. enableOfflineSupport: boolean;
  40626. /**
  40627. * 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)
  40628. **/
  40629. disableManifestCheck: boolean;
  40630. /**
  40631. * Gets the list of created scenes
  40632. */
  40633. scenes: Scene[];
  40634. /**
  40635. * Event raised when a new scene is created
  40636. */
  40637. onNewSceneAddedObservable: Observable<Scene>;
  40638. /**
  40639. * Gets the list of created postprocesses
  40640. */
  40641. postProcesses: PostProcess[];
  40642. /**
  40643. * Gets a boolean indicating if the pointer is currently locked
  40644. */
  40645. isPointerLock: boolean;
  40646. /**
  40647. * Observable event triggered each time the rendering canvas is resized
  40648. */
  40649. onResizeObservable: Observable<Engine>;
  40650. /**
  40651. * Observable event triggered each time the canvas loses focus
  40652. */
  40653. onCanvasBlurObservable: Observable<Engine>;
  40654. /**
  40655. * Observable event triggered each time the canvas gains focus
  40656. */
  40657. onCanvasFocusObservable: Observable<Engine>;
  40658. /**
  40659. * Observable event triggered each time the canvas receives pointerout event
  40660. */
  40661. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40662. /**
  40663. * Observable raised when the engine begins a new frame
  40664. */
  40665. onBeginFrameObservable: Observable<Engine>;
  40666. /**
  40667. * If set, will be used to request the next animation frame for the render loop
  40668. */
  40669. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40670. /**
  40671. * Observable raised when the engine ends the current frame
  40672. */
  40673. onEndFrameObservable: Observable<Engine>;
  40674. /**
  40675. * Observable raised when the engine is about to compile a shader
  40676. */
  40677. onBeforeShaderCompilationObservable: Observable<Engine>;
  40678. /**
  40679. * Observable raised when the engine has jsut compiled a shader
  40680. */
  40681. onAfterShaderCompilationObservable: Observable<Engine>;
  40682. /**
  40683. * Gets the audio engine
  40684. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40685. * @ignorenaming
  40686. */
  40687. static audioEngine: IAudioEngine;
  40688. /**
  40689. * Default AudioEngine factory responsible of creating the Audio Engine.
  40690. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40691. */
  40692. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40693. /**
  40694. * Default offline support factory responsible of creating a tool used to store data locally.
  40695. * By default, this will create a Database object if the workload has been embedded.
  40696. */
  40697. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40698. private _loadingScreen;
  40699. private _pointerLockRequested;
  40700. private _rescalePostProcess;
  40701. private _deterministicLockstep;
  40702. private _lockstepMaxSteps;
  40703. private _timeStep;
  40704. protected get _supportsHardwareTextureRescaling(): boolean;
  40705. private _fps;
  40706. private _deltaTime;
  40707. /** @hidden */
  40708. _drawCalls: PerfCounter;
  40709. /** 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 */
  40710. canvasTabIndex: number;
  40711. /**
  40712. * Turn this value on if you want to pause FPS computation when in background
  40713. */
  40714. disablePerformanceMonitorInBackground: boolean;
  40715. private _performanceMonitor;
  40716. /**
  40717. * Gets the performance monitor attached to this engine
  40718. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40719. */
  40720. get performanceMonitor(): PerformanceMonitor;
  40721. private _onFocus;
  40722. private _onBlur;
  40723. private _onCanvasPointerOut;
  40724. private _onCanvasBlur;
  40725. private _onCanvasFocus;
  40726. private _onFullscreenChange;
  40727. private _onPointerLockChange;
  40728. /**
  40729. * Gets the HTML element used to attach event listeners
  40730. * @returns a HTML element
  40731. */
  40732. getInputElement(): Nullable<HTMLElement>;
  40733. /**
  40734. * Creates a new engine
  40735. * @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
  40736. * @param antialias defines enable antialiasing (default: false)
  40737. * @param options defines further options to be sent to the getContext() function
  40738. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40739. */
  40740. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40741. /**
  40742. * Gets current aspect ratio
  40743. * @param viewportOwner defines the camera to use to get the aspect ratio
  40744. * @param useScreen defines if screen size must be used (or the current render target if any)
  40745. * @returns a number defining the aspect ratio
  40746. */
  40747. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  40748. /**
  40749. * Gets current screen aspect ratio
  40750. * @returns a number defining the aspect ratio
  40751. */
  40752. getScreenAspectRatio(): number;
  40753. /**
  40754. * Gets the client rect of the HTML canvas attached with the current webGL context
  40755. * @returns a client rectanglee
  40756. */
  40757. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  40758. /**
  40759. * Gets the client rect of the HTML element used for events
  40760. * @returns a client rectanglee
  40761. */
  40762. getInputElementClientRect(): Nullable<ClientRect>;
  40763. /**
  40764. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  40765. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40766. * @returns true if engine is in deterministic lock step mode
  40767. */
  40768. isDeterministicLockStep(): boolean;
  40769. /**
  40770. * Gets the max steps when engine is running in deterministic lock step
  40771. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40772. * @returns the max steps
  40773. */
  40774. getLockstepMaxSteps(): number;
  40775. /**
  40776. * Returns the time in ms between steps when using deterministic lock step.
  40777. * @returns time step in (ms)
  40778. */
  40779. getTimeStep(): number;
  40780. /**
  40781. * Force the mipmap generation for the given render target texture
  40782. * @param texture defines the render target texture to use
  40783. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  40784. */
  40785. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  40786. /** States */
  40787. /**
  40788. * Set various states to the webGL context
  40789. * @param culling defines backface culling state
  40790. * @param zOffset defines the value to apply to zOffset (0 by default)
  40791. * @param force defines if states must be applied even if cache is up to date
  40792. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  40793. */
  40794. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40795. /**
  40796. * Set the z offset to apply to current rendering
  40797. * @param value defines the offset to apply
  40798. */
  40799. setZOffset(value: number): void;
  40800. /**
  40801. * Gets the current value of the zOffset
  40802. * @returns the current zOffset state
  40803. */
  40804. getZOffset(): number;
  40805. /**
  40806. * Enable or disable depth buffering
  40807. * @param enable defines the state to set
  40808. */
  40809. setDepthBuffer(enable: boolean): void;
  40810. /**
  40811. * Gets a boolean indicating if depth writing is enabled
  40812. * @returns the current depth writing state
  40813. */
  40814. getDepthWrite(): boolean;
  40815. /**
  40816. * Enable or disable depth writing
  40817. * @param enable defines the state to set
  40818. */
  40819. setDepthWrite(enable: boolean): void;
  40820. /**
  40821. * Gets a boolean indicating if stencil buffer is enabled
  40822. * @returns the current stencil buffer state
  40823. */
  40824. getStencilBuffer(): boolean;
  40825. /**
  40826. * Enable or disable the stencil buffer
  40827. * @param enable defines if the stencil buffer must be enabled or disabled
  40828. */
  40829. setStencilBuffer(enable: boolean): void;
  40830. /**
  40831. * Gets the current stencil mask
  40832. * @returns a number defining the new stencil mask to use
  40833. */
  40834. getStencilMask(): number;
  40835. /**
  40836. * Sets the current stencil mask
  40837. * @param mask defines the new stencil mask to use
  40838. */
  40839. setStencilMask(mask: number): void;
  40840. /**
  40841. * Gets the current stencil function
  40842. * @returns a number defining the stencil function to use
  40843. */
  40844. getStencilFunction(): number;
  40845. /**
  40846. * Gets the current stencil reference value
  40847. * @returns a number defining the stencil reference value to use
  40848. */
  40849. getStencilFunctionReference(): number;
  40850. /**
  40851. * Gets the current stencil mask
  40852. * @returns a number defining the stencil mask to use
  40853. */
  40854. getStencilFunctionMask(): number;
  40855. /**
  40856. * Sets the current stencil function
  40857. * @param stencilFunc defines the new stencil function to use
  40858. */
  40859. setStencilFunction(stencilFunc: number): void;
  40860. /**
  40861. * Sets the current stencil reference
  40862. * @param reference defines the new stencil reference to use
  40863. */
  40864. setStencilFunctionReference(reference: number): void;
  40865. /**
  40866. * Sets the current stencil mask
  40867. * @param mask defines the new stencil mask to use
  40868. */
  40869. setStencilFunctionMask(mask: number): void;
  40870. /**
  40871. * Gets the current stencil operation when stencil fails
  40872. * @returns a number defining stencil operation to use when stencil fails
  40873. */
  40874. getStencilOperationFail(): number;
  40875. /**
  40876. * Gets the current stencil operation when depth fails
  40877. * @returns a number defining stencil operation to use when depth fails
  40878. */
  40879. getStencilOperationDepthFail(): number;
  40880. /**
  40881. * Gets the current stencil operation when stencil passes
  40882. * @returns a number defining stencil operation to use when stencil passes
  40883. */
  40884. getStencilOperationPass(): number;
  40885. /**
  40886. * Sets the stencil operation to use when stencil fails
  40887. * @param operation defines the stencil operation to use when stencil fails
  40888. */
  40889. setStencilOperationFail(operation: number): void;
  40890. /**
  40891. * Sets the stencil operation to use when depth fails
  40892. * @param operation defines the stencil operation to use when depth fails
  40893. */
  40894. setStencilOperationDepthFail(operation: number): void;
  40895. /**
  40896. * Sets the stencil operation to use when stencil passes
  40897. * @param operation defines the stencil operation to use when stencil passes
  40898. */
  40899. setStencilOperationPass(operation: number): void;
  40900. /**
  40901. * Sets a boolean indicating if the dithering state is enabled or disabled
  40902. * @param value defines the dithering state
  40903. */
  40904. setDitheringState(value: boolean): void;
  40905. /**
  40906. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  40907. * @param value defines the rasterizer state
  40908. */
  40909. setRasterizerState(value: boolean): void;
  40910. /**
  40911. * Gets the current depth function
  40912. * @returns a number defining the depth function
  40913. */
  40914. getDepthFunction(): Nullable<number>;
  40915. /**
  40916. * Sets the current depth function
  40917. * @param depthFunc defines the function to use
  40918. */
  40919. setDepthFunction(depthFunc: number): void;
  40920. /**
  40921. * Sets the current depth function to GREATER
  40922. */
  40923. setDepthFunctionToGreater(): void;
  40924. /**
  40925. * Sets the current depth function to GEQUAL
  40926. */
  40927. setDepthFunctionToGreaterOrEqual(): void;
  40928. /**
  40929. * Sets the current depth function to LESS
  40930. */
  40931. setDepthFunctionToLess(): void;
  40932. /**
  40933. * Sets the current depth function to LEQUAL
  40934. */
  40935. setDepthFunctionToLessOrEqual(): void;
  40936. private _cachedStencilBuffer;
  40937. private _cachedStencilFunction;
  40938. private _cachedStencilMask;
  40939. private _cachedStencilOperationPass;
  40940. private _cachedStencilOperationFail;
  40941. private _cachedStencilOperationDepthFail;
  40942. private _cachedStencilReference;
  40943. /**
  40944. * Caches the the state of the stencil buffer
  40945. */
  40946. cacheStencilState(): void;
  40947. /**
  40948. * Restores the state of the stencil buffer
  40949. */
  40950. restoreStencilState(): void;
  40951. /**
  40952. * Directly set the WebGL Viewport
  40953. * @param x defines the x coordinate of the viewport (in screen space)
  40954. * @param y defines the y coordinate of the viewport (in screen space)
  40955. * @param width defines the width of the viewport (in screen space)
  40956. * @param height defines the height of the viewport (in screen space)
  40957. * @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
  40958. */
  40959. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  40960. /**
  40961. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  40962. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40963. * @param y defines the y-coordinate of the corner of the clear rectangle
  40964. * @param width defines the width of the clear rectangle
  40965. * @param height defines the height of the clear rectangle
  40966. * @param clearColor defines the clear color
  40967. */
  40968. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  40969. /**
  40970. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  40971. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40972. * @param y defines the y-coordinate of the corner of the clear rectangle
  40973. * @param width defines the width of the clear rectangle
  40974. * @param height defines the height of the clear rectangle
  40975. */
  40976. enableScissor(x: number, y: number, width: number, height: number): void;
  40977. /**
  40978. * Disable previously set scissor test rectangle
  40979. */
  40980. disableScissor(): void;
  40981. protected _reportDrawCall(): void;
  40982. /**
  40983. * Initializes a webVR display and starts listening to display change events
  40984. * The onVRDisplayChangedObservable will be notified upon these changes
  40985. * @returns The onVRDisplayChangedObservable
  40986. */
  40987. initWebVR(): Observable<IDisplayChangedEventArgs>;
  40988. /** @hidden */
  40989. _prepareVRComponent(): void;
  40990. /** @hidden */
  40991. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  40992. /** @hidden */
  40993. _submitVRFrame(): void;
  40994. /**
  40995. * Call this function to leave webVR mode
  40996. * Will do nothing if webVR is not supported or if there is no webVR device
  40997. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40998. */
  40999. disableVR(): void;
  41000. /**
  41001. * Gets a boolean indicating that the system is in VR mode and is presenting
  41002. * @returns true if VR mode is engaged
  41003. */
  41004. isVRPresenting(): boolean;
  41005. /** @hidden */
  41006. _requestVRFrame(): void;
  41007. /** @hidden */
  41008. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41009. /**
  41010. * Gets the source code of the vertex shader associated with a specific webGL program
  41011. * @param program defines the program to use
  41012. * @returns a string containing the source code of the vertex shader associated with the program
  41013. */
  41014. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41015. /**
  41016. * Gets the source code of the fragment shader associated with a specific webGL program
  41017. * @param program defines the program to use
  41018. * @returns a string containing the source code of the fragment shader associated with the program
  41019. */
  41020. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41021. /**
  41022. * Sets a depth stencil texture from a render target to the according uniform.
  41023. * @param channel The texture channel
  41024. * @param uniform The uniform to set
  41025. * @param texture The render target texture containing the depth stencil texture to apply
  41026. */
  41027. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41028. /**
  41029. * Sets a texture to the webGL context from a postprocess
  41030. * @param channel defines the channel to use
  41031. * @param postProcess defines the source postprocess
  41032. */
  41033. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41034. /**
  41035. * Binds the output of the passed in post process to the texture channel specified
  41036. * @param channel The channel the texture should be bound to
  41037. * @param postProcess The post process which's output should be bound
  41038. */
  41039. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41040. protected _rebuildBuffers(): void;
  41041. /** @hidden */
  41042. _renderFrame(): void;
  41043. _renderLoop(): void;
  41044. /** @hidden */
  41045. _renderViews(): boolean;
  41046. /**
  41047. * Toggle full screen mode
  41048. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41049. */
  41050. switchFullscreen(requestPointerLock: boolean): void;
  41051. /**
  41052. * Enters full screen mode
  41053. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41054. */
  41055. enterFullscreen(requestPointerLock: boolean): void;
  41056. /**
  41057. * Exits full screen mode
  41058. */
  41059. exitFullscreen(): void;
  41060. /**
  41061. * Enters Pointerlock mode
  41062. */
  41063. enterPointerlock(): void;
  41064. /**
  41065. * Exits Pointerlock mode
  41066. */
  41067. exitPointerlock(): void;
  41068. /**
  41069. * Begin a new frame
  41070. */
  41071. beginFrame(): void;
  41072. /**
  41073. * Enf the current frame
  41074. */
  41075. endFrame(): void;
  41076. resize(): void;
  41077. /**
  41078. * Force a specific size of the canvas
  41079. * @param width defines the new canvas' width
  41080. * @param height defines the new canvas' height
  41081. * @returns true if the size was changed
  41082. */
  41083. setSize(width: number, height: number): boolean;
  41084. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41085. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41086. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41087. _releaseTexture(texture: InternalTexture): void;
  41088. /**
  41089. * @hidden
  41090. * Rescales a texture
  41091. * @param source input texutre
  41092. * @param destination destination texture
  41093. * @param scene scene to use to render the resize
  41094. * @param internalFormat format to use when resizing
  41095. * @param onComplete callback to be called when resize has completed
  41096. */
  41097. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41098. /**
  41099. * Gets the current framerate
  41100. * @returns a number representing the framerate
  41101. */
  41102. getFps(): number;
  41103. /**
  41104. * Gets the time spent between current and previous frame
  41105. * @returns a number representing the delta time in ms
  41106. */
  41107. getDeltaTime(): number;
  41108. private _measureFps;
  41109. /** @hidden */
  41110. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41111. /**
  41112. * Updates the sample count of a render target texture
  41113. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41114. * @param texture defines the texture to update
  41115. * @param samples defines the sample count to set
  41116. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41117. */
  41118. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41119. /**
  41120. * Updates a depth texture Comparison Mode and Function.
  41121. * If the comparison Function is equal to 0, the mode will be set to none.
  41122. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41123. * @param texture The texture to set the comparison function for
  41124. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41125. */
  41126. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41127. /**
  41128. * Creates a webGL buffer to use with instanciation
  41129. * @param capacity defines the size of the buffer
  41130. * @returns the webGL buffer
  41131. */
  41132. createInstancesBuffer(capacity: number): DataBuffer;
  41133. /**
  41134. * Delete a webGL buffer used with instanciation
  41135. * @param buffer defines the webGL buffer to delete
  41136. */
  41137. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41138. private _clientWaitAsync;
  41139. /** @hidden */
  41140. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41141. dispose(): void;
  41142. private _disableTouchAction;
  41143. /**
  41144. * Display the loading screen
  41145. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41146. */
  41147. displayLoadingUI(): void;
  41148. /**
  41149. * Hide the loading screen
  41150. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41151. */
  41152. hideLoadingUI(): void;
  41153. /**
  41154. * Gets the current loading screen object
  41155. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41156. */
  41157. get loadingScreen(): ILoadingScreen;
  41158. /**
  41159. * Sets the current loading screen object
  41160. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41161. */
  41162. set loadingScreen(loadingScreen: ILoadingScreen);
  41163. /**
  41164. * Sets the current loading screen text
  41165. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41166. */
  41167. set loadingUIText(text: string);
  41168. /**
  41169. * Sets the current loading screen background color
  41170. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41171. */
  41172. set loadingUIBackgroundColor(color: string);
  41173. /** Pointerlock and fullscreen */
  41174. /**
  41175. * Ask the browser to promote the current element to pointerlock mode
  41176. * @param element defines the DOM element to promote
  41177. */
  41178. static _RequestPointerlock(element: HTMLElement): void;
  41179. /**
  41180. * Asks the browser to exit pointerlock mode
  41181. */
  41182. static _ExitPointerlock(): void;
  41183. /**
  41184. * Ask the browser to promote the current element to fullscreen rendering mode
  41185. * @param element defines the DOM element to promote
  41186. */
  41187. static _RequestFullscreen(element: HTMLElement): void;
  41188. /**
  41189. * Asks the browser to exit fullscreen mode
  41190. */
  41191. static _ExitFullscreen(): void;
  41192. }
  41193. }
  41194. declare module BABYLON {
  41195. /**
  41196. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41197. * during the life time of the application.
  41198. */
  41199. export class EngineStore {
  41200. /** Gets the list of created engines */
  41201. static Instances: Engine[];
  41202. /** @hidden */
  41203. static _LastCreatedScene: Nullable<Scene>;
  41204. /**
  41205. * Gets the latest created engine
  41206. */
  41207. static get LastCreatedEngine(): Nullable<Engine>;
  41208. /**
  41209. * Gets the latest created scene
  41210. */
  41211. static get LastCreatedScene(): Nullable<Scene>;
  41212. /**
  41213. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41214. * @ignorenaming
  41215. */
  41216. static UseFallbackTexture: boolean;
  41217. /**
  41218. * Texture content used if a texture cannot loaded
  41219. * @ignorenaming
  41220. */
  41221. static FallbackTexture: string;
  41222. }
  41223. }
  41224. declare module BABYLON {
  41225. /**
  41226. * Helper class that provides a small promise polyfill
  41227. */
  41228. export class PromisePolyfill {
  41229. /**
  41230. * Static function used to check if the polyfill is required
  41231. * If this is the case then the function will inject the polyfill to window.Promise
  41232. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41233. */
  41234. static Apply(force?: boolean): void;
  41235. }
  41236. }
  41237. declare module BABYLON {
  41238. /**
  41239. * Interface for screenshot methods with describe argument called `size` as object with options
  41240. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41241. */
  41242. export interface IScreenshotSize {
  41243. /**
  41244. * number in pixels for canvas height
  41245. */
  41246. height?: number;
  41247. /**
  41248. * multiplier allowing render at a higher or lower resolution
  41249. * If value is defined then height and width will be ignored and taken from camera
  41250. */
  41251. precision?: number;
  41252. /**
  41253. * number in pixels for canvas width
  41254. */
  41255. width?: number;
  41256. }
  41257. }
  41258. declare module BABYLON {
  41259. interface IColor4Like {
  41260. r: float;
  41261. g: float;
  41262. b: float;
  41263. a: float;
  41264. }
  41265. /**
  41266. * Class containing a set of static utilities functions
  41267. */
  41268. export class Tools {
  41269. /**
  41270. * Gets or sets the base URL to use to load assets
  41271. */
  41272. static get BaseUrl(): string;
  41273. static set BaseUrl(value: string);
  41274. /**
  41275. * Enable/Disable Custom HTTP Request Headers globally.
  41276. * default = false
  41277. * @see CustomRequestHeaders
  41278. */
  41279. static UseCustomRequestHeaders: boolean;
  41280. /**
  41281. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41282. * i.e. when loading files, where the server/service expects an Authorization header
  41283. */
  41284. static CustomRequestHeaders: {
  41285. [key: string]: string;
  41286. };
  41287. /**
  41288. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41289. */
  41290. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41291. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41292. /**
  41293. * Default behaviour for cors in the application.
  41294. * It can be a string if the expected behavior is identical in the entire app.
  41295. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41296. */
  41297. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41298. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41299. /**
  41300. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41301. * @ignorenaming
  41302. */
  41303. static get UseFallbackTexture(): boolean;
  41304. static set UseFallbackTexture(value: boolean);
  41305. /**
  41306. * Use this object to register external classes like custom textures or material
  41307. * to allow the laoders to instantiate them
  41308. */
  41309. static get RegisteredExternalClasses(): {
  41310. [key: string]: Object;
  41311. };
  41312. static set RegisteredExternalClasses(classes: {
  41313. [key: string]: Object;
  41314. });
  41315. /**
  41316. * Texture content used if a texture cannot loaded
  41317. * @ignorenaming
  41318. */
  41319. static get fallbackTexture(): string;
  41320. static set fallbackTexture(value: string);
  41321. /**
  41322. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41323. * @param u defines the coordinate on X axis
  41324. * @param v defines the coordinate on Y axis
  41325. * @param width defines the width of the source data
  41326. * @param height defines the height of the source data
  41327. * @param pixels defines the source byte array
  41328. * @param color defines the output color
  41329. */
  41330. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41331. /**
  41332. * Interpolates between a and b via alpha
  41333. * @param a The lower value (returned when alpha = 0)
  41334. * @param b The upper value (returned when alpha = 1)
  41335. * @param alpha The interpolation-factor
  41336. * @return The mixed value
  41337. */
  41338. static Mix(a: number, b: number, alpha: number): number;
  41339. /**
  41340. * Tries to instantiate a new object from a given class name
  41341. * @param className defines the class name to instantiate
  41342. * @returns the new object or null if the system was not able to do the instantiation
  41343. */
  41344. static Instantiate(className: string): any;
  41345. /**
  41346. * Provides a slice function that will work even on IE
  41347. * @param data defines the array to slice
  41348. * @param start defines the start of the data (optional)
  41349. * @param end defines the end of the data (optional)
  41350. * @returns the new sliced array
  41351. */
  41352. static Slice<T>(data: T, start?: number, end?: number): T;
  41353. /**
  41354. * Provides a slice function that will work even on IE
  41355. * The difference between this and Slice is that this will force-convert to array
  41356. * @param data defines the array to slice
  41357. * @param start defines the start of the data (optional)
  41358. * @param end defines the end of the data (optional)
  41359. * @returns the new sliced array
  41360. */
  41361. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41362. /**
  41363. * Polyfill for setImmediate
  41364. * @param action defines the action to execute after the current execution block
  41365. */
  41366. static SetImmediate(action: () => void): void;
  41367. /**
  41368. * Function indicating if a number is an exponent of 2
  41369. * @param value defines the value to test
  41370. * @returns true if the value is an exponent of 2
  41371. */
  41372. static IsExponentOfTwo(value: number): boolean;
  41373. private static _tmpFloatArray;
  41374. /**
  41375. * Returns the nearest 32-bit single precision float representation of a Number
  41376. * @param value A Number. If the parameter is of a different type, it will get converted
  41377. * to a number or to NaN if it cannot be converted
  41378. * @returns number
  41379. */
  41380. static FloatRound(value: number): number;
  41381. /**
  41382. * Extracts the filename from a path
  41383. * @param path defines the path to use
  41384. * @returns the filename
  41385. */
  41386. static GetFilename(path: string): string;
  41387. /**
  41388. * Extracts the "folder" part of a path (everything before the filename).
  41389. * @param uri The URI to extract the info from
  41390. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41391. * @returns The "folder" part of the path
  41392. */
  41393. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41394. /**
  41395. * Extracts text content from a DOM element hierarchy
  41396. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41397. */
  41398. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41399. /**
  41400. * Convert an angle in radians to degrees
  41401. * @param angle defines the angle to convert
  41402. * @returns the angle in degrees
  41403. */
  41404. static ToDegrees(angle: number): number;
  41405. /**
  41406. * Convert an angle in degrees to radians
  41407. * @param angle defines the angle to convert
  41408. * @returns the angle in radians
  41409. */
  41410. static ToRadians(angle: number): number;
  41411. /**
  41412. * Returns an array if obj is not an array
  41413. * @param obj defines the object to evaluate as an array
  41414. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41415. * @returns either obj directly if obj is an array or a new array containing obj
  41416. */
  41417. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41418. /**
  41419. * Gets the pointer prefix to use
  41420. * @param engine defines the engine we are finding the prefix for
  41421. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41422. */
  41423. static GetPointerPrefix(engine: Engine): string;
  41424. /**
  41425. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41426. * @param url define the url we are trying
  41427. * @param element define the dom element where to configure the cors policy
  41428. */
  41429. static SetCorsBehavior(url: string | string[], element: {
  41430. crossOrigin: string | null;
  41431. }): void;
  41432. /**
  41433. * Removes unwanted characters from an url
  41434. * @param url defines the url to clean
  41435. * @returns the cleaned url
  41436. */
  41437. static CleanUrl(url: string): string;
  41438. /**
  41439. * Gets or sets a function used to pre-process url before using them to load assets
  41440. */
  41441. static get PreprocessUrl(): (url: string) => string;
  41442. static set PreprocessUrl(processor: (url: string) => string);
  41443. /**
  41444. * Loads an image as an HTMLImageElement.
  41445. * @param input url string, ArrayBuffer, or Blob to load
  41446. * @param onLoad callback called when the image successfully loads
  41447. * @param onError callback called when the image fails to load
  41448. * @param offlineProvider offline provider for caching
  41449. * @param mimeType optional mime type
  41450. * @returns the HTMLImageElement of the loaded image
  41451. */
  41452. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41453. /**
  41454. * Loads a file from a url
  41455. * @param url url string, ArrayBuffer, or Blob to load
  41456. * @param onSuccess callback called when the file successfully loads
  41457. * @param onProgress callback called while file is loading (if the server supports this mode)
  41458. * @param offlineProvider defines the offline provider for caching
  41459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41460. * @param onError callback called when the file fails to load
  41461. * @returns a file request object
  41462. */
  41463. 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;
  41464. /**
  41465. * Loads a file from a url
  41466. * @param url the file url to load
  41467. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41468. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41469. */
  41470. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41471. /**
  41472. * Load a script (identified by an url). When the url returns, the
  41473. * content of this file is added into a new script element, attached to the DOM (body element)
  41474. * @param scriptUrl defines the url of the script to laod
  41475. * @param onSuccess defines the callback called when the script is loaded
  41476. * @param onError defines the callback to call if an error occurs
  41477. * @param scriptId defines the id of the script element
  41478. */
  41479. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41480. /**
  41481. * Load an asynchronous script (identified by an url). When the url returns, the
  41482. * content of this file is added into a new script element, attached to the DOM (body element)
  41483. * @param scriptUrl defines the url of the script to laod
  41484. * @param scriptId defines the id of the script element
  41485. * @returns a promise request object
  41486. */
  41487. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41488. /**
  41489. * Loads a file from a blob
  41490. * @param fileToLoad defines the blob to use
  41491. * @param callback defines the callback to call when data is loaded
  41492. * @param progressCallback defines the callback to call during loading process
  41493. * @returns a file request object
  41494. */
  41495. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41496. /**
  41497. * Reads a file from a File object
  41498. * @param file defines the file to load
  41499. * @param onSuccess defines the callback to call when data is loaded
  41500. * @param onProgress defines the callback to call during loading process
  41501. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41502. * @param onError defines the callback to call when an error occurs
  41503. * @returns a file request object
  41504. */
  41505. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41506. /**
  41507. * Creates a data url from a given string content
  41508. * @param content defines the content to convert
  41509. * @returns the new data url link
  41510. */
  41511. static FileAsURL(content: string): string;
  41512. /**
  41513. * Format the given number to a specific decimal format
  41514. * @param value defines the number to format
  41515. * @param decimals defines the number of decimals to use
  41516. * @returns the formatted string
  41517. */
  41518. static Format(value: number, decimals?: number): string;
  41519. /**
  41520. * Tries to copy an object by duplicating every property
  41521. * @param source defines the source object
  41522. * @param destination defines the target object
  41523. * @param doNotCopyList defines a list of properties to avoid
  41524. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41525. */
  41526. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41527. /**
  41528. * Gets a boolean indicating if the given object has no own property
  41529. * @param obj defines the object to test
  41530. * @returns true if object has no own property
  41531. */
  41532. static IsEmpty(obj: any): boolean;
  41533. /**
  41534. * Function used to register events at window level
  41535. * @param windowElement defines the Window object to use
  41536. * @param events defines the events to register
  41537. */
  41538. static RegisterTopRootEvents(windowElement: Window, events: {
  41539. name: string;
  41540. handler: Nullable<(e: FocusEvent) => any>;
  41541. }[]): void;
  41542. /**
  41543. * Function used to unregister events from window level
  41544. * @param windowElement defines the Window object to use
  41545. * @param events defines the events to unregister
  41546. */
  41547. static UnregisterTopRootEvents(windowElement: Window, events: {
  41548. name: string;
  41549. handler: Nullable<(e: FocusEvent) => any>;
  41550. }[]): void;
  41551. /**
  41552. * @ignore
  41553. */
  41554. static _ScreenshotCanvas: HTMLCanvasElement;
  41555. /**
  41556. * Dumps the current bound framebuffer
  41557. * @param width defines the rendering width
  41558. * @param height defines the rendering height
  41559. * @param engine defines the hosting engine
  41560. * @param successCallback defines the callback triggered once the data are available
  41561. * @param mimeType defines the mime type of the result
  41562. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41563. */
  41564. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41565. /**
  41566. * Converts the canvas data to blob.
  41567. * This acts as a polyfill for browsers not supporting the to blob function.
  41568. * @param canvas Defines the canvas to extract the data from
  41569. * @param successCallback Defines the callback triggered once the data are available
  41570. * @param mimeType Defines the mime type of the result
  41571. */
  41572. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41573. /**
  41574. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41575. * @param successCallback defines the callback triggered once the data are available
  41576. * @param mimeType defines the mime type of the result
  41577. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41578. */
  41579. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41580. /**
  41581. * Downloads a blob in the browser
  41582. * @param blob defines the blob to download
  41583. * @param fileName defines the name of the downloaded file
  41584. */
  41585. static Download(blob: Blob, fileName: string): void;
  41586. /**
  41587. * Captures a screenshot of the current rendering
  41588. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41589. * @param engine defines the rendering engine
  41590. * @param camera defines the source camera
  41591. * @param size This parameter can be set to a single number or to an object with the
  41592. * following (optional) properties: precision, width, height. If a single number is passed,
  41593. * it will be used for both width and height. If an object is passed, the screenshot size
  41594. * will be derived from the parameters. The precision property is a multiplier allowing
  41595. * rendering at a higher or lower resolution
  41596. * @param successCallback defines the callback receives a single parameter which contains the
  41597. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41598. * src parameter of an <img> to display it
  41599. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41600. * Check your browser for supported MIME types
  41601. */
  41602. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41603. /**
  41604. * Captures a screenshot of the current rendering
  41605. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41606. * @param engine defines the rendering engine
  41607. * @param camera defines the source camera
  41608. * @param size This parameter can be set to a single number or to an object with the
  41609. * following (optional) properties: precision, width, height. If a single number is passed,
  41610. * it will be used for both width and height. If an object is passed, the screenshot size
  41611. * will be derived from the parameters. The precision property is a multiplier allowing
  41612. * rendering at a higher or lower resolution
  41613. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41614. * Check your browser for supported MIME types
  41615. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41616. * to the src parameter of an <img> to display it
  41617. */
  41618. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41619. /**
  41620. * Generates an image screenshot from the specified camera.
  41621. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41622. * @param engine The engine to use for rendering
  41623. * @param camera The camera to use for rendering
  41624. * @param size This parameter can be set to a single number or to an object with the
  41625. * following (optional) properties: precision, width, height. If a single number is passed,
  41626. * it will be used for both width and height. If an object is passed, the screenshot size
  41627. * will be derived from the parameters. The precision property is a multiplier allowing
  41628. * rendering at a higher or lower resolution
  41629. * @param successCallback The callback receives a single parameter which contains the
  41630. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41631. * src parameter of an <img> to display it
  41632. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41633. * Check your browser for supported MIME types
  41634. * @param samples Texture samples (default: 1)
  41635. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41636. * @param fileName A name for for the downloaded file.
  41637. */
  41638. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41639. /**
  41640. * Generates an image screenshot from the specified camera.
  41641. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41642. * @param engine The engine to use for rendering
  41643. * @param camera The camera to use for rendering
  41644. * @param size This parameter can be set to a single number or to an object with the
  41645. * following (optional) properties: precision, width, height. If a single number is passed,
  41646. * it will be used for both width and height. If an object is passed, the screenshot size
  41647. * will be derived from the parameters. The precision property is a multiplier allowing
  41648. * rendering at a higher or lower resolution
  41649. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41650. * Check your browser for supported MIME types
  41651. * @param samples Texture samples (default: 1)
  41652. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41653. * @param fileName A name for for the downloaded file.
  41654. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41655. * to the src parameter of an <img> to display it
  41656. */
  41657. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41658. /**
  41659. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41660. * Be aware Math.random() could cause collisions, but:
  41661. * "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"
  41662. * @returns a pseudo random id
  41663. */
  41664. static RandomId(): string;
  41665. /**
  41666. * Test if the given uri is a base64 string
  41667. * @param uri The uri to test
  41668. * @return True if the uri is a base64 string or false otherwise
  41669. */
  41670. static IsBase64(uri: string): boolean;
  41671. /**
  41672. * Decode the given base64 uri.
  41673. * @param uri The uri to decode
  41674. * @return The decoded base64 data.
  41675. */
  41676. static DecodeBase64(uri: string): ArrayBuffer;
  41677. /**
  41678. * Gets the absolute url.
  41679. * @param url the input url
  41680. * @return the absolute url
  41681. */
  41682. static GetAbsoluteUrl(url: string): string;
  41683. /**
  41684. * No log
  41685. */
  41686. static readonly NoneLogLevel: number;
  41687. /**
  41688. * Only message logs
  41689. */
  41690. static readonly MessageLogLevel: number;
  41691. /**
  41692. * Only warning logs
  41693. */
  41694. static readonly WarningLogLevel: number;
  41695. /**
  41696. * Only error logs
  41697. */
  41698. static readonly ErrorLogLevel: number;
  41699. /**
  41700. * All logs
  41701. */
  41702. static readonly AllLogLevel: number;
  41703. /**
  41704. * Gets a value indicating the number of loading errors
  41705. * @ignorenaming
  41706. */
  41707. static get errorsCount(): number;
  41708. /**
  41709. * Callback called when a new log is added
  41710. */
  41711. static OnNewCacheEntry: (entry: string) => void;
  41712. /**
  41713. * Log a message to the console
  41714. * @param message defines the message to log
  41715. */
  41716. static Log(message: string): void;
  41717. /**
  41718. * Write a warning message to the console
  41719. * @param message defines the message to log
  41720. */
  41721. static Warn(message: string): void;
  41722. /**
  41723. * Write an error message to the console
  41724. * @param message defines the message to log
  41725. */
  41726. static Error(message: string): void;
  41727. /**
  41728. * Gets current log cache (list of logs)
  41729. */
  41730. static get LogCache(): string;
  41731. /**
  41732. * Clears the log cache
  41733. */
  41734. static ClearLogCache(): void;
  41735. /**
  41736. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41737. */
  41738. static set LogLevels(level: number);
  41739. /**
  41740. * Checks if the window object exists
  41741. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  41742. */
  41743. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  41744. /**
  41745. * No performance log
  41746. */
  41747. static readonly PerformanceNoneLogLevel: number;
  41748. /**
  41749. * Use user marks to log performance
  41750. */
  41751. static readonly PerformanceUserMarkLogLevel: number;
  41752. /**
  41753. * Log performance to the console
  41754. */
  41755. static readonly PerformanceConsoleLogLevel: number;
  41756. private static _performance;
  41757. /**
  41758. * Sets the current performance log level
  41759. */
  41760. static set PerformanceLogLevel(level: number);
  41761. private static _StartPerformanceCounterDisabled;
  41762. private static _EndPerformanceCounterDisabled;
  41763. private static _StartUserMark;
  41764. private static _EndUserMark;
  41765. private static _StartPerformanceConsole;
  41766. private static _EndPerformanceConsole;
  41767. /**
  41768. * Starts a performance counter
  41769. */
  41770. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41771. /**
  41772. * Ends a specific performance coutner
  41773. */
  41774. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41775. /**
  41776. * Gets either window.performance.now() if supported or Date.now() else
  41777. */
  41778. static get Now(): number;
  41779. /**
  41780. * This method will return the name of the class used to create the instance of the given object.
  41781. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  41782. * @param object the object to get the class name from
  41783. * @param isType defines if the object is actually a type
  41784. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  41785. */
  41786. static GetClassName(object: any, isType?: boolean): string;
  41787. /**
  41788. * Gets the first element of an array satisfying a given predicate
  41789. * @param array defines the array to browse
  41790. * @param predicate defines the predicate to use
  41791. * @returns null if not found or the element
  41792. */
  41793. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  41794. /**
  41795. * This method will return the name of the full name of the class, including its owning module (if any).
  41796. * 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).
  41797. * @param object the object to get the class name from
  41798. * @param isType defines if the object is actually a type
  41799. * @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.
  41800. * @ignorenaming
  41801. */
  41802. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  41803. /**
  41804. * Returns a promise that resolves after the given amount of time.
  41805. * @param delay Number of milliseconds to delay
  41806. * @returns Promise that resolves after the given amount of time
  41807. */
  41808. static DelayAsync(delay: number): Promise<void>;
  41809. /**
  41810. * Utility function to detect if the current user agent is Safari
  41811. * @returns whether or not the current user agent is safari
  41812. */
  41813. static IsSafari(): boolean;
  41814. }
  41815. /**
  41816. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  41817. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  41818. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  41819. * @param name The name of the class, case should be preserved
  41820. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  41821. */
  41822. export function className(name: string, module?: string): (target: Object) => void;
  41823. /**
  41824. * An implementation of a loop for asynchronous functions.
  41825. */
  41826. export class AsyncLoop {
  41827. /**
  41828. * Defines the number of iterations for the loop
  41829. */
  41830. iterations: number;
  41831. /**
  41832. * Defines the current index of the loop.
  41833. */
  41834. index: number;
  41835. private _done;
  41836. private _fn;
  41837. private _successCallback;
  41838. /**
  41839. * Constructor.
  41840. * @param iterations the number of iterations.
  41841. * @param func the function to run each iteration
  41842. * @param successCallback the callback that will be called upon succesful execution
  41843. * @param offset starting offset.
  41844. */
  41845. constructor(
  41846. /**
  41847. * Defines the number of iterations for the loop
  41848. */
  41849. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  41850. /**
  41851. * Execute the next iteration. Must be called after the last iteration was finished.
  41852. */
  41853. executeNext(): void;
  41854. /**
  41855. * Break the loop and run the success callback.
  41856. */
  41857. breakLoop(): void;
  41858. /**
  41859. * Create and run an async loop.
  41860. * @param iterations the number of iterations.
  41861. * @param fn the function to run each iteration
  41862. * @param successCallback the callback that will be called upon succesful execution
  41863. * @param offset starting offset.
  41864. * @returns the created async loop object
  41865. */
  41866. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  41867. /**
  41868. * A for-loop that will run a given number of iterations synchronous and the rest async.
  41869. * @param iterations total number of iterations
  41870. * @param syncedIterations number of synchronous iterations in each async iteration.
  41871. * @param fn the function to call each iteration.
  41872. * @param callback a success call back that will be called when iterating stops.
  41873. * @param breakFunction a break condition (optional)
  41874. * @param timeout timeout settings for the setTimeout function. default - 0.
  41875. * @returns the created async loop object
  41876. */
  41877. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  41878. }
  41879. }
  41880. declare module BABYLON {
  41881. /**
  41882. * This class implement a typical dictionary using a string as key and the generic type T as value.
  41883. * The underlying implementation relies on an associative array to ensure the best performances.
  41884. * The value can be anything including 'null' but except 'undefined'
  41885. */
  41886. export class StringDictionary<T> {
  41887. /**
  41888. * This will clear this dictionary and copy the content from the 'source' one.
  41889. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  41890. * @param source the dictionary to take the content from and copy to this dictionary
  41891. */
  41892. copyFrom(source: StringDictionary<T>): void;
  41893. /**
  41894. * Get a value based from its key
  41895. * @param key the given key to get the matching value from
  41896. * @return the value if found, otherwise undefined is returned
  41897. */
  41898. get(key: string): T | undefined;
  41899. /**
  41900. * Get a value from its key or add it if it doesn't exist.
  41901. * This method will ensure you that a given key/data will be present in the dictionary.
  41902. * @param key the given key to get the matching value from
  41903. * @param factory the factory that will create the value if the key is not present in the dictionary.
  41904. * The factory will only be invoked if there's no data for the given key.
  41905. * @return the value corresponding to the key.
  41906. */
  41907. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  41908. /**
  41909. * Get a value from its key if present in the dictionary otherwise add it
  41910. * @param key the key to get the value from
  41911. * @param val if there's no such key/value pair in the dictionary add it with this value
  41912. * @return the value corresponding to the key
  41913. */
  41914. getOrAdd(key: string, val: T): T;
  41915. /**
  41916. * Check if there's a given key in the dictionary
  41917. * @param key the key to check for
  41918. * @return true if the key is present, false otherwise
  41919. */
  41920. contains(key: string): boolean;
  41921. /**
  41922. * Add a new key and its corresponding value
  41923. * @param key the key to add
  41924. * @param value the value corresponding to the key
  41925. * @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
  41926. */
  41927. add(key: string, value: T): boolean;
  41928. /**
  41929. * Update a specific value associated to a key
  41930. * @param key defines the key to use
  41931. * @param value defines the value to store
  41932. * @returns true if the value was updated (or false if the key was not found)
  41933. */
  41934. set(key: string, value: T): boolean;
  41935. /**
  41936. * Get the element of the given key and remove it from the dictionary
  41937. * @param key defines the key to search
  41938. * @returns the value associated with the key or null if not found
  41939. */
  41940. getAndRemove(key: string): Nullable<T>;
  41941. /**
  41942. * Remove a key/value from the dictionary.
  41943. * @param key the key to remove
  41944. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  41945. */
  41946. remove(key: string): boolean;
  41947. /**
  41948. * Clear the whole content of the dictionary
  41949. */
  41950. clear(): void;
  41951. /**
  41952. * Gets the current count
  41953. */
  41954. get count(): number;
  41955. /**
  41956. * Execute a callback on each key/val of the dictionary.
  41957. * Note that you can remove any element in this dictionary in the callback implementation
  41958. * @param callback the callback to execute on a given key/value pair
  41959. */
  41960. forEach(callback: (key: string, val: T) => void): void;
  41961. /**
  41962. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  41963. * If the callback returns null or undefined the method will iterate to the next key/value pair
  41964. * Note that you can remove any element in this dictionary in the callback implementation
  41965. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  41966. * @returns the first item
  41967. */
  41968. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  41969. private _count;
  41970. private _data;
  41971. }
  41972. }
  41973. declare module BABYLON {
  41974. /** @hidden */
  41975. export interface ICollisionCoordinator {
  41976. createCollider(): Collider;
  41977. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41978. init(scene: Scene): void;
  41979. }
  41980. /** @hidden */
  41981. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  41982. private _scene;
  41983. private _scaledPosition;
  41984. private _scaledVelocity;
  41985. private _finalPosition;
  41986. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41987. createCollider(): Collider;
  41988. init(scene: Scene): void;
  41989. private _collideWithWorld;
  41990. }
  41991. }
  41992. declare module BABYLON {
  41993. /**
  41994. * Class used to manage all inputs for the scene.
  41995. */
  41996. export class InputManager {
  41997. /** The distance in pixel that you have to move to prevent some events */
  41998. static DragMovementThreshold: number;
  41999. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42000. static LongPressDelay: number;
  42001. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42002. static DoubleClickDelay: number;
  42003. /** If you need to check double click without raising a single click at first click, enable this flag */
  42004. static ExclusiveDoubleClickMode: boolean;
  42005. /** 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. */
  42006. private _alreadyAttached;
  42007. private _alreadyAttachedTo;
  42008. private _wheelEventName;
  42009. private _onPointerMove;
  42010. private _onPointerDown;
  42011. private _onPointerUp;
  42012. private _initClickEvent;
  42013. private _initActionManager;
  42014. private _delayedSimpleClick;
  42015. private _delayedSimpleClickTimeout;
  42016. private _previousDelayedSimpleClickTimeout;
  42017. private _meshPickProceed;
  42018. private _previousButtonPressed;
  42019. private _currentPickResult;
  42020. private _previousPickResult;
  42021. private _totalPointersPressed;
  42022. private _doubleClickOccured;
  42023. private _pointerOverMesh;
  42024. private _pickedDownMesh;
  42025. private _pickedUpMesh;
  42026. private _pointerX;
  42027. private _pointerY;
  42028. private _unTranslatedPointerX;
  42029. private _unTranslatedPointerY;
  42030. private _startingPointerPosition;
  42031. private _previousStartingPointerPosition;
  42032. private _startingPointerTime;
  42033. private _previousStartingPointerTime;
  42034. private _pointerCaptures;
  42035. private _meshUnderPointerId;
  42036. private _onKeyDown;
  42037. private _onKeyUp;
  42038. private _keyboardIsAttached;
  42039. private _onCanvasFocusObserver;
  42040. private _onCanvasBlurObserver;
  42041. private _scene;
  42042. /**
  42043. * Creates a new InputManager
  42044. * @param scene defines the hosting scene
  42045. */
  42046. constructor(scene: Scene);
  42047. /**
  42048. * Gets the mesh that is currently under the pointer
  42049. */
  42050. get meshUnderPointer(): Nullable<AbstractMesh>;
  42051. /**
  42052. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42053. * @param pointerId the pointer id to use
  42054. * @returns The mesh under this pointer id or null if not found
  42055. */
  42056. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42057. /**
  42058. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42059. */
  42060. get unTranslatedPointer(): Vector2;
  42061. /**
  42062. * Gets or sets the current on-screen X position of the pointer
  42063. */
  42064. get pointerX(): number;
  42065. set pointerX(value: number);
  42066. /**
  42067. * Gets or sets the current on-screen Y position of the pointer
  42068. */
  42069. get pointerY(): number;
  42070. set pointerY(value: number);
  42071. private _updatePointerPosition;
  42072. private _processPointerMove;
  42073. private _setRayOnPointerInfo;
  42074. private _checkPrePointerObservable;
  42075. /**
  42076. * Use this method to simulate a pointer move on a mesh
  42077. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42078. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42079. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42080. */
  42081. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42082. /**
  42083. * Use this method to simulate a pointer down on a mesh
  42084. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42085. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42086. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42087. */
  42088. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42089. private _processPointerDown;
  42090. /** @hidden */
  42091. _isPointerSwiping(): boolean;
  42092. /**
  42093. * Use this method to simulate a pointer up on a mesh
  42094. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42095. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42096. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42097. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42098. */
  42099. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42100. private _processPointerUp;
  42101. /**
  42102. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42103. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42104. * @returns true if the pointer was captured
  42105. */
  42106. isPointerCaptured(pointerId?: number): boolean;
  42107. /**
  42108. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42109. * @param attachUp defines if you want to attach events to pointerup
  42110. * @param attachDown defines if you want to attach events to pointerdown
  42111. * @param attachMove defines if you want to attach events to pointermove
  42112. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42113. */
  42114. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42115. /**
  42116. * Detaches all event handlers
  42117. */
  42118. detachControl(): void;
  42119. /**
  42120. * Force the value of meshUnderPointer
  42121. * @param mesh defines the mesh to use
  42122. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42123. */
  42124. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42125. /**
  42126. * Gets the mesh under the pointer
  42127. * @returns a Mesh or null if no mesh is under the pointer
  42128. */
  42129. getPointerOverMesh(): Nullable<AbstractMesh>;
  42130. }
  42131. }
  42132. declare module BABYLON {
  42133. /**
  42134. * This class defines the direct association between an animation and a target
  42135. */
  42136. export class TargetedAnimation {
  42137. /**
  42138. * Animation to perform
  42139. */
  42140. animation: Animation;
  42141. /**
  42142. * Target to animate
  42143. */
  42144. target: any;
  42145. /**
  42146. * Returns the string "TargetedAnimation"
  42147. * @returns "TargetedAnimation"
  42148. */
  42149. getClassName(): string;
  42150. /**
  42151. * Serialize the object
  42152. * @returns the JSON object representing the current entity
  42153. */
  42154. serialize(): any;
  42155. }
  42156. /**
  42157. * Use this class to create coordinated animations on multiple targets
  42158. */
  42159. export class AnimationGroup implements IDisposable {
  42160. /** The name of the animation group */
  42161. name: string;
  42162. private _scene;
  42163. private _targetedAnimations;
  42164. private _animatables;
  42165. private _from;
  42166. private _to;
  42167. private _isStarted;
  42168. private _isPaused;
  42169. private _speedRatio;
  42170. private _loopAnimation;
  42171. private _isAdditive;
  42172. /**
  42173. * Gets or sets the unique id of the node
  42174. */
  42175. uniqueId: number;
  42176. /**
  42177. * This observable will notify when one animation have ended
  42178. */
  42179. onAnimationEndObservable: Observable<TargetedAnimation>;
  42180. /**
  42181. * Observer raised when one animation loops
  42182. */
  42183. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42184. /**
  42185. * Observer raised when all animations have looped
  42186. */
  42187. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42188. /**
  42189. * This observable will notify when all animations have ended.
  42190. */
  42191. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42192. /**
  42193. * This observable will notify when all animations have paused.
  42194. */
  42195. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42196. /**
  42197. * This observable will notify when all animations are playing.
  42198. */
  42199. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42200. /**
  42201. * Gets the first frame
  42202. */
  42203. get from(): number;
  42204. /**
  42205. * Gets the last frame
  42206. */
  42207. get to(): number;
  42208. /**
  42209. * Define if the animations are started
  42210. */
  42211. get isStarted(): boolean;
  42212. /**
  42213. * Gets a value indicating that the current group is playing
  42214. */
  42215. get isPlaying(): boolean;
  42216. /**
  42217. * Gets or sets the speed ratio to use for all animations
  42218. */
  42219. get speedRatio(): number;
  42220. /**
  42221. * Gets or sets the speed ratio to use for all animations
  42222. */
  42223. set speedRatio(value: number);
  42224. /**
  42225. * Gets or sets if all animations should loop or not
  42226. */
  42227. get loopAnimation(): boolean;
  42228. set loopAnimation(value: boolean);
  42229. /**
  42230. * Gets or sets if all animations should be evaluated additively
  42231. */
  42232. get isAdditive(): boolean;
  42233. set isAdditive(value: boolean);
  42234. /**
  42235. * Gets the targeted animations for this animation group
  42236. */
  42237. get targetedAnimations(): Array<TargetedAnimation>;
  42238. /**
  42239. * returning the list of animatables controlled by this animation group.
  42240. */
  42241. get animatables(): Array<Animatable>;
  42242. /**
  42243. * Gets the list of target animations
  42244. */
  42245. get children(): TargetedAnimation[];
  42246. /**
  42247. * Instantiates a new Animation Group.
  42248. * This helps managing several animations at once.
  42249. * @see https://doc.babylonjs.com/how_to/group
  42250. * @param name Defines the name of the group
  42251. * @param scene Defines the scene the group belongs to
  42252. */
  42253. constructor(
  42254. /** The name of the animation group */
  42255. name: string, scene?: Nullable<Scene>);
  42256. /**
  42257. * Add an animation (with its target) in the group
  42258. * @param animation defines the animation we want to add
  42259. * @param target defines the target of the animation
  42260. * @returns the TargetedAnimation object
  42261. */
  42262. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42263. /**
  42264. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42265. * It can add constant keys at begin or end
  42266. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42267. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42268. * @returns the animation group
  42269. */
  42270. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42271. private _animationLoopCount;
  42272. private _animationLoopFlags;
  42273. private _processLoop;
  42274. /**
  42275. * Start all animations on given targets
  42276. * @param loop defines if animations must loop
  42277. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42278. * @param from defines the from key (optional)
  42279. * @param to defines the to key (optional)
  42280. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42281. * @returns the current animation group
  42282. */
  42283. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42284. /**
  42285. * Pause all animations
  42286. * @returns the animation group
  42287. */
  42288. pause(): AnimationGroup;
  42289. /**
  42290. * Play all animations to initial state
  42291. * This function will start() the animations if they were not started or will restart() them if they were paused
  42292. * @param loop defines if animations must loop
  42293. * @returns the animation group
  42294. */
  42295. play(loop?: boolean): AnimationGroup;
  42296. /**
  42297. * Reset all animations to initial state
  42298. * @returns the animation group
  42299. */
  42300. reset(): AnimationGroup;
  42301. /**
  42302. * Restart animations from key 0
  42303. * @returns the animation group
  42304. */
  42305. restart(): AnimationGroup;
  42306. /**
  42307. * Stop all animations
  42308. * @returns the animation group
  42309. */
  42310. stop(): AnimationGroup;
  42311. /**
  42312. * Set animation weight for all animatables
  42313. * @param weight defines the weight to use
  42314. * @return the animationGroup
  42315. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42316. */
  42317. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42318. /**
  42319. * Synchronize and normalize all animatables with a source animatable
  42320. * @param root defines the root animatable to synchronize with
  42321. * @return the animationGroup
  42322. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42323. */
  42324. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42325. /**
  42326. * Goes to a specific frame in this animation group
  42327. * @param frame the frame number to go to
  42328. * @return the animationGroup
  42329. */
  42330. goToFrame(frame: number): AnimationGroup;
  42331. /**
  42332. * Dispose all associated resources
  42333. */
  42334. dispose(): void;
  42335. private _checkAnimationGroupEnded;
  42336. /**
  42337. * Clone the current animation group and returns a copy
  42338. * @param newName defines the name of the new group
  42339. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42340. * @returns the new aniamtion group
  42341. */
  42342. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42343. /**
  42344. * Serializes the animationGroup to an object
  42345. * @returns Serialized object
  42346. */
  42347. serialize(): any;
  42348. /**
  42349. * Returns a new AnimationGroup object parsed from the source provided.
  42350. * @param parsedAnimationGroup defines the source
  42351. * @param scene defines the scene that will receive the animationGroup
  42352. * @returns a new AnimationGroup
  42353. */
  42354. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42355. /**
  42356. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42357. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42358. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42359. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42360. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42361. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42362. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42363. */
  42364. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42365. /**
  42366. * Returns the string "AnimationGroup"
  42367. * @returns "AnimationGroup"
  42368. */
  42369. getClassName(): string;
  42370. /**
  42371. * Creates a detailled string about the object
  42372. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42373. * @returns a string representing the object
  42374. */
  42375. toString(fullDetails?: boolean): string;
  42376. }
  42377. }
  42378. declare module BABYLON {
  42379. /**
  42380. * Define an interface for all classes that will hold resources
  42381. */
  42382. export interface IDisposable {
  42383. /**
  42384. * Releases all held resources
  42385. */
  42386. dispose(): void;
  42387. }
  42388. /** Interface defining initialization parameters for Scene class */
  42389. export interface SceneOptions {
  42390. /**
  42391. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42392. * It will improve performance when the number of geometries becomes important.
  42393. */
  42394. useGeometryUniqueIdsMap?: boolean;
  42395. /**
  42396. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42397. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42398. */
  42399. useMaterialMeshMap?: boolean;
  42400. /**
  42401. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42402. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42403. */
  42404. useClonedMeshMap?: boolean;
  42405. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42406. virtual?: boolean;
  42407. }
  42408. /**
  42409. * Represents a scene to be rendered by the engine.
  42410. * @see https://doc.babylonjs.com/features/scene
  42411. */
  42412. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42413. /** The fog is deactivated */
  42414. static readonly FOGMODE_NONE: number;
  42415. /** The fog density is following an exponential function */
  42416. static readonly FOGMODE_EXP: number;
  42417. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42418. static readonly FOGMODE_EXP2: number;
  42419. /** The fog density is following a linear function. */
  42420. static readonly FOGMODE_LINEAR: number;
  42421. /**
  42422. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42423. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42424. */
  42425. static MinDeltaTime: number;
  42426. /**
  42427. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42428. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42429. */
  42430. static MaxDeltaTime: number;
  42431. /**
  42432. * Factory used to create the default material.
  42433. * @param name The name of the material to create
  42434. * @param scene The scene to create the material for
  42435. * @returns The default material
  42436. */
  42437. static DefaultMaterialFactory(scene: Scene): Material;
  42438. /**
  42439. * Factory used to create the a collision coordinator.
  42440. * @returns The collision coordinator
  42441. */
  42442. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42443. /** @hidden */
  42444. _inputManager: InputManager;
  42445. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42446. cameraToUseForPointers: Nullable<Camera>;
  42447. /** @hidden */
  42448. readonly _isScene: boolean;
  42449. /** @hidden */
  42450. _blockEntityCollection: boolean;
  42451. /**
  42452. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42453. */
  42454. autoClear: boolean;
  42455. /**
  42456. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42457. */
  42458. autoClearDepthAndStencil: boolean;
  42459. /**
  42460. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42461. */
  42462. clearColor: Color4;
  42463. /**
  42464. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42465. */
  42466. ambientColor: Color3;
  42467. /**
  42468. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42469. * It should only be one of the following (if not the default embedded one):
  42470. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42471. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42472. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42473. * The material properties need to be setup according to the type of texture in use.
  42474. */
  42475. environmentBRDFTexture: BaseTexture;
  42476. /**
  42477. * Texture used in all pbr material as the reflection texture.
  42478. * As in the majority of the scene they are the same (exception for multi room and so on),
  42479. * this is easier to reference from here than from all the materials.
  42480. */
  42481. get environmentTexture(): Nullable<BaseTexture>;
  42482. /**
  42483. * Texture used in all pbr material as the reflection texture.
  42484. * As in the majority of the scene they are the same (exception for multi room and so on),
  42485. * this is easier to set here than in all the materials.
  42486. */
  42487. set environmentTexture(value: Nullable<BaseTexture>);
  42488. /** @hidden */
  42489. protected _environmentIntensity: number;
  42490. /**
  42491. * Intensity of the environment in all pbr material.
  42492. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42493. * As in the majority of the scene they are the same (exception for multi room and so on),
  42494. * this is easier to reference from here than from all the materials.
  42495. */
  42496. get environmentIntensity(): number;
  42497. /**
  42498. * Intensity of the environment in all pbr material.
  42499. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42500. * As in the majority of the scene they are the same (exception for multi room and so on),
  42501. * this is easier to set here than in all the materials.
  42502. */
  42503. set environmentIntensity(value: number);
  42504. /** @hidden */
  42505. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42506. /**
  42507. * Default image processing configuration used either in the rendering
  42508. * Forward main pass or through the imageProcessingPostProcess if present.
  42509. * As in the majority of the scene they are the same (exception for multi camera),
  42510. * this is easier to reference from here than from all the materials and post process.
  42511. *
  42512. * No setter as we it is a shared configuration, you can set the values instead.
  42513. */
  42514. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42515. private _forceWireframe;
  42516. /**
  42517. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42518. */
  42519. set forceWireframe(value: boolean);
  42520. get forceWireframe(): boolean;
  42521. private _skipFrustumClipping;
  42522. /**
  42523. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42524. */
  42525. set skipFrustumClipping(value: boolean);
  42526. get skipFrustumClipping(): boolean;
  42527. private _forcePointsCloud;
  42528. /**
  42529. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42530. */
  42531. set forcePointsCloud(value: boolean);
  42532. get forcePointsCloud(): boolean;
  42533. /**
  42534. * Gets or sets the active clipplane 1
  42535. */
  42536. clipPlane: Nullable<Plane>;
  42537. /**
  42538. * Gets or sets the active clipplane 2
  42539. */
  42540. clipPlane2: Nullable<Plane>;
  42541. /**
  42542. * Gets or sets the active clipplane 3
  42543. */
  42544. clipPlane3: Nullable<Plane>;
  42545. /**
  42546. * Gets or sets the active clipplane 4
  42547. */
  42548. clipPlane4: Nullable<Plane>;
  42549. /**
  42550. * Gets or sets the active clipplane 5
  42551. */
  42552. clipPlane5: Nullable<Plane>;
  42553. /**
  42554. * Gets or sets the active clipplane 6
  42555. */
  42556. clipPlane6: Nullable<Plane>;
  42557. /**
  42558. * Gets or sets a boolean indicating if animations are enabled
  42559. */
  42560. animationsEnabled: boolean;
  42561. private _animationPropertiesOverride;
  42562. /**
  42563. * Gets or sets the animation properties override
  42564. */
  42565. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42566. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42567. /**
  42568. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42569. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42570. */
  42571. useConstantAnimationDeltaTime: boolean;
  42572. /**
  42573. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42574. * Please note that it requires to run a ray cast through the scene on every frame
  42575. */
  42576. constantlyUpdateMeshUnderPointer: boolean;
  42577. /**
  42578. * Defines the HTML cursor to use when hovering over interactive elements
  42579. */
  42580. hoverCursor: string;
  42581. /**
  42582. * Defines the HTML default cursor to use (empty by default)
  42583. */
  42584. defaultCursor: string;
  42585. /**
  42586. * Defines whether cursors are handled by the scene.
  42587. */
  42588. doNotHandleCursors: boolean;
  42589. /**
  42590. * This is used to call preventDefault() on pointer down
  42591. * in order to block unwanted artifacts like system double clicks
  42592. */
  42593. preventDefaultOnPointerDown: boolean;
  42594. /**
  42595. * This is used to call preventDefault() on pointer up
  42596. * in order to block unwanted artifacts like system double clicks
  42597. */
  42598. preventDefaultOnPointerUp: boolean;
  42599. /**
  42600. * Gets or sets user defined metadata
  42601. */
  42602. metadata: any;
  42603. /**
  42604. * For internal use only. Please do not use.
  42605. */
  42606. reservedDataStore: any;
  42607. /**
  42608. * Gets the name of the plugin used to load this scene (null by default)
  42609. */
  42610. loadingPluginName: string;
  42611. /**
  42612. * Use this array to add regular expressions used to disable offline support for specific urls
  42613. */
  42614. disableOfflineSupportExceptionRules: RegExp[];
  42615. /**
  42616. * An event triggered when the scene is disposed.
  42617. */
  42618. onDisposeObservable: Observable<Scene>;
  42619. private _onDisposeObserver;
  42620. /** Sets a function to be executed when this scene is disposed. */
  42621. set onDispose(callback: () => void);
  42622. /**
  42623. * An event triggered before rendering the scene (right after animations and physics)
  42624. */
  42625. onBeforeRenderObservable: Observable<Scene>;
  42626. private _onBeforeRenderObserver;
  42627. /** Sets a function to be executed before rendering this scene */
  42628. set beforeRender(callback: Nullable<() => void>);
  42629. /**
  42630. * An event triggered after rendering the scene
  42631. */
  42632. onAfterRenderObservable: Observable<Scene>;
  42633. /**
  42634. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42635. */
  42636. onAfterRenderCameraObservable: Observable<Camera>;
  42637. private _onAfterRenderObserver;
  42638. /** Sets a function to be executed after rendering this scene */
  42639. set afterRender(callback: Nullable<() => void>);
  42640. /**
  42641. * An event triggered before animating the scene
  42642. */
  42643. onBeforeAnimationsObservable: Observable<Scene>;
  42644. /**
  42645. * An event triggered after animations processing
  42646. */
  42647. onAfterAnimationsObservable: Observable<Scene>;
  42648. /**
  42649. * An event triggered before draw calls are ready to be sent
  42650. */
  42651. onBeforeDrawPhaseObservable: Observable<Scene>;
  42652. /**
  42653. * An event triggered after draw calls have been sent
  42654. */
  42655. onAfterDrawPhaseObservable: Observable<Scene>;
  42656. /**
  42657. * An event triggered when the scene is ready
  42658. */
  42659. onReadyObservable: Observable<Scene>;
  42660. /**
  42661. * An event triggered before rendering a camera
  42662. */
  42663. onBeforeCameraRenderObservable: Observable<Camera>;
  42664. private _onBeforeCameraRenderObserver;
  42665. /** Sets a function to be executed before rendering a camera*/
  42666. set beforeCameraRender(callback: () => void);
  42667. /**
  42668. * An event triggered after rendering a camera
  42669. */
  42670. onAfterCameraRenderObservable: Observable<Camera>;
  42671. private _onAfterCameraRenderObserver;
  42672. /** Sets a function to be executed after rendering a camera*/
  42673. set afterCameraRender(callback: () => void);
  42674. /**
  42675. * An event triggered when active meshes evaluation is about to start
  42676. */
  42677. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42678. /**
  42679. * An event triggered when active meshes evaluation is done
  42680. */
  42681. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42682. /**
  42683. * An event triggered when particles rendering is about to start
  42684. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42685. */
  42686. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42687. /**
  42688. * An event triggered when particles rendering is done
  42689. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42690. */
  42691. onAfterParticlesRenderingObservable: Observable<Scene>;
  42692. /**
  42693. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42694. */
  42695. onDataLoadedObservable: Observable<Scene>;
  42696. /**
  42697. * An event triggered when a camera is created
  42698. */
  42699. onNewCameraAddedObservable: Observable<Camera>;
  42700. /**
  42701. * An event triggered when a camera is removed
  42702. */
  42703. onCameraRemovedObservable: Observable<Camera>;
  42704. /**
  42705. * An event triggered when a light is created
  42706. */
  42707. onNewLightAddedObservable: Observable<Light>;
  42708. /**
  42709. * An event triggered when a light is removed
  42710. */
  42711. onLightRemovedObservable: Observable<Light>;
  42712. /**
  42713. * An event triggered when a geometry is created
  42714. */
  42715. onNewGeometryAddedObservable: Observable<Geometry>;
  42716. /**
  42717. * An event triggered when a geometry is removed
  42718. */
  42719. onGeometryRemovedObservable: Observable<Geometry>;
  42720. /**
  42721. * An event triggered when a transform node is created
  42722. */
  42723. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42724. /**
  42725. * An event triggered when a transform node is removed
  42726. */
  42727. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42728. /**
  42729. * An event triggered when a mesh is created
  42730. */
  42731. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42732. /**
  42733. * An event triggered when a mesh is removed
  42734. */
  42735. onMeshRemovedObservable: Observable<AbstractMesh>;
  42736. /**
  42737. * An event triggered when a skeleton is created
  42738. */
  42739. onNewSkeletonAddedObservable: Observable<Skeleton>;
  42740. /**
  42741. * An event triggered when a skeleton is removed
  42742. */
  42743. onSkeletonRemovedObservable: Observable<Skeleton>;
  42744. /**
  42745. * An event triggered when a material is created
  42746. */
  42747. onNewMaterialAddedObservable: Observable<Material>;
  42748. /**
  42749. * An event triggered when a material is removed
  42750. */
  42751. onMaterialRemovedObservable: Observable<Material>;
  42752. /**
  42753. * An event triggered when a texture is created
  42754. */
  42755. onNewTextureAddedObservable: Observable<BaseTexture>;
  42756. /**
  42757. * An event triggered when a texture is removed
  42758. */
  42759. onTextureRemovedObservable: Observable<BaseTexture>;
  42760. /**
  42761. * An event triggered when render targets are about to be rendered
  42762. * Can happen multiple times per frame.
  42763. */
  42764. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  42765. /**
  42766. * An event triggered when render targets were rendered.
  42767. * Can happen multiple times per frame.
  42768. */
  42769. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  42770. /**
  42771. * An event triggered before calculating deterministic simulation step
  42772. */
  42773. onBeforeStepObservable: Observable<Scene>;
  42774. /**
  42775. * An event triggered after calculating deterministic simulation step
  42776. */
  42777. onAfterStepObservable: Observable<Scene>;
  42778. /**
  42779. * An event triggered when the activeCamera property is updated
  42780. */
  42781. onActiveCameraChanged: Observable<Scene>;
  42782. /**
  42783. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  42784. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42785. * 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)
  42786. */
  42787. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42788. /**
  42789. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  42790. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42791. * 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)
  42792. */
  42793. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42794. /**
  42795. * This Observable will when a mesh has been imported into the scene.
  42796. */
  42797. onMeshImportedObservable: Observable<AbstractMesh>;
  42798. /**
  42799. * This Observable will when an animation file has been imported into the scene.
  42800. */
  42801. onAnimationFileImportedObservable: Observable<Scene>;
  42802. /**
  42803. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  42804. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  42805. */
  42806. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  42807. /** @hidden */
  42808. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  42809. /**
  42810. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  42811. */
  42812. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  42813. /**
  42814. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  42815. */
  42816. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  42817. /**
  42818. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  42819. */
  42820. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  42821. /** Callback called when a pointer move is detected */
  42822. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42823. /** Callback called when a pointer down is detected */
  42824. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42825. /** Callback called when a pointer up is detected */
  42826. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  42827. /** Callback called when a pointer pick is detected */
  42828. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  42829. /**
  42830. * 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).
  42831. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  42832. */
  42833. onPrePointerObservable: Observable<PointerInfoPre>;
  42834. /**
  42835. * Observable event triggered each time an input event is received from the rendering canvas
  42836. */
  42837. onPointerObservable: Observable<PointerInfo>;
  42838. /**
  42839. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  42840. */
  42841. get unTranslatedPointer(): Vector2;
  42842. /**
  42843. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  42844. */
  42845. static get DragMovementThreshold(): number;
  42846. static set DragMovementThreshold(value: number);
  42847. /**
  42848. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  42849. */
  42850. static get LongPressDelay(): number;
  42851. static set LongPressDelay(value: number);
  42852. /**
  42853. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  42854. */
  42855. static get DoubleClickDelay(): number;
  42856. static set DoubleClickDelay(value: number);
  42857. /** If you need to check double click without raising a single click at first click, enable this flag */
  42858. static get ExclusiveDoubleClickMode(): boolean;
  42859. static set ExclusiveDoubleClickMode(value: boolean);
  42860. /** @hidden */
  42861. _mirroredCameraPosition: Nullable<Vector3>;
  42862. /**
  42863. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  42864. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  42865. */
  42866. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  42867. /**
  42868. * Observable event triggered each time an keyboard event is received from the hosting window
  42869. */
  42870. onKeyboardObservable: Observable<KeyboardInfo>;
  42871. private _useRightHandedSystem;
  42872. /**
  42873. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  42874. */
  42875. set useRightHandedSystem(value: boolean);
  42876. get useRightHandedSystem(): boolean;
  42877. private _timeAccumulator;
  42878. private _currentStepId;
  42879. private _currentInternalStep;
  42880. /**
  42881. * Sets the step Id used by deterministic lock step
  42882. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42883. * @param newStepId defines the step Id
  42884. */
  42885. setStepId(newStepId: number): void;
  42886. /**
  42887. * Gets the step Id used by deterministic lock step
  42888. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42889. * @returns the step Id
  42890. */
  42891. getStepId(): number;
  42892. /**
  42893. * Gets the internal step used by deterministic lock step
  42894. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42895. * @returns the internal step
  42896. */
  42897. getInternalStep(): number;
  42898. private _fogEnabled;
  42899. /**
  42900. * Gets or sets a boolean indicating if fog is enabled on this scene
  42901. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42902. * (Default is true)
  42903. */
  42904. set fogEnabled(value: boolean);
  42905. get fogEnabled(): boolean;
  42906. private _fogMode;
  42907. /**
  42908. * Gets or sets the fog mode to use
  42909. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42910. * | mode | value |
  42911. * | --- | --- |
  42912. * | FOGMODE_NONE | 0 |
  42913. * | FOGMODE_EXP | 1 |
  42914. * | FOGMODE_EXP2 | 2 |
  42915. * | FOGMODE_LINEAR | 3 |
  42916. */
  42917. set fogMode(value: number);
  42918. get fogMode(): number;
  42919. /**
  42920. * Gets or sets the fog color to use
  42921. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42922. * (Default is Color3(0.2, 0.2, 0.3))
  42923. */
  42924. fogColor: Color3;
  42925. /**
  42926. * Gets or sets the fog density to use
  42927. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42928. * (Default is 0.1)
  42929. */
  42930. fogDensity: number;
  42931. /**
  42932. * Gets or sets the fog start distance to use
  42933. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42934. * (Default is 0)
  42935. */
  42936. fogStart: number;
  42937. /**
  42938. * Gets or sets the fog end distance to use
  42939. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42940. * (Default is 1000)
  42941. */
  42942. fogEnd: number;
  42943. /**
  42944. * Flag indicating that the frame buffer binding is handled by another component
  42945. */
  42946. prePass: boolean;
  42947. private _shadowsEnabled;
  42948. /**
  42949. * Gets or sets a boolean indicating if shadows are enabled on this scene
  42950. */
  42951. set shadowsEnabled(value: boolean);
  42952. get shadowsEnabled(): boolean;
  42953. private _lightsEnabled;
  42954. /**
  42955. * Gets or sets a boolean indicating if lights are enabled on this scene
  42956. */
  42957. set lightsEnabled(value: boolean);
  42958. get lightsEnabled(): boolean;
  42959. /** All of the active cameras added to this scene. */
  42960. activeCameras: Camera[];
  42961. /** @hidden */
  42962. _activeCamera: Nullable<Camera>;
  42963. /** Gets or sets the current active camera */
  42964. get activeCamera(): Nullable<Camera>;
  42965. set activeCamera(value: Nullable<Camera>);
  42966. private _defaultMaterial;
  42967. /** The default material used on meshes when no material is affected */
  42968. get defaultMaterial(): Material;
  42969. /** The default material used on meshes when no material is affected */
  42970. set defaultMaterial(value: Material);
  42971. private _texturesEnabled;
  42972. /**
  42973. * Gets or sets a boolean indicating if textures are enabled on this scene
  42974. */
  42975. set texturesEnabled(value: boolean);
  42976. get texturesEnabled(): boolean;
  42977. /**
  42978. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  42979. */
  42980. physicsEnabled: boolean;
  42981. /**
  42982. * Gets or sets a boolean indicating if particles are enabled on this scene
  42983. */
  42984. particlesEnabled: boolean;
  42985. /**
  42986. * Gets or sets a boolean indicating if sprites are enabled on this scene
  42987. */
  42988. spritesEnabled: boolean;
  42989. private _skeletonsEnabled;
  42990. /**
  42991. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  42992. */
  42993. set skeletonsEnabled(value: boolean);
  42994. get skeletonsEnabled(): boolean;
  42995. /**
  42996. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  42997. */
  42998. lensFlaresEnabled: boolean;
  42999. /**
  43000. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43001. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43002. */
  43003. collisionsEnabled: boolean;
  43004. private _collisionCoordinator;
  43005. /** @hidden */
  43006. get collisionCoordinator(): ICollisionCoordinator;
  43007. /**
  43008. * Defines the gravity applied to this scene (used only for collisions)
  43009. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43010. */
  43011. gravity: Vector3;
  43012. /**
  43013. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43014. */
  43015. postProcessesEnabled: boolean;
  43016. /**
  43017. * Gets the current postprocess manager
  43018. */
  43019. postProcessManager: PostProcessManager;
  43020. /**
  43021. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43022. */
  43023. renderTargetsEnabled: boolean;
  43024. /**
  43025. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43026. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43027. */
  43028. dumpNextRenderTargets: boolean;
  43029. /**
  43030. * The list of user defined render targets added to the scene
  43031. */
  43032. customRenderTargets: RenderTargetTexture[];
  43033. /**
  43034. * Defines if texture loading must be delayed
  43035. * If true, textures will only be loaded when they need to be rendered
  43036. */
  43037. useDelayedTextureLoading: boolean;
  43038. /**
  43039. * Gets the list of meshes imported to the scene through SceneLoader
  43040. */
  43041. importedMeshesFiles: String[];
  43042. /**
  43043. * Gets or sets a boolean indicating if probes are enabled on this scene
  43044. */
  43045. probesEnabled: boolean;
  43046. /**
  43047. * Gets or sets the current offline provider to use to store scene data
  43048. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43049. */
  43050. offlineProvider: IOfflineProvider;
  43051. /**
  43052. * Gets or sets the action manager associated with the scene
  43053. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43054. */
  43055. actionManager: AbstractActionManager;
  43056. private _meshesForIntersections;
  43057. /**
  43058. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43059. */
  43060. proceduralTexturesEnabled: boolean;
  43061. private _engine;
  43062. private _totalVertices;
  43063. /** @hidden */
  43064. _activeIndices: PerfCounter;
  43065. /** @hidden */
  43066. _activeParticles: PerfCounter;
  43067. /** @hidden */
  43068. _activeBones: PerfCounter;
  43069. private _animationRatio;
  43070. /** @hidden */
  43071. _animationTimeLast: number;
  43072. /** @hidden */
  43073. _animationTime: number;
  43074. /**
  43075. * Gets or sets a general scale for animation speed
  43076. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43077. */
  43078. animationTimeScale: number;
  43079. /** @hidden */
  43080. _cachedMaterial: Nullable<Material>;
  43081. /** @hidden */
  43082. _cachedEffect: Nullable<Effect>;
  43083. /** @hidden */
  43084. _cachedVisibility: Nullable<number>;
  43085. private _renderId;
  43086. private _frameId;
  43087. private _executeWhenReadyTimeoutId;
  43088. private _intermediateRendering;
  43089. private _viewUpdateFlag;
  43090. private _projectionUpdateFlag;
  43091. /** @hidden */
  43092. _toBeDisposed: Nullable<IDisposable>[];
  43093. private _activeRequests;
  43094. /** @hidden */
  43095. _pendingData: any[];
  43096. private _isDisposed;
  43097. /**
  43098. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43099. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43100. */
  43101. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43102. private _activeMeshes;
  43103. private _processedMaterials;
  43104. private _renderTargets;
  43105. /** @hidden */
  43106. _activeParticleSystems: SmartArray<IParticleSystem>;
  43107. private _activeSkeletons;
  43108. private _softwareSkinnedMeshes;
  43109. private _renderingManager;
  43110. /** @hidden */
  43111. _activeAnimatables: Animatable[];
  43112. private _transformMatrix;
  43113. private _sceneUbo;
  43114. /** @hidden */
  43115. _viewMatrix: Matrix;
  43116. private _projectionMatrix;
  43117. /** @hidden */
  43118. _forcedViewPosition: Nullable<Vector3>;
  43119. /** @hidden */
  43120. _frustumPlanes: Plane[];
  43121. /**
  43122. * Gets the list of frustum planes (built from the active camera)
  43123. */
  43124. get frustumPlanes(): Plane[];
  43125. /**
  43126. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43127. * This is useful if there are more lights that the maximum simulteanous authorized
  43128. */
  43129. requireLightSorting: boolean;
  43130. /** @hidden */
  43131. readonly useMaterialMeshMap: boolean;
  43132. /** @hidden */
  43133. readonly useClonedMeshMap: boolean;
  43134. private _externalData;
  43135. private _uid;
  43136. /**
  43137. * @hidden
  43138. * Backing store of defined scene components.
  43139. */
  43140. _components: ISceneComponent[];
  43141. /**
  43142. * @hidden
  43143. * Backing store of defined scene components.
  43144. */
  43145. _serializableComponents: ISceneSerializableComponent[];
  43146. /**
  43147. * List of components to register on the next registration step.
  43148. */
  43149. private _transientComponents;
  43150. /**
  43151. * Registers the transient components if needed.
  43152. */
  43153. private _registerTransientComponents;
  43154. /**
  43155. * @hidden
  43156. * Add a component to the scene.
  43157. * Note that the ccomponent could be registered on th next frame if this is called after
  43158. * the register component stage.
  43159. * @param component Defines the component to add to the scene
  43160. */
  43161. _addComponent(component: ISceneComponent): void;
  43162. /**
  43163. * @hidden
  43164. * Gets a component from the scene.
  43165. * @param name defines the name of the component to retrieve
  43166. * @returns the component or null if not present
  43167. */
  43168. _getComponent(name: string): Nullable<ISceneComponent>;
  43169. /**
  43170. * @hidden
  43171. * Defines the actions happening before camera updates.
  43172. */
  43173. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43174. /**
  43175. * @hidden
  43176. * Defines the actions happening before clear the canvas.
  43177. */
  43178. _beforeClearStage: Stage<SimpleStageAction>;
  43179. /**
  43180. * @hidden
  43181. * Defines the actions when collecting render targets for the frame.
  43182. */
  43183. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43184. /**
  43185. * @hidden
  43186. * Defines the actions happening for one camera in the frame.
  43187. */
  43188. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43189. /**
  43190. * @hidden
  43191. * Defines the actions happening during the per mesh ready checks.
  43192. */
  43193. _isReadyForMeshStage: Stage<MeshStageAction>;
  43194. /**
  43195. * @hidden
  43196. * Defines the actions happening before evaluate active mesh checks.
  43197. */
  43198. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43199. /**
  43200. * @hidden
  43201. * Defines the actions happening during the evaluate sub mesh checks.
  43202. */
  43203. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43204. /**
  43205. * @hidden
  43206. * Defines the actions happening during the active mesh stage.
  43207. */
  43208. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43209. /**
  43210. * @hidden
  43211. * Defines the actions happening during the per camera render target step.
  43212. */
  43213. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43214. /**
  43215. * @hidden
  43216. * Defines the actions happening just before the active camera is drawing.
  43217. */
  43218. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43219. /**
  43220. * @hidden
  43221. * Defines the actions happening just before a render target is drawing.
  43222. */
  43223. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43224. /**
  43225. * @hidden
  43226. * Defines the actions happening just before a rendering group is drawing.
  43227. */
  43228. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43229. /**
  43230. * @hidden
  43231. * Defines the actions happening just before a mesh is drawing.
  43232. */
  43233. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43234. /**
  43235. * @hidden
  43236. * Defines the actions happening just after a mesh has been drawn.
  43237. */
  43238. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43239. /**
  43240. * @hidden
  43241. * Defines the actions happening just after a rendering group has been drawn.
  43242. */
  43243. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43244. /**
  43245. * @hidden
  43246. * Defines the actions happening just after the active camera has been drawn.
  43247. */
  43248. _afterCameraDrawStage: Stage<CameraStageAction>;
  43249. /**
  43250. * @hidden
  43251. * Defines the actions happening just after a render target has been drawn.
  43252. */
  43253. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43254. /**
  43255. * @hidden
  43256. * Defines the actions happening just after rendering all cameras and computing intersections.
  43257. */
  43258. _afterRenderStage: Stage<SimpleStageAction>;
  43259. /**
  43260. * @hidden
  43261. * Defines the actions happening when a pointer move event happens.
  43262. */
  43263. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43264. /**
  43265. * @hidden
  43266. * Defines the actions happening when a pointer down event happens.
  43267. */
  43268. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43269. /**
  43270. * @hidden
  43271. * Defines the actions happening when a pointer up event happens.
  43272. */
  43273. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43274. /**
  43275. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43276. */
  43277. private geometriesByUniqueId;
  43278. /**
  43279. * Creates a new Scene
  43280. * @param engine defines the engine to use to render this scene
  43281. * @param options defines the scene options
  43282. */
  43283. constructor(engine: Engine, options?: SceneOptions);
  43284. /**
  43285. * Gets a string identifying the name of the class
  43286. * @returns "Scene" string
  43287. */
  43288. getClassName(): string;
  43289. private _defaultMeshCandidates;
  43290. /**
  43291. * @hidden
  43292. */
  43293. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43294. private _defaultSubMeshCandidates;
  43295. /**
  43296. * @hidden
  43297. */
  43298. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43299. /**
  43300. * Sets the default candidate providers for the scene.
  43301. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43302. * and getCollidingSubMeshCandidates to their default function
  43303. */
  43304. setDefaultCandidateProviders(): void;
  43305. /**
  43306. * Gets the mesh that is currently under the pointer
  43307. */
  43308. get meshUnderPointer(): Nullable<AbstractMesh>;
  43309. /**
  43310. * Gets or sets the current on-screen X position of the pointer
  43311. */
  43312. get pointerX(): number;
  43313. set pointerX(value: number);
  43314. /**
  43315. * Gets or sets the current on-screen Y position of the pointer
  43316. */
  43317. get pointerY(): number;
  43318. set pointerY(value: number);
  43319. /**
  43320. * Gets the cached material (ie. the latest rendered one)
  43321. * @returns the cached material
  43322. */
  43323. getCachedMaterial(): Nullable<Material>;
  43324. /**
  43325. * Gets the cached effect (ie. the latest rendered one)
  43326. * @returns the cached effect
  43327. */
  43328. getCachedEffect(): Nullable<Effect>;
  43329. /**
  43330. * Gets the cached visibility state (ie. the latest rendered one)
  43331. * @returns the cached visibility state
  43332. */
  43333. getCachedVisibility(): Nullable<number>;
  43334. /**
  43335. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43336. * @param material defines the current material
  43337. * @param effect defines the current effect
  43338. * @param visibility defines the current visibility state
  43339. * @returns true if one parameter is not cached
  43340. */
  43341. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43342. /**
  43343. * Gets the engine associated with the scene
  43344. * @returns an Engine
  43345. */
  43346. getEngine(): Engine;
  43347. /**
  43348. * Gets the total number of vertices rendered per frame
  43349. * @returns the total number of vertices rendered per frame
  43350. */
  43351. getTotalVertices(): number;
  43352. /**
  43353. * Gets the performance counter for total vertices
  43354. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43355. */
  43356. get totalVerticesPerfCounter(): PerfCounter;
  43357. /**
  43358. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43359. * @returns the total number of active indices rendered per frame
  43360. */
  43361. getActiveIndices(): number;
  43362. /**
  43363. * Gets the performance counter for active indices
  43364. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43365. */
  43366. get totalActiveIndicesPerfCounter(): PerfCounter;
  43367. /**
  43368. * Gets the total number of active particles rendered per frame
  43369. * @returns the total number of active particles rendered per frame
  43370. */
  43371. getActiveParticles(): number;
  43372. /**
  43373. * Gets the performance counter for active particles
  43374. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43375. */
  43376. get activeParticlesPerfCounter(): PerfCounter;
  43377. /**
  43378. * Gets the total number of active bones rendered per frame
  43379. * @returns the total number of active bones rendered per frame
  43380. */
  43381. getActiveBones(): number;
  43382. /**
  43383. * Gets the performance counter for active bones
  43384. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43385. */
  43386. get activeBonesPerfCounter(): PerfCounter;
  43387. /**
  43388. * Gets the array of active meshes
  43389. * @returns an array of AbstractMesh
  43390. */
  43391. getActiveMeshes(): SmartArray<AbstractMesh>;
  43392. /**
  43393. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43394. * @returns a number
  43395. */
  43396. getAnimationRatio(): number;
  43397. /**
  43398. * Gets an unique Id for the current render phase
  43399. * @returns a number
  43400. */
  43401. getRenderId(): number;
  43402. /**
  43403. * Gets an unique Id for the current frame
  43404. * @returns a number
  43405. */
  43406. getFrameId(): number;
  43407. /** Call this function if you want to manually increment the render Id*/
  43408. incrementRenderId(): void;
  43409. private _createUbo;
  43410. /**
  43411. * Use this method to simulate a pointer move on a mesh
  43412. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43413. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43414. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43415. * @returns the current scene
  43416. */
  43417. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43418. /**
  43419. * Use this method to simulate a pointer down on a mesh
  43420. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43421. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43422. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43423. * @returns the current scene
  43424. */
  43425. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43426. /**
  43427. * Use this method to simulate a pointer up on a mesh
  43428. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43429. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43430. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43431. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43432. * @returns the current scene
  43433. */
  43434. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43435. /**
  43436. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43437. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43438. * @returns true if the pointer was captured
  43439. */
  43440. isPointerCaptured(pointerId?: number): boolean;
  43441. /**
  43442. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43443. * @param attachUp defines if you want to attach events to pointerup
  43444. * @param attachDown defines if you want to attach events to pointerdown
  43445. * @param attachMove defines if you want to attach events to pointermove
  43446. */
  43447. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43448. /** Detaches all event handlers*/
  43449. detachControl(): void;
  43450. /**
  43451. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43452. * Delay loaded resources are not taking in account
  43453. * @return true if all required resources are ready
  43454. */
  43455. isReady(): boolean;
  43456. /** Resets all cached information relative to material (including effect and visibility) */
  43457. resetCachedMaterial(): void;
  43458. /**
  43459. * Registers a function to be called before every frame render
  43460. * @param func defines the function to register
  43461. */
  43462. registerBeforeRender(func: () => void): void;
  43463. /**
  43464. * Unregisters a function called before every frame render
  43465. * @param func defines the function to unregister
  43466. */
  43467. unregisterBeforeRender(func: () => void): void;
  43468. /**
  43469. * Registers a function to be called after every frame render
  43470. * @param func defines the function to register
  43471. */
  43472. registerAfterRender(func: () => void): void;
  43473. /**
  43474. * Unregisters a function called after every frame render
  43475. * @param func defines the function to unregister
  43476. */
  43477. unregisterAfterRender(func: () => void): void;
  43478. private _executeOnceBeforeRender;
  43479. /**
  43480. * The provided function will run before render once and will be disposed afterwards.
  43481. * A timeout delay can be provided so that the function will be executed in N ms.
  43482. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43483. * @param func The function to be executed.
  43484. * @param timeout optional delay in ms
  43485. */
  43486. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43487. /** @hidden */
  43488. _addPendingData(data: any): void;
  43489. /** @hidden */
  43490. _removePendingData(data: any): void;
  43491. /**
  43492. * Returns the number of items waiting to be loaded
  43493. * @returns the number of items waiting to be loaded
  43494. */
  43495. getWaitingItemsCount(): number;
  43496. /**
  43497. * Returns a boolean indicating if the scene is still loading data
  43498. */
  43499. get isLoading(): boolean;
  43500. /**
  43501. * Registers a function to be executed when the scene is ready
  43502. * @param {Function} func - the function to be executed
  43503. */
  43504. executeWhenReady(func: () => void): void;
  43505. /**
  43506. * Returns a promise that resolves when the scene is ready
  43507. * @returns A promise that resolves when the scene is ready
  43508. */
  43509. whenReadyAsync(): Promise<void>;
  43510. /** @hidden */
  43511. _checkIsReady(): void;
  43512. /**
  43513. * Gets all animatable attached to the scene
  43514. */
  43515. get animatables(): Animatable[];
  43516. /**
  43517. * Resets the last animation time frame.
  43518. * Useful to override when animations start running when loading a scene for the first time.
  43519. */
  43520. resetLastAnimationTimeFrame(): void;
  43521. /**
  43522. * Gets the current view matrix
  43523. * @returns a Matrix
  43524. */
  43525. getViewMatrix(): Matrix;
  43526. /**
  43527. * Gets the current projection matrix
  43528. * @returns a Matrix
  43529. */
  43530. getProjectionMatrix(): Matrix;
  43531. /**
  43532. * Gets the current transform matrix
  43533. * @returns a Matrix made of View * Projection
  43534. */
  43535. getTransformMatrix(): Matrix;
  43536. /**
  43537. * Sets the current transform matrix
  43538. * @param viewL defines the View matrix to use
  43539. * @param projectionL defines the Projection matrix to use
  43540. * @param viewR defines the right View matrix to use (if provided)
  43541. * @param projectionR defines the right Projection matrix to use (if provided)
  43542. */
  43543. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43544. /**
  43545. * Gets the uniform buffer used to store scene data
  43546. * @returns a UniformBuffer
  43547. */
  43548. getSceneUniformBuffer(): UniformBuffer;
  43549. /**
  43550. * Gets an unique (relatively to the current scene) Id
  43551. * @returns an unique number for the scene
  43552. */
  43553. getUniqueId(): number;
  43554. /**
  43555. * Add a mesh to the list of scene's meshes
  43556. * @param newMesh defines the mesh to add
  43557. * @param recursive if all child meshes should also be added to the scene
  43558. */
  43559. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43560. /**
  43561. * Remove a mesh for the list of scene's meshes
  43562. * @param toRemove defines the mesh to remove
  43563. * @param recursive if all child meshes should also be removed from the scene
  43564. * @returns the index where the mesh was in the mesh list
  43565. */
  43566. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43567. /**
  43568. * Add a transform node to the list of scene's transform nodes
  43569. * @param newTransformNode defines the transform node to add
  43570. */
  43571. addTransformNode(newTransformNode: TransformNode): void;
  43572. /**
  43573. * Remove a transform node for the list of scene's transform nodes
  43574. * @param toRemove defines the transform node to remove
  43575. * @returns the index where the transform node was in the transform node list
  43576. */
  43577. removeTransformNode(toRemove: TransformNode): number;
  43578. /**
  43579. * Remove a skeleton for the list of scene's skeletons
  43580. * @param toRemove defines the skeleton to remove
  43581. * @returns the index where the skeleton was in the skeleton list
  43582. */
  43583. removeSkeleton(toRemove: Skeleton): number;
  43584. /**
  43585. * Remove a morph target for the list of scene's morph targets
  43586. * @param toRemove defines the morph target to remove
  43587. * @returns the index where the morph target was in the morph target list
  43588. */
  43589. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43590. /**
  43591. * Remove a light for the list of scene's lights
  43592. * @param toRemove defines the light to remove
  43593. * @returns the index where the light was in the light list
  43594. */
  43595. removeLight(toRemove: Light): number;
  43596. /**
  43597. * Remove a camera for the list of scene's cameras
  43598. * @param toRemove defines the camera to remove
  43599. * @returns the index where the camera was in the camera list
  43600. */
  43601. removeCamera(toRemove: Camera): number;
  43602. /**
  43603. * Remove a particle system for the list of scene's particle systems
  43604. * @param toRemove defines the particle system to remove
  43605. * @returns the index where the particle system was in the particle system list
  43606. */
  43607. removeParticleSystem(toRemove: IParticleSystem): number;
  43608. /**
  43609. * Remove a animation for the list of scene's animations
  43610. * @param toRemove defines the animation to remove
  43611. * @returns the index where the animation was in the animation list
  43612. */
  43613. removeAnimation(toRemove: Animation): number;
  43614. /**
  43615. * Will stop the animation of the given target
  43616. * @param target - the target
  43617. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43618. * @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)
  43619. */
  43620. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43621. /**
  43622. * Removes the given animation group from this scene.
  43623. * @param toRemove The animation group to remove
  43624. * @returns The index of the removed animation group
  43625. */
  43626. removeAnimationGroup(toRemove: AnimationGroup): number;
  43627. /**
  43628. * Removes the given multi-material from this scene.
  43629. * @param toRemove The multi-material to remove
  43630. * @returns The index of the removed multi-material
  43631. */
  43632. removeMultiMaterial(toRemove: MultiMaterial): number;
  43633. /**
  43634. * Removes the given material from this scene.
  43635. * @param toRemove The material to remove
  43636. * @returns The index of the removed material
  43637. */
  43638. removeMaterial(toRemove: Material): number;
  43639. /**
  43640. * Removes the given action manager from this scene.
  43641. * @param toRemove The action manager to remove
  43642. * @returns The index of the removed action manager
  43643. */
  43644. removeActionManager(toRemove: AbstractActionManager): number;
  43645. /**
  43646. * Removes the given texture from this scene.
  43647. * @param toRemove The texture to remove
  43648. * @returns The index of the removed texture
  43649. */
  43650. removeTexture(toRemove: BaseTexture): number;
  43651. /**
  43652. * Adds the given light to this scene
  43653. * @param newLight The light to add
  43654. */
  43655. addLight(newLight: Light): void;
  43656. /**
  43657. * Sorts the list list based on light priorities
  43658. */
  43659. sortLightsByPriority(): void;
  43660. /**
  43661. * Adds the given camera to this scene
  43662. * @param newCamera The camera to add
  43663. */
  43664. addCamera(newCamera: Camera): void;
  43665. /**
  43666. * Adds the given skeleton to this scene
  43667. * @param newSkeleton The skeleton to add
  43668. */
  43669. addSkeleton(newSkeleton: Skeleton): void;
  43670. /**
  43671. * Adds the given particle system to this scene
  43672. * @param newParticleSystem The particle system to add
  43673. */
  43674. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43675. /**
  43676. * Adds the given animation to this scene
  43677. * @param newAnimation The animation to add
  43678. */
  43679. addAnimation(newAnimation: Animation): void;
  43680. /**
  43681. * Adds the given animation group to this scene.
  43682. * @param newAnimationGroup The animation group to add
  43683. */
  43684. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43685. /**
  43686. * Adds the given multi-material to this scene
  43687. * @param newMultiMaterial The multi-material to add
  43688. */
  43689. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43690. /**
  43691. * Adds the given material to this scene
  43692. * @param newMaterial The material to add
  43693. */
  43694. addMaterial(newMaterial: Material): void;
  43695. /**
  43696. * Adds the given morph target to this scene
  43697. * @param newMorphTargetManager The morph target to add
  43698. */
  43699. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43700. /**
  43701. * Adds the given geometry to this scene
  43702. * @param newGeometry The geometry to add
  43703. */
  43704. addGeometry(newGeometry: Geometry): void;
  43705. /**
  43706. * Adds the given action manager to this scene
  43707. * @param newActionManager The action manager to add
  43708. */
  43709. addActionManager(newActionManager: AbstractActionManager): void;
  43710. /**
  43711. * Adds the given texture to this scene.
  43712. * @param newTexture The texture to add
  43713. */
  43714. addTexture(newTexture: BaseTexture): void;
  43715. /**
  43716. * Switch active camera
  43717. * @param newCamera defines the new active camera
  43718. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43719. */
  43720. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43721. /**
  43722. * sets the active camera of the scene using its ID
  43723. * @param id defines the camera's ID
  43724. * @return the new active camera or null if none found.
  43725. */
  43726. setActiveCameraByID(id: string): Nullable<Camera>;
  43727. /**
  43728. * sets the active camera of the scene using its name
  43729. * @param name defines the camera's name
  43730. * @returns the new active camera or null if none found.
  43731. */
  43732. setActiveCameraByName(name: string): Nullable<Camera>;
  43733. /**
  43734. * get an animation group using its name
  43735. * @param name defines the material's name
  43736. * @return the animation group or null if none found.
  43737. */
  43738. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  43739. /**
  43740. * Get a material using its unique id
  43741. * @param uniqueId defines the material's unique id
  43742. * @return the material or null if none found.
  43743. */
  43744. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  43745. /**
  43746. * get a material using its id
  43747. * @param id defines the material's ID
  43748. * @return the material or null if none found.
  43749. */
  43750. getMaterialByID(id: string): Nullable<Material>;
  43751. /**
  43752. * Gets a the last added material using a given id
  43753. * @param id defines the material's ID
  43754. * @return the last material with the given id or null if none found.
  43755. */
  43756. getLastMaterialByID(id: string): Nullable<Material>;
  43757. /**
  43758. * Gets a material using its name
  43759. * @param name defines the material's name
  43760. * @return the material or null if none found.
  43761. */
  43762. getMaterialByName(name: string): Nullable<Material>;
  43763. /**
  43764. * Get a texture using its unique id
  43765. * @param uniqueId defines the texture's unique id
  43766. * @return the texture or null if none found.
  43767. */
  43768. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  43769. /**
  43770. * Gets a camera using its id
  43771. * @param id defines the id to look for
  43772. * @returns the camera or null if not found
  43773. */
  43774. getCameraByID(id: string): Nullable<Camera>;
  43775. /**
  43776. * Gets a camera using its unique id
  43777. * @param uniqueId defines the unique id to look for
  43778. * @returns the camera or null if not found
  43779. */
  43780. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  43781. /**
  43782. * Gets a camera using its name
  43783. * @param name defines the camera's name
  43784. * @return the camera or null if none found.
  43785. */
  43786. getCameraByName(name: string): Nullable<Camera>;
  43787. /**
  43788. * Gets a bone using its id
  43789. * @param id defines the bone's id
  43790. * @return the bone or null if not found
  43791. */
  43792. getBoneByID(id: string): Nullable<Bone>;
  43793. /**
  43794. * Gets a bone using its id
  43795. * @param name defines the bone's name
  43796. * @return the bone or null if not found
  43797. */
  43798. getBoneByName(name: string): Nullable<Bone>;
  43799. /**
  43800. * Gets a light node using its name
  43801. * @param name defines the the light's name
  43802. * @return the light or null if none found.
  43803. */
  43804. getLightByName(name: string): Nullable<Light>;
  43805. /**
  43806. * Gets a light node using its id
  43807. * @param id defines the light's id
  43808. * @return the light or null if none found.
  43809. */
  43810. getLightByID(id: string): Nullable<Light>;
  43811. /**
  43812. * Gets a light node using its scene-generated unique ID
  43813. * @param uniqueId defines the light's unique id
  43814. * @return the light or null if none found.
  43815. */
  43816. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  43817. /**
  43818. * Gets a particle system by id
  43819. * @param id defines the particle system id
  43820. * @return the corresponding system or null if none found
  43821. */
  43822. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  43823. /**
  43824. * Gets a geometry using its ID
  43825. * @param id defines the geometry's id
  43826. * @return the geometry or null if none found.
  43827. */
  43828. getGeometryByID(id: string): Nullable<Geometry>;
  43829. private _getGeometryByUniqueID;
  43830. /**
  43831. * Add a new geometry to this scene
  43832. * @param geometry defines the geometry to be added to the scene.
  43833. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  43834. * @return a boolean defining if the geometry was added or not
  43835. */
  43836. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  43837. /**
  43838. * Removes an existing geometry
  43839. * @param geometry defines the geometry to be removed from the scene
  43840. * @return a boolean defining if the geometry was removed or not
  43841. */
  43842. removeGeometry(geometry: Geometry): boolean;
  43843. /**
  43844. * Gets the list of geometries attached to the scene
  43845. * @returns an array of Geometry
  43846. */
  43847. getGeometries(): Geometry[];
  43848. /**
  43849. * Gets the first added mesh found of a given ID
  43850. * @param id defines the id to search for
  43851. * @return the mesh found or null if not found at all
  43852. */
  43853. getMeshByID(id: string): Nullable<AbstractMesh>;
  43854. /**
  43855. * Gets a list of meshes using their id
  43856. * @param id defines the id to search for
  43857. * @returns a list of meshes
  43858. */
  43859. getMeshesByID(id: string): Array<AbstractMesh>;
  43860. /**
  43861. * Gets the first added transform node found of a given ID
  43862. * @param id defines the id to search for
  43863. * @return the found transform node or null if not found at all.
  43864. */
  43865. getTransformNodeByID(id: string): Nullable<TransformNode>;
  43866. /**
  43867. * Gets a transform node with its auto-generated unique id
  43868. * @param uniqueId efines the unique id to search for
  43869. * @return the found transform node or null if not found at all.
  43870. */
  43871. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  43872. /**
  43873. * Gets a list of transform nodes using their id
  43874. * @param id defines the id to search for
  43875. * @returns a list of transform nodes
  43876. */
  43877. getTransformNodesByID(id: string): Array<TransformNode>;
  43878. /**
  43879. * Gets a mesh with its auto-generated unique id
  43880. * @param uniqueId defines the unique id to search for
  43881. * @return the found mesh or null if not found at all.
  43882. */
  43883. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  43884. /**
  43885. * Gets a the last added mesh using a given id
  43886. * @param id defines the id to search for
  43887. * @return the found mesh or null if not found at all.
  43888. */
  43889. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  43890. /**
  43891. * Gets a the last added node (Mesh, Camera, Light) using a given id
  43892. * @param id defines the id to search for
  43893. * @return the found node or null if not found at all
  43894. */
  43895. getLastEntryByID(id: string): Nullable<Node>;
  43896. /**
  43897. * Gets a node (Mesh, Camera, Light) using a given id
  43898. * @param id defines the id to search for
  43899. * @return the found node or null if not found at all
  43900. */
  43901. getNodeByID(id: string): Nullable<Node>;
  43902. /**
  43903. * Gets a node (Mesh, Camera, Light) using a given name
  43904. * @param name defines the name to search for
  43905. * @return the found node or null if not found at all.
  43906. */
  43907. getNodeByName(name: string): Nullable<Node>;
  43908. /**
  43909. * Gets a mesh using a given name
  43910. * @param name defines the name to search for
  43911. * @return the found mesh or null if not found at all.
  43912. */
  43913. getMeshByName(name: string): Nullable<AbstractMesh>;
  43914. /**
  43915. * Gets a transform node using a given name
  43916. * @param name defines the name to search for
  43917. * @return the found transform node or null if not found at all.
  43918. */
  43919. getTransformNodeByName(name: string): Nullable<TransformNode>;
  43920. /**
  43921. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  43922. * @param id defines the id to search for
  43923. * @return the found skeleton or null if not found at all.
  43924. */
  43925. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  43926. /**
  43927. * Gets a skeleton using a given auto generated unique id
  43928. * @param uniqueId defines the unique id to search for
  43929. * @return the found skeleton or null if not found at all.
  43930. */
  43931. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  43932. /**
  43933. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  43934. * @param id defines the id to search for
  43935. * @return the found skeleton or null if not found at all.
  43936. */
  43937. getSkeletonById(id: string): Nullable<Skeleton>;
  43938. /**
  43939. * Gets a skeleton using a given name
  43940. * @param name defines the name to search for
  43941. * @return the found skeleton or null if not found at all.
  43942. */
  43943. getSkeletonByName(name: string): Nullable<Skeleton>;
  43944. /**
  43945. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  43946. * @param id defines the id to search for
  43947. * @return the found morph target manager or null if not found at all.
  43948. */
  43949. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  43950. /**
  43951. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  43952. * @param id defines the id to search for
  43953. * @return the found morph target or null if not found at all.
  43954. */
  43955. getMorphTargetById(id: string): Nullable<MorphTarget>;
  43956. /**
  43957. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  43958. * @param name defines the name to search for
  43959. * @return the found morph target or null if not found at all.
  43960. */
  43961. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  43962. /**
  43963. * Gets a post process using a given name (if many are found, this function will pick the first one)
  43964. * @param name defines the name to search for
  43965. * @return the found post process or null if not found at all.
  43966. */
  43967. getPostProcessByName(name: string): Nullable<PostProcess>;
  43968. /**
  43969. * Gets a boolean indicating if the given mesh is active
  43970. * @param mesh defines the mesh to look for
  43971. * @returns true if the mesh is in the active list
  43972. */
  43973. isActiveMesh(mesh: AbstractMesh): boolean;
  43974. /**
  43975. * Return a unique id as a string which can serve as an identifier for the scene
  43976. */
  43977. get uid(): string;
  43978. /**
  43979. * Add an externaly attached data from its key.
  43980. * This method call will fail and return false, if such key already exists.
  43981. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  43982. * @param key the unique key that identifies the data
  43983. * @param data the data object to associate to the key for this Engine instance
  43984. * @return true if no such key were already present and the data was added successfully, false otherwise
  43985. */
  43986. addExternalData<T>(key: string, data: T): boolean;
  43987. /**
  43988. * Get an externaly attached data from its key
  43989. * @param key the unique key that identifies the data
  43990. * @return the associated data, if present (can be null), or undefined if not present
  43991. */
  43992. getExternalData<T>(key: string): Nullable<T>;
  43993. /**
  43994. * Get an externaly attached data from its key, create it using a factory if it's not already present
  43995. * @param key the unique key that identifies the data
  43996. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  43997. * @return the associated data, can be null if the factory returned null.
  43998. */
  43999. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44000. /**
  44001. * Remove an externaly attached data from the Engine instance
  44002. * @param key the unique key that identifies the data
  44003. * @return true if the data was successfully removed, false if it doesn't exist
  44004. */
  44005. removeExternalData(key: string): boolean;
  44006. private _evaluateSubMesh;
  44007. /**
  44008. * Clear the processed materials smart array preventing retention point in material dispose.
  44009. */
  44010. freeProcessedMaterials(): void;
  44011. private _preventFreeActiveMeshesAndRenderingGroups;
  44012. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44013. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44014. * when disposing several meshes in a row or a hierarchy of meshes.
  44015. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44016. */
  44017. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44018. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44019. /**
  44020. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44021. */
  44022. freeActiveMeshes(): void;
  44023. /**
  44024. * Clear the info related to rendering groups preventing retention points during dispose.
  44025. */
  44026. freeRenderingGroups(): void;
  44027. /** @hidden */
  44028. _isInIntermediateRendering(): boolean;
  44029. /**
  44030. * Lambda returning the list of potentially active meshes.
  44031. */
  44032. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44033. /**
  44034. * Lambda returning the list of potentially active sub meshes.
  44035. */
  44036. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44037. /**
  44038. * Lambda returning the list of potentially intersecting sub meshes.
  44039. */
  44040. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44041. /**
  44042. * Lambda returning the list of potentially colliding sub meshes.
  44043. */
  44044. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44045. private _activeMeshesFrozen;
  44046. private _skipEvaluateActiveMeshesCompletely;
  44047. /**
  44048. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44049. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44050. * @param onSuccess optional success callback
  44051. * @param onError optional error callback
  44052. * @returns the current scene
  44053. */
  44054. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44055. /**
  44056. * Use this function to restart evaluating active meshes on every frame
  44057. * @returns the current scene
  44058. */
  44059. unfreezeActiveMeshes(): Scene;
  44060. private _evaluateActiveMeshes;
  44061. private _activeMesh;
  44062. /**
  44063. * Update the transform matrix to update from the current active camera
  44064. * @param force defines a boolean used to force the update even if cache is up to date
  44065. */
  44066. updateTransformMatrix(force?: boolean): void;
  44067. private _bindFrameBuffer;
  44068. /** @hidden */
  44069. _allowPostProcessClearColor: boolean;
  44070. /** @hidden */
  44071. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44072. private _processSubCameras;
  44073. private _checkIntersections;
  44074. /** @hidden */
  44075. _advancePhysicsEngineStep(step: number): void;
  44076. /**
  44077. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44078. */
  44079. getDeterministicFrameTime: () => number;
  44080. /** @hidden */
  44081. _animate(): void;
  44082. /** Execute all animations (for a frame) */
  44083. animate(): void;
  44084. /**
  44085. * Render the scene
  44086. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44087. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44088. */
  44089. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44090. /**
  44091. * Freeze all materials
  44092. * A frozen material will not be updatable but should be faster to render
  44093. */
  44094. freezeMaterials(): void;
  44095. /**
  44096. * Unfreeze all materials
  44097. * A frozen material will not be updatable but should be faster to render
  44098. */
  44099. unfreezeMaterials(): void;
  44100. /**
  44101. * Releases all held ressources
  44102. */
  44103. dispose(): void;
  44104. /**
  44105. * Gets if the scene is already disposed
  44106. */
  44107. get isDisposed(): boolean;
  44108. /**
  44109. * Call this function to reduce memory footprint of the scene.
  44110. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44111. */
  44112. clearCachedVertexData(): void;
  44113. /**
  44114. * This function will remove the local cached buffer data from texture.
  44115. * It will save memory but will prevent the texture from being rebuilt
  44116. */
  44117. cleanCachedTextureBuffer(): void;
  44118. /**
  44119. * Get the world extend vectors with an optional filter
  44120. *
  44121. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44122. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44123. */
  44124. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44125. min: Vector3;
  44126. max: Vector3;
  44127. };
  44128. /**
  44129. * Creates a ray that can be used to pick in the scene
  44130. * @param x defines the x coordinate of the origin (on-screen)
  44131. * @param y defines the y coordinate of the origin (on-screen)
  44132. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44133. * @param camera defines the camera to use for the picking
  44134. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44135. * @returns a Ray
  44136. */
  44137. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44138. /**
  44139. * Creates a ray that can be used to pick in the scene
  44140. * @param x defines the x coordinate of the origin (on-screen)
  44141. * @param y defines the y coordinate of the origin (on-screen)
  44142. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44143. * @param result defines the ray where to store the picking ray
  44144. * @param camera defines the camera to use for the picking
  44145. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44146. * @returns the current scene
  44147. */
  44148. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44149. /**
  44150. * Creates a ray that can be used to pick in the scene
  44151. * @param x defines the x coordinate of the origin (on-screen)
  44152. * @param y defines the y coordinate of the origin (on-screen)
  44153. * @param camera defines the camera to use for the picking
  44154. * @returns a Ray
  44155. */
  44156. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44157. /**
  44158. * Creates a ray that can be used to pick in the scene
  44159. * @param x defines the x coordinate of the origin (on-screen)
  44160. * @param y defines the y coordinate of the origin (on-screen)
  44161. * @param result defines the ray where to store the picking ray
  44162. * @param camera defines the camera to use for the picking
  44163. * @returns the current scene
  44164. */
  44165. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44166. /** Launch a ray to try to pick a mesh in the scene
  44167. * @param x position on screen
  44168. * @param y position on screen
  44169. * @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
  44170. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44171. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44172. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44173. * @returns a PickingInfo
  44174. */
  44175. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44176. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44177. * @param x position on screen
  44178. * @param y position on screen
  44179. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  44180. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44181. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44182. * @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)
  44183. */
  44184. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44185. /** Use the given ray to pick a mesh in the scene
  44186. * @param ray The ray to use to pick meshes
  44187. * @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
  44188. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44189. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44190. * @returns a PickingInfo
  44191. */
  44192. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44193. /**
  44194. * Launch a ray to try to pick a mesh in the scene
  44195. * @param x X position on screen
  44196. * @param y Y position on screen
  44197. * @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
  44198. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44199. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44200. * @returns an array of PickingInfo
  44201. */
  44202. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44203. /**
  44204. * Launch a ray to try to pick a mesh in the scene
  44205. * @param ray Ray to use
  44206. * @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
  44207. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44208. * @returns an array of PickingInfo
  44209. */
  44210. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44211. /**
  44212. * Force the value of meshUnderPointer
  44213. * @param mesh defines the mesh to use
  44214. * @param pointerId optional pointer id when using more than one pointer
  44215. */
  44216. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44217. /**
  44218. * Gets the mesh under the pointer
  44219. * @returns a Mesh or null if no mesh is under the pointer
  44220. */
  44221. getPointerOverMesh(): Nullable<AbstractMesh>;
  44222. /** @hidden */
  44223. _rebuildGeometries(): void;
  44224. /** @hidden */
  44225. _rebuildTextures(): void;
  44226. private _getByTags;
  44227. /**
  44228. * Get a list of meshes by tags
  44229. * @param tagsQuery defines the tags query to use
  44230. * @param forEach defines a predicate used to filter results
  44231. * @returns an array of Mesh
  44232. */
  44233. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44234. /**
  44235. * Get a list of cameras by tags
  44236. * @param tagsQuery defines the tags query to use
  44237. * @param forEach defines a predicate used to filter results
  44238. * @returns an array of Camera
  44239. */
  44240. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44241. /**
  44242. * Get a list of lights by tags
  44243. * @param tagsQuery defines the tags query to use
  44244. * @param forEach defines a predicate used to filter results
  44245. * @returns an array of Light
  44246. */
  44247. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44248. /**
  44249. * Get a list of materials by tags
  44250. * @param tagsQuery defines the tags query to use
  44251. * @param forEach defines a predicate used to filter results
  44252. * @returns an array of Material
  44253. */
  44254. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44255. /**
  44256. * Get a list of transform nodes by tags
  44257. * @param tagsQuery defines the tags query to use
  44258. * @param forEach defines a predicate used to filter results
  44259. * @returns an array of TransformNode
  44260. */
  44261. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44262. /**
  44263. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44264. * This allowed control for front to back rendering or reversly depending of the special needs.
  44265. *
  44266. * @param renderingGroupId The rendering group id corresponding to its index
  44267. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44268. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44269. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44270. */
  44271. 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;
  44272. /**
  44273. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44274. *
  44275. * @param renderingGroupId The rendering group id corresponding to its index
  44276. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44277. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44278. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44279. */
  44280. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44281. /**
  44282. * Gets the current auto clear configuration for one rendering group of the rendering
  44283. * manager.
  44284. * @param index the rendering group index to get the information for
  44285. * @returns The auto clear setup for the requested rendering group
  44286. */
  44287. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44288. private _blockMaterialDirtyMechanism;
  44289. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44290. get blockMaterialDirtyMechanism(): boolean;
  44291. set blockMaterialDirtyMechanism(value: boolean);
  44292. /**
  44293. * Will flag all materials as dirty to trigger new shader compilation
  44294. * @param flag defines the flag used to specify which material part must be marked as dirty
  44295. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44296. */
  44297. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44298. /** @hidden */
  44299. _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;
  44300. /** @hidden */
  44301. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44302. /** @hidden */
  44303. _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;
  44304. /** @hidden */
  44305. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44306. /** @hidden */
  44307. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44308. /** @hidden */
  44309. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44310. }
  44311. }
  44312. declare module BABYLON {
  44313. /**
  44314. * Set of assets to keep when moving a scene into an asset container.
  44315. */
  44316. export class KeepAssets extends AbstractScene {
  44317. }
  44318. /**
  44319. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44320. */
  44321. export class InstantiatedEntries {
  44322. /**
  44323. * List of new root nodes (eg. nodes with no parent)
  44324. */
  44325. rootNodes: TransformNode[];
  44326. /**
  44327. * List of new skeletons
  44328. */
  44329. skeletons: Skeleton[];
  44330. /**
  44331. * List of new animation groups
  44332. */
  44333. animationGroups: AnimationGroup[];
  44334. }
  44335. /**
  44336. * Container with a set of assets that can be added or removed from a scene.
  44337. */
  44338. export class AssetContainer extends AbstractScene {
  44339. private _wasAddedToScene;
  44340. /**
  44341. * The scene the AssetContainer belongs to.
  44342. */
  44343. scene: Scene;
  44344. /**
  44345. * Instantiates an AssetContainer.
  44346. * @param scene The scene the AssetContainer belongs to.
  44347. */
  44348. constructor(scene: Scene);
  44349. /**
  44350. * Instantiate or clone all meshes and add the new ones to the scene.
  44351. * Skeletons and animation groups will all be cloned
  44352. * @param nameFunction defines an optional function used to get new names for clones
  44353. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44354. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44355. */
  44356. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44357. /**
  44358. * Adds all the assets from the container to the scene.
  44359. */
  44360. addAllToScene(): void;
  44361. /**
  44362. * Removes all the assets in the container from the scene
  44363. */
  44364. removeAllFromScene(): void;
  44365. /**
  44366. * Disposes all the assets in the container
  44367. */
  44368. dispose(): void;
  44369. private _moveAssets;
  44370. /**
  44371. * Removes all the assets contained in the scene and adds them to the container.
  44372. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44373. */
  44374. moveAllFromScene(keepAssets?: KeepAssets): void;
  44375. /**
  44376. * 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.
  44377. * @returns the root mesh
  44378. */
  44379. createRootMesh(): Mesh;
  44380. /**
  44381. * Merge animations (direct and animation groups) from this asset container into a scene
  44382. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44383. * @param animatables set of animatables to retarget to a node from the scene
  44384. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44385. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44386. */
  44387. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44388. }
  44389. }
  44390. declare module BABYLON {
  44391. /**
  44392. * Defines how the parser contract is defined.
  44393. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44394. */
  44395. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44396. /**
  44397. * Defines how the individual parser contract is defined.
  44398. * These parser can parse an individual asset
  44399. */
  44400. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44401. /**
  44402. * Base class of the scene acting as a container for the different elements composing a scene.
  44403. * This class is dynamically extended by the different components of the scene increasing
  44404. * flexibility and reducing coupling
  44405. */
  44406. export abstract class AbstractScene {
  44407. /**
  44408. * Stores the list of available parsers in the application.
  44409. */
  44410. private static _BabylonFileParsers;
  44411. /**
  44412. * Stores the list of available individual parsers in the application.
  44413. */
  44414. private static _IndividualBabylonFileParsers;
  44415. /**
  44416. * Adds a parser in the list of available ones
  44417. * @param name Defines the name of the parser
  44418. * @param parser Defines the parser to add
  44419. */
  44420. static AddParser(name: string, parser: BabylonFileParser): void;
  44421. /**
  44422. * Gets a general parser from the list of avaialble ones
  44423. * @param name Defines the name of the parser
  44424. * @returns the requested parser or null
  44425. */
  44426. static GetParser(name: string): Nullable<BabylonFileParser>;
  44427. /**
  44428. * Adds n individual parser in the list of available ones
  44429. * @param name Defines the name of the parser
  44430. * @param parser Defines the parser to add
  44431. */
  44432. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44433. /**
  44434. * Gets an individual parser from the list of avaialble ones
  44435. * @param name Defines the name of the parser
  44436. * @returns the requested parser or null
  44437. */
  44438. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44439. /**
  44440. * Parser json data and populate both a scene and its associated container object
  44441. * @param jsonData Defines the data to parse
  44442. * @param scene Defines the scene to parse the data for
  44443. * @param container Defines the container attached to the parsing sequence
  44444. * @param rootUrl Defines the root url of the data
  44445. */
  44446. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44447. /**
  44448. * Gets the list of root nodes (ie. nodes with no parent)
  44449. */
  44450. rootNodes: Node[];
  44451. /** All of the cameras added to this scene
  44452. * @see https://doc.babylonjs.com/babylon101/cameras
  44453. */
  44454. cameras: Camera[];
  44455. /**
  44456. * All of the lights added to this scene
  44457. * @see https://doc.babylonjs.com/babylon101/lights
  44458. */
  44459. lights: Light[];
  44460. /**
  44461. * All of the (abstract) meshes added to this scene
  44462. */
  44463. meshes: AbstractMesh[];
  44464. /**
  44465. * The list of skeletons added to the scene
  44466. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44467. */
  44468. skeletons: Skeleton[];
  44469. /**
  44470. * All of the particle systems added to this scene
  44471. * @see https://doc.babylonjs.com/babylon101/particles
  44472. */
  44473. particleSystems: IParticleSystem[];
  44474. /**
  44475. * Gets a list of Animations associated with the scene
  44476. */
  44477. animations: Animation[];
  44478. /**
  44479. * All of the animation groups added to this scene
  44480. * @see https://doc.babylonjs.com/how_to/group
  44481. */
  44482. animationGroups: AnimationGroup[];
  44483. /**
  44484. * All of the multi-materials added to this scene
  44485. * @see https://doc.babylonjs.com/how_to/multi_materials
  44486. */
  44487. multiMaterials: MultiMaterial[];
  44488. /**
  44489. * All of the materials added to this scene
  44490. * In the context of a Scene, it is not supposed to be modified manually.
  44491. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44492. * Note also that the order of the Material within the array is not significant and might change.
  44493. * @see https://doc.babylonjs.com/babylon101/materials
  44494. */
  44495. materials: Material[];
  44496. /**
  44497. * The list of morph target managers added to the scene
  44498. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44499. */
  44500. morphTargetManagers: MorphTargetManager[];
  44501. /**
  44502. * The list of geometries used in the scene.
  44503. */
  44504. geometries: Geometry[];
  44505. /**
  44506. * All of the tranform nodes added to this scene
  44507. * In the context of a Scene, it is not supposed to be modified manually.
  44508. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44509. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44510. * @see https://doc.babylonjs.com/how_to/transformnode
  44511. */
  44512. transformNodes: TransformNode[];
  44513. /**
  44514. * ActionManagers available on the scene.
  44515. */
  44516. actionManagers: AbstractActionManager[];
  44517. /**
  44518. * Textures to keep.
  44519. */
  44520. textures: BaseTexture[];
  44521. /** @hidden */
  44522. protected _environmentTexture: Nullable<BaseTexture>;
  44523. /**
  44524. * Texture used in all pbr material as the reflection texture.
  44525. * As in the majority of the scene they are the same (exception for multi room and so on),
  44526. * this is easier to reference from here than from all the materials.
  44527. */
  44528. get environmentTexture(): Nullable<BaseTexture>;
  44529. set environmentTexture(value: Nullable<BaseTexture>);
  44530. /**
  44531. * The list of postprocesses added to the scene
  44532. */
  44533. postProcesses: PostProcess[];
  44534. /**
  44535. * @returns all meshes, lights, cameras, transformNodes and bones
  44536. */
  44537. getNodes(): Array<Node>;
  44538. }
  44539. }
  44540. declare module BABYLON {
  44541. /**
  44542. * Interface used to define options for Sound class
  44543. */
  44544. export interface ISoundOptions {
  44545. /**
  44546. * Does the sound autoplay once loaded.
  44547. */
  44548. autoplay?: boolean;
  44549. /**
  44550. * Does the sound loop after it finishes playing once.
  44551. */
  44552. loop?: boolean;
  44553. /**
  44554. * Sound's volume
  44555. */
  44556. volume?: number;
  44557. /**
  44558. * Is it a spatial sound?
  44559. */
  44560. spatialSound?: boolean;
  44561. /**
  44562. * Maximum distance to hear that sound
  44563. */
  44564. maxDistance?: number;
  44565. /**
  44566. * Uses user defined attenuation function
  44567. */
  44568. useCustomAttenuation?: boolean;
  44569. /**
  44570. * Define the roll off factor of spatial sounds.
  44571. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44572. */
  44573. rolloffFactor?: number;
  44574. /**
  44575. * Define the reference distance the sound should be heard perfectly.
  44576. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44577. */
  44578. refDistance?: number;
  44579. /**
  44580. * Define the distance attenuation model the sound will follow.
  44581. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44582. */
  44583. distanceModel?: string;
  44584. /**
  44585. * Defines the playback speed (1 by default)
  44586. */
  44587. playbackRate?: number;
  44588. /**
  44589. * Defines if the sound is from a streaming source
  44590. */
  44591. streaming?: boolean;
  44592. /**
  44593. * Defines an optional length (in seconds) inside the sound file
  44594. */
  44595. length?: number;
  44596. /**
  44597. * Defines an optional offset (in seconds) inside the sound file
  44598. */
  44599. offset?: number;
  44600. /**
  44601. * If true, URLs will not be required to state the audio file codec to use.
  44602. */
  44603. skipCodecCheck?: boolean;
  44604. }
  44605. /**
  44606. * Defines a sound that can be played in the application.
  44607. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44608. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44609. */
  44610. export class Sound {
  44611. /**
  44612. * The name of the sound in the scene.
  44613. */
  44614. name: string;
  44615. /**
  44616. * Does the sound autoplay once loaded.
  44617. */
  44618. autoplay: boolean;
  44619. /**
  44620. * Does the sound loop after it finishes playing once.
  44621. */
  44622. loop: boolean;
  44623. /**
  44624. * Does the sound use a custom attenuation curve to simulate the falloff
  44625. * happening when the source gets further away from the camera.
  44626. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44627. */
  44628. useCustomAttenuation: boolean;
  44629. /**
  44630. * The sound track id this sound belongs to.
  44631. */
  44632. soundTrackId: number;
  44633. /**
  44634. * Is this sound currently played.
  44635. */
  44636. isPlaying: boolean;
  44637. /**
  44638. * Is this sound currently paused.
  44639. */
  44640. isPaused: boolean;
  44641. /**
  44642. * Does this sound enables spatial sound.
  44643. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44644. */
  44645. spatialSound: boolean;
  44646. /**
  44647. * Define the reference distance the sound should be heard perfectly.
  44648. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44649. */
  44650. refDistance: number;
  44651. /**
  44652. * Define the roll off factor of spatial sounds.
  44653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44654. */
  44655. rolloffFactor: number;
  44656. /**
  44657. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44658. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44659. */
  44660. maxDistance: number;
  44661. /**
  44662. * Define the distance attenuation model the sound will follow.
  44663. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44664. */
  44665. distanceModel: string;
  44666. /**
  44667. * @hidden
  44668. * Back Compat
  44669. **/
  44670. onended: () => any;
  44671. /**
  44672. * Gets or sets an object used to store user defined information for the sound.
  44673. */
  44674. metadata: any;
  44675. /**
  44676. * Observable event when the current playing sound finishes.
  44677. */
  44678. onEndedObservable: Observable<Sound>;
  44679. private _panningModel;
  44680. private _playbackRate;
  44681. private _streaming;
  44682. private _startTime;
  44683. private _startOffset;
  44684. private _position;
  44685. /** @hidden */
  44686. _positionInEmitterSpace: boolean;
  44687. private _localDirection;
  44688. private _volume;
  44689. private _isReadyToPlay;
  44690. private _isDirectional;
  44691. private _readyToPlayCallback;
  44692. private _audioBuffer;
  44693. private _soundSource;
  44694. private _streamingSource;
  44695. private _soundPanner;
  44696. private _soundGain;
  44697. private _inputAudioNode;
  44698. private _outputAudioNode;
  44699. private _coneInnerAngle;
  44700. private _coneOuterAngle;
  44701. private _coneOuterGain;
  44702. private _scene;
  44703. private _connectedTransformNode;
  44704. private _customAttenuationFunction;
  44705. private _registerFunc;
  44706. private _isOutputConnected;
  44707. private _htmlAudioElement;
  44708. private _urlType;
  44709. private _length?;
  44710. private _offset?;
  44711. /** @hidden */
  44712. static _SceneComponentInitialization: (scene: Scene) => void;
  44713. /**
  44714. * Create a sound and attach it to a scene
  44715. * @param name Name of your sound
  44716. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44717. * @param scene defines the scene the sound belongs to
  44718. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44719. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44720. */
  44721. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44722. /**
  44723. * Release the sound and its associated resources
  44724. */
  44725. dispose(): void;
  44726. /**
  44727. * Gets if the sounds is ready to be played or not.
  44728. * @returns true if ready, otherwise false
  44729. */
  44730. isReady(): boolean;
  44731. private _soundLoaded;
  44732. /**
  44733. * Sets the data of the sound from an audiobuffer
  44734. * @param audioBuffer The audioBuffer containing the data
  44735. */
  44736. setAudioBuffer(audioBuffer: AudioBuffer): void;
  44737. /**
  44738. * Updates the current sounds options such as maxdistance, loop...
  44739. * @param options A JSON object containing values named as the object properties
  44740. */
  44741. updateOptions(options: ISoundOptions): void;
  44742. private _createSpatialParameters;
  44743. private _updateSpatialParameters;
  44744. /**
  44745. * Switch the panning model to HRTF:
  44746. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44747. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44748. */
  44749. switchPanningModelToHRTF(): void;
  44750. /**
  44751. * Switch the panning model to Equal Power:
  44752. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44753. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44754. */
  44755. switchPanningModelToEqualPower(): void;
  44756. private _switchPanningModel;
  44757. /**
  44758. * Connect this sound to a sound track audio node like gain...
  44759. * @param soundTrackAudioNode the sound track audio node to connect to
  44760. */
  44761. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  44762. /**
  44763. * Transform this sound into a directional source
  44764. * @param coneInnerAngle Size of the inner cone in degree
  44765. * @param coneOuterAngle Size of the outer cone in degree
  44766. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  44767. */
  44768. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  44769. /**
  44770. * Gets or sets the inner angle for the directional cone.
  44771. */
  44772. get directionalConeInnerAngle(): number;
  44773. /**
  44774. * Gets or sets the inner angle for the directional cone.
  44775. */
  44776. set directionalConeInnerAngle(value: number);
  44777. /**
  44778. * Gets or sets the outer angle for the directional cone.
  44779. */
  44780. get directionalConeOuterAngle(): number;
  44781. /**
  44782. * Gets or sets the outer angle for the directional cone.
  44783. */
  44784. set directionalConeOuterAngle(value: number);
  44785. /**
  44786. * Sets the position of the emitter if spatial sound is enabled
  44787. * @param newPosition Defines the new posisiton
  44788. */
  44789. setPosition(newPosition: Vector3): void;
  44790. /**
  44791. * Sets the local direction of the emitter if spatial sound is enabled
  44792. * @param newLocalDirection Defines the new local direction
  44793. */
  44794. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  44795. private _updateDirection;
  44796. /** @hidden */
  44797. updateDistanceFromListener(): void;
  44798. /**
  44799. * Sets a new custom attenuation function for the sound.
  44800. * @param callback Defines the function used for the attenuation
  44801. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44802. */
  44803. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  44804. /**
  44805. * Play the sound
  44806. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  44807. * @param offset (optional) Start the sound at a specific time in seconds
  44808. * @param length (optional) Sound duration (in seconds)
  44809. */
  44810. play(time?: number, offset?: number, length?: number): void;
  44811. private _onended;
  44812. /**
  44813. * Stop the sound
  44814. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  44815. */
  44816. stop(time?: number): void;
  44817. /**
  44818. * Put the sound in pause
  44819. */
  44820. pause(): void;
  44821. /**
  44822. * Sets a dedicated volume for this sounds
  44823. * @param newVolume Define the new volume of the sound
  44824. * @param time Define time for gradual change to new volume
  44825. */
  44826. setVolume(newVolume: number, time?: number): void;
  44827. /**
  44828. * Set the sound play back rate
  44829. * @param newPlaybackRate Define the playback rate the sound should be played at
  44830. */
  44831. setPlaybackRate(newPlaybackRate: number): void;
  44832. /**
  44833. * Gets the volume of the sound.
  44834. * @returns the volume of the sound
  44835. */
  44836. getVolume(): number;
  44837. /**
  44838. * Attach the sound to a dedicated mesh
  44839. * @param transformNode The transform node to connect the sound with
  44840. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44841. */
  44842. attachToMesh(transformNode: TransformNode): void;
  44843. /**
  44844. * Detach the sound from the previously attached mesh
  44845. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44846. */
  44847. detachFromMesh(): void;
  44848. private _onRegisterAfterWorldMatrixUpdate;
  44849. /**
  44850. * Clone the current sound in the scene.
  44851. * @returns the new sound clone
  44852. */
  44853. clone(): Nullable<Sound>;
  44854. /**
  44855. * Gets the current underlying audio buffer containing the data
  44856. * @returns the audio buffer
  44857. */
  44858. getAudioBuffer(): Nullable<AudioBuffer>;
  44859. /**
  44860. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  44861. * @returns the source node
  44862. */
  44863. getSoundSource(): Nullable<AudioBufferSourceNode>;
  44864. /**
  44865. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  44866. * @returns the gain node
  44867. */
  44868. getSoundGain(): Nullable<GainNode>;
  44869. /**
  44870. * Serializes the Sound in a JSON representation
  44871. * @returns the JSON representation of the sound
  44872. */
  44873. serialize(): any;
  44874. /**
  44875. * Parse a JSON representation of a sound to innstantiate in a given scene
  44876. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  44877. * @param scene Define the scene the new parsed sound should be created in
  44878. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  44879. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  44880. * @returns the newly parsed sound
  44881. */
  44882. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  44883. }
  44884. }
  44885. declare module BABYLON {
  44886. /**
  44887. * This defines an action helpful to play a defined sound on a triggered action.
  44888. */
  44889. export class PlaySoundAction extends Action {
  44890. private _sound;
  44891. /**
  44892. * Instantiate the action
  44893. * @param triggerOptions defines the trigger options
  44894. * @param sound defines the sound to play
  44895. * @param condition defines the trigger related conditions
  44896. */
  44897. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44898. /** @hidden */
  44899. _prepare(): void;
  44900. /**
  44901. * Execute the action and play the sound.
  44902. */
  44903. execute(): void;
  44904. /**
  44905. * Serializes the actions and its related information.
  44906. * @param parent defines the object to serialize in
  44907. * @returns the serialized object
  44908. */
  44909. serialize(parent: any): any;
  44910. }
  44911. /**
  44912. * This defines an action helpful to stop a defined sound on a triggered action.
  44913. */
  44914. export class StopSoundAction extends Action {
  44915. private _sound;
  44916. /**
  44917. * Instantiate the action
  44918. * @param triggerOptions defines the trigger options
  44919. * @param sound defines the sound to stop
  44920. * @param condition defines the trigger related conditions
  44921. */
  44922. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44923. /** @hidden */
  44924. _prepare(): void;
  44925. /**
  44926. * Execute the action and stop the sound.
  44927. */
  44928. execute(): void;
  44929. /**
  44930. * Serializes the actions and its related information.
  44931. * @param parent defines the object to serialize in
  44932. * @returns the serialized object
  44933. */
  44934. serialize(parent: any): any;
  44935. }
  44936. }
  44937. declare module BABYLON {
  44938. /**
  44939. * This defines an action responsible to change the value of a property
  44940. * by interpolating between its current value and the newly set one once triggered.
  44941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44942. */
  44943. export class InterpolateValueAction extends Action {
  44944. /**
  44945. * Defines the path of the property where the value should be interpolated
  44946. */
  44947. propertyPath: string;
  44948. /**
  44949. * Defines the target value at the end of the interpolation.
  44950. */
  44951. value: any;
  44952. /**
  44953. * Defines the time it will take for the property to interpolate to the value.
  44954. */
  44955. duration: number;
  44956. /**
  44957. * Defines if the other scene animations should be stopped when the action has been triggered
  44958. */
  44959. stopOtherAnimations?: boolean;
  44960. /**
  44961. * Defines a callback raised once the interpolation animation has been done.
  44962. */
  44963. onInterpolationDone?: () => void;
  44964. /**
  44965. * Observable triggered once the interpolation animation has been done.
  44966. */
  44967. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  44968. private _target;
  44969. private _effectiveTarget;
  44970. private _property;
  44971. /**
  44972. * Instantiate the action
  44973. * @param triggerOptions defines the trigger options
  44974. * @param target defines the object containing the value to interpolate
  44975. * @param propertyPath defines the path to the property in the target object
  44976. * @param value defines the target value at the end of the interpolation
  44977. * @param duration deines the time it will take for the property to interpolate to the value.
  44978. * @param condition defines the trigger related conditions
  44979. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  44980. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  44981. */
  44982. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  44983. /** @hidden */
  44984. _prepare(): void;
  44985. /**
  44986. * Execute the action starts the value interpolation.
  44987. */
  44988. execute(): void;
  44989. /**
  44990. * Serializes the actions and its related information.
  44991. * @param parent defines the object to serialize in
  44992. * @returns the serialized object
  44993. */
  44994. serialize(parent: any): any;
  44995. }
  44996. }
  44997. declare module BABYLON {
  44998. /**
  44999. * Options allowed during the creation of a sound track.
  45000. */
  45001. export interface ISoundTrackOptions {
  45002. /**
  45003. * The volume the sound track should take during creation
  45004. */
  45005. volume?: number;
  45006. /**
  45007. * Define if the sound track is the main sound track of the scene
  45008. */
  45009. mainTrack?: boolean;
  45010. }
  45011. /**
  45012. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45013. * It will be also used in a future release to apply effects on a specific track.
  45014. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45015. */
  45016. export class SoundTrack {
  45017. /**
  45018. * The unique identifier of the sound track in the scene.
  45019. */
  45020. id: number;
  45021. /**
  45022. * The list of sounds included in the sound track.
  45023. */
  45024. soundCollection: Array<Sound>;
  45025. private _outputAudioNode;
  45026. private _scene;
  45027. private _connectedAnalyser;
  45028. private _options;
  45029. private _isInitialized;
  45030. /**
  45031. * Creates a new sound track.
  45032. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45033. * @param scene Define the scene the sound track belongs to
  45034. * @param options
  45035. */
  45036. constructor(scene: Scene, options?: ISoundTrackOptions);
  45037. private _initializeSoundTrackAudioGraph;
  45038. /**
  45039. * Release the sound track and its associated resources
  45040. */
  45041. dispose(): void;
  45042. /**
  45043. * Adds a sound to this sound track
  45044. * @param sound define the cound to add
  45045. * @ignoreNaming
  45046. */
  45047. AddSound(sound: Sound): void;
  45048. /**
  45049. * Removes a sound to this sound track
  45050. * @param sound define the cound to remove
  45051. * @ignoreNaming
  45052. */
  45053. RemoveSound(sound: Sound): void;
  45054. /**
  45055. * Set a global volume for the full sound track.
  45056. * @param newVolume Define the new volume of the sound track
  45057. */
  45058. setVolume(newVolume: number): void;
  45059. /**
  45060. * Switch the panning model to HRTF:
  45061. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45062. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45063. */
  45064. switchPanningModelToHRTF(): void;
  45065. /**
  45066. * Switch the panning model to Equal Power:
  45067. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45068. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45069. */
  45070. switchPanningModelToEqualPower(): void;
  45071. /**
  45072. * Connect the sound track to an audio analyser allowing some amazing
  45073. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45074. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45075. * @param analyser The analyser to connect to the engine
  45076. */
  45077. connectToAnalyser(analyser: Analyser): void;
  45078. }
  45079. }
  45080. declare module BABYLON {
  45081. interface AbstractScene {
  45082. /**
  45083. * The list of sounds used in the scene.
  45084. */
  45085. sounds: Nullable<Array<Sound>>;
  45086. }
  45087. interface Scene {
  45088. /**
  45089. * @hidden
  45090. * Backing field
  45091. */
  45092. _mainSoundTrack: SoundTrack;
  45093. /**
  45094. * The main sound track played by the scene.
  45095. * It cotains your primary collection of sounds.
  45096. */
  45097. mainSoundTrack: SoundTrack;
  45098. /**
  45099. * The list of sound tracks added to the scene
  45100. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45101. */
  45102. soundTracks: Nullable<Array<SoundTrack>>;
  45103. /**
  45104. * Gets a sound using a given name
  45105. * @param name defines the name to search for
  45106. * @return the found sound or null if not found at all.
  45107. */
  45108. getSoundByName(name: string): Nullable<Sound>;
  45109. /**
  45110. * Gets or sets if audio support is enabled
  45111. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45112. */
  45113. audioEnabled: boolean;
  45114. /**
  45115. * Gets or sets if audio will be output to headphones
  45116. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45117. */
  45118. headphone: boolean;
  45119. /**
  45120. * Gets or sets custom audio listener position provider
  45121. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45122. */
  45123. audioListenerPositionProvider: Nullable<() => Vector3>;
  45124. /**
  45125. * Gets or sets a refresh rate when using 3D audio positioning
  45126. */
  45127. audioPositioningRefreshRate: number;
  45128. }
  45129. /**
  45130. * Defines the sound scene component responsible to manage any sounds
  45131. * in a given scene.
  45132. */
  45133. export class AudioSceneComponent implements ISceneSerializableComponent {
  45134. private static _CameraDirectionLH;
  45135. private static _CameraDirectionRH;
  45136. /**
  45137. * The component name helpfull to identify the component in the list of scene components.
  45138. */
  45139. readonly name: string;
  45140. /**
  45141. * The scene the component belongs to.
  45142. */
  45143. scene: Scene;
  45144. private _audioEnabled;
  45145. /**
  45146. * Gets whether audio is enabled or not.
  45147. * Please use related enable/disable method to switch state.
  45148. */
  45149. get audioEnabled(): boolean;
  45150. private _headphone;
  45151. /**
  45152. * Gets whether audio is outputing to headphone or not.
  45153. * Please use the according Switch methods to change output.
  45154. */
  45155. get headphone(): boolean;
  45156. /**
  45157. * Gets or sets a refresh rate when using 3D audio positioning
  45158. */
  45159. audioPositioningRefreshRate: number;
  45160. private _audioListenerPositionProvider;
  45161. /**
  45162. * Gets the current audio listener position provider
  45163. */
  45164. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45165. /**
  45166. * Sets a custom listener position for all sounds in the scene
  45167. * By default, this is the position of the first active camera
  45168. */
  45169. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45170. /**
  45171. * Creates a new instance of the component for the given scene
  45172. * @param scene Defines the scene to register the component in
  45173. */
  45174. constructor(scene: Scene);
  45175. /**
  45176. * Registers the component in a given scene
  45177. */
  45178. register(): void;
  45179. /**
  45180. * Rebuilds the elements related to this component in case of
  45181. * context lost for instance.
  45182. */
  45183. rebuild(): void;
  45184. /**
  45185. * Serializes the component data to the specified json object
  45186. * @param serializationObject The object to serialize to
  45187. */
  45188. serialize(serializationObject: any): void;
  45189. /**
  45190. * Adds all the elements from the container to the scene
  45191. * @param container the container holding the elements
  45192. */
  45193. addFromContainer(container: AbstractScene): void;
  45194. /**
  45195. * Removes all the elements in the container from the scene
  45196. * @param container contains the elements to remove
  45197. * @param dispose if the removed element should be disposed (default: false)
  45198. */
  45199. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45200. /**
  45201. * Disposes the component and the associated ressources.
  45202. */
  45203. dispose(): void;
  45204. /**
  45205. * Disables audio in the associated scene.
  45206. */
  45207. disableAudio(): void;
  45208. /**
  45209. * Enables audio in the associated scene.
  45210. */
  45211. enableAudio(): void;
  45212. /**
  45213. * Switch audio to headphone output.
  45214. */
  45215. switchAudioModeForHeadphones(): void;
  45216. /**
  45217. * Switch audio to normal speakers.
  45218. */
  45219. switchAudioModeForNormalSpeakers(): void;
  45220. private _cachedCameraDirection;
  45221. private _cachedCameraPosition;
  45222. private _lastCheck;
  45223. private _afterRender;
  45224. }
  45225. }
  45226. declare module BABYLON {
  45227. /**
  45228. * Wraps one or more Sound objects and selects one with random weight for playback.
  45229. */
  45230. export class WeightedSound {
  45231. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45232. loop: boolean;
  45233. private _coneInnerAngle;
  45234. private _coneOuterAngle;
  45235. private _volume;
  45236. /** A Sound is currently playing. */
  45237. isPlaying: boolean;
  45238. /** A Sound is currently paused. */
  45239. isPaused: boolean;
  45240. private _sounds;
  45241. private _weights;
  45242. private _currentIndex?;
  45243. /**
  45244. * Creates a new WeightedSound from the list of sounds given.
  45245. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45246. * @param sounds Array of Sounds that will be selected from.
  45247. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45248. */
  45249. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45250. /**
  45251. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45252. */
  45253. get directionalConeInnerAngle(): number;
  45254. /**
  45255. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45256. */
  45257. set directionalConeInnerAngle(value: number);
  45258. /**
  45259. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45260. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45261. */
  45262. get directionalConeOuterAngle(): number;
  45263. /**
  45264. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45265. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45266. */
  45267. set directionalConeOuterAngle(value: number);
  45268. /**
  45269. * Playback volume.
  45270. */
  45271. get volume(): number;
  45272. /**
  45273. * Playback volume.
  45274. */
  45275. set volume(value: number);
  45276. private _onended;
  45277. /**
  45278. * Suspend playback
  45279. */
  45280. pause(): void;
  45281. /**
  45282. * Stop playback
  45283. */
  45284. stop(): void;
  45285. /**
  45286. * Start playback.
  45287. * @param startOffset Position the clip head at a specific time in seconds.
  45288. */
  45289. play(startOffset?: number): void;
  45290. }
  45291. }
  45292. declare module BABYLON {
  45293. /**
  45294. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45295. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45296. */
  45297. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45298. /**
  45299. * Gets the name of the behavior.
  45300. */
  45301. get name(): string;
  45302. /**
  45303. * The easing function used by animations
  45304. */
  45305. static EasingFunction: BackEase;
  45306. /**
  45307. * The easing mode used by animations
  45308. */
  45309. static EasingMode: number;
  45310. /**
  45311. * The duration of the animation, in milliseconds
  45312. */
  45313. transitionDuration: number;
  45314. /**
  45315. * Length of the distance animated by the transition when lower radius is reached
  45316. */
  45317. lowerRadiusTransitionRange: number;
  45318. /**
  45319. * Length of the distance animated by the transition when upper radius is reached
  45320. */
  45321. upperRadiusTransitionRange: number;
  45322. private _autoTransitionRange;
  45323. /**
  45324. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45325. */
  45326. get autoTransitionRange(): boolean;
  45327. /**
  45328. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45329. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45330. */
  45331. set autoTransitionRange(value: boolean);
  45332. private _attachedCamera;
  45333. private _onAfterCheckInputsObserver;
  45334. private _onMeshTargetChangedObserver;
  45335. /**
  45336. * Initializes the behavior.
  45337. */
  45338. init(): void;
  45339. /**
  45340. * Attaches the behavior to its arc rotate camera.
  45341. * @param camera Defines the camera to attach the behavior to
  45342. */
  45343. attach(camera: ArcRotateCamera): void;
  45344. /**
  45345. * Detaches the behavior from its current arc rotate camera.
  45346. */
  45347. detach(): void;
  45348. private _radiusIsAnimating;
  45349. private _radiusBounceTransition;
  45350. private _animatables;
  45351. private _cachedWheelPrecision;
  45352. /**
  45353. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45354. * @param radiusLimit The limit to check against.
  45355. * @return Bool to indicate if at limit.
  45356. */
  45357. private _isRadiusAtLimit;
  45358. /**
  45359. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45360. * @param radiusDelta The delta by which to animate to. Can be negative.
  45361. */
  45362. private _applyBoundRadiusAnimation;
  45363. /**
  45364. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45365. */
  45366. protected _clearAnimationLocks(): void;
  45367. /**
  45368. * Stops and removes all animations that have been applied to the camera
  45369. */
  45370. stopAllAnimations(): void;
  45371. }
  45372. }
  45373. declare module BABYLON {
  45374. /**
  45375. * 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.
  45376. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45377. */
  45378. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45379. /**
  45380. * Gets the name of the behavior.
  45381. */
  45382. get name(): string;
  45383. private _mode;
  45384. private _radiusScale;
  45385. private _positionScale;
  45386. private _defaultElevation;
  45387. private _elevationReturnTime;
  45388. private _elevationReturnWaitTime;
  45389. private _zoomStopsAnimation;
  45390. private _framingTime;
  45391. /**
  45392. * The easing function used by animations
  45393. */
  45394. static EasingFunction: ExponentialEase;
  45395. /**
  45396. * The easing mode used by animations
  45397. */
  45398. static EasingMode: number;
  45399. /**
  45400. * Sets the current mode used by the behavior
  45401. */
  45402. set mode(mode: number);
  45403. /**
  45404. * Gets current mode used by the behavior.
  45405. */
  45406. get mode(): number;
  45407. /**
  45408. * Sets the scale applied to the radius (1 by default)
  45409. */
  45410. set radiusScale(radius: number);
  45411. /**
  45412. * Gets the scale applied to the radius
  45413. */
  45414. get radiusScale(): number;
  45415. /**
  45416. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45417. */
  45418. set positionScale(scale: number);
  45419. /**
  45420. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45421. */
  45422. get positionScale(): number;
  45423. /**
  45424. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45425. * behaviour is triggered, in radians.
  45426. */
  45427. set defaultElevation(elevation: number);
  45428. /**
  45429. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45430. * behaviour is triggered, in radians.
  45431. */
  45432. get defaultElevation(): number;
  45433. /**
  45434. * Sets the time (in milliseconds) taken to return to the default beta position.
  45435. * Negative value indicates camera should not return to default.
  45436. */
  45437. set elevationReturnTime(speed: number);
  45438. /**
  45439. * Gets the time (in milliseconds) taken to return to the default beta position.
  45440. * Negative value indicates camera should not return to default.
  45441. */
  45442. get elevationReturnTime(): number;
  45443. /**
  45444. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45445. */
  45446. set elevationReturnWaitTime(time: number);
  45447. /**
  45448. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45449. */
  45450. get elevationReturnWaitTime(): number;
  45451. /**
  45452. * Sets the flag that indicates if user zooming should stop animation.
  45453. */
  45454. set zoomStopsAnimation(flag: boolean);
  45455. /**
  45456. * Gets the flag that indicates if user zooming should stop animation.
  45457. */
  45458. get zoomStopsAnimation(): boolean;
  45459. /**
  45460. * Sets the transition time when framing the mesh, in milliseconds
  45461. */
  45462. set framingTime(time: number);
  45463. /**
  45464. * Gets the transition time when framing the mesh, in milliseconds
  45465. */
  45466. get framingTime(): number;
  45467. /**
  45468. * Define if the behavior should automatically change the configured
  45469. * camera limits and sensibilities.
  45470. */
  45471. autoCorrectCameraLimitsAndSensibility: boolean;
  45472. private _onPrePointerObservableObserver;
  45473. private _onAfterCheckInputsObserver;
  45474. private _onMeshTargetChangedObserver;
  45475. private _attachedCamera;
  45476. private _isPointerDown;
  45477. private _lastInteractionTime;
  45478. /**
  45479. * Initializes the behavior.
  45480. */
  45481. init(): void;
  45482. /**
  45483. * Attaches the behavior to its arc rotate camera.
  45484. * @param camera Defines the camera to attach the behavior to
  45485. */
  45486. attach(camera: ArcRotateCamera): void;
  45487. /**
  45488. * Detaches the behavior from its current arc rotate camera.
  45489. */
  45490. detach(): void;
  45491. private _animatables;
  45492. private _betaIsAnimating;
  45493. private _betaTransition;
  45494. private _radiusTransition;
  45495. private _vectorTransition;
  45496. /**
  45497. * Targets the given mesh and updates zoom level accordingly.
  45498. * @param mesh The mesh to target.
  45499. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45500. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45501. */
  45502. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45503. /**
  45504. * Targets the given mesh with its children and updates zoom level accordingly.
  45505. * @param mesh The mesh to target.
  45506. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45507. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45508. */
  45509. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45510. /**
  45511. * Targets the given meshes with their children and updates zoom level accordingly.
  45512. * @param meshes The mesh to target.
  45513. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45514. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45515. */
  45516. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45517. /**
  45518. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45519. * @param minimumWorld Determines the smaller position of the bounding box extend
  45520. * @param maximumWorld Determines the bigger position of the bounding box extend
  45521. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45522. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45523. */
  45524. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45525. /**
  45526. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45527. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45528. * frustum width.
  45529. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45530. * to fully enclose the mesh in the viewing frustum.
  45531. */
  45532. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45533. /**
  45534. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45535. * is automatically returned to its default position (expected to be above ground plane).
  45536. */
  45537. private _maintainCameraAboveGround;
  45538. /**
  45539. * Returns the frustum slope based on the canvas ratio and camera FOV
  45540. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45541. */
  45542. private _getFrustumSlope;
  45543. /**
  45544. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45545. */
  45546. private _clearAnimationLocks;
  45547. /**
  45548. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45549. */
  45550. private _applyUserInteraction;
  45551. /**
  45552. * Stops and removes all animations that have been applied to the camera
  45553. */
  45554. stopAllAnimations(): void;
  45555. /**
  45556. * Gets a value indicating if the user is moving the camera
  45557. */
  45558. get isUserIsMoving(): boolean;
  45559. /**
  45560. * The camera can move all the way towards the mesh.
  45561. */
  45562. static IgnoreBoundsSizeMode: number;
  45563. /**
  45564. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45565. */
  45566. static FitFrustumSidesMode: number;
  45567. }
  45568. }
  45569. declare module BABYLON {
  45570. /**
  45571. * Base class for Camera Pointer Inputs.
  45572. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45573. * for example usage.
  45574. */
  45575. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45576. /**
  45577. * Defines the camera the input is attached to.
  45578. */
  45579. abstract camera: Camera;
  45580. /**
  45581. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45582. */
  45583. protected _altKey: boolean;
  45584. protected _ctrlKey: boolean;
  45585. protected _metaKey: boolean;
  45586. protected _shiftKey: boolean;
  45587. /**
  45588. * Which mouse buttons were pressed at time of last mouse event.
  45589. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45590. */
  45591. protected _buttonsPressed: number;
  45592. /**
  45593. * Defines the buttons associated with the input to handle camera move.
  45594. */
  45595. buttons: number[];
  45596. /**
  45597. * Attach the input controls to a specific dom element to get the input from.
  45598. * @param element Defines the element the controls should be listened from
  45599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45600. */
  45601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45602. /**
  45603. * Detach the current controls from the specified dom element.
  45604. * @param element Defines the element to stop listening the inputs from
  45605. */
  45606. detachControl(element: Nullable<HTMLElement>): void;
  45607. /**
  45608. * Gets the class name of the current input.
  45609. * @returns the class name
  45610. */
  45611. getClassName(): string;
  45612. /**
  45613. * Get the friendly name associated with the input class.
  45614. * @returns the input friendly name
  45615. */
  45616. getSimpleName(): string;
  45617. /**
  45618. * Called on pointer POINTERDOUBLETAP event.
  45619. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45620. */
  45621. protected onDoubleTap(type: string): void;
  45622. /**
  45623. * Called on pointer POINTERMOVE event if only a single touch is active.
  45624. * Override this method to provide functionality.
  45625. */
  45626. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45627. /**
  45628. * Called on pointer POINTERMOVE event if multiple touches are active.
  45629. * Override this method to provide functionality.
  45630. */
  45631. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45632. /**
  45633. * Called on JS contextmenu event.
  45634. * Override this method to provide functionality.
  45635. */
  45636. protected onContextMenu(evt: PointerEvent): void;
  45637. /**
  45638. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45639. * press.
  45640. * Override this method to provide functionality.
  45641. */
  45642. protected onButtonDown(evt: PointerEvent): void;
  45643. /**
  45644. * Called each time a new POINTERUP event occurs. Ie, for each button
  45645. * release.
  45646. * Override this method to provide functionality.
  45647. */
  45648. protected onButtonUp(evt: PointerEvent): void;
  45649. /**
  45650. * Called when window becomes inactive.
  45651. * Override this method to provide functionality.
  45652. */
  45653. protected onLostFocus(): void;
  45654. private _pointerInput;
  45655. private _observer;
  45656. private _onLostFocus;
  45657. private pointA;
  45658. private pointB;
  45659. }
  45660. }
  45661. declare module BABYLON {
  45662. /**
  45663. * Manage the pointers inputs to control an arc rotate camera.
  45664. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45665. */
  45666. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45667. /**
  45668. * Defines the camera the input is attached to.
  45669. */
  45670. camera: ArcRotateCamera;
  45671. /**
  45672. * Gets the class name of the current input.
  45673. * @returns the class name
  45674. */
  45675. getClassName(): string;
  45676. /**
  45677. * Defines the buttons associated with the input to handle camera move.
  45678. */
  45679. buttons: number[];
  45680. /**
  45681. * Defines the pointer angular sensibility along the X axis or how fast is
  45682. * the camera rotating.
  45683. */
  45684. angularSensibilityX: number;
  45685. /**
  45686. * Defines the pointer angular sensibility along the Y axis or how fast is
  45687. * the camera rotating.
  45688. */
  45689. angularSensibilityY: number;
  45690. /**
  45691. * Defines the pointer pinch precision or how fast is the camera zooming.
  45692. */
  45693. pinchPrecision: number;
  45694. /**
  45695. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45696. * from 0.
  45697. * It defines the percentage of current camera.radius to use as delta when
  45698. * pinch zoom is used.
  45699. */
  45700. pinchDeltaPercentage: number;
  45701. /**
  45702. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  45703. * that any object in the plane at the camera's target point will scale
  45704. * perfectly with finger motion.
  45705. * Overrides pinchDeltaPercentage and pinchPrecision.
  45706. */
  45707. useNaturalPinchZoom: boolean;
  45708. /**
  45709. * Defines the pointer panning sensibility or how fast is the camera moving.
  45710. */
  45711. panningSensibility: number;
  45712. /**
  45713. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  45714. */
  45715. multiTouchPanning: boolean;
  45716. /**
  45717. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  45718. * zoom (pinch) through multitouch.
  45719. */
  45720. multiTouchPanAndZoom: boolean;
  45721. /**
  45722. * Revers pinch action direction.
  45723. */
  45724. pinchInwards: boolean;
  45725. private _isPanClick;
  45726. private _twoFingerActivityCount;
  45727. private _isPinching;
  45728. /**
  45729. * Called on pointer POINTERMOVE event if only a single touch is active.
  45730. */
  45731. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45732. /**
  45733. * Called on pointer POINTERDOUBLETAP event.
  45734. */
  45735. protected onDoubleTap(type: string): void;
  45736. /**
  45737. * Called on pointer POINTERMOVE event if multiple touches are active.
  45738. */
  45739. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45740. /**
  45741. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45742. * press.
  45743. */
  45744. protected onButtonDown(evt: PointerEvent): void;
  45745. /**
  45746. * Called each time a new POINTERUP event occurs. Ie, for each button
  45747. * release.
  45748. */
  45749. protected onButtonUp(evt: PointerEvent): void;
  45750. /**
  45751. * Called when window becomes inactive.
  45752. */
  45753. protected onLostFocus(): void;
  45754. }
  45755. }
  45756. declare module BABYLON {
  45757. /**
  45758. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  45759. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45760. */
  45761. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  45762. /**
  45763. * Defines the camera the input is attached to.
  45764. */
  45765. camera: ArcRotateCamera;
  45766. /**
  45767. * Defines the list of key codes associated with the up action (increase alpha)
  45768. */
  45769. keysUp: number[];
  45770. /**
  45771. * Defines the list of key codes associated with the down action (decrease alpha)
  45772. */
  45773. keysDown: number[];
  45774. /**
  45775. * Defines the list of key codes associated with the left action (increase beta)
  45776. */
  45777. keysLeft: number[];
  45778. /**
  45779. * Defines the list of key codes associated with the right action (decrease beta)
  45780. */
  45781. keysRight: number[];
  45782. /**
  45783. * Defines the list of key codes associated with the reset action.
  45784. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  45785. */
  45786. keysReset: number[];
  45787. /**
  45788. * Defines the panning sensibility of the inputs.
  45789. * (How fast is the camera panning)
  45790. */
  45791. panningSensibility: number;
  45792. /**
  45793. * Defines the zooming sensibility of the inputs.
  45794. * (How fast is the camera zooming)
  45795. */
  45796. zoomingSensibility: number;
  45797. /**
  45798. * Defines whether maintaining the alt key down switch the movement mode from
  45799. * orientation to zoom.
  45800. */
  45801. useAltToZoom: boolean;
  45802. /**
  45803. * Rotation speed of the camera
  45804. */
  45805. angularSpeed: number;
  45806. private _keys;
  45807. private _ctrlPressed;
  45808. private _altPressed;
  45809. private _onCanvasBlurObserver;
  45810. private _onKeyboardObserver;
  45811. private _engine;
  45812. private _scene;
  45813. /**
  45814. * Attach the input controls to a specific dom element to get the input from.
  45815. * @param element Defines the element the controls should be listened from
  45816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45817. */
  45818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45819. /**
  45820. * Detach the current controls from the specified dom element.
  45821. * @param element Defines the element to stop listening the inputs from
  45822. */
  45823. detachControl(element: Nullable<HTMLElement>): void;
  45824. /**
  45825. * Update the current camera state depending on the inputs that have been used this frame.
  45826. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45827. */
  45828. checkInputs(): void;
  45829. /**
  45830. * Gets the class name of the current intput.
  45831. * @returns the class name
  45832. */
  45833. getClassName(): string;
  45834. /**
  45835. * Get the friendly name associated with the input class.
  45836. * @returns the input friendly name
  45837. */
  45838. getSimpleName(): string;
  45839. }
  45840. }
  45841. declare module BABYLON {
  45842. /**
  45843. * Manage the mouse wheel inputs to control an arc rotate camera.
  45844. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45845. */
  45846. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  45847. /**
  45848. * Defines the camera the input is attached to.
  45849. */
  45850. camera: ArcRotateCamera;
  45851. /**
  45852. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  45853. */
  45854. wheelPrecision: number;
  45855. /**
  45856. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45857. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45858. */
  45859. wheelDeltaPercentage: number;
  45860. private _wheel;
  45861. private _observer;
  45862. private computeDeltaFromMouseWheelLegacyEvent;
  45863. /**
  45864. * Attach the input controls to a specific dom element to get the input from.
  45865. * @param element Defines the element the controls should be listened from
  45866. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45867. */
  45868. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45869. /**
  45870. * Detach the current controls from the specified dom element.
  45871. * @param element Defines the element to stop listening the inputs from
  45872. */
  45873. detachControl(element: Nullable<HTMLElement>): void;
  45874. /**
  45875. * Gets the class name of the current intput.
  45876. * @returns the class name
  45877. */
  45878. getClassName(): string;
  45879. /**
  45880. * Get the friendly name associated with the input class.
  45881. * @returns the input friendly name
  45882. */
  45883. getSimpleName(): string;
  45884. }
  45885. }
  45886. declare module BABYLON {
  45887. /**
  45888. * Default Inputs manager for the ArcRotateCamera.
  45889. * It groups all the default supported inputs for ease of use.
  45890. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45891. */
  45892. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  45893. /**
  45894. * Instantiates a new ArcRotateCameraInputsManager.
  45895. * @param camera Defines the camera the inputs belong to
  45896. */
  45897. constructor(camera: ArcRotateCamera);
  45898. /**
  45899. * Add mouse wheel input support to the input manager.
  45900. * @returns the current input manager
  45901. */
  45902. addMouseWheel(): ArcRotateCameraInputsManager;
  45903. /**
  45904. * Add pointers input support to the input manager.
  45905. * @returns the current input manager
  45906. */
  45907. addPointers(): ArcRotateCameraInputsManager;
  45908. /**
  45909. * Add keyboard input support to the input manager.
  45910. * @returns the current input manager
  45911. */
  45912. addKeyboard(): ArcRotateCameraInputsManager;
  45913. }
  45914. }
  45915. declare module BABYLON {
  45916. /**
  45917. * This represents an orbital type of camera.
  45918. *
  45919. * 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.
  45920. * 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.
  45921. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  45922. */
  45923. export class ArcRotateCamera extends TargetCamera {
  45924. /**
  45925. * Defines the rotation angle of the camera along the longitudinal axis.
  45926. */
  45927. alpha: number;
  45928. /**
  45929. * Defines the rotation angle of the camera along the latitudinal axis.
  45930. */
  45931. beta: number;
  45932. /**
  45933. * Defines the radius of the camera from it s target point.
  45934. */
  45935. radius: number;
  45936. protected _target: Vector3;
  45937. protected _targetHost: Nullable<AbstractMesh>;
  45938. /**
  45939. * Defines the target point of the camera.
  45940. * The camera looks towards it form the radius distance.
  45941. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  45942. */
  45943. get target(): Vector3;
  45944. set target(value: Vector3);
  45945. /**
  45946. * Define the current local position of the camera in the scene
  45947. */
  45948. get position(): Vector3;
  45949. set position(newPosition: Vector3);
  45950. protected _upToYMatrix: Matrix;
  45951. protected _YToUpMatrix: Matrix;
  45952. /**
  45953. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  45954. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  45955. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  45956. */
  45957. set upVector(vec: Vector3);
  45958. get upVector(): Vector3;
  45959. /**
  45960. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  45961. */
  45962. setMatUp(): void;
  45963. /**
  45964. * Current inertia value on the longitudinal axis.
  45965. * The bigger this number the longer it will take for the camera to stop.
  45966. */
  45967. inertialAlphaOffset: number;
  45968. /**
  45969. * Current inertia value on the latitudinal axis.
  45970. * The bigger this number the longer it will take for the camera to stop.
  45971. */
  45972. inertialBetaOffset: number;
  45973. /**
  45974. * Current inertia value on the radius axis.
  45975. * The bigger this number the longer it will take for the camera to stop.
  45976. */
  45977. inertialRadiusOffset: number;
  45978. /**
  45979. * Minimum allowed angle on the longitudinal axis.
  45980. * This can help limiting how the Camera is able to move in the scene.
  45981. */
  45982. lowerAlphaLimit: Nullable<number>;
  45983. /**
  45984. * Maximum allowed angle on the longitudinal axis.
  45985. * This can help limiting how the Camera is able to move in the scene.
  45986. */
  45987. upperAlphaLimit: Nullable<number>;
  45988. /**
  45989. * Minimum allowed angle on the latitudinal axis.
  45990. * This can help limiting how the Camera is able to move in the scene.
  45991. */
  45992. lowerBetaLimit: number;
  45993. /**
  45994. * Maximum allowed angle on the latitudinal axis.
  45995. * This can help limiting how the Camera is able to move in the scene.
  45996. */
  45997. upperBetaLimit: number;
  45998. /**
  45999. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46000. * This can help limiting how the Camera is able to move in the scene.
  46001. */
  46002. lowerRadiusLimit: Nullable<number>;
  46003. /**
  46004. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46005. * This can help limiting how the Camera is able to move in the scene.
  46006. */
  46007. upperRadiusLimit: Nullable<number>;
  46008. /**
  46009. * Defines the current inertia value used during panning of the camera along the X axis.
  46010. */
  46011. inertialPanningX: number;
  46012. /**
  46013. * Defines the current inertia value used during panning of the camera along the Y axis.
  46014. */
  46015. inertialPanningY: number;
  46016. /**
  46017. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46018. * Basically if your fingers moves away from more than this distance you will be considered
  46019. * in pinch mode.
  46020. */
  46021. pinchToPanMaxDistance: number;
  46022. /**
  46023. * Defines the maximum distance the camera can pan.
  46024. * This could help keeping the cammera always in your scene.
  46025. */
  46026. panningDistanceLimit: Nullable<number>;
  46027. /**
  46028. * Defines the target of the camera before paning.
  46029. */
  46030. panningOriginTarget: Vector3;
  46031. /**
  46032. * Defines the value of the inertia used during panning.
  46033. * 0 would mean stop inertia and one would mean no decelleration at all.
  46034. */
  46035. panningInertia: number;
  46036. /**
  46037. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46038. */
  46039. get angularSensibilityX(): number;
  46040. set angularSensibilityX(value: number);
  46041. /**
  46042. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46043. */
  46044. get angularSensibilityY(): number;
  46045. set angularSensibilityY(value: number);
  46046. /**
  46047. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46048. */
  46049. get pinchPrecision(): number;
  46050. set pinchPrecision(value: number);
  46051. /**
  46052. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46053. * It will be used instead of pinchDeltaPrecision if different from 0.
  46054. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46055. */
  46056. get pinchDeltaPercentage(): number;
  46057. set pinchDeltaPercentage(value: number);
  46058. /**
  46059. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46060. * and pinch delta percentage.
  46061. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46062. * that any object in the plane at the camera's target point will scale
  46063. * perfectly with finger motion.
  46064. */
  46065. get useNaturalPinchZoom(): boolean;
  46066. set useNaturalPinchZoom(value: boolean);
  46067. /**
  46068. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46069. */
  46070. get panningSensibility(): number;
  46071. set panningSensibility(value: number);
  46072. /**
  46073. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46074. */
  46075. get keysUp(): number[];
  46076. set keysUp(value: number[]);
  46077. /**
  46078. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46079. */
  46080. get keysDown(): number[];
  46081. set keysDown(value: number[]);
  46082. /**
  46083. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46084. */
  46085. get keysLeft(): number[];
  46086. set keysLeft(value: number[]);
  46087. /**
  46088. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46089. */
  46090. get keysRight(): number[];
  46091. set keysRight(value: number[]);
  46092. /**
  46093. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46094. */
  46095. get wheelPrecision(): number;
  46096. set wheelPrecision(value: number);
  46097. /**
  46098. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46099. * It will be used instead of pinchDeltaPrecision if different from 0.
  46100. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46101. */
  46102. get wheelDeltaPercentage(): number;
  46103. set wheelDeltaPercentage(value: number);
  46104. /**
  46105. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46106. */
  46107. zoomOnFactor: number;
  46108. /**
  46109. * Defines a screen offset for the camera position.
  46110. */
  46111. targetScreenOffset: Vector2;
  46112. /**
  46113. * Allows the camera to be completely reversed.
  46114. * If false the camera can not arrive upside down.
  46115. */
  46116. allowUpsideDown: boolean;
  46117. /**
  46118. * Define if double tap/click is used to restore the previously saved state of the camera.
  46119. */
  46120. useInputToRestoreState: boolean;
  46121. /** @hidden */
  46122. _viewMatrix: Matrix;
  46123. /** @hidden */
  46124. _useCtrlForPanning: boolean;
  46125. /** @hidden */
  46126. _panningMouseButton: number;
  46127. /**
  46128. * Defines the input associated to the camera.
  46129. */
  46130. inputs: ArcRotateCameraInputsManager;
  46131. /** @hidden */
  46132. _reset: () => void;
  46133. /**
  46134. * Defines the allowed panning axis.
  46135. */
  46136. panningAxis: Vector3;
  46137. protected _localDirection: Vector3;
  46138. protected _transformedDirection: Vector3;
  46139. private _bouncingBehavior;
  46140. /**
  46141. * Gets the bouncing behavior of the camera if it has been enabled.
  46142. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46143. */
  46144. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46145. /**
  46146. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46147. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46148. */
  46149. get useBouncingBehavior(): boolean;
  46150. set useBouncingBehavior(value: boolean);
  46151. private _framingBehavior;
  46152. /**
  46153. * Gets the framing behavior of the camera if it has been enabled.
  46154. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46155. */
  46156. get framingBehavior(): Nullable<FramingBehavior>;
  46157. /**
  46158. * Defines if the framing behavior of the camera is enabled on the camera.
  46159. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46160. */
  46161. get useFramingBehavior(): boolean;
  46162. set useFramingBehavior(value: boolean);
  46163. private _autoRotationBehavior;
  46164. /**
  46165. * Gets the auto rotation behavior of the camera if it has been enabled.
  46166. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46167. */
  46168. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46169. /**
  46170. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46171. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46172. */
  46173. get useAutoRotationBehavior(): boolean;
  46174. set useAutoRotationBehavior(value: boolean);
  46175. /**
  46176. * Observable triggered when the mesh target has been changed on the camera.
  46177. */
  46178. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46179. /**
  46180. * Event raised when the camera is colliding with a mesh.
  46181. */
  46182. onCollide: (collidedMesh: AbstractMesh) => void;
  46183. /**
  46184. * Defines whether the camera should check collision with the objects oh the scene.
  46185. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46186. */
  46187. checkCollisions: boolean;
  46188. /**
  46189. * Defines the collision radius of the camera.
  46190. * This simulates a sphere around the camera.
  46191. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46192. */
  46193. collisionRadius: Vector3;
  46194. protected _collider: Collider;
  46195. protected _previousPosition: Vector3;
  46196. protected _collisionVelocity: Vector3;
  46197. protected _newPosition: Vector3;
  46198. protected _previousAlpha: number;
  46199. protected _previousBeta: number;
  46200. protected _previousRadius: number;
  46201. protected _collisionTriggered: boolean;
  46202. protected _targetBoundingCenter: Nullable<Vector3>;
  46203. private _computationVector;
  46204. /**
  46205. * Instantiates a new ArcRotateCamera in a given scene
  46206. * @param name Defines the name of the camera
  46207. * @param alpha Defines the camera rotation along the logitudinal axis
  46208. * @param beta Defines the camera rotation along the latitudinal axis
  46209. * @param radius Defines the camera distance from its target
  46210. * @param target Defines the camera target
  46211. * @param scene Defines the scene the camera belongs to
  46212. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46213. */
  46214. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46215. /** @hidden */
  46216. _initCache(): void;
  46217. /** @hidden */
  46218. _updateCache(ignoreParentClass?: boolean): void;
  46219. protected _getTargetPosition(): Vector3;
  46220. private _storedAlpha;
  46221. private _storedBeta;
  46222. private _storedRadius;
  46223. private _storedTarget;
  46224. private _storedTargetScreenOffset;
  46225. /**
  46226. * Stores the current state of the camera (alpha, beta, radius and target)
  46227. * @returns the camera itself
  46228. */
  46229. storeState(): Camera;
  46230. /**
  46231. * @hidden
  46232. * Restored camera state. You must call storeState() first
  46233. */
  46234. _restoreStateValues(): boolean;
  46235. /** @hidden */
  46236. _isSynchronizedViewMatrix(): boolean;
  46237. /**
  46238. * Attached controls to the current camera.
  46239. * @param element Defines the element the controls should be listened from
  46240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46241. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46242. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46243. */
  46244. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  46245. /**
  46246. * Detach the current controls from the camera.
  46247. * The camera will stop reacting to inputs.
  46248. * @param element Defines the element to stop listening the inputs from
  46249. */
  46250. detachControl(element: HTMLElement): void;
  46251. /** @hidden */
  46252. _checkInputs(): void;
  46253. protected _checkLimits(): void;
  46254. /**
  46255. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46256. */
  46257. rebuildAnglesAndRadius(): void;
  46258. /**
  46259. * Use a position to define the current camera related information like alpha, beta and radius
  46260. * @param position Defines the position to set the camera at
  46261. */
  46262. setPosition(position: Vector3): void;
  46263. /**
  46264. * Defines the target the camera should look at.
  46265. * This will automatically adapt alpha beta and radius to fit within the new target.
  46266. * @param target Defines the new target as a Vector or a mesh
  46267. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46268. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46269. */
  46270. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46271. /** @hidden */
  46272. _getViewMatrix(): Matrix;
  46273. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46274. /**
  46275. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46276. * @param meshes Defines the mesh to zoom on
  46277. * @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)
  46278. */
  46279. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46280. /**
  46281. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46282. * The target will be changed but the radius
  46283. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46284. * @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)
  46285. */
  46286. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46287. min: Vector3;
  46288. max: Vector3;
  46289. distance: number;
  46290. }, doNotUpdateMaxZ?: boolean): void;
  46291. /**
  46292. * @override
  46293. * Override Camera.createRigCamera
  46294. */
  46295. createRigCamera(name: string, cameraIndex: number): Camera;
  46296. /**
  46297. * @hidden
  46298. * @override
  46299. * Override Camera._updateRigCameras
  46300. */
  46301. _updateRigCameras(): void;
  46302. /**
  46303. * Destroy the camera and release the current resources hold by it.
  46304. */
  46305. dispose(): void;
  46306. /**
  46307. * Gets the current object class name.
  46308. * @return the class name
  46309. */
  46310. getClassName(): string;
  46311. }
  46312. }
  46313. declare module BABYLON {
  46314. /**
  46315. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46316. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46317. */
  46318. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46319. /**
  46320. * Gets the name of the behavior.
  46321. */
  46322. get name(): string;
  46323. private _zoomStopsAnimation;
  46324. private _idleRotationSpeed;
  46325. private _idleRotationWaitTime;
  46326. private _idleRotationSpinupTime;
  46327. /**
  46328. * Sets the flag that indicates if user zooming should stop animation.
  46329. */
  46330. set zoomStopsAnimation(flag: boolean);
  46331. /**
  46332. * Gets the flag that indicates if user zooming should stop animation.
  46333. */
  46334. get zoomStopsAnimation(): boolean;
  46335. /**
  46336. * Sets the default speed at which the camera rotates around the model.
  46337. */
  46338. set idleRotationSpeed(speed: number);
  46339. /**
  46340. * Gets the default speed at which the camera rotates around the model.
  46341. */
  46342. get idleRotationSpeed(): number;
  46343. /**
  46344. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46345. */
  46346. set idleRotationWaitTime(time: number);
  46347. /**
  46348. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46349. */
  46350. get idleRotationWaitTime(): number;
  46351. /**
  46352. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46353. */
  46354. set idleRotationSpinupTime(time: number);
  46355. /**
  46356. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46357. */
  46358. get idleRotationSpinupTime(): number;
  46359. /**
  46360. * Gets a value indicating if the camera is currently rotating because of this behavior
  46361. */
  46362. get rotationInProgress(): boolean;
  46363. private _onPrePointerObservableObserver;
  46364. private _onAfterCheckInputsObserver;
  46365. private _attachedCamera;
  46366. private _isPointerDown;
  46367. private _lastFrameTime;
  46368. private _lastInteractionTime;
  46369. private _cameraRotationSpeed;
  46370. /**
  46371. * Initializes the behavior.
  46372. */
  46373. init(): void;
  46374. /**
  46375. * Attaches the behavior to its arc rotate camera.
  46376. * @param camera Defines the camera to attach the behavior to
  46377. */
  46378. attach(camera: ArcRotateCamera): void;
  46379. /**
  46380. * Detaches the behavior from its current arc rotate camera.
  46381. */
  46382. detach(): void;
  46383. /**
  46384. * Returns true if user is scrolling.
  46385. * @return true if user is scrolling.
  46386. */
  46387. private _userIsZooming;
  46388. private _lastFrameRadius;
  46389. private _shouldAnimationStopForInteraction;
  46390. /**
  46391. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46392. */
  46393. private _applyUserInteraction;
  46394. private _userIsMoving;
  46395. }
  46396. }
  46397. declare module BABYLON {
  46398. /**
  46399. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46400. */
  46401. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46402. private ui;
  46403. /**
  46404. * The name of the behavior
  46405. */
  46406. name: string;
  46407. /**
  46408. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46409. */
  46410. distanceAwayFromFace: number;
  46411. /**
  46412. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46413. */
  46414. distanceAwayFromBottomOfFace: number;
  46415. private _faceVectors;
  46416. private _target;
  46417. private _scene;
  46418. private _onRenderObserver;
  46419. private _tmpMatrix;
  46420. private _tmpVector;
  46421. /**
  46422. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46423. * @param ui The transform node that should be attched to the mesh
  46424. */
  46425. constructor(ui: TransformNode);
  46426. /**
  46427. * Initializes the behavior
  46428. */
  46429. init(): void;
  46430. private _closestFace;
  46431. private _zeroVector;
  46432. private _lookAtTmpMatrix;
  46433. private _lookAtToRef;
  46434. /**
  46435. * Attaches the AttachToBoxBehavior to the passed in mesh
  46436. * @param target The mesh that the specified node will be attached to
  46437. */
  46438. attach(target: Mesh): void;
  46439. /**
  46440. * Detaches the behavior from the mesh
  46441. */
  46442. detach(): void;
  46443. }
  46444. }
  46445. declare module BABYLON {
  46446. /**
  46447. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46448. */
  46449. export class FadeInOutBehavior implements Behavior<Mesh> {
  46450. /**
  46451. * Time in milliseconds to delay before fading in (Default: 0)
  46452. */
  46453. delay: number;
  46454. /**
  46455. * Time in milliseconds for the mesh to fade in (Default: 300)
  46456. */
  46457. fadeInTime: number;
  46458. private _millisecondsPerFrame;
  46459. private _hovered;
  46460. private _hoverValue;
  46461. private _ownerNode;
  46462. /**
  46463. * Instatiates the FadeInOutBehavior
  46464. */
  46465. constructor();
  46466. /**
  46467. * The name of the behavior
  46468. */
  46469. get name(): string;
  46470. /**
  46471. * Initializes the behavior
  46472. */
  46473. init(): void;
  46474. /**
  46475. * Attaches the fade behavior on the passed in mesh
  46476. * @param ownerNode The mesh that will be faded in/out once attached
  46477. */
  46478. attach(ownerNode: Mesh): void;
  46479. /**
  46480. * Detaches the behavior from the mesh
  46481. */
  46482. detach(): void;
  46483. /**
  46484. * Triggers the mesh to begin fading in or out
  46485. * @param value if the object should fade in or out (true to fade in)
  46486. */
  46487. fadeIn(value: boolean): void;
  46488. private _update;
  46489. private _setAllVisibility;
  46490. }
  46491. }
  46492. declare module BABYLON {
  46493. /**
  46494. * Class containing a set of static utilities functions for managing Pivots
  46495. * @hidden
  46496. */
  46497. export class PivotTools {
  46498. private static _PivotCached;
  46499. private static _OldPivotPoint;
  46500. private static _PivotTranslation;
  46501. private static _PivotTmpVector;
  46502. private static _PivotPostMultiplyPivotMatrix;
  46503. /** @hidden */
  46504. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46505. /** @hidden */
  46506. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46507. }
  46508. }
  46509. declare module BABYLON {
  46510. /**
  46511. * Class containing static functions to help procedurally build meshes
  46512. */
  46513. export class PlaneBuilder {
  46514. /**
  46515. * Creates a plane mesh
  46516. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46517. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46518. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46520. * * 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
  46521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46522. * @param name defines the name of the mesh
  46523. * @param options defines the options used to create the mesh
  46524. * @param scene defines the hosting scene
  46525. * @returns the plane mesh
  46526. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46527. */
  46528. static CreatePlane(name: string, options: {
  46529. size?: number;
  46530. width?: number;
  46531. height?: number;
  46532. sideOrientation?: number;
  46533. frontUVs?: Vector4;
  46534. backUVs?: Vector4;
  46535. updatable?: boolean;
  46536. sourcePlane?: Plane;
  46537. }, scene?: Nullable<Scene>): Mesh;
  46538. }
  46539. }
  46540. declare module BABYLON {
  46541. /**
  46542. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46543. */
  46544. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46545. private static _AnyMouseID;
  46546. /**
  46547. * Abstract mesh the behavior is set on
  46548. */
  46549. attachedNode: AbstractMesh;
  46550. private _dragPlane;
  46551. private _scene;
  46552. private _pointerObserver;
  46553. private _beforeRenderObserver;
  46554. private static _planeScene;
  46555. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46556. /**
  46557. * 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)
  46558. */
  46559. maxDragAngle: number;
  46560. /**
  46561. * @hidden
  46562. */
  46563. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46564. /**
  46565. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46566. */
  46567. currentDraggingPointerID: number;
  46568. /**
  46569. * The last position where the pointer hit the drag plane in world space
  46570. */
  46571. lastDragPosition: Vector3;
  46572. /**
  46573. * If the behavior is currently in a dragging state
  46574. */
  46575. dragging: boolean;
  46576. /**
  46577. * 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)
  46578. */
  46579. dragDeltaRatio: number;
  46580. /**
  46581. * If the drag plane orientation should be updated during the dragging (Default: true)
  46582. */
  46583. updateDragPlane: boolean;
  46584. private _debugMode;
  46585. private _moving;
  46586. /**
  46587. * Fires each time the attached mesh is dragged with the pointer
  46588. * * delta between last drag position and current drag position in world space
  46589. * * dragDistance along the drag axis
  46590. * * dragPlaneNormal normal of the current drag plane used during the drag
  46591. * * dragPlanePoint in world space where the drag intersects the drag plane
  46592. */
  46593. onDragObservable: Observable<{
  46594. delta: Vector3;
  46595. dragPlanePoint: Vector3;
  46596. dragPlaneNormal: Vector3;
  46597. dragDistance: number;
  46598. pointerId: number;
  46599. }>;
  46600. /**
  46601. * Fires each time a drag begins (eg. mouse down on mesh)
  46602. */
  46603. onDragStartObservable: Observable<{
  46604. dragPlanePoint: Vector3;
  46605. pointerId: number;
  46606. }>;
  46607. /**
  46608. * Fires each time a drag ends (eg. mouse release after drag)
  46609. */
  46610. onDragEndObservable: Observable<{
  46611. dragPlanePoint: Vector3;
  46612. pointerId: number;
  46613. }>;
  46614. /**
  46615. * If the attached mesh should be moved when dragged
  46616. */
  46617. moveAttached: boolean;
  46618. /**
  46619. * If the drag behavior will react to drag events (Default: true)
  46620. */
  46621. enabled: boolean;
  46622. /**
  46623. * If pointer events should start and release the drag (Default: true)
  46624. */
  46625. startAndReleaseDragOnPointerEvents: boolean;
  46626. /**
  46627. * If camera controls should be detached during the drag
  46628. */
  46629. detachCameraControls: boolean;
  46630. /**
  46631. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46632. */
  46633. useObjectOrientationForDragging: boolean;
  46634. private _options;
  46635. /**
  46636. * Gets the options used by the behavior
  46637. */
  46638. get options(): {
  46639. dragAxis?: Vector3;
  46640. dragPlaneNormal?: Vector3;
  46641. };
  46642. /**
  46643. * Sets the options used by the behavior
  46644. */
  46645. set options(options: {
  46646. dragAxis?: Vector3;
  46647. dragPlaneNormal?: Vector3;
  46648. });
  46649. /**
  46650. * Creates a pointer drag behavior that can be attached to a mesh
  46651. * @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)
  46652. */
  46653. constructor(options?: {
  46654. dragAxis?: Vector3;
  46655. dragPlaneNormal?: Vector3;
  46656. });
  46657. /**
  46658. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46659. */
  46660. validateDrag: (targetPosition: Vector3) => boolean;
  46661. /**
  46662. * The name of the behavior
  46663. */
  46664. get name(): string;
  46665. /**
  46666. * Initializes the behavior
  46667. */
  46668. init(): void;
  46669. private _tmpVector;
  46670. private _alternatePickedPoint;
  46671. private _worldDragAxis;
  46672. private _targetPosition;
  46673. private _attachedElement;
  46674. /**
  46675. * Attaches the drag behavior the passed in mesh
  46676. * @param ownerNode The mesh that will be dragged around once attached
  46677. * @param predicate Predicate to use for pick filtering
  46678. */
  46679. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  46680. /**
  46681. * Force relase the drag action by code.
  46682. */
  46683. releaseDrag(): void;
  46684. private _startDragRay;
  46685. private _lastPointerRay;
  46686. /**
  46687. * Simulates the start of a pointer drag event on the behavior
  46688. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  46689. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  46690. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  46691. */
  46692. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46693. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46694. private _dragDelta;
  46695. protected _moveDrag(ray: Ray): void;
  46696. private _pickWithRayOnDragPlane;
  46697. private _pointA;
  46698. private _pointC;
  46699. private _localAxis;
  46700. private _lookAt;
  46701. private _updateDragPlanePosition;
  46702. /**
  46703. * Detaches the behavior from the mesh
  46704. */
  46705. detach(): void;
  46706. }
  46707. }
  46708. declare module BABYLON {
  46709. /**
  46710. * A behavior that when attached to a mesh will allow the mesh to be scaled
  46711. */
  46712. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  46713. private _dragBehaviorA;
  46714. private _dragBehaviorB;
  46715. private _startDistance;
  46716. private _initialScale;
  46717. private _targetScale;
  46718. private _ownerNode;
  46719. private _sceneRenderObserver;
  46720. /**
  46721. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  46722. */
  46723. constructor();
  46724. /**
  46725. * The name of the behavior
  46726. */
  46727. get name(): string;
  46728. /**
  46729. * Initializes the behavior
  46730. */
  46731. init(): void;
  46732. private _getCurrentDistance;
  46733. /**
  46734. * Attaches the scale behavior the passed in mesh
  46735. * @param ownerNode The mesh that will be scaled around once attached
  46736. */
  46737. attach(ownerNode: Mesh): void;
  46738. /**
  46739. * Detaches the behavior from the mesh
  46740. */
  46741. detach(): void;
  46742. }
  46743. }
  46744. declare module BABYLON {
  46745. /**
  46746. * 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
  46747. */
  46748. export class SixDofDragBehavior implements Behavior<Mesh> {
  46749. private static _virtualScene;
  46750. private _ownerNode;
  46751. private _sceneRenderObserver;
  46752. private _scene;
  46753. private _targetPosition;
  46754. private _virtualOriginMesh;
  46755. private _virtualDragMesh;
  46756. private _pointerObserver;
  46757. private _moving;
  46758. private _startingOrientation;
  46759. private _attachedElement;
  46760. /**
  46761. * 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)
  46762. */
  46763. private zDragFactor;
  46764. /**
  46765. * If the object should rotate to face the drag origin
  46766. */
  46767. rotateDraggedObject: boolean;
  46768. /**
  46769. * If the behavior is currently in a dragging state
  46770. */
  46771. dragging: boolean;
  46772. /**
  46773. * 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)
  46774. */
  46775. dragDeltaRatio: number;
  46776. /**
  46777. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46778. */
  46779. currentDraggingPointerID: number;
  46780. /**
  46781. * If camera controls should be detached during the drag
  46782. */
  46783. detachCameraControls: boolean;
  46784. /**
  46785. * Fires each time a drag starts
  46786. */
  46787. onDragStartObservable: Observable<{}>;
  46788. /**
  46789. * Fires each time a drag ends (eg. mouse release after drag)
  46790. */
  46791. onDragEndObservable: Observable<{}>;
  46792. /**
  46793. * 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
  46794. */
  46795. constructor();
  46796. /**
  46797. * The name of the behavior
  46798. */
  46799. get name(): string;
  46800. /**
  46801. * Initializes the behavior
  46802. */
  46803. init(): void;
  46804. /**
  46805. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  46806. */
  46807. private get _pointerCamera();
  46808. /**
  46809. * Attaches the scale behavior the passed in mesh
  46810. * @param ownerNode The mesh that will be scaled around once attached
  46811. */
  46812. attach(ownerNode: Mesh): void;
  46813. /**
  46814. * Detaches the behavior from the mesh
  46815. */
  46816. detach(): void;
  46817. }
  46818. }
  46819. declare module BABYLON {
  46820. /**
  46821. * Class used to apply inverse kinematics to bones
  46822. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  46823. */
  46824. export class BoneIKController {
  46825. private static _tmpVecs;
  46826. private static _tmpQuat;
  46827. private static _tmpMats;
  46828. /**
  46829. * Gets or sets the target mesh
  46830. */
  46831. targetMesh: AbstractMesh;
  46832. /** Gets or sets the mesh used as pole */
  46833. poleTargetMesh: AbstractMesh;
  46834. /**
  46835. * Gets or sets the bone used as pole
  46836. */
  46837. poleTargetBone: Nullable<Bone>;
  46838. /**
  46839. * Gets or sets the target position
  46840. */
  46841. targetPosition: Vector3;
  46842. /**
  46843. * Gets or sets the pole target position
  46844. */
  46845. poleTargetPosition: Vector3;
  46846. /**
  46847. * Gets or sets the pole target local offset
  46848. */
  46849. poleTargetLocalOffset: Vector3;
  46850. /**
  46851. * Gets or sets the pole angle
  46852. */
  46853. poleAngle: number;
  46854. /**
  46855. * Gets or sets the mesh associated with the controller
  46856. */
  46857. mesh: AbstractMesh;
  46858. /**
  46859. * 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)
  46860. */
  46861. slerpAmount: number;
  46862. private _bone1Quat;
  46863. private _bone1Mat;
  46864. private _bone2Ang;
  46865. private _bone1;
  46866. private _bone2;
  46867. private _bone1Length;
  46868. private _bone2Length;
  46869. private _maxAngle;
  46870. private _maxReach;
  46871. private _rightHandedSystem;
  46872. private _bendAxis;
  46873. private _slerping;
  46874. private _adjustRoll;
  46875. /**
  46876. * Gets or sets maximum allowed angle
  46877. */
  46878. get maxAngle(): number;
  46879. set maxAngle(value: number);
  46880. /**
  46881. * Creates a new BoneIKController
  46882. * @param mesh defines the mesh to control
  46883. * @param bone defines the bone to control
  46884. * @param options defines options to set up the controller
  46885. */
  46886. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  46887. targetMesh?: AbstractMesh;
  46888. poleTargetMesh?: AbstractMesh;
  46889. poleTargetBone?: Bone;
  46890. poleTargetLocalOffset?: Vector3;
  46891. poleAngle?: number;
  46892. bendAxis?: Vector3;
  46893. maxAngle?: number;
  46894. slerpAmount?: number;
  46895. });
  46896. private _setMaxAngle;
  46897. /**
  46898. * Force the controller to update the bones
  46899. */
  46900. update(): void;
  46901. }
  46902. }
  46903. declare module BABYLON {
  46904. /**
  46905. * Class used to make a bone look toward a point in space
  46906. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  46907. */
  46908. export class BoneLookController {
  46909. private static _tmpVecs;
  46910. private static _tmpQuat;
  46911. private static _tmpMats;
  46912. /**
  46913. * The target Vector3 that the bone will look at
  46914. */
  46915. target: Vector3;
  46916. /**
  46917. * The mesh that the bone is attached to
  46918. */
  46919. mesh: AbstractMesh;
  46920. /**
  46921. * The bone that will be looking to the target
  46922. */
  46923. bone: Bone;
  46924. /**
  46925. * The up axis of the coordinate system that is used when the bone is rotated
  46926. */
  46927. upAxis: Vector3;
  46928. /**
  46929. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  46930. */
  46931. upAxisSpace: Space;
  46932. /**
  46933. * Used to make an adjustment to the yaw of the bone
  46934. */
  46935. adjustYaw: number;
  46936. /**
  46937. * Used to make an adjustment to the pitch of the bone
  46938. */
  46939. adjustPitch: number;
  46940. /**
  46941. * Used to make an adjustment to the roll of the bone
  46942. */
  46943. adjustRoll: number;
  46944. /**
  46945. * 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)
  46946. */
  46947. slerpAmount: number;
  46948. private _minYaw;
  46949. private _maxYaw;
  46950. private _minPitch;
  46951. private _maxPitch;
  46952. private _minYawSin;
  46953. private _minYawCos;
  46954. private _maxYawSin;
  46955. private _maxYawCos;
  46956. private _midYawConstraint;
  46957. private _minPitchTan;
  46958. private _maxPitchTan;
  46959. private _boneQuat;
  46960. private _slerping;
  46961. private _transformYawPitch;
  46962. private _transformYawPitchInv;
  46963. private _firstFrameSkipped;
  46964. private _yawRange;
  46965. private _fowardAxis;
  46966. /**
  46967. * Gets or sets the minimum yaw angle that the bone can look to
  46968. */
  46969. get minYaw(): number;
  46970. set minYaw(value: number);
  46971. /**
  46972. * Gets or sets the maximum yaw angle that the bone can look to
  46973. */
  46974. get maxYaw(): number;
  46975. set maxYaw(value: number);
  46976. /**
  46977. * Gets or sets the minimum pitch angle that the bone can look to
  46978. */
  46979. get minPitch(): number;
  46980. set minPitch(value: number);
  46981. /**
  46982. * Gets or sets the maximum pitch angle that the bone can look to
  46983. */
  46984. get maxPitch(): number;
  46985. set maxPitch(value: number);
  46986. /**
  46987. * Create a BoneLookController
  46988. * @param mesh the mesh that the bone belongs to
  46989. * @param bone the bone that will be looking to the target
  46990. * @param target the target Vector3 to look at
  46991. * @param options optional settings:
  46992. * * maxYaw: the maximum angle the bone will yaw to
  46993. * * minYaw: the minimum angle the bone will yaw to
  46994. * * maxPitch: the maximum angle the bone will pitch to
  46995. * * minPitch: the minimum angle the bone will yaw to
  46996. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  46997. * * upAxis: the up axis of the coordinate system
  46998. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  46999. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47000. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47001. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47002. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47003. * * adjustRoll: used to make an adjustment to the roll of the bone
  47004. **/
  47005. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47006. maxYaw?: number;
  47007. minYaw?: number;
  47008. maxPitch?: number;
  47009. minPitch?: number;
  47010. slerpAmount?: number;
  47011. upAxis?: Vector3;
  47012. upAxisSpace?: Space;
  47013. yawAxis?: Vector3;
  47014. pitchAxis?: Vector3;
  47015. adjustYaw?: number;
  47016. adjustPitch?: number;
  47017. adjustRoll?: number;
  47018. });
  47019. /**
  47020. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47021. */
  47022. update(): void;
  47023. private _getAngleDiff;
  47024. private _getAngleBetween;
  47025. private _isAngleBetween;
  47026. }
  47027. }
  47028. declare module BABYLON {
  47029. /**
  47030. * Manage the gamepad inputs to control an arc rotate camera.
  47031. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47032. */
  47033. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47034. /**
  47035. * Defines the camera the input is attached to.
  47036. */
  47037. camera: ArcRotateCamera;
  47038. /**
  47039. * Defines the gamepad the input is gathering event from.
  47040. */
  47041. gamepad: Nullable<Gamepad>;
  47042. /**
  47043. * Defines the gamepad rotation sensiblity.
  47044. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47045. */
  47046. gamepadRotationSensibility: number;
  47047. /**
  47048. * Defines the gamepad move sensiblity.
  47049. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47050. */
  47051. gamepadMoveSensibility: number;
  47052. private _yAxisScale;
  47053. /**
  47054. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47055. */
  47056. get invertYAxis(): boolean;
  47057. set invertYAxis(value: boolean);
  47058. private _onGamepadConnectedObserver;
  47059. private _onGamepadDisconnectedObserver;
  47060. /**
  47061. * Attach the input controls to a specific dom element to get the input from.
  47062. * @param element Defines the element the controls should be listened from
  47063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47064. */
  47065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47066. /**
  47067. * Detach the current controls from the specified dom element.
  47068. * @param element Defines the element to stop listening the inputs from
  47069. */
  47070. detachControl(element: Nullable<HTMLElement>): void;
  47071. /**
  47072. * Update the current camera state depending on the inputs that have been used this frame.
  47073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47074. */
  47075. checkInputs(): void;
  47076. /**
  47077. * Gets the class name of the current intput.
  47078. * @returns the class name
  47079. */
  47080. getClassName(): string;
  47081. /**
  47082. * Get the friendly name associated with the input class.
  47083. * @returns the input friendly name
  47084. */
  47085. getSimpleName(): string;
  47086. }
  47087. }
  47088. declare module BABYLON {
  47089. interface ArcRotateCameraInputsManager {
  47090. /**
  47091. * Add orientation input support to the input manager.
  47092. * @returns the current input manager
  47093. */
  47094. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47095. }
  47096. /**
  47097. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47098. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47099. */
  47100. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47101. /**
  47102. * Defines the camera the input is attached to.
  47103. */
  47104. camera: ArcRotateCamera;
  47105. /**
  47106. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47107. */
  47108. alphaCorrection: number;
  47109. /**
  47110. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47111. */
  47112. gammaCorrection: number;
  47113. private _alpha;
  47114. private _gamma;
  47115. private _dirty;
  47116. private _deviceOrientationHandler;
  47117. /**
  47118. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47119. */
  47120. constructor();
  47121. /**
  47122. * Attach the input controls to a specific dom element to get the input from.
  47123. * @param element Defines the element the controls should be listened from
  47124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47125. */
  47126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47127. /** @hidden */
  47128. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47129. /**
  47130. * Update the current camera state depending on the inputs that have been used this frame.
  47131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47132. */
  47133. checkInputs(): void;
  47134. /**
  47135. * Detach the current controls from the specified dom element.
  47136. * @param element Defines the element to stop listening the inputs from
  47137. */
  47138. detachControl(element: Nullable<HTMLElement>): void;
  47139. /**
  47140. * Gets the class name of the current intput.
  47141. * @returns the class name
  47142. */
  47143. getClassName(): string;
  47144. /**
  47145. * Get the friendly name associated with the input class.
  47146. * @returns the input friendly name
  47147. */
  47148. getSimpleName(): string;
  47149. }
  47150. }
  47151. declare module BABYLON {
  47152. /**
  47153. * Listen to mouse events to control the camera.
  47154. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47155. */
  47156. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47157. /**
  47158. * Defines the camera the input is attached to.
  47159. */
  47160. camera: FlyCamera;
  47161. /**
  47162. * Defines if touch is enabled. (Default is true.)
  47163. */
  47164. touchEnabled: boolean;
  47165. /**
  47166. * Defines the buttons associated with the input to handle camera rotation.
  47167. */
  47168. buttons: number[];
  47169. /**
  47170. * Assign buttons for Yaw control.
  47171. */
  47172. buttonsYaw: number[];
  47173. /**
  47174. * Assign buttons for Pitch control.
  47175. */
  47176. buttonsPitch: number[];
  47177. /**
  47178. * Assign buttons for Roll control.
  47179. */
  47180. buttonsRoll: number[];
  47181. /**
  47182. * Detect if any button is being pressed while mouse is moved.
  47183. * -1 = Mouse locked.
  47184. * 0 = Left button.
  47185. * 1 = Middle Button.
  47186. * 2 = Right Button.
  47187. */
  47188. activeButton: number;
  47189. /**
  47190. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47191. * Higher values reduce its sensitivity.
  47192. */
  47193. angularSensibility: number;
  47194. private _observer;
  47195. private _rollObserver;
  47196. private previousPosition;
  47197. private noPreventDefault;
  47198. private element;
  47199. /**
  47200. * Listen to mouse events to control the camera.
  47201. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47202. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47203. */
  47204. constructor(touchEnabled?: boolean);
  47205. /**
  47206. * Attach the mouse control to the HTML DOM element.
  47207. * @param element Defines the element that listens to the input events.
  47208. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47209. */
  47210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47211. /**
  47212. * Detach the current controls from the specified dom element.
  47213. * @param element Defines the element to stop listening the inputs from
  47214. */
  47215. detachControl(element: Nullable<HTMLElement>): void;
  47216. /**
  47217. * Gets the class name of the current input.
  47218. * @returns the class name.
  47219. */
  47220. getClassName(): string;
  47221. /**
  47222. * Get the friendly name associated with the input class.
  47223. * @returns the input's friendly name.
  47224. */
  47225. getSimpleName(): string;
  47226. private _pointerInput;
  47227. private _onMouseMove;
  47228. /**
  47229. * Rotate camera by mouse offset.
  47230. */
  47231. private rotateCamera;
  47232. }
  47233. }
  47234. declare module BABYLON {
  47235. /**
  47236. * Default Inputs manager for the FlyCamera.
  47237. * It groups all the default supported inputs for ease of use.
  47238. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47239. */
  47240. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47241. /**
  47242. * Instantiates a new FlyCameraInputsManager.
  47243. * @param camera Defines the camera the inputs belong to.
  47244. */
  47245. constructor(camera: FlyCamera);
  47246. /**
  47247. * Add keyboard input support to the input manager.
  47248. * @returns the new FlyCameraKeyboardMoveInput().
  47249. */
  47250. addKeyboard(): FlyCameraInputsManager;
  47251. /**
  47252. * Add mouse input support to the input manager.
  47253. * @param touchEnabled Enable touch screen support.
  47254. * @returns the new FlyCameraMouseInput().
  47255. */
  47256. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47257. }
  47258. }
  47259. declare module BABYLON {
  47260. /**
  47261. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47262. * such as in a 3D Space Shooter or a Flight Simulator.
  47263. */
  47264. export class FlyCamera extends TargetCamera {
  47265. /**
  47266. * Define the collision ellipsoid of the camera.
  47267. * This is helpful for simulating a camera body, like a player's body.
  47268. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47269. */
  47270. ellipsoid: Vector3;
  47271. /**
  47272. * Define an offset for the position of the ellipsoid around the camera.
  47273. * This can be helpful if the camera is attached away from the player's body center,
  47274. * such as at its head.
  47275. */
  47276. ellipsoidOffset: Vector3;
  47277. /**
  47278. * Enable or disable collisions of the camera with the rest of the scene objects.
  47279. */
  47280. checkCollisions: boolean;
  47281. /**
  47282. * Enable or disable gravity on the camera.
  47283. */
  47284. applyGravity: boolean;
  47285. /**
  47286. * Define the current direction the camera is moving to.
  47287. */
  47288. cameraDirection: Vector3;
  47289. /**
  47290. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47291. * This overrides and empties cameraRotation.
  47292. */
  47293. rotationQuaternion: Quaternion;
  47294. /**
  47295. * Track Roll to maintain the wanted Rolling when looking around.
  47296. */
  47297. _trackRoll: number;
  47298. /**
  47299. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47300. */
  47301. rollCorrect: number;
  47302. /**
  47303. * Mimic a banked turn, Rolling the camera when Yawing.
  47304. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47305. */
  47306. bankedTurn: boolean;
  47307. /**
  47308. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47309. */
  47310. bankedTurnLimit: number;
  47311. /**
  47312. * Value of 0 disables the banked Roll.
  47313. * Value of 1 is equal to the Yaw angle in radians.
  47314. */
  47315. bankedTurnMultiplier: number;
  47316. /**
  47317. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47318. */
  47319. inputs: FlyCameraInputsManager;
  47320. /**
  47321. * Gets the input sensibility for mouse input.
  47322. * Higher values reduce sensitivity.
  47323. */
  47324. get angularSensibility(): number;
  47325. /**
  47326. * Sets the input sensibility for a mouse input.
  47327. * Higher values reduce sensitivity.
  47328. */
  47329. set angularSensibility(value: number);
  47330. /**
  47331. * Get the keys for camera movement forward.
  47332. */
  47333. get keysForward(): number[];
  47334. /**
  47335. * Set the keys for camera movement forward.
  47336. */
  47337. set keysForward(value: number[]);
  47338. /**
  47339. * Get the keys for camera movement backward.
  47340. */
  47341. get keysBackward(): number[];
  47342. set keysBackward(value: number[]);
  47343. /**
  47344. * Get the keys for camera movement up.
  47345. */
  47346. get keysUp(): number[];
  47347. /**
  47348. * Set the keys for camera movement up.
  47349. */
  47350. set keysUp(value: number[]);
  47351. /**
  47352. * Get the keys for camera movement down.
  47353. */
  47354. get keysDown(): number[];
  47355. /**
  47356. * Set the keys for camera movement down.
  47357. */
  47358. set keysDown(value: number[]);
  47359. /**
  47360. * Get the keys for camera movement left.
  47361. */
  47362. get keysLeft(): number[];
  47363. /**
  47364. * Set the keys for camera movement left.
  47365. */
  47366. set keysLeft(value: number[]);
  47367. /**
  47368. * Set the keys for camera movement right.
  47369. */
  47370. get keysRight(): number[];
  47371. /**
  47372. * Set the keys for camera movement right.
  47373. */
  47374. set keysRight(value: number[]);
  47375. /**
  47376. * Event raised when the camera collides with a mesh in the scene.
  47377. */
  47378. onCollide: (collidedMesh: AbstractMesh) => void;
  47379. private _collider;
  47380. private _needMoveForGravity;
  47381. private _oldPosition;
  47382. private _diffPosition;
  47383. private _newPosition;
  47384. /** @hidden */
  47385. _localDirection: Vector3;
  47386. /** @hidden */
  47387. _transformedDirection: Vector3;
  47388. /**
  47389. * Instantiates a FlyCamera.
  47390. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47391. * such as in a 3D Space Shooter or a Flight Simulator.
  47392. * @param name Define the name of the camera in the scene.
  47393. * @param position Define the starting position of the camera in the scene.
  47394. * @param scene Define the scene the camera belongs to.
  47395. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47396. */
  47397. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47398. /**
  47399. * Attach a control to the HTML DOM element.
  47400. * @param element Defines the element that listens to the input events.
  47401. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47402. */
  47403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47404. /**
  47405. * Detach a control from the HTML DOM element.
  47406. * The camera will stop reacting to that input.
  47407. * @param element Defines the element that listens to the input events.
  47408. */
  47409. detachControl(element: HTMLElement): void;
  47410. private _collisionMask;
  47411. /**
  47412. * Get the mask that the camera ignores in collision events.
  47413. */
  47414. get collisionMask(): number;
  47415. /**
  47416. * Set the mask that the camera ignores in collision events.
  47417. */
  47418. set collisionMask(mask: number);
  47419. /** @hidden */
  47420. _collideWithWorld(displacement: Vector3): void;
  47421. /** @hidden */
  47422. private _onCollisionPositionChange;
  47423. /** @hidden */
  47424. _checkInputs(): void;
  47425. /** @hidden */
  47426. _decideIfNeedsToMove(): boolean;
  47427. /** @hidden */
  47428. _updatePosition(): void;
  47429. /**
  47430. * Restore the Roll to its target value at the rate specified.
  47431. * @param rate - Higher means slower restoring.
  47432. * @hidden
  47433. */
  47434. restoreRoll(rate: number): void;
  47435. /**
  47436. * Destroy the camera and release the current resources held by it.
  47437. */
  47438. dispose(): void;
  47439. /**
  47440. * Get the current object class name.
  47441. * @returns the class name.
  47442. */
  47443. getClassName(): string;
  47444. }
  47445. }
  47446. declare module BABYLON {
  47447. /**
  47448. * Listen to keyboard events to control the camera.
  47449. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47450. */
  47451. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47452. /**
  47453. * Defines the camera the input is attached to.
  47454. */
  47455. camera: FlyCamera;
  47456. /**
  47457. * The list of keyboard keys used to control the forward move of the camera.
  47458. */
  47459. keysForward: number[];
  47460. /**
  47461. * The list of keyboard keys used to control the backward move of the camera.
  47462. */
  47463. keysBackward: number[];
  47464. /**
  47465. * The list of keyboard keys used to control the forward move of the camera.
  47466. */
  47467. keysUp: number[];
  47468. /**
  47469. * The list of keyboard keys used to control the backward move of the camera.
  47470. */
  47471. keysDown: number[];
  47472. /**
  47473. * The list of keyboard keys used to control the right strafe move of the camera.
  47474. */
  47475. keysRight: number[];
  47476. /**
  47477. * The list of keyboard keys used to control the left strafe move of the camera.
  47478. */
  47479. keysLeft: number[];
  47480. private _keys;
  47481. private _onCanvasBlurObserver;
  47482. private _onKeyboardObserver;
  47483. private _engine;
  47484. private _scene;
  47485. /**
  47486. * Attach the input controls to a specific dom element to get the input from.
  47487. * @param element Defines the element the controls should be listened from
  47488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47489. */
  47490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47491. /**
  47492. * Detach the current controls from the specified dom element.
  47493. * @param element Defines the element to stop listening the inputs from
  47494. */
  47495. detachControl(element: Nullable<HTMLElement>): void;
  47496. /**
  47497. * Gets the class name of the current intput.
  47498. * @returns the class name
  47499. */
  47500. getClassName(): string;
  47501. /** @hidden */
  47502. _onLostFocus(e: FocusEvent): void;
  47503. /**
  47504. * Get the friendly name associated with the input class.
  47505. * @returns the input friendly name
  47506. */
  47507. getSimpleName(): string;
  47508. /**
  47509. * Update the current camera state depending on the inputs that have been used this frame.
  47510. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47511. */
  47512. checkInputs(): void;
  47513. }
  47514. }
  47515. declare module BABYLON {
  47516. /**
  47517. * Manage the mouse wheel inputs to control a follow camera.
  47518. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47519. */
  47520. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47521. /**
  47522. * Defines the camera the input is attached to.
  47523. */
  47524. camera: FollowCamera;
  47525. /**
  47526. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47527. */
  47528. axisControlRadius: boolean;
  47529. /**
  47530. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47531. */
  47532. axisControlHeight: boolean;
  47533. /**
  47534. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47535. */
  47536. axisControlRotation: boolean;
  47537. /**
  47538. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47539. * relation to mouseWheel events.
  47540. */
  47541. wheelPrecision: number;
  47542. /**
  47543. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47544. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47545. */
  47546. wheelDeltaPercentage: number;
  47547. private _wheel;
  47548. private _observer;
  47549. /**
  47550. * Attach the input controls to a specific dom element to get the input from.
  47551. * @param element Defines the element the controls should be listened from
  47552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47553. */
  47554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47555. /**
  47556. * Detach the current controls from the specified dom element.
  47557. * @param element Defines the element to stop listening the inputs from
  47558. */
  47559. detachControl(element: Nullable<HTMLElement>): void;
  47560. /**
  47561. * Gets the class name of the current intput.
  47562. * @returns the class name
  47563. */
  47564. getClassName(): string;
  47565. /**
  47566. * Get the friendly name associated with the input class.
  47567. * @returns the input friendly name
  47568. */
  47569. getSimpleName(): string;
  47570. }
  47571. }
  47572. declare module BABYLON {
  47573. /**
  47574. * Manage the pointers inputs to control an follow camera.
  47575. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47576. */
  47577. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47578. /**
  47579. * Defines the camera the input is attached to.
  47580. */
  47581. camera: FollowCamera;
  47582. /**
  47583. * Gets the class name of the current input.
  47584. * @returns the class name
  47585. */
  47586. getClassName(): string;
  47587. /**
  47588. * Defines the pointer angular sensibility along the X axis or how fast is
  47589. * the camera rotating.
  47590. * A negative number will reverse the axis direction.
  47591. */
  47592. angularSensibilityX: number;
  47593. /**
  47594. * Defines the pointer angular sensibility along the Y axis or how fast is
  47595. * the camera rotating.
  47596. * A negative number will reverse the axis direction.
  47597. */
  47598. angularSensibilityY: number;
  47599. /**
  47600. * Defines the pointer pinch precision or how fast is the camera zooming.
  47601. * A negative number will reverse the axis direction.
  47602. */
  47603. pinchPrecision: number;
  47604. /**
  47605. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47606. * from 0.
  47607. * It defines the percentage of current camera.radius to use as delta when
  47608. * pinch zoom is used.
  47609. */
  47610. pinchDeltaPercentage: number;
  47611. /**
  47612. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47613. */
  47614. axisXControlRadius: boolean;
  47615. /**
  47616. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47617. */
  47618. axisXControlHeight: boolean;
  47619. /**
  47620. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47621. */
  47622. axisXControlRotation: boolean;
  47623. /**
  47624. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47625. */
  47626. axisYControlRadius: boolean;
  47627. /**
  47628. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47629. */
  47630. axisYControlHeight: boolean;
  47631. /**
  47632. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47633. */
  47634. axisYControlRotation: boolean;
  47635. /**
  47636. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47637. */
  47638. axisPinchControlRadius: boolean;
  47639. /**
  47640. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47641. */
  47642. axisPinchControlHeight: boolean;
  47643. /**
  47644. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47645. */
  47646. axisPinchControlRotation: boolean;
  47647. /**
  47648. * Log error messages if basic misconfiguration has occurred.
  47649. */
  47650. warningEnable: boolean;
  47651. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47652. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47653. private _warningCounter;
  47654. private _warning;
  47655. }
  47656. }
  47657. declare module BABYLON {
  47658. /**
  47659. * Default Inputs manager for the FollowCamera.
  47660. * It groups all the default supported inputs for ease of use.
  47661. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47662. */
  47663. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47664. /**
  47665. * Instantiates a new FollowCameraInputsManager.
  47666. * @param camera Defines the camera the inputs belong to
  47667. */
  47668. constructor(camera: FollowCamera);
  47669. /**
  47670. * Add keyboard input support to the input manager.
  47671. * @returns the current input manager
  47672. */
  47673. addKeyboard(): FollowCameraInputsManager;
  47674. /**
  47675. * Add mouse wheel input support to the input manager.
  47676. * @returns the current input manager
  47677. */
  47678. addMouseWheel(): FollowCameraInputsManager;
  47679. /**
  47680. * Add pointers input support to the input manager.
  47681. * @returns the current input manager
  47682. */
  47683. addPointers(): FollowCameraInputsManager;
  47684. /**
  47685. * Add orientation input support to the input manager.
  47686. * @returns the current input manager
  47687. */
  47688. addVRDeviceOrientation(): FollowCameraInputsManager;
  47689. }
  47690. }
  47691. declare module BABYLON {
  47692. /**
  47693. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  47694. * an arc rotate version arcFollowCamera are available.
  47695. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47696. */
  47697. export class FollowCamera extends TargetCamera {
  47698. /**
  47699. * Distance the follow camera should follow an object at
  47700. */
  47701. radius: number;
  47702. /**
  47703. * Minimum allowed distance of the camera to the axis of rotation
  47704. * (The camera can not get closer).
  47705. * This can help limiting how the Camera is able to move in the scene.
  47706. */
  47707. lowerRadiusLimit: Nullable<number>;
  47708. /**
  47709. * Maximum allowed distance of the camera to the axis of rotation
  47710. * (The camera can not get further).
  47711. * This can help limiting how the Camera is able to move in the scene.
  47712. */
  47713. upperRadiusLimit: Nullable<number>;
  47714. /**
  47715. * Define a rotation offset between the camera and the object it follows
  47716. */
  47717. rotationOffset: number;
  47718. /**
  47719. * Minimum allowed angle to camera position relative to target object.
  47720. * This can help limiting how the Camera is able to move in the scene.
  47721. */
  47722. lowerRotationOffsetLimit: Nullable<number>;
  47723. /**
  47724. * Maximum allowed angle to camera position relative to target object.
  47725. * This can help limiting how the Camera is able to move in the scene.
  47726. */
  47727. upperRotationOffsetLimit: Nullable<number>;
  47728. /**
  47729. * Define a height offset between the camera and the object it follows.
  47730. * It can help following an object from the top (like a car chaing a plane)
  47731. */
  47732. heightOffset: number;
  47733. /**
  47734. * Minimum allowed height of camera position relative to target object.
  47735. * This can help limiting how the Camera is able to move in the scene.
  47736. */
  47737. lowerHeightOffsetLimit: Nullable<number>;
  47738. /**
  47739. * Maximum allowed height of camera position relative to target object.
  47740. * This can help limiting how the Camera is able to move in the scene.
  47741. */
  47742. upperHeightOffsetLimit: Nullable<number>;
  47743. /**
  47744. * Define how fast the camera can accelerate to follow it s target.
  47745. */
  47746. cameraAcceleration: number;
  47747. /**
  47748. * Define the speed limit of the camera following an object.
  47749. */
  47750. maxCameraSpeed: number;
  47751. /**
  47752. * Define the target of the camera.
  47753. */
  47754. lockedTarget: Nullable<AbstractMesh>;
  47755. /**
  47756. * Defines the input associated with the camera.
  47757. */
  47758. inputs: FollowCameraInputsManager;
  47759. /**
  47760. * Instantiates the follow camera.
  47761. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47762. * @param name Define the name of the camera in the scene
  47763. * @param position Define the position of the camera
  47764. * @param scene Define the scene the camera belong to
  47765. * @param lockedTarget Define the target of the camera
  47766. */
  47767. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  47768. private _follow;
  47769. /**
  47770. * Attached controls to the current camera.
  47771. * @param element Defines the element the controls should be listened from
  47772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47773. */
  47774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47775. /**
  47776. * Detach the current controls from the camera.
  47777. * The camera will stop reacting to inputs.
  47778. * @param element Defines the element to stop listening the inputs from
  47779. */
  47780. detachControl(element: HTMLElement): void;
  47781. /** @hidden */
  47782. _checkInputs(): void;
  47783. private _checkLimits;
  47784. /**
  47785. * Gets the camera class name.
  47786. * @returns the class name
  47787. */
  47788. getClassName(): string;
  47789. }
  47790. /**
  47791. * Arc Rotate version of the follow camera.
  47792. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  47793. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47794. */
  47795. export class ArcFollowCamera extends TargetCamera {
  47796. /** The longitudinal angle of the camera */
  47797. alpha: number;
  47798. /** The latitudinal angle of the camera */
  47799. beta: number;
  47800. /** The radius of the camera from its target */
  47801. radius: number;
  47802. private _cartesianCoordinates;
  47803. /** Define the camera target (the mesh it should follow) */
  47804. private _meshTarget;
  47805. /**
  47806. * Instantiates a new ArcFollowCamera
  47807. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47808. * @param name Define the name of the camera
  47809. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  47810. * @param beta Define the rotation angle of the camera around the elevation axis
  47811. * @param radius Define the radius of the camera from its target point
  47812. * @param target Define the target of the camera
  47813. * @param scene Define the scene the camera belongs to
  47814. */
  47815. constructor(name: string,
  47816. /** The longitudinal angle of the camera */
  47817. alpha: number,
  47818. /** The latitudinal angle of the camera */
  47819. beta: number,
  47820. /** The radius of the camera from its target */
  47821. radius: number,
  47822. /** Define the camera target (the mesh it should follow) */
  47823. target: Nullable<AbstractMesh>, scene: Scene);
  47824. private _follow;
  47825. /** @hidden */
  47826. _checkInputs(): void;
  47827. /**
  47828. * Returns the class name of the object.
  47829. * It is mostly used internally for serialization purposes.
  47830. */
  47831. getClassName(): string;
  47832. }
  47833. }
  47834. declare module BABYLON {
  47835. /**
  47836. * Manage the keyboard inputs to control the movement of a follow camera.
  47837. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47838. */
  47839. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  47840. /**
  47841. * Defines the camera the input is attached to.
  47842. */
  47843. camera: FollowCamera;
  47844. /**
  47845. * Defines the list of key codes associated with the up action (increase heightOffset)
  47846. */
  47847. keysHeightOffsetIncr: number[];
  47848. /**
  47849. * Defines the list of key codes associated with the down action (decrease heightOffset)
  47850. */
  47851. keysHeightOffsetDecr: number[];
  47852. /**
  47853. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  47854. */
  47855. keysHeightOffsetModifierAlt: boolean;
  47856. /**
  47857. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  47858. */
  47859. keysHeightOffsetModifierCtrl: boolean;
  47860. /**
  47861. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  47862. */
  47863. keysHeightOffsetModifierShift: boolean;
  47864. /**
  47865. * Defines the list of key codes associated with the left action (increase rotationOffset)
  47866. */
  47867. keysRotationOffsetIncr: number[];
  47868. /**
  47869. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  47870. */
  47871. keysRotationOffsetDecr: number[];
  47872. /**
  47873. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  47874. */
  47875. keysRotationOffsetModifierAlt: boolean;
  47876. /**
  47877. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  47878. */
  47879. keysRotationOffsetModifierCtrl: boolean;
  47880. /**
  47881. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  47882. */
  47883. keysRotationOffsetModifierShift: boolean;
  47884. /**
  47885. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  47886. */
  47887. keysRadiusIncr: number[];
  47888. /**
  47889. * Defines the list of key codes associated with the zoom-out action (increase radius)
  47890. */
  47891. keysRadiusDecr: number[];
  47892. /**
  47893. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  47894. */
  47895. keysRadiusModifierAlt: boolean;
  47896. /**
  47897. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  47898. */
  47899. keysRadiusModifierCtrl: boolean;
  47900. /**
  47901. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  47902. */
  47903. keysRadiusModifierShift: boolean;
  47904. /**
  47905. * Defines the rate of change of heightOffset.
  47906. */
  47907. heightSensibility: number;
  47908. /**
  47909. * Defines the rate of change of rotationOffset.
  47910. */
  47911. rotationSensibility: number;
  47912. /**
  47913. * Defines the rate of change of radius.
  47914. */
  47915. radiusSensibility: number;
  47916. private _keys;
  47917. private _ctrlPressed;
  47918. private _altPressed;
  47919. private _shiftPressed;
  47920. private _onCanvasBlurObserver;
  47921. private _onKeyboardObserver;
  47922. private _engine;
  47923. private _scene;
  47924. /**
  47925. * Attach the input controls to a specific dom element to get the input from.
  47926. * @param element Defines the element the controls should be listened from
  47927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47928. */
  47929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47930. /**
  47931. * Detach the current controls from the specified dom element.
  47932. * @param element Defines the element to stop listening the inputs from
  47933. */
  47934. detachControl(element: Nullable<HTMLElement>): void;
  47935. /**
  47936. * Update the current camera state depending on the inputs that have been used this frame.
  47937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47938. */
  47939. checkInputs(): void;
  47940. /**
  47941. * Gets the class name of the current input.
  47942. * @returns the class name
  47943. */
  47944. getClassName(): string;
  47945. /**
  47946. * Get the friendly name associated with the input class.
  47947. * @returns the input friendly name
  47948. */
  47949. getSimpleName(): string;
  47950. /**
  47951. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47952. * allow modification of the heightOffset value.
  47953. */
  47954. private _modifierHeightOffset;
  47955. /**
  47956. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47957. * allow modification of the rotationOffset value.
  47958. */
  47959. private _modifierRotationOffset;
  47960. /**
  47961. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47962. * allow modification of the radius value.
  47963. */
  47964. private _modifierRadius;
  47965. }
  47966. }
  47967. declare module BABYLON {
  47968. interface FreeCameraInputsManager {
  47969. /**
  47970. * @hidden
  47971. */
  47972. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  47973. /**
  47974. * Add orientation input support to the input manager.
  47975. * @returns the current input manager
  47976. */
  47977. addDeviceOrientation(): FreeCameraInputsManager;
  47978. }
  47979. /**
  47980. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  47981. * Screen rotation is taken into account.
  47982. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47983. */
  47984. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  47985. private _camera;
  47986. private _screenOrientationAngle;
  47987. private _constantTranform;
  47988. private _screenQuaternion;
  47989. private _alpha;
  47990. private _beta;
  47991. private _gamma;
  47992. /**
  47993. * Can be used to detect if a device orientation sensor is available on a device
  47994. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  47995. * @returns a promise that will resolve on orientation change
  47996. */
  47997. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  47998. /**
  47999. * @hidden
  48000. */
  48001. _onDeviceOrientationChangedObservable: Observable<void>;
  48002. /**
  48003. * Instantiates a new input
  48004. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48005. */
  48006. constructor();
  48007. /**
  48008. * Define the camera controlled by the input.
  48009. */
  48010. get camera(): FreeCamera;
  48011. set camera(camera: FreeCamera);
  48012. /**
  48013. * Attach the input controls to a specific dom element to get the input from.
  48014. * @param element Defines the element the controls should be listened from
  48015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48016. */
  48017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48018. private _orientationChanged;
  48019. private _deviceOrientation;
  48020. /**
  48021. * Detach the current controls from the specified dom element.
  48022. * @param element Defines the element to stop listening the inputs from
  48023. */
  48024. detachControl(element: Nullable<HTMLElement>): void;
  48025. /**
  48026. * Update the current camera state depending on the inputs that have been used this frame.
  48027. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48028. */
  48029. checkInputs(): void;
  48030. /**
  48031. * Gets the class name of the current intput.
  48032. * @returns the class name
  48033. */
  48034. getClassName(): string;
  48035. /**
  48036. * Get the friendly name associated with the input class.
  48037. * @returns the input friendly name
  48038. */
  48039. getSimpleName(): string;
  48040. }
  48041. }
  48042. declare module BABYLON {
  48043. /**
  48044. * Manage the gamepad inputs to control a free camera.
  48045. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48046. */
  48047. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48048. /**
  48049. * Define the camera the input is attached to.
  48050. */
  48051. camera: FreeCamera;
  48052. /**
  48053. * Define the Gamepad controlling the input
  48054. */
  48055. gamepad: Nullable<Gamepad>;
  48056. /**
  48057. * Defines the gamepad rotation sensiblity.
  48058. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48059. */
  48060. gamepadAngularSensibility: number;
  48061. /**
  48062. * Defines the gamepad move sensiblity.
  48063. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48064. */
  48065. gamepadMoveSensibility: number;
  48066. private _yAxisScale;
  48067. /**
  48068. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48069. */
  48070. get invertYAxis(): boolean;
  48071. set invertYAxis(value: boolean);
  48072. private _onGamepadConnectedObserver;
  48073. private _onGamepadDisconnectedObserver;
  48074. private _cameraTransform;
  48075. private _deltaTransform;
  48076. private _vector3;
  48077. private _vector2;
  48078. /**
  48079. * Attach the input controls to a specific dom element to get the input from.
  48080. * @param element Defines the element the controls should be listened from
  48081. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48082. */
  48083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48084. /**
  48085. * Detach the current controls from the specified dom element.
  48086. * @param element Defines the element to stop listening the inputs from
  48087. */
  48088. detachControl(element: Nullable<HTMLElement>): void;
  48089. /**
  48090. * Update the current camera state depending on the inputs that have been used this frame.
  48091. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48092. */
  48093. checkInputs(): void;
  48094. /**
  48095. * Gets the class name of the current intput.
  48096. * @returns the class name
  48097. */
  48098. getClassName(): string;
  48099. /**
  48100. * Get the friendly name associated with the input class.
  48101. * @returns the input friendly name
  48102. */
  48103. getSimpleName(): string;
  48104. }
  48105. }
  48106. declare module BABYLON {
  48107. /**
  48108. * Defines the potential axis of a Joystick
  48109. */
  48110. export enum JoystickAxis {
  48111. /** X axis */
  48112. X = 0,
  48113. /** Y axis */
  48114. Y = 1,
  48115. /** Z axis */
  48116. Z = 2
  48117. }
  48118. /**
  48119. * Represents the different customization options available
  48120. * for VirtualJoystick
  48121. */
  48122. interface VirtualJoystickCustomizations {
  48123. /**
  48124. * Size of the joystick's puck
  48125. */
  48126. puckSize: number;
  48127. /**
  48128. * Size of the joystick's container
  48129. */
  48130. containerSize: number;
  48131. /**
  48132. * Color of the joystick && puck
  48133. */
  48134. color: string;
  48135. /**
  48136. * Image URL for the joystick's puck
  48137. */
  48138. puckImage?: string;
  48139. /**
  48140. * Image URL for the joystick's container
  48141. */
  48142. containerImage?: string;
  48143. /**
  48144. * Defines the unmoving position of the joystick container
  48145. */
  48146. position?: {
  48147. x: number;
  48148. y: number;
  48149. };
  48150. /**
  48151. * Defines whether or not the joystick container is always visible
  48152. */
  48153. alwaysVisible: boolean;
  48154. /**
  48155. * Defines whether or not to limit the movement of the puck to the joystick's container
  48156. */
  48157. limitToContainer: boolean;
  48158. }
  48159. /**
  48160. * Class used to define virtual joystick (used in touch mode)
  48161. */
  48162. export class VirtualJoystick {
  48163. /**
  48164. * Gets or sets a boolean indicating that left and right values must be inverted
  48165. */
  48166. reverseLeftRight: boolean;
  48167. /**
  48168. * Gets or sets a boolean indicating that up and down values must be inverted
  48169. */
  48170. reverseUpDown: boolean;
  48171. /**
  48172. * Gets the offset value for the position (ie. the change of the position value)
  48173. */
  48174. deltaPosition: Vector3;
  48175. /**
  48176. * Gets a boolean indicating if the virtual joystick was pressed
  48177. */
  48178. pressed: boolean;
  48179. /**
  48180. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48181. */
  48182. static Canvas: Nullable<HTMLCanvasElement>;
  48183. /**
  48184. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48185. */
  48186. limitToContainer: boolean;
  48187. private static _globalJoystickIndex;
  48188. private static _alwaysVisibleSticks;
  48189. private static vjCanvasContext;
  48190. private static vjCanvasWidth;
  48191. private static vjCanvasHeight;
  48192. private static halfWidth;
  48193. private static _GetDefaultOptions;
  48194. private _action;
  48195. private _axisTargetedByLeftAndRight;
  48196. private _axisTargetedByUpAndDown;
  48197. private _joystickSensibility;
  48198. private _inversedSensibility;
  48199. private _joystickPointerID;
  48200. private _joystickColor;
  48201. private _joystickPointerPos;
  48202. private _joystickPreviousPointerPos;
  48203. private _joystickPointerStartPos;
  48204. private _deltaJoystickVector;
  48205. private _leftJoystick;
  48206. private _touches;
  48207. private _joystickPosition;
  48208. private _alwaysVisible;
  48209. private _puckImage;
  48210. private _containerImage;
  48211. private _joystickPuckSize;
  48212. private _joystickContainerSize;
  48213. private _clearPuckSize;
  48214. private _clearContainerSize;
  48215. private _clearPuckSizeOffset;
  48216. private _clearContainerSizeOffset;
  48217. private _onPointerDownHandlerRef;
  48218. private _onPointerMoveHandlerRef;
  48219. private _onPointerUpHandlerRef;
  48220. private _onResize;
  48221. /**
  48222. * Creates a new virtual joystick
  48223. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48224. * @param customizations Defines the options we want to customize the VirtualJoystick
  48225. */
  48226. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48227. /**
  48228. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48229. * @param newJoystickSensibility defines the new sensibility
  48230. */
  48231. setJoystickSensibility(newJoystickSensibility: number): void;
  48232. private _onPointerDown;
  48233. private _onPointerMove;
  48234. private _onPointerUp;
  48235. /**
  48236. * Change the color of the virtual joystick
  48237. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48238. */
  48239. setJoystickColor(newColor: string): void;
  48240. /**
  48241. * Size of the joystick's container
  48242. */
  48243. set containerSize(newSize: number);
  48244. get containerSize(): number;
  48245. /**
  48246. * Size of the joystick's puck
  48247. */
  48248. set puckSize(newSize: number);
  48249. get puckSize(): number;
  48250. /**
  48251. * Clears the set position of the joystick
  48252. */
  48253. clearPosition(): void;
  48254. /**
  48255. * Defines whether or not the joystick container is always visible
  48256. */
  48257. set alwaysVisible(value: boolean);
  48258. get alwaysVisible(): boolean;
  48259. /**
  48260. * Sets the constant position of the Joystick container
  48261. * @param x X axis coordinate
  48262. * @param y Y axis coordinate
  48263. */
  48264. setPosition(x: number, y: number): void;
  48265. /**
  48266. * Defines a callback to call when the joystick is touched
  48267. * @param action defines the callback
  48268. */
  48269. setActionOnTouch(action: () => any): void;
  48270. /**
  48271. * Defines which axis you'd like to control for left & right
  48272. * @param axis defines the axis to use
  48273. */
  48274. setAxisForLeftRight(axis: JoystickAxis): void;
  48275. /**
  48276. * Defines which axis you'd like to control for up & down
  48277. * @param axis defines the axis to use
  48278. */
  48279. setAxisForUpDown(axis: JoystickAxis): void;
  48280. /**
  48281. * Clears the canvas from the previous puck / container draw
  48282. */
  48283. private _clearPreviousDraw;
  48284. /**
  48285. * Loads `urlPath` to be used for the container's image
  48286. * @param urlPath defines the urlPath of an image to use
  48287. */
  48288. setContainerImage(urlPath: string): void;
  48289. /**
  48290. * Loads `urlPath` to be used for the puck's image
  48291. * @param urlPath defines the urlPath of an image to use
  48292. */
  48293. setPuckImage(urlPath: string): void;
  48294. /**
  48295. * Draws the Virtual Joystick's container
  48296. */
  48297. private _drawContainer;
  48298. /**
  48299. * Draws the Virtual Joystick's puck
  48300. */
  48301. private _drawPuck;
  48302. private _drawVirtualJoystick;
  48303. /**
  48304. * Release internal HTML canvas
  48305. */
  48306. releaseCanvas(): void;
  48307. }
  48308. }
  48309. declare module BABYLON {
  48310. interface FreeCameraInputsManager {
  48311. /**
  48312. * Add virtual joystick input support to the input manager.
  48313. * @returns the current input manager
  48314. */
  48315. addVirtualJoystick(): FreeCameraInputsManager;
  48316. }
  48317. /**
  48318. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48319. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48320. */
  48321. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48322. /**
  48323. * Defines the camera the input is attached to.
  48324. */
  48325. camera: FreeCamera;
  48326. private _leftjoystick;
  48327. private _rightjoystick;
  48328. /**
  48329. * Gets the left stick of the virtual joystick.
  48330. * @returns The virtual Joystick
  48331. */
  48332. getLeftJoystick(): VirtualJoystick;
  48333. /**
  48334. * Gets the right stick of the virtual joystick.
  48335. * @returns The virtual Joystick
  48336. */
  48337. getRightJoystick(): VirtualJoystick;
  48338. /**
  48339. * Update the current camera state depending on the inputs that have been used this frame.
  48340. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48341. */
  48342. checkInputs(): void;
  48343. /**
  48344. * Attach the input controls to a specific dom element to get the input from.
  48345. * @param element Defines the element the controls should be listened from
  48346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48347. */
  48348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48349. /**
  48350. * Detach the current controls from the specified dom element.
  48351. * @param element Defines the element to stop listening the inputs from
  48352. */
  48353. detachControl(element: Nullable<HTMLElement>): void;
  48354. /**
  48355. * Gets the class name of the current intput.
  48356. * @returns the class name
  48357. */
  48358. getClassName(): string;
  48359. /**
  48360. * Get the friendly name associated with the input class.
  48361. * @returns the input friendly name
  48362. */
  48363. getSimpleName(): string;
  48364. }
  48365. }
  48366. declare module BABYLON {
  48367. /**
  48368. * This represents a FPS type of camera controlled by touch.
  48369. * This is like a universal camera minus the Gamepad controls.
  48370. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48371. */
  48372. export class TouchCamera extends FreeCamera {
  48373. /**
  48374. * Defines the touch sensibility for rotation.
  48375. * The higher the faster.
  48376. */
  48377. get touchAngularSensibility(): number;
  48378. set touchAngularSensibility(value: number);
  48379. /**
  48380. * Defines the touch sensibility for move.
  48381. * The higher the faster.
  48382. */
  48383. get touchMoveSensibility(): number;
  48384. set touchMoveSensibility(value: number);
  48385. /**
  48386. * Instantiates a new touch camera.
  48387. * This represents a FPS type of camera controlled by touch.
  48388. * This is like a universal camera minus the Gamepad controls.
  48389. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48390. * @param name Define the name of the camera in the scene
  48391. * @param position Define the start position of the camera in the scene
  48392. * @param scene Define the scene the camera belongs to
  48393. */
  48394. constructor(name: string, position: Vector3, scene: Scene);
  48395. /**
  48396. * Gets the current object class name.
  48397. * @return the class name
  48398. */
  48399. getClassName(): string;
  48400. /** @hidden */
  48401. _setupInputs(): void;
  48402. }
  48403. }
  48404. declare module BABYLON {
  48405. /**
  48406. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48407. * being tilted forward or back and left or right.
  48408. */
  48409. export class DeviceOrientationCamera extends FreeCamera {
  48410. private _initialQuaternion;
  48411. private _quaternionCache;
  48412. private _tmpDragQuaternion;
  48413. private _disablePointerInputWhenUsingDeviceOrientation;
  48414. /**
  48415. * Creates a new device orientation camera
  48416. * @param name The name of the camera
  48417. * @param position The start position camera
  48418. * @param scene The scene the camera belongs to
  48419. */
  48420. constructor(name: string, position: Vector3, scene: Scene);
  48421. /**
  48422. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48423. */
  48424. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48425. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48426. private _dragFactor;
  48427. /**
  48428. * Enabled turning on the y axis when the orientation sensor is active
  48429. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48430. */
  48431. enableHorizontalDragging(dragFactor?: number): void;
  48432. /**
  48433. * Gets the current instance class name ("DeviceOrientationCamera").
  48434. * This helps avoiding instanceof at run time.
  48435. * @returns the class name
  48436. */
  48437. getClassName(): string;
  48438. /**
  48439. * @hidden
  48440. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48441. */
  48442. _checkInputs(): void;
  48443. /**
  48444. * Reset the camera to its default orientation on the specified axis only.
  48445. * @param axis The axis to reset
  48446. */
  48447. resetToCurrentRotation(axis?: Axis): void;
  48448. }
  48449. }
  48450. declare module BABYLON {
  48451. /**
  48452. * Defines supported buttons for XBox360 compatible gamepads
  48453. */
  48454. export enum Xbox360Button {
  48455. /** A */
  48456. A = 0,
  48457. /** B */
  48458. B = 1,
  48459. /** X */
  48460. X = 2,
  48461. /** Y */
  48462. Y = 3,
  48463. /** Left button */
  48464. LB = 4,
  48465. /** Right button */
  48466. RB = 5,
  48467. /** Back */
  48468. Back = 8,
  48469. /** Start */
  48470. Start = 9,
  48471. /** Left stick */
  48472. LeftStick = 10,
  48473. /** Right stick */
  48474. RightStick = 11
  48475. }
  48476. /** Defines values for XBox360 DPad */
  48477. export enum Xbox360Dpad {
  48478. /** Up */
  48479. Up = 12,
  48480. /** Down */
  48481. Down = 13,
  48482. /** Left */
  48483. Left = 14,
  48484. /** Right */
  48485. Right = 15
  48486. }
  48487. /**
  48488. * Defines a XBox360 gamepad
  48489. */
  48490. export class Xbox360Pad extends Gamepad {
  48491. private _leftTrigger;
  48492. private _rightTrigger;
  48493. private _onlefttriggerchanged;
  48494. private _onrighttriggerchanged;
  48495. private _onbuttondown;
  48496. private _onbuttonup;
  48497. private _ondpaddown;
  48498. private _ondpadup;
  48499. /** Observable raised when a button is pressed */
  48500. onButtonDownObservable: Observable<Xbox360Button>;
  48501. /** Observable raised when a button is released */
  48502. onButtonUpObservable: Observable<Xbox360Button>;
  48503. /** Observable raised when a pad is pressed */
  48504. onPadDownObservable: Observable<Xbox360Dpad>;
  48505. /** Observable raised when a pad is released */
  48506. onPadUpObservable: Observable<Xbox360Dpad>;
  48507. private _buttonA;
  48508. private _buttonB;
  48509. private _buttonX;
  48510. private _buttonY;
  48511. private _buttonBack;
  48512. private _buttonStart;
  48513. private _buttonLB;
  48514. private _buttonRB;
  48515. private _buttonLeftStick;
  48516. private _buttonRightStick;
  48517. private _dPadUp;
  48518. private _dPadDown;
  48519. private _dPadLeft;
  48520. private _dPadRight;
  48521. private _isXboxOnePad;
  48522. /**
  48523. * Creates a new XBox360 gamepad object
  48524. * @param id defines the id of this gamepad
  48525. * @param index defines its index
  48526. * @param gamepad defines the internal HTML gamepad object
  48527. * @param xboxOne defines if it is a XBox One gamepad
  48528. */
  48529. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48530. /**
  48531. * Defines the callback to call when left trigger is pressed
  48532. * @param callback defines the callback to use
  48533. */
  48534. onlefttriggerchanged(callback: (value: number) => void): void;
  48535. /**
  48536. * Defines the callback to call when right trigger is pressed
  48537. * @param callback defines the callback to use
  48538. */
  48539. onrighttriggerchanged(callback: (value: number) => void): void;
  48540. /**
  48541. * Gets the left trigger value
  48542. */
  48543. get leftTrigger(): number;
  48544. /**
  48545. * Sets the left trigger value
  48546. */
  48547. set leftTrigger(newValue: number);
  48548. /**
  48549. * Gets the right trigger value
  48550. */
  48551. get rightTrigger(): number;
  48552. /**
  48553. * Sets the right trigger value
  48554. */
  48555. set rightTrigger(newValue: number);
  48556. /**
  48557. * Defines the callback to call when a button is pressed
  48558. * @param callback defines the callback to use
  48559. */
  48560. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48561. /**
  48562. * Defines the callback to call when a button is released
  48563. * @param callback defines the callback to use
  48564. */
  48565. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48566. /**
  48567. * Defines the callback to call when a pad is pressed
  48568. * @param callback defines the callback to use
  48569. */
  48570. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48571. /**
  48572. * Defines the callback to call when a pad is released
  48573. * @param callback defines the callback to use
  48574. */
  48575. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48576. private _setButtonValue;
  48577. private _setDPadValue;
  48578. /**
  48579. * Gets the value of the `A` button
  48580. */
  48581. get buttonA(): number;
  48582. /**
  48583. * Sets the value of the `A` button
  48584. */
  48585. set buttonA(value: number);
  48586. /**
  48587. * Gets the value of the `B` button
  48588. */
  48589. get buttonB(): number;
  48590. /**
  48591. * Sets the value of the `B` button
  48592. */
  48593. set buttonB(value: number);
  48594. /**
  48595. * Gets the value of the `X` button
  48596. */
  48597. get buttonX(): number;
  48598. /**
  48599. * Sets the value of the `X` button
  48600. */
  48601. set buttonX(value: number);
  48602. /**
  48603. * Gets the value of the `Y` button
  48604. */
  48605. get buttonY(): number;
  48606. /**
  48607. * Sets the value of the `Y` button
  48608. */
  48609. set buttonY(value: number);
  48610. /**
  48611. * Gets the value of the `Start` button
  48612. */
  48613. get buttonStart(): number;
  48614. /**
  48615. * Sets the value of the `Start` button
  48616. */
  48617. set buttonStart(value: number);
  48618. /**
  48619. * Gets the value of the `Back` button
  48620. */
  48621. get buttonBack(): number;
  48622. /**
  48623. * Sets the value of the `Back` button
  48624. */
  48625. set buttonBack(value: number);
  48626. /**
  48627. * Gets the value of the `Left` button
  48628. */
  48629. get buttonLB(): number;
  48630. /**
  48631. * Sets the value of the `Left` button
  48632. */
  48633. set buttonLB(value: number);
  48634. /**
  48635. * Gets the value of the `Right` button
  48636. */
  48637. get buttonRB(): number;
  48638. /**
  48639. * Sets the value of the `Right` button
  48640. */
  48641. set buttonRB(value: number);
  48642. /**
  48643. * Gets the value of the Left joystick
  48644. */
  48645. get buttonLeftStick(): number;
  48646. /**
  48647. * Sets the value of the Left joystick
  48648. */
  48649. set buttonLeftStick(value: number);
  48650. /**
  48651. * Gets the value of the Right joystick
  48652. */
  48653. get buttonRightStick(): number;
  48654. /**
  48655. * Sets the value of the Right joystick
  48656. */
  48657. set buttonRightStick(value: number);
  48658. /**
  48659. * Gets the value of D-pad up
  48660. */
  48661. get dPadUp(): number;
  48662. /**
  48663. * Sets the value of D-pad up
  48664. */
  48665. set dPadUp(value: number);
  48666. /**
  48667. * Gets the value of D-pad down
  48668. */
  48669. get dPadDown(): number;
  48670. /**
  48671. * Sets the value of D-pad down
  48672. */
  48673. set dPadDown(value: number);
  48674. /**
  48675. * Gets the value of D-pad left
  48676. */
  48677. get dPadLeft(): number;
  48678. /**
  48679. * Sets the value of D-pad left
  48680. */
  48681. set dPadLeft(value: number);
  48682. /**
  48683. * Gets the value of D-pad right
  48684. */
  48685. get dPadRight(): number;
  48686. /**
  48687. * Sets the value of D-pad right
  48688. */
  48689. set dPadRight(value: number);
  48690. /**
  48691. * Force the gamepad to synchronize with device values
  48692. */
  48693. update(): void;
  48694. /**
  48695. * Disposes the gamepad
  48696. */
  48697. dispose(): void;
  48698. }
  48699. }
  48700. declare module BABYLON {
  48701. /**
  48702. * Defines supported buttons for DualShock compatible gamepads
  48703. */
  48704. export enum DualShockButton {
  48705. /** Cross */
  48706. Cross = 0,
  48707. /** Circle */
  48708. Circle = 1,
  48709. /** Square */
  48710. Square = 2,
  48711. /** Triangle */
  48712. Triangle = 3,
  48713. /** L1 */
  48714. L1 = 4,
  48715. /** R1 */
  48716. R1 = 5,
  48717. /** Share */
  48718. Share = 8,
  48719. /** Options */
  48720. Options = 9,
  48721. /** Left stick */
  48722. LeftStick = 10,
  48723. /** Right stick */
  48724. RightStick = 11
  48725. }
  48726. /** Defines values for DualShock DPad */
  48727. export enum DualShockDpad {
  48728. /** Up */
  48729. Up = 12,
  48730. /** Down */
  48731. Down = 13,
  48732. /** Left */
  48733. Left = 14,
  48734. /** Right */
  48735. Right = 15
  48736. }
  48737. /**
  48738. * Defines a DualShock gamepad
  48739. */
  48740. export class DualShockPad extends Gamepad {
  48741. private _leftTrigger;
  48742. private _rightTrigger;
  48743. private _onlefttriggerchanged;
  48744. private _onrighttriggerchanged;
  48745. private _onbuttondown;
  48746. private _onbuttonup;
  48747. private _ondpaddown;
  48748. private _ondpadup;
  48749. /** Observable raised when a button is pressed */
  48750. onButtonDownObservable: Observable<DualShockButton>;
  48751. /** Observable raised when a button is released */
  48752. onButtonUpObservable: Observable<DualShockButton>;
  48753. /** Observable raised when a pad is pressed */
  48754. onPadDownObservable: Observable<DualShockDpad>;
  48755. /** Observable raised when a pad is released */
  48756. onPadUpObservable: Observable<DualShockDpad>;
  48757. private _buttonCross;
  48758. private _buttonCircle;
  48759. private _buttonSquare;
  48760. private _buttonTriangle;
  48761. private _buttonShare;
  48762. private _buttonOptions;
  48763. private _buttonL1;
  48764. private _buttonR1;
  48765. private _buttonLeftStick;
  48766. private _buttonRightStick;
  48767. private _dPadUp;
  48768. private _dPadDown;
  48769. private _dPadLeft;
  48770. private _dPadRight;
  48771. /**
  48772. * Creates a new DualShock gamepad object
  48773. * @param id defines the id of this gamepad
  48774. * @param index defines its index
  48775. * @param gamepad defines the internal HTML gamepad object
  48776. */
  48777. constructor(id: string, index: number, gamepad: any);
  48778. /**
  48779. * Defines the callback to call when left trigger is pressed
  48780. * @param callback defines the callback to use
  48781. */
  48782. onlefttriggerchanged(callback: (value: number) => void): void;
  48783. /**
  48784. * Defines the callback to call when right trigger is pressed
  48785. * @param callback defines the callback to use
  48786. */
  48787. onrighttriggerchanged(callback: (value: number) => void): void;
  48788. /**
  48789. * Gets the left trigger value
  48790. */
  48791. get leftTrigger(): number;
  48792. /**
  48793. * Sets the left trigger value
  48794. */
  48795. set leftTrigger(newValue: number);
  48796. /**
  48797. * Gets the right trigger value
  48798. */
  48799. get rightTrigger(): number;
  48800. /**
  48801. * Sets the right trigger value
  48802. */
  48803. set rightTrigger(newValue: number);
  48804. /**
  48805. * Defines the callback to call when a button is pressed
  48806. * @param callback defines the callback to use
  48807. */
  48808. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  48809. /**
  48810. * Defines the callback to call when a button is released
  48811. * @param callback defines the callback to use
  48812. */
  48813. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  48814. /**
  48815. * Defines the callback to call when a pad is pressed
  48816. * @param callback defines the callback to use
  48817. */
  48818. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  48819. /**
  48820. * Defines the callback to call when a pad is released
  48821. * @param callback defines the callback to use
  48822. */
  48823. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  48824. private _setButtonValue;
  48825. private _setDPadValue;
  48826. /**
  48827. * Gets the value of the `Cross` button
  48828. */
  48829. get buttonCross(): number;
  48830. /**
  48831. * Sets the value of the `Cross` button
  48832. */
  48833. set buttonCross(value: number);
  48834. /**
  48835. * Gets the value of the `Circle` button
  48836. */
  48837. get buttonCircle(): number;
  48838. /**
  48839. * Sets the value of the `Circle` button
  48840. */
  48841. set buttonCircle(value: number);
  48842. /**
  48843. * Gets the value of the `Square` button
  48844. */
  48845. get buttonSquare(): number;
  48846. /**
  48847. * Sets the value of the `Square` button
  48848. */
  48849. set buttonSquare(value: number);
  48850. /**
  48851. * Gets the value of the `Triangle` button
  48852. */
  48853. get buttonTriangle(): number;
  48854. /**
  48855. * Sets the value of the `Triangle` button
  48856. */
  48857. set buttonTriangle(value: number);
  48858. /**
  48859. * Gets the value of the `Options` button
  48860. */
  48861. get buttonOptions(): number;
  48862. /**
  48863. * Sets the value of the `Options` button
  48864. */
  48865. set buttonOptions(value: number);
  48866. /**
  48867. * Gets the value of the `Share` button
  48868. */
  48869. get buttonShare(): number;
  48870. /**
  48871. * Sets the value of the `Share` button
  48872. */
  48873. set buttonShare(value: number);
  48874. /**
  48875. * Gets the value of the `L1` button
  48876. */
  48877. get buttonL1(): number;
  48878. /**
  48879. * Sets the value of the `L1` button
  48880. */
  48881. set buttonL1(value: number);
  48882. /**
  48883. * Gets the value of the `R1` button
  48884. */
  48885. get buttonR1(): number;
  48886. /**
  48887. * Sets the value of the `R1` button
  48888. */
  48889. set buttonR1(value: number);
  48890. /**
  48891. * Gets the value of the Left joystick
  48892. */
  48893. get buttonLeftStick(): number;
  48894. /**
  48895. * Sets the value of the Left joystick
  48896. */
  48897. set buttonLeftStick(value: number);
  48898. /**
  48899. * Gets the value of the Right joystick
  48900. */
  48901. get buttonRightStick(): number;
  48902. /**
  48903. * Sets the value of the Right joystick
  48904. */
  48905. set buttonRightStick(value: number);
  48906. /**
  48907. * Gets the value of D-pad up
  48908. */
  48909. get dPadUp(): number;
  48910. /**
  48911. * Sets the value of D-pad up
  48912. */
  48913. set dPadUp(value: number);
  48914. /**
  48915. * Gets the value of D-pad down
  48916. */
  48917. get dPadDown(): number;
  48918. /**
  48919. * Sets the value of D-pad down
  48920. */
  48921. set dPadDown(value: number);
  48922. /**
  48923. * Gets the value of D-pad left
  48924. */
  48925. get dPadLeft(): number;
  48926. /**
  48927. * Sets the value of D-pad left
  48928. */
  48929. set dPadLeft(value: number);
  48930. /**
  48931. * Gets the value of D-pad right
  48932. */
  48933. get dPadRight(): number;
  48934. /**
  48935. * Sets the value of D-pad right
  48936. */
  48937. set dPadRight(value: number);
  48938. /**
  48939. * Force the gamepad to synchronize with device values
  48940. */
  48941. update(): void;
  48942. /**
  48943. * Disposes the gamepad
  48944. */
  48945. dispose(): void;
  48946. }
  48947. }
  48948. declare module BABYLON {
  48949. /**
  48950. * Manager for handling gamepads
  48951. */
  48952. export class GamepadManager {
  48953. private _scene?;
  48954. private _babylonGamepads;
  48955. private _oneGamepadConnected;
  48956. /** @hidden */
  48957. _isMonitoring: boolean;
  48958. private _gamepadEventSupported;
  48959. private _gamepadSupport?;
  48960. /**
  48961. * observable to be triggered when the gamepad controller has been connected
  48962. */
  48963. onGamepadConnectedObservable: Observable<Gamepad>;
  48964. /**
  48965. * observable to be triggered when the gamepad controller has been disconnected
  48966. */
  48967. onGamepadDisconnectedObservable: Observable<Gamepad>;
  48968. private _onGamepadConnectedEvent;
  48969. private _onGamepadDisconnectedEvent;
  48970. /**
  48971. * Initializes the gamepad manager
  48972. * @param _scene BabylonJS scene
  48973. */
  48974. constructor(_scene?: Scene | undefined);
  48975. /**
  48976. * The gamepads in the game pad manager
  48977. */
  48978. get gamepads(): Gamepad[];
  48979. /**
  48980. * Get the gamepad controllers based on type
  48981. * @param type The type of gamepad controller
  48982. * @returns Nullable gamepad
  48983. */
  48984. getGamepadByType(type?: number): Nullable<Gamepad>;
  48985. /**
  48986. * Disposes the gamepad manager
  48987. */
  48988. dispose(): void;
  48989. private _addNewGamepad;
  48990. private _startMonitoringGamepads;
  48991. private _stopMonitoringGamepads;
  48992. /** @hidden */
  48993. _checkGamepadsStatus(): void;
  48994. private _updateGamepadObjects;
  48995. }
  48996. }
  48997. declare module BABYLON {
  48998. interface Scene {
  48999. /** @hidden */
  49000. _gamepadManager: Nullable<GamepadManager>;
  49001. /**
  49002. * Gets the gamepad manager associated with the scene
  49003. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49004. */
  49005. gamepadManager: GamepadManager;
  49006. }
  49007. /**
  49008. * Interface representing a free camera inputs manager
  49009. */
  49010. interface FreeCameraInputsManager {
  49011. /**
  49012. * Adds gamepad input support to the FreeCameraInputsManager.
  49013. * @returns the FreeCameraInputsManager
  49014. */
  49015. addGamepad(): FreeCameraInputsManager;
  49016. }
  49017. /**
  49018. * Interface representing an arc rotate camera inputs manager
  49019. */
  49020. interface ArcRotateCameraInputsManager {
  49021. /**
  49022. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49023. * @returns the camera inputs manager
  49024. */
  49025. addGamepad(): ArcRotateCameraInputsManager;
  49026. }
  49027. /**
  49028. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49029. */
  49030. export class GamepadSystemSceneComponent implements ISceneComponent {
  49031. /**
  49032. * The component name helpfull to identify the component in the list of scene components.
  49033. */
  49034. readonly name: string;
  49035. /**
  49036. * The scene the component belongs to.
  49037. */
  49038. scene: Scene;
  49039. /**
  49040. * Creates a new instance of the component for the given scene
  49041. * @param scene Defines the scene to register the component in
  49042. */
  49043. constructor(scene: Scene);
  49044. /**
  49045. * Registers the component in a given scene
  49046. */
  49047. register(): void;
  49048. /**
  49049. * Rebuilds the elements related to this component in case of
  49050. * context lost for instance.
  49051. */
  49052. rebuild(): void;
  49053. /**
  49054. * Disposes the component and the associated ressources
  49055. */
  49056. dispose(): void;
  49057. private _beforeCameraUpdate;
  49058. }
  49059. }
  49060. declare module BABYLON {
  49061. /**
  49062. * 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,
  49063. * which still works and will still be found in many Playgrounds.
  49064. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49065. */
  49066. export class UniversalCamera extends TouchCamera {
  49067. /**
  49068. * Defines the gamepad rotation sensiblity.
  49069. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49070. */
  49071. get gamepadAngularSensibility(): number;
  49072. set gamepadAngularSensibility(value: number);
  49073. /**
  49074. * Defines the gamepad move sensiblity.
  49075. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49076. */
  49077. get gamepadMoveSensibility(): number;
  49078. set gamepadMoveSensibility(value: number);
  49079. /**
  49080. * 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,
  49081. * which still works and will still be found in many Playgrounds.
  49082. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49083. * @param name Define the name of the camera in the scene
  49084. * @param position Define the start position of the camera in the scene
  49085. * @param scene Define the scene the camera belongs to
  49086. */
  49087. constructor(name: string, position: Vector3, scene: Scene);
  49088. /**
  49089. * Gets the current object class name.
  49090. * @return the class name
  49091. */
  49092. getClassName(): string;
  49093. }
  49094. }
  49095. declare module BABYLON {
  49096. /**
  49097. * This represents a FPS type of camera. This is only here for back compat purpose.
  49098. * Please use the UniversalCamera instead as both are identical.
  49099. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49100. */
  49101. export class GamepadCamera extends UniversalCamera {
  49102. /**
  49103. * Instantiates a new Gamepad Camera
  49104. * This represents a FPS type of camera. This is only here for back compat purpose.
  49105. * Please use the UniversalCamera instead as both are identical.
  49106. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49107. * @param name Define the name of the camera in the scene
  49108. * @param position Define the start position of the camera in the scene
  49109. * @param scene Define the scene the camera belongs to
  49110. */
  49111. constructor(name: string, position: Vector3, scene: Scene);
  49112. /**
  49113. * Gets the current object class name.
  49114. * @return the class name
  49115. */
  49116. getClassName(): string;
  49117. }
  49118. }
  49119. declare module BABYLON {
  49120. /** @hidden */
  49121. export var passPixelShader: {
  49122. name: string;
  49123. shader: string;
  49124. };
  49125. }
  49126. declare module BABYLON {
  49127. /** @hidden */
  49128. export var passCubePixelShader: {
  49129. name: string;
  49130. shader: string;
  49131. };
  49132. }
  49133. declare module BABYLON {
  49134. /**
  49135. * PassPostProcess which produces an output the same as it's input
  49136. */
  49137. export class PassPostProcess extends PostProcess {
  49138. /**
  49139. * Gets a string identifying the name of the class
  49140. * @returns "PassPostProcess" string
  49141. */
  49142. getClassName(): string;
  49143. /**
  49144. * Creates the PassPostProcess
  49145. * @param name The name of the effect.
  49146. * @param options The required width/height ratio to downsize to before computing the render pass.
  49147. * @param camera The camera to apply the render pass to.
  49148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49149. * @param engine The engine which the post process will be applied. (default: current engine)
  49150. * @param reusable If the post process can be reused on the same frame. (default: false)
  49151. * @param textureType The type of texture to be used when performing the post processing.
  49152. * @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)
  49153. */
  49154. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49155. /** @hidden */
  49156. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49157. }
  49158. /**
  49159. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49160. */
  49161. export class PassCubePostProcess extends PostProcess {
  49162. private _face;
  49163. /**
  49164. * Gets or sets the cube face to display.
  49165. * * 0 is +X
  49166. * * 1 is -X
  49167. * * 2 is +Y
  49168. * * 3 is -Y
  49169. * * 4 is +Z
  49170. * * 5 is -Z
  49171. */
  49172. get face(): number;
  49173. set face(value: number);
  49174. /**
  49175. * Gets a string identifying the name of the class
  49176. * @returns "PassCubePostProcess" string
  49177. */
  49178. getClassName(): string;
  49179. /**
  49180. * Creates the PassCubePostProcess
  49181. * @param name The name of the effect.
  49182. * @param options The required width/height ratio to downsize to before computing the render pass.
  49183. * @param camera The camera to apply the render pass to.
  49184. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49185. * @param engine The engine which the post process will be applied. (default: current engine)
  49186. * @param reusable If the post process can be reused on the same frame. (default: false)
  49187. * @param textureType The type of texture to be used when performing the post processing.
  49188. * @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)
  49189. */
  49190. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49191. /** @hidden */
  49192. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49193. }
  49194. }
  49195. declare module BABYLON {
  49196. /** @hidden */
  49197. export var anaglyphPixelShader: {
  49198. name: string;
  49199. shader: string;
  49200. };
  49201. }
  49202. declare module BABYLON {
  49203. /**
  49204. * Postprocess used to generate anaglyphic rendering
  49205. */
  49206. export class AnaglyphPostProcess extends PostProcess {
  49207. private _passedProcess;
  49208. /**
  49209. * Gets a string identifying the name of the class
  49210. * @returns "AnaglyphPostProcess" string
  49211. */
  49212. getClassName(): string;
  49213. /**
  49214. * Creates a new AnaglyphPostProcess
  49215. * @param name defines postprocess name
  49216. * @param options defines creation options or target ratio scale
  49217. * @param rigCameras defines cameras using this postprocess
  49218. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49219. * @param engine defines hosting engine
  49220. * @param reusable defines if the postprocess will be reused multiple times per frame
  49221. */
  49222. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49223. }
  49224. }
  49225. declare module BABYLON {
  49226. /**
  49227. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49228. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49229. */
  49230. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49231. /**
  49232. * Creates a new AnaglyphArcRotateCamera
  49233. * @param name defines camera name
  49234. * @param alpha defines alpha angle (in radians)
  49235. * @param beta defines beta angle (in radians)
  49236. * @param radius defines radius
  49237. * @param target defines camera target
  49238. * @param interaxialDistance defines distance between each color axis
  49239. * @param scene defines the hosting scene
  49240. */
  49241. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49242. /**
  49243. * Gets camera class name
  49244. * @returns AnaglyphArcRotateCamera
  49245. */
  49246. getClassName(): string;
  49247. }
  49248. }
  49249. declare module BABYLON {
  49250. /**
  49251. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49252. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49253. */
  49254. export class AnaglyphFreeCamera extends FreeCamera {
  49255. /**
  49256. * Creates a new AnaglyphFreeCamera
  49257. * @param name defines camera name
  49258. * @param position defines initial position
  49259. * @param interaxialDistance defines distance between each color axis
  49260. * @param scene defines the hosting scene
  49261. */
  49262. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49263. /**
  49264. * Gets camera class name
  49265. * @returns AnaglyphFreeCamera
  49266. */
  49267. getClassName(): string;
  49268. }
  49269. }
  49270. declare module BABYLON {
  49271. /**
  49272. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49273. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49274. */
  49275. export class AnaglyphGamepadCamera extends GamepadCamera {
  49276. /**
  49277. * Creates a new AnaglyphGamepadCamera
  49278. * @param name defines camera name
  49279. * @param position defines initial position
  49280. * @param interaxialDistance defines distance between each color axis
  49281. * @param scene defines the hosting scene
  49282. */
  49283. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49284. /**
  49285. * Gets camera class name
  49286. * @returns AnaglyphGamepadCamera
  49287. */
  49288. getClassName(): string;
  49289. }
  49290. }
  49291. declare module BABYLON {
  49292. /**
  49293. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49294. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49295. */
  49296. export class AnaglyphUniversalCamera extends UniversalCamera {
  49297. /**
  49298. * Creates a new AnaglyphUniversalCamera
  49299. * @param name defines camera name
  49300. * @param position defines initial position
  49301. * @param interaxialDistance defines distance between each color axis
  49302. * @param scene defines the hosting scene
  49303. */
  49304. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49305. /**
  49306. * Gets camera class name
  49307. * @returns AnaglyphUniversalCamera
  49308. */
  49309. getClassName(): string;
  49310. }
  49311. }
  49312. declare module BABYLON {
  49313. /**
  49314. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49315. * @see https://doc.babylonjs.com/features/cameras
  49316. */
  49317. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49318. /**
  49319. * Creates a new StereoscopicArcRotateCamera
  49320. * @param name defines camera name
  49321. * @param alpha defines alpha angle (in radians)
  49322. * @param beta defines beta angle (in radians)
  49323. * @param radius defines radius
  49324. * @param target defines camera target
  49325. * @param interaxialDistance defines distance between each color axis
  49326. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49327. * @param scene defines the hosting scene
  49328. */
  49329. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49330. /**
  49331. * Gets camera class name
  49332. * @returns StereoscopicArcRotateCamera
  49333. */
  49334. getClassName(): string;
  49335. }
  49336. }
  49337. declare module BABYLON {
  49338. /**
  49339. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49340. * @see https://doc.babylonjs.com/features/cameras
  49341. */
  49342. export class StereoscopicFreeCamera extends FreeCamera {
  49343. /**
  49344. * Creates a new StereoscopicFreeCamera
  49345. * @param name defines camera name
  49346. * @param position defines initial position
  49347. * @param interaxialDistance defines distance between each color axis
  49348. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49349. * @param scene defines the hosting scene
  49350. */
  49351. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49352. /**
  49353. * Gets camera class name
  49354. * @returns StereoscopicFreeCamera
  49355. */
  49356. getClassName(): string;
  49357. }
  49358. }
  49359. declare module BABYLON {
  49360. /**
  49361. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49362. * @see https://doc.babylonjs.com/features/cameras
  49363. */
  49364. export class StereoscopicGamepadCamera extends GamepadCamera {
  49365. /**
  49366. * Creates a new StereoscopicGamepadCamera
  49367. * @param name defines camera name
  49368. * @param position defines initial position
  49369. * @param interaxialDistance defines distance between each color axis
  49370. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49371. * @param scene defines the hosting scene
  49372. */
  49373. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49374. /**
  49375. * Gets camera class name
  49376. * @returns StereoscopicGamepadCamera
  49377. */
  49378. getClassName(): string;
  49379. }
  49380. }
  49381. declare module BABYLON {
  49382. /**
  49383. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49384. * @see https://doc.babylonjs.com/features/cameras
  49385. */
  49386. export class StereoscopicUniversalCamera extends UniversalCamera {
  49387. /**
  49388. * Creates a new StereoscopicUniversalCamera
  49389. * @param name defines camera name
  49390. * @param position defines initial position
  49391. * @param interaxialDistance defines distance between each color axis
  49392. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49393. * @param scene defines the hosting scene
  49394. */
  49395. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49396. /**
  49397. * Gets camera class name
  49398. * @returns StereoscopicUniversalCamera
  49399. */
  49400. getClassName(): string;
  49401. }
  49402. }
  49403. declare module BABYLON {
  49404. /**
  49405. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49406. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49407. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49408. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49409. */
  49410. export class VirtualJoysticksCamera extends FreeCamera {
  49411. /**
  49412. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49413. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49414. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49415. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49416. * @param name Define the name of the camera in the scene
  49417. * @param position Define the start position of the camera in the scene
  49418. * @param scene Define the scene the camera belongs to
  49419. */
  49420. constructor(name: string, position: Vector3, scene: Scene);
  49421. /**
  49422. * Gets the current object class name.
  49423. * @return the class name
  49424. */
  49425. getClassName(): string;
  49426. }
  49427. }
  49428. declare module BABYLON {
  49429. /**
  49430. * This represents all the required metrics to create a VR camera.
  49431. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49432. */
  49433. export class VRCameraMetrics {
  49434. /**
  49435. * Define the horizontal resolution off the screen.
  49436. */
  49437. hResolution: number;
  49438. /**
  49439. * Define the vertical resolution off the screen.
  49440. */
  49441. vResolution: number;
  49442. /**
  49443. * Define the horizontal screen size.
  49444. */
  49445. hScreenSize: number;
  49446. /**
  49447. * Define the vertical screen size.
  49448. */
  49449. vScreenSize: number;
  49450. /**
  49451. * Define the vertical screen center position.
  49452. */
  49453. vScreenCenter: number;
  49454. /**
  49455. * Define the distance of the eyes to the screen.
  49456. */
  49457. eyeToScreenDistance: number;
  49458. /**
  49459. * Define the distance between both lenses
  49460. */
  49461. lensSeparationDistance: number;
  49462. /**
  49463. * Define the distance between both viewer's eyes.
  49464. */
  49465. interpupillaryDistance: number;
  49466. /**
  49467. * Define the distortion factor of the VR postprocess.
  49468. * Please, touch with care.
  49469. */
  49470. distortionK: number[];
  49471. /**
  49472. * Define the chromatic aberration correction factors for the VR post process.
  49473. */
  49474. chromaAbCorrection: number[];
  49475. /**
  49476. * Define the scale factor of the post process.
  49477. * The smaller the better but the slower.
  49478. */
  49479. postProcessScaleFactor: number;
  49480. /**
  49481. * Define an offset for the lens center.
  49482. */
  49483. lensCenterOffset: number;
  49484. /**
  49485. * Define if the current vr camera should compensate the distortion of the lense or not.
  49486. */
  49487. compensateDistortion: boolean;
  49488. /**
  49489. * Defines if multiview should be enabled when rendering (Default: false)
  49490. */
  49491. multiviewEnabled: boolean;
  49492. /**
  49493. * Gets the rendering aspect ratio based on the provided resolutions.
  49494. */
  49495. get aspectRatio(): number;
  49496. /**
  49497. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49498. */
  49499. get aspectRatioFov(): number;
  49500. /**
  49501. * @hidden
  49502. */
  49503. get leftHMatrix(): Matrix;
  49504. /**
  49505. * @hidden
  49506. */
  49507. get rightHMatrix(): Matrix;
  49508. /**
  49509. * @hidden
  49510. */
  49511. get leftPreViewMatrix(): Matrix;
  49512. /**
  49513. * @hidden
  49514. */
  49515. get rightPreViewMatrix(): Matrix;
  49516. /**
  49517. * Get the default VRMetrics based on the most generic setup.
  49518. * @returns the default vr metrics
  49519. */
  49520. static GetDefault(): VRCameraMetrics;
  49521. }
  49522. }
  49523. declare module BABYLON {
  49524. /** @hidden */
  49525. export var vrDistortionCorrectionPixelShader: {
  49526. name: string;
  49527. shader: string;
  49528. };
  49529. }
  49530. declare module BABYLON {
  49531. /**
  49532. * VRDistortionCorrectionPostProcess used for mobile VR
  49533. */
  49534. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49535. private _isRightEye;
  49536. private _distortionFactors;
  49537. private _postProcessScaleFactor;
  49538. private _lensCenterOffset;
  49539. private _scaleIn;
  49540. private _scaleFactor;
  49541. private _lensCenter;
  49542. /**
  49543. * Gets a string identifying the name of the class
  49544. * @returns "VRDistortionCorrectionPostProcess" string
  49545. */
  49546. getClassName(): string;
  49547. /**
  49548. * Initializes the VRDistortionCorrectionPostProcess
  49549. * @param name The name of the effect.
  49550. * @param camera The camera to apply the render pass to.
  49551. * @param isRightEye If this is for the right eye distortion
  49552. * @param vrMetrics All the required metrics for the VR camera
  49553. */
  49554. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49555. }
  49556. }
  49557. declare module BABYLON {
  49558. /**
  49559. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49560. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49561. */
  49562. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49563. /**
  49564. * Creates a new VRDeviceOrientationArcRotateCamera
  49565. * @param name defines camera name
  49566. * @param alpha defines the camera rotation along the logitudinal axis
  49567. * @param beta defines the camera rotation along the latitudinal axis
  49568. * @param radius defines the camera distance from its target
  49569. * @param target defines the camera target
  49570. * @param scene defines the scene the camera belongs to
  49571. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49572. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49573. */
  49574. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49575. /**
  49576. * Gets camera class name
  49577. * @returns VRDeviceOrientationArcRotateCamera
  49578. */
  49579. getClassName(): string;
  49580. }
  49581. }
  49582. declare module BABYLON {
  49583. /**
  49584. * Camera used to simulate VR rendering (based on FreeCamera)
  49585. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49586. */
  49587. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49588. /**
  49589. * Creates a new VRDeviceOrientationFreeCamera
  49590. * @param name defines camera name
  49591. * @param position defines the start position of the camera
  49592. * @param scene defines the scene the camera belongs to
  49593. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49594. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49595. */
  49596. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49597. /**
  49598. * Gets camera class name
  49599. * @returns VRDeviceOrientationFreeCamera
  49600. */
  49601. getClassName(): string;
  49602. }
  49603. }
  49604. declare module BABYLON {
  49605. /**
  49606. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49607. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49608. */
  49609. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49610. /**
  49611. * Creates a new VRDeviceOrientationGamepadCamera
  49612. * @param name defines camera name
  49613. * @param position defines the start position of the camera
  49614. * @param scene defines the scene the camera belongs to
  49615. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49616. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49617. */
  49618. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49619. /**
  49620. * Gets camera class name
  49621. * @returns VRDeviceOrientationGamepadCamera
  49622. */
  49623. getClassName(): string;
  49624. }
  49625. }
  49626. declare module BABYLON {
  49627. /**
  49628. * A class extending Texture allowing drawing on a texture
  49629. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49630. */
  49631. export class DynamicTexture extends Texture {
  49632. private _generateMipMaps;
  49633. private _canvas;
  49634. private _context;
  49635. /**
  49636. * Creates a DynamicTexture
  49637. * @param name defines the name of the texture
  49638. * @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
  49639. * @param scene defines the scene where you want the texture
  49640. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49641. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49642. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49643. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49644. */
  49645. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49646. /**
  49647. * Get the current class name of the texture useful for serialization or dynamic coding.
  49648. * @returns "DynamicTexture"
  49649. */
  49650. getClassName(): string;
  49651. /**
  49652. * Gets the current state of canRescale
  49653. */
  49654. get canRescale(): boolean;
  49655. private _recreate;
  49656. /**
  49657. * Scales the texture
  49658. * @param ratio the scale factor to apply to both width and height
  49659. */
  49660. scale(ratio: number): void;
  49661. /**
  49662. * Resizes the texture
  49663. * @param width the new width
  49664. * @param height the new height
  49665. */
  49666. scaleTo(width: number, height: number): void;
  49667. /**
  49668. * Gets the context of the canvas used by the texture
  49669. * @returns the canvas context of the dynamic texture
  49670. */
  49671. getContext(): CanvasRenderingContext2D;
  49672. /**
  49673. * Clears the texture
  49674. */
  49675. clear(): void;
  49676. /**
  49677. * Updates the texture
  49678. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49679. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49680. */
  49681. update(invertY?: boolean, premulAlpha?: boolean): void;
  49682. /**
  49683. * Draws text onto the texture
  49684. * @param text defines the text to be drawn
  49685. * @param x defines the placement of the text from the left
  49686. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49687. * @param font defines the font to be used with font-style, font-size, font-name
  49688. * @param color defines the color used for the text
  49689. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49690. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49691. * @param update defines whether texture is immediately update (default is true)
  49692. */
  49693. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49694. /**
  49695. * Clones the texture
  49696. * @returns the clone of the texture.
  49697. */
  49698. clone(): DynamicTexture;
  49699. /**
  49700. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49701. * @returns a serialized dynamic texture object
  49702. */
  49703. serialize(): any;
  49704. private _IsCanvasElement;
  49705. /** @hidden */
  49706. _rebuild(): void;
  49707. }
  49708. }
  49709. declare module BABYLON {
  49710. /**
  49711. * Class containing static functions to help procedurally build meshes
  49712. */
  49713. export class GroundBuilder {
  49714. /**
  49715. * Creates a ground mesh
  49716. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49717. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49719. * @param name defines the name of the mesh
  49720. * @param options defines the options used to create the mesh
  49721. * @param scene defines the hosting scene
  49722. * @returns the ground mesh
  49723. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49724. */
  49725. static CreateGround(name: string, options: {
  49726. width?: number;
  49727. height?: number;
  49728. subdivisions?: number;
  49729. subdivisionsX?: number;
  49730. subdivisionsY?: number;
  49731. updatable?: boolean;
  49732. }, scene: any): Mesh;
  49733. /**
  49734. * Creates a tiled ground mesh
  49735. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49736. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49737. * * 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
  49738. * * 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
  49739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49740. * @param name defines the name of the mesh
  49741. * @param options defines the options used to create the mesh
  49742. * @param scene defines the hosting scene
  49743. * @returns the tiled ground mesh
  49744. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49745. */
  49746. static CreateTiledGround(name: string, options: {
  49747. xmin: number;
  49748. zmin: number;
  49749. xmax: number;
  49750. zmax: number;
  49751. subdivisions?: {
  49752. w: number;
  49753. h: number;
  49754. };
  49755. precision?: {
  49756. w: number;
  49757. h: number;
  49758. };
  49759. updatable?: boolean;
  49760. }, scene?: Nullable<Scene>): Mesh;
  49761. /**
  49762. * Creates a ground mesh from a height map
  49763. * * The parameter `url` sets the URL of the height map image resource.
  49764. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49765. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49766. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49767. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49768. * * 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.
  49769. * * 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).
  49770. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49772. * @param name defines the name of the mesh
  49773. * @param url defines the url to the height map
  49774. * @param options defines the options used to create the mesh
  49775. * @param scene defines the hosting scene
  49776. * @returns the ground mesh
  49777. * @see https://doc.babylonjs.com/babylon101/height_map
  49778. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49779. */
  49780. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49781. width?: number;
  49782. height?: number;
  49783. subdivisions?: number;
  49784. minHeight?: number;
  49785. maxHeight?: number;
  49786. colorFilter?: Color3;
  49787. alphaFilter?: number;
  49788. updatable?: boolean;
  49789. onReady?: (mesh: GroundMesh) => void;
  49790. }, scene?: Nullable<Scene>): GroundMesh;
  49791. }
  49792. }
  49793. declare module BABYLON {
  49794. /**
  49795. * Class containing static functions to help procedurally build meshes
  49796. */
  49797. export class TorusBuilder {
  49798. /**
  49799. * Creates a torus mesh
  49800. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49801. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49802. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49804. * * 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
  49805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49806. * @param name defines the name of the mesh
  49807. * @param options defines the options used to create the mesh
  49808. * @param scene defines the hosting scene
  49809. * @returns the torus mesh
  49810. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49811. */
  49812. static CreateTorus(name: string, options: {
  49813. diameter?: number;
  49814. thickness?: number;
  49815. tessellation?: number;
  49816. updatable?: boolean;
  49817. sideOrientation?: number;
  49818. frontUVs?: Vector4;
  49819. backUVs?: Vector4;
  49820. }, scene: any): Mesh;
  49821. }
  49822. }
  49823. declare module BABYLON {
  49824. /**
  49825. * Class containing static functions to help procedurally build meshes
  49826. */
  49827. export class CylinderBuilder {
  49828. /**
  49829. * Creates a cylinder or a cone mesh
  49830. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49831. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49832. * * 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.
  49833. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49834. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49835. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49836. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49837. * * 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).
  49838. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49839. * * 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).
  49840. * * 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
  49841. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49842. * * 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
  49843. * * 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.
  49844. * * If `enclose` is false, a ring surface is one element.
  49845. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49846. * * 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
  49847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49848. * * 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
  49849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49850. * @param name defines the name of the mesh
  49851. * @param options defines the options used to create the mesh
  49852. * @param scene defines the hosting scene
  49853. * @returns the cylinder mesh
  49854. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49855. */
  49856. static CreateCylinder(name: string, options: {
  49857. height?: number;
  49858. diameterTop?: number;
  49859. diameterBottom?: number;
  49860. diameter?: number;
  49861. tessellation?: number;
  49862. subdivisions?: number;
  49863. arc?: number;
  49864. faceColors?: Color4[];
  49865. faceUV?: Vector4[];
  49866. updatable?: boolean;
  49867. hasRings?: boolean;
  49868. enclose?: boolean;
  49869. cap?: number;
  49870. sideOrientation?: number;
  49871. frontUVs?: Vector4;
  49872. backUVs?: Vector4;
  49873. }, scene: any): Mesh;
  49874. }
  49875. }
  49876. declare module BABYLON {
  49877. /**
  49878. * States of the webXR experience
  49879. */
  49880. export enum WebXRState {
  49881. /**
  49882. * Transitioning to being in XR mode
  49883. */
  49884. ENTERING_XR = 0,
  49885. /**
  49886. * Transitioning to non XR mode
  49887. */
  49888. EXITING_XR = 1,
  49889. /**
  49890. * In XR mode and presenting
  49891. */
  49892. IN_XR = 2,
  49893. /**
  49894. * Not entered XR mode
  49895. */
  49896. NOT_IN_XR = 3
  49897. }
  49898. /**
  49899. * The state of the XR camera's tracking
  49900. */
  49901. export enum WebXRTrackingState {
  49902. /**
  49903. * No transformation received, device is not being tracked
  49904. */
  49905. NOT_TRACKING = 0,
  49906. /**
  49907. * Tracking lost - using emulated position
  49908. */
  49909. TRACKING_LOST = 1,
  49910. /**
  49911. * Transformation tracking works normally
  49912. */
  49913. TRACKING = 2
  49914. }
  49915. /**
  49916. * Abstraction of the XR render target
  49917. */
  49918. export interface WebXRRenderTarget extends IDisposable {
  49919. /**
  49920. * xrpresent context of the canvas which can be used to display/mirror xr content
  49921. */
  49922. canvasContext: WebGLRenderingContext;
  49923. /**
  49924. * xr layer for the canvas
  49925. */
  49926. xrLayer: Nullable<XRWebGLLayer>;
  49927. /**
  49928. * Initializes the xr layer for the session
  49929. * @param xrSession xr session
  49930. * @returns a promise that will resolve once the XR Layer has been created
  49931. */
  49932. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49933. }
  49934. }
  49935. declare module BABYLON {
  49936. /**
  49937. * COnfiguration object for WebXR output canvas
  49938. */
  49939. export class WebXRManagedOutputCanvasOptions {
  49940. /**
  49941. * An optional canvas in case you wish to create it yourself and provide it here.
  49942. * If not provided, a new canvas will be created
  49943. */
  49944. canvasElement?: HTMLCanvasElement;
  49945. /**
  49946. * Options for this XR Layer output
  49947. */
  49948. canvasOptions?: XRWebGLLayerOptions;
  49949. /**
  49950. * CSS styling for a newly created canvas (if not provided)
  49951. */
  49952. newCanvasCssStyle?: string;
  49953. /**
  49954. * Get the default values of the configuration object
  49955. * @param engine defines the engine to use (can be null)
  49956. * @returns default values of this configuration object
  49957. */
  49958. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  49959. }
  49960. /**
  49961. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  49962. */
  49963. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  49964. private _options;
  49965. private _canvas;
  49966. private _engine;
  49967. private _originalCanvasSize;
  49968. /**
  49969. * Rendering context of the canvas which can be used to display/mirror xr content
  49970. */
  49971. canvasContext: WebGLRenderingContext;
  49972. /**
  49973. * xr layer for the canvas
  49974. */
  49975. xrLayer: Nullable<XRWebGLLayer>;
  49976. /**
  49977. * Obseervers registered here will be triggered when the xr layer was initialized
  49978. */
  49979. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  49980. /**
  49981. * Initializes the canvas to be added/removed upon entering/exiting xr
  49982. * @param _xrSessionManager The XR Session manager
  49983. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  49984. */
  49985. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  49986. /**
  49987. * Disposes of the object
  49988. */
  49989. dispose(): void;
  49990. /**
  49991. * Initializes the xr layer for the session
  49992. * @param xrSession xr session
  49993. * @returns a promise that will resolve once the XR Layer has been created
  49994. */
  49995. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49996. private _addCanvas;
  49997. private _removeCanvas;
  49998. private _setCanvasSize;
  49999. private _setManagedOutputCanvas;
  50000. }
  50001. }
  50002. declare module BABYLON {
  50003. /**
  50004. * Manages an XRSession to work with Babylon's engine
  50005. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50006. */
  50007. export class WebXRSessionManager implements IDisposable {
  50008. /** The scene which the session should be created for */
  50009. scene: Scene;
  50010. private _referenceSpace;
  50011. private _rttProvider;
  50012. private _sessionEnded;
  50013. private _xrNavigator;
  50014. private baseLayer;
  50015. /**
  50016. * The base reference space from which the session started. good if you want to reset your
  50017. * reference space
  50018. */
  50019. baseReferenceSpace: XRReferenceSpace;
  50020. /**
  50021. * Current XR frame
  50022. */
  50023. currentFrame: Nullable<XRFrame>;
  50024. /** WebXR timestamp updated every frame */
  50025. currentTimestamp: number;
  50026. /**
  50027. * Used just in case of a failure to initialize an immersive session.
  50028. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50029. */
  50030. defaultHeightCompensation: number;
  50031. /**
  50032. * Fires every time a new xrFrame arrives which can be used to update the camera
  50033. */
  50034. onXRFrameObservable: Observable<XRFrame>;
  50035. /**
  50036. * Fires when the reference space changed
  50037. */
  50038. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50039. /**
  50040. * Fires when the xr session is ended either by the device or manually done
  50041. */
  50042. onXRSessionEnded: Observable<any>;
  50043. /**
  50044. * Fires when the xr session is ended either by the device or manually done
  50045. */
  50046. onXRSessionInit: Observable<XRSession>;
  50047. /**
  50048. * Underlying xr session
  50049. */
  50050. session: XRSession;
  50051. /**
  50052. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50053. * or get the offset the player is currently at.
  50054. */
  50055. viewerReferenceSpace: XRReferenceSpace;
  50056. /**
  50057. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50058. * @param scene The scene which the session should be created for
  50059. */
  50060. constructor(
  50061. /** The scene which the session should be created for */
  50062. scene: Scene);
  50063. /**
  50064. * The current reference space used in this session. This reference space can constantly change!
  50065. * It is mainly used to offset the camera's position.
  50066. */
  50067. get referenceSpace(): XRReferenceSpace;
  50068. /**
  50069. * Set a new reference space and triggers the observable
  50070. */
  50071. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50072. /**
  50073. * Disposes of the session manager
  50074. */
  50075. dispose(): void;
  50076. /**
  50077. * Stops the xrSession and restores the render loop
  50078. * @returns Promise which resolves after it exits XR
  50079. */
  50080. exitXRAsync(): Promise<void>;
  50081. /**
  50082. * Gets the correct render target texture to be rendered this frame for this eye
  50083. * @param eye the eye for which to get the render target
  50084. * @returns the render target for the specified eye
  50085. */
  50086. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50087. /**
  50088. * Creates a WebXRRenderTarget object for the XR session
  50089. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50090. * @param options optional options to provide when creating a new render target
  50091. * @returns a WebXR render target to which the session can render
  50092. */
  50093. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50094. /**
  50095. * Initializes the manager
  50096. * After initialization enterXR can be called to start an XR session
  50097. * @returns Promise which resolves after it is initialized
  50098. */
  50099. initializeAsync(): Promise<void>;
  50100. /**
  50101. * Initializes an xr session
  50102. * @param xrSessionMode mode to initialize
  50103. * @param xrSessionInit defines optional and required values to pass to the session builder
  50104. * @returns a promise which will resolve once the session has been initialized
  50105. */
  50106. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50107. /**
  50108. * Checks if a session would be supported for the creation options specified
  50109. * @param sessionMode session mode to check if supported eg. immersive-vr
  50110. * @returns A Promise that resolves to true if supported and false if not
  50111. */
  50112. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50113. /**
  50114. * Resets the reference space to the one started the session
  50115. */
  50116. resetReferenceSpace(): void;
  50117. /**
  50118. * Starts rendering to the xr layer
  50119. */
  50120. runXRRenderLoop(): void;
  50121. /**
  50122. * Sets the reference space on the xr session
  50123. * @param referenceSpaceType space to set
  50124. * @returns a promise that will resolve once the reference space has been set
  50125. */
  50126. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50127. /**
  50128. * Updates the render state of the session
  50129. * @param state state to set
  50130. * @returns a promise that resolves once the render state has been updated
  50131. */
  50132. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50133. /**
  50134. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50135. * @param sessionMode defines the session to test
  50136. * @returns a promise with boolean as final value
  50137. */
  50138. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50139. private _createRenderTargetTexture;
  50140. }
  50141. }
  50142. declare module BABYLON {
  50143. /**
  50144. * WebXR Camera which holds the views for the xrSession
  50145. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50146. */
  50147. export class WebXRCamera extends FreeCamera {
  50148. private _xrSessionManager;
  50149. private _firstFrame;
  50150. private _referenceQuaternion;
  50151. private _referencedPosition;
  50152. private _xrInvPositionCache;
  50153. private _xrInvQuaternionCache;
  50154. private _trackingState;
  50155. /**
  50156. * Observable raised before camera teleportation
  50157. */
  50158. onBeforeCameraTeleport: Observable<Vector3>;
  50159. /**
  50160. * Observable raised after camera teleportation
  50161. */
  50162. onAfterCameraTeleport: Observable<Vector3>;
  50163. /**
  50164. * Notifies when the camera's tracking state has changed.
  50165. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50166. */
  50167. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50168. /**
  50169. * Should position compensation execute on first frame.
  50170. * This is used when copying the position from a native (non XR) camera
  50171. */
  50172. compensateOnFirstFrame: boolean;
  50173. /**
  50174. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50175. * @param name the name of the camera
  50176. * @param scene the scene to add the camera to
  50177. * @param _xrSessionManager a constructed xr session manager
  50178. */
  50179. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50180. /**
  50181. * Get the current XR tracking state of the camera
  50182. */
  50183. get trackingState(): WebXRTrackingState;
  50184. private _setTrackingState;
  50185. /**
  50186. * Return the user's height, unrelated to the current ground.
  50187. * This will be the y position of this camera, when ground level is 0.
  50188. */
  50189. get realWorldHeight(): number;
  50190. /** @hidden */
  50191. _updateForDualEyeDebugging(): void;
  50192. /**
  50193. * Sets this camera's transformation based on a non-vr camera
  50194. * @param otherCamera the non-vr camera to copy the transformation from
  50195. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50196. */
  50197. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50198. /**
  50199. * Gets the current instance class name ("WebXRCamera").
  50200. * @returns the class name
  50201. */
  50202. getClassName(): string;
  50203. private _rotate180;
  50204. private _updateFromXRSession;
  50205. private _updateNumberOfRigCameras;
  50206. private _updateReferenceSpace;
  50207. private _updateReferenceSpaceOffset;
  50208. }
  50209. }
  50210. declare module BABYLON {
  50211. /**
  50212. * Defining the interface required for a (webxr) feature
  50213. */
  50214. export interface IWebXRFeature extends IDisposable {
  50215. /**
  50216. * Is this feature attached
  50217. */
  50218. attached: boolean;
  50219. /**
  50220. * Should auto-attach be disabled?
  50221. */
  50222. disableAutoAttach: boolean;
  50223. /**
  50224. * Attach the feature to the session
  50225. * Will usually be called by the features manager
  50226. *
  50227. * @param force should attachment be forced (even when already attached)
  50228. * @returns true if successful.
  50229. */
  50230. attach(force?: boolean): boolean;
  50231. /**
  50232. * Detach the feature from the session
  50233. * Will usually be called by the features manager
  50234. *
  50235. * @returns true if successful.
  50236. */
  50237. detach(): boolean;
  50238. /**
  50239. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50240. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50241. *
  50242. * @returns whether or not the feature is compatible in this environment
  50243. */
  50244. isCompatible(): boolean;
  50245. /**
  50246. * Was this feature disposed;
  50247. */
  50248. isDisposed: boolean;
  50249. /**
  50250. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50251. */
  50252. xrNativeFeatureName?: string;
  50253. /**
  50254. * A list of (Babylon WebXR) features this feature depends on
  50255. */
  50256. dependsOn?: string[];
  50257. }
  50258. /**
  50259. * A list of the currently available features without referencing them
  50260. */
  50261. export class WebXRFeatureName {
  50262. /**
  50263. * The name of the anchor system feature
  50264. */
  50265. static readonly ANCHOR_SYSTEM: string;
  50266. /**
  50267. * The name of the background remover feature
  50268. */
  50269. static readonly BACKGROUND_REMOVER: string;
  50270. /**
  50271. * The name of the hit test feature
  50272. */
  50273. static readonly HIT_TEST: string;
  50274. /**
  50275. * physics impostors for xr controllers feature
  50276. */
  50277. static readonly PHYSICS_CONTROLLERS: string;
  50278. /**
  50279. * The name of the plane detection feature
  50280. */
  50281. static readonly PLANE_DETECTION: string;
  50282. /**
  50283. * The name of the pointer selection feature
  50284. */
  50285. static readonly POINTER_SELECTION: string;
  50286. /**
  50287. * The name of the teleportation feature
  50288. */
  50289. static readonly TELEPORTATION: string;
  50290. /**
  50291. * The name of the feature points feature.
  50292. */
  50293. static readonly FEATURE_POINTS: string;
  50294. /**
  50295. * The name of the hand tracking feature.
  50296. */
  50297. static readonly HAND_TRACKING: string;
  50298. }
  50299. /**
  50300. * Defining the constructor of a feature. Used to register the modules.
  50301. */
  50302. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50303. /**
  50304. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50305. * It is mainly used in AR sessions.
  50306. *
  50307. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50308. */
  50309. export class WebXRFeaturesManager implements IDisposable {
  50310. private _xrSessionManager;
  50311. private static readonly _AvailableFeatures;
  50312. private _features;
  50313. /**
  50314. * constructs a new features manages.
  50315. *
  50316. * @param _xrSessionManager an instance of WebXRSessionManager
  50317. */
  50318. constructor(_xrSessionManager: WebXRSessionManager);
  50319. /**
  50320. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50321. * Mainly used internally.
  50322. *
  50323. * @param featureName the name of the feature to register
  50324. * @param constructorFunction the function used to construct the module
  50325. * @param version the (babylon) version of the module
  50326. * @param stable is that a stable version of this module
  50327. */
  50328. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50329. /**
  50330. * Returns a constructor of a specific feature.
  50331. *
  50332. * @param featureName the name of the feature to construct
  50333. * @param version the version of the feature to load
  50334. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50335. * @param options optional options provided to the module.
  50336. * @returns a function that, when called, will return a new instance of this feature
  50337. */
  50338. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50339. /**
  50340. * Can be used to return the list of features currently registered
  50341. *
  50342. * @returns an Array of available features
  50343. */
  50344. static GetAvailableFeatures(): string[];
  50345. /**
  50346. * Gets the versions available for a specific feature
  50347. * @param featureName the name of the feature
  50348. * @returns an array with the available versions
  50349. */
  50350. static GetAvailableVersions(featureName: string): string[];
  50351. /**
  50352. * Return the latest unstable version of this feature
  50353. * @param featureName the name of the feature to search
  50354. * @returns the version number. if not found will return -1
  50355. */
  50356. static GetLatestVersionOfFeature(featureName: string): number;
  50357. /**
  50358. * Return the latest stable version of this feature
  50359. * @param featureName the name of the feature to search
  50360. * @returns the version number. if not found will return -1
  50361. */
  50362. static GetStableVersionOfFeature(featureName: string): number;
  50363. /**
  50364. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50365. * Can be used during a session to start a feature
  50366. * @param featureName the name of feature to attach
  50367. */
  50368. attachFeature(featureName: string): void;
  50369. /**
  50370. * Can be used inside a session or when the session ends to detach a specific feature
  50371. * @param featureName the name of the feature to detach
  50372. */
  50373. detachFeature(featureName: string): void;
  50374. /**
  50375. * Used to disable an already-enabled feature
  50376. * The feature will be disposed and will be recreated once enabled.
  50377. * @param featureName the feature to disable
  50378. * @returns true if disable was successful
  50379. */
  50380. disableFeature(featureName: string | {
  50381. Name: string;
  50382. }): boolean;
  50383. /**
  50384. * dispose this features manager
  50385. */
  50386. dispose(): void;
  50387. /**
  50388. * 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.
  50389. * 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.
  50390. *
  50391. * @param featureName the name of the feature to load or the class of the feature
  50392. * @param version optional version to load. if not provided the latest version will be enabled
  50393. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50394. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50395. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50396. * @returns a new constructed feature or throws an error if feature not found.
  50397. */
  50398. enableFeature(featureName: string | {
  50399. Name: string;
  50400. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50401. /**
  50402. * get the implementation of an enabled feature.
  50403. * @param featureName the name of the feature to load
  50404. * @returns the feature class, if found
  50405. */
  50406. getEnabledFeature(featureName: string): IWebXRFeature;
  50407. /**
  50408. * Get the list of enabled features
  50409. * @returns an array of enabled features
  50410. */
  50411. getEnabledFeatures(): string[];
  50412. /**
  50413. * This function will exten the session creation configuration object with enabled features.
  50414. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50415. * according to the defined "required" variable, provided during enableFeature call
  50416. * @param xrSessionInit the xr Session init object to extend
  50417. *
  50418. * @returns an extended XRSessionInit object
  50419. */
  50420. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50421. }
  50422. }
  50423. declare module BABYLON {
  50424. /**
  50425. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50426. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50427. */
  50428. export class WebXRExperienceHelper implements IDisposable {
  50429. private scene;
  50430. private _nonVRCamera;
  50431. private _originalSceneAutoClear;
  50432. private _supported;
  50433. /**
  50434. * Camera used to render xr content
  50435. */
  50436. camera: WebXRCamera;
  50437. /** A features manager for this xr session */
  50438. featuresManager: WebXRFeaturesManager;
  50439. /**
  50440. * Observers registered here will be triggered after the camera's initial transformation is set
  50441. * This can be used to set a different ground level or an extra rotation.
  50442. *
  50443. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50444. * to the position set after this observable is done executing.
  50445. */
  50446. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50447. /**
  50448. * Fires when the state of the experience helper has changed
  50449. */
  50450. onStateChangedObservable: Observable<WebXRState>;
  50451. /** Session manager used to keep track of xr session */
  50452. sessionManager: WebXRSessionManager;
  50453. /**
  50454. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50455. */
  50456. state: WebXRState;
  50457. /**
  50458. * Creates a WebXRExperienceHelper
  50459. * @param scene The scene the helper should be created in
  50460. */
  50461. private constructor();
  50462. /**
  50463. * Creates the experience helper
  50464. * @param scene the scene to attach the experience helper to
  50465. * @returns a promise for the experience helper
  50466. */
  50467. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50468. /**
  50469. * Disposes of the experience helper
  50470. */
  50471. dispose(): void;
  50472. /**
  50473. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50474. * @param sessionMode options for the XR session
  50475. * @param referenceSpaceType frame of reference of the XR session
  50476. * @param renderTarget the output canvas that will be used to enter XR mode
  50477. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50478. * @returns promise that resolves after xr mode has entered
  50479. */
  50480. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50481. /**
  50482. * Exits XR mode and returns the scene to its original state
  50483. * @returns promise that resolves after xr mode has exited
  50484. */
  50485. exitXRAsync(): Promise<void>;
  50486. private _nonXRToXRCamera;
  50487. private _setState;
  50488. }
  50489. }
  50490. declare module BABYLON {
  50491. /**
  50492. * X-Y values for axes in WebXR
  50493. */
  50494. export interface IWebXRMotionControllerAxesValue {
  50495. /**
  50496. * The value of the x axis
  50497. */
  50498. x: number;
  50499. /**
  50500. * The value of the y-axis
  50501. */
  50502. y: number;
  50503. }
  50504. /**
  50505. * changed / previous values for the values of this component
  50506. */
  50507. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50508. /**
  50509. * current (this frame) value
  50510. */
  50511. current: T;
  50512. /**
  50513. * previous (last change) value
  50514. */
  50515. previous: T;
  50516. }
  50517. /**
  50518. * Represents changes in the component between current frame and last values recorded
  50519. */
  50520. export interface IWebXRMotionControllerComponentChanges {
  50521. /**
  50522. * will be populated with previous and current values if axes changed
  50523. */
  50524. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50525. /**
  50526. * will be populated with previous and current values if pressed changed
  50527. */
  50528. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50529. /**
  50530. * will be populated with previous and current values if touched changed
  50531. */
  50532. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50533. /**
  50534. * will be populated with previous and current values if value changed
  50535. */
  50536. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50537. }
  50538. /**
  50539. * This class represents a single component (for example button or thumbstick) of a motion controller
  50540. */
  50541. export class WebXRControllerComponent implements IDisposable {
  50542. /**
  50543. * the id of this component
  50544. */
  50545. id: string;
  50546. /**
  50547. * the type of the component
  50548. */
  50549. type: MotionControllerComponentType;
  50550. private _buttonIndex;
  50551. private _axesIndices;
  50552. private _axes;
  50553. private _changes;
  50554. private _currentValue;
  50555. private _hasChanges;
  50556. private _pressed;
  50557. private _touched;
  50558. /**
  50559. * button component type
  50560. */
  50561. static BUTTON_TYPE: MotionControllerComponentType;
  50562. /**
  50563. * squeeze component type
  50564. */
  50565. static SQUEEZE_TYPE: MotionControllerComponentType;
  50566. /**
  50567. * Thumbstick component type
  50568. */
  50569. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50570. /**
  50571. * Touchpad component type
  50572. */
  50573. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50574. /**
  50575. * trigger component type
  50576. */
  50577. static TRIGGER_TYPE: MotionControllerComponentType;
  50578. /**
  50579. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50580. * the axes data changes
  50581. */
  50582. onAxisValueChangedObservable: Observable<{
  50583. x: number;
  50584. y: number;
  50585. }>;
  50586. /**
  50587. * Observers registered here will be triggered when the state of a button changes
  50588. * State change is either pressed / touched / value
  50589. */
  50590. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50591. /**
  50592. * Creates a new component for a motion controller.
  50593. * It is created by the motion controller itself
  50594. *
  50595. * @param id the id of this component
  50596. * @param type the type of the component
  50597. * @param _buttonIndex index in the buttons array of the gamepad
  50598. * @param _axesIndices indices of the values in the axes array of the gamepad
  50599. */
  50600. constructor(
  50601. /**
  50602. * the id of this component
  50603. */
  50604. id: string,
  50605. /**
  50606. * the type of the component
  50607. */
  50608. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50609. /**
  50610. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50611. */
  50612. get axes(): IWebXRMotionControllerAxesValue;
  50613. /**
  50614. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50615. */
  50616. get changes(): IWebXRMotionControllerComponentChanges;
  50617. /**
  50618. * Return whether or not the component changed the last frame
  50619. */
  50620. get hasChanges(): boolean;
  50621. /**
  50622. * is the button currently pressed
  50623. */
  50624. get pressed(): boolean;
  50625. /**
  50626. * is the button currently touched
  50627. */
  50628. get touched(): boolean;
  50629. /**
  50630. * Get the current value of this component
  50631. */
  50632. get value(): number;
  50633. /**
  50634. * Dispose this component
  50635. */
  50636. dispose(): void;
  50637. /**
  50638. * Are there axes correlating to this component
  50639. * @return true is axes data is available
  50640. */
  50641. isAxes(): boolean;
  50642. /**
  50643. * Is this component a button (hence - pressable)
  50644. * @returns true if can be pressed
  50645. */
  50646. isButton(): boolean;
  50647. /**
  50648. * update this component using the gamepad object it is in. Called on every frame
  50649. * @param nativeController the native gamepad controller object
  50650. */
  50651. update(nativeController: IMinimalMotionControllerObject): void;
  50652. }
  50653. }
  50654. declare module BABYLON {
  50655. /**
  50656. * Interface used to represent data loading progression
  50657. */
  50658. export interface ISceneLoaderProgressEvent {
  50659. /**
  50660. * Defines if data length to load can be evaluated
  50661. */
  50662. readonly lengthComputable: boolean;
  50663. /**
  50664. * Defines the loaded data length
  50665. */
  50666. readonly loaded: number;
  50667. /**
  50668. * Defines the data length to load
  50669. */
  50670. readonly total: number;
  50671. }
  50672. /**
  50673. * Interface used by SceneLoader plugins to define supported file extensions
  50674. */
  50675. export interface ISceneLoaderPluginExtensions {
  50676. /**
  50677. * Defines the list of supported extensions
  50678. */
  50679. [extension: string]: {
  50680. isBinary: boolean;
  50681. };
  50682. }
  50683. /**
  50684. * Interface used by SceneLoader plugin factory
  50685. */
  50686. export interface ISceneLoaderPluginFactory {
  50687. /**
  50688. * Defines the name of the factory
  50689. */
  50690. name: string;
  50691. /**
  50692. * Function called to create a new plugin
  50693. * @return the new plugin
  50694. */
  50695. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50696. /**
  50697. * The callback that returns true if the data can be directly loaded.
  50698. * @param data string containing the file data
  50699. * @returns if the data can be loaded directly
  50700. */
  50701. canDirectLoad?(data: string): boolean;
  50702. }
  50703. /**
  50704. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  50705. */
  50706. export interface ISceneLoaderPluginBase {
  50707. /**
  50708. * The friendly name of this plugin.
  50709. */
  50710. name: string;
  50711. /**
  50712. * The file extensions supported by this plugin.
  50713. */
  50714. extensions: string | ISceneLoaderPluginExtensions;
  50715. /**
  50716. * The callback called when loading from a url.
  50717. * @param scene scene loading this url
  50718. * @param url url to load
  50719. * @param onSuccess callback called when the file successfully loads
  50720. * @param onProgress callback called while file is loading (if the server supports this mode)
  50721. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  50722. * @param onError callback called when the file fails to load
  50723. * @returns a file request object
  50724. */
  50725. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50726. /**
  50727. * The callback called when loading from a file object.
  50728. * @param scene scene loading this file
  50729. * @param file defines the file to load
  50730. * @param onSuccess defines the callback to call when data is loaded
  50731. * @param onProgress defines the callback to call during loading process
  50732. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  50733. * @param onError defines the callback to call when an error occurs
  50734. * @returns a file request object
  50735. */
  50736. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50737. /**
  50738. * The callback that returns true if the data can be directly loaded.
  50739. * @param data string containing the file data
  50740. * @returns if the data can be loaded directly
  50741. */
  50742. canDirectLoad?(data: string): boolean;
  50743. /**
  50744. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  50745. * @param scene scene loading this data
  50746. * @param data string containing the data
  50747. * @returns data to pass to the plugin
  50748. */
  50749. directLoad?(scene: Scene, data: string): any;
  50750. /**
  50751. * The callback that allows custom handling of the root url based on the response url.
  50752. * @param rootUrl the original root url
  50753. * @param responseURL the response url if available
  50754. * @returns the new root url
  50755. */
  50756. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  50757. }
  50758. /**
  50759. * Interface used to define a SceneLoader plugin
  50760. */
  50761. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  50762. /**
  50763. * Import meshes into a scene.
  50764. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50765. * @param scene The scene to import into
  50766. * @param data The data to import
  50767. * @param rootUrl The root url for scene and resources
  50768. * @param meshes The meshes array to import into
  50769. * @param particleSystems The particle systems array to import into
  50770. * @param skeletons The skeletons array to import into
  50771. * @param onError The callback when import fails
  50772. * @returns True if successful or false otherwise
  50773. */
  50774. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  50775. /**
  50776. * Load into a scene.
  50777. * @param scene The scene to load into
  50778. * @param data The data to import
  50779. * @param rootUrl The root url for scene and resources
  50780. * @param onError The callback when import fails
  50781. * @returns True if successful or false otherwise
  50782. */
  50783. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  50784. /**
  50785. * Load into an asset container.
  50786. * @param scene The scene to load into
  50787. * @param data The data to import
  50788. * @param rootUrl The root url for scene and resources
  50789. * @param onError The callback when import fails
  50790. * @returns The loaded asset container
  50791. */
  50792. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  50793. }
  50794. /**
  50795. * Interface used to define an async SceneLoader plugin
  50796. */
  50797. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  50798. /**
  50799. * Import meshes into a scene.
  50800. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50801. * @param scene The scene to import into
  50802. * @param data The data to import
  50803. * @param rootUrl The root url for scene and resources
  50804. * @param onProgress The callback when the load progresses
  50805. * @param fileName Defines the name of the file to load
  50806. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  50807. */
  50808. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  50809. meshes: AbstractMesh[];
  50810. particleSystems: IParticleSystem[];
  50811. skeletons: Skeleton[];
  50812. animationGroups: AnimationGroup[];
  50813. }>;
  50814. /**
  50815. * Load into a scene.
  50816. * @param scene The scene to load into
  50817. * @param data The data to import
  50818. * @param rootUrl The root url for scene and resources
  50819. * @param onProgress The callback when the load progresses
  50820. * @param fileName Defines the name of the file to load
  50821. * @returns Nothing
  50822. */
  50823. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  50824. /**
  50825. * Load into an asset container.
  50826. * @param scene The scene to load into
  50827. * @param data The data to import
  50828. * @param rootUrl The root url for scene and resources
  50829. * @param onProgress The callback when the load progresses
  50830. * @param fileName Defines the name of the file to load
  50831. * @returns The loaded asset container
  50832. */
  50833. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  50834. }
  50835. /**
  50836. * Mode that determines how to handle old animation groups before loading new ones.
  50837. */
  50838. export enum SceneLoaderAnimationGroupLoadingMode {
  50839. /**
  50840. * Reset all old animations to initial state then dispose them.
  50841. */
  50842. Clean = 0,
  50843. /**
  50844. * Stop all old animations.
  50845. */
  50846. Stop = 1,
  50847. /**
  50848. * Restart old animations from first frame.
  50849. */
  50850. Sync = 2,
  50851. /**
  50852. * Old animations remains untouched.
  50853. */
  50854. NoSync = 3
  50855. }
  50856. /**
  50857. * Defines a plugin registered by the SceneLoader
  50858. */
  50859. interface IRegisteredPlugin {
  50860. /**
  50861. * Defines the plugin to use
  50862. */
  50863. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50864. /**
  50865. * Defines if the plugin supports binary data
  50866. */
  50867. isBinary: boolean;
  50868. }
  50869. /**
  50870. * Class used to load scene from various file formats using registered plugins
  50871. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  50872. */
  50873. export class SceneLoader {
  50874. /**
  50875. * No logging while loading
  50876. */
  50877. static readonly NO_LOGGING: number;
  50878. /**
  50879. * Minimal logging while loading
  50880. */
  50881. static readonly MINIMAL_LOGGING: number;
  50882. /**
  50883. * Summary logging while loading
  50884. */
  50885. static readonly SUMMARY_LOGGING: number;
  50886. /**
  50887. * Detailled logging while loading
  50888. */
  50889. static readonly DETAILED_LOGGING: number;
  50890. /**
  50891. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50892. */
  50893. static get ForceFullSceneLoadingForIncremental(): boolean;
  50894. static set ForceFullSceneLoadingForIncremental(value: boolean);
  50895. /**
  50896. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50897. */
  50898. static get ShowLoadingScreen(): boolean;
  50899. static set ShowLoadingScreen(value: boolean);
  50900. /**
  50901. * Defines the current logging level (while loading the scene)
  50902. * @ignorenaming
  50903. */
  50904. static get loggingLevel(): number;
  50905. static set loggingLevel(value: number);
  50906. /**
  50907. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50908. */
  50909. static get CleanBoneMatrixWeights(): boolean;
  50910. static set CleanBoneMatrixWeights(value: boolean);
  50911. /**
  50912. * Event raised when a plugin is used to load a scene
  50913. */
  50914. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  50915. private static _registeredPlugins;
  50916. private static _showingLoadingScreen;
  50917. /**
  50918. * Gets the default plugin (used to load Babylon files)
  50919. * @returns the .babylon plugin
  50920. */
  50921. static GetDefaultPlugin(): IRegisteredPlugin;
  50922. private static _GetPluginForExtension;
  50923. private static _GetPluginForDirectLoad;
  50924. private static _GetPluginForFilename;
  50925. private static _GetDirectLoad;
  50926. private static _LoadData;
  50927. private static _GetFileInfo;
  50928. /**
  50929. * Gets a plugin that can load the given extension
  50930. * @param extension defines the extension to load
  50931. * @returns a plugin or null if none works
  50932. */
  50933. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50934. /**
  50935. * Gets a boolean indicating that the given extension can be loaded
  50936. * @param extension defines the extension to load
  50937. * @returns true if the extension is supported
  50938. */
  50939. static IsPluginForExtensionAvailable(extension: string): boolean;
  50940. /**
  50941. * Adds a new plugin to the list of registered plugins
  50942. * @param plugin defines the plugin to add
  50943. */
  50944. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  50945. /**
  50946. * Import meshes into a scene
  50947. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50948. * @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)
  50949. * @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)
  50950. * @param scene the instance of BABYLON.Scene to append to
  50951. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  50952. * @param onProgress a callback with a progress event for each file being loaded
  50953. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50954. * @param pluginExtension the extension used to determine the plugin
  50955. * @returns The loaded plugin
  50956. */
  50957. 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>;
  50958. /**
  50959. * Import meshes into a scene
  50960. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50961. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  50962. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  50963. * @param scene the instance of BABYLON.Scene to append to
  50964. * @param onProgress a callback with a progress event for each file being loaded
  50965. * @param pluginExtension the extension used to determine the plugin
  50966. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  50967. */
  50968. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  50969. meshes: AbstractMesh[];
  50970. particleSystems: IParticleSystem[];
  50971. skeletons: Skeleton[];
  50972. animationGroups: AnimationGroup[];
  50973. }>;
  50974. /**
  50975. * Load a scene
  50976. * @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)
  50977. * @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)
  50978. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50979. * @param onSuccess a callback with the scene when import succeeds
  50980. * @param onProgress a callback with a progress event for each file being loaded
  50981. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50982. * @param pluginExtension the extension used to determine the plugin
  50983. * @returns The loaded plugin
  50984. */
  50985. 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>;
  50986. /**
  50987. * Load a scene
  50988. * @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)
  50989. * @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)
  50990. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50991. * @param onProgress a callback with a progress event for each file being loaded
  50992. * @param pluginExtension the extension used to determine the plugin
  50993. * @returns The loaded scene
  50994. */
  50995. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  50996. /**
  50997. * Append a scene
  50998. * @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)
  50999. * @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)
  51000. * @param scene is the instance of BABYLON.Scene to append to
  51001. * @param onSuccess a callback with the scene when import succeeds
  51002. * @param onProgress a callback with a progress event for each file being loaded
  51003. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51004. * @param pluginExtension the extension used to determine the plugin
  51005. * @returns The loaded plugin
  51006. */
  51007. 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>;
  51008. /**
  51009. * Append a scene
  51010. * @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)
  51011. * @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)
  51012. * @param scene is the instance of BABYLON.Scene to append to
  51013. * @param onProgress a callback with a progress event for each file being loaded
  51014. * @param pluginExtension the extension used to determine the plugin
  51015. * @returns The given scene
  51016. */
  51017. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51018. /**
  51019. * Load a scene into an asset container
  51020. * @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)
  51021. * @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)
  51022. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51023. * @param onSuccess a callback with the scene when import succeeds
  51024. * @param onProgress a callback with a progress event for each file being loaded
  51025. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51026. * @param pluginExtension the extension used to determine the plugin
  51027. * @returns The loaded plugin
  51028. */
  51029. 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>;
  51030. /**
  51031. * Load a scene into an asset container
  51032. * @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)
  51033. * @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)
  51034. * @param scene is the instance of Scene to append to
  51035. * @param onProgress a callback with a progress event for each file being loaded
  51036. * @param pluginExtension the extension used to determine the plugin
  51037. * @returns The loaded asset container
  51038. */
  51039. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51040. /**
  51041. * Import animations from a file into a scene
  51042. * @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)
  51043. * @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)
  51044. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51045. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51046. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51047. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51048. * @param onSuccess a callback with the scene when import succeeds
  51049. * @param onProgress a callback with a progress event for each file being loaded
  51050. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51051. * @param pluginExtension the extension used to determine the plugin
  51052. */
  51053. 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;
  51054. /**
  51055. * Import animations from a file into a scene
  51056. * @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)
  51057. * @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)
  51058. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51059. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51060. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51061. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51062. * @param onSuccess a callback with the scene when import succeeds
  51063. * @param onProgress a callback with a progress event for each file being loaded
  51064. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51065. * @param pluginExtension the extension used to determine the plugin
  51066. * @returns the updated scene with imported animations
  51067. */
  51068. 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>;
  51069. }
  51070. }
  51071. declare module BABYLON {
  51072. /**
  51073. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51074. */
  51075. export type MotionControllerHandedness = "none" | "left" | "right";
  51076. /**
  51077. * The type of components available in motion controllers.
  51078. * This is not the name of the component.
  51079. */
  51080. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51081. /**
  51082. * The state of a controller component
  51083. */
  51084. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51085. /**
  51086. * The schema of motion controller layout.
  51087. * No object will be initialized using this interface
  51088. * This is used just to define the profile.
  51089. */
  51090. export interface IMotionControllerLayout {
  51091. /**
  51092. * Path to load the assets. Usually relative to the base path
  51093. */
  51094. assetPath: string;
  51095. /**
  51096. * Available components (unsorted)
  51097. */
  51098. components: {
  51099. /**
  51100. * A map of component Ids
  51101. */
  51102. [componentId: string]: {
  51103. /**
  51104. * The type of input the component outputs
  51105. */
  51106. type: MotionControllerComponentType;
  51107. /**
  51108. * The indices of this component in the gamepad object
  51109. */
  51110. gamepadIndices: {
  51111. /**
  51112. * Index of button
  51113. */
  51114. button?: number;
  51115. /**
  51116. * If available, index of x-axis
  51117. */
  51118. xAxis?: number;
  51119. /**
  51120. * If available, index of y-axis
  51121. */
  51122. yAxis?: number;
  51123. };
  51124. /**
  51125. * The mesh's root node name
  51126. */
  51127. rootNodeName: string;
  51128. /**
  51129. * Animation definitions for this model
  51130. */
  51131. visualResponses: {
  51132. [stateKey: string]: {
  51133. /**
  51134. * What property will be animated
  51135. */
  51136. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51137. /**
  51138. * What states influence this visual response
  51139. */
  51140. states: MotionControllerComponentStateType[];
  51141. /**
  51142. * Type of animation - movement or visibility
  51143. */
  51144. valueNodeProperty: "transform" | "visibility";
  51145. /**
  51146. * Base node name to move. Its position will be calculated according to the min and max nodes
  51147. */
  51148. valueNodeName?: string;
  51149. /**
  51150. * Minimum movement node
  51151. */
  51152. minNodeName?: string;
  51153. /**
  51154. * Max movement node
  51155. */
  51156. maxNodeName?: string;
  51157. };
  51158. };
  51159. /**
  51160. * If touch enabled, what is the name of node to display user feedback
  51161. */
  51162. touchPointNodeName?: string;
  51163. };
  51164. };
  51165. /**
  51166. * Is it xr standard mapping or not
  51167. */
  51168. gamepadMapping: "" | "xr-standard";
  51169. /**
  51170. * Base root node of this entire model
  51171. */
  51172. rootNodeName: string;
  51173. /**
  51174. * Defines the main button component id
  51175. */
  51176. selectComponentId: string;
  51177. }
  51178. /**
  51179. * A definition for the layout map in the input profile
  51180. */
  51181. export interface IMotionControllerLayoutMap {
  51182. /**
  51183. * Layouts with handedness type as a key
  51184. */
  51185. [handedness: string]: IMotionControllerLayout;
  51186. }
  51187. /**
  51188. * The XR Input profile schema
  51189. * Profiles can be found here:
  51190. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51191. */
  51192. export interface IMotionControllerProfile {
  51193. /**
  51194. * fallback profiles for this profileId
  51195. */
  51196. fallbackProfileIds: string[];
  51197. /**
  51198. * The layout map, with handedness as key
  51199. */
  51200. layouts: IMotionControllerLayoutMap;
  51201. /**
  51202. * The id of this profile
  51203. * correlates to the profile(s) in the xrInput.profiles array
  51204. */
  51205. profileId: string;
  51206. }
  51207. /**
  51208. * A helper-interface for the 3 meshes needed for controller button animation
  51209. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51210. */
  51211. export interface IMotionControllerButtonMeshMap {
  51212. /**
  51213. * the mesh that defines the pressed value mesh position.
  51214. * This is used to find the max-position of this button
  51215. */
  51216. pressedMesh: AbstractMesh;
  51217. /**
  51218. * the mesh that defines the unpressed value mesh position.
  51219. * This is used to find the min (or initial) position of this button
  51220. */
  51221. unpressedMesh: AbstractMesh;
  51222. /**
  51223. * The mesh that will be changed when value changes
  51224. */
  51225. valueMesh: AbstractMesh;
  51226. }
  51227. /**
  51228. * A helper-interface for the 3 meshes needed for controller axis animation.
  51229. * This will be expanded when touchpad animations are fully supported
  51230. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51231. */
  51232. export interface IMotionControllerMeshMap {
  51233. /**
  51234. * the mesh that defines the maximum value mesh position.
  51235. */
  51236. maxMesh?: AbstractMesh;
  51237. /**
  51238. * the mesh that defines the minimum value mesh position.
  51239. */
  51240. minMesh?: AbstractMesh;
  51241. /**
  51242. * The mesh that will be changed when axis value changes
  51243. */
  51244. valueMesh?: AbstractMesh;
  51245. }
  51246. /**
  51247. * The elements needed for change-detection of the gamepad objects in motion controllers
  51248. */
  51249. export interface IMinimalMotionControllerObject {
  51250. /**
  51251. * Available axes of this controller
  51252. */
  51253. axes: number[];
  51254. /**
  51255. * An array of available buttons
  51256. */
  51257. buttons: Array<{
  51258. /**
  51259. * Value of the button/trigger
  51260. */
  51261. value: number;
  51262. /**
  51263. * If the button/trigger is currently touched
  51264. */
  51265. touched: boolean;
  51266. /**
  51267. * If the button/trigger is currently pressed
  51268. */
  51269. pressed: boolean;
  51270. }>;
  51271. /**
  51272. * EXPERIMENTAL haptic support.
  51273. */
  51274. hapticActuators?: Array<{
  51275. pulse: (value: number, duration: number) => Promise<boolean>;
  51276. }>;
  51277. }
  51278. /**
  51279. * An Abstract Motion controller
  51280. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51281. * Each component has an observable to check for changes in value and state
  51282. */
  51283. export abstract class WebXRAbstractMotionController implements IDisposable {
  51284. protected scene: Scene;
  51285. protected layout: IMotionControllerLayout;
  51286. /**
  51287. * The gamepad object correlating to this controller
  51288. */
  51289. gamepadObject: IMinimalMotionControllerObject;
  51290. /**
  51291. * handedness (left/right/none) of this controller
  51292. */
  51293. handedness: MotionControllerHandedness;
  51294. private _initComponent;
  51295. private _modelReady;
  51296. /**
  51297. * A map of components (WebXRControllerComponent) in this motion controller
  51298. * Components have a ComponentType and can also have both button and axis definitions
  51299. */
  51300. readonly components: {
  51301. [id: string]: WebXRControllerComponent;
  51302. };
  51303. /**
  51304. * Disable the model's animation. Can be set at any time.
  51305. */
  51306. disableAnimation: boolean;
  51307. /**
  51308. * Observers registered here will be triggered when the model of this controller is done loading
  51309. */
  51310. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51311. /**
  51312. * The profile id of this motion controller
  51313. */
  51314. abstract profileId: string;
  51315. /**
  51316. * The root mesh of the model. It is null if the model was not yet initialized
  51317. */
  51318. rootMesh: Nullable<AbstractMesh>;
  51319. /**
  51320. * constructs a new abstract motion controller
  51321. * @param scene the scene to which the model of the controller will be added
  51322. * @param layout The profile layout to load
  51323. * @param gamepadObject The gamepad object correlating to this controller
  51324. * @param handedness handedness (left/right/none) of this controller
  51325. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51326. */
  51327. constructor(scene: Scene, layout: IMotionControllerLayout,
  51328. /**
  51329. * The gamepad object correlating to this controller
  51330. */
  51331. gamepadObject: IMinimalMotionControllerObject,
  51332. /**
  51333. * handedness (left/right/none) of this controller
  51334. */
  51335. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51336. /**
  51337. * Dispose this controller, the model mesh and all its components
  51338. */
  51339. dispose(): void;
  51340. /**
  51341. * Returns all components of specific type
  51342. * @param type the type to search for
  51343. * @return an array of components with this type
  51344. */
  51345. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51346. /**
  51347. * get a component based an its component id as defined in layout.components
  51348. * @param id the id of the component
  51349. * @returns the component correlates to the id or undefined if not found
  51350. */
  51351. getComponent(id: string): WebXRControllerComponent;
  51352. /**
  51353. * Get the list of components available in this motion controller
  51354. * @returns an array of strings correlating to available components
  51355. */
  51356. getComponentIds(): string[];
  51357. /**
  51358. * Get the first component of specific type
  51359. * @param type type of component to find
  51360. * @return a controller component or null if not found
  51361. */
  51362. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51363. /**
  51364. * Get the main (Select) component of this controller as defined in the layout
  51365. * @returns the main component of this controller
  51366. */
  51367. getMainComponent(): WebXRControllerComponent;
  51368. /**
  51369. * Loads the model correlating to this controller
  51370. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51371. * @returns A promise fulfilled with the result of the model loading
  51372. */
  51373. loadModel(): Promise<boolean>;
  51374. /**
  51375. * Update this model using the current XRFrame
  51376. * @param xrFrame the current xr frame to use and update the model
  51377. */
  51378. updateFromXRFrame(xrFrame: XRFrame): void;
  51379. /**
  51380. * Backwards compatibility due to a deeply-integrated typo
  51381. */
  51382. get handness(): XREye;
  51383. /**
  51384. * Pulse (vibrate) this controller
  51385. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51386. * Consecutive calls to this function will cancel the last pulse call
  51387. *
  51388. * @param value the strength of the pulse in 0.0...1.0 range
  51389. * @param duration Duration of the pulse in milliseconds
  51390. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51391. * @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
  51392. */
  51393. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51394. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51395. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51396. /**
  51397. * Moves the axis on the controller mesh based on its current state
  51398. * @param axis the index of the axis
  51399. * @param axisValue the value of the axis which determines the meshes new position
  51400. * @hidden
  51401. */
  51402. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51403. /**
  51404. * Update the model itself with the current frame data
  51405. * @param xrFrame the frame to use for updating the model mesh
  51406. */
  51407. protected updateModel(xrFrame: XRFrame): void;
  51408. /**
  51409. * Get the filename and path for this controller's model
  51410. * @returns a map of filename and path
  51411. */
  51412. protected abstract _getFilenameAndPath(): {
  51413. filename: string;
  51414. path: string;
  51415. };
  51416. /**
  51417. * This function is called before the mesh is loaded. It checks for loading constraints.
  51418. * For example, this function can check if the GLB loader is available
  51419. * If this function returns false, the generic controller will be loaded instead
  51420. * @returns Is the client ready to load the mesh
  51421. */
  51422. protected abstract _getModelLoadingConstraints(): boolean;
  51423. /**
  51424. * This function will be called after the model was successfully loaded and can be used
  51425. * for mesh transformations before it is available for the user
  51426. * @param meshes the loaded meshes
  51427. */
  51428. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51429. /**
  51430. * Set the root mesh for this controller. Important for the WebXR controller class
  51431. * @param meshes the loaded meshes
  51432. */
  51433. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51434. /**
  51435. * A function executed each frame that updates the mesh (if needed)
  51436. * @param xrFrame the current xrFrame
  51437. */
  51438. protected abstract _updateModel(xrFrame: XRFrame): void;
  51439. private _getGenericFilenameAndPath;
  51440. private _getGenericParentMesh;
  51441. }
  51442. }
  51443. declare module BABYLON {
  51444. /**
  51445. * A generic trigger-only motion controller for WebXR
  51446. */
  51447. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51448. /**
  51449. * Static version of the profile id of this controller
  51450. */
  51451. static ProfileId: string;
  51452. profileId: string;
  51453. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51454. protected _getFilenameAndPath(): {
  51455. filename: string;
  51456. path: string;
  51457. };
  51458. protected _getModelLoadingConstraints(): boolean;
  51459. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51460. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51461. protected _updateModel(): void;
  51462. }
  51463. }
  51464. declare module BABYLON {
  51465. /**
  51466. * Class containing static functions to help procedurally build meshes
  51467. */
  51468. export class SphereBuilder {
  51469. /**
  51470. * Creates a sphere mesh
  51471. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51472. * * 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`)
  51473. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51474. * * 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
  51475. * * 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)
  51476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51477. * * 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
  51478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51479. * @param name defines the name of the mesh
  51480. * @param options defines the options used to create the mesh
  51481. * @param scene defines the hosting scene
  51482. * @returns the sphere mesh
  51483. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51484. */
  51485. static CreateSphere(name: string, options: {
  51486. segments?: number;
  51487. diameter?: number;
  51488. diameterX?: number;
  51489. diameterY?: number;
  51490. diameterZ?: number;
  51491. arc?: number;
  51492. slice?: number;
  51493. sideOrientation?: number;
  51494. frontUVs?: Vector4;
  51495. backUVs?: Vector4;
  51496. updatable?: boolean;
  51497. }, scene?: Nullable<Scene>): Mesh;
  51498. }
  51499. }
  51500. declare module BABYLON {
  51501. /**
  51502. * A profiled motion controller has its profile loaded from an online repository.
  51503. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51504. */
  51505. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51506. private _repositoryUrl;
  51507. private _buttonMeshMapping;
  51508. private _touchDots;
  51509. /**
  51510. * The profile ID of this controller. Will be populated when the controller initializes.
  51511. */
  51512. profileId: string;
  51513. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51514. dispose(): void;
  51515. protected _getFilenameAndPath(): {
  51516. filename: string;
  51517. path: string;
  51518. };
  51519. protected _getModelLoadingConstraints(): boolean;
  51520. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51521. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51522. protected _updateModel(_xrFrame: XRFrame): void;
  51523. }
  51524. }
  51525. declare module BABYLON {
  51526. /**
  51527. * A construction function type to create a new controller based on an xrInput object
  51528. */
  51529. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51530. /**
  51531. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51532. *
  51533. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51534. * it should be replaced with auto-loaded controllers.
  51535. *
  51536. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51537. */
  51538. export class WebXRMotionControllerManager {
  51539. private static _AvailableControllers;
  51540. private static _Fallbacks;
  51541. private static _ProfileLoadingPromises;
  51542. private static _ProfilesList;
  51543. /**
  51544. * The base URL of the online controller repository. Can be changed at any time.
  51545. */
  51546. static BaseRepositoryUrl: string;
  51547. /**
  51548. * Which repository gets priority - local or online
  51549. */
  51550. static PrioritizeOnlineRepository: boolean;
  51551. /**
  51552. * Use the online repository, or use only locally-defined controllers
  51553. */
  51554. static UseOnlineRepository: boolean;
  51555. /**
  51556. * Clear the cache used for profile loading and reload when requested again
  51557. */
  51558. static ClearProfilesCache(): void;
  51559. /**
  51560. * Register the default fallbacks.
  51561. * This function is called automatically when this file is imported.
  51562. */
  51563. static DefaultFallbacks(): void;
  51564. /**
  51565. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51566. * @param profileId the profile to which a fallback needs to be found
  51567. * @return an array with corresponding fallback profiles
  51568. */
  51569. static FindFallbackWithProfileId(profileId: string): string[];
  51570. /**
  51571. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51572. * The order of search:
  51573. *
  51574. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51575. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51576. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51577. * 4) return the generic trigger controller if none were found
  51578. *
  51579. * @param xrInput the xrInput to which a new controller is initialized
  51580. * @param scene the scene to which the model will be added
  51581. * @param forceProfile force a certain profile for this controller
  51582. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51583. */
  51584. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51585. /**
  51586. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51587. *
  51588. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51589. *
  51590. * @param type the profile type to register
  51591. * @param constructFunction the function to be called when loading this profile
  51592. */
  51593. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51594. /**
  51595. * Register a fallback to a specific profile.
  51596. * @param profileId the profileId that will receive the fallbacks
  51597. * @param fallbacks A list of fallback profiles
  51598. */
  51599. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51600. /**
  51601. * Will update the list of profiles available in the repository
  51602. * @return a promise that resolves to a map of profiles available online
  51603. */
  51604. static UpdateProfilesList(): Promise<{
  51605. [profile: string]: string;
  51606. }>;
  51607. private static _LoadProfileFromRepository;
  51608. private static _LoadProfilesFromAvailableControllers;
  51609. }
  51610. }
  51611. declare module BABYLON {
  51612. /**
  51613. * Configuration options for the WebXR controller creation
  51614. */
  51615. export interface IWebXRControllerOptions {
  51616. /**
  51617. * Should the controller mesh be animated when a user interacts with it
  51618. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51619. */
  51620. disableMotionControllerAnimation?: boolean;
  51621. /**
  51622. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51623. */
  51624. doNotLoadControllerMesh?: boolean;
  51625. /**
  51626. * Force a specific controller type for this controller.
  51627. * This can be used when creating your own profile or when testing different controllers
  51628. */
  51629. forceControllerProfile?: string;
  51630. /**
  51631. * Defines a rendering group ID for meshes that will be loaded.
  51632. * This is for the default controllers only.
  51633. */
  51634. renderingGroupId?: number;
  51635. }
  51636. /**
  51637. * Represents an XR controller
  51638. */
  51639. export class WebXRInputSource {
  51640. private _scene;
  51641. /** The underlying input source for the controller */
  51642. inputSource: XRInputSource;
  51643. private _options;
  51644. private _tmpVector;
  51645. private _uniqueId;
  51646. private _disposed;
  51647. /**
  51648. * 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
  51649. */
  51650. grip?: AbstractMesh;
  51651. /**
  51652. * If available, this is the gamepad object related to this controller.
  51653. * Using this object it is possible to get click events and trackpad changes of the
  51654. * webxr controller that is currently being used.
  51655. */
  51656. motionController?: WebXRAbstractMotionController;
  51657. /**
  51658. * Event that fires when the controller is removed/disposed.
  51659. * The object provided as event data is this controller, after associated assets were disposed.
  51660. * uniqueId is still available.
  51661. */
  51662. onDisposeObservable: Observable<WebXRInputSource>;
  51663. /**
  51664. * Will be triggered when the mesh associated with the motion controller is done loading.
  51665. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51666. * A shortened version of controller -> motion controller -> on mesh loaded.
  51667. */
  51668. onMeshLoadedObservable: Observable<AbstractMesh>;
  51669. /**
  51670. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51671. */
  51672. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51673. /**
  51674. * Pointer which can be used to select objects or attach a visible laser to
  51675. */
  51676. pointer: AbstractMesh;
  51677. /**
  51678. * Creates the input source object
  51679. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51680. * @param _scene the scene which the controller should be associated to
  51681. * @param inputSource the underlying input source for the controller
  51682. * @param _options options for this controller creation
  51683. */
  51684. constructor(_scene: Scene,
  51685. /** The underlying input source for the controller */
  51686. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51687. /**
  51688. * Get this controllers unique id
  51689. */
  51690. get uniqueId(): string;
  51691. /**
  51692. * Disposes of the object
  51693. */
  51694. dispose(): void;
  51695. /**
  51696. * Gets a world space ray coming from the pointer or grip
  51697. * @param result the resulting ray
  51698. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51699. */
  51700. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51701. /**
  51702. * Updates the controller pose based on the given XRFrame
  51703. * @param xrFrame xr frame to update the pose with
  51704. * @param referenceSpace reference space to use
  51705. */
  51706. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  51707. }
  51708. }
  51709. declare module BABYLON {
  51710. /**
  51711. * The schema for initialization options of the XR Input class
  51712. */
  51713. export interface IWebXRInputOptions {
  51714. /**
  51715. * If set to true no model will be automatically loaded
  51716. */
  51717. doNotLoadControllerMeshes?: boolean;
  51718. /**
  51719. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  51720. * If not found, the xr input profile data will be used.
  51721. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  51722. */
  51723. forceInputProfile?: string;
  51724. /**
  51725. * Do not send a request to the controller repository to load the profile.
  51726. *
  51727. * Instead, use the controllers available in babylon itself.
  51728. */
  51729. disableOnlineControllerRepository?: boolean;
  51730. /**
  51731. * A custom URL for the controllers repository
  51732. */
  51733. customControllersRepositoryURL?: string;
  51734. /**
  51735. * Should the controller model's components not move according to the user input
  51736. */
  51737. disableControllerAnimation?: boolean;
  51738. /**
  51739. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  51740. */
  51741. controllerOptions?: IWebXRControllerOptions;
  51742. }
  51743. /**
  51744. * XR input used to track XR inputs such as controllers/rays
  51745. */
  51746. export class WebXRInput implements IDisposable {
  51747. /**
  51748. * the xr session manager for this session
  51749. */
  51750. xrSessionManager: WebXRSessionManager;
  51751. /**
  51752. * the WebXR camera for this session. Mainly used for teleportation
  51753. */
  51754. xrCamera: WebXRCamera;
  51755. private readonly options;
  51756. /**
  51757. * XR controllers being tracked
  51758. */
  51759. controllers: Array<WebXRInputSource>;
  51760. private _frameObserver;
  51761. private _sessionEndedObserver;
  51762. private _sessionInitObserver;
  51763. /**
  51764. * Event when a controller has been connected/added
  51765. */
  51766. onControllerAddedObservable: Observable<WebXRInputSource>;
  51767. /**
  51768. * Event when a controller has been removed/disconnected
  51769. */
  51770. onControllerRemovedObservable: Observable<WebXRInputSource>;
  51771. /**
  51772. * Initializes the WebXRInput
  51773. * @param xrSessionManager the xr session manager for this session
  51774. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  51775. * @param options = initialization options for this xr input
  51776. */
  51777. constructor(
  51778. /**
  51779. * the xr session manager for this session
  51780. */
  51781. xrSessionManager: WebXRSessionManager,
  51782. /**
  51783. * the WebXR camera for this session. Mainly used for teleportation
  51784. */
  51785. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  51786. private _onInputSourcesChange;
  51787. private _addAndRemoveControllers;
  51788. /**
  51789. * Disposes of the object
  51790. */
  51791. dispose(): void;
  51792. }
  51793. }
  51794. declare module BABYLON {
  51795. /**
  51796. * This is the base class for all WebXR features.
  51797. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  51798. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  51799. */
  51800. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  51801. protected _xrSessionManager: WebXRSessionManager;
  51802. private _attached;
  51803. private _removeOnDetach;
  51804. /**
  51805. * Is this feature disposed?
  51806. */
  51807. isDisposed: boolean;
  51808. /**
  51809. * Should auto-attach be disabled?
  51810. */
  51811. disableAutoAttach: boolean;
  51812. /**
  51813. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  51814. */
  51815. xrNativeFeatureName: string;
  51816. /**
  51817. * Construct a new (abstract) WebXR feature
  51818. * @param _xrSessionManager the xr session manager for this feature
  51819. */
  51820. constructor(_xrSessionManager: WebXRSessionManager);
  51821. /**
  51822. * Is this feature attached
  51823. */
  51824. get attached(): boolean;
  51825. /**
  51826. * attach this feature
  51827. *
  51828. * @param force should attachment be forced (even when already attached)
  51829. * @returns true if successful, false is failed or already attached
  51830. */
  51831. attach(force?: boolean): boolean;
  51832. /**
  51833. * detach this feature.
  51834. *
  51835. * @returns true if successful, false if failed or already detached
  51836. */
  51837. detach(): boolean;
  51838. /**
  51839. * Dispose this feature and all of the resources attached
  51840. */
  51841. dispose(): void;
  51842. /**
  51843. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  51844. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  51845. *
  51846. * @returns whether or not the feature is compatible in this environment
  51847. */
  51848. isCompatible(): boolean;
  51849. /**
  51850. * This is used to register callbacks that will automatically be removed when detach is called.
  51851. * @param observable the observable to which the observer will be attached
  51852. * @param callback the callback to register
  51853. */
  51854. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  51855. /**
  51856. * Code in this function will be executed on each xrFrame received from the browser.
  51857. * This function will not execute after the feature is detached.
  51858. * @param _xrFrame the current frame
  51859. */
  51860. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  51861. }
  51862. }
  51863. declare module BABYLON {
  51864. /**
  51865. * Renders a layer on top of an existing scene
  51866. */
  51867. export class UtilityLayerRenderer implements IDisposable {
  51868. /** the original scene that will be rendered on top of */
  51869. originalScene: Scene;
  51870. private _pointerCaptures;
  51871. private _lastPointerEvents;
  51872. private static _DefaultUtilityLayer;
  51873. private static _DefaultKeepDepthUtilityLayer;
  51874. private _sharedGizmoLight;
  51875. private _renderCamera;
  51876. /**
  51877. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  51878. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  51879. * @returns the camera that is used when rendering the utility layer
  51880. */
  51881. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  51882. /**
  51883. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  51884. * @param cam the camera that should be used when rendering the utility layer
  51885. */
  51886. setRenderCamera(cam: Nullable<Camera>): void;
  51887. /**
  51888. * @hidden
  51889. * Light which used by gizmos to get light shading
  51890. */
  51891. _getSharedGizmoLight(): HemisphericLight;
  51892. /**
  51893. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  51894. */
  51895. pickUtilitySceneFirst: boolean;
  51896. /**
  51897. * 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)
  51898. */
  51899. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  51900. /**
  51901. * 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)
  51902. */
  51903. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  51904. /**
  51905. * The scene that is rendered on top of the original scene
  51906. */
  51907. utilityLayerScene: Scene;
  51908. /**
  51909. * If the utility layer should automatically be rendered on top of existing scene
  51910. */
  51911. shouldRender: boolean;
  51912. /**
  51913. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  51914. */
  51915. onlyCheckPointerDownEvents: boolean;
  51916. /**
  51917. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  51918. */
  51919. processAllEvents: boolean;
  51920. /**
  51921. * Observable raised when the pointer move from the utility layer scene to the main scene
  51922. */
  51923. onPointerOutObservable: Observable<number>;
  51924. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  51925. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  51926. private _afterRenderObserver;
  51927. private _sceneDisposeObserver;
  51928. private _originalPointerObserver;
  51929. /**
  51930. * Instantiates a UtilityLayerRenderer
  51931. * @param originalScene the original scene that will be rendered on top of
  51932. * @param handleEvents boolean indicating if the utility layer should handle events
  51933. */
  51934. constructor(
  51935. /** the original scene that will be rendered on top of */
  51936. originalScene: Scene, handleEvents?: boolean);
  51937. private _notifyObservers;
  51938. /**
  51939. * Renders the utility layers scene on top of the original scene
  51940. */
  51941. render(): void;
  51942. /**
  51943. * Disposes of the renderer
  51944. */
  51945. dispose(): void;
  51946. private _updateCamera;
  51947. }
  51948. }
  51949. declare module BABYLON {
  51950. /**
  51951. * Options interface for the pointer selection module
  51952. */
  51953. export interface IWebXRControllerPointerSelectionOptions {
  51954. /**
  51955. * if provided, this scene will be used to render meshes.
  51956. */
  51957. customUtilityLayerScene?: Scene;
  51958. /**
  51959. * 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)
  51960. * If not disabled, the last picked point will be used to execute a pointer up event
  51961. * If disabled, pointer up event will be triggered right after the pointer down event.
  51962. * Used in screen and gaze target ray mode only
  51963. */
  51964. disablePointerUpOnTouchOut: boolean;
  51965. /**
  51966. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  51967. */
  51968. forceGazeMode: boolean;
  51969. /**
  51970. * 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
  51971. * to start a new countdown to the pointer down event.
  51972. * Defaults to 1.
  51973. */
  51974. gazeModePointerMovedFactor?: number;
  51975. /**
  51976. * Different button type to use instead of the main component
  51977. */
  51978. overrideButtonId?: string;
  51979. /**
  51980. * use this rendering group id for the meshes (optional)
  51981. */
  51982. renderingGroupId?: number;
  51983. /**
  51984. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  51985. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  51986. * 3000 means 3 seconds between pointing at something and selecting it
  51987. */
  51988. timeToSelect?: number;
  51989. /**
  51990. * Should meshes created here be added to a utility layer or the main scene
  51991. */
  51992. useUtilityLayer?: boolean;
  51993. /**
  51994. * Optional WebXR camera to be used for gaze selection
  51995. */
  51996. gazeCamera?: WebXRCamera;
  51997. /**
  51998. * the xr input to use with this pointer selection
  51999. */
  52000. xrInput: WebXRInput;
  52001. /**
  52002. * Should the scene pointerX and pointerY update be disabled
  52003. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52004. * Disable in VR, if not needed.
  52005. * The first rig camera (left eye) will be used to calculate the projection
  52006. */
  52007. disableScenePointerVectorUpdate: boolean;
  52008. /**
  52009. * Enable pointer selection on all controllers instead of switching between them
  52010. */
  52011. enablePointerSelectionOnAllControllers?: boolean;
  52012. /**
  52013. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52014. * If switch is enabled, it will still allow the user to switch between the different controllers
  52015. */
  52016. preferredHandedness?: XRHandedness;
  52017. /**
  52018. * Disable switching the pointer selection from one controller to the other.
  52019. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  52020. */
  52021. disableSwitchOnClick?: boolean;
  52022. /**
  52023. * The maximum distance of the pointer selection feature. Defaults to 100.
  52024. */
  52025. maxPointerDistance?: number;
  52026. }
  52027. /**
  52028. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52029. */
  52030. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52031. private readonly _options;
  52032. private static _idCounter;
  52033. private _attachController;
  52034. private _controllers;
  52035. private _scene;
  52036. private _tmpVectorForPickCompare;
  52037. private _attachedController;
  52038. /**
  52039. * The module's name
  52040. */
  52041. static readonly Name: string;
  52042. /**
  52043. * The (Babylon) version of this module.
  52044. * This is an integer representing the implementation version.
  52045. * This number does not correspond to the WebXR specs version
  52046. */
  52047. static readonly Version: number;
  52048. /**
  52049. * Disable lighting on the laser pointer (so it will always be visible)
  52050. */
  52051. disablePointerLighting: boolean;
  52052. /**
  52053. * Disable lighting on the selection mesh (so it will always be visible)
  52054. */
  52055. disableSelectionMeshLighting: boolean;
  52056. /**
  52057. * Should the laser pointer be displayed
  52058. */
  52059. displayLaserPointer: boolean;
  52060. /**
  52061. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52062. */
  52063. displaySelectionMesh: boolean;
  52064. /**
  52065. * This color will be set to the laser pointer when selection is triggered
  52066. */
  52067. laserPointerPickedColor: Color3;
  52068. /**
  52069. * Default color of the laser pointer
  52070. */
  52071. laserPointerDefaultColor: Color3;
  52072. /**
  52073. * default color of the selection ring
  52074. */
  52075. selectionMeshDefaultColor: Color3;
  52076. /**
  52077. * This color will be applied to the selection ring when selection is triggered
  52078. */
  52079. selectionMeshPickedColor: Color3;
  52080. /**
  52081. * Optional filter to be used for ray selection. This predicate shares behavior with
  52082. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52083. */
  52084. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52085. /**
  52086. * constructs a new background remover module
  52087. * @param _xrSessionManager the session manager for this module
  52088. * @param _options read-only options to be used in this module
  52089. */
  52090. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52091. /**
  52092. * attach this feature
  52093. * Will usually be called by the features manager
  52094. *
  52095. * @returns true if successful.
  52096. */
  52097. attach(): boolean;
  52098. /**
  52099. * detach this feature.
  52100. * Will usually be called by the features manager
  52101. *
  52102. * @returns true if successful.
  52103. */
  52104. detach(): boolean;
  52105. /**
  52106. * Will get the mesh under a specific pointer.
  52107. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52108. * @param controllerId the controllerId to check
  52109. * @returns The mesh under pointer or null if no mesh is under the pointer
  52110. */
  52111. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52112. /**
  52113. * Get the xr controller that correlates to the pointer id in the pointer event
  52114. *
  52115. * @param id the pointer id to search for
  52116. * @returns the controller that correlates to this id or null if not found
  52117. */
  52118. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52119. private _identityMatrix;
  52120. private _screenCoordinatesRef;
  52121. private _viewportRef;
  52122. protected _onXRFrame(_xrFrame: XRFrame): void;
  52123. private _attachGazeMode;
  52124. private _attachScreenRayMode;
  52125. private _attachTrackedPointerRayMode;
  52126. private _convertNormalToDirectionOfRay;
  52127. private _detachController;
  52128. private _generateNewMeshPair;
  52129. private _pickingMoved;
  52130. private _updatePointerDistance;
  52131. /** @hidden */
  52132. get lasterPointerDefaultColor(): Color3;
  52133. }
  52134. }
  52135. declare module BABYLON {
  52136. /**
  52137. * Button which can be used to enter a different mode of XR
  52138. */
  52139. export class WebXREnterExitUIButton {
  52140. /** button element */
  52141. element: HTMLElement;
  52142. /** XR initialization options for the button */
  52143. sessionMode: XRSessionMode;
  52144. /** Reference space type */
  52145. referenceSpaceType: XRReferenceSpaceType;
  52146. /**
  52147. * Creates a WebXREnterExitUIButton
  52148. * @param element button element
  52149. * @param sessionMode XR initialization session mode
  52150. * @param referenceSpaceType the type of reference space to be used
  52151. */
  52152. constructor(
  52153. /** button element */
  52154. element: HTMLElement,
  52155. /** XR initialization options for the button */
  52156. sessionMode: XRSessionMode,
  52157. /** Reference space type */
  52158. referenceSpaceType: XRReferenceSpaceType);
  52159. /**
  52160. * Extendable function which can be used to update the button's visuals when the state changes
  52161. * @param activeButton the current active button in the UI
  52162. */
  52163. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52164. }
  52165. /**
  52166. * Options to create the webXR UI
  52167. */
  52168. export class WebXREnterExitUIOptions {
  52169. /**
  52170. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52171. */
  52172. customButtons?: Array<WebXREnterExitUIButton>;
  52173. /**
  52174. * A reference space type to use when creating the default button.
  52175. * Default is local-floor
  52176. */
  52177. referenceSpaceType?: XRReferenceSpaceType;
  52178. /**
  52179. * Context to enter xr with
  52180. */
  52181. renderTarget?: Nullable<WebXRRenderTarget>;
  52182. /**
  52183. * A session mode to use when creating the default button.
  52184. * Default is immersive-vr
  52185. */
  52186. sessionMode?: XRSessionMode;
  52187. /**
  52188. * A list of optional features to init the session with
  52189. */
  52190. optionalFeatures?: string[];
  52191. /**
  52192. * A list of optional features to init the session with
  52193. */
  52194. requiredFeatures?: string[];
  52195. }
  52196. /**
  52197. * UI to allow the user to enter/exit XR mode
  52198. */
  52199. export class WebXREnterExitUI implements IDisposable {
  52200. private scene;
  52201. /** version of the options passed to this UI */
  52202. options: WebXREnterExitUIOptions;
  52203. private _activeButton;
  52204. private _buttons;
  52205. /**
  52206. * The HTML Div Element to which buttons are added.
  52207. */
  52208. readonly overlay: HTMLDivElement;
  52209. /**
  52210. * Fired every time the active button is changed.
  52211. *
  52212. * When xr is entered via a button that launches xr that button will be the callback parameter
  52213. *
  52214. * When exiting xr the callback parameter will be null)
  52215. */
  52216. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52217. /**
  52218. *
  52219. * @param scene babylon scene object to use
  52220. * @param options (read-only) version of the options passed to this UI
  52221. */
  52222. private constructor();
  52223. /**
  52224. * Creates UI to allow the user to enter/exit XR mode
  52225. * @param scene the scene to add the ui to
  52226. * @param helper the xr experience helper to enter/exit xr with
  52227. * @param options options to configure the UI
  52228. * @returns the created ui
  52229. */
  52230. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52231. /**
  52232. * Disposes of the XR UI component
  52233. */
  52234. dispose(): void;
  52235. private _updateButtons;
  52236. }
  52237. }
  52238. declare module BABYLON {
  52239. /**
  52240. * Class containing static functions to help procedurally build meshes
  52241. */
  52242. export class LinesBuilder {
  52243. /**
  52244. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52245. * * 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
  52246. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52247. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52248. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52249. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52250. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52251. * * 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
  52252. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52254. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52255. * @param name defines the name of the new line system
  52256. * @param options defines the options used to create the line system
  52257. * @param scene defines the hosting scene
  52258. * @returns a new line system mesh
  52259. */
  52260. static CreateLineSystem(name: string, options: {
  52261. lines: Vector3[][];
  52262. updatable?: boolean;
  52263. instance?: Nullable<LinesMesh>;
  52264. colors?: Nullable<Color4[][]>;
  52265. useVertexAlpha?: boolean;
  52266. }, scene: Nullable<Scene>): LinesMesh;
  52267. /**
  52268. * Creates a line mesh
  52269. * 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
  52270. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52271. * * The parameter `points` is an array successive Vector3
  52272. * * 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
  52273. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52274. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52275. * * When updating an instance, remember that only point positions can change, not the number of points
  52276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52278. * @param name defines the name of the new line system
  52279. * @param options defines the options used to create the line system
  52280. * @param scene defines the hosting scene
  52281. * @returns a new line mesh
  52282. */
  52283. static CreateLines(name: string, options: {
  52284. points: Vector3[];
  52285. updatable?: boolean;
  52286. instance?: Nullable<LinesMesh>;
  52287. colors?: Color4[];
  52288. useVertexAlpha?: boolean;
  52289. }, scene?: Nullable<Scene>): LinesMesh;
  52290. /**
  52291. * Creates a dashed line mesh
  52292. * * 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
  52293. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52294. * * The parameter `points` is an array successive Vector3
  52295. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52296. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52297. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52298. * * 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
  52299. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52300. * * When updating an instance, remember that only point positions can change, not the number of points
  52301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52302. * @param name defines the name of the mesh
  52303. * @param options defines the options used to create the mesh
  52304. * @param scene defines the hosting scene
  52305. * @returns the dashed line mesh
  52306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52307. */
  52308. static CreateDashedLines(name: string, options: {
  52309. points: Vector3[];
  52310. dashSize?: number;
  52311. gapSize?: number;
  52312. dashNb?: number;
  52313. updatable?: boolean;
  52314. instance?: LinesMesh;
  52315. useVertexAlpha?: boolean;
  52316. }, scene?: Nullable<Scene>): LinesMesh;
  52317. }
  52318. }
  52319. declare module BABYLON {
  52320. /**
  52321. * Construction options for a timer
  52322. */
  52323. export interface ITimerOptions<T> {
  52324. /**
  52325. * Time-to-end
  52326. */
  52327. timeout: number;
  52328. /**
  52329. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52330. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52331. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52332. */
  52333. contextObservable: Observable<T>;
  52334. /**
  52335. * Optional parameters when adding an observer to the observable
  52336. */
  52337. observableParameters?: {
  52338. mask?: number;
  52339. insertFirst?: boolean;
  52340. scope?: any;
  52341. };
  52342. /**
  52343. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52344. */
  52345. breakCondition?: (data?: ITimerData<T>) => boolean;
  52346. /**
  52347. * Will be triggered when the time condition has met
  52348. */
  52349. onEnded?: (data: ITimerData<any>) => void;
  52350. /**
  52351. * Will be triggered when the break condition has met (prematurely ended)
  52352. */
  52353. onAborted?: (data: ITimerData<any>) => void;
  52354. /**
  52355. * Optional function to execute on each tick (or count)
  52356. */
  52357. onTick?: (data: ITimerData<any>) => void;
  52358. }
  52359. /**
  52360. * An interface defining the data sent by the timer
  52361. */
  52362. export interface ITimerData<T> {
  52363. /**
  52364. * When did it start
  52365. */
  52366. startTime: number;
  52367. /**
  52368. * Time now
  52369. */
  52370. currentTime: number;
  52371. /**
  52372. * Time passed since started
  52373. */
  52374. deltaTime: number;
  52375. /**
  52376. * How much is completed, in [0.0...1.0].
  52377. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52378. */
  52379. completeRate: number;
  52380. /**
  52381. * What the registered observable sent in the last count
  52382. */
  52383. payload: T;
  52384. }
  52385. /**
  52386. * The current state of the timer
  52387. */
  52388. export enum TimerState {
  52389. /**
  52390. * Timer initialized, not yet started
  52391. */
  52392. INIT = 0,
  52393. /**
  52394. * Timer started and counting
  52395. */
  52396. STARTED = 1,
  52397. /**
  52398. * Timer ended (whether aborted or time reached)
  52399. */
  52400. ENDED = 2
  52401. }
  52402. /**
  52403. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52404. *
  52405. * @param options options with which to initialize this timer
  52406. */
  52407. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52408. /**
  52409. * An advanced implementation of a timer class
  52410. */
  52411. export class AdvancedTimer<T = any> implements IDisposable {
  52412. /**
  52413. * Will notify each time the timer calculates the remaining time
  52414. */
  52415. onEachCountObservable: Observable<ITimerData<T>>;
  52416. /**
  52417. * Will trigger when the timer was aborted due to the break condition
  52418. */
  52419. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52420. /**
  52421. * Will trigger when the timer ended successfully
  52422. */
  52423. onTimerEndedObservable: Observable<ITimerData<T>>;
  52424. /**
  52425. * Will trigger when the timer state has changed
  52426. */
  52427. onStateChangedObservable: Observable<TimerState>;
  52428. private _observer;
  52429. private _contextObservable;
  52430. private _observableParameters;
  52431. private _startTime;
  52432. private _timer;
  52433. private _state;
  52434. private _breakCondition;
  52435. private _timeToEnd;
  52436. private _breakOnNextTick;
  52437. /**
  52438. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52439. * @param options construction options for this advanced timer
  52440. */
  52441. constructor(options: ITimerOptions<T>);
  52442. /**
  52443. * set a breaking condition for this timer. Default is to never break during count
  52444. * @param predicate the new break condition. Returns true to break, false otherwise
  52445. */
  52446. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52447. /**
  52448. * Reset ALL associated observables in this advanced timer
  52449. */
  52450. clearObservables(): void;
  52451. /**
  52452. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52453. *
  52454. * @param timeToEnd how much time to measure until timer ended
  52455. */
  52456. start(timeToEnd?: number): void;
  52457. /**
  52458. * Will force a stop on the next tick.
  52459. */
  52460. stop(): void;
  52461. /**
  52462. * Dispose this timer, clearing all resources
  52463. */
  52464. dispose(): void;
  52465. private _setState;
  52466. private _tick;
  52467. private _stop;
  52468. }
  52469. }
  52470. declare module BABYLON {
  52471. /**
  52472. * The options container for the teleportation module
  52473. */
  52474. export interface IWebXRTeleportationOptions {
  52475. /**
  52476. * if provided, this scene will be used to render meshes.
  52477. */
  52478. customUtilityLayerScene?: Scene;
  52479. /**
  52480. * Values to configure the default target mesh
  52481. */
  52482. defaultTargetMeshOptions?: {
  52483. /**
  52484. * Fill color of the teleportation area
  52485. */
  52486. teleportationFillColor?: string;
  52487. /**
  52488. * Border color for the teleportation area
  52489. */
  52490. teleportationBorderColor?: string;
  52491. /**
  52492. * Disable the mesh's animation sequence
  52493. */
  52494. disableAnimation?: boolean;
  52495. /**
  52496. * Disable lighting on the material or the ring and arrow
  52497. */
  52498. disableLighting?: boolean;
  52499. /**
  52500. * Override the default material of the torus and arrow
  52501. */
  52502. torusArrowMaterial?: Material;
  52503. };
  52504. /**
  52505. * A list of meshes to use as floor meshes.
  52506. * Meshes can be added and removed after initializing the feature using the
  52507. * addFloorMesh and removeFloorMesh functions
  52508. * If empty, rotation will still work
  52509. */
  52510. floorMeshes?: AbstractMesh[];
  52511. /**
  52512. * use this rendering group id for the meshes (optional)
  52513. */
  52514. renderingGroupId?: number;
  52515. /**
  52516. * Should teleportation move only to snap points
  52517. */
  52518. snapPointsOnly?: boolean;
  52519. /**
  52520. * An array of points to which the teleportation will snap to.
  52521. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52522. */
  52523. snapPositions?: Vector3[];
  52524. /**
  52525. * How close should the teleportation ray be in order to snap to position.
  52526. * Default to 0.8 units (meters)
  52527. */
  52528. snapToPositionRadius?: number;
  52529. /**
  52530. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52531. * If you want to support rotation, make sure your mesh has a direction indicator.
  52532. *
  52533. * When left untouched, the default mesh will be initialized.
  52534. */
  52535. teleportationTargetMesh?: AbstractMesh;
  52536. /**
  52537. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52538. */
  52539. timeToTeleport?: number;
  52540. /**
  52541. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52542. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52543. */
  52544. useMainComponentOnly?: boolean;
  52545. /**
  52546. * Should meshes created here be added to a utility layer or the main scene
  52547. */
  52548. useUtilityLayer?: boolean;
  52549. /**
  52550. * Babylon XR Input class for controller
  52551. */
  52552. xrInput: WebXRInput;
  52553. /**
  52554. * Meshes that the teleportation ray cannot go through
  52555. */
  52556. pickBlockerMeshes?: AbstractMesh[];
  52557. }
  52558. /**
  52559. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52560. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52561. * the input of the attached controllers.
  52562. */
  52563. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52564. private _options;
  52565. private _controllers;
  52566. private _currentTeleportationControllerId;
  52567. private _floorMeshes;
  52568. private _quadraticBezierCurve;
  52569. private _selectionFeature;
  52570. private _snapToPositions;
  52571. private _snappedToPoint;
  52572. private _teleportationRingMaterial?;
  52573. private _tmpRay;
  52574. private _tmpVector;
  52575. private _tmpQuaternion;
  52576. /**
  52577. * The module's name
  52578. */
  52579. static readonly Name: string;
  52580. /**
  52581. * The (Babylon) version of this module.
  52582. * This is an integer representing the implementation version.
  52583. * This number does not correspond to the webxr specs version
  52584. */
  52585. static readonly Version: number;
  52586. /**
  52587. * Is movement backwards enabled
  52588. */
  52589. backwardsMovementEnabled: boolean;
  52590. /**
  52591. * Distance to travel when moving backwards
  52592. */
  52593. backwardsTeleportationDistance: number;
  52594. /**
  52595. * The distance from the user to the inspection point in the direction of the controller
  52596. * A higher number will allow the user to move further
  52597. * defaults to 5 (meters, in xr units)
  52598. */
  52599. parabolicCheckRadius: number;
  52600. /**
  52601. * Should the module support parabolic ray on top of direct ray
  52602. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52603. * Very helpful when moving between floors / different heights
  52604. */
  52605. parabolicRayEnabled: boolean;
  52606. /**
  52607. * How much rotation should be applied when rotating right and left
  52608. */
  52609. rotationAngle: number;
  52610. /**
  52611. * Is rotation enabled when moving forward?
  52612. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52613. */
  52614. rotationEnabled: boolean;
  52615. /**
  52616. * constructs a new anchor system
  52617. * @param _xrSessionManager an instance of WebXRSessionManager
  52618. * @param _options configuration object for this feature
  52619. */
  52620. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52621. /**
  52622. * Get the snapPointsOnly flag
  52623. */
  52624. get snapPointsOnly(): boolean;
  52625. /**
  52626. * Sets the snapPointsOnly flag
  52627. * @param snapToPoints should teleportation be exclusively to snap points
  52628. */
  52629. set snapPointsOnly(snapToPoints: boolean);
  52630. /**
  52631. * Add a new mesh to the floor meshes array
  52632. * @param mesh the mesh to use as floor mesh
  52633. */
  52634. addFloorMesh(mesh: AbstractMesh): void;
  52635. /**
  52636. * Add a new snap-to point to fix teleportation to this position
  52637. * @param newSnapPoint The new Snap-To point
  52638. */
  52639. addSnapPoint(newSnapPoint: Vector3): void;
  52640. attach(): boolean;
  52641. detach(): boolean;
  52642. dispose(): void;
  52643. /**
  52644. * Remove a mesh from the floor meshes array
  52645. * @param mesh the mesh to remove
  52646. */
  52647. removeFloorMesh(mesh: AbstractMesh): void;
  52648. /**
  52649. * Remove a mesh from the floor meshes array using its name
  52650. * @param name the mesh name to remove
  52651. */
  52652. removeFloorMeshByName(name: string): void;
  52653. /**
  52654. * 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
  52655. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52656. * @returns was the point found and removed or not
  52657. */
  52658. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52659. /**
  52660. * This function sets a selection feature that will be disabled when
  52661. * the forward ray is shown and will be reattached when hidden.
  52662. * This is used to remove the selection rays when moving.
  52663. * @param selectionFeature the feature to disable when forward movement is enabled
  52664. */
  52665. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52666. protected _onXRFrame(_xrFrame: XRFrame): void;
  52667. private _attachController;
  52668. private _createDefaultTargetMesh;
  52669. private _detachController;
  52670. private _findClosestSnapPointWithRadius;
  52671. private _setTargetMeshPosition;
  52672. private _setTargetMeshVisibility;
  52673. private _showParabolicPath;
  52674. private _teleportForward;
  52675. }
  52676. }
  52677. declare module BABYLON {
  52678. /**
  52679. * Options for the default xr helper
  52680. */
  52681. export class WebXRDefaultExperienceOptions {
  52682. /**
  52683. * Enable or disable default UI to enter XR
  52684. */
  52685. disableDefaultUI?: boolean;
  52686. /**
  52687. * Should teleportation not initialize. defaults to false.
  52688. */
  52689. disableTeleportation?: boolean;
  52690. /**
  52691. * Floor meshes that will be used for teleport
  52692. */
  52693. floorMeshes?: Array<AbstractMesh>;
  52694. /**
  52695. * If set to true, the first frame will not be used to reset position
  52696. * The first frame is mainly used when copying transformation from the old camera
  52697. * Mainly used in AR
  52698. */
  52699. ignoreNativeCameraTransformation?: boolean;
  52700. /**
  52701. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  52702. */
  52703. inputOptions?: IWebXRInputOptions;
  52704. /**
  52705. * optional configuration for the output canvas
  52706. */
  52707. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  52708. /**
  52709. * optional UI options. This can be used among other to change session mode and reference space type
  52710. */
  52711. uiOptions?: WebXREnterExitUIOptions;
  52712. /**
  52713. * When loading teleportation and pointer select, use stable versions instead of latest.
  52714. */
  52715. useStablePlugins?: boolean;
  52716. /**
  52717. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  52718. */
  52719. renderingGroupId?: number;
  52720. /**
  52721. * A list of optional features to init the session with
  52722. * If set to true, all features we support will be added
  52723. */
  52724. optionalFeatures?: boolean | string[];
  52725. }
  52726. /**
  52727. * Default experience which provides a similar setup to the previous webVRExperience
  52728. */
  52729. export class WebXRDefaultExperience {
  52730. /**
  52731. * Base experience
  52732. */
  52733. baseExperience: WebXRExperienceHelper;
  52734. /**
  52735. * Enables ui for entering/exiting xr
  52736. */
  52737. enterExitUI: WebXREnterExitUI;
  52738. /**
  52739. * Input experience extension
  52740. */
  52741. input: WebXRInput;
  52742. /**
  52743. * Enables laser pointer and selection
  52744. */
  52745. pointerSelection: WebXRControllerPointerSelection;
  52746. /**
  52747. * Default target xr should render to
  52748. */
  52749. renderTarget: WebXRRenderTarget;
  52750. /**
  52751. * Enables teleportation
  52752. */
  52753. teleportation: WebXRMotionControllerTeleportation;
  52754. private constructor();
  52755. /**
  52756. * Creates the default xr experience
  52757. * @param scene scene
  52758. * @param options options for basic configuration
  52759. * @returns resulting WebXRDefaultExperience
  52760. */
  52761. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52762. /**
  52763. * DIsposes of the experience helper
  52764. */
  52765. dispose(): void;
  52766. }
  52767. }
  52768. declare module BABYLON {
  52769. /**
  52770. * Options to modify the vr teleportation behavior.
  52771. */
  52772. export interface VRTeleportationOptions {
  52773. /**
  52774. * The name of the mesh which should be used as the teleportation floor. (default: null)
  52775. */
  52776. floorMeshName?: string;
  52777. /**
  52778. * A list of meshes to be used as the teleportation floor. (default: empty)
  52779. */
  52780. floorMeshes?: Mesh[];
  52781. /**
  52782. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  52783. */
  52784. teleportationMode?: number;
  52785. /**
  52786. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  52787. */
  52788. teleportationTime?: number;
  52789. /**
  52790. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  52791. */
  52792. teleportationSpeed?: number;
  52793. /**
  52794. * The easing function used in the animation or null for Linear. (default CircleEase)
  52795. */
  52796. easingFunction?: EasingFunction;
  52797. }
  52798. /**
  52799. * Options to modify the vr experience helper's behavior.
  52800. */
  52801. export interface VRExperienceHelperOptions extends WebVROptions {
  52802. /**
  52803. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  52804. */
  52805. createDeviceOrientationCamera?: boolean;
  52806. /**
  52807. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  52808. */
  52809. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  52810. /**
  52811. * Uses the main button on the controller to toggle the laser casted. (default: true)
  52812. */
  52813. laserToggle?: boolean;
  52814. /**
  52815. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  52816. */
  52817. floorMeshes?: Mesh[];
  52818. /**
  52819. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  52820. */
  52821. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  52822. /**
  52823. * Defines if WebXR should be used instead of WebVR (if available)
  52824. */
  52825. useXR?: boolean;
  52826. }
  52827. /**
  52828. * Event containing information after VR has been entered
  52829. */
  52830. export class OnAfterEnteringVRObservableEvent {
  52831. /**
  52832. * If entering vr was successful
  52833. */
  52834. success: boolean;
  52835. }
  52836. /**
  52837. * Helps to quickly add VR support to an existing scene.
  52838. * See https://doc.babylonjs.com/how_to/webvr_helper
  52839. */
  52840. export class VRExperienceHelper {
  52841. /** Options to modify the vr experience helper's behavior. */
  52842. webVROptions: VRExperienceHelperOptions;
  52843. private _scene;
  52844. private _position;
  52845. private _btnVR;
  52846. private _btnVRDisplayed;
  52847. private _webVRsupported;
  52848. private _webVRready;
  52849. private _webVRrequesting;
  52850. private _webVRpresenting;
  52851. private _hasEnteredVR;
  52852. private _fullscreenVRpresenting;
  52853. private _inputElement;
  52854. private _webVRCamera;
  52855. private _vrDeviceOrientationCamera;
  52856. private _deviceOrientationCamera;
  52857. private _existingCamera;
  52858. private _onKeyDown;
  52859. private _onVrDisplayPresentChange;
  52860. private _onVRDisplayChanged;
  52861. private _onVRRequestPresentStart;
  52862. private _onVRRequestPresentComplete;
  52863. /**
  52864. * 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)
  52865. */
  52866. enableGazeEvenWhenNoPointerLock: boolean;
  52867. /**
  52868. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  52869. */
  52870. exitVROnDoubleTap: boolean;
  52871. /**
  52872. * Observable raised right before entering VR.
  52873. */
  52874. onEnteringVRObservable: Observable<VRExperienceHelper>;
  52875. /**
  52876. * Observable raised when entering VR has completed.
  52877. */
  52878. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  52879. /**
  52880. * Observable raised when exiting VR.
  52881. */
  52882. onExitingVRObservable: Observable<VRExperienceHelper>;
  52883. /**
  52884. * Observable raised when controller mesh is loaded.
  52885. */
  52886. onControllerMeshLoadedObservable: Observable<WebVRController>;
  52887. /** Return this.onEnteringVRObservable
  52888. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  52889. */
  52890. get onEnteringVR(): Observable<VRExperienceHelper>;
  52891. /** Return this.onExitingVRObservable
  52892. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  52893. */
  52894. get onExitingVR(): Observable<VRExperienceHelper>;
  52895. /** Return this.onControllerMeshLoadedObservable
  52896. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  52897. */
  52898. get onControllerMeshLoaded(): Observable<WebVRController>;
  52899. private _rayLength;
  52900. private _useCustomVRButton;
  52901. private _teleportationRequested;
  52902. private _teleportActive;
  52903. private _floorMeshName;
  52904. private _floorMeshesCollection;
  52905. private _teleportationMode;
  52906. private _teleportationTime;
  52907. private _teleportationSpeed;
  52908. private _teleportationEasing;
  52909. private _rotationAllowed;
  52910. private _teleportBackwardsVector;
  52911. private _teleportationTarget;
  52912. private _isDefaultTeleportationTarget;
  52913. private _postProcessMove;
  52914. private _teleportationFillColor;
  52915. private _teleportationBorderColor;
  52916. private _rotationAngle;
  52917. private _haloCenter;
  52918. private _cameraGazer;
  52919. private _padSensibilityUp;
  52920. private _padSensibilityDown;
  52921. private _leftController;
  52922. private _rightController;
  52923. private _gazeColor;
  52924. private _laserColor;
  52925. private _pickedLaserColor;
  52926. private _pickedGazeColor;
  52927. /**
  52928. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  52929. */
  52930. onNewMeshSelected: Observable<AbstractMesh>;
  52931. /**
  52932. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  52933. * This observable will provide the mesh and the controller used to select the mesh
  52934. */
  52935. onMeshSelectedWithController: Observable<{
  52936. mesh: AbstractMesh;
  52937. controller: WebVRController;
  52938. }>;
  52939. /**
  52940. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  52941. */
  52942. onNewMeshPicked: Observable<PickingInfo>;
  52943. private _circleEase;
  52944. /**
  52945. * Observable raised before camera teleportation
  52946. */
  52947. onBeforeCameraTeleport: Observable<Vector3>;
  52948. /**
  52949. * Observable raised after camera teleportation
  52950. */
  52951. onAfterCameraTeleport: Observable<Vector3>;
  52952. /**
  52953. * Observable raised when current selected mesh gets unselected
  52954. */
  52955. onSelectedMeshUnselected: Observable<AbstractMesh>;
  52956. private _raySelectionPredicate;
  52957. /**
  52958. * To be optionaly changed by user to define custom ray selection
  52959. */
  52960. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52961. /**
  52962. * To be optionaly changed by user to define custom selection logic (after ray selection)
  52963. */
  52964. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52965. /**
  52966. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  52967. */
  52968. teleportationEnabled: boolean;
  52969. private _defaultHeight;
  52970. private _teleportationInitialized;
  52971. private _interactionsEnabled;
  52972. private _interactionsRequested;
  52973. private _displayGaze;
  52974. private _displayLaserPointer;
  52975. /**
  52976. * The mesh used to display where the user is going to teleport.
  52977. */
  52978. get teleportationTarget(): Mesh;
  52979. /**
  52980. * Sets the mesh to be used to display where the user is going to teleport.
  52981. */
  52982. set teleportationTarget(value: Mesh);
  52983. /**
  52984. * 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
  52985. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  52986. * See https://doc.babylonjs.com/resources/baking_transformations
  52987. */
  52988. get gazeTrackerMesh(): Mesh;
  52989. set gazeTrackerMesh(value: Mesh);
  52990. /**
  52991. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  52992. */
  52993. updateGazeTrackerScale: boolean;
  52994. /**
  52995. * If the gaze trackers color should be updated when selecting meshes
  52996. */
  52997. updateGazeTrackerColor: boolean;
  52998. /**
  52999. * If the controller laser color should be updated when selecting meshes
  53000. */
  53001. updateControllerLaserColor: boolean;
  53002. /**
  53003. * The gaze tracking mesh corresponding to the left controller
  53004. */
  53005. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53006. /**
  53007. * The gaze tracking mesh corresponding to the right controller
  53008. */
  53009. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53010. /**
  53011. * If the ray of the gaze should be displayed.
  53012. */
  53013. get displayGaze(): boolean;
  53014. /**
  53015. * Sets if the ray of the gaze should be displayed.
  53016. */
  53017. set displayGaze(value: boolean);
  53018. /**
  53019. * If the ray of the LaserPointer should be displayed.
  53020. */
  53021. get displayLaserPointer(): boolean;
  53022. /**
  53023. * Sets if the ray of the LaserPointer should be displayed.
  53024. */
  53025. set displayLaserPointer(value: boolean);
  53026. /**
  53027. * The deviceOrientationCamera used as the camera when not in VR.
  53028. */
  53029. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53030. /**
  53031. * Based on the current WebVR support, returns the current VR camera used.
  53032. */
  53033. get currentVRCamera(): Nullable<Camera>;
  53034. /**
  53035. * The webVRCamera which is used when in VR.
  53036. */
  53037. get webVRCamera(): WebVRFreeCamera;
  53038. /**
  53039. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53040. */
  53041. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53042. /**
  53043. * The html button that is used to trigger entering into VR.
  53044. */
  53045. get vrButton(): Nullable<HTMLButtonElement>;
  53046. private get _teleportationRequestInitiated();
  53047. /**
  53048. * Defines whether or not Pointer lock should be requested when switching to
  53049. * full screen.
  53050. */
  53051. requestPointerLockOnFullScreen: boolean;
  53052. /**
  53053. * If asking to force XR, this will be populated with the default xr experience
  53054. */
  53055. xr: WebXRDefaultExperience;
  53056. /**
  53057. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53058. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53059. */
  53060. xrTestDone: boolean;
  53061. /**
  53062. * Instantiates a VRExperienceHelper.
  53063. * Helps to quickly add VR support to an existing scene.
  53064. * @param scene The scene the VRExperienceHelper belongs to.
  53065. * @param webVROptions Options to modify the vr experience helper's behavior.
  53066. */
  53067. constructor(scene: Scene,
  53068. /** Options to modify the vr experience helper's behavior. */
  53069. webVROptions?: VRExperienceHelperOptions);
  53070. private completeVRInit;
  53071. private _onDefaultMeshLoaded;
  53072. private _onResize;
  53073. private _onFullscreenChange;
  53074. /**
  53075. * Gets a value indicating if we are currently in VR mode.
  53076. */
  53077. get isInVRMode(): boolean;
  53078. private onVrDisplayPresentChange;
  53079. private onVRDisplayChanged;
  53080. private moveButtonToBottomRight;
  53081. private displayVRButton;
  53082. private updateButtonVisibility;
  53083. private _cachedAngularSensibility;
  53084. /**
  53085. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53086. * Otherwise, will use the fullscreen API.
  53087. */
  53088. enterVR(): void;
  53089. /**
  53090. * Attempt to exit VR, or fullscreen.
  53091. */
  53092. exitVR(): void;
  53093. /**
  53094. * The position of the vr experience helper.
  53095. */
  53096. get position(): Vector3;
  53097. /**
  53098. * Sets the position of the vr experience helper.
  53099. */
  53100. set position(value: Vector3);
  53101. /**
  53102. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53103. */
  53104. enableInteractions(): void;
  53105. private get _noControllerIsActive();
  53106. private beforeRender;
  53107. private _isTeleportationFloor;
  53108. /**
  53109. * Adds a floor mesh to be used for teleportation.
  53110. * @param floorMesh the mesh to be used for teleportation.
  53111. */
  53112. addFloorMesh(floorMesh: Mesh): void;
  53113. /**
  53114. * Removes a floor mesh from being used for teleportation.
  53115. * @param floorMesh the mesh to be removed.
  53116. */
  53117. removeFloorMesh(floorMesh: Mesh): void;
  53118. /**
  53119. * Enables interactions and teleportation using the VR controllers and gaze.
  53120. * @param vrTeleportationOptions options to modify teleportation behavior.
  53121. */
  53122. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53123. private _onNewGamepadConnected;
  53124. private _tryEnableInteractionOnController;
  53125. private _onNewGamepadDisconnected;
  53126. private _enableInteractionOnController;
  53127. private _checkTeleportWithRay;
  53128. private _checkRotate;
  53129. private _checkTeleportBackwards;
  53130. private _enableTeleportationOnController;
  53131. private _createTeleportationCircles;
  53132. private _displayTeleportationTarget;
  53133. private _hideTeleportationTarget;
  53134. private _rotateCamera;
  53135. private _moveTeleportationSelectorTo;
  53136. private _workingVector;
  53137. private _workingQuaternion;
  53138. private _workingMatrix;
  53139. /**
  53140. * Time Constant Teleportation Mode
  53141. */
  53142. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53143. /**
  53144. * Speed Constant Teleportation Mode
  53145. */
  53146. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53147. /**
  53148. * Teleports the users feet to the desired location
  53149. * @param location The location where the user's feet should be placed
  53150. */
  53151. teleportCamera(location: Vector3): void;
  53152. private _convertNormalToDirectionOfRay;
  53153. private _castRayAndSelectObject;
  53154. private _notifySelectedMeshUnselected;
  53155. /**
  53156. * Permanently set new colors for the laser pointer
  53157. * @param color the new laser color
  53158. * @param pickedColor the new laser color when picked mesh detected
  53159. */
  53160. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53161. /**
  53162. * Set lighting enabled / disabled on the laser pointer of both controllers
  53163. * @param enabled should the lighting be enabled on the laser pointer
  53164. */
  53165. setLaserLightingState(enabled?: boolean): void;
  53166. /**
  53167. * Permanently set new colors for the gaze pointer
  53168. * @param color the new gaze color
  53169. * @param pickedColor the new gaze color when picked mesh detected
  53170. */
  53171. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53172. /**
  53173. * Sets the color of the laser ray from the vr controllers.
  53174. * @param color new color for the ray.
  53175. */
  53176. changeLaserColor(color: Color3): void;
  53177. /**
  53178. * Sets the color of the ray from the vr headsets gaze.
  53179. * @param color new color for the ray.
  53180. */
  53181. changeGazeColor(color: Color3): void;
  53182. /**
  53183. * Exits VR and disposes of the vr experience helper
  53184. */
  53185. dispose(): void;
  53186. /**
  53187. * Gets the name of the VRExperienceHelper class
  53188. * @returns "VRExperienceHelper"
  53189. */
  53190. getClassName(): string;
  53191. }
  53192. }
  53193. declare module BABYLON {
  53194. /**
  53195. * Contains an array of blocks representing the octree
  53196. */
  53197. export interface IOctreeContainer<T> {
  53198. /**
  53199. * Blocks within the octree
  53200. */
  53201. blocks: Array<OctreeBlock<T>>;
  53202. }
  53203. /**
  53204. * Class used to store a cell in an octree
  53205. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53206. */
  53207. export class OctreeBlock<T> {
  53208. /**
  53209. * Gets the content of the current block
  53210. */
  53211. entries: T[];
  53212. /**
  53213. * Gets the list of block children
  53214. */
  53215. blocks: Array<OctreeBlock<T>>;
  53216. private _depth;
  53217. private _maxDepth;
  53218. private _capacity;
  53219. private _minPoint;
  53220. private _maxPoint;
  53221. private _boundingVectors;
  53222. private _creationFunc;
  53223. /**
  53224. * Creates a new block
  53225. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53226. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53227. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53228. * @param depth defines the current depth of this block in the octree
  53229. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53230. * @param creationFunc defines a callback to call when an element is added to the block
  53231. */
  53232. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53233. /**
  53234. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53235. */
  53236. get capacity(): number;
  53237. /**
  53238. * Gets the minimum vector (in world space) of the block's bounding box
  53239. */
  53240. get minPoint(): Vector3;
  53241. /**
  53242. * Gets the maximum vector (in world space) of the block's bounding box
  53243. */
  53244. get maxPoint(): Vector3;
  53245. /**
  53246. * Add a new element to this block
  53247. * @param entry defines the element to add
  53248. */
  53249. addEntry(entry: T): void;
  53250. /**
  53251. * Remove an element from this block
  53252. * @param entry defines the element to remove
  53253. */
  53254. removeEntry(entry: T): void;
  53255. /**
  53256. * Add an array of elements to this block
  53257. * @param entries defines the array of elements to add
  53258. */
  53259. addEntries(entries: T[]): void;
  53260. /**
  53261. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53262. * @param frustumPlanes defines the frustum planes to test
  53263. * @param selection defines the array to store current content if selection is positive
  53264. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53265. */
  53266. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53267. /**
  53268. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53269. * @param sphereCenter defines the bounding sphere center
  53270. * @param sphereRadius defines the bounding sphere radius
  53271. * @param selection defines the array to store current content if selection is positive
  53272. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53273. */
  53274. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53275. /**
  53276. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53277. * @param ray defines the ray to test with
  53278. * @param selection defines the array to store current content if selection is positive
  53279. */
  53280. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53281. /**
  53282. * Subdivide the content into child blocks (this block will then be empty)
  53283. */
  53284. createInnerBlocks(): void;
  53285. /**
  53286. * @hidden
  53287. */
  53288. 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;
  53289. }
  53290. }
  53291. declare module BABYLON {
  53292. /**
  53293. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53294. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53295. */
  53296. export class Octree<T> {
  53297. /** 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.) */
  53298. maxDepth: number;
  53299. /**
  53300. * Blocks within the octree containing objects
  53301. */
  53302. blocks: Array<OctreeBlock<T>>;
  53303. /**
  53304. * Content stored in the octree
  53305. */
  53306. dynamicContent: T[];
  53307. private _maxBlockCapacity;
  53308. private _selectionContent;
  53309. private _creationFunc;
  53310. /**
  53311. * Creates a octree
  53312. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53313. * @param creationFunc function to be used to instatiate the octree
  53314. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53315. * @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.)
  53316. */
  53317. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53318. /** 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.) */
  53319. maxDepth?: number);
  53320. /**
  53321. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53322. * @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);
  53323. * @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);
  53324. * @param entries meshes to be added to the octree blocks
  53325. */
  53326. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53327. /**
  53328. * Adds a mesh to the octree
  53329. * @param entry Mesh to add to the octree
  53330. */
  53331. addMesh(entry: T): void;
  53332. /**
  53333. * Remove an element from the octree
  53334. * @param entry defines the element to remove
  53335. */
  53336. removeMesh(entry: T): void;
  53337. /**
  53338. * Selects an array of meshes within the frustum
  53339. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53340. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53341. * @returns array of meshes within the frustum
  53342. */
  53343. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53344. /**
  53345. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53346. * @param sphereCenter defines the bounding sphere center
  53347. * @param sphereRadius defines the bounding sphere radius
  53348. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53349. * @returns an array of objects that intersect the sphere
  53350. */
  53351. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53352. /**
  53353. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53354. * @param ray defines the ray to test with
  53355. * @returns array of intersected objects
  53356. */
  53357. intersectsRay(ray: Ray): SmartArray<T>;
  53358. /**
  53359. * Adds a mesh into the octree block if it intersects the block
  53360. */
  53361. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53362. /**
  53363. * Adds a submesh into the octree block if it intersects the block
  53364. */
  53365. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53366. }
  53367. }
  53368. declare module BABYLON {
  53369. interface Scene {
  53370. /**
  53371. * @hidden
  53372. * Backing Filed
  53373. */
  53374. _selectionOctree: Octree<AbstractMesh>;
  53375. /**
  53376. * Gets the octree used to boost mesh selection (picking)
  53377. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53378. */
  53379. selectionOctree: Octree<AbstractMesh>;
  53380. /**
  53381. * Creates or updates the octree used to boost selection (picking)
  53382. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53383. * @param maxCapacity defines the maximum capacity per leaf
  53384. * @param maxDepth defines the maximum depth of the octree
  53385. * @returns an octree of AbstractMesh
  53386. */
  53387. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53388. }
  53389. interface AbstractMesh {
  53390. /**
  53391. * @hidden
  53392. * Backing Field
  53393. */
  53394. _submeshesOctree: Octree<SubMesh>;
  53395. /**
  53396. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53397. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53398. * @param maxCapacity defines the maximum size of each block (64 by default)
  53399. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53400. * @returns the new octree
  53401. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53402. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53403. */
  53404. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53405. }
  53406. /**
  53407. * Defines the octree scene component responsible to manage any octrees
  53408. * in a given scene.
  53409. */
  53410. export class OctreeSceneComponent {
  53411. /**
  53412. * The component name help to identify the component in the list of scene components.
  53413. */
  53414. readonly name: string;
  53415. /**
  53416. * The scene the component belongs to.
  53417. */
  53418. scene: Scene;
  53419. /**
  53420. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53421. */
  53422. readonly checksIsEnabled: boolean;
  53423. /**
  53424. * Creates a new instance of the component for the given scene
  53425. * @param scene Defines the scene to register the component in
  53426. */
  53427. constructor(scene: Scene);
  53428. /**
  53429. * Registers the component in a given scene
  53430. */
  53431. register(): void;
  53432. /**
  53433. * Return the list of active meshes
  53434. * @returns the list of active meshes
  53435. */
  53436. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53437. /**
  53438. * Return the list of active sub meshes
  53439. * @param mesh The mesh to get the candidates sub meshes from
  53440. * @returns the list of active sub meshes
  53441. */
  53442. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53443. private _tempRay;
  53444. /**
  53445. * Return the list of sub meshes intersecting with a given local ray
  53446. * @param mesh defines the mesh to find the submesh for
  53447. * @param localRay defines the ray in local space
  53448. * @returns the list of intersecting sub meshes
  53449. */
  53450. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53451. /**
  53452. * Return the list of sub meshes colliding with a collider
  53453. * @param mesh defines the mesh to find the submesh for
  53454. * @param collider defines the collider to evaluate the collision against
  53455. * @returns the list of colliding sub meshes
  53456. */
  53457. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53458. /**
  53459. * Rebuilds the elements related to this component in case of
  53460. * context lost for instance.
  53461. */
  53462. rebuild(): void;
  53463. /**
  53464. * Disposes the component and the associated ressources.
  53465. */
  53466. dispose(): void;
  53467. }
  53468. }
  53469. declare module BABYLON {
  53470. /**
  53471. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53472. */
  53473. export class Gizmo implements IDisposable {
  53474. /** The utility layer the gizmo will be added to */
  53475. gizmoLayer: UtilityLayerRenderer;
  53476. /**
  53477. * The root mesh of the gizmo
  53478. */
  53479. _rootMesh: Mesh;
  53480. private _attachedMesh;
  53481. private _attachedNode;
  53482. /**
  53483. * Ratio for the scale of the gizmo (Default: 1)
  53484. */
  53485. protected _scaleRatio: number;
  53486. /**
  53487. * boolean updated by pointermove when a gizmo mesh is hovered
  53488. */
  53489. protected _isHovered: boolean;
  53490. /**
  53491. * Ratio for the scale of the gizmo (Default: 1)
  53492. */
  53493. set scaleRatio(value: number);
  53494. get scaleRatio(): number;
  53495. /**
  53496. * True when the mouse pointer is hovered a gizmo mesh
  53497. */
  53498. get isHovered(): boolean;
  53499. /**
  53500. * If a custom mesh has been set (Default: false)
  53501. */
  53502. protected _customMeshSet: boolean;
  53503. /**
  53504. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53505. * * When set, interactions will be enabled
  53506. */
  53507. get attachedMesh(): Nullable<AbstractMesh>;
  53508. set attachedMesh(value: Nullable<AbstractMesh>);
  53509. /**
  53510. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53511. * * When set, interactions will be enabled
  53512. */
  53513. get attachedNode(): Nullable<Node>;
  53514. set attachedNode(value: Nullable<Node>);
  53515. /**
  53516. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53517. * @param mesh The mesh to replace the default mesh of the gizmo
  53518. */
  53519. setCustomMesh(mesh: Mesh): void;
  53520. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53521. /**
  53522. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53523. */
  53524. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53525. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53526. /**
  53527. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53528. */
  53529. updateGizmoPositionToMatchAttachedMesh: boolean;
  53530. /**
  53531. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53532. */
  53533. updateScale: boolean;
  53534. protected _interactionsEnabled: boolean;
  53535. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53536. private _beforeRenderObserver;
  53537. private _tempQuaternion;
  53538. private _tempVector;
  53539. private _tempVector2;
  53540. private _tempMatrix1;
  53541. private _tempMatrix2;
  53542. private _rightHandtoLeftHandMatrix;
  53543. /**
  53544. * Creates a gizmo
  53545. * @param gizmoLayer The utility layer the gizmo will be added to
  53546. */
  53547. constructor(
  53548. /** The utility layer the gizmo will be added to */
  53549. gizmoLayer?: UtilityLayerRenderer);
  53550. /**
  53551. * Updates the gizmo to match the attached mesh's position/rotation
  53552. */
  53553. protected _update(): void;
  53554. /**
  53555. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53556. * @param value Node, TransformNode or mesh
  53557. */
  53558. protected _matrixChanged(): void;
  53559. /**
  53560. * Disposes of the gizmo
  53561. */
  53562. dispose(): void;
  53563. }
  53564. }
  53565. declare module BABYLON {
  53566. /**
  53567. * Single plane drag gizmo
  53568. */
  53569. export class PlaneDragGizmo extends Gizmo {
  53570. /**
  53571. * Drag behavior responsible for the gizmos dragging interactions
  53572. */
  53573. dragBehavior: PointerDragBehavior;
  53574. private _pointerObserver;
  53575. /**
  53576. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53577. */
  53578. snapDistance: number;
  53579. /**
  53580. * Event that fires each time the gizmo snaps to a new location.
  53581. * * snapDistance is the the change in distance
  53582. */
  53583. onSnapObservable: Observable<{
  53584. snapDistance: number;
  53585. }>;
  53586. private _plane;
  53587. private _coloredMaterial;
  53588. private _hoverMaterial;
  53589. private _isEnabled;
  53590. private _parent;
  53591. /** @hidden */
  53592. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53593. /** @hidden */
  53594. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53595. /**
  53596. * Creates a PlaneDragGizmo
  53597. * @param gizmoLayer The utility layer the gizmo will be added to
  53598. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53599. * @param color The color of the gizmo
  53600. */
  53601. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53602. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53603. /**
  53604. * If the gizmo is enabled
  53605. */
  53606. set isEnabled(value: boolean);
  53607. get isEnabled(): boolean;
  53608. /**
  53609. * Disposes of the gizmo
  53610. */
  53611. dispose(): void;
  53612. }
  53613. }
  53614. declare module BABYLON {
  53615. /**
  53616. * Gizmo that enables dragging a mesh along 3 axis
  53617. */
  53618. export class PositionGizmo extends Gizmo {
  53619. /**
  53620. * Internal gizmo used for interactions on the x axis
  53621. */
  53622. xGizmo: AxisDragGizmo;
  53623. /**
  53624. * Internal gizmo used for interactions on the y axis
  53625. */
  53626. yGizmo: AxisDragGizmo;
  53627. /**
  53628. * Internal gizmo used for interactions on the z axis
  53629. */
  53630. zGizmo: AxisDragGizmo;
  53631. /**
  53632. * Internal gizmo used for interactions on the yz plane
  53633. */
  53634. xPlaneGizmo: PlaneDragGizmo;
  53635. /**
  53636. * Internal gizmo used for interactions on the xz plane
  53637. */
  53638. yPlaneGizmo: PlaneDragGizmo;
  53639. /**
  53640. * Internal gizmo used for interactions on the xy plane
  53641. */
  53642. zPlaneGizmo: PlaneDragGizmo;
  53643. /**
  53644. * private variables
  53645. */
  53646. private _meshAttached;
  53647. private _nodeAttached;
  53648. private _snapDistance;
  53649. /** Fires an event when any of it's sub gizmos are dragged */
  53650. onDragStartObservable: Observable<unknown>;
  53651. /** Fires an event when any of it's sub gizmos are released from dragging */
  53652. onDragEndObservable: Observable<unknown>;
  53653. /**
  53654. * If set to true, planar drag is enabled
  53655. */
  53656. private _planarGizmoEnabled;
  53657. get attachedMesh(): Nullable<AbstractMesh>;
  53658. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53659. get attachedNode(): Nullable<Node>;
  53660. set attachedNode(node: Nullable<Node>);
  53661. /**
  53662. * True when the mouse pointer is hovering a gizmo mesh
  53663. */
  53664. get isHovered(): boolean;
  53665. /**
  53666. * Creates a PositionGizmo
  53667. * @param gizmoLayer The utility layer the gizmo will be added to
  53668. @param thickness display gizmo axis thickness
  53669. */
  53670. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53671. /**
  53672. * If the planar drag gizmo is enabled
  53673. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53674. */
  53675. set planarGizmoEnabled(value: boolean);
  53676. get planarGizmoEnabled(): boolean;
  53677. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53678. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53679. /**
  53680. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53681. */
  53682. set snapDistance(value: number);
  53683. get snapDistance(): number;
  53684. /**
  53685. * Ratio for the scale of the gizmo (Default: 1)
  53686. */
  53687. set scaleRatio(value: number);
  53688. get scaleRatio(): number;
  53689. /**
  53690. * Disposes of the gizmo
  53691. */
  53692. dispose(): void;
  53693. /**
  53694. * CustomMeshes are not supported by this gizmo
  53695. * @param mesh The mesh to replace the default mesh of the gizmo
  53696. */
  53697. setCustomMesh(mesh: Mesh): void;
  53698. }
  53699. }
  53700. declare module BABYLON {
  53701. /**
  53702. * Single axis drag gizmo
  53703. */
  53704. export class AxisDragGizmo extends Gizmo {
  53705. /**
  53706. * Drag behavior responsible for the gizmos dragging interactions
  53707. */
  53708. dragBehavior: PointerDragBehavior;
  53709. private _pointerObserver;
  53710. /**
  53711. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53712. */
  53713. snapDistance: number;
  53714. /**
  53715. * Event that fires each time the gizmo snaps to a new location.
  53716. * * snapDistance is the the change in distance
  53717. */
  53718. onSnapObservable: Observable<{
  53719. snapDistance: number;
  53720. }>;
  53721. private _isEnabled;
  53722. private _parent;
  53723. private _arrow;
  53724. private _coloredMaterial;
  53725. private _hoverMaterial;
  53726. /** @hidden */
  53727. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  53728. /** @hidden */
  53729. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53730. /**
  53731. * Creates an AxisDragGizmo
  53732. * @param gizmoLayer The utility layer the gizmo will be added to
  53733. * @param dragAxis The axis which the gizmo will be able to drag on
  53734. * @param color The color of the gizmo
  53735. * @param thickness display gizmo axis thickness
  53736. */
  53737. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  53738. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53739. /**
  53740. * If the gizmo is enabled
  53741. */
  53742. set isEnabled(value: boolean);
  53743. get isEnabled(): boolean;
  53744. /**
  53745. * Disposes of the gizmo
  53746. */
  53747. dispose(): void;
  53748. }
  53749. }
  53750. declare module BABYLON.Debug {
  53751. /**
  53752. * The Axes viewer will show 3 axes in a specific point in space
  53753. */
  53754. export class AxesViewer {
  53755. private _xAxis;
  53756. private _yAxis;
  53757. private _zAxis;
  53758. private _scaleLinesFactor;
  53759. private _instanced;
  53760. /**
  53761. * Gets the hosting scene
  53762. */
  53763. scene: Nullable<Scene>;
  53764. /**
  53765. * Gets or sets a number used to scale line length
  53766. */
  53767. scaleLines: number;
  53768. /** Gets the node hierarchy used to render x-axis */
  53769. get xAxis(): TransformNode;
  53770. /** Gets the node hierarchy used to render y-axis */
  53771. get yAxis(): TransformNode;
  53772. /** Gets the node hierarchy used to render z-axis */
  53773. get zAxis(): TransformNode;
  53774. /**
  53775. * Creates a new AxesViewer
  53776. * @param scene defines the hosting scene
  53777. * @param scaleLines defines a number used to scale line length (1 by default)
  53778. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  53779. * @param xAxis defines the node hierarchy used to render the x-axis
  53780. * @param yAxis defines the node hierarchy used to render the y-axis
  53781. * @param zAxis defines the node hierarchy used to render the z-axis
  53782. */
  53783. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  53784. /**
  53785. * Force the viewer to update
  53786. * @param position defines the position of the viewer
  53787. * @param xaxis defines the x axis of the viewer
  53788. * @param yaxis defines the y axis of the viewer
  53789. * @param zaxis defines the z axis of the viewer
  53790. */
  53791. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  53792. /**
  53793. * Creates an instance of this axes viewer.
  53794. * @returns a new axes viewer with instanced meshes
  53795. */
  53796. createInstance(): AxesViewer;
  53797. /** Releases resources */
  53798. dispose(): void;
  53799. private static _SetRenderingGroupId;
  53800. }
  53801. }
  53802. declare module BABYLON.Debug {
  53803. /**
  53804. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  53805. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  53806. */
  53807. export class BoneAxesViewer extends AxesViewer {
  53808. /**
  53809. * Gets or sets the target mesh where to display the axes viewer
  53810. */
  53811. mesh: Nullable<Mesh>;
  53812. /**
  53813. * Gets or sets the target bone where to display the axes viewer
  53814. */
  53815. bone: Nullable<Bone>;
  53816. /** Gets current position */
  53817. pos: Vector3;
  53818. /** Gets direction of X axis */
  53819. xaxis: Vector3;
  53820. /** Gets direction of Y axis */
  53821. yaxis: Vector3;
  53822. /** Gets direction of Z axis */
  53823. zaxis: Vector3;
  53824. /**
  53825. * Creates a new BoneAxesViewer
  53826. * @param scene defines the hosting scene
  53827. * @param bone defines the target bone
  53828. * @param mesh defines the target mesh
  53829. * @param scaleLines defines a scaling factor for line length (1 by default)
  53830. */
  53831. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  53832. /**
  53833. * Force the viewer to update
  53834. */
  53835. update(): void;
  53836. /** Releases resources */
  53837. dispose(): void;
  53838. }
  53839. }
  53840. declare module BABYLON {
  53841. /**
  53842. * Interface used to define scene explorer extensibility option
  53843. */
  53844. export interface IExplorerExtensibilityOption {
  53845. /**
  53846. * Define the option label
  53847. */
  53848. label: string;
  53849. /**
  53850. * Defines the action to execute on click
  53851. */
  53852. action: (entity: any) => void;
  53853. }
  53854. /**
  53855. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  53856. */
  53857. export interface IExplorerExtensibilityGroup {
  53858. /**
  53859. * Defines a predicate to test if a given type mut be extended
  53860. */
  53861. predicate: (entity: any) => boolean;
  53862. /**
  53863. * Gets the list of options added to a type
  53864. */
  53865. entries: IExplorerExtensibilityOption[];
  53866. }
  53867. /**
  53868. * Interface used to define the options to use to create the Inspector
  53869. */
  53870. export interface IInspectorOptions {
  53871. /**
  53872. * Display in overlay mode (default: false)
  53873. */
  53874. overlay?: boolean;
  53875. /**
  53876. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  53877. */
  53878. globalRoot?: HTMLElement;
  53879. /**
  53880. * Display the Scene explorer
  53881. */
  53882. showExplorer?: boolean;
  53883. /**
  53884. * Display the property inspector
  53885. */
  53886. showInspector?: boolean;
  53887. /**
  53888. * Display in embed mode (both panes on the right)
  53889. */
  53890. embedMode?: boolean;
  53891. /**
  53892. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  53893. */
  53894. handleResize?: boolean;
  53895. /**
  53896. * Allow the panes to popup (default: true)
  53897. */
  53898. enablePopup?: boolean;
  53899. /**
  53900. * Allow the panes to be closed by users (default: true)
  53901. */
  53902. enableClose?: boolean;
  53903. /**
  53904. * Optional list of extensibility entries
  53905. */
  53906. explorerExtensibility?: IExplorerExtensibilityGroup[];
  53907. /**
  53908. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  53909. */
  53910. inspectorURL?: string;
  53911. /**
  53912. * Optional initial tab (default to DebugLayerTab.Properties)
  53913. */
  53914. initialTab?: DebugLayerTab;
  53915. }
  53916. interface Scene {
  53917. /**
  53918. * @hidden
  53919. * Backing field
  53920. */
  53921. _debugLayer: DebugLayer;
  53922. /**
  53923. * Gets the debug layer (aka Inspector) associated with the scene
  53924. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53925. */
  53926. debugLayer: DebugLayer;
  53927. }
  53928. /**
  53929. * Enum of inspector action tab
  53930. */
  53931. export enum DebugLayerTab {
  53932. /**
  53933. * Properties tag (default)
  53934. */
  53935. Properties = 0,
  53936. /**
  53937. * Debug tab
  53938. */
  53939. Debug = 1,
  53940. /**
  53941. * Statistics tab
  53942. */
  53943. Statistics = 2,
  53944. /**
  53945. * Tools tab
  53946. */
  53947. Tools = 3,
  53948. /**
  53949. * Settings tab
  53950. */
  53951. Settings = 4
  53952. }
  53953. /**
  53954. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53955. * what is happening in your scene
  53956. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53957. */
  53958. export class DebugLayer {
  53959. /**
  53960. * Define the url to get the inspector script from.
  53961. * By default it uses the babylonjs CDN.
  53962. * @ignoreNaming
  53963. */
  53964. static InspectorURL: string;
  53965. private _scene;
  53966. private BJSINSPECTOR;
  53967. private _onPropertyChangedObservable?;
  53968. /**
  53969. * Observable triggered when a property is changed through the inspector.
  53970. */
  53971. get onPropertyChangedObservable(): any;
  53972. /**
  53973. * Instantiates a new debug layer.
  53974. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53975. * what is happening in your scene
  53976. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53977. * @param scene Defines the scene to inspect
  53978. */
  53979. constructor(scene: Scene);
  53980. /** Creates the inspector window. */
  53981. private _createInspector;
  53982. /**
  53983. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  53984. * @param entity defines the entity to select
  53985. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  53986. */
  53987. select(entity: any, lineContainerTitles?: string | string[]): void;
  53988. /** Get the inspector from bundle or global */
  53989. private _getGlobalInspector;
  53990. /**
  53991. * Get if the inspector is visible or not.
  53992. * @returns true if visible otherwise, false
  53993. */
  53994. isVisible(): boolean;
  53995. /**
  53996. * Hide the inspector and close its window.
  53997. */
  53998. hide(): void;
  53999. /**
  54000. * Update the scene in the inspector
  54001. */
  54002. setAsActiveScene(): void;
  54003. /**
  54004. * Launch the debugLayer.
  54005. * @param config Define the configuration of the inspector
  54006. * @return a promise fulfilled when the debug layer is visible
  54007. */
  54008. show(config?: IInspectorOptions): Promise<DebugLayer>;
  54009. }
  54010. }
  54011. declare module BABYLON {
  54012. /**
  54013. * Class containing static functions to help procedurally build meshes
  54014. */
  54015. export class BoxBuilder {
  54016. /**
  54017. * Creates a box mesh
  54018. * * The parameter `size` sets the size (float) of each box side (default 1)
  54019. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54020. * * 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)
  54021. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54023. * * 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
  54024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54025. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54026. * @param name defines the name of the mesh
  54027. * @param options defines the options used to create the mesh
  54028. * @param scene defines the hosting scene
  54029. * @returns the box mesh
  54030. */
  54031. static CreateBox(name: string, options: {
  54032. size?: number;
  54033. width?: number;
  54034. height?: number;
  54035. depth?: number;
  54036. faceUV?: Vector4[];
  54037. faceColors?: Color4[];
  54038. sideOrientation?: number;
  54039. frontUVs?: Vector4;
  54040. backUVs?: Vector4;
  54041. wrap?: boolean;
  54042. topBaseAt?: number;
  54043. bottomBaseAt?: number;
  54044. updatable?: boolean;
  54045. }, scene?: Nullable<Scene>): Mesh;
  54046. }
  54047. }
  54048. declare module BABYLON.Debug {
  54049. /**
  54050. * Used to show the physics impostor around the specific mesh
  54051. */
  54052. export class PhysicsViewer {
  54053. /** @hidden */
  54054. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  54055. /** @hidden */
  54056. protected _meshes: Array<Nullable<AbstractMesh>>;
  54057. /** @hidden */
  54058. protected _scene: Nullable<Scene>;
  54059. /** @hidden */
  54060. protected _numMeshes: number;
  54061. /** @hidden */
  54062. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  54063. private _renderFunction;
  54064. private _utilityLayer;
  54065. private _debugBoxMesh;
  54066. private _debugSphereMesh;
  54067. private _debugCylinderMesh;
  54068. private _debugMaterial;
  54069. private _debugMeshMeshes;
  54070. /**
  54071. * Creates a new PhysicsViewer
  54072. * @param scene defines the hosting scene
  54073. */
  54074. constructor(scene: Scene);
  54075. /** @hidden */
  54076. protected _updateDebugMeshes(): void;
  54077. /**
  54078. * Renders a specified physic impostor
  54079. * @param impostor defines the impostor to render
  54080. * @param targetMesh defines the mesh represented by the impostor
  54081. * @returns the new debug mesh used to render the impostor
  54082. */
  54083. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  54084. /**
  54085. * Hides a specified physic impostor
  54086. * @param impostor defines the impostor to hide
  54087. */
  54088. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  54089. private _getDebugMaterial;
  54090. private _getDebugBoxMesh;
  54091. private _getDebugSphereMesh;
  54092. private _getDebugCylinderMesh;
  54093. private _getDebugMeshMesh;
  54094. private _getDebugMesh;
  54095. /** Releases all resources */
  54096. dispose(): void;
  54097. }
  54098. }
  54099. declare module BABYLON {
  54100. /**
  54101. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54102. * in order to better appreciate the issue one might have.
  54103. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54104. */
  54105. export class RayHelper {
  54106. /**
  54107. * Defines the ray we are currently tryin to visualize.
  54108. */
  54109. ray: Nullable<Ray>;
  54110. private _renderPoints;
  54111. private _renderLine;
  54112. private _renderFunction;
  54113. private _scene;
  54114. private _onAfterRenderObserver;
  54115. private _onAfterStepObserver;
  54116. private _attachedToMesh;
  54117. private _meshSpaceDirection;
  54118. private _meshSpaceOrigin;
  54119. /**
  54120. * Helper function to create a colored helper in a scene in one line.
  54121. * @param ray Defines the ray we are currently tryin to visualize
  54122. * @param scene Defines the scene the ray is used in
  54123. * @param color Defines the color we want to see the ray in
  54124. * @returns The newly created ray helper.
  54125. */
  54126. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  54127. /**
  54128. * Instantiate a new ray helper.
  54129. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54130. * in order to better appreciate the issue one might have.
  54131. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54132. * @param ray Defines the ray we are currently tryin to visualize
  54133. */
  54134. constructor(ray: Ray);
  54135. /**
  54136. * Shows the ray we are willing to debug.
  54137. * @param scene Defines the scene the ray needs to be rendered in
  54138. * @param color Defines the color the ray needs to be rendered in
  54139. */
  54140. show(scene: Scene, color?: Color3): void;
  54141. /**
  54142. * Hides the ray we are debugging.
  54143. */
  54144. hide(): void;
  54145. private _render;
  54146. /**
  54147. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  54148. * @param mesh Defines the mesh we want the helper attached to
  54149. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  54150. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  54151. * @param length Defines the length of the ray
  54152. */
  54153. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  54154. /**
  54155. * Detach the ray helper from the mesh it has previously been attached to.
  54156. */
  54157. detachFromMesh(): void;
  54158. private _updateToMesh;
  54159. /**
  54160. * Dispose the helper and release its associated resources.
  54161. */
  54162. dispose(): void;
  54163. }
  54164. }
  54165. declare module BABYLON {
  54166. /**
  54167. * Defines the options associated with the creation of a SkeletonViewer.
  54168. */
  54169. export interface ISkeletonViewerOptions {
  54170. /** Should the system pause animations before building the Viewer? */
  54171. pauseAnimations: boolean;
  54172. /** Should the system return the skeleton to rest before building? */
  54173. returnToRest: boolean;
  54174. /** public Display Mode of the Viewer */
  54175. displayMode: number;
  54176. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54177. displayOptions: ISkeletonViewerDisplayOptions;
  54178. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54179. computeBonesUsingShaders: boolean;
  54180. /** Flag ignore non weighted bones */
  54181. useAllBones: boolean;
  54182. }
  54183. /**
  54184. * Defines how to display the various bone meshes for the viewer.
  54185. */
  54186. export interface ISkeletonViewerDisplayOptions {
  54187. /** How far down to start tapering the bone spurs */
  54188. midStep?: number;
  54189. /** How big is the midStep? */
  54190. midStepFactor?: number;
  54191. /** Base for the Sphere Size */
  54192. sphereBaseSize?: number;
  54193. /** The ratio of the sphere to the longest bone in units */
  54194. sphereScaleUnit?: number;
  54195. /** Ratio for the Sphere Size */
  54196. sphereFactor?: number;
  54197. /** Whether a spur should attach its far end to the child bone position */
  54198. spurFollowsChild?: boolean;
  54199. /** Whether to show local axes or not */
  54200. showLocalAxes?: boolean;
  54201. /** Length of each local axis */
  54202. localAxesSize?: number;
  54203. }
  54204. /**
  54205. * Defines the constructor options for the BoneWeight Shader.
  54206. */
  54207. export interface IBoneWeightShaderOptions {
  54208. /** Skeleton to Map */
  54209. skeleton: Skeleton;
  54210. /** Colors for Uninfluenced bones */
  54211. colorBase?: Color3;
  54212. /** Colors for 0.0-0.25 Weight bones */
  54213. colorZero?: Color3;
  54214. /** Color for 0.25-0.5 Weight Influence */
  54215. colorQuarter?: Color3;
  54216. /** Color for 0.5-0.75 Weight Influence */
  54217. colorHalf?: Color3;
  54218. /** Color for 0.75-1 Weight Influence */
  54219. colorFull?: Color3;
  54220. /** Color for Zero Weight Influence */
  54221. targetBoneIndex?: number;
  54222. }
  54223. /**
  54224. * Simple structure of the gradient steps for the Color Map.
  54225. */
  54226. export interface ISkeletonMapShaderColorMapKnot {
  54227. /** Color of the Knot */
  54228. color: Color3;
  54229. /** Location of the Knot */
  54230. location: number;
  54231. }
  54232. /**
  54233. * Defines the constructor options for the SkeletonMap Shader.
  54234. */
  54235. export interface ISkeletonMapShaderOptions {
  54236. /** Skeleton to Map */
  54237. skeleton: Skeleton;
  54238. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54239. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54240. }
  54241. }
  54242. declare module BABYLON {
  54243. /**
  54244. * Class containing static functions to help procedurally build meshes
  54245. */
  54246. export class RibbonBuilder {
  54247. /**
  54248. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54249. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54250. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54251. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54252. * * 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
  54253. * * 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
  54254. * * 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
  54255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54256. * * 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
  54257. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54258. * * 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
  54259. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54260. * * 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
  54261. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54263. * @param name defines the name of the mesh
  54264. * @param options defines the options used to create the mesh
  54265. * @param scene defines the hosting scene
  54266. * @returns the ribbon mesh
  54267. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54268. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54269. */
  54270. static CreateRibbon(name: string, options: {
  54271. pathArray: Vector3[][];
  54272. closeArray?: boolean;
  54273. closePath?: boolean;
  54274. offset?: number;
  54275. updatable?: boolean;
  54276. sideOrientation?: number;
  54277. frontUVs?: Vector4;
  54278. backUVs?: Vector4;
  54279. instance?: Mesh;
  54280. invertUV?: boolean;
  54281. uvs?: Vector2[];
  54282. colors?: Color4[];
  54283. }, scene?: Nullable<Scene>): Mesh;
  54284. }
  54285. }
  54286. declare module BABYLON {
  54287. /**
  54288. * Class containing static functions to help procedurally build meshes
  54289. */
  54290. export class ShapeBuilder {
  54291. /**
  54292. * 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.
  54293. * * 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.
  54294. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54295. * * 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.
  54296. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54297. * * 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
  54298. * * 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
  54299. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54301. * * 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
  54302. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54304. * @param name defines the name of the mesh
  54305. * @param options defines the options used to create the mesh
  54306. * @param scene defines the hosting scene
  54307. * @returns the extruded shape mesh
  54308. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54310. */
  54311. static ExtrudeShape(name: string, options: {
  54312. shape: Vector3[];
  54313. path: Vector3[];
  54314. scale?: number;
  54315. rotation?: number;
  54316. cap?: number;
  54317. updatable?: boolean;
  54318. sideOrientation?: number;
  54319. frontUVs?: Vector4;
  54320. backUVs?: Vector4;
  54321. instance?: Mesh;
  54322. invertUV?: boolean;
  54323. }, scene?: Nullable<Scene>): Mesh;
  54324. /**
  54325. * Creates an custom extruded shape mesh.
  54326. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54327. * * 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.
  54328. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54329. * * 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
  54330. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54331. * * 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
  54332. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54333. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54334. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54335. * * 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
  54336. * * 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
  54337. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54339. * * 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
  54340. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54342. * @param name defines the name of the mesh
  54343. * @param options defines the options used to create the mesh
  54344. * @param scene defines the hosting scene
  54345. * @returns the custom extruded shape mesh
  54346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54348. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54349. */
  54350. static ExtrudeShapeCustom(name: string, options: {
  54351. shape: Vector3[];
  54352. path: Vector3[];
  54353. scaleFunction?: any;
  54354. rotationFunction?: any;
  54355. ribbonCloseArray?: boolean;
  54356. ribbonClosePath?: boolean;
  54357. cap?: number;
  54358. updatable?: boolean;
  54359. sideOrientation?: number;
  54360. frontUVs?: Vector4;
  54361. backUVs?: Vector4;
  54362. instance?: Mesh;
  54363. invertUV?: boolean;
  54364. }, scene?: Nullable<Scene>): Mesh;
  54365. private static _ExtrudeShapeGeneric;
  54366. }
  54367. }
  54368. declare module BABYLON.Debug {
  54369. /**
  54370. * Class used to render a debug view of a given skeleton
  54371. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54372. */
  54373. export class SkeletonViewer {
  54374. /** defines the skeleton to render */
  54375. skeleton: Skeleton;
  54376. /** defines the mesh attached to the skeleton */
  54377. mesh: AbstractMesh;
  54378. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54379. autoUpdateBonesMatrices: boolean;
  54380. /** defines the rendering group id to use with the viewer */
  54381. renderingGroupId: number;
  54382. /** is the options for the viewer */
  54383. options: Partial<ISkeletonViewerOptions>;
  54384. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54385. static readonly DISPLAY_LINES: number;
  54386. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54387. static readonly DISPLAY_SPHERES: number;
  54388. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54389. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54390. /** public static method to create a BoneWeight Shader
  54391. * @param options The constructor options
  54392. * @param scene The scene that the shader is scoped to
  54393. * @returns The created ShaderMaterial
  54394. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54395. */
  54396. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54397. /** public static method to create a BoneWeight Shader
  54398. * @param options The constructor options
  54399. * @param scene The scene that the shader is scoped to
  54400. * @returns The created ShaderMaterial
  54401. */
  54402. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54403. /** private static method to create a BoneWeight Shader
  54404. * @param size The size of the buffer to create (usually the bone count)
  54405. * @param colorMap The gradient data to generate
  54406. * @param scene The scene that the shader is scoped to
  54407. * @returns an Array of floats from the color gradient values
  54408. */
  54409. private static _CreateBoneMapColorBuffer;
  54410. /** If SkeletonViewer scene scope. */
  54411. private _scene;
  54412. /** Gets or sets the color used to render the skeleton */
  54413. color: Color3;
  54414. /** Array of the points of the skeleton fo the line view. */
  54415. private _debugLines;
  54416. /** The SkeletonViewers Mesh. */
  54417. private _debugMesh;
  54418. /** The local axes Meshes. */
  54419. private _localAxes;
  54420. /** If SkeletonViewer is enabled. */
  54421. private _isEnabled;
  54422. /** If SkeletonViewer is ready. */
  54423. private _ready;
  54424. /** SkeletonViewer render observable. */
  54425. private _obs;
  54426. /** The Utility Layer to render the gizmos in. */
  54427. private _utilityLayer;
  54428. private _boneIndices;
  54429. /** Gets the Scene. */
  54430. get scene(): Scene;
  54431. /** Gets the utilityLayer. */
  54432. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54433. /** Checks Ready Status. */
  54434. get isReady(): Boolean;
  54435. /** Sets Ready Status. */
  54436. set ready(value: boolean);
  54437. /** Gets the debugMesh */
  54438. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54439. /** Sets the debugMesh */
  54440. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54441. /** Gets the displayMode */
  54442. get displayMode(): number;
  54443. /** Sets the displayMode */
  54444. set displayMode(value: number);
  54445. /**
  54446. * Creates a new SkeletonViewer
  54447. * @param skeleton defines the skeleton to render
  54448. * @param mesh defines the mesh attached to the skeleton
  54449. * @param scene defines the hosting scene
  54450. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54451. * @param renderingGroupId defines the rendering group id to use with the viewer
  54452. * @param options All of the extra constructor options for the SkeletonViewer
  54453. */
  54454. constructor(
  54455. /** defines the skeleton to render */
  54456. skeleton: Skeleton,
  54457. /** defines the mesh attached to the skeleton */
  54458. mesh: AbstractMesh,
  54459. /** The Scene scope*/
  54460. scene: Scene,
  54461. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54462. autoUpdateBonesMatrices?: boolean,
  54463. /** defines the rendering group id to use with the viewer */
  54464. renderingGroupId?: number,
  54465. /** is the options for the viewer */
  54466. options?: Partial<ISkeletonViewerOptions>);
  54467. /** The Dynamic bindings for the update functions */
  54468. private _bindObs;
  54469. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54470. update(): void;
  54471. /** Gets or sets a boolean indicating if the viewer is enabled */
  54472. set isEnabled(value: boolean);
  54473. get isEnabled(): boolean;
  54474. private _getBonePosition;
  54475. private _getLinesForBonesWithLength;
  54476. private _getLinesForBonesNoLength;
  54477. /** function to revert the mesh and scene back to the initial state. */
  54478. private _revert;
  54479. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54480. private _getAbsoluteBindPoseToRef;
  54481. /** function to build and bind sphere joint points and spur bone representations. */
  54482. private _buildSpheresAndSpurs;
  54483. private _buildLocalAxes;
  54484. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54485. private _displayLinesUpdate;
  54486. /** Changes the displayMode of the skeleton viewer
  54487. * @param mode The displayMode numerical value
  54488. */
  54489. changeDisplayMode(mode: number): void;
  54490. /** Sets a display option of the skeleton viewer
  54491. *
  54492. * | Option | Type | Default | Description |
  54493. * | ---------------- | ------- | ------- | ----------- |
  54494. * | 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`. |
  54495. * | 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`. |
  54496. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54497. * | 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`. |
  54498. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54499. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54500. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54501. *
  54502. * @param option String of the option name
  54503. * @param value The numerical option value
  54504. */
  54505. changeDisplayOptions(option: string, value: number): void;
  54506. /** Release associated resources */
  54507. dispose(): void;
  54508. }
  54509. }
  54510. declare module BABYLON {
  54511. /**
  54512. * Enum for Device Types
  54513. */
  54514. export enum DeviceType {
  54515. /** Generic */
  54516. Generic = 0,
  54517. /** Keyboard */
  54518. Keyboard = 1,
  54519. /** Mouse */
  54520. Mouse = 2,
  54521. /** Touch Pointers */
  54522. Touch = 3,
  54523. /** PS4 Dual Shock */
  54524. DualShock = 4,
  54525. /** Xbox */
  54526. Xbox = 5,
  54527. /** Switch Controller */
  54528. Switch = 6
  54529. }
  54530. /**
  54531. * Enum for All Pointers (Touch/Mouse)
  54532. */
  54533. export enum PointerInput {
  54534. /** Horizontal Axis */
  54535. Horizontal = 0,
  54536. /** Vertical Axis */
  54537. Vertical = 1,
  54538. /** Left Click or Touch */
  54539. LeftClick = 2,
  54540. /** Middle Click */
  54541. MiddleClick = 3,
  54542. /** Right Click */
  54543. RightClick = 4,
  54544. /** Browser Back */
  54545. BrowserBack = 5,
  54546. /** Browser Forward */
  54547. BrowserForward = 6
  54548. }
  54549. /**
  54550. * Enum for Dual Shock Gamepad
  54551. */
  54552. export enum DualShockInput {
  54553. /** Cross */
  54554. Cross = 0,
  54555. /** Circle */
  54556. Circle = 1,
  54557. /** Square */
  54558. Square = 2,
  54559. /** Triangle */
  54560. Triangle = 3,
  54561. /** L1 */
  54562. L1 = 4,
  54563. /** R1 */
  54564. R1 = 5,
  54565. /** L2 */
  54566. L2 = 6,
  54567. /** R2 */
  54568. R2 = 7,
  54569. /** Share */
  54570. Share = 8,
  54571. /** Options */
  54572. Options = 9,
  54573. /** L3 */
  54574. L3 = 10,
  54575. /** R3 */
  54576. R3 = 11,
  54577. /** DPadUp */
  54578. DPadUp = 12,
  54579. /** DPadDown */
  54580. DPadDown = 13,
  54581. /** DPadLeft */
  54582. DPadLeft = 14,
  54583. /** DRight */
  54584. DPadRight = 15,
  54585. /** Home */
  54586. Home = 16,
  54587. /** TouchPad */
  54588. TouchPad = 17,
  54589. /** LStickXAxis */
  54590. LStickXAxis = 18,
  54591. /** LStickYAxis */
  54592. LStickYAxis = 19,
  54593. /** RStickXAxis */
  54594. RStickXAxis = 20,
  54595. /** RStickYAxis */
  54596. RStickYAxis = 21
  54597. }
  54598. /**
  54599. * Enum for Xbox Gamepad
  54600. */
  54601. export enum XboxInput {
  54602. /** A */
  54603. A = 0,
  54604. /** B */
  54605. B = 1,
  54606. /** X */
  54607. X = 2,
  54608. /** Y */
  54609. Y = 3,
  54610. /** LB */
  54611. LB = 4,
  54612. /** RB */
  54613. RB = 5,
  54614. /** LT */
  54615. LT = 6,
  54616. /** RT */
  54617. RT = 7,
  54618. /** Back */
  54619. Back = 8,
  54620. /** Start */
  54621. Start = 9,
  54622. /** LS */
  54623. LS = 10,
  54624. /** RS */
  54625. RS = 11,
  54626. /** DPadUp */
  54627. DPadUp = 12,
  54628. /** DPadDown */
  54629. DPadDown = 13,
  54630. /** DPadLeft */
  54631. DPadLeft = 14,
  54632. /** DRight */
  54633. DPadRight = 15,
  54634. /** Home */
  54635. Home = 16,
  54636. /** LStickXAxis */
  54637. LStickXAxis = 17,
  54638. /** LStickYAxis */
  54639. LStickYAxis = 18,
  54640. /** RStickXAxis */
  54641. RStickXAxis = 19,
  54642. /** RStickYAxis */
  54643. RStickYAxis = 20
  54644. }
  54645. /**
  54646. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54647. */
  54648. export enum SwitchInput {
  54649. /** B */
  54650. B = 0,
  54651. /** A */
  54652. A = 1,
  54653. /** Y */
  54654. Y = 2,
  54655. /** X */
  54656. X = 3,
  54657. /** L */
  54658. L = 4,
  54659. /** R */
  54660. R = 5,
  54661. /** ZL */
  54662. ZL = 6,
  54663. /** ZR */
  54664. ZR = 7,
  54665. /** Minus */
  54666. Minus = 8,
  54667. /** Plus */
  54668. Plus = 9,
  54669. /** LS */
  54670. LS = 10,
  54671. /** RS */
  54672. RS = 11,
  54673. /** DPadUp */
  54674. DPadUp = 12,
  54675. /** DPadDown */
  54676. DPadDown = 13,
  54677. /** DPadLeft */
  54678. DPadLeft = 14,
  54679. /** DRight */
  54680. DPadRight = 15,
  54681. /** Home */
  54682. Home = 16,
  54683. /** Capture */
  54684. Capture = 17,
  54685. /** LStickXAxis */
  54686. LStickXAxis = 18,
  54687. /** LStickYAxis */
  54688. LStickYAxis = 19,
  54689. /** RStickXAxis */
  54690. RStickXAxis = 20,
  54691. /** RStickYAxis */
  54692. RStickYAxis = 21
  54693. }
  54694. }
  54695. declare module BABYLON {
  54696. /**
  54697. * This class will take all inputs from Keyboard, Pointer, and
  54698. * any Gamepads and provide a polling system that all devices
  54699. * will use. This class assumes that there will only be one
  54700. * pointer device and one keyboard.
  54701. */
  54702. export class DeviceInputSystem implements IDisposable {
  54703. /**
  54704. * Callback to be triggered when a device is connected
  54705. */
  54706. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54707. /**
  54708. * Callback to be triggered when a device is disconnected
  54709. */
  54710. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54711. /**
  54712. * Callback to be triggered when event driven input is updated
  54713. */
  54714. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  54715. private _inputs;
  54716. private _gamepads;
  54717. private _keyboardActive;
  54718. private _pointerActive;
  54719. private _elementToAttachTo;
  54720. private _keyboardDownEvent;
  54721. private _keyboardUpEvent;
  54722. private _pointerMoveEvent;
  54723. private _pointerDownEvent;
  54724. private _pointerUpEvent;
  54725. private _gamepadConnectedEvent;
  54726. private _gamepadDisconnectedEvent;
  54727. private static _MAX_KEYCODES;
  54728. private static _MAX_POINTER_INPUTS;
  54729. private constructor();
  54730. /**
  54731. * Creates a new DeviceInputSystem instance
  54732. * @param engine Engine to pull input element from
  54733. * @returns The new instance
  54734. */
  54735. static Create(engine: Engine): DeviceInputSystem;
  54736. /**
  54737. * Checks for current device input value, given an id and input index
  54738. * @param deviceName Id of connected device
  54739. * @param inputIndex Index of device input
  54740. * @returns Current value of input
  54741. */
  54742. /**
  54743. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  54744. * @param deviceType Enum specifiying device type
  54745. * @param deviceSlot "Slot" or index that device is referenced in
  54746. * @param inputIndex Id of input to be checked
  54747. * @returns Current value of input
  54748. */
  54749. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  54750. /**
  54751. * Dispose of all the eventlisteners
  54752. */
  54753. dispose(): void;
  54754. /**
  54755. * Add device and inputs to device array
  54756. * @param deviceType Enum specifiying device type
  54757. * @param deviceSlot "Slot" or index that device is referenced in
  54758. * @param numberOfInputs Number of input entries to create for given device
  54759. */
  54760. private _registerDevice;
  54761. /**
  54762. * Given a specific device name, remove that device from the device map
  54763. * @param deviceType Enum specifiying device type
  54764. * @param deviceSlot "Slot" or index that device is referenced in
  54765. */
  54766. private _unregisterDevice;
  54767. /**
  54768. * Handle all actions that come from keyboard interaction
  54769. */
  54770. private _handleKeyActions;
  54771. /**
  54772. * Handle all actions that come from pointer interaction
  54773. */
  54774. private _handlePointerActions;
  54775. /**
  54776. * Handle all actions that come from gamepad interaction
  54777. */
  54778. private _handleGamepadActions;
  54779. /**
  54780. * Update all non-event based devices with each frame
  54781. * @param deviceType Enum specifiying device type
  54782. * @param deviceSlot "Slot" or index that device is referenced in
  54783. * @param inputIndex Id of input to be checked
  54784. */
  54785. private _updateDevice;
  54786. /**
  54787. * Gets DeviceType from the device name
  54788. * @param deviceName Name of Device from DeviceInputSystem
  54789. * @returns DeviceType enum value
  54790. */
  54791. private _getGamepadDeviceType;
  54792. }
  54793. }
  54794. declare module BABYLON {
  54795. /**
  54796. * Type to handle enforcement of inputs
  54797. */
  54798. 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;
  54799. }
  54800. declare module BABYLON {
  54801. /**
  54802. * Class that handles all input for a specific device
  54803. */
  54804. export class DeviceSource<T extends DeviceType> {
  54805. /** Type of device */
  54806. readonly deviceType: DeviceType;
  54807. /** "Slot" or index that device is referenced in */
  54808. readonly deviceSlot: number;
  54809. /**
  54810. * Observable to handle device input changes per device
  54811. */
  54812. readonly onInputChangedObservable: Observable<{
  54813. inputIndex: DeviceInput<T>;
  54814. previousState: Nullable<number>;
  54815. currentState: Nullable<number>;
  54816. }>;
  54817. private readonly _deviceInputSystem;
  54818. /**
  54819. * Default Constructor
  54820. * @param deviceInputSystem Reference to DeviceInputSystem
  54821. * @param deviceType Type of device
  54822. * @param deviceSlot "Slot" or index that device is referenced in
  54823. */
  54824. constructor(deviceInputSystem: DeviceInputSystem,
  54825. /** Type of device */
  54826. deviceType: DeviceType,
  54827. /** "Slot" or index that device is referenced in */
  54828. deviceSlot?: number);
  54829. /**
  54830. * Get input for specific input
  54831. * @param inputIndex index of specific input on device
  54832. * @returns Input value from DeviceInputSystem
  54833. */
  54834. getInput(inputIndex: DeviceInput<T>): number;
  54835. }
  54836. /**
  54837. * Class to keep track of devices
  54838. */
  54839. export class DeviceSourceManager implements IDisposable {
  54840. /**
  54841. * Observable to be triggered when before a device is connected
  54842. */
  54843. readonly onBeforeDeviceConnectedObservable: Observable<{
  54844. deviceType: DeviceType;
  54845. deviceSlot: number;
  54846. }>;
  54847. /**
  54848. * Observable to be triggered when before a device is disconnected
  54849. */
  54850. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  54851. deviceType: DeviceType;
  54852. deviceSlot: number;
  54853. }>;
  54854. /**
  54855. * Observable to be triggered when after a device is connected
  54856. */
  54857. readonly onAfterDeviceConnectedObservable: Observable<{
  54858. deviceType: DeviceType;
  54859. deviceSlot: number;
  54860. }>;
  54861. /**
  54862. * Observable to be triggered when after a device is disconnected
  54863. */
  54864. readonly onAfterDeviceDisconnectedObservable: Observable<{
  54865. deviceType: DeviceType;
  54866. deviceSlot: number;
  54867. }>;
  54868. private readonly _devices;
  54869. private readonly _firstDevice;
  54870. private readonly _deviceInputSystem;
  54871. /**
  54872. * Default Constructor
  54873. * @param engine engine to pull input element from
  54874. */
  54875. constructor(engine: Engine);
  54876. /**
  54877. * Gets a DeviceSource, given a type and slot
  54878. * @param deviceType Enum specifying device type
  54879. * @param deviceSlot "Slot" or index that device is referenced in
  54880. * @returns DeviceSource object
  54881. */
  54882. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  54883. /**
  54884. * Gets an array of DeviceSource objects for a given device type
  54885. * @param deviceType Enum specifying device type
  54886. * @returns Array of DeviceSource objects
  54887. */
  54888. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  54889. /**
  54890. * Dispose of DeviceInputSystem and other parts
  54891. */
  54892. dispose(): void;
  54893. /**
  54894. * Function to add device name to device list
  54895. * @param deviceType Enum specifying device type
  54896. * @param deviceSlot "Slot" or index that device is referenced in
  54897. */
  54898. private _addDevice;
  54899. /**
  54900. * Function to remove device name to device list
  54901. * @param deviceType Enum specifying device type
  54902. * @param deviceSlot "Slot" or index that device is referenced in
  54903. */
  54904. private _removeDevice;
  54905. /**
  54906. * Updates array storing first connected device of each type
  54907. * @param type Type of Device
  54908. */
  54909. private _updateFirstDevices;
  54910. }
  54911. }
  54912. declare module BABYLON {
  54913. /**
  54914. * Options to create the null engine
  54915. */
  54916. export class NullEngineOptions {
  54917. /**
  54918. * Render width (Default: 512)
  54919. */
  54920. renderWidth: number;
  54921. /**
  54922. * Render height (Default: 256)
  54923. */
  54924. renderHeight: number;
  54925. /**
  54926. * Texture size (Default: 512)
  54927. */
  54928. textureSize: number;
  54929. /**
  54930. * If delta time between frames should be constant
  54931. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54932. */
  54933. deterministicLockstep: boolean;
  54934. /**
  54935. * Maximum about of steps between frames (Default: 4)
  54936. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54937. */
  54938. lockstepMaxSteps: number;
  54939. /**
  54940. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54941. */
  54942. useHighPrecisionMatrix?: boolean;
  54943. }
  54944. /**
  54945. * The null engine class provides support for headless version of babylon.js.
  54946. * This can be used in server side scenario or for testing purposes
  54947. */
  54948. export class NullEngine extends Engine {
  54949. private _options;
  54950. /**
  54951. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54952. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54953. * @returns true if engine is in deterministic lock step mode
  54954. */
  54955. isDeterministicLockStep(): boolean;
  54956. /**
  54957. * Gets the max steps when engine is running in deterministic lock step
  54958. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54959. * @returns the max steps
  54960. */
  54961. getLockstepMaxSteps(): number;
  54962. /**
  54963. * Gets the current hardware scaling level.
  54964. * By default the hardware scaling level is computed from the window device ratio.
  54965. * 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.
  54966. * @returns a number indicating the current hardware scaling level
  54967. */
  54968. getHardwareScalingLevel(): number;
  54969. constructor(options?: NullEngineOptions);
  54970. /**
  54971. * Creates a vertex buffer
  54972. * @param vertices the data for the vertex buffer
  54973. * @returns the new WebGL static buffer
  54974. */
  54975. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54976. /**
  54977. * Creates a new index buffer
  54978. * @param indices defines the content of the index buffer
  54979. * @param updatable defines if the index buffer must be updatable
  54980. * @returns a new webGL buffer
  54981. */
  54982. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54983. /**
  54984. * Clear the current render buffer or the current render target (if any is set up)
  54985. * @param color defines the color to use
  54986. * @param backBuffer defines if the back buffer must be cleared
  54987. * @param depth defines if the depth buffer must be cleared
  54988. * @param stencil defines if the stencil buffer must be cleared
  54989. */
  54990. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54991. /**
  54992. * Gets the current render width
  54993. * @param useScreen defines if screen size must be used (or the current render target if any)
  54994. * @returns a number defining the current render width
  54995. */
  54996. getRenderWidth(useScreen?: boolean): number;
  54997. /**
  54998. * Gets the current render height
  54999. * @param useScreen defines if screen size must be used (or the current render target if any)
  55000. * @returns a number defining the current render height
  55001. */
  55002. getRenderHeight(useScreen?: boolean): number;
  55003. /**
  55004. * Set the WebGL's viewport
  55005. * @param viewport defines the viewport element to be used
  55006. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  55007. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  55008. */
  55009. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  55010. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  55011. /**
  55012. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  55013. * @param pipelineContext defines the pipeline context to use
  55014. * @param uniformsNames defines the list of uniform names
  55015. * @returns an array of webGL uniform locations
  55016. */
  55017. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  55018. /**
  55019. * Gets the lsit of active attributes for a given webGL program
  55020. * @param pipelineContext defines the pipeline context to use
  55021. * @param attributesNames defines the list of attribute names to get
  55022. * @returns an array of indices indicating the offset of each attribute
  55023. */
  55024. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55025. /**
  55026. * Binds an effect to the webGL context
  55027. * @param effect defines the effect to bind
  55028. */
  55029. bindSamplers(effect: Effect): void;
  55030. /**
  55031. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  55032. * @param effect defines the effect to activate
  55033. */
  55034. enableEffect(effect: Effect): void;
  55035. /**
  55036. * Set various states to the webGL context
  55037. * @param culling defines backface culling state
  55038. * @param zOffset defines the value to apply to zOffset (0 by default)
  55039. * @param force defines if states must be applied even if cache is up to date
  55040. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  55041. */
  55042. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55043. /**
  55044. * Set the value of an uniform to an array of int32
  55045. * @param uniform defines the webGL uniform location where to store the value
  55046. * @param array defines the array of int32 to store
  55047. * @returns true if value was set
  55048. */
  55049. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55050. /**
  55051. * Set the value of an uniform to an array of int32 (stored as vec2)
  55052. * @param uniform defines the webGL uniform location where to store the value
  55053. * @param array defines the array of int32 to store
  55054. * @returns true if value was set
  55055. */
  55056. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55057. /**
  55058. * Set the value of an uniform to an array of int32 (stored as vec3)
  55059. * @param uniform defines the webGL uniform location where to store the value
  55060. * @param array defines the array of int32 to store
  55061. * @returns true if value was set
  55062. */
  55063. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55064. /**
  55065. * Set the value of an uniform to an array of int32 (stored as vec4)
  55066. * @param uniform defines the webGL uniform location where to store the value
  55067. * @param array defines the array of int32 to store
  55068. * @returns true if value was set
  55069. */
  55070. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55071. /**
  55072. * Set the value of an uniform to an array of float32
  55073. * @param uniform defines the webGL uniform location where to store the value
  55074. * @param array defines the array of float32 to store
  55075. * @returns true if value was set
  55076. */
  55077. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55078. /**
  55079. * Set the value of an uniform to an array of float32 (stored as vec2)
  55080. * @param uniform defines the webGL uniform location where to store the value
  55081. * @param array defines the array of float32 to store
  55082. * @returns true if value was set
  55083. */
  55084. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55085. /**
  55086. * Set the value of an uniform to an array of float32 (stored as vec3)
  55087. * @param uniform defines the webGL uniform location where to store the value
  55088. * @param array defines the array of float32 to store
  55089. * @returns true if value was set
  55090. */
  55091. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55092. /**
  55093. * Set the value of an uniform to an array of float32 (stored as vec4)
  55094. * @param uniform defines the webGL uniform location where to store the value
  55095. * @param array defines the array of float32 to store
  55096. * @returns true if value was set
  55097. */
  55098. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55099. /**
  55100. * Set the value of an uniform to an array of number
  55101. * @param uniform defines the webGL uniform location where to store the value
  55102. * @param array defines the array of number to store
  55103. * @returns true if value was set
  55104. */
  55105. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55106. /**
  55107. * Set the value of an uniform to an array of number (stored as vec2)
  55108. * @param uniform defines the webGL uniform location where to store the value
  55109. * @param array defines the array of number to store
  55110. * @returns true if value was set
  55111. */
  55112. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55113. /**
  55114. * Set the value of an uniform to an array of number (stored as vec3)
  55115. * @param uniform defines the webGL uniform location where to store the value
  55116. * @param array defines the array of number to store
  55117. * @returns true if value was set
  55118. */
  55119. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55120. /**
  55121. * Set the value of an uniform to an array of number (stored as vec4)
  55122. * @param uniform defines the webGL uniform location where to store the value
  55123. * @param array defines the array of number to store
  55124. * @returns true if value was set
  55125. */
  55126. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55127. /**
  55128. * Set the value of an uniform to an array of float32 (stored as matrices)
  55129. * @param uniform defines the webGL uniform location where to store the value
  55130. * @param matrices defines the array of float32 to store
  55131. * @returns true if value was set
  55132. */
  55133. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55134. /**
  55135. * Set the value of an uniform to a matrix (3x3)
  55136. * @param uniform defines the webGL uniform location where to store the value
  55137. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  55138. * @returns true if value was set
  55139. */
  55140. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55141. /**
  55142. * Set the value of an uniform to a matrix (2x2)
  55143. * @param uniform defines the webGL uniform location where to store the value
  55144. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  55145. * @returns true if value was set
  55146. */
  55147. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55148. /**
  55149. * Set the value of an uniform to a number (float)
  55150. * @param uniform defines the webGL uniform location where to store the value
  55151. * @param value defines the float number to store
  55152. * @returns true if value was set
  55153. */
  55154. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55155. /**
  55156. * Set the value of an uniform to a vec2
  55157. * @param uniform defines the webGL uniform location where to store the value
  55158. * @param x defines the 1st component of the value
  55159. * @param y defines the 2nd component of the value
  55160. * @returns true if value was set
  55161. */
  55162. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55163. /**
  55164. * Set the value of an uniform to a vec3
  55165. * @param uniform defines the webGL uniform location where to store the value
  55166. * @param x defines the 1st component of the value
  55167. * @param y defines the 2nd component of the value
  55168. * @param z defines the 3rd component of the value
  55169. * @returns true if value was set
  55170. */
  55171. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55172. /**
  55173. * Set the value of an uniform to a boolean
  55174. * @param uniform defines the webGL uniform location where to store the value
  55175. * @param bool defines the boolean to store
  55176. * @returns true if value was set
  55177. */
  55178. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55179. /**
  55180. * Set the value of an uniform to a vec4
  55181. * @param uniform defines the webGL uniform location where to store the value
  55182. * @param x defines the 1st component of the value
  55183. * @param y defines the 2nd component of the value
  55184. * @param z defines the 3rd component of the value
  55185. * @param w defines the 4th component of the value
  55186. * @returns true if value was set
  55187. */
  55188. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55189. /**
  55190. * Sets the current alpha mode
  55191. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55192. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55193. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55194. */
  55195. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55196. /**
  55197. * Bind webGl buffers directly to the webGL context
  55198. * @param vertexBuffers defines the vertex buffer to bind
  55199. * @param indexBuffer defines the index buffer to bind
  55200. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55201. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55202. * @param effect defines the effect associated with the vertex buffer
  55203. */
  55204. bindBuffers(vertexBuffers: {
  55205. [key: string]: VertexBuffer;
  55206. }, indexBuffer: DataBuffer, effect: Effect): void;
  55207. /**
  55208. * Force the entire cache to be cleared
  55209. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55210. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55211. */
  55212. wipeCaches(bruteForce?: boolean): void;
  55213. /**
  55214. * Send a draw order
  55215. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55216. * @param indexStart defines the starting index
  55217. * @param indexCount defines the number of index to draw
  55218. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55219. */
  55220. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55221. /**
  55222. * Draw a list of indexed primitives
  55223. * @param fillMode defines the primitive to use
  55224. * @param indexStart defines the starting index
  55225. * @param indexCount defines the number of index to draw
  55226. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55227. */
  55228. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55229. /**
  55230. * Draw a list of unindexed primitives
  55231. * @param fillMode defines the primitive to use
  55232. * @param verticesStart defines the index of first vertex to draw
  55233. * @param verticesCount defines the count of vertices to draw
  55234. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55235. */
  55236. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55237. /** @hidden */
  55238. _createTexture(): WebGLTexture;
  55239. /** @hidden */
  55240. _releaseTexture(texture: InternalTexture): void;
  55241. /**
  55242. * Usually called from Texture.ts.
  55243. * Passed information to create a WebGLTexture
  55244. * @param urlArg defines a value which contains one of the following:
  55245. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55246. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55247. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55248. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55249. * @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)
  55250. * @param scene needed for loading to the correct scene
  55251. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55252. * @param onLoad optional callback to be called upon successful completion
  55253. * @param onError optional callback to be called upon failure
  55254. * @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
  55255. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55256. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55257. * @param forcedExtension defines the extension to use to pick the right loader
  55258. * @param mimeType defines an optional mime type
  55259. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55260. */
  55261. 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;
  55262. /**
  55263. * Creates a new render target texture
  55264. * @param size defines the size of the texture
  55265. * @param options defines the options used to create the texture
  55266. * @returns a new render target texture stored in an InternalTexture
  55267. */
  55268. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55269. /**
  55270. * Update the sampling mode of a given texture
  55271. * @param samplingMode defines the required sampling mode
  55272. * @param texture defines the texture to update
  55273. */
  55274. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55275. /**
  55276. * Binds the frame buffer to the specified texture.
  55277. * @param texture The texture to render to or null for the default canvas
  55278. * @param faceIndex The face of the texture to render to in case of cube texture
  55279. * @param requiredWidth The width of the target to render to
  55280. * @param requiredHeight The height of the target to render to
  55281. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55282. * @param lodLevel defines le lod level to bind to the frame buffer
  55283. */
  55284. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55285. /**
  55286. * Unbind the current render target texture from the webGL context
  55287. * @param texture defines the render target texture to unbind
  55288. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55289. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55290. */
  55291. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55292. /**
  55293. * Creates a dynamic vertex buffer
  55294. * @param vertices the data for the dynamic vertex buffer
  55295. * @returns the new WebGL dynamic buffer
  55296. */
  55297. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55298. /**
  55299. * Update the content of a dynamic texture
  55300. * @param texture defines the texture to update
  55301. * @param canvas defines the canvas containing the source
  55302. * @param invertY defines if data must be stored with Y axis inverted
  55303. * @param premulAlpha defines if alpha is stored as premultiplied
  55304. * @param format defines the format of the data
  55305. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55306. */
  55307. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55308. /**
  55309. * Gets a boolean indicating if all created effects are ready
  55310. * @returns true if all effects are ready
  55311. */
  55312. areAllEffectsReady(): boolean;
  55313. /**
  55314. * @hidden
  55315. * Get the current error code of the webGL context
  55316. * @returns the error code
  55317. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55318. */
  55319. getError(): number;
  55320. /** @hidden */
  55321. _getUnpackAlignement(): number;
  55322. /** @hidden */
  55323. _unpackFlipY(value: boolean): void;
  55324. /**
  55325. * Update a dynamic index buffer
  55326. * @param indexBuffer defines the target index buffer
  55327. * @param indices defines the data to update
  55328. * @param offset defines the offset in the target index buffer where update should start
  55329. */
  55330. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55331. /**
  55332. * Updates a dynamic vertex buffer.
  55333. * @param vertexBuffer the vertex buffer to update
  55334. * @param vertices the data used to update the vertex buffer
  55335. * @param byteOffset the byte offset of the data (optional)
  55336. * @param byteLength the byte length of the data (optional)
  55337. */
  55338. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55339. /** @hidden */
  55340. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55341. /** @hidden */
  55342. _bindTexture(channel: number, texture: InternalTexture): void;
  55343. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55344. /**
  55345. * 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
  55346. */
  55347. releaseEffects(): void;
  55348. displayLoadingUI(): void;
  55349. hideLoadingUI(): void;
  55350. /** @hidden */
  55351. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55352. /** @hidden */
  55353. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55354. /** @hidden */
  55355. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55356. /** @hidden */
  55357. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55358. }
  55359. }
  55360. declare module BABYLON {
  55361. /**
  55362. * @hidden
  55363. **/
  55364. export class _TimeToken {
  55365. _startTimeQuery: Nullable<WebGLQuery>;
  55366. _endTimeQuery: Nullable<WebGLQuery>;
  55367. _timeElapsedQuery: Nullable<WebGLQuery>;
  55368. _timeElapsedQueryEnded: boolean;
  55369. }
  55370. }
  55371. declare module BABYLON {
  55372. /** @hidden */
  55373. export class _OcclusionDataStorage {
  55374. /** @hidden */
  55375. occlusionInternalRetryCounter: number;
  55376. /** @hidden */
  55377. isOcclusionQueryInProgress: boolean;
  55378. /** @hidden */
  55379. isOccluded: boolean;
  55380. /** @hidden */
  55381. occlusionRetryCount: number;
  55382. /** @hidden */
  55383. occlusionType: number;
  55384. /** @hidden */
  55385. occlusionQueryAlgorithmType: number;
  55386. }
  55387. interface Engine {
  55388. /**
  55389. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55390. * @return the new query
  55391. */
  55392. createQuery(): WebGLQuery;
  55393. /**
  55394. * Delete and release a webGL query
  55395. * @param query defines the query to delete
  55396. * @return the current engine
  55397. */
  55398. deleteQuery(query: WebGLQuery): Engine;
  55399. /**
  55400. * Check if a given query has resolved and got its value
  55401. * @param query defines the query to check
  55402. * @returns true if the query got its value
  55403. */
  55404. isQueryResultAvailable(query: WebGLQuery): boolean;
  55405. /**
  55406. * Gets the value of a given query
  55407. * @param query defines the query to check
  55408. * @returns the value of the query
  55409. */
  55410. getQueryResult(query: WebGLQuery): number;
  55411. /**
  55412. * Initiates an occlusion query
  55413. * @param algorithmType defines the algorithm to use
  55414. * @param query defines the query to use
  55415. * @returns the current engine
  55416. * @see https://doc.babylonjs.com/features/occlusionquery
  55417. */
  55418. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55419. /**
  55420. * Ends an occlusion query
  55421. * @see https://doc.babylonjs.com/features/occlusionquery
  55422. * @param algorithmType defines the algorithm to use
  55423. * @returns the current engine
  55424. */
  55425. endOcclusionQuery(algorithmType: number): Engine;
  55426. /**
  55427. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55428. * Please note that only one query can be issued at a time
  55429. * @returns a time token used to track the time span
  55430. */
  55431. startTimeQuery(): Nullable<_TimeToken>;
  55432. /**
  55433. * Ends a time query
  55434. * @param token defines the token used to measure the time span
  55435. * @returns the time spent (in ns)
  55436. */
  55437. endTimeQuery(token: _TimeToken): int;
  55438. /** @hidden */
  55439. _currentNonTimestampToken: Nullable<_TimeToken>;
  55440. /** @hidden */
  55441. _createTimeQuery(): WebGLQuery;
  55442. /** @hidden */
  55443. _deleteTimeQuery(query: WebGLQuery): void;
  55444. /** @hidden */
  55445. _getGlAlgorithmType(algorithmType: number): number;
  55446. /** @hidden */
  55447. _getTimeQueryResult(query: WebGLQuery): any;
  55448. /** @hidden */
  55449. _getTimeQueryAvailability(query: WebGLQuery): any;
  55450. }
  55451. interface AbstractMesh {
  55452. /**
  55453. * Backing filed
  55454. * @hidden
  55455. */
  55456. __occlusionDataStorage: _OcclusionDataStorage;
  55457. /**
  55458. * Access property
  55459. * @hidden
  55460. */
  55461. _occlusionDataStorage: _OcclusionDataStorage;
  55462. /**
  55463. * 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.
  55464. * The default value is -1 which means don't break the query and wait till the result
  55465. * @see https://doc.babylonjs.com/features/occlusionquery
  55466. */
  55467. occlusionRetryCount: number;
  55468. /**
  55469. * 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:
  55470. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55471. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55472. * * 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.
  55473. * @see https://doc.babylonjs.com/features/occlusionquery
  55474. */
  55475. occlusionType: number;
  55476. /**
  55477. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55478. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55479. * * 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.
  55480. * @see https://doc.babylonjs.com/features/occlusionquery
  55481. */
  55482. occlusionQueryAlgorithmType: number;
  55483. /**
  55484. * 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
  55485. * @see https://doc.babylonjs.com/features/occlusionquery
  55486. */
  55487. isOccluded: boolean;
  55488. /**
  55489. * Flag to check the progress status of the query
  55490. * @see https://doc.babylonjs.com/features/occlusionquery
  55491. */
  55492. isOcclusionQueryInProgress: boolean;
  55493. }
  55494. }
  55495. declare module BABYLON {
  55496. /** @hidden */
  55497. export var _forceTransformFeedbackToBundle: boolean;
  55498. interface Engine {
  55499. /**
  55500. * Creates a webGL transform feedback object
  55501. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55502. * @returns the webGL transform feedback object
  55503. */
  55504. createTransformFeedback(): WebGLTransformFeedback;
  55505. /**
  55506. * Delete a webGL transform feedback object
  55507. * @param value defines the webGL transform feedback object to delete
  55508. */
  55509. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55510. /**
  55511. * Bind a webGL transform feedback object to the webgl context
  55512. * @param value defines the webGL transform feedback object to bind
  55513. */
  55514. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55515. /**
  55516. * Begins a transform feedback operation
  55517. * @param usePoints defines if points or triangles must be used
  55518. */
  55519. beginTransformFeedback(usePoints: boolean): void;
  55520. /**
  55521. * Ends a transform feedback operation
  55522. */
  55523. endTransformFeedback(): void;
  55524. /**
  55525. * Specify the varyings to use with transform feedback
  55526. * @param program defines the associated webGL program
  55527. * @param value defines the list of strings representing the varying names
  55528. */
  55529. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55530. /**
  55531. * Bind a webGL buffer for a transform feedback operation
  55532. * @param value defines the webGL buffer to bind
  55533. */
  55534. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55535. }
  55536. }
  55537. declare module BABYLON {
  55538. /**
  55539. * Class used to define an additional view for the engine
  55540. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55541. */
  55542. export class EngineView {
  55543. /** Defines the canvas where to render the view */
  55544. target: HTMLCanvasElement;
  55545. /** Defines an optional camera used to render the view (will use active camera else) */
  55546. camera?: Camera;
  55547. }
  55548. interface Engine {
  55549. /**
  55550. * Gets or sets the HTML element to use for attaching events
  55551. */
  55552. inputElement: Nullable<HTMLElement>;
  55553. /**
  55554. * Gets the current engine view
  55555. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55556. */
  55557. activeView: Nullable<EngineView>;
  55558. /** Gets or sets the list of views */
  55559. views: EngineView[];
  55560. /**
  55561. * Register a new child canvas
  55562. * @param canvas defines the canvas to register
  55563. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55564. * @returns the associated view
  55565. */
  55566. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55567. /**
  55568. * Remove a registered child canvas
  55569. * @param canvas defines the canvas to remove
  55570. * @returns the current engine
  55571. */
  55572. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55573. }
  55574. }
  55575. declare module BABYLON {
  55576. interface Engine {
  55577. /** @hidden */
  55578. _excludedCompressedTextures: string[];
  55579. /** @hidden */
  55580. _textureFormatInUse: string;
  55581. /**
  55582. * Gets the list of texture formats supported
  55583. */
  55584. readonly texturesSupported: Array<string>;
  55585. /**
  55586. * Gets the texture format in use
  55587. */
  55588. readonly textureFormatInUse: Nullable<string>;
  55589. /**
  55590. * Set the compressed texture extensions or file names to skip.
  55591. *
  55592. * @param skippedFiles defines the list of those texture files you want to skip
  55593. * Example: [".dds", ".env", "myfile.png"]
  55594. */
  55595. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55596. /**
  55597. * Set the compressed texture format to use, based on the formats you have, and the formats
  55598. * supported by the hardware / browser.
  55599. *
  55600. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55601. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55602. * to API arguments needed to compressed textures. This puts the burden on the container
  55603. * generator to house the arcane code for determining these for current & future formats.
  55604. *
  55605. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55606. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55607. *
  55608. * Note: The result of this call is not taken into account when a texture is base64.
  55609. *
  55610. * @param formatsAvailable defines the list of those format families you have created
  55611. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55612. *
  55613. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55614. * @returns The extension selected.
  55615. */
  55616. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55617. }
  55618. }
  55619. declare module BABYLON {
  55620. /** @hidden */
  55621. export var rgbdEncodePixelShader: {
  55622. name: string;
  55623. shader: string;
  55624. };
  55625. }
  55626. declare module BABYLON {
  55627. /**
  55628. * Raw texture data and descriptor sufficient for WebGL texture upload
  55629. */
  55630. export interface EnvironmentTextureInfo {
  55631. /**
  55632. * Version of the environment map
  55633. */
  55634. version: number;
  55635. /**
  55636. * Width of image
  55637. */
  55638. width: number;
  55639. /**
  55640. * Irradiance information stored in the file.
  55641. */
  55642. irradiance: any;
  55643. /**
  55644. * Specular information stored in the file.
  55645. */
  55646. specular: any;
  55647. }
  55648. /**
  55649. * Defines One Image in the file. It requires only the position in the file
  55650. * as well as the length.
  55651. */
  55652. interface BufferImageData {
  55653. /**
  55654. * Length of the image data.
  55655. */
  55656. length: number;
  55657. /**
  55658. * Position of the data from the null terminator delimiting the end of the JSON.
  55659. */
  55660. position: number;
  55661. }
  55662. /**
  55663. * Defines the specular data enclosed in the file.
  55664. * This corresponds to the version 1 of the data.
  55665. */
  55666. export interface EnvironmentTextureSpecularInfoV1 {
  55667. /**
  55668. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55669. */
  55670. specularDataPosition?: number;
  55671. /**
  55672. * This contains all the images data needed to reconstruct the cubemap.
  55673. */
  55674. mipmaps: Array<BufferImageData>;
  55675. /**
  55676. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55677. */
  55678. lodGenerationScale: number;
  55679. }
  55680. /**
  55681. * Sets of helpers addressing the serialization and deserialization of environment texture
  55682. * stored in a BabylonJS env file.
  55683. * Those files are usually stored as .env files.
  55684. */
  55685. export class EnvironmentTextureTools {
  55686. /**
  55687. * Magic number identifying the env file.
  55688. */
  55689. private static _MagicBytes;
  55690. /**
  55691. * Gets the environment info from an env file.
  55692. * @param data The array buffer containing the .env bytes.
  55693. * @returns the environment file info (the json header) if successfully parsed.
  55694. */
  55695. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55696. /**
  55697. * Creates an environment texture from a loaded cube texture.
  55698. * @param texture defines the cube texture to convert in env file
  55699. * @return a promise containing the environment data if succesfull.
  55700. */
  55701. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55702. /**
  55703. * Creates a JSON representation of the spherical data.
  55704. * @param texture defines the texture containing the polynomials
  55705. * @return the JSON representation of the spherical info
  55706. */
  55707. private static _CreateEnvTextureIrradiance;
  55708. /**
  55709. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55710. * @param data the image data
  55711. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55712. * @return the views described by info providing access to the underlying buffer
  55713. */
  55714. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55715. /**
  55716. * Uploads the texture info contained in the env file to the GPU.
  55717. * @param texture defines the internal texture to upload to
  55718. * @param data defines the data to load
  55719. * @param info defines the texture info retrieved through the GetEnvInfo method
  55720. * @returns a promise
  55721. */
  55722. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55723. private static _OnImageReadyAsync;
  55724. /**
  55725. * Uploads the levels of image data to the GPU.
  55726. * @param texture defines the internal texture to upload to
  55727. * @param imageData defines the array buffer views of image data [mipmap][face]
  55728. * @returns a promise
  55729. */
  55730. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  55731. /**
  55732. * Uploads spherical polynomials information to the texture.
  55733. * @param texture defines the texture we are trying to upload the information to
  55734. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  55735. */
  55736. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55737. /** @hidden */
  55738. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55739. }
  55740. }
  55741. declare module BABYLON {
  55742. /**
  55743. * Class used to inline functions in shader code
  55744. */
  55745. export class ShaderCodeInliner {
  55746. private static readonly _RegexpFindFunctionNameAndType;
  55747. private _sourceCode;
  55748. private _functionDescr;
  55749. private _numMaxIterations;
  55750. /** Gets or sets the token used to mark the functions to inline */
  55751. inlineToken: string;
  55752. /** Gets or sets the debug mode */
  55753. debug: boolean;
  55754. /** Gets the code after the inlining process */
  55755. get code(): string;
  55756. /**
  55757. * Initializes the inliner
  55758. * @param sourceCode shader code source to inline
  55759. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55760. */
  55761. constructor(sourceCode: string, numMaxIterations?: number);
  55762. /**
  55763. * Start the processing of the shader code
  55764. */
  55765. processCode(): void;
  55766. private _collectFunctions;
  55767. private _processInlining;
  55768. private _extractBetweenMarkers;
  55769. private _skipWhitespaces;
  55770. private _removeComments;
  55771. private _replaceFunctionCallsByCode;
  55772. private _findBackward;
  55773. private _escapeRegExp;
  55774. private _replaceNames;
  55775. }
  55776. }
  55777. declare module BABYLON {
  55778. /**
  55779. * Container for accessors for natively-stored mesh data buffers.
  55780. */
  55781. class NativeDataBuffer extends DataBuffer {
  55782. /**
  55783. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55784. */
  55785. nativeIndexBuffer?: any;
  55786. /**
  55787. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55788. */
  55789. nativeVertexBuffer?: any;
  55790. }
  55791. /** @hidden */
  55792. class NativeTexture extends InternalTexture {
  55793. getInternalTexture(): InternalTexture;
  55794. getViewCount(): number;
  55795. }
  55796. /** @hidden */
  55797. export class NativeEngine extends Engine {
  55798. private readonly _native;
  55799. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55800. private readonly INVALID_HANDLE;
  55801. private _boundBuffersVertexArray;
  55802. private _currentDepthTest;
  55803. getHardwareScalingLevel(): number;
  55804. constructor();
  55805. dispose(): void;
  55806. /**
  55807. * Can be used to override the current requestAnimationFrame requester.
  55808. * @hidden
  55809. */
  55810. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55811. /**
  55812. * Override default engine behavior.
  55813. * @param color
  55814. * @param backBuffer
  55815. * @param depth
  55816. * @param stencil
  55817. */
  55818. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55819. /**
  55820. * Gets host document
  55821. * @returns the host document object
  55822. */
  55823. getHostDocument(): Nullable<Document>;
  55824. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55825. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55826. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55827. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55828. [key: string]: VertexBuffer;
  55829. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55830. bindBuffers(vertexBuffers: {
  55831. [key: string]: VertexBuffer;
  55832. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55833. recordVertexArrayObject(vertexBuffers: {
  55834. [key: string]: VertexBuffer;
  55835. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55836. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55837. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55838. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55839. /**
  55840. * Draw a list of indexed primitives
  55841. * @param fillMode defines the primitive to use
  55842. * @param indexStart defines the starting index
  55843. * @param indexCount defines the number of index to draw
  55844. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55845. */
  55846. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55847. /**
  55848. * Draw a list of unindexed primitives
  55849. * @param fillMode defines the primitive to use
  55850. * @param verticesStart defines the index of first vertex to draw
  55851. * @param verticesCount defines the count of vertices to draw
  55852. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55853. */
  55854. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55855. createPipelineContext(): IPipelineContext;
  55856. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55857. /** @hidden */
  55858. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55859. /** @hidden */
  55860. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55861. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55862. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55863. protected _setProgram(program: WebGLProgram): void;
  55864. _releaseEffect(effect: Effect): void;
  55865. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55866. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55867. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55868. bindSamplers(effect: Effect): void;
  55869. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55870. getRenderWidth(useScreen?: boolean): number;
  55871. getRenderHeight(useScreen?: boolean): number;
  55872. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55873. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55874. /**
  55875. * Set the z offset to apply to current rendering
  55876. * @param value defines the offset to apply
  55877. */
  55878. setZOffset(value: number): void;
  55879. /**
  55880. * Gets the current value of the zOffset
  55881. * @returns the current zOffset state
  55882. */
  55883. getZOffset(): number;
  55884. /**
  55885. * Enable or disable depth buffering
  55886. * @param enable defines the state to set
  55887. */
  55888. setDepthBuffer(enable: boolean): void;
  55889. /**
  55890. * Gets a boolean indicating if depth writing is enabled
  55891. * @returns the current depth writing state
  55892. */
  55893. getDepthWrite(): boolean;
  55894. setDepthFunctionToGreater(): void;
  55895. setDepthFunctionToGreaterOrEqual(): void;
  55896. setDepthFunctionToLess(): void;
  55897. setDepthFunctionToLessOrEqual(): void;
  55898. /**
  55899. * Enable or disable depth writing
  55900. * @param enable defines the state to set
  55901. */
  55902. setDepthWrite(enable: boolean): void;
  55903. /**
  55904. * Enable or disable color writing
  55905. * @param enable defines the state to set
  55906. */
  55907. setColorWrite(enable: boolean): void;
  55908. /**
  55909. * Gets a boolean indicating if color writing is enabled
  55910. * @returns the current color writing state
  55911. */
  55912. getColorWrite(): boolean;
  55913. /**
  55914. * Sets alpha constants used by some alpha blending modes
  55915. * @param r defines the red component
  55916. * @param g defines the green component
  55917. * @param b defines the blue component
  55918. * @param a defines the alpha component
  55919. */
  55920. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55921. /**
  55922. * Sets the current alpha mode
  55923. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55924. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55925. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55926. */
  55927. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55928. /**
  55929. * Gets the current alpha mode
  55930. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55931. * @returns the current alpha mode
  55932. */
  55933. getAlphaMode(): number;
  55934. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55935. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55936. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55937. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55938. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55939. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55940. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55941. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55942. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55943. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55944. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55945. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55946. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55947. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55948. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55949. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55950. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55951. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55952. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55953. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55954. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55955. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55956. wipeCaches(bruteForce?: boolean): void;
  55957. _createTexture(): WebGLTexture;
  55958. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55959. /**
  55960. * Update the content of a dynamic texture
  55961. * @param texture defines the texture to update
  55962. * @param canvas defines the canvas containing the source
  55963. * @param invertY defines if data must be stored with Y axis inverted
  55964. * @param premulAlpha defines if alpha is stored as premultiplied
  55965. * @param format defines the format of the data
  55966. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55967. */
  55968. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55969. /**
  55970. * Usually called from Texture.ts.
  55971. * Passed information to create a WebGLTexture
  55972. * @param url defines a value which contains one of the following:
  55973. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55974. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55975. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55976. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55977. * @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)
  55978. * @param scene needed for loading to the correct scene
  55979. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55980. * @param onLoad optional callback to be called upon successful completion
  55981. * @param onError optional callback to be called upon failure
  55982. * @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
  55983. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55984. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55985. * @param forcedExtension defines the extension to use to pick the right loader
  55986. * @param mimeType defines an optional mime type
  55987. * @param loaderOptions options to be passed to the loader
  55988. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55989. */
  55990. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  55991. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  55992. _releaseFramebufferObjects(texture: InternalTexture): void;
  55993. /**
  55994. * Creates a cube texture
  55995. * @param rootUrl defines the url where the files to load is located
  55996. * @param scene defines the current scene
  55997. * @param files defines the list of files to load (1 per face)
  55998. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55999. * @param onLoad defines an optional callback raised when the texture is loaded
  56000. * @param onError defines an optional callback raised if there is an issue to load the texture
  56001. * @param format defines the format of the data
  56002. * @param forcedExtension defines the extension to use to pick the right loader
  56003. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  56004. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56005. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56006. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  56007. * @returns the cube texture as an InternalTexture
  56008. */
  56009. 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;
  56010. createRenderTargetTexture(size: number | {
  56011. width: number;
  56012. height: number;
  56013. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  56014. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56015. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56016. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56017. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  56018. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  56019. /**
  56020. * Updates a dynamic vertex buffer.
  56021. * @param vertexBuffer the vertex buffer to update
  56022. * @param data the data used to update the vertex buffer
  56023. * @param byteOffset the byte offset of the data (optional)
  56024. * @param byteLength the byte length of the data (optional)
  56025. */
  56026. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  56027. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  56028. private _updateAnisotropicLevel;
  56029. private _getAddressMode;
  56030. /** @hidden */
  56031. _bindTexture(channel: number, texture: InternalTexture): void;
  56032. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  56033. releaseEffects(): void;
  56034. /** @hidden */
  56035. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56036. /** @hidden */
  56037. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56038. /** @hidden */
  56039. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56040. /** @hidden */
  56041. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56042. private _getNativeSamplingMode;
  56043. private _getNativeTextureFormat;
  56044. private _getNativeAlphaMode;
  56045. private _getNativeAttribType;
  56046. }
  56047. }
  56048. declare module BABYLON {
  56049. /**
  56050. * Gather the list of clipboard event types as constants.
  56051. */
  56052. export class ClipboardEventTypes {
  56053. /**
  56054. * The clipboard event is fired when a copy command is active (pressed).
  56055. */
  56056. static readonly COPY: number;
  56057. /**
  56058. * The clipboard event is fired when a cut command is active (pressed).
  56059. */
  56060. static readonly CUT: number;
  56061. /**
  56062. * The clipboard event is fired when a paste command is active (pressed).
  56063. */
  56064. static readonly PASTE: number;
  56065. }
  56066. /**
  56067. * This class is used to store clipboard related info for the onClipboardObservable event.
  56068. */
  56069. export class ClipboardInfo {
  56070. /**
  56071. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56072. */
  56073. type: number;
  56074. /**
  56075. * Defines the related dom event
  56076. */
  56077. event: ClipboardEvent;
  56078. /**
  56079. *Creates an instance of ClipboardInfo.
  56080. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  56081. * @param event Defines the related dom event
  56082. */
  56083. constructor(
  56084. /**
  56085. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56086. */
  56087. type: number,
  56088. /**
  56089. * Defines the related dom event
  56090. */
  56091. event: ClipboardEvent);
  56092. /**
  56093. * Get the clipboard event's type from the keycode.
  56094. * @param keyCode Defines the keyCode for the current keyboard event.
  56095. * @return {number}
  56096. */
  56097. static GetTypeFromCharacter(keyCode: number): number;
  56098. }
  56099. }
  56100. declare module BABYLON {
  56101. /**
  56102. * Google Daydream controller
  56103. */
  56104. export class DaydreamController extends WebVRController {
  56105. /**
  56106. * Base Url for the controller model.
  56107. */
  56108. static MODEL_BASE_URL: string;
  56109. /**
  56110. * File name for the controller model.
  56111. */
  56112. static MODEL_FILENAME: string;
  56113. /**
  56114. * Gamepad Id prefix used to identify Daydream Controller.
  56115. */
  56116. static readonly GAMEPAD_ID_PREFIX: string;
  56117. /**
  56118. * Creates a new DaydreamController from a gamepad
  56119. * @param vrGamepad the gamepad that the controller should be created from
  56120. */
  56121. constructor(vrGamepad: any);
  56122. /**
  56123. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56124. * @param scene scene in which to add meshes
  56125. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56126. */
  56127. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56128. /**
  56129. * Called once for each button that changed state since the last frame
  56130. * @param buttonIdx Which button index changed
  56131. * @param state New state of the button
  56132. * @param changes Which properties on the state changed since last frame
  56133. */
  56134. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56135. }
  56136. }
  56137. declare module BABYLON {
  56138. /**
  56139. * Gear VR Controller
  56140. */
  56141. export class GearVRController extends WebVRController {
  56142. /**
  56143. * Base Url for the controller model.
  56144. */
  56145. static MODEL_BASE_URL: string;
  56146. /**
  56147. * File name for the controller model.
  56148. */
  56149. static MODEL_FILENAME: string;
  56150. /**
  56151. * Gamepad Id prefix used to identify this controller.
  56152. */
  56153. static readonly GAMEPAD_ID_PREFIX: string;
  56154. private readonly _buttonIndexToObservableNameMap;
  56155. /**
  56156. * Creates a new GearVRController from a gamepad
  56157. * @param vrGamepad the gamepad that the controller should be created from
  56158. */
  56159. constructor(vrGamepad: any);
  56160. /**
  56161. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56162. * @param scene scene in which to add meshes
  56163. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56164. */
  56165. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56166. /**
  56167. * Called once for each button that changed state since the last frame
  56168. * @param buttonIdx Which button index changed
  56169. * @param state New state of the button
  56170. * @param changes Which properties on the state changed since last frame
  56171. */
  56172. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56173. }
  56174. }
  56175. declare module BABYLON {
  56176. /**
  56177. * Generic Controller
  56178. */
  56179. export class GenericController extends WebVRController {
  56180. /**
  56181. * Base Url for the controller model.
  56182. */
  56183. static readonly MODEL_BASE_URL: string;
  56184. /**
  56185. * File name for the controller model.
  56186. */
  56187. static readonly MODEL_FILENAME: string;
  56188. /**
  56189. * Creates a new GenericController from a gamepad
  56190. * @param vrGamepad the gamepad that the controller should be created from
  56191. */
  56192. constructor(vrGamepad: any);
  56193. /**
  56194. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56195. * @param scene scene in which to add meshes
  56196. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56197. */
  56198. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56199. /**
  56200. * Called once for each button that changed state since the last frame
  56201. * @param buttonIdx Which button index changed
  56202. * @param state New state of the button
  56203. * @param changes Which properties on the state changed since last frame
  56204. */
  56205. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56206. }
  56207. }
  56208. declare module BABYLON {
  56209. /**
  56210. * Oculus Touch Controller
  56211. */
  56212. export class OculusTouchController extends WebVRController {
  56213. /**
  56214. * Base Url for the controller model.
  56215. */
  56216. static MODEL_BASE_URL: string;
  56217. /**
  56218. * File name for the left controller model.
  56219. */
  56220. static MODEL_LEFT_FILENAME: string;
  56221. /**
  56222. * File name for the right controller model.
  56223. */
  56224. static MODEL_RIGHT_FILENAME: string;
  56225. /**
  56226. * Base Url for the Quest controller model.
  56227. */
  56228. static QUEST_MODEL_BASE_URL: string;
  56229. /**
  56230. * @hidden
  56231. * If the controllers are running on a device that needs the updated Quest controller models
  56232. */
  56233. static _IsQuest: boolean;
  56234. /**
  56235. * Fired when the secondary trigger on this controller is modified
  56236. */
  56237. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56238. /**
  56239. * Fired when the thumb rest on this controller is modified
  56240. */
  56241. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56242. /**
  56243. * Creates a new OculusTouchController from a gamepad
  56244. * @param vrGamepad the gamepad that the controller should be created from
  56245. */
  56246. constructor(vrGamepad: any);
  56247. /**
  56248. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56249. * @param scene scene in which to add meshes
  56250. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56251. */
  56252. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56253. /**
  56254. * Fired when the A button on this controller is modified
  56255. */
  56256. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56257. /**
  56258. * Fired when the B button on this controller is modified
  56259. */
  56260. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56261. /**
  56262. * Fired when the X button on this controller is modified
  56263. */
  56264. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56265. /**
  56266. * Fired when the Y button on this controller is modified
  56267. */
  56268. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56269. /**
  56270. * Called once for each button that changed state since the last frame
  56271. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56272. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56273. * 2) secondary trigger (same)
  56274. * 3) A (right) X (left), touch, pressed = value
  56275. * 4) B / Y
  56276. * 5) thumb rest
  56277. * @param buttonIdx Which button index changed
  56278. * @param state New state of the button
  56279. * @param changes Which properties on the state changed since last frame
  56280. */
  56281. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56282. }
  56283. }
  56284. declare module BABYLON {
  56285. /**
  56286. * Vive Controller
  56287. */
  56288. export class ViveController extends WebVRController {
  56289. /**
  56290. * Base Url for the controller model.
  56291. */
  56292. static MODEL_BASE_URL: string;
  56293. /**
  56294. * File name for the controller model.
  56295. */
  56296. static MODEL_FILENAME: string;
  56297. /**
  56298. * Creates a new ViveController from a gamepad
  56299. * @param vrGamepad the gamepad that the controller should be created from
  56300. */
  56301. constructor(vrGamepad: any);
  56302. /**
  56303. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56304. * @param scene scene in which to add meshes
  56305. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56306. */
  56307. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56308. /**
  56309. * Fired when the left button on this controller is modified
  56310. */
  56311. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56312. /**
  56313. * Fired when the right button on this controller is modified
  56314. */
  56315. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56316. /**
  56317. * Fired when the menu button on this controller is modified
  56318. */
  56319. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56320. /**
  56321. * Called once for each button that changed state since the last frame
  56322. * Vive mapping:
  56323. * 0: touchpad
  56324. * 1: trigger
  56325. * 2: left AND right buttons
  56326. * 3: menu button
  56327. * @param buttonIdx Which button index changed
  56328. * @param state New state of the button
  56329. * @param changes Which properties on the state changed since last frame
  56330. */
  56331. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56332. }
  56333. }
  56334. declare module BABYLON {
  56335. /**
  56336. * Defines the WindowsMotionController object that the state of the windows motion controller
  56337. */
  56338. export class WindowsMotionController extends WebVRController {
  56339. /**
  56340. * The base url used to load the left and right controller models
  56341. */
  56342. static MODEL_BASE_URL: string;
  56343. /**
  56344. * The name of the left controller model file
  56345. */
  56346. static MODEL_LEFT_FILENAME: string;
  56347. /**
  56348. * The name of the right controller model file
  56349. */
  56350. static MODEL_RIGHT_FILENAME: string;
  56351. /**
  56352. * The controller name prefix for this controller type
  56353. */
  56354. static readonly GAMEPAD_ID_PREFIX: string;
  56355. /**
  56356. * The controller id pattern for this controller type
  56357. */
  56358. private static readonly GAMEPAD_ID_PATTERN;
  56359. private _loadedMeshInfo;
  56360. protected readonly _mapping: {
  56361. buttons: string[];
  56362. buttonMeshNames: {
  56363. trigger: string;
  56364. menu: string;
  56365. grip: string;
  56366. thumbstick: string;
  56367. trackpad: string;
  56368. };
  56369. buttonObservableNames: {
  56370. trigger: string;
  56371. menu: string;
  56372. grip: string;
  56373. thumbstick: string;
  56374. trackpad: string;
  56375. };
  56376. axisMeshNames: string[];
  56377. pointingPoseMeshName: string;
  56378. };
  56379. /**
  56380. * Fired when the trackpad on this controller is clicked
  56381. */
  56382. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56383. /**
  56384. * Fired when the trackpad on this controller is modified
  56385. */
  56386. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56387. /**
  56388. * The current x and y values of this controller's trackpad
  56389. */
  56390. trackpad: StickValues;
  56391. /**
  56392. * Creates a new WindowsMotionController from a gamepad
  56393. * @param vrGamepad the gamepad that the controller should be created from
  56394. */
  56395. constructor(vrGamepad: any);
  56396. /**
  56397. * Fired when the trigger on this controller is modified
  56398. */
  56399. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56400. /**
  56401. * Fired when the menu button on this controller is modified
  56402. */
  56403. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56404. /**
  56405. * Fired when the grip button on this controller is modified
  56406. */
  56407. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56408. /**
  56409. * Fired when the thumbstick button on this controller is modified
  56410. */
  56411. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56412. /**
  56413. * Fired when the touchpad button on this controller is modified
  56414. */
  56415. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56416. /**
  56417. * Fired when the touchpad values on this controller are modified
  56418. */
  56419. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56420. protected _updateTrackpad(): void;
  56421. /**
  56422. * Called once per frame by the engine.
  56423. */
  56424. update(): void;
  56425. /**
  56426. * Called once for each button that changed state since the last frame
  56427. * @param buttonIdx Which button index changed
  56428. * @param state New state of the button
  56429. * @param changes Which properties on the state changed since last frame
  56430. */
  56431. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56432. /**
  56433. * Moves the buttons on the controller mesh based on their current state
  56434. * @param buttonName the name of the button to move
  56435. * @param buttonValue the value of the button which determines the buttons new position
  56436. */
  56437. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56438. /**
  56439. * Moves the axis on the controller mesh based on its current state
  56440. * @param axis the index of the axis
  56441. * @param axisValue the value of the axis which determines the meshes new position
  56442. * @hidden
  56443. */
  56444. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56445. /**
  56446. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56447. * @param scene scene in which to add meshes
  56448. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56449. */
  56450. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56451. /**
  56452. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56453. * can be transformed by button presses and axes values, based on this._mapping.
  56454. *
  56455. * @param scene scene in which the meshes exist
  56456. * @param meshes list of meshes that make up the controller model to process
  56457. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56458. */
  56459. private processModel;
  56460. private createMeshInfo;
  56461. /**
  56462. * Gets the ray of the controller in the direction the controller is pointing
  56463. * @param length the length the resulting ray should be
  56464. * @returns a ray in the direction the controller is pointing
  56465. */
  56466. getForwardRay(length?: number): Ray;
  56467. /**
  56468. * Disposes of the controller
  56469. */
  56470. dispose(): void;
  56471. }
  56472. /**
  56473. * This class represents a new windows motion controller in XR.
  56474. */
  56475. export class XRWindowsMotionController extends WindowsMotionController {
  56476. /**
  56477. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56478. */
  56479. protected readonly _mapping: {
  56480. buttons: string[];
  56481. buttonMeshNames: {
  56482. trigger: string;
  56483. menu: string;
  56484. grip: string;
  56485. thumbstick: string;
  56486. trackpad: string;
  56487. };
  56488. buttonObservableNames: {
  56489. trigger: string;
  56490. menu: string;
  56491. grip: string;
  56492. thumbstick: string;
  56493. trackpad: string;
  56494. };
  56495. axisMeshNames: string[];
  56496. pointingPoseMeshName: string;
  56497. };
  56498. /**
  56499. * Construct a new XR-Based windows motion controller
  56500. *
  56501. * @param gamepadInfo the gamepad object from the browser
  56502. */
  56503. constructor(gamepadInfo: any);
  56504. /**
  56505. * holds the thumbstick values (X,Y)
  56506. */
  56507. thumbstickValues: StickValues;
  56508. /**
  56509. * Fired when the thumbstick on this controller is clicked
  56510. */
  56511. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56512. /**
  56513. * Fired when the thumbstick on this controller is modified
  56514. */
  56515. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56516. /**
  56517. * Fired when the touchpad button on this controller is modified
  56518. */
  56519. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56520. /**
  56521. * Fired when the touchpad values on this controller are modified
  56522. */
  56523. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56524. /**
  56525. * Fired when the thumbstick button on this controller is modified
  56526. * here to prevent breaking changes
  56527. */
  56528. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56529. /**
  56530. * updating the thumbstick(!) and not the trackpad.
  56531. * This is named this way due to the difference between WebVR and XR and to avoid
  56532. * changing the parent class.
  56533. */
  56534. protected _updateTrackpad(): void;
  56535. /**
  56536. * Disposes the class with joy
  56537. */
  56538. dispose(): void;
  56539. }
  56540. }
  56541. declare module BABYLON {
  56542. /**
  56543. * Class containing static functions to help procedurally build meshes
  56544. */
  56545. export class PolyhedronBuilder {
  56546. /**
  56547. * Creates a polyhedron mesh
  56548. * * 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
  56549. * * The parameter `size` (positive float, default 1) sets the polygon size
  56550. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56551. * * 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`
  56552. * * 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
  56553. * * 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)`)
  56554. * * 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
  56555. * * 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
  56556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56557. * * 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
  56558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56559. * @param name defines the name of the mesh
  56560. * @param options defines the options used to create the mesh
  56561. * @param scene defines the hosting scene
  56562. * @returns the polyhedron mesh
  56563. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56564. */
  56565. static CreatePolyhedron(name: string, options: {
  56566. type?: number;
  56567. size?: number;
  56568. sizeX?: number;
  56569. sizeY?: number;
  56570. sizeZ?: number;
  56571. custom?: any;
  56572. faceUV?: Vector4[];
  56573. faceColors?: Color4[];
  56574. flat?: boolean;
  56575. updatable?: boolean;
  56576. sideOrientation?: number;
  56577. frontUVs?: Vector4;
  56578. backUVs?: Vector4;
  56579. }, scene?: Nullable<Scene>): Mesh;
  56580. }
  56581. }
  56582. declare module BABYLON {
  56583. /**
  56584. * Gizmo that enables scaling a mesh along 3 axis
  56585. */
  56586. export class ScaleGizmo extends Gizmo {
  56587. /**
  56588. * Internal gizmo used for interactions on the x axis
  56589. */
  56590. xGizmo: AxisScaleGizmo;
  56591. /**
  56592. * Internal gizmo used for interactions on the y axis
  56593. */
  56594. yGizmo: AxisScaleGizmo;
  56595. /**
  56596. * Internal gizmo used for interactions on the z axis
  56597. */
  56598. zGizmo: AxisScaleGizmo;
  56599. /**
  56600. * Internal gizmo used to scale all axis equally
  56601. */
  56602. uniformScaleGizmo: AxisScaleGizmo;
  56603. private _meshAttached;
  56604. private _nodeAttached;
  56605. private _snapDistance;
  56606. private _uniformScalingMesh;
  56607. private _octahedron;
  56608. private _sensitivity;
  56609. /** Fires an event when any of it's sub gizmos are dragged */
  56610. onDragStartObservable: Observable<unknown>;
  56611. /** Fires an event when any of it's sub gizmos are released from dragging */
  56612. onDragEndObservable: Observable<unknown>;
  56613. get attachedMesh(): Nullable<AbstractMesh>;
  56614. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56615. get attachedNode(): Nullable<Node>;
  56616. set attachedNode(node: Nullable<Node>);
  56617. /**
  56618. * True when the mouse pointer is hovering a gizmo mesh
  56619. */
  56620. get isHovered(): boolean;
  56621. /**
  56622. * Creates a ScaleGizmo
  56623. * @param gizmoLayer The utility layer the gizmo will be added to
  56624. * @param thickness display gizmo axis thickness
  56625. */
  56626. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56627. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56628. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56629. /**
  56630. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56631. */
  56632. set snapDistance(value: number);
  56633. get snapDistance(): number;
  56634. /**
  56635. * Ratio for the scale of the gizmo (Default: 1)
  56636. */
  56637. set scaleRatio(value: number);
  56638. get scaleRatio(): number;
  56639. /**
  56640. * Sensitivity factor for dragging (Default: 1)
  56641. */
  56642. set sensitivity(value: number);
  56643. get sensitivity(): number;
  56644. /**
  56645. * Disposes of the gizmo
  56646. */
  56647. dispose(): void;
  56648. }
  56649. }
  56650. declare module BABYLON {
  56651. /**
  56652. * Single axis scale gizmo
  56653. */
  56654. export class AxisScaleGizmo extends Gizmo {
  56655. /**
  56656. * Drag behavior responsible for the gizmos dragging interactions
  56657. */
  56658. dragBehavior: PointerDragBehavior;
  56659. private _pointerObserver;
  56660. /**
  56661. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56662. */
  56663. snapDistance: number;
  56664. /**
  56665. * Event that fires each time the gizmo snaps to a new location.
  56666. * * snapDistance is the the change in distance
  56667. */
  56668. onSnapObservable: Observable<{
  56669. snapDistance: number;
  56670. }>;
  56671. /**
  56672. * If the scaling operation should be done on all axis (default: false)
  56673. */
  56674. uniformScaling: boolean;
  56675. /**
  56676. * Custom sensitivity value for the drag strength
  56677. */
  56678. sensitivity: number;
  56679. private _isEnabled;
  56680. private _parent;
  56681. private _arrow;
  56682. private _coloredMaterial;
  56683. private _hoverMaterial;
  56684. /**
  56685. * Creates an AxisScaleGizmo
  56686. * @param gizmoLayer The utility layer the gizmo will be added to
  56687. * @param dragAxis The axis which the gizmo will be able to scale on
  56688. * @param color The color of the gizmo
  56689. * @param thickness display gizmo axis thickness
  56690. */
  56691. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56692. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56693. /**
  56694. * If the gizmo is enabled
  56695. */
  56696. set isEnabled(value: boolean);
  56697. get isEnabled(): boolean;
  56698. /**
  56699. * Disposes of the gizmo
  56700. */
  56701. dispose(): void;
  56702. /**
  56703. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56704. * @param mesh The mesh to replace the default mesh of the gizmo
  56705. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56706. */
  56707. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56708. }
  56709. }
  56710. declare module BABYLON {
  56711. /**
  56712. * Bounding box gizmo
  56713. */
  56714. export class BoundingBoxGizmo extends Gizmo {
  56715. private _lineBoundingBox;
  56716. private _rotateSpheresParent;
  56717. private _scaleBoxesParent;
  56718. private _boundingDimensions;
  56719. private _renderObserver;
  56720. private _pointerObserver;
  56721. private _scaleDragSpeed;
  56722. private _tmpQuaternion;
  56723. private _tmpVector;
  56724. private _tmpRotationMatrix;
  56725. /**
  56726. * 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)
  56727. */
  56728. ignoreChildren: boolean;
  56729. /**
  56730. * 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)
  56731. */
  56732. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56733. /**
  56734. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56735. */
  56736. rotationSphereSize: number;
  56737. /**
  56738. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56739. */
  56740. scaleBoxSize: number;
  56741. /**
  56742. * 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)
  56743. */
  56744. fixedDragMeshScreenSize: boolean;
  56745. /**
  56746. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56747. */
  56748. fixedDragMeshScreenSizeDistanceFactor: number;
  56749. /**
  56750. * Fired when a rotation sphere or scale box is dragged
  56751. */
  56752. onDragStartObservable: Observable<{}>;
  56753. /**
  56754. * Fired when a scale box is dragged
  56755. */
  56756. onScaleBoxDragObservable: Observable<{}>;
  56757. /**
  56758. * Fired when a scale box drag is ended
  56759. */
  56760. onScaleBoxDragEndObservable: Observable<{}>;
  56761. /**
  56762. * Fired when a rotation sphere is dragged
  56763. */
  56764. onRotationSphereDragObservable: Observable<{}>;
  56765. /**
  56766. * Fired when a rotation sphere drag is ended
  56767. */
  56768. onRotationSphereDragEndObservable: Observable<{}>;
  56769. /**
  56770. * 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)
  56771. */
  56772. scalePivot: Nullable<Vector3>;
  56773. /**
  56774. * Mesh used as a pivot to rotate the attached node
  56775. */
  56776. private _anchorMesh;
  56777. private _existingMeshScale;
  56778. private _dragMesh;
  56779. private pointerDragBehavior;
  56780. private coloredMaterial;
  56781. private hoverColoredMaterial;
  56782. /**
  56783. * Sets the color of the bounding box gizmo
  56784. * @param color the color to set
  56785. */
  56786. setColor(color: Color3): void;
  56787. /**
  56788. * Creates an BoundingBoxGizmo
  56789. * @param gizmoLayer The utility layer the gizmo will be added to
  56790. * @param color The color of the gizmo
  56791. */
  56792. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56793. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56794. private _selectNode;
  56795. /**
  56796. * Updates the bounding box information for the Gizmo
  56797. */
  56798. updateBoundingBox(): void;
  56799. private _updateRotationSpheres;
  56800. private _updateScaleBoxes;
  56801. /**
  56802. * Enables rotation on the specified axis and disables rotation on the others
  56803. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56804. */
  56805. setEnabledRotationAxis(axis: string): void;
  56806. /**
  56807. * Enables/disables scaling
  56808. * @param enable if scaling should be enabled
  56809. * @param homogeneousScaling defines if scaling should only be homogeneous
  56810. */
  56811. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56812. private _updateDummy;
  56813. /**
  56814. * Enables a pointer drag behavior on the bounding box of the gizmo
  56815. */
  56816. enableDragBehavior(): void;
  56817. /**
  56818. * Disposes of the gizmo
  56819. */
  56820. dispose(): void;
  56821. /**
  56822. * 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)
  56823. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56824. * @returns the bounding box mesh with the passed in mesh as a child
  56825. */
  56826. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56827. /**
  56828. * CustomMeshes are not supported by this gizmo
  56829. * @param mesh The mesh to replace the default mesh of the gizmo
  56830. */
  56831. setCustomMesh(mesh: Mesh): void;
  56832. }
  56833. }
  56834. declare module BABYLON {
  56835. /**
  56836. * Single plane rotation gizmo
  56837. */
  56838. export class PlaneRotationGizmo extends Gizmo {
  56839. /**
  56840. * Drag behavior responsible for the gizmos dragging interactions
  56841. */
  56842. dragBehavior: PointerDragBehavior;
  56843. private _pointerObserver;
  56844. /**
  56845. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56846. */
  56847. snapDistance: number;
  56848. /**
  56849. * Event that fires each time the gizmo snaps to a new location.
  56850. * * snapDistance is the the change in distance
  56851. */
  56852. onSnapObservable: Observable<{
  56853. snapDistance: number;
  56854. }>;
  56855. private _isEnabled;
  56856. private _parent;
  56857. /**
  56858. * Creates a PlaneRotationGizmo
  56859. * @param gizmoLayer The utility layer the gizmo will be added to
  56860. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56861. * @param color The color of the gizmo
  56862. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56863. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56864. * @param thickness display gizmo axis thickness
  56865. */
  56866. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56867. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56868. /**
  56869. * If the gizmo is enabled
  56870. */
  56871. set isEnabled(value: boolean);
  56872. get isEnabled(): boolean;
  56873. /**
  56874. * Disposes of the gizmo
  56875. */
  56876. dispose(): void;
  56877. }
  56878. }
  56879. declare module BABYLON {
  56880. /**
  56881. * Gizmo that enables rotating a mesh along 3 axis
  56882. */
  56883. export class RotationGizmo extends Gizmo {
  56884. /**
  56885. * Internal gizmo used for interactions on the x axis
  56886. */
  56887. xGizmo: PlaneRotationGizmo;
  56888. /**
  56889. * Internal gizmo used for interactions on the y axis
  56890. */
  56891. yGizmo: PlaneRotationGizmo;
  56892. /**
  56893. * Internal gizmo used for interactions on the z axis
  56894. */
  56895. zGizmo: PlaneRotationGizmo;
  56896. /** Fires an event when any of it's sub gizmos are dragged */
  56897. onDragStartObservable: Observable<unknown>;
  56898. /** Fires an event when any of it's sub gizmos are released from dragging */
  56899. onDragEndObservable: Observable<unknown>;
  56900. private _meshAttached;
  56901. private _nodeAttached;
  56902. get attachedMesh(): Nullable<AbstractMesh>;
  56903. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56904. get attachedNode(): Nullable<Node>;
  56905. set attachedNode(node: Nullable<Node>);
  56906. protected _checkBillboardTransform(): void;
  56907. /**
  56908. * True when the mouse pointer is hovering a gizmo mesh
  56909. */
  56910. get isHovered(): boolean;
  56911. /**
  56912. * Creates a RotationGizmo
  56913. * @param gizmoLayer The utility layer the gizmo will be added to
  56914. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56915. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56916. * @param thickness display gizmo axis thickness
  56917. */
  56918. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56919. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56920. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56921. /**
  56922. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56923. */
  56924. set snapDistance(value: number);
  56925. get snapDistance(): number;
  56926. /**
  56927. * Ratio for the scale of the gizmo (Default: 1)
  56928. */
  56929. set scaleRatio(value: number);
  56930. get scaleRatio(): number;
  56931. /**
  56932. * Disposes of the gizmo
  56933. */
  56934. dispose(): void;
  56935. /**
  56936. * CustomMeshes are not supported by this gizmo
  56937. * @param mesh The mesh to replace the default mesh of the gizmo
  56938. */
  56939. setCustomMesh(mesh: Mesh): void;
  56940. }
  56941. }
  56942. declare module BABYLON {
  56943. /**
  56944. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56945. */
  56946. export class GizmoManager implements IDisposable {
  56947. private scene;
  56948. /**
  56949. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56950. */
  56951. gizmos: {
  56952. positionGizmo: Nullable<PositionGizmo>;
  56953. rotationGizmo: Nullable<RotationGizmo>;
  56954. scaleGizmo: Nullable<ScaleGizmo>;
  56955. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56956. };
  56957. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56958. clearGizmoOnEmptyPointerEvent: boolean;
  56959. /** Fires an event when the manager is attached to a mesh */
  56960. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56961. /** Fires an event when the manager is attached to a node */
  56962. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56963. private _gizmosEnabled;
  56964. private _pointerObserver;
  56965. private _attachedMesh;
  56966. private _attachedNode;
  56967. private _boundingBoxColor;
  56968. private _defaultUtilityLayer;
  56969. private _defaultKeepDepthUtilityLayer;
  56970. private _thickness;
  56971. /**
  56972. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56973. */
  56974. boundingBoxDragBehavior: SixDofDragBehavior;
  56975. /**
  56976. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56977. */
  56978. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56979. /**
  56980. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56981. */
  56982. attachableNodes: Nullable<Array<Node>>;
  56983. /**
  56984. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56985. */
  56986. usePointerToAttachGizmos: boolean;
  56987. /**
  56988. * Utility layer that the bounding box gizmo belongs to
  56989. */
  56990. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56991. /**
  56992. * Utility layer that all gizmos besides bounding box belong to
  56993. */
  56994. get utilityLayer(): UtilityLayerRenderer;
  56995. /**
  56996. * True when the mouse pointer is hovering a gizmo mesh
  56997. */
  56998. get isHovered(): boolean;
  56999. /**
  57000. * Instatiates a gizmo manager
  57001. * @param scene the scene to overlay the gizmos on top of
  57002. * @param thickness display gizmo axis thickness
  57003. */
  57004. constructor(scene: Scene, thickness?: number);
  57005. /**
  57006. * Attaches a set of gizmos to the specified mesh
  57007. * @param mesh The mesh the gizmo's should be attached to
  57008. */
  57009. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57010. /**
  57011. * Attaches a set of gizmos to the specified node
  57012. * @param node The node the gizmo's should be attached to
  57013. */
  57014. attachToNode(node: Nullable<Node>): void;
  57015. /**
  57016. * If the position gizmo is enabled
  57017. */
  57018. set positionGizmoEnabled(value: boolean);
  57019. get positionGizmoEnabled(): boolean;
  57020. /**
  57021. * If the rotation gizmo is enabled
  57022. */
  57023. set rotationGizmoEnabled(value: boolean);
  57024. get rotationGizmoEnabled(): boolean;
  57025. /**
  57026. * If the scale gizmo is enabled
  57027. */
  57028. set scaleGizmoEnabled(value: boolean);
  57029. get scaleGizmoEnabled(): boolean;
  57030. /**
  57031. * If the boundingBox gizmo is enabled
  57032. */
  57033. set boundingBoxGizmoEnabled(value: boolean);
  57034. get boundingBoxGizmoEnabled(): boolean;
  57035. /**
  57036. * Disposes of the gizmo manager
  57037. */
  57038. dispose(): void;
  57039. }
  57040. }
  57041. declare module BABYLON {
  57042. /**
  57043. * A directional light is defined by a direction (what a surprise!).
  57044. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57045. * 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.
  57046. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57047. */
  57048. export class DirectionalLight extends ShadowLight {
  57049. private _shadowFrustumSize;
  57050. /**
  57051. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57052. */
  57053. get shadowFrustumSize(): number;
  57054. /**
  57055. * Specifies a fix frustum size for the shadow generation.
  57056. */
  57057. set shadowFrustumSize(value: number);
  57058. private _shadowOrthoScale;
  57059. /**
  57060. * Gets the shadow projection scale against the optimal computed one.
  57061. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57062. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57063. */
  57064. get shadowOrthoScale(): number;
  57065. /**
  57066. * Sets the shadow projection scale against the optimal computed one.
  57067. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57068. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57069. */
  57070. set shadowOrthoScale(value: number);
  57071. /**
  57072. * Automatically compute the projection matrix to best fit (including all the casters)
  57073. * on each frame.
  57074. */
  57075. autoUpdateExtends: boolean;
  57076. /**
  57077. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57078. * on each frame. autoUpdateExtends must be set to true for this to work
  57079. */
  57080. autoCalcShadowZBounds: boolean;
  57081. private _orthoLeft;
  57082. private _orthoRight;
  57083. private _orthoTop;
  57084. private _orthoBottom;
  57085. /**
  57086. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57087. * The directional light is emitted from everywhere in the given direction.
  57088. * It can cast shadows.
  57089. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57090. * @param name The friendly name of the light
  57091. * @param direction The direction of the light
  57092. * @param scene The scene the light belongs to
  57093. */
  57094. constructor(name: string, direction: Vector3, scene: Scene);
  57095. /**
  57096. * Returns the string "DirectionalLight".
  57097. * @return The class name
  57098. */
  57099. getClassName(): string;
  57100. /**
  57101. * Returns the integer 1.
  57102. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57103. */
  57104. getTypeID(): number;
  57105. /**
  57106. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57107. * Returns the DirectionalLight Shadow projection matrix.
  57108. */
  57109. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57110. /**
  57111. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57112. * Returns the DirectionalLight Shadow projection matrix.
  57113. */
  57114. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57115. /**
  57116. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57117. * Returns the DirectionalLight Shadow projection matrix.
  57118. */
  57119. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57120. protected _buildUniformLayout(): void;
  57121. /**
  57122. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57123. * @param effect The effect to update
  57124. * @param lightIndex The index of the light in the effect to update
  57125. * @returns The directional light
  57126. */
  57127. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57128. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57129. /**
  57130. * Gets the minZ used for shadow according to both the scene and the light.
  57131. *
  57132. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57133. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57134. * @param activeCamera The camera we are returning the min for
  57135. * @returns the depth min z
  57136. */
  57137. getDepthMinZ(activeCamera: Camera): number;
  57138. /**
  57139. * Gets the maxZ used for shadow according to both the scene and the light.
  57140. *
  57141. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57142. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57143. * @param activeCamera The camera we are returning the max for
  57144. * @returns the depth max z
  57145. */
  57146. getDepthMaxZ(activeCamera: Camera): number;
  57147. /**
  57148. * Prepares the list of defines specific to the light type.
  57149. * @param defines the list of defines
  57150. * @param lightIndex defines the index of the light for the effect
  57151. */
  57152. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57153. }
  57154. }
  57155. declare module BABYLON {
  57156. /**
  57157. * Class containing static functions to help procedurally build meshes
  57158. */
  57159. export class HemisphereBuilder {
  57160. /**
  57161. * Creates a hemisphere mesh
  57162. * @param name defines the name of the mesh
  57163. * @param options defines the options used to create the mesh
  57164. * @param scene defines the hosting scene
  57165. * @returns the hemisphere mesh
  57166. */
  57167. static CreateHemisphere(name: string, options: {
  57168. segments?: number;
  57169. diameter?: number;
  57170. sideOrientation?: number;
  57171. }, scene: any): Mesh;
  57172. }
  57173. }
  57174. declare module BABYLON {
  57175. /**
  57176. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57177. * These values define a cone of light starting from the position, emitting toward the direction.
  57178. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57179. * and the exponent defines the speed of the decay of the light with distance (reach).
  57180. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57181. */
  57182. export class SpotLight extends ShadowLight {
  57183. private _angle;
  57184. private _innerAngle;
  57185. private _cosHalfAngle;
  57186. private _lightAngleScale;
  57187. private _lightAngleOffset;
  57188. /**
  57189. * Gets the cone angle of the spot light in Radians.
  57190. */
  57191. get angle(): number;
  57192. /**
  57193. * Sets the cone angle of the spot light in Radians.
  57194. */
  57195. set angle(value: number);
  57196. /**
  57197. * Only used in gltf falloff mode, this defines the angle where
  57198. * the directional falloff will start before cutting at angle which could be seen
  57199. * as outer angle.
  57200. */
  57201. get innerAngle(): number;
  57202. /**
  57203. * Only used in gltf falloff mode, this defines the angle where
  57204. * the directional falloff will start before cutting at angle which could be seen
  57205. * as outer angle.
  57206. */
  57207. set innerAngle(value: number);
  57208. private _shadowAngleScale;
  57209. /**
  57210. * Allows scaling the angle of the light for shadow generation only.
  57211. */
  57212. get shadowAngleScale(): number;
  57213. /**
  57214. * Allows scaling the angle of the light for shadow generation only.
  57215. */
  57216. set shadowAngleScale(value: number);
  57217. /**
  57218. * The light decay speed with the distance from the emission spot.
  57219. */
  57220. exponent: number;
  57221. private _projectionTextureMatrix;
  57222. /**
  57223. * Allows reading the projecton texture
  57224. */
  57225. get projectionTextureMatrix(): Matrix;
  57226. protected _projectionTextureLightNear: number;
  57227. /**
  57228. * Gets the near clip of the Spotlight for texture projection.
  57229. */
  57230. get projectionTextureLightNear(): number;
  57231. /**
  57232. * Sets the near clip of the Spotlight for texture projection.
  57233. */
  57234. set projectionTextureLightNear(value: number);
  57235. protected _projectionTextureLightFar: number;
  57236. /**
  57237. * Gets the far clip of the Spotlight for texture projection.
  57238. */
  57239. get projectionTextureLightFar(): number;
  57240. /**
  57241. * Sets the far clip of the Spotlight for texture projection.
  57242. */
  57243. set projectionTextureLightFar(value: number);
  57244. protected _projectionTextureUpDirection: Vector3;
  57245. /**
  57246. * Gets the Up vector of the Spotlight for texture projection.
  57247. */
  57248. get projectionTextureUpDirection(): Vector3;
  57249. /**
  57250. * Sets the Up vector of the Spotlight for texture projection.
  57251. */
  57252. set projectionTextureUpDirection(value: Vector3);
  57253. private _projectionTexture;
  57254. /**
  57255. * Gets the projection texture of the light.
  57256. */
  57257. get projectionTexture(): Nullable<BaseTexture>;
  57258. /**
  57259. * Sets the projection texture of the light.
  57260. */
  57261. set projectionTexture(value: Nullable<BaseTexture>);
  57262. private _projectionTextureViewLightDirty;
  57263. private _projectionTextureProjectionLightDirty;
  57264. private _projectionTextureDirty;
  57265. private _projectionTextureViewTargetVector;
  57266. private _projectionTextureViewLightMatrix;
  57267. private _projectionTextureProjectionLightMatrix;
  57268. private _projectionTextureScalingMatrix;
  57269. /**
  57270. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57271. * It can cast shadows.
  57272. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57273. * @param name The light friendly name
  57274. * @param position The position of the spot light in the scene
  57275. * @param direction The direction of the light in the scene
  57276. * @param angle The cone angle of the light in Radians
  57277. * @param exponent The light decay speed with the distance from the emission spot
  57278. * @param scene The scene the lights belongs to
  57279. */
  57280. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57281. /**
  57282. * Returns the string "SpotLight".
  57283. * @returns the class name
  57284. */
  57285. getClassName(): string;
  57286. /**
  57287. * Returns the integer 2.
  57288. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57289. */
  57290. getTypeID(): number;
  57291. /**
  57292. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57293. */
  57294. protected _setDirection(value: Vector3): void;
  57295. /**
  57296. * Overrides the position setter to recompute the projection texture view light Matrix.
  57297. */
  57298. protected _setPosition(value: Vector3): void;
  57299. /**
  57300. * 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.
  57301. * Returns the SpotLight.
  57302. */
  57303. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57304. protected _computeProjectionTextureViewLightMatrix(): void;
  57305. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57306. /**
  57307. * Main function for light texture projection matrix computing.
  57308. */
  57309. protected _computeProjectionTextureMatrix(): void;
  57310. protected _buildUniformLayout(): void;
  57311. private _computeAngleValues;
  57312. /**
  57313. * Sets the passed Effect "effect" with the Light textures.
  57314. * @param effect The effect to update
  57315. * @param lightIndex The index of the light in the effect to update
  57316. * @returns The light
  57317. */
  57318. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57319. /**
  57320. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57321. * @param effect The effect to update
  57322. * @param lightIndex The index of the light in the effect to update
  57323. * @returns The spot light
  57324. */
  57325. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57326. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57327. /**
  57328. * Disposes the light and the associated resources.
  57329. */
  57330. dispose(): void;
  57331. /**
  57332. * Prepares the list of defines specific to the light type.
  57333. * @param defines the list of defines
  57334. * @param lightIndex defines the index of the light for the effect
  57335. */
  57336. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57337. }
  57338. }
  57339. declare module BABYLON {
  57340. /**
  57341. * Gizmo that enables viewing a light
  57342. */
  57343. export class LightGizmo extends Gizmo {
  57344. private _lightMesh;
  57345. private _material;
  57346. private _cachedPosition;
  57347. private _cachedForward;
  57348. private _attachedMeshParent;
  57349. private _pointerObserver;
  57350. /**
  57351. * Event that fires each time the gizmo is clicked
  57352. */
  57353. onClickedObservable: Observable<Light>;
  57354. /**
  57355. * Creates a LightGizmo
  57356. * @param gizmoLayer The utility layer the gizmo will be added to
  57357. */
  57358. constructor(gizmoLayer?: UtilityLayerRenderer);
  57359. private _light;
  57360. /**
  57361. * The light that the gizmo is attached to
  57362. */
  57363. set light(light: Nullable<Light>);
  57364. get light(): Nullable<Light>;
  57365. /**
  57366. * Gets the material used to render the light gizmo
  57367. */
  57368. get material(): StandardMaterial;
  57369. /**
  57370. * @hidden
  57371. * Updates the gizmo to match the attached mesh's position/rotation
  57372. */
  57373. protected _update(): void;
  57374. private static _Scale;
  57375. /**
  57376. * Creates the lines for a light mesh
  57377. */
  57378. private static _CreateLightLines;
  57379. /**
  57380. * Disposes of the light gizmo
  57381. */
  57382. dispose(): void;
  57383. private static _CreateHemisphericLightMesh;
  57384. private static _CreatePointLightMesh;
  57385. private static _CreateSpotLightMesh;
  57386. private static _CreateDirectionalLightMesh;
  57387. }
  57388. }
  57389. declare module BABYLON {
  57390. /**
  57391. * Gizmo that enables viewing a camera
  57392. */
  57393. export class CameraGizmo extends Gizmo {
  57394. private _cameraMesh;
  57395. private _cameraLinesMesh;
  57396. private _material;
  57397. private _pointerObserver;
  57398. /**
  57399. * Event that fires each time the gizmo is clicked
  57400. */
  57401. onClickedObservable: Observable<Camera>;
  57402. /**
  57403. * Creates a CameraGizmo
  57404. * @param gizmoLayer The utility layer the gizmo will be added to
  57405. */
  57406. constructor(gizmoLayer?: UtilityLayerRenderer);
  57407. private _camera;
  57408. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57409. get displayFrustum(): boolean;
  57410. set displayFrustum(value: boolean);
  57411. /**
  57412. * The camera that the gizmo is attached to
  57413. */
  57414. set camera(camera: Nullable<Camera>);
  57415. get camera(): Nullable<Camera>;
  57416. /**
  57417. * Gets the material used to render the camera gizmo
  57418. */
  57419. get material(): StandardMaterial;
  57420. /**
  57421. * @hidden
  57422. * Updates the gizmo to match the attached mesh's position/rotation
  57423. */
  57424. protected _update(): void;
  57425. private static _Scale;
  57426. private _invProjection;
  57427. /**
  57428. * Disposes of the camera gizmo
  57429. */
  57430. dispose(): void;
  57431. private static _CreateCameraMesh;
  57432. private static _CreateCameraFrustum;
  57433. }
  57434. }
  57435. declare module BABYLON {
  57436. /** @hidden */
  57437. export var backgroundFragmentDeclaration: {
  57438. name: string;
  57439. shader: string;
  57440. };
  57441. }
  57442. declare module BABYLON {
  57443. /** @hidden */
  57444. export var backgroundUboDeclaration: {
  57445. name: string;
  57446. shader: string;
  57447. };
  57448. }
  57449. declare module BABYLON {
  57450. /** @hidden */
  57451. export var backgroundPixelShader: {
  57452. name: string;
  57453. shader: string;
  57454. };
  57455. }
  57456. declare module BABYLON {
  57457. /** @hidden */
  57458. export var backgroundVertexDeclaration: {
  57459. name: string;
  57460. shader: string;
  57461. };
  57462. }
  57463. declare module BABYLON {
  57464. /** @hidden */
  57465. export var backgroundVertexShader: {
  57466. name: string;
  57467. shader: string;
  57468. };
  57469. }
  57470. declare module BABYLON {
  57471. /**
  57472. * Background material used to create an efficient environement around your scene.
  57473. */
  57474. export class BackgroundMaterial extends PushMaterial {
  57475. /**
  57476. * Standard reflectance value at parallel view angle.
  57477. */
  57478. static StandardReflectance0: number;
  57479. /**
  57480. * Standard reflectance value at grazing angle.
  57481. */
  57482. static StandardReflectance90: number;
  57483. protected _primaryColor: Color3;
  57484. /**
  57485. * Key light Color (multiply against the environement texture)
  57486. */
  57487. primaryColor: Color3;
  57488. protected __perceptualColor: Nullable<Color3>;
  57489. /**
  57490. * Experimental Internal Use Only.
  57491. *
  57492. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57493. * This acts as a helper to set the primary color to a more "human friendly" value.
  57494. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57495. * output color as close as possible from the chosen value.
  57496. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57497. * part of lighting setup.)
  57498. */
  57499. get _perceptualColor(): Nullable<Color3>;
  57500. set _perceptualColor(value: Nullable<Color3>);
  57501. protected _primaryColorShadowLevel: float;
  57502. /**
  57503. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57504. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57505. */
  57506. get primaryColorShadowLevel(): float;
  57507. set primaryColorShadowLevel(value: float);
  57508. protected _primaryColorHighlightLevel: float;
  57509. /**
  57510. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57511. * The primary color is used at the level chosen to define what the white area would look.
  57512. */
  57513. get primaryColorHighlightLevel(): float;
  57514. set primaryColorHighlightLevel(value: float);
  57515. protected _reflectionTexture: Nullable<BaseTexture>;
  57516. /**
  57517. * Reflection Texture used in the material.
  57518. * Should be author in a specific way for the best result (refer to the documentation).
  57519. */
  57520. reflectionTexture: Nullable<BaseTexture>;
  57521. protected _reflectionBlur: float;
  57522. /**
  57523. * Reflection Texture level of blur.
  57524. *
  57525. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57526. * texture twice.
  57527. */
  57528. reflectionBlur: float;
  57529. protected _diffuseTexture: Nullable<BaseTexture>;
  57530. /**
  57531. * Diffuse Texture used in the material.
  57532. * Should be author in a specific way for the best result (refer to the documentation).
  57533. */
  57534. diffuseTexture: Nullable<BaseTexture>;
  57535. protected _shadowLights: Nullable<IShadowLight[]>;
  57536. /**
  57537. * Specify the list of lights casting shadow on the material.
  57538. * All scene shadow lights will be included if null.
  57539. */
  57540. shadowLights: Nullable<IShadowLight[]>;
  57541. protected _shadowLevel: float;
  57542. /**
  57543. * Helps adjusting the shadow to a softer level if required.
  57544. * 0 means black shadows and 1 means no shadows.
  57545. */
  57546. shadowLevel: float;
  57547. protected _sceneCenter: Vector3;
  57548. /**
  57549. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57550. * It is usually zero but might be interesting to modify according to your setup.
  57551. */
  57552. sceneCenter: Vector3;
  57553. protected _opacityFresnel: boolean;
  57554. /**
  57555. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57556. * This helps ensuring a nice transition when the camera goes under the ground.
  57557. */
  57558. opacityFresnel: boolean;
  57559. protected _reflectionFresnel: boolean;
  57560. /**
  57561. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57562. * This helps adding a mirror texture on the ground.
  57563. */
  57564. reflectionFresnel: boolean;
  57565. protected _reflectionFalloffDistance: number;
  57566. /**
  57567. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57568. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57569. */
  57570. reflectionFalloffDistance: number;
  57571. protected _reflectionAmount: number;
  57572. /**
  57573. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57574. */
  57575. reflectionAmount: number;
  57576. protected _reflectionReflectance0: number;
  57577. /**
  57578. * This specifies the weight of the reflection at grazing angle.
  57579. */
  57580. reflectionReflectance0: number;
  57581. protected _reflectionReflectance90: number;
  57582. /**
  57583. * This specifies the weight of the reflection at a perpendicular point of view.
  57584. */
  57585. reflectionReflectance90: number;
  57586. /**
  57587. * Sets the reflection reflectance fresnel values according to the default standard
  57588. * empirically know to work well :-)
  57589. */
  57590. set reflectionStandardFresnelWeight(value: number);
  57591. protected _useRGBColor: boolean;
  57592. /**
  57593. * Helps to directly use the maps channels instead of their level.
  57594. */
  57595. useRGBColor: boolean;
  57596. protected _enableNoise: boolean;
  57597. /**
  57598. * This helps reducing the banding effect that could occur on the background.
  57599. */
  57600. enableNoise: boolean;
  57601. /**
  57602. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57603. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57604. * Recommended to be keep at 1.0 except for special cases.
  57605. */
  57606. get fovMultiplier(): number;
  57607. set fovMultiplier(value: number);
  57608. private _fovMultiplier;
  57609. /**
  57610. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57611. */
  57612. useEquirectangularFOV: boolean;
  57613. private _maxSimultaneousLights;
  57614. /**
  57615. * Number of Simultaneous lights allowed on the material.
  57616. */
  57617. maxSimultaneousLights: int;
  57618. private _shadowOnly;
  57619. /**
  57620. * Make the material only render shadows
  57621. */
  57622. shadowOnly: boolean;
  57623. /**
  57624. * Default configuration related to image processing available in the Background Material.
  57625. */
  57626. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57627. /**
  57628. * Keep track of the image processing observer to allow dispose and replace.
  57629. */
  57630. private _imageProcessingObserver;
  57631. /**
  57632. * Attaches a new image processing configuration to the PBR Material.
  57633. * @param configuration (if null the scene configuration will be use)
  57634. */
  57635. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57636. /**
  57637. * Gets the image processing configuration used either in this material.
  57638. */
  57639. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57640. /**
  57641. * Sets the Default image processing configuration used either in the this material.
  57642. *
  57643. * If sets to null, the scene one is in use.
  57644. */
  57645. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57646. /**
  57647. * Gets wether the color curves effect is enabled.
  57648. */
  57649. get cameraColorCurvesEnabled(): boolean;
  57650. /**
  57651. * Sets wether the color curves effect is enabled.
  57652. */
  57653. set cameraColorCurvesEnabled(value: boolean);
  57654. /**
  57655. * Gets wether the color grading effect is enabled.
  57656. */
  57657. get cameraColorGradingEnabled(): boolean;
  57658. /**
  57659. * Gets wether the color grading effect is enabled.
  57660. */
  57661. set cameraColorGradingEnabled(value: boolean);
  57662. /**
  57663. * Gets wether tonemapping is enabled or not.
  57664. */
  57665. get cameraToneMappingEnabled(): boolean;
  57666. /**
  57667. * Sets wether tonemapping is enabled or not
  57668. */
  57669. set cameraToneMappingEnabled(value: boolean);
  57670. /**
  57671. * The camera exposure used on this material.
  57672. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57673. * This corresponds to a photographic exposure.
  57674. */
  57675. get cameraExposure(): float;
  57676. /**
  57677. * The camera exposure used on this material.
  57678. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57679. * This corresponds to a photographic exposure.
  57680. */
  57681. set cameraExposure(value: float);
  57682. /**
  57683. * Gets The camera contrast used on this material.
  57684. */
  57685. get cameraContrast(): float;
  57686. /**
  57687. * Sets The camera contrast used on this material.
  57688. */
  57689. set cameraContrast(value: float);
  57690. /**
  57691. * Gets the Color Grading 2D Lookup Texture.
  57692. */
  57693. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57694. /**
  57695. * Sets the Color Grading 2D Lookup Texture.
  57696. */
  57697. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57698. /**
  57699. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57700. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57701. * 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;
  57702. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57703. */
  57704. get cameraColorCurves(): Nullable<ColorCurves>;
  57705. /**
  57706. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57707. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57708. * 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;
  57709. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57710. */
  57711. set cameraColorCurves(value: Nullable<ColorCurves>);
  57712. /**
  57713. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57714. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57715. */
  57716. switchToBGR: boolean;
  57717. private _renderTargets;
  57718. private _reflectionControls;
  57719. private _white;
  57720. private _primaryShadowColor;
  57721. private _primaryHighlightColor;
  57722. /**
  57723. * Instantiates a Background Material in the given scene
  57724. * @param name The friendly name of the material
  57725. * @param scene The scene to add the material to
  57726. */
  57727. constructor(name: string, scene: Scene);
  57728. /**
  57729. * Gets a boolean indicating that current material needs to register RTT
  57730. */
  57731. get hasRenderTargetTextures(): boolean;
  57732. /**
  57733. * The entire material has been created in order to prevent overdraw.
  57734. * @returns false
  57735. */
  57736. needAlphaTesting(): boolean;
  57737. /**
  57738. * The entire material has been created in order to prevent overdraw.
  57739. * @returns true if blending is enable
  57740. */
  57741. needAlphaBlending(): boolean;
  57742. /**
  57743. * Checks wether the material is ready to be rendered for a given mesh.
  57744. * @param mesh The mesh to render
  57745. * @param subMesh The submesh to check against
  57746. * @param useInstances Specify wether or not the material is used with instances
  57747. * @returns true if all the dependencies are ready (Textures, Effects...)
  57748. */
  57749. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57750. /**
  57751. * Compute the primary color according to the chosen perceptual color.
  57752. */
  57753. private _computePrimaryColorFromPerceptualColor;
  57754. /**
  57755. * Compute the highlights and shadow colors according to their chosen levels.
  57756. */
  57757. private _computePrimaryColors;
  57758. /**
  57759. * Build the uniform buffer used in the material.
  57760. */
  57761. buildUniformLayout(): void;
  57762. /**
  57763. * Unbind the material.
  57764. */
  57765. unbind(): void;
  57766. /**
  57767. * Bind only the world matrix to the material.
  57768. * @param world The world matrix to bind.
  57769. */
  57770. bindOnlyWorldMatrix(world: Matrix): void;
  57771. /**
  57772. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57773. * @param world The world matrix to bind.
  57774. * @param subMesh The submesh to bind for.
  57775. */
  57776. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57777. /**
  57778. * Checks to see if a texture is used in the material.
  57779. * @param texture - Base texture to use.
  57780. * @returns - Boolean specifying if a texture is used in the material.
  57781. */
  57782. hasTexture(texture: BaseTexture): boolean;
  57783. /**
  57784. * Dispose the material.
  57785. * @param forceDisposeEffect Force disposal of the associated effect.
  57786. * @param forceDisposeTextures Force disposal of the associated textures.
  57787. */
  57788. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57789. /**
  57790. * Clones the material.
  57791. * @param name The cloned name.
  57792. * @returns The cloned material.
  57793. */
  57794. clone(name: string): BackgroundMaterial;
  57795. /**
  57796. * Serializes the current material to its JSON representation.
  57797. * @returns The JSON representation.
  57798. */
  57799. serialize(): any;
  57800. /**
  57801. * Gets the class name of the material
  57802. * @returns "BackgroundMaterial"
  57803. */
  57804. getClassName(): string;
  57805. /**
  57806. * Parse a JSON input to create back a background material.
  57807. * @param source The JSON data to parse
  57808. * @param scene The scene to create the parsed material in
  57809. * @param rootUrl The root url of the assets the material depends upon
  57810. * @returns the instantiated BackgroundMaterial.
  57811. */
  57812. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57813. }
  57814. }
  57815. declare module BABYLON {
  57816. /**
  57817. * Represents the different options available during the creation of
  57818. * a Environment helper.
  57819. *
  57820. * This can control the default ground, skybox and image processing setup of your scene.
  57821. */
  57822. export interface IEnvironmentHelperOptions {
  57823. /**
  57824. * Specifies whether or not to create a ground.
  57825. * True by default.
  57826. */
  57827. createGround: boolean;
  57828. /**
  57829. * Specifies the ground size.
  57830. * 15 by default.
  57831. */
  57832. groundSize: number;
  57833. /**
  57834. * The texture used on the ground for the main color.
  57835. * Comes from the BabylonJS CDN by default.
  57836. *
  57837. * Remarks: Can be either a texture or a url.
  57838. */
  57839. groundTexture: string | BaseTexture;
  57840. /**
  57841. * The color mixed in the ground texture by default.
  57842. * BabylonJS clearColor by default.
  57843. */
  57844. groundColor: Color3;
  57845. /**
  57846. * Specifies the ground opacity.
  57847. * 1 by default.
  57848. */
  57849. groundOpacity: number;
  57850. /**
  57851. * Enables the ground to receive shadows.
  57852. * True by default.
  57853. */
  57854. enableGroundShadow: boolean;
  57855. /**
  57856. * Helps preventing the shadow to be fully black on the ground.
  57857. * 0.5 by default.
  57858. */
  57859. groundShadowLevel: number;
  57860. /**
  57861. * Creates a mirror texture attach to the ground.
  57862. * false by default.
  57863. */
  57864. enableGroundMirror: boolean;
  57865. /**
  57866. * Specifies the ground mirror size ratio.
  57867. * 0.3 by default as the default kernel is 64.
  57868. */
  57869. groundMirrorSizeRatio: number;
  57870. /**
  57871. * Specifies the ground mirror blur kernel size.
  57872. * 64 by default.
  57873. */
  57874. groundMirrorBlurKernel: number;
  57875. /**
  57876. * Specifies the ground mirror visibility amount.
  57877. * 1 by default
  57878. */
  57879. groundMirrorAmount: number;
  57880. /**
  57881. * Specifies the ground mirror reflectance weight.
  57882. * This uses the standard weight of the background material to setup the fresnel effect
  57883. * of the mirror.
  57884. * 1 by default.
  57885. */
  57886. groundMirrorFresnelWeight: number;
  57887. /**
  57888. * Specifies the ground mirror Falloff distance.
  57889. * This can helps reducing the size of the reflection.
  57890. * 0 by Default.
  57891. */
  57892. groundMirrorFallOffDistance: number;
  57893. /**
  57894. * Specifies the ground mirror texture type.
  57895. * Unsigned Int by Default.
  57896. */
  57897. groundMirrorTextureType: number;
  57898. /**
  57899. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57900. * the shown objects.
  57901. */
  57902. groundYBias: number;
  57903. /**
  57904. * Specifies whether or not to create a skybox.
  57905. * True by default.
  57906. */
  57907. createSkybox: boolean;
  57908. /**
  57909. * Specifies the skybox size.
  57910. * 20 by default.
  57911. */
  57912. skyboxSize: number;
  57913. /**
  57914. * The texture used on the skybox for the main color.
  57915. * Comes from the BabylonJS CDN by default.
  57916. *
  57917. * Remarks: Can be either a texture or a url.
  57918. */
  57919. skyboxTexture: string | BaseTexture;
  57920. /**
  57921. * The color mixed in the skybox texture by default.
  57922. * BabylonJS clearColor by default.
  57923. */
  57924. skyboxColor: Color3;
  57925. /**
  57926. * The background rotation around the Y axis of the scene.
  57927. * This helps aligning the key lights of your scene with the background.
  57928. * 0 by default.
  57929. */
  57930. backgroundYRotation: number;
  57931. /**
  57932. * Compute automatically the size of the elements to best fit with the scene.
  57933. */
  57934. sizeAuto: boolean;
  57935. /**
  57936. * Default position of the rootMesh if autoSize is not true.
  57937. */
  57938. rootPosition: Vector3;
  57939. /**
  57940. * Sets up the image processing in the scene.
  57941. * true by default.
  57942. */
  57943. setupImageProcessing: boolean;
  57944. /**
  57945. * The texture used as your environment texture in the scene.
  57946. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57947. *
  57948. * Remarks: Can be either a texture or a url.
  57949. */
  57950. environmentTexture: string | BaseTexture;
  57951. /**
  57952. * The value of the exposure to apply to the scene.
  57953. * 0.6 by default if setupImageProcessing is true.
  57954. */
  57955. cameraExposure: number;
  57956. /**
  57957. * The value of the contrast to apply to the scene.
  57958. * 1.6 by default if setupImageProcessing is true.
  57959. */
  57960. cameraContrast: number;
  57961. /**
  57962. * Specifies whether or not tonemapping should be enabled in the scene.
  57963. * true by default if setupImageProcessing is true.
  57964. */
  57965. toneMappingEnabled: boolean;
  57966. }
  57967. /**
  57968. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57969. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57970. * It also helps with the default setup of your imageProcessing configuration.
  57971. */
  57972. export class EnvironmentHelper {
  57973. /**
  57974. * Default ground texture URL.
  57975. */
  57976. private static _groundTextureCDNUrl;
  57977. /**
  57978. * Default skybox texture URL.
  57979. */
  57980. private static _skyboxTextureCDNUrl;
  57981. /**
  57982. * Default environment texture URL.
  57983. */
  57984. private static _environmentTextureCDNUrl;
  57985. /**
  57986. * Creates the default options for the helper.
  57987. */
  57988. private static _getDefaultOptions;
  57989. private _rootMesh;
  57990. /**
  57991. * Gets the root mesh created by the helper.
  57992. */
  57993. get rootMesh(): Mesh;
  57994. private _skybox;
  57995. /**
  57996. * Gets the skybox created by the helper.
  57997. */
  57998. get skybox(): Nullable<Mesh>;
  57999. private _skyboxTexture;
  58000. /**
  58001. * Gets the skybox texture created by the helper.
  58002. */
  58003. get skyboxTexture(): Nullable<BaseTexture>;
  58004. private _skyboxMaterial;
  58005. /**
  58006. * Gets the skybox material created by the helper.
  58007. */
  58008. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58009. private _ground;
  58010. /**
  58011. * Gets the ground mesh created by the helper.
  58012. */
  58013. get ground(): Nullable<Mesh>;
  58014. private _groundTexture;
  58015. /**
  58016. * Gets the ground texture created by the helper.
  58017. */
  58018. get groundTexture(): Nullable<BaseTexture>;
  58019. private _groundMirror;
  58020. /**
  58021. * Gets the ground mirror created by the helper.
  58022. */
  58023. get groundMirror(): Nullable<MirrorTexture>;
  58024. /**
  58025. * Gets the ground mirror render list to helps pushing the meshes
  58026. * you wish in the ground reflection.
  58027. */
  58028. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58029. private _groundMaterial;
  58030. /**
  58031. * Gets the ground material created by the helper.
  58032. */
  58033. get groundMaterial(): Nullable<BackgroundMaterial>;
  58034. /**
  58035. * Stores the creation options.
  58036. */
  58037. private readonly _scene;
  58038. private _options;
  58039. /**
  58040. * This observable will be notified with any error during the creation of the environment,
  58041. * mainly texture creation errors.
  58042. */
  58043. onErrorObservable: Observable<{
  58044. message?: string;
  58045. exception?: any;
  58046. }>;
  58047. /**
  58048. * constructor
  58049. * @param options Defines the options we want to customize the helper
  58050. * @param scene The scene to add the material to
  58051. */
  58052. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58053. /**
  58054. * Updates the background according to the new options
  58055. * @param options
  58056. */
  58057. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58058. /**
  58059. * Sets the primary color of all the available elements.
  58060. * @param color the main color to affect to the ground and the background
  58061. */
  58062. setMainColor(color: Color3): void;
  58063. /**
  58064. * Setup the image processing according to the specified options.
  58065. */
  58066. private _setupImageProcessing;
  58067. /**
  58068. * Setup the environment texture according to the specified options.
  58069. */
  58070. private _setupEnvironmentTexture;
  58071. /**
  58072. * Setup the background according to the specified options.
  58073. */
  58074. private _setupBackground;
  58075. /**
  58076. * Get the scene sizes according to the setup.
  58077. */
  58078. private _getSceneSize;
  58079. /**
  58080. * Setup the ground according to the specified options.
  58081. */
  58082. private _setupGround;
  58083. /**
  58084. * Setup the ground material according to the specified options.
  58085. */
  58086. private _setupGroundMaterial;
  58087. /**
  58088. * Setup the ground diffuse texture according to the specified options.
  58089. */
  58090. private _setupGroundDiffuseTexture;
  58091. /**
  58092. * Setup the ground mirror texture according to the specified options.
  58093. */
  58094. private _setupGroundMirrorTexture;
  58095. /**
  58096. * Setup the ground to receive the mirror texture.
  58097. */
  58098. private _setupMirrorInGroundMaterial;
  58099. /**
  58100. * Setup the skybox according to the specified options.
  58101. */
  58102. private _setupSkybox;
  58103. /**
  58104. * Setup the skybox material according to the specified options.
  58105. */
  58106. private _setupSkyboxMaterial;
  58107. /**
  58108. * Setup the skybox reflection texture according to the specified options.
  58109. */
  58110. private _setupSkyboxReflectionTexture;
  58111. private _errorHandler;
  58112. /**
  58113. * Dispose all the elements created by the Helper.
  58114. */
  58115. dispose(): void;
  58116. }
  58117. }
  58118. declare module BABYLON {
  58119. /**
  58120. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58121. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58122. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58123. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58124. */
  58125. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58126. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58127. /**
  58128. * Define the source as a Monoscopic panoramic 360/180.
  58129. */
  58130. static readonly MODE_MONOSCOPIC: number;
  58131. /**
  58132. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58133. */
  58134. static readonly MODE_TOPBOTTOM: number;
  58135. /**
  58136. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58137. */
  58138. static readonly MODE_SIDEBYSIDE: number;
  58139. private _halfDome;
  58140. private _crossEye;
  58141. protected _useDirectMapping: boolean;
  58142. /**
  58143. * The texture being displayed on the sphere
  58144. */
  58145. protected _texture: T;
  58146. /**
  58147. * Gets the texture being displayed on the sphere
  58148. */
  58149. get texture(): T;
  58150. /**
  58151. * Sets the texture being displayed on the sphere
  58152. */
  58153. set texture(newTexture: T);
  58154. /**
  58155. * The skybox material
  58156. */
  58157. protected _material: BackgroundMaterial;
  58158. /**
  58159. * The surface used for the dome
  58160. */
  58161. protected _mesh: Mesh;
  58162. /**
  58163. * Gets the mesh used for the dome.
  58164. */
  58165. get mesh(): Mesh;
  58166. /**
  58167. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58168. */
  58169. private _halfDomeMask;
  58170. /**
  58171. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58172. * Also see the options.resolution property.
  58173. */
  58174. get fovMultiplier(): number;
  58175. set fovMultiplier(value: number);
  58176. protected _textureMode: number;
  58177. /**
  58178. * Gets or set the current texture mode for the texture. It can be:
  58179. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58180. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58181. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58182. */
  58183. get textureMode(): number;
  58184. /**
  58185. * Sets the current texture mode for the texture. It can be:
  58186. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58187. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58188. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58189. */
  58190. set textureMode(value: number);
  58191. /**
  58192. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58193. */
  58194. get halfDome(): boolean;
  58195. /**
  58196. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58197. */
  58198. set halfDome(enabled: boolean);
  58199. /**
  58200. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58201. */
  58202. set crossEye(enabled: boolean);
  58203. /**
  58204. * Is it a cross-eye texture?
  58205. */
  58206. get crossEye(): boolean;
  58207. /**
  58208. * The background material of this dome.
  58209. */
  58210. get material(): BackgroundMaterial;
  58211. /**
  58212. * Oberserver used in Stereoscopic VR Mode.
  58213. */
  58214. private _onBeforeCameraRenderObserver;
  58215. /**
  58216. * Observable raised when an error occured while loading the 360 image
  58217. */
  58218. onLoadErrorObservable: Observable<string>;
  58219. /**
  58220. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58221. * @param name Element's name, child elements will append suffixes for their own names.
  58222. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58223. * @param options An object containing optional or exposed sub element properties
  58224. */
  58225. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58226. resolution?: number;
  58227. clickToPlay?: boolean;
  58228. autoPlay?: boolean;
  58229. loop?: boolean;
  58230. size?: number;
  58231. poster?: string;
  58232. faceForward?: boolean;
  58233. useDirectMapping?: boolean;
  58234. halfDomeMode?: boolean;
  58235. crossEyeMode?: boolean;
  58236. generateMipMaps?: boolean;
  58237. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58238. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58239. protected _changeTextureMode(value: number): void;
  58240. /**
  58241. * Releases resources associated with this node.
  58242. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58243. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58244. */
  58245. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58246. }
  58247. }
  58248. declare module BABYLON {
  58249. /**
  58250. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58251. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58252. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58253. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58254. */
  58255. export class PhotoDome extends TextureDome<Texture> {
  58256. /**
  58257. * Define the image as a Monoscopic panoramic 360 image.
  58258. */
  58259. static readonly MODE_MONOSCOPIC: number;
  58260. /**
  58261. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58262. */
  58263. static readonly MODE_TOPBOTTOM: number;
  58264. /**
  58265. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58266. */
  58267. static readonly MODE_SIDEBYSIDE: number;
  58268. /**
  58269. * Gets or sets the texture being displayed on the sphere
  58270. */
  58271. get photoTexture(): Texture;
  58272. /**
  58273. * sets the texture being displayed on the sphere
  58274. */
  58275. set photoTexture(value: Texture);
  58276. /**
  58277. * Gets the current video mode for the video. It can be:
  58278. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58279. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58280. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58281. */
  58282. get imageMode(): number;
  58283. /**
  58284. * Sets the current video mode for the video. It can be:
  58285. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58286. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58287. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58288. */
  58289. set imageMode(value: number);
  58290. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58291. }
  58292. }
  58293. declare module BABYLON {
  58294. /**
  58295. * Direct draw surface info
  58296. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58297. */
  58298. export interface DDSInfo {
  58299. /**
  58300. * Width of the texture
  58301. */
  58302. width: number;
  58303. /**
  58304. * Width of the texture
  58305. */
  58306. height: number;
  58307. /**
  58308. * Number of Mipmaps for the texture
  58309. * @see https://en.wikipedia.org/wiki/Mipmap
  58310. */
  58311. mipmapCount: number;
  58312. /**
  58313. * If the textures format is a known fourCC format
  58314. * @see https://www.fourcc.org/
  58315. */
  58316. isFourCC: boolean;
  58317. /**
  58318. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58319. */
  58320. isRGB: boolean;
  58321. /**
  58322. * If the texture is a lumincance format
  58323. */
  58324. isLuminance: boolean;
  58325. /**
  58326. * If this is a cube texture
  58327. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58328. */
  58329. isCube: boolean;
  58330. /**
  58331. * If the texture is a compressed format eg. FOURCC_DXT1
  58332. */
  58333. isCompressed: boolean;
  58334. /**
  58335. * The dxgiFormat of the texture
  58336. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58337. */
  58338. dxgiFormat: number;
  58339. /**
  58340. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58341. */
  58342. textureType: number;
  58343. /**
  58344. * Sphericle polynomial created for the dds texture
  58345. */
  58346. sphericalPolynomial?: SphericalPolynomial;
  58347. }
  58348. /**
  58349. * Class used to provide DDS decompression tools
  58350. */
  58351. export class DDSTools {
  58352. /**
  58353. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58354. */
  58355. static StoreLODInAlphaChannel: boolean;
  58356. /**
  58357. * Gets DDS information from an array buffer
  58358. * @param data defines the array buffer view to read data from
  58359. * @returns the DDS information
  58360. */
  58361. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58362. private static _FloatView;
  58363. private static _Int32View;
  58364. private static _ToHalfFloat;
  58365. private static _FromHalfFloat;
  58366. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58367. private static _GetHalfFloatRGBAArrayBuffer;
  58368. private static _GetFloatRGBAArrayBuffer;
  58369. private static _GetFloatAsUIntRGBAArrayBuffer;
  58370. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58371. private static _GetRGBAArrayBuffer;
  58372. private static _ExtractLongWordOrder;
  58373. private static _GetRGBArrayBuffer;
  58374. private static _GetLuminanceArrayBuffer;
  58375. /**
  58376. * Uploads DDS Levels to a Babylon Texture
  58377. * @hidden
  58378. */
  58379. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58380. }
  58381. interface ThinEngine {
  58382. /**
  58383. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58384. * @param rootUrl defines the url where the file to load is located
  58385. * @param scene defines the current scene
  58386. * @param lodScale defines scale to apply to the mip map selection
  58387. * @param lodOffset defines offset to apply to the mip map selection
  58388. * @param onLoad defines an optional callback raised when the texture is loaded
  58389. * @param onError defines an optional callback raised if there is an issue to load the texture
  58390. * @param format defines the format of the data
  58391. * @param forcedExtension defines the extension to use to pick the right loader
  58392. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58393. * @returns the cube texture as an InternalTexture
  58394. */
  58395. 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;
  58396. }
  58397. }
  58398. declare module BABYLON {
  58399. /**
  58400. * Implementation of the DDS Texture Loader.
  58401. * @hidden
  58402. */
  58403. export class _DDSTextureLoader implements IInternalTextureLoader {
  58404. /**
  58405. * Defines wether the loader supports cascade loading the different faces.
  58406. */
  58407. readonly supportCascades: boolean;
  58408. /**
  58409. * This returns if the loader support the current file information.
  58410. * @param extension defines the file extension of the file being loaded
  58411. * @returns true if the loader can load the specified file
  58412. */
  58413. canLoad(extension: string): boolean;
  58414. /**
  58415. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58416. * @param data contains the texture data
  58417. * @param texture defines the BabylonJS internal texture
  58418. * @param createPolynomials will be true if polynomials have been requested
  58419. * @param onLoad defines the callback to trigger once the texture is ready
  58420. * @param onError defines the callback to trigger in case of error
  58421. */
  58422. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58423. /**
  58424. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58425. * @param data contains the texture data
  58426. * @param texture defines the BabylonJS internal texture
  58427. * @param callback defines the method to call once ready to upload
  58428. */
  58429. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58430. }
  58431. }
  58432. declare module BABYLON {
  58433. /**
  58434. * Implementation of the ENV Texture Loader.
  58435. * @hidden
  58436. */
  58437. export class _ENVTextureLoader implements IInternalTextureLoader {
  58438. /**
  58439. * Defines wether the loader supports cascade loading the different faces.
  58440. */
  58441. readonly supportCascades: boolean;
  58442. /**
  58443. * This returns if the loader support the current file information.
  58444. * @param extension defines the file extension of the file being loaded
  58445. * @returns true if the loader can load the specified file
  58446. */
  58447. canLoad(extension: string): boolean;
  58448. /**
  58449. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58450. * @param data contains the texture data
  58451. * @param texture defines the BabylonJS internal texture
  58452. * @param createPolynomials will be true if polynomials have been requested
  58453. * @param onLoad defines the callback to trigger once the texture is ready
  58454. * @param onError defines the callback to trigger in case of error
  58455. */
  58456. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58457. /**
  58458. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58459. * @param data contains the texture data
  58460. * @param texture defines the BabylonJS internal texture
  58461. * @param callback defines the method to call once ready to upload
  58462. */
  58463. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58464. }
  58465. }
  58466. declare module BABYLON {
  58467. /**
  58468. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58469. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58470. */
  58471. export class KhronosTextureContainer {
  58472. /** contents of the KTX container file */
  58473. data: ArrayBufferView;
  58474. private static HEADER_LEN;
  58475. private static COMPRESSED_2D;
  58476. private static COMPRESSED_3D;
  58477. private static TEX_2D;
  58478. private static TEX_3D;
  58479. /**
  58480. * Gets the openGL type
  58481. */
  58482. glType: number;
  58483. /**
  58484. * Gets the openGL type size
  58485. */
  58486. glTypeSize: number;
  58487. /**
  58488. * Gets the openGL format
  58489. */
  58490. glFormat: number;
  58491. /**
  58492. * Gets the openGL internal format
  58493. */
  58494. glInternalFormat: number;
  58495. /**
  58496. * Gets the base internal format
  58497. */
  58498. glBaseInternalFormat: number;
  58499. /**
  58500. * Gets image width in pixel
  58501. */
  58502. pixelWidth: number;
  58503. /**
  58504. * Gets image height in pixel
  58505. */
  58506. pixelHeight: number;
  58507. /**
  58508. * Gets image depth in pixels
  58509. */
  58510. pixelDepth: number;
  58511. /**
  58512. * Gets the number of array elements
  58513. */
  58514. numberOfArrayElements: number;
  58515. /**
  58516. * Gets the number of faces
  58517. */
  58518. numberOfFaces: number;
  58519. /**
  58520. * Gets the number of mipmap levels
  58521. */
  58522. numberOfMipmapLevels: number;
  58523. /**
  58524. * Gets the bytes of key value data
  58525. */
  58526. bytesOfKeyValueData: number;
  58527. /**
  58528. * Gets the load type
  58529. */
  58530. loadType: number;
  58531. /**
  58532. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58533. */
  58534. isInvalid: boolean;
  58535. /**
  58536. * Creates a new KhronosTextureContainer
  58537. * @param data contents of the KTX container file
  58538. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58539. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58540. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58541. */
  58542. constructor(
  58543. /** contents of the KTX container file */
  58544. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58545. /**
  58546. * Uploads KTX content to a Babylon Texture.
  58547. * It is assumed that the texture has already been created & is currently bound
  58548. * @hidden
  58549. */
  58550. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58551. private _upload2DCompressedLevels;
  58552. /**
  58553. * Checks if the given data starts with a KTX file identifier.
  58554. * @param data the data to check
  58555. * @returns true if the data is a KTX file or false otherwise
  58556. */
  58557. static IsValid(data: ArrayBufferView): boolean;
  58558. }
  58559. }
  58560. declare module BABYLON {
  58561. /**
  58562. * Helper class to push actions to a pool of workers.
  58563. */
  58564. export class WorkerPool implements IDisposable {
  58565. private _workerInfos;
  58566. private _pendingActions;
  58567. /**
  58568. * Constructor
  58569. * @param workers Array of workers to use for actions
  58570. */
  58571. constructor(workers: Array<Worker>);
  58572. /**
  58573. * Terminates all workers and clears any pending actions.
  58574. */
  58575. dispose(): void;
  58576. /**
  58577. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58578. * pended until a worker has completed its action.
  58579. * @param action The action to perform. Call onComplete when the action is complete.
  58580. */
  58581. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58582. private _execute;
  58583. }
  58584. }
  58585. declare module BABYLON {
  58586. /**
  58587. * Class for loading KTX2 files
  58588. */
  58589. export class KhronosTextureContainer2 {
  58590. private static _WorkerPoolPromise?;
  58591. private static _Initialized;
  58592. private static _Ktx2Decoder;
  58593. /**
  58594. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58595. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58596. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58597. * Urls you can change:
  58598. * URLConfig.jsDecoderModule
  58599. * URLConfig.wasmUASTCToASTC
  58600. * URLConfig.wasmUASTCToBC7
  58601. * URLConfig.jsMSCTranscoder
  58602. * URLConfig.wasmMSCTranscoder
  58603. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58604. */
  58605. static URLConfig: {
  58606. jsDecoderModule: string;
  58607. wasmUASTCToASTC: null;
  58608. wasmUASTCToBC7: null;
  58609. jsMSCTranscoder: null;
  58610. wasmMSCTranscoder: null;
  58611. };
  58612. /**
  58613. * Default number of workers used to handle data decoding
  58614. */
  58615. static DefaultNumWorkers: number;
  58616. private static GetDefaultNumWorkers;
  58617. private _engine;
  58618. private static _CreateWorkerPool;
  58619. /**
  58620. * Constructor
  58621. * @param engine The engine to use
  58622. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58623. */
  58624. constructor(engine: ThinEngine, numWorkers?: number);
  58625. /** @hidden */
  58626. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  58627. /**
  58628. * Stop all async operations and release resources.
  58629. */
  58630. dispose(): void;
  58631. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  58632. /**
  58633. * Checks if the given data starts with a KTX2 file identifier.
  58634. * @param data the data to check
  58635. * @returns true if the data is a KTX2 file or false otherwise
  58636. */
  58637. static IsValid(data: ArrayBufferView): boolean;
  58638. }
  58639. }
  58640. declare module BABYLON {
  58641. /**
  58642. * Implementation of the KTX Texture Loader.
  58643. * @hidden
  58644. */
  58645. export class _KTXTextureLoader implements IInternalTextureLoader {
  58646. /**
  58647. * Defines wether the loader supports cascade loading the different faces.
  58648. */
  58649. readonly supportCascades: boolean;
  58650. /**
  58651. * This returns if the loader support the current file information.
  58652. * @param extension defines the file extension of the file being loaded
  58653. * @param mimeType defines the optional mime type of the file being loaded
  58654. * @returns true if the loader can load the specified file
  58655. */
  58656. canLoad(extension: string, mimeType?: string): boolean;
  58657. /**
  58658. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58659. * @param data contains the texture data
  58660. * @param texture defines the BabylonJS internal texture
  58661. * @param createPolynomials will be true if polynomials have been requested
  58662. * @param onLoad defines the callback to trigger once the texture is ready
  58663. * @param onError defines the callback to trigger in case of error
  58664. */
  58665. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58666. /**
  58667. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58668. * @param data contains the texture data
  58669. * @param texture defines the BabylonJS internal texture
  58670. * @param callback defines the method to call once ready to upload
  58671. */
  58672. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  58673. }
  58674. }
  58675. declare module BABYLON {
  58676. /** @hidden */
  58677. export var _forceSceneHelpersToBundle: boolean;
  58678. interface Scene {
  58679. /**
  58680. * Creates a default light for the scene.
  58681. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58682. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58683. */
  58684. createDefaultLight(replace?: boolean): void;
  58685. /**
  58686. * Creates a default camera for the scene.
  58687. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58688. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58689. * @param replace has default false, when true replaces the active camera in the scene
  58690. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58691. */
  58692. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58693. /**
  58694. * Creates a default camera and a default light.
  58695. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58696. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58697. * @param replace has the default false, when true replaces the active camera/light in the scene
  58698. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58699. */
  58700. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58701. /**
  58702. * Creates a new sky box
  58703. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58704. * @param environmentTexture defines the texture to use as environment texture
  58705. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58706. * @param scale defines the overall scale of the skybox
  58707. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58708. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58709. * @returns a new mesh holding the sky box
  58710. */
  58711. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58712. /**
  58713. * Creates a new environment
  58714. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58715. * @param options defines the options you can use to configure the environment
  58716. * @returns the new EnvironmentHelper
  58717. */
  58718. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58719. /**
  58720. * Creates a new VREXperienceHelper
  58721. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58722. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58723. * @returns a new VREXperienceHelper
  58724. */
  58725. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58726. /**
  58727. * Creates a new WebXRDefaultExperience
  58728. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58729. * @param options experience options
  58730. * @returns a promise for a new WebXRDefaultExperience
  58731. */
  58732. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58733. }
  58734. }
  58735. declare module BABYLON {
  58736. /**
  58737. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58738. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58739. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58740. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58741. */
  58742. export class VideoDome extends TextureDome<VideoTexture> {
  58743. /**
  58744. * Define the video source as a Monoscopic panoramic 360 video.
  58745. */
  58746. static readonly MODE_MONOSCOPIC: number;
  58747. /**
  58748. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58749. */
  58750. static readonly MODE_TOPBOTTOM: number;
  58751. /**
  58752. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58753. */
  58754. static readonly MODE_SIDEBYSIDE: number;
  58755. /**
  58756. * Get the video texture associated with this video dome
  58757. */
  58758. get videoTexture(): VideoTexture;
  58759. /**
  58760. * Get the video mode of this dome
  58761. */
  58762. get videoMode(): number;
  58763. /**
  58764. * Set the video mode of this dome.
  58765. * @see textureMode
  58766. */
  58767. set videoMode(value: number);
  58768. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58769. }
  58770. }
  58771. declare module BABYLON {
  58772. /**
  58773. * This class can be used to get instrumentation data from a Babylon engine
  58774. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58775. */
  58776. export class EngineInstrumentation implements IDisposable {
  58777. /**
  58778. * Define the instrumented engine.
  58779. */
  58780. engine: Engine;
  58781. private _captureGPUFrameTime;
  58782. private _gpuFrameTimeToken;
  58783. private _gpuFrameTime;
  58784. private _captureShaderCompilationTime;
  58785. private _shaderCompilationTime;
  58786. private _onBeginFrameObserver;
  58787. private _onEndFrameObserver;
  58788. private _onBeforeShaderCompilationObserver;
  58789. private _onAfterShaderCompilationObserver;
  58790. /**
  58791. * Gets the perf counter used for GPU frame time
  58792. */
  58793. get gpuFrameTimeCounter(): PerfCounter;
  58794. /**
  58795. * Gets the GPU frame time capture status
  58796. */
  58797. get captureGPUFrameTime(): boolean;
  58798. /**
  58799. * Enable or disable the GPU frame time capture
  58800. */
  58801. set captureGPUFrameTime(value: boolean);
  58802. /**
  58803. * Gets the perf counter used for shader compilation time
  58804. */
  58805. get shaderCompilationTimeCounter(): PerfCounter;
  58806. /**
  58807. * Gets the shader compilation time capture status
  58808. */
  58809. get captureShaderCompilationTime(): boolean;
  58810. /**
  58811. * Enable or disable the shader compilation time capture
  58812. */
  58813. set captureShaderCompilationTime(value: boolean);
  58814. /**
  58815. * Instantiates a new engine instrumentation.
  58816. * This class can be used to get instrumentation data from a Babylon engine
  58817. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58818. * @param engine Defines the engine to instrument
  58819. */
  58820. constructor(
  58821. /**
  58822. * Define the instrumented engine.
  58823. */
  58824. engine: Engine);
  58825. /**
  58826. * Dispose and release associated resources.
  58827. */
  58828. dispose(): void;
  58829. }
  58830. }
  58831. declare module BABYLON {
  58832. /**
  58833. * This class can be used to get instrumentation data from a Babylon engine
  58834. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58835. */
  58836. export class SceneInstrumentation implements IDisposable {
  58837. /**
  58838. * Defines the scene to instrument
  58839. */
  58840. scene: Scene;
  58841. private _captureActiveMeshesEvaluationTime;
  58842. private _activeMeshesEvaluationTime;
  58843. private _captureRenderTargetsRenderTime;
  58844. private _renderTargetsRenderTime;
  58845. private _captureFrameTime;
  58846. private _frameTime;
  58847. private _captureRenderTime;
  58848. private _renderTime;
  58849. private _captureInterFrameTime;
  58850. private _interFrameTime;
  58851. private _captureParticlesRenderTime;
  58852. private _particlesRenderTime;
  58853. private _captureSpritesRenderTime;
  58854. private _spritesRenderTime;
  58855. private _capturePhysicsTime;
  58856. private _physicsTime;
  58857. private _captureAnimationsTime;
  58858. private _animationsTime;
  58859. private _captureCameraRenderTime;
  58860. private _cameraRenderTime;
  58861. private _onBeforeActiveMeshesEvaluationObserver;
  58862. private _onAfterActiveMeshesEvaluationObserver;
  58863. private _onBeforeRenderTargetsRenderObserver;
  58864. private _onAfterRenderTargetsRenderObserver;
  58865. private _onAfterRenderObserver;
  58866. private _onBeforeDrawPhaseObserver;
  58867. private _onAfterDrawPhaseObserver;
  58868. private _onBeforeAnimationsObserver;
  58869. private _onBeforeParticlesRenderingObserver;
  58870. private _onAfterParticlesRenderingObserver;
  58871. private _onBeforeSpritesRenderingObserver;
  58872. private _onAfterSpritesRenderingObserver;
  58873. private _onBeforePhysicsObserver;
  58874. private _onAfterPhysicsObserver;
  58875. private _onAfterAnimationsObserver;
  58876. private _onBeforeCameraRenderObserver;
  58877. private _onAfterCameraRenderObserver;
  58878. /**
  58879. * Gets the perf counter used for active meshes evaluation time
  58880. */
  58881. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58882. /**
  58883. * Gets the active meshes evaluation time capture status
  58884. */
  58885. get captureActiveMeshesEvaluationTime(): boolean;
  58886. /**
  58887. * Enable or disable the active meshes evaluation time capture
  58888. */
  58889. set captureActiveMeshesEvaluationTime(value: boolean);
  58890. /**
  58891. * Gets the perf counter used for render targets render time
  58892. */
  58893. get renderTargetsRenderTimeCounter(): PerfCounter;
  58894. /**
  58895. * Gets the render targets render time capture status
  58896. */
  58897. get captureRenderTargetsRenderTime(): boolean;
  58898. /**
  58899. * Enable or disable the render targets render time capture
  58900. */
  58901. set captureRenderTargetsRenderTime(value: boolean);
  58902. /**
  58903. * Gets the perf counter used for particles render time
  58904. */
  58905. get particlesRenderTimeCounter(): PerfCounter;
  58906. /**
  58907. * Gets the particles render time capture status
  58908. */
  58909. get captureParticlesRenderTime(): boolean;
  58910. /**
  58911. * Enable or disable the particles render time capture
  58912. */
  58913. set captureParticlesRenderTime(value: boolean);
  58914. /**
  58915. * Gets the perf counter used for sprites render time
  58916. */
  58917. get spritesRenderTimeCounter(): PerfCounter;
  58918. /**
  58919. * Gets the sprites render time capture status
  58920. */
  58921. get captureSpritesRenderTime(): boolean;
  58922. /**
  58923. * Enable or disable the sprites render time capture
  58924. */
  58925. set captureSpritesRenderTime(value: boolean);
  58926. /**
  58927. * Gets the perf counter used for physics time
  58928. */
  58929. get physicsTimeCounter(): PerfCounter;
  58930. /**
  58931. * Gets the physics time capture status
  58932. */
  58933. get capturePhysicsTime(): boolean;
  58934. /**
  58935. * Enable or disable the physics time capture
  58936. */
  58937. set capturePhysicsTime(value: boolean);
  58938. /**
  58939. * Gets the perf counter used for animations time
  58940. */
  58941. get animationsTimeCounter(): PerfCounter;
  58942. /**
  58943. * Gets the animations time capture status
  58944. */
  58945. get captureAnimationsTime(): boolean;
  58946. /**
  58947. * Enable or disable the animations time capture
  58948. */
  58949. set captureAnimationsTime(value: boolean);
  58950. /**
  58951. * Gets the perf counter used for frame time capture
  58952. */
  58953. get frameTimeCounter(): PerfCounter;
  58954. /**
  58955. * Gets the frame time capture status
  58956. */
  58957. get captureFrameTime(): boolean;
  58958. /**
  58959. * Enable or disable the frame time capture
  58960. */
  58961. set captureFrameTime(value: boolean);
  58962. /**
  58963. * Gets the perf counter used for inter-frames time capture
  58964. */
  58965. get interFrameTimeCounter(): PerfCounter;
  58966. /**
  58967. * Gets the inter-frames time capture status
  58968. */
  58969. get captureInterFrameTime(): boolean;
  58970. /**
  58971. * Enable or disable the inter-frames time capture
  58972. */
  58973. set captureInterFrameTime(value: boolean);
  58974. /**
  58975. * Gets the perf counter used for render time capture
  58976. */
  58977. get renderTimeCounter(): PerfCounter;
  58978. /**
  58979. * Gets the render time capture status
  58980. */
  58981. get captureRenderTime(): boolean;
  58982. /**
  58983. * Enable or disable the render time capture
  58984. */
  58985. set captureRenderTime(value: boolean);
  58986. /**
  58987. * Gets the perf counter used for camera render time capture
  58988. */
  58989. get cameraRenderTimeCounter(): PerfCounter;
  58990. /**
  58991. * Gets the camera render time capture status
  58992. */
  58993. get captureCameraRenderTime(): boolean;
  58994. /**
  58995. * Enable or disable the camera render time capture
  58996. */
  58997. set captureCameraRenderTime(value: boolean);
  58998. /**
  58999. * Gets the perf counter used for draw calls
  59000. */
  59001. get drawCallsCounter(): PerfCounter;
  59002. /**
  59003. * Instantiates a new scene instrumentation.
  59004. * This class can be used to get instrumentation data from a Babylon engine
  59005. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59006. * @param scene Defines the scene to instrument
  59007. */
  59008. constructor(
  59009. /**
  59010. * Defines the scene to instrument
  59011. */
  59012. scene: Scene);
  59013. /**
  59014. * Dispose and release associated resources.
  59015. */
  59016. dispose(): void;
  59017. }
  59018. }
  59019. declare module BABYLON {
  59020. /** @hidden */
  59021. export var glowMapGenerationPixelShader: {
  59022. name: string;
  59023. shader: string;
  59024. };
  59025. }
  59026. declare module BABYLON {
  59027. /** @hidden */
  59028. export var glowMapGenerationVertexShader: {
  59029. name: string;
  59030. shader: string;
  59031. };
  59032. }
  59033. declare module BABYLON {
  59034. /**
  59035. * Effect layer options. This helps customizing the behaviour
  59036. * of the effect layer.
  59037. */
  59038. export interface IEffectLayerOptions {
  59039. /**
  59040. * Multiplication factor apply to the canvas size to compute the render target size
  59041. * used to generated the objects (the smaller the faster).
  59042. */
  59043. mainTextureRatio: number;
  59044. /**
  59045. * Enforces a fixed size texture to ensure effect stability across devices.
  59046. */
  59047. mainTextureFixedSize?: number;
  59048. /**
  59049. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59050. */
  59051. alphaBlendingMode: number;
  59052. /**
  59053. * The camera attached to the layer.
  59054. */
  59055. camera: Nullable<Camera>;
  59056. /**
  59057. * The rendering group to draw the layer in.
  59058. */
  59059. renderingGroupId: number;
  59060. }
  59061. /**
  59062. * The effect layer Helps adding post process effect blended with the main pass.
  59063. *
  59064. * This can be for instance use to generate glow or higlight effects on the scene.
  59065. *
  59066. * The effect layer class can not be used directly and is intented to inherited from to be
  59067. * customized per effects.
  59068. */
  59069. export abstract class EffectLayer {
  59070. private _vertexBuffers;
  59071. private _indexBuffer;
  59072. private _cachedDefines;
  59073. private _effectLayerMapGenerationEffect;
  59074. private _effectLayerOptions;
  59075. private _mergeEffect;
  59076. protected _scene: Scene;
  59077. protected _engine: Engine;
  59078. protected _maxSize: number;
  59079. protected _mainTextureDesiredSize: ISize;
  59080. protected _mainTexture: RenderTargetTexture;
  59081. protected _shouldRender: boolean;
  59082. protected _postProcesses: PostProcess[];
  59083. protected _textures: BaseTexture[];
  59084. protected _emissiveTextureAndColor: {
  59085. texture: Nullable<BaseTexture>;
  59086. color: Color4;
  59087. };
  59088. /**
  59089. * The name of the layer
  59090. */
  59091. name: string;
  59092. /**
  59093. * The clear color of the texture used to generate the glow map.
  59094. */
  59095. neutralColor: Color4;
  59096. /**
  59097. * Specifies whether the highlight layer is enabled or not.
  59098. */
  59099. isEnabled: boolean;
  59100. /**
  59101. * Gets the camera attached to the layer.
  59102. */
  59103. get camera(): Nullable<Camera>;
  59104. /**
  59105. * Gets the rendering group id the layer should render in.
  59106. */
  59107. get renderingGroupId(): number;
  59108. set renderingGroupId(renderingGroupId: number);
  59109. /**
  59110. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59111. */
  59112. disableBoundingBoxesFromEffectLayer: boolean;
  59113. /**
  59114. * An event triggered when the effect layer has been disposed.
  59115. */
  59116. onDisposeObservable: Observable<EffectLayer>;
  59117. /**
  59118. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59119. */
  59120. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59121. /**
  59122. * An event triggered when the generated texture is being merged in the scene.
  59123. */
  59124. onBeforeComposeObservable: Observable<EffectLayer>;
  59125. /**
  59126. * An event triggered when the mesh is rendered into the effect render target.
  59127. */
  59128. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59129. /**
  59130. * An event triggered after the mesh has been rendered into the effect render target.
  59131. */
  59132. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59133. /**
  59134. * An event triggered when the generated texture has been merged in the scene.
  59135. */
  59136. onAfterComposeObservable: Observable<EffectLayer>;
  59137. /**
  59138. * An event triggered when the efffect layer changes its size.
  59139. */
  59140. onSizeChangedObservable: Observable<EffectLayer>;
  59141. /** @hidden */
  59142. static _SceneComponentInitialization: (scene: Scene) => void;
  59143. /**
  59144. * Instantiates a new effect Layer and references it in the scene.
  59145. * @param name The name of the layer
  59146. * @param scene The scene to use the layer in
  59147. */
  59148. constructor(
  59149. /** The Friendly of the effect in the scene */
  59150. name: string, scene: Scene);
  59151. /**
  59152. * Get the effect name of the layer.
  59153. * @return The effect name
  59154. */
  59155. abstract getEffectName(): string;
  59156. /**
  59157. * Checks for the readiness of the element composing the layer.
  59158. * @param subMesh the mesh to check for
  59159. * @param useInstances specify whether or not to use instances to render the mesh
  59160. * @return true if ready otherwise, false
  59161. */
  59162. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59163. /**
  59164. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59165. * @returns true if the effect requires stencil during the main canvas render pass.
  59166. */
  59167. abstract needStencil(): boolean;
  59168. /**
  59169. * Create the merge effect. This is the shader use to blit the information back
  59170. * to the main canvas at the end of the scene rendering.
  59171. * @returns The effect containing the shader used to merge the effect on the main canvas
  59172. */
  59173. protected abstract _createMergeEffect(): Effect;
  59174. /**
  59175. * Creates the render target textures and post processes used in the effect layer.
  59176. */
  59177. protected abstract _createTextureAndPostProcesses(): void;
  59178. /**
  59179. * Implementation specific of rendering the generating effect on the main canvas.
  59180. * @param effect The effect used to render through
  59181. */
  59182. protected abstract _internalRender(effect: Effect): void;
  59183. /**
  59184. * Sets the required values for both the emissive texture and and the main color.
  59185. */
  59186. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59187. /**
  59188. * Free any resources and references associated to a mesh.
  59189. * Internal use
  59190. * @param mesh The mesh to free.
  59191. */
  59192. abstract _disposeMesh(mesh: Mesh): void;
  59193. /**
  59194. * Serializes this layer (Glow or Highlight for example)
  59195. * @returns a serialized layer object
  59196. */
  59197. abstract serialize?(): any;
  59198. /**
  59199. * Initializes the effect layer with the required options.
  59200. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59201. */
  59202. protected _init(options: Partial<IEffectLayerOptions>): void;
  59203. /**
  59204. * Generates the index buffer of the full screen quad blending to the main canvas.
  59205. */
  59206. private _generateIndexBuffer;
  59207. /**
  59208. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59209. */
  59210. private _generateVertexBuffer;
  59211. /**
  59212. * Sets the main texture desired size which is the closest power of two
  59213. * of the engine canvas size.
  59214. */
  59215. private _setMainTextureSize;
  59216. /**
  59217. * Creates the main texture for the effect layer.
  59218. */
  59219. protected _createMainTexture(): void;
  59220. /**
  59221. * Adds specific effects defines.
  59222. * @param defines The defines to add specifics to.
  59223. */
  59224. protected _addCustomEffectDefines(defines: string[]): void;
  59225. /**
  59226. * Checks for the readiness of the element composing the layer.
  59227. * @param subMesh the mesh to check for
  59228. * @param useInstances specify whether or not to use instances to render the mesh
  59229. * @param emissiveTexture the associated emissive texture used to generate the glow
  59230. * @return true if ready otherwise, false
  59231. */
  59232. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59233. /**
  59234. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59235. */
  59236. render(): void;
  59237. /**
  59238. * Determine if a given mesh will be used in the current effect.
  59239. * @param mesh mesh to test
  59240. * @returns true if the mesh will be used
  59241. */
  59242. hasMesh(mesh: AbstractMesh): boolean;
  59243. /**
  59244. * Returns true if the layer contains information to display, otherwise false.
  59245. * @returns true if the glow layer should be rendered
  59246. */
  59247. shouldRender(): boolean;
  59248. /**
  59249. * Returns true if the mesh should render, otherwise false.
  59250. * @param mesh The mesh to render
  59251. * @returns true if it should render otherwise false
  59252. */
  59253. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59254. /**
  59255. * Returns true if the mesh can be rendered, otherwise false.
  59256. * @param mesh The mesh to render
  59257. * @param material The material used on the mesh
  59258. * @returns true if it can be rendered otherwise false
  59259. */
  59260. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59261. /**
  59262. * Returns true if the mesh should render, otherwise false.
  59263. * @param mesh The mesh to render
  59264. * @returns true if it should render otherwise false
  59265. */
  59266. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59267. /**
  59268. * Renders the submesh passed in parameter to the generation map.
  59269. */
  59270. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59271. /**
  59272. * Defines whether the current material of the mesh should be use to render the effect.
  59273. * @param mesh defines the current mesh to render
  59274. */
  59275. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59276. /**
  59277. * Rebuild the required buffers.
  59278. * @hidden Internal use only.
  59279. */
  59280. _rebuild(): void;
  59281. /**
  59282. * Dispose only the render target textures and post process.
  59283. */
  59284. private _disposeTextureAndPostProcesses;
  59285. /**
  59286. * Dispose the highlight layer and free resources.
  59287. */
  59288. dispose(): void;
  59289. /**
  59290. * Gets the class name of the effect layer
  59291. * @returns the string with the class name of the effect layer
  59292. */
  59293. getClassName(): string;
  59294. /**
  59295. * Creates an effect layer from parsed effect layer data
  59296. * @param parsedEffectLayer defines effect layer data
  59297. * @param scene defines the current scene
  59298. * @param rootUrl defines the root URL containing the effect layer information
  59299. * @returns a parsed effect Layer
  59300. */
  59301. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59302. }
  59303. }
  59304. declare module BABYLON {
  59305. interface AbstractScene {
  59306. /**
  59307. * The list of effect layers (highlights/glow) added to the scene
  59308. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59309. * @see https://doc.babylonjs.com/how_to/glow_layer
  59310. */
  59311. effectLayers: Array<EffectLayer>;
  59312. /**
  59313. * Removes the given effect layer from this scene.
  59314. * @param toRemove defines the effect layer to remove
  59315. * @returns the index of the removed effect layer
  59316. */
  59317. removeEffectLayer(toRemove: EffectLayer): number;
  59318. /**
  59319. * Adds the given effect layer to this scene
  59320. * @param newEffectLayer defines the effect layer to add
  59321. */
  59322. addEffectLayer(newEffectLayer: EffectLayer): void;
  59323. }
  59324. /**
  59325. * Defines the layer scene component responsible to manage any effect layers
  59326. * in a given scene.
  59327. */
  59328. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59329. /**
  59330. * The component name helpfull to identify the component in the list of scene components.
  59331. */
  59332. readonly name: string;
  59333. /**
  59334. * The scene the component belongs to.
  59335. */
  59336. scene: Scene;
  59337. private _engine;
  59338. private _renderEffects;
  59339. private _needStencil;
  59340. private _previousStencilState;
  59341. /**
  59342. * Creates a new instance of the component for the given scene
  59343. * @param scene Defines the scene to register the component in
  59344. */
  59345. constructor(scene: Scene);
  59346. /**
  59347. * Registers the component in a given scene
  59348. */
  59349. register(): void;
  59350. /**
  59351. * Rebuilds the elements related to this component in case of
  59352. * context lost for instance.
  59353. */
  59354. rebuild(): void;
  59355. /**
  59356. * Serializes the component data to the specified json object
  59357. * @param serializationObject The object to serialize to
  59358. */
  59359. serialize(serializationObject: any): void;
  59360. /**
  59361. * Adds all the elements from the container to the scene
  59362. * @param container the container holding the elements
  59363. */
  59364. addFromContainer(container: AbstractScene): void;
  59365. /**
  59366. * Removes all the elements in the container from the scene
  59367. * @param container contains the elements to remove
  59368. * @param dispose if the removed element should be disposed (default: false)
  59369. */
  59370. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59371. /**
  59372. * Disposes the component and the associated ressources.
  59373. */
  59374. dispose(): void;
  59375. private _isReadyForMesh;
  59376. private _renderMainTexture;
  59377. private _setStencil;
  59378. private _setStencilBack;
  59379. private _draw;
  59380. private _drawCamera;
  59381. private _drawRenderingGroup;
  59382. }
  59383. }
  59384. declare module BABYLON {
  59385. /** @hidden */
  59386. export var glowMapMergePixelShader: {
  59387. name: string;
  59388. shader: string;
  59389. };
  59390. }
  59391. declare module BABYLON {
  59392. /** @hidden */
  59393. export var glowMapMergeVertexShader: {
  59394. name: string;
  59395. shader: string;
  59396. };
  59397. }
  59398. declare module BABYLON {
  59399. interface AbstractScene {
  59400. /**
  59401. * Return a the first highlight layer of the scene with a given name.
  59402. * @param name The name of the highlight layer to look for.
  59403. * @return The highlight layer if found otherwise null.
  59404. */
  59405. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59406. }
  59407. /**
  59408. * Glow layer options. This helps customizing the behaviour
  59409. * of the glow layer.
  59410. */
  59411. export interface IGlowLayerOptions {
  59412. /**
  59413. * Multiplication factor apply to the canvas size to compute the render target size
  59414. * used to generated the glowing objects (the smaller the faster).
  59415. */
  59416. mainTextureRatio: number;
  59417. /**
  59418. * Enforces a fixed size texture to ensure resize independant blur.
  59419. */
  59420. mainTextureFixedSize?: number;
  59421. /**
  59422. * How big is the kernel of the blur texture.
  59423. */
  59424. blurKernelSize: number;
  59425. /**
  59426. * The camera attached to the layer.
  59427. */
  59428. camera: Nullable<Camera>;
  59429. /**
  59430. * Enable MSAA by chosing the number of samples.
  59431. */
  59432. mainTextureSamples?: number;
  59433. /**
  59434. * The rendering group to draw the layer in.
  59435. */
  59436. renderingGroupId: number;
  59437. }
  59438. /**
  59439. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59440. *
  59441. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59442. *
  59443. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59444. */
  59445. export class GlowLayer extends EffectLayer {
  59446. /**
  59447. * Effect Name of the layer.
  59448. */
  59449. static readonly EffectName: string;
  59450. /**
  59451. * The default blur kernel size used for the glow.
  59452. */
  59453. static DefaultBlurKernelSize: number;
  59454. /**
  59455. * The default texture size ratio used for the glow.
  59456. */
  59457. static DefaultTextureRatio: number;
  59458. /**
  59459. * Sets the kernel size of the blur.
  59460. */
  59461. set blurKernelSize(value: number);
  59462. /**
  59463. * Gets the kernel size of the blur.
  59464. */
  59465. get blurKernelSize(): number;
  59466. /**
  59467. * Sets the glow intensity.
  59468. */
  59469. set intensity(value: number);
  59470. /**
  59471. * Gets the glow intensity.
  59472. */
  59473. get intensity(): number;
  59474. private _options;
  59475. private _intensity;
  59476. private _horizontalBlurPostprocess1;
  59477. private _verticalBlurPostprocess1;
  59478. private _horizontalBlurPostprocess2;
  59479. private _verticalBlurPostprocess2;
  59480. private _blurTexture1;
  59481. private _blurTexture2;
  59482. private _postProcesses1;
  59483. private _postProcesses2;
  59484. private _includedOnlyMeshes;
  59485. private _excludedMeshes;
  59486. private _meshesUsingTheirOwnMaterials;
  59487. /**
  59488. * Callback used to let the user override the color selection on a per mesh basis
  59489. */
  59490. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59491. /**
  59492. * Callback used to let the user override the texture selection on a per mesh basis
  59493. */
  59494. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59495. /**
  59496. * Instantiates a new glow Layer and references it to the scene.
  59497. * @param name The name of the layer
  59498. * @param scene The scene to use the layer in
  59499. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59500. */
  59501. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59502. /**
  59503. * Get the effect name of the layer.
  59504. * @return The effect name
  59505. */
  59506. getEffectName(): string;
  59507. /**
  59508. * Create the merge effect. This is the shader use to blit the information back
  59509. * to the main canvas at the end of the scene rendering.
  59510. */
  59511. protected _createMergeEffect(): Effect;
  59512. /**
  59513. * Creates the render target textures and post processes used in the glow layer.
  59514. */
  59515. protected _createTextureAndPostProcesses(): void;
  59516. /**
  59517. * Checks for the readiness of the element composing the layer.
  59518. * @param subMesh the mesh to check for
  59519. * @param useInstances specify wether or not to use instances to render the mesh
  59520. * @param emissiveTexture the associated emissive texture used to generate the glow
  59521. * @return true if ready otherwise, false
  59522. */
  59523. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59524. /**
  59525. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59526. */
  59527. needStencil(): boolean;
  59528. /**
  59529. * Returns true if the mesh can be rendered, otherwise false.
  59530. * @param mesh The mesh to render
  59531. * @param material The material used on the mesh
  59532. * @returns true if it can be rendered otherwise false
  59533. */
  59534. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59535. /**
  59536. * Implementation specific of rendering the generating effect on the main canvas.
  59537. * @param effect The effect used to render through
  59538. */
  59539. protected _internalRender(effect: Effect): void;
  59540. /**
  59541. * Sets the required values for both the emissive texture and and the main color.
  59542. */
  59543. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59544. /**
  59545. * Returns true if the mesh should render, otherwise false.
  59546. * @param mesh The mesh to render
  59547. * @returns true if it should render otherwise false
  59548. */
  59549. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59550. /**
  59551. * Adds specific effects defines.
  59552. * @param defines The defines to add specifics to.
  59553. */
  59554. protected _addCustomEffectDefines(defines: string[]): void;
  59555. /**
  59556. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59557. * @param mesh The mesh to exclude from the glow layer
  59558. */
  59559. addExcludedMesh(mesh: Mesh): void;
  59560. /**
  59561. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59562. * @param mesh The mesh to remove
  59563. */
  59564. removeExcludedMesh(mesh: Mesh): void;
  59565. /**
  59566. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59567. * @param mesh The mesh to include in the glow layer
  59568. */
  59569. addIncludedOnlyMesh(mesh: Mesh): void;
  59570. /**
  59571. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59572. * @param mesh The mesh to remove
  59573. */
  59574. removeIncludedOnlyMesh(mesh: Mesh): void;
  59575. /**
  59576. * Determine if a given mesh will be used in the glow layer
  59577. * @param mesh The mesh to test
  59578. * @returns true if the mesh will be highlighted by the current glow layer
  59579. */
  59580. hasMesh(mesh: AbstractMesh): boolean;
  59581. /**
  59582. * Defines whether the current material of the mesh should be use to render the effect.
  59583. * @param mesh defines the current mesh to render
  59584. */
  59585. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59586. /**
  59587. * Add a mesh to be rendered through its own material and not with emissive only.
  59588. * @param mesh The mesh for which we need to use its material
  59589. */
  59590. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59591. /**
  59592. * Remove a mesh from being rendered through its own material and not with emissive only.
  59593. * @param mesh The mesh for which we need to not use its material
  59594. */
  59595. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59596. /**
  59597. * Free any resources and references associated to a mesh.
  59598. * Internal use
  59599. * @param mesh The mesh to free.
  59600. * @hidden
  59601. */
  59602. _disposeMesh(mesh: Mesh): void;
  59603. /**
  59604. * Gets the class name of the effect layer
  59605. * @returns the string with the class name of the effect layer
  59606. */
  59607. getClassName(): string;
  59608. /**
  59609. * Serializes this glow layer
  59610. * @returns a serialized glow layer object
  59611. */
  59612. serialize(): any;
  59613. /**
  59614. * Creates a Glow Layer from parsed glow layer data
  59615. * @param parsedGlowLayer defines glow layer data
  59616. * @param scene defines the current scene
  59617. * @param rootUrl defines the root URL containing the glow layer information
  59618. * @returns a parsed Glow Layer
  59619. */
  59620. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59621. }
  59622. }
  59623. declare module BABYLON {
  59624. /** @hidden */
  59625. export var glowBlurPostProcessPixelShader: {
  59626. name: string;
  59627. shader: string;
  59628. };
  59629. }
  59630. declare module BABYLON {
  59631. interface AbstractScene {
  59632. /**
  59633. * Return a the first highlight layer of the scene with a given name.
  59634. * @param name The name of the highlight layer to look for.
  59635. * @return The highlight layer if found otherwise null.
  59636. */
  59637. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59638. }
  59639. /**
  59640. * Highlight layer options. This helps customizing the behaviour
  59641. * of the highlight layer.
  59642. */
  59643. export interface IHighlightLayerOptions {
  59644. /**
  59645. * Multiplication factor apply to the canvas size to compute the render target size
  59646. * used to generated the glowing objects (the smaller the faster).
  59647. */
  59648. mainTextureRatio: number;
  59649. /**
  59650. * Enforces a fixed size texture to ensure resize independant blur.
  59651. */
  59652. mainTextureFixedSize?: number;
  59653. /**
  59654. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59655. * of the picture to blur (the smaller the faster).
  59656. */
  59657. blurTextureSizeRatio: number;
  59658. /**
  59659. * How big in texel of the blur texture is the vertical blur.
  59660. */
  59661. blurVerticalSize: number;
  59662. /**
  59663. * How big in texel of the blur texture is the horizontal blur.
  59664. */
  59665. blurHorizontalSize: number;
  59666. /**
  59667. * Alpha blending mode used to apply the blur. Default is combine.
  59668. */
  59669. alphaBlendingMode: number;
  59670. /**
  59671. * The camera attached to the layer.
  59672. */
  59673. camera: Nullable<Camera>;
  59674. /**
  59675. * Should we display highlight as a solid stroke?
  59676. */
  59677. isStroke?: boolean;
  59678. /**
  59679. * The rendering group to draw the layer in.
  59680. */
  59681. renderingGroupId: number;
  59682. }
  59683. /**
  59684. * The highlight layer Helps adding a glow effect around a mesh.
  59685. *
  59686. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59687. * glowy meshes to your scene.
  59688. *
  59689. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59690. */
  59691. export class HighlightLayer extends EffectLayer {
  59692. name: string;
  59693. /**
  59694. * Effect Name of the highlight layer.
  59695. */
  59696. static readonly EffectName: string;
  59697. /**
  59698. * The neutral color used during the preparation of the glow effect.
  59699. * This is black by default as the blend operation is a blend operation.
  59700. */
  59701. static NeutralColor: Color4;
  59702. /**
  59703. * Stencil value used for glowing meshes.
  59704. */
  59705. static GlowingMeshStencilReference: number;
  59706. /**
  59707. * Stencil value used for the other meshes in the scene.
  59708. */
  59709. static NormalMeshStencilReference: number;
  59710. /**
  59711. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59712. */
  59713. innerGlow: boolean;
  59714. /**
  59715. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59716. */
  59717. outerGlow: boolean;
  59718. /**
  59719. * Specifies the horizontal size of the blur.
  59720. */
  59721. set blurHorizontalSize(value: number);
  59722. /**
  59723. * Specifies the vertical size of the blur.
  59724. */
  59725. set blurVerticalSize(value: number);
  59726. /**
  59727. * Gets the horizontal size of the blur.
  59728. */
  59729. get blurHorizontalSize(): number;
  59730. /**
  59731. * Gets the vertical size of the blur.
  59732. */
  59733. get blurVerticalSize(): number;
  59734. /**
  59735. * An event triggered when the highlight layer is being blurred.
  59736. */
  59737. onBeforeBlurObservable: Observable<HighlightLayer>;
  59738. /**
  59739. * An event triggered when the highlight layer has been blurred.
  59740. */
  59741. onAfterBlurObservable: Observable<HighlightLayer>;
  59742. private _instanceGlowingMeshStencilReference;
  59743. private _options;
  59744. private _downSamplePostprocess;
  59745. private _horizontalBlurPostprocess;
  59746. private _verticalBlurPostprocess;
  59747. private _blurTexture;
  59748. private _meshes;
  59749. private _excludedMeshes;
  59750. /**
  59751. * Instantiates a new highlight Layer and references it to the scene..
  59752. * @param name The name of the layer
  59753. * @param scene The scene to use the layer in
  59754. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59755. */
  59756. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59757. /**
  59758. * Get the effect name of the layer.
  59759. * @return The effect name
  59760. */
  59761. getEffectName(): string;
  59762. /**
  59763. * Create the merge effect. This is the shader use to blit the information back
  59764. * to the main canvas at the end of the scene rendering.
  59765. */
  59766. protected _createMergeEffect(): Effect;
  59767. /**
  59768. * Creates the render target textures and post processes used in the highlight layer.
  59769. */
  59770. protected _createTextureAndPostProcesses(): void;
  59771. /**
  59772. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59773. */
  59774. needStencil(): boolean;
  59775. /**
  59776. * Checks for the readiness of the element composing the layer.
  59777. * @param subMesh the mesh to check for
  59778. * @param useInstances specify wether or not to use instances to render the mesh
  59779. * @param emissiveTexture the associated emissive texture used to generate the glow
  59780. * @return true if ready otherwise, false
  59781. */
  59782. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59783. /**
  59784. * Implementation specific of rendering the generating effect on the main canvas.
  59785. * @param effect The effect used to render through
  59786. */
  59787. protected _internalRender(effect: Effect): void;
  59788. /**
  59789. * Returns true if the layer contains information to display, otherwise false.
  59790. */
  59791. shouldRender(): boolean;
  59792. /**
  59793. * Returns true if the mesh should render, otherwise false.
  59794. * @param mesh The mesh to render
  59795. * @returns true if it should render otherwise false
  59796. */
  59797. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59798. /**
  59799. * Returns true if the mesh can be rendered, otherwise false.
  59800. * @param mesh The mesh to render
  59801. * @param material The material used on the mesh
  59802. * @returns true if it can be rendered otherwise false
  59803. */
  59804. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59805. /**
  59806. * Adds specific effects defines.
  59807. * @param defines The defines to add specifics to.
  59808. */
  59809. protected _addCustomEffectDefines(defines: string[]): void;
  59810. /**
  59811. * Sets the required values for both the emissive texture and and the main color.
  59812. */
  59813. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59814. /**
  59815. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59816. * @param mesh The mesh to exclude from the highlight layer
  59817. */
  59818. addExcludedMesh(mesh: Mesh): void;
  59819. /**
  59820. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59821. * @param mesh The mesh to highlight
  59822. */
  59823. removeExcludedMesh(mesh: Mesh): void;
  59824. /**
  59825. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59826. * @param mesh mesh to test
  59827. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59828. */
  59829. hasMesh(mesh: AbstractMesh): boolean;
  59830. /**
  59831. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59832. * @param mesh The mesh to highlight
  59833. * @param color The color of the highlight
  59834. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59835. */
  59836. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59837. /**
  59838. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59839. * @param mesh The mesh to highlight
  59840. */
  59841. removeMesh(mesh: Mesh): void;
  59842. /**
  59843. * Remove all the meshes currently referenced in the highlight layer
  59844. */
  59845. removeAllMeshes(): void;
  59846. /**
  59847. * Force the stencil to the normal expected value for none glowing parts
  59848. */
  59849. private _defaultStencilReference;
  59850. /**
  59851. * Free any resources and references associated to a mesh.
  59852. * Internal use
  59853. * @param mesh The mesh to free.
  59854. * @hidden
  59855. */
  59856. _disposeMesh(mesh: Mesh): void;
  59857. /**
  59858. * Dispose the highlight layer and free resources.
  59859. */
  59860. dispose(): void;
  59861. /**
  59862. * Gets the class name of the effect layer
  59863. * @returns the string with the class name of the effect layer
  59864. */
  59865. getClassName(): string;
  59866. /**
  59867. * Serializes this Highlight layer
  59868. * @returns a serialized Highlight layer object
  59869. */
  59870. serialize(): any;
  59871. /**
  59872. * Creates a Highlight layer from parsed Highlight layer data
  59873. * @param parsedHightlightLayer defines the Highlight layer data
  59874. * @param scene defines the current scene
  59875. * @param rootUrl defines the root URL containing the Highlight layer information
  59876. * @returns a parsed Highlight layer
  59877. */
  59878. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59879. }
  59880. }
  59881. declare module BABYLON {
  59882. interface AbstractScene {
  59883. /**
  59884. * The list of layers (background and foreground) of the scene
  59885. */
  59886. layers: Array<Layer>;
  59887. }
  59888. /**
  59889. * Defines the layer scene component responsible to manage any layers
  59890. * in a given scene.
  59891. */
  59892. export class LayerSceneComponent implements ISceneComponent {
  59893. /**
  59894. * The component name helpfull to identify the component in the list of scene components.
  59895. */
  59896. readonly name: string;
  59897. /**
  59898. * The scene the component belongs to.
  59899. */
  59900. scene: Scene;
  59901. private _engine;
  59902. /**
  59903. * Creates a new instance of the component for the given scene
  59904. * @param scene Defines the scene to register the component in
  59905. */
  59906. constructor(scene: Scene);
  59907. /**
  59908. * Registers the component in a given scene
  59909. */
  59910. register(): void;
  59911. /**
  59912. * Rebuilds the elements related to this component in case of
  59913. * context lost for instance.
  59914. */
  59915. rebuild(): void;
  59916. /**
  59917. * Disposes the component and the associated ressources.
  59918. */
  59919. dispose(): void;
  59920. private _draw;
  59921. private _drawCameraPredicate;
  59922. private _drawCameraBackground;
  59923. private _drawCameraForeground;
  59924. private _drawRenderTargetPredicate;
  59925. private _drawRenderTargetBackground;
  59926. private _drawRenderTargetForeground;
  59927. /**
  59928. * Adds all the elements from the container to the scene
  59929. * @param container the container holding the elements
  59930. */
  59931. addFromContainer(container: AbstractScene): void;
  59932. /**
  59933. * Removes all the elements in the container from the scene
  59934. * @param container contains the elements to remove
  59935. * @param dispose if the removed element should be disposed (default: false)
  59936. */
  59937. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59938. }
  59939. }
  59940. declare module BABYLON {
  59941. /** @hidden */
  59942. export var layerPixelShader: {
  59943. name: string;
  59944. shader: string;
  59945. };
  59946. }
  59947. declare module BABYLON {
  59948. /** @hidden */
  59949. export var layerVertexShader: {
  59950. name: string;
  59951. shader: string;
  59952. };
  59953. }
  59954. declare module BABYLON {
  59955. /**
  59956. * This represents a full screen 2d layer.
  59957. * This can be useful to display a picture in the background of your scene for instance.
  59958. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59959. */
  59960. export class Layer {
  59961. /**
  59962. * Define the name of the layer.
  59963. */
  59964. name: string;
  59965. /**
  59966. * Define the texture the layer should display.
  59967. */
  59968. texture: Nullable<Texture>;
  59969. /**
  59970. * Is the layer in background or foreground.
  59971. */
  59972. isBackground: boolean;
  59973. /**
  59974. * Define the color of the layer (instead of texture).
  59975. */
  59976. color: Color4;
  59977. /**
  59978. * Define the scale of the layer in order to zoom in out of the texture.
  59979. */
  59980. scale: Vector2;
  59981. /**
  59982. * Define an offset for the layer in order to shift the texture.
  59983. */
  59984. offset: Vector2;
  59985. /**
  59986. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59987. */
  59988. alphaBlendingMode: number;
  59989. /**
  59990. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59991. * Alpha test will not mix with the background color in case of transparency.
  59992. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59993. */
  59994. alphaTest: boolean;
  59995. /**
  59996. * Define a mask to restrict the layer to only some of the scene cameras.
  59997. */
  59998. layerMask: number;
  59999. /**
  60000. * Define the list of render target the layer is visible into.
  60001. */
  60002. renderTargetTextures: RenderTargetTexture[];
  60003. /**
  60004. * Define if the layer is only used in renderTarget or if it also
  60005. * renders in the main frame buffer of the canvas.
  60006. */
  60007. renderOnlyInRenderTargetTextures: boolean;
  60008. private _scene;
  60009. private _vertexBuffers;
  60010. private _indexBuffer;
  60011. private _effect;
  60012. private _previousDefines;
  60013. /**
  60014. * An event triggered when the layer is disposed.
  60015. */
  60016. onDisposeObservable: Observable<Layer>;
  60017. private _onDisposeObserver;
  60018. /**
  60019. * Back compatibility with callback before the onDisposeObservable existed.
  60020. * The set callback will be triggered when the layer has been disposed.
  60021. */
  60022. set onDispose(callback: () => void);
  60023. /**
  60024. * An event triggered before rendering the scene
  60025. */
  60026. onBeforeRenderObservable: Observable<Layer>;
  60027. private _onBeforeRenderObserver;
  60028. /**
  60029. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60030. * The set callback will be triggered just before rendering the layer.
  60031. */
  60032. set onBeforeRender(callback: () => void);
  60033. /**
  60034. * An event triggered after rendering the scene
  60035. */
  60036. onAfterRenderObservable: Observable<Layer>;
  60037. private _onAfterRenderObserver;
  60038. /**
  60039. * Back compatibility with callback before the onAfterRenderObservable existed.
  60040. * The set callback will be triggered just after rendering the layer.
  60041. */
  60042. set onAfterRender(callback: () => void);
  60043. /**
  60044. * Instantiates a new layer.
  60045. * This represents a full screen 2d layer.
  60046. * This can be useful to display a picture in the background of your scene for instance.
  60047. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60048. * @param name Define the name of the layer in the scene
  60049. * @param imgUrl Define the url of the texture to display in the layer
  60050. * @param scene Define the scene the layer belongs to
  60051. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60052. * @param color Defines a color for the layer
  60053. */
  60054. constructor(
  60055. /**
  60056. * Define the name of the layer.
  60057. */
  60058. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60059. private _createIndexBuffer;
  60060. /** @hidden */
  60061. _rebuild(): void;
  60062. /**
  60063. * Renders the layer in the scene.
  60064. */
  60065. render(): void;
  60066. /**
  60067. * Disposes and releases the associated ressources.
  60068. */
  60069. dispose(): void;
  60070. }
  60071. }
  60072. declare module BABYLON {
  60073. /** @hidden */
  60074. export var lensFlarePixelShader: {
  60075. name: string;
  60076. shader: string;
  60077. };
  60078. }
  60079. declare module BABYLON {
  60080. /** @hidden */
  60081. export var lensFlareVertexShader: {
  60082. name: string;
  60083. shader: string;
  60084. };
  60085. }
  60086. declare module BABYLON {
  60087. /**
  60088. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60089. * It is usually composed of several `lensFlare`.
  60090. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60091. */
  60092. export class LensFlareSystem {
  60093. /**
  60094. * Define the name of the lens flare system
  60095. */
  60096. name: string;
  60097. /**
  60098. * List of lens flares used in this system.
  60099. */
  60100. lensFlares: LensFlare[];
  60101. /**
  60102. * Define a limit from the border the lens flare can be visible.
  60103. */
  60104. borderLimit: number;
  60105. /**
  60106. * Define a viewport border we do not want to see the lens flare in.
  60107. */
  60108. viewportBorder: number;
  60109. /**
  60110. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60111. */
  60112. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60113. /**
  60114. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60115. */
  60116. layerMask: number;
  60117. /**
  60118. * Define the id of the lens flare system in the scene.
  60119. * (equal to name by default)
  60120. */
  60121. id: string;
  60122. private _scene;
  60123. private _emitter;
  60124. private _vertexBuffers;
  60125. private _indexBuffer;
  60126. private _effect;
  60127. private _positionX;
  60128. private _positionY;
  60129. private _isEnabled;
  60130. /** @hidden */
  60131. static _SceneComponentInitialization: (scene: Scene) => void;
  60132. /**
  60133. * Instantiates a lens flare system.
  60134. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60135. * It is usually composed of several `lensFlare`.
  60136. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60137. * @param name Define the name of the lens flare system in the scene
  60138. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60139. * @param scene Define the scene the lens flare system belongs to
  60140. */
  60141. constructor(
  60142. /**
  60143. * Define the name of the lens flare system
  60144. */
  60145. name: string, emitter: any, scene: Scene);
  60146. /**
  60147. * Define if the lens flare system is enabled.
  60148. */
  60149. get isEnabled(): boolean;
  60150. set isEnabled(value: boolean);
  60151. /**
  60152. * Get the scene the effects belongs to.
  60153. * @returns the scene holding the lens flare system
  60154. */
  60155. getScene(): Scene;
  60156. /**
  60157. * Get the emitter of the lens flare system.
  60158. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60159. * @returns the emitter of the lens flare system
  60160. */
  60161. getEmitter(): any;
  60162. /**
  60163. * Set the emitter of the lens flare system.
  60164. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60165. * @param newEmitter Define the new emitter of the system
  60166. */
  60167. setEmitter(newEmitter: any): void;
  60168. /**
  60169. * Get the lens flare system emitter position.
  60170. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60171. * @returns the position
  60172. */
  60173. getEmitterPosition(): Vector3;
  60174. /**
  60175. * @hidden
  60176. */
  60177. computeEffectivePosition(globalViewport: Viewport): boolean;
  60178. /** @hidden */
  60179. _isVisible(): boolean;
  60180. /**
  60181. * @hidden
  60182. */
  60183. render(): boolean;
  60184. /**
  60185. * Dispose and release the lens flare with its associated resources.
  60186. */
  60187. dispose(): void;
  60188. /**
  60189. * Parse a lens flare system from a JSON repressentation
  60190. * @param parsedLensFlareSystem Define the JSON to parse
  60191. * @param scene Define the scene the parsed system should be instantiated in
  60192. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60193. * @returns the parsed system
  60194. */
  60195. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60196. /**
  60197. * Serialize the current Lens Flare System into a JSON representation.
  60198. * @returns the serialized JSON
  60199. */
  60200. serialize(): any;
  60201. }
  60202. }
  60203. declare module BABYLON {
  60204. /**
  60205. * This represents one of the lens effect in a `lensFlareSystem`.
  60206. * It controls one of the indiviual texture used in the effect.
  60207. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60208. */
  60209. export class LensFlare {
  60210. /**
  60211. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60212. */
  60213. size: number;
  60214. /**
  60215. * 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.
  60216. */
  60217. position: number;
  60218. /**
  60219. * Define the lens color.
  60220. */
  60221. color: Color3;
  60222. /**
  60223. * Define the lens texture.
  60224. */
  60225. texture: Nullable<Texture>;
  60226. /**
  60227. * Define the alpha mode to render this particular lens.
  60228. */
  60229. alphaMode: number;
  60230. private _system;
  60231. /**
  60232. * Creates a new Lens Flare.
  60233. * This represents one of the lens effect in a `lensFlareSystem`.
  60234. * It controls one of the indiviual texture used in the effect.
  60235. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60236. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60237. * @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.
  60238. * @param color Define the lens color
  60239. * @param imgUrl Define the lens texture url
  60240. * @param system Define the `lensFlareSystem` this flare is part of
  60241. * @returns The newly created Lens Flare
  60242. */
  60243. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60244. /**
  60245. * Instantiates a new Lens Flare.
  60246. * This represents one of the lens effect in a `lensFlareSystem`.
  60247. * It controls one of the indiviual texture used in the effect.
  60248. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60249. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60250. * @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.
  60251. * @param color Define the lens color
  60252. * @param imgUrl Define the lens texture url
  60253. * @param system Define the `lensFlareSystem` this flare is part of
  60254. */
  60255. constructor(
  60256. /**
  60257. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60258. */
  60259. size: number,
  60260. /**
  60261. * 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.
  60262. */
  60263. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60264. /**
  60265. * Dispose and release the lens flare with its associated resources.
  60266. */
  60267. dispose(): void;
  60268. }
  60269. }
  60270. declare module BABYLON {
  60271. interface AbstractScene {
  60272. /**
  60273. * The list of lens flare system added to the scene
  60274. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60275. */
  60276. lensFlareSystems: Array<LensFlareSystem>;
  60277. /**
  60278. * Removes the given lens flare system from this scene.
  60279. * @param toRemove The lens flare system to remove
  60280. * @returns The index of the removed lens flare system
  60281. */
  60282. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60283. /**
  60284. * Adds the given lens flare system to this scene
  60285. * @param newLensFlareSystem The lens flare system to add
  60286. */
  60287. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60288. /**
  60289. * Gets a lens flare system using its name
  60290. * @param name defines the name to look for
  60291. * @returns the lens flare system or null if not found
  60292. */
  60293. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60294. /**
  60295. * Gets a lens flare system using its id
  60296. * @param id defines the id to look for
  60297. * @returns the lens flare system or null if not found
  60298. */
  60299. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60300. }
  60301. /**
  60302. * Defines the lens flare scene component responsible to manage any lens flares
  60303. * in a given scene.
  60304. */
  60305. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60306. /**
  60307. * The component name helpfull to identify the component in the list of scene components.
  60308. */
  60309. readonly name: string;
  60310. /**
  60311. * The scene the component belongs to.
  60312. */
  60313. scene: Scene;
  60314. /**
  60315. * Creates a new instance of the component for the given scene
  60316. * @param scene Defines the scene to register the component in
  60317. */
  60318. constructor(scene: Scene);
  60319. /**
  60320. * Registers the component in a given scene
  60321. */
  60322. register(): void;
  60323. /**
  60324. * Rebuilds the elements related to this component in case of
  60325. * context lost for instance.
  60326. */
  60327. rebuild(): void;
  60328. /**
  60329. * Adds all the elements from the container to the scene
  60330. * @param container the container holding the elements
  60331. */
  60332. addFromContainer(container: AbstractScene): void;
  60333. /**
  60334. * Removes all the elements in the container from the scene
  60335. * @param container contains the elements to remove
  60336. * @param dispose if the removed element should be disposed (default: false)
  60337. */
  60338. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60339. /**
  60340. * Serializes the component data to the specified json object
  60341. * @param serializationObject The object to serialize to
  60342. */
  60343. serialize(serializationObject: any): void;
  60344. /**
  60345. * Disposes the component and the associated ressources.
  60346. */
  60347. dispose(): void;
  60348. private _draw;
  60349. }
  60350. }
  60351. declare module BABYLON {
  60352. /** @hidden */
  60353. export var depthPixelShader: {
  60354. name: string;
  60355. shader: string;
  60356. };
  60357. }
  60358. declare module BABYLON {
  60359. /** @hidden */
  60360. export var depthVertexShader: {
  60361. name: string;
  60362. shader: string;
  60363. };
  60364. }
  60365. declare module BABYLON {
  60366. /**
  60367. * This represents a depth renderer in Babylon.
  60368. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60369. */
  60370. export class DepthRenderer {
  60371. private _scene;
  60372. private _depthMap;
  60373. private _effect;
  60374. private readonly _storeNonLinearDepth;
  60375. private readonly _clearColor;
  60376. /** Get if the depth renderer is using packed depth or not */
  60377. readonly isPacked: boolean;
  60378. private _cachedDefines;
  60379. private _camera;
  60380. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60381. enabled: boolean;
  60382. /**
  60383. * Specifiess that the depth renderer will only be used within
  60384. * the camera it is created for.
  60385. * This can help forcing its rendering during the camera processing.
  60386. */
  60387. useOnlyInActiveCamera: boolean;
  60388. /** @hidden */
  60389. static _SceneComponentInitialization: (scene: Scene) => void;
  60390. /**
  60391. * Instantiates a depth renderer
  60392. * @param scene The scene the renderer belongs to
  60393. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60394. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60395. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60396. */
  60397. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60398. /**
  60399. * Creates the depth rendering effect and checks if the effect is ready.
  60400. * @param subMesh The submesh to be used to render the depth map of
  60401. * @param useInstances If multiple world instances should be used
  60402. * @returns if the depth renderer is ready to render the depth map
  60403. */
  60404. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60405. /**
  60406. * Gets the texture which the depth map will be written to.
  60407. * @returns The depth map texture
  60408. */
  60409. getDepthMap(): RenderTargetTexture;
  60410. /**
  60411. * Disposes of the depth renderer.
  60412. */
  60413. dispose(): void;
  60414. }
  60415. }
  60416. declare module BABYLON {
  60417. /** @hidden */
  60418. export var minmaxReduxPixelShader: {
  60419. name: string;
  60420. shader: string;
  60421. };
  60422. }
  60423. declare module BABYLON {
  60424. /**
  60425. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60426. * and maximum values from all values of the texture.
  60427. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60428. * The source values are read from the red channel of the texture.
  60429. */
  60430. export class MinMaxReducer {
  60431. /**
  60432. * Observable triggered when the computation has been performed
  60433. */
  60434. onAfterReductionPerformed: Observable<{
  60435. min: number;
  60436. max: number;
  60437. }>;
  60438. protected _camera: Camera;
  60439. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60440. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60441. protected _postProcessManager: PostProcessManager;
  60442. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60443. protected _forceFullscreenViewport: boolean;
  60444. /**
  60445. * Creates a min/max reducer
  60446. * @param camera The camera to use for the post processes
  60447. */
  60448. constructor(camera: Camera);
  60449. /**
  60450. * Gets the texture used to read the values from.
  60451. */
  60452. get sourceTexture(): Nullable<RenderTargetTexture>;
  60453. /**
  60454. * Sets the source texture to read the values from.
  60455. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60456. * because in such textures '1' value must not be taken into account to compute the maximum
  60457. * as this value is used to clear the texture.
  60458. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60459. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60460. * @param depthRedux Indicates if the texture is a depth texture or not
  60461. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60462. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60463. */
  60464. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60465. /**
  60466. * Defines the refresh rate of the computation.
  60467. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60468. */
  60469. get refreshRate(): number;
  60470. set refreshRate(value: number);
  60471. protected _activated: boolean;
  60472. /**
  60473. * Gets the activation status of the reducer
  60474. */
  60475. get activated(): boolean;
  60476. /**
  60477. * Activates the reduction computation.
  60478. * When activated, the observers registered in onAfterReductionPerformed are
  60479. * called after the compuation is performed
  60480. */
  60481. activate(): void;
  60482. /**
  60483. * Deactivates the reduction computation.
  60484. */
  60485. deactivate(): void;
  60486. /**
  60487. * Disposes the min/max reducer
  60488. * @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.
  60489. */
  60490. dispose(disposeAll?: boolean): void;
  60491. }
  60492. }
  60493. declare module BABYLON {
  60494. /**
  60495. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60496. */
  60497. export class DepthReducer extends MinMaxReducer {
  60498. private _depthRenderer;
  60499. private _depthRendererId;
  60500. /**
  60501. * Gets the depth renderer used for the computation.
  60502. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60503. */
  60504. get depthRenderer(): Nullable<DepthRenderer>;
  60505. /**
  60506. * Creates a depth reducer
  60507. * @param camera The camera used to render the depth texture
  60508. */
  60509. constructor(camera: Camera);
  60510. /**
  60511. * Sets the depth renderer to use to generate the depth map
  60512. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60513. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60514. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60515. */
  60516. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60517. /** @hidden */
  60518. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60519. /**
  60520. * Activates the reduction computation.
  60521. * When activated, the observers registered in onAfterReductionPerformed are
  60522. * called after the compuation is performed
  60523. */
  60524. activate(): void;
  60525. /**
  60526. * Deactivates the reduction computation.
  60527. */
  60528. deactivate(): void;
  60529. /**
  60530. * Disposes the depth reducer
  60531. * @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.
  60532. */
  60533. dispose(disposeAll?: boolean): void;
  60534. }
  60535. }
  60536. declare module BABYLON {
  60537. /**
  60538. * A CSM implementation allowing casting shadows on large scenes.
  60539. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60540. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60541. */
  60542. export class CascadedShadowGenerator extends ShadowGenerator {
  60543. private static readonly frustumCornersNDCSpace;
  60544. /**
  60545. * Name of the CSM class
  60546. */
  60547. static CLASSNAME: string;
  60548. /**
  60549. * Defines the default number of cascades used by the CSM.
  60550. */
  60551. static readonly DEFAULT_CASCADES_COUNT: number;
  60552. /**
  60553. * Defines the minimum number of cascades used by the CSM.
  60554. */
  60555. static readonly MIN_CASCADES_COUNT: number;
  60556. /**
  60557. * Defines the maximum number of cascades used by the CSM.
  60558. */
  60559. static readonly MAX_CASCADES_COUNT: number;
  60560. protected _validateFilter(filter: number): number;
  60561. /**
  60562. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60563. */
  60564. penumbraDarkness: number;
  60565. private _numCascades;
  60566. /**
  60567. * Gets or set the number of cascades used by the CSM.
  60568. */
  60569. get numCascades(): number;
  60570. set numCascades(value: number);
  60571. /**
  60572. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60573. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60574. */
  60575. stabilizeCascades: boolean;
  60576. private _freezeShadowCastersBoundingInfo;
  60577. private _freezeShadowCastersBoundingInfoObservable;
  60578. /**
  60579. * Enables or disables the shadow casters bounding info computation.
  60580. * If your shadow casters don't move, you can disable this feature.
  60581. * If it is enabled, the bounding box computation is done every frame.
  60582. */
  60583. get freezeShadowCastersBoundingInfo(): boolean;
  60584. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60585. private _scbiMin;
  60586. private _scbiMax;
  60587. protected _computeShadowCastersBoundingInfo(): void;
  60588. protected _shadowCastersBoundingInfo: BoundingInfo;
  60589. /**
  60590. * Gets or sets the shadow casters bounding info.
  60591. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60592. * so that the system won't overwrite the bounds you provide
  60593. */
  60594. get shadowCastersBoundingInfo(): BoundingInfo;
  60595. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60596. protected _breaksAreDirty: boolean;
  60597. protected _minDistance: number;
  60598. protected _maxDistance: number;
  60599. /**
  60600. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60601. *
  60602. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60603. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60604. * @param min minimal distance for the breaks (default to 0.)
  60605. * @param max maximal distance for the breaks (default to 1.)
  60606. */
  60607. setMinMaxDistance(min: number, max: number): void;
  60608. /** Gets the minimal distance used in the cascade break computation */
  60609. get minDistance(): number;
  60610. /** Gets the maximal distance used in the cascade break computation */
  60611. get maxDistance(): number;
  60612. /**
  60613. * Gets the class name of that object
  60614. * @returns "CascadedShadowGenerator"
  60615. */
  60616. getClassName(): string;
  60617. private _cascadeMinExtents;
  60618. private _cascadeMaxExtents;
  60619. /**
  60620. * Gets a cascade minimum extents
  60621. * @param cascadeIndex index of the cascade
  60622. * @returns the minimum cascade extents
  60623. */
  60624. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60625. /**
  60626. * Gets a cascade maximum extents
  60627. * @param cascadeIndex index of the cascade
  60628. * @returns the maximum cascade extents
  60629. */
  60630. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60631. private _cascades;
  60632. private _currentLayer;
  60633. private _viewSpaceFrustumsZ;
  60634. private _viewMatrices;
  60635. private _projectionMatrices;
  60636. private _transformMatrices;
  60637. private _transformMatricesAsArray;
  60638. private _frustumLengths;
  60639. private _lightSizeUVCorrection;
  60640. private _depthCorrection;
  60641. private _frustumCornersWorldSpace;
  60642. private _frustumCenter;
  60643. private _shadowCameraPos;
  60644. private _shadowMaxZ;
  60645. /**
  60646. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60647. * It defaults to camera.maxZ
  60648. */
  60649. get shadowMaxZ(): number;
  60650. /**
  60651. * Sets the shadow max z distance.
  60652. */
  60653. set shadowMaxZ(value: number);
  60654. protected _debug: boolean;
  60655. /**
  60656. * Gets or sets the debug flag.
  60657. * When enabled, the cascades are materialized by different colors on the screen.
  60658. */
  60659. get debug(): boolean;
  60660. set debug(dbg: boolean);
  60661. private _depthClamp;
  60662. /**
  60663. * Gets or sets the depth clamping value.
  60664. *
  60665. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60666. * to account for the shadow casters far away.
  60667. *
  60668. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60669. */
  60670. get depthClamp(): boolean;
  60671. set depthClamp(value: boolean);
  60672. private _cascadeBlendPercentage;
  60673. /**
  60674. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60675. * It defaults to 0.1 (10% blending).
  60676. */
  60677. get cascadeBlendPercentage(): number;
  60678. set cascadeBlendPercentage(value: number);
  60679. private _lambda;
  60680. /**
  60681. * Gets or set the lambda parameter.
  60682. * This parameter is used to split the camera frustum and create the cascades.
  60683. * 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.
  60684. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60685. */
  60686. get lambda(): number;
  60687. set lambda(value: number);
  60688. /**
  60689. * Gets the view matrix corresponding to a given cascade
  60690. * @param cascadeNum cascade to retrieve the view matrix from
  60691. * @returns the cascade view matrix
  60692. */
  60693. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60694. /**
  60695. * Gets the projection matrix corresponding to a given cascade
  60696. * @param cascadeNum cascade to retrieve the projection matrix from
  60697. * @returns the cascade projection matrix
  60698. */
  60699. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60700. /**
  60701. * Gets the transformation matrix corresponding to a given cascade
  60702. * @param cascadeNum cascade to retrieve the transformation matrix from
  60703. * @returns the cascade transformation matrix
  60704. */
  60705. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60706. private _depthRenderer;
  60707. /**
  60708. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60709. *
  60710. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60711. *
  60712. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60713. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60714. * @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
  60715. */
  60716. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60717. private _depthReducer;
  60718. private _autoCalcDepthBounds;
  60719. /**
  60720. * Gets or sets the autoCalcDepthBounds property.
  60721. *
  60722. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60723. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60724. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60725. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60726. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60727. */
  60728. get autoCalcDepthBounds(): boolean;
  60729. set autoCalcDepthBounds(value: boolean);
  60730. /**
  60731. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60732. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60733. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60734. * for setting the refresh rate on the renderer yourself!
  60735. */
  60736. get autoCalcDepthBoundsRefreshRate(): number;
  60737. set autoCalcDepthBoundsRefreshRate(value: number);
  60738. /**
  60739. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60740. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60741. * you change the camera near/far planes!
  60742. */
  60743. splitFrustum(): void;
  60744. private _splitFrustum;
  60745. private _computeMatrices;
  60746. private _computeFrustumInWorldSpace;
  60747. private _computeCascadeFrustum;
  60748. /**
  60749. * Support test.
  60750. */
  60751. static get IsSupported(): boolean;
  60752. /** @hidden */
  60753. static _SceneComponentInitialization: (scene: Scene) => void;
  60754. /**
  60755. * Creates a Cascaded Shadow Generator object.
  60756. * A ShadowGenerator is the required tool to use the shadows.
  60757. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60758. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60759. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60760. * @param light The directional light object generating the shadows.
  60761. * @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.
  60762. */
  60763. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60764. protected _initializeGenerator(): void;
  60765. protected _createTargetRenderTexture(): void;
  60766. protected _initializeShadowMap(): void;
  60767. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60768. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60769. /**
  60770. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60771. * @param defines Defines of the material we want to update
  60772. * @param lightIndex Index of the light in the enabled light list of the material
  60773. */
  60774. prepareDefines(defines: any, lightIndex: number): void;
  60775. /**
  60776. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60777. * defined in the generator but impacting the effect).
  60778. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60779. * @param effect The effect we are binfing the information for
  60780. */
  60781. bindShadowLight(lightIndex: string, effect: Effect): void;
  60782. /**
  60783. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60784. * (eq to view projection * shadow projection matrices)
  60785. * @returns The transform matrix used to create the shadow map
  60786. */
  60787. getTransformMatrix(): Matrix;
  60788. /**
  60789. * Disposes the ShadowGenerator.
  60790. * Returns nothing.
  60791. */
  60792. dispose(): void;
  60793. /**
  60794. * Serializes the shadow generator setup to a json object.
  60795. * @returns The serialized JSON object
  60796. */
  60797. serialize(): any;
  60798. /**
  60799. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60800. * @param parsedShadowGenerator The JSON object to parse
  60801. * @param scene The scene to create the shadow map for
  60802. * @returns The parsed shadow generator
  60803. */
  60804. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60805. }
  60806. }
  60807. declare module BABYLON {
  60808. /**
  60809. * Defines the shadow generator component responsible to manage any shadow generators
  60810. * in a given scene.
  60811. */
  60812. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60813. /**
  60814. * The component name helpfull to identify the component in the list of scene components.
  60815. */
  60816. readonly name: string;
  60817. /**
  60818. * The scene the component belongs to.
  60819. */
  60820. scene: Scene;
  60821. /**
  60822. * Creates a new instance of the component for the given scene
  60823. * @param scene Defines the scene to register the component in
  60824. */
  60825. constructor(scene: Scene);
  60826. /**
  60827. * Registers the component in a given scene
  60828. */
  60829. register(): void;
  60830. /**
  60831. * Rebuilds the elements related to this component in case of
  60832. * context lost for instance.
  60833. */
  60834. rebuild(): void;
  60835. /**
  60836. * Serializes the component data to the specified json object
  60837. * @param serializationObject The object to serialize to
  60838. */
  60839. serialize(serializationObject: any): void;
  60840. /**
  60841. * Adds all the elements from the container to the scene
  60842. * @param container the container holding the elements
  60843. */
  60844. addFromContainer(container: AbstractScene): void;
  60845. /**
  60846. * Removes all the elements in the container from the scene
  60847. * @param container contains the elements to remove
  60848. * @param dispose if the removed element should be disposed (default: false)
  60849. */
  60850. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60851. /**
  60852. * Rebuilds the elements related to this component in case of
  60853. * context lost for instance.
  60854. */
  60855. dispose(): void;
  60856. private _gatherRenderTargets;
  60857. }
  60858. }
  60859. declare module BABYLON {
  60860. /**
  60861. * A point light is a light defined by an unique point in world space.
  60862. * The light is emitted in every direction from this point.
  60863. * A good example of a point light is a standard light bulb.
  60864. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60865. */
  60866. export class PointLight extends ShadowLight {
  60867. private _shadowAngle;
  60868. /**
  60869. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60870. * This specifies what angle the shadow will use to be created.
  60871. *
  60872. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60873. */
  60874. get shadowAngle(): number;
  60875. /**
  60876. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60877. * This specifies what angle the shadow will use to be created.
  60878. *
  60879. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60880. */
  60881. set shadowAngle(value: number);
  60882. /**
  60883. * Gets the direction if it has been set.
  60884. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60885. */
  60886. get direction(): Vector3;
  60887. /**
  60888. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60889. */
  60890. set direction(value: Vector3);
  60891. /**
  60892. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60893. * A PointLight emits the light in every direction.
  60894. * It can cast shadows.
  60895. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60896. * ```javascript
  60897. * var pointLight = new PointLight("pl", camera.position, scene);
  60898. * ```
  60899. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60900. * @param name The light friendly name
  60901. * @param position The position of the point light in the scene
  60902. * @param scene The scene the lights belongs to
  60903. */
  60904. constructor(name: string, position: Vector3, scene: Scene);
  60905. /**
  60906. * Returns the string "PointLight"
  60907. * @returns the class name
  60908. */
  60909. getClassName(): string;
  60910. /**
  60911. * Returns the integer 0.
  60912. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60913. */
  60914. getTypeID(): number;
  60915. /**
  60916. * Specifies wether or not the shadowmap should be a cube texture.
  60917. * @returns true if the shadowmap needs to be a cube texture.
  60918. */
  60919. needCube(): boolean;
  60920. /**
  60921. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60922. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60923. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60924. */
  60925. getShadowDirection(faceIndex?: number): Vector3;
  60926. /**
  60927. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60928. * - fov = PI / 2
  60929. * - aspect ratio : 1.0
  60930. * - z-near and far equal to the active camera minZ and maxZ.
  60931. * Returns the PointLight.
  60932. */
  60933. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60934. protected _buildUniformLayout(): void;
  60935. /**
  60936. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60937. * @param effect The effect to update
  60938. * @param lightIndex The index of the light in the effect to update
  60939. * @returns The point light
  60940. */
  60941. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60942. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60943. /**
  60944. * Prepares the list of defines specific to the light type.
  60945. * @param defines the list of defines
  60946. * @param lightIndex defines the index of the light for the effect
  60947. */
  60948. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60949. }
  60950. }
  60951. declare module BABYLON {
  60952. /**
  60953. * Header information of HDR texture files.
  60954. */
  60955. export interface HDRInfo {
  60956. /**
  60957. * The height of the texture in pixels.
  60958. */
  60959. height: number;
  60960. /**
  60961. * The width of the texture in pixels.
  60962. */
  60963. width: number;
  60964. /**
  60965. * The index of the beginning of the data in the binary file.
  60966. */
  60967. dataPosition: number;
  60968. }
  60969. /**
  60970. * This groups tools to convert HDR texture to native colors array.
  60971. */
  60972. export class HDRTools {
  60973. private static Ldexp;
  60974. private static Rgbe2float;
  60975. private static readStringLine;
  60976. /**
  60977. * Reads header information from an RGBE texture stored in a native array.
  60978. * More information on this format are available here:
  60979. * https://en.wikipedia.org/wiki/RGBE_image_format
  60980. *
  60981. * @param uint8array The binary file stored in native array.
  60982. * @return The header information.
  60983. */
  60984. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60985. /**
  60986. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60987. * This RGBE texture needs to store the information as a panorama.
  60988. *
  60989. * More information on this format are available here:
  60990. * https://en.wikipedia.org/wiki/RGBE_image_format
  60991. *
  60992. * @param buffer The binary file stored in an array buffer.
  60993. * @param size The expected size of the extracted cubemap.
  60994. * @return The Cube Map information.
  60995. */
  60996. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60997. /**
  60998. * Returns the pixels data extracted from an RGBE texture.
  60999. * This pixels will be stored left to right up to down in the R G B order in one array.
  61000. *
  61001. * More information on this format are available here:
  61002. * https://en.wikipedia.org/wiki/RGBE_image_format
  61003. *
  61004. * @param uint8array The binary file stored in an array buffer.
  61005. * @param hdrInfo The header information of the file.
  61006. * @return The pixels data in RGB right to left up to down order.
  61007. */
  61008. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61009. private static RGBE_ReadPixels_RLE;
  61010. private static RGBE_ReadPixels_NOT_RLE;
  61011. }
  61012. }
  61013. declare module BABYLON {
  61014. /**
  61015. * Effect Render Options
  61016. */
  61017. export interface IEffectRendererOptions {
  61018. /**
  61019. * Defines the vertices positions.
  61020. */
  61021. positions?: number[];
  61022. /**
  61023. * Defines the indices.
  61024. */
  61025. indices?: number[];
  61026. }
  61027. /**
  61028. * Helper class to render one or more effects.
  61029. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61030. */
  61031. export class EffectRenderer {
  61032. private engine;
  61033. private static _DefaultOptions;
  61034. private _vertexBuffers;
  61035. private _indexBuffer;
  61036. private _fullscreenViewport;
  61037. /**
  61038. * Creates an effect renderer
  61039. * @param engine the engine to use for rendering
  61040. * @param options defines the options of the effect renderer
  61041. */
  61042. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61043. /**
  61044. * Sets the current viewport in normalized coordinates 0-1
  61045. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61046. */
  61047. setViewport(viewport?: Viewport): void;
  61048. /**
  61049. * Binds the embedded attributes buffer to the effect.
  61050. * @param effect Defines the effect to bind the attributes for
  61051. */
  61052. bindBuffers(effect: Effect): void;
  61053. /**
  61054. * Sets the current effect wrapper to use during draw.
  61055. * The effect needs to be ready before calling this api.
  61056. * This also sets the default full screen position attribute.
  61057. * @param effectWrapper Defines the effect to draw with
  61058. */
  61059. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61060. /**
  61061. * Restores engine states
  61062. */
  61063. restoreStates(): void;
  61064. /**
  61065. * Draws a full screen quad.
  61066. */
  61067. draw(): void;
  61068. private isRenderTargetTexture;
  61069. /**
  61070. * renders one or more effects to a specified texture
  61071. * @param effectWrapper the effect to renderer
  61072. * @param outputTexture texture to draw to, if null it will render to the screen.
  61073. */
  61074. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61075. /**
  61076. * Disposes of the effect renderer
  61077. */
  61078. dispose(): void;
  61079. }
  61080. /**
  61081. * Options to create an EffectWrapper
  61082. */
  61083. interface EffectWrapperCreationOptions {
  61084. /**
  61085. * Engine to use to create the effect
  61086. */
  61087. engine: ThinEngine;
  61088. /**
  61089. * Fragment shader for the effect
  61090. */
  61091. fragmentShader: string;
  61092. /**
  61093. * Use the shader store instead of direct source code
  61094. */
  61095. useShaderStore?: boolean;
  61096. /**
  61097. * Vertex shader for the effect
  61098. */
  61099. vertexShader?: string;
  61100. /**
  61101. * Attributes to use in the shader
  61102. */
  61103. attributeNames?: Array<string>;
  61104. /**
  61105. * Uniforms to use in the shader
  61106. */
  61107. uniformNames?: Array<string>;
  61108. /**
  61109. * Texture sampler names to use in the shader
  61110. */
  61111. samplerNames?: Array<string>;
  61112. /**
  61113. * Defines to use in the shader
  61114. */
  61115. defines?: Array<string>;
  61116. /**
  61117. * Callback when effect is compiled
  61118. */
  61119. onCompiled?: Nullable<(effect: Effect) => void>;
  61120. /**
  61121. * The friendly name of the effect displayed in Spector.
  61122. */
  61123. name?: string;
  61124. }
  61125. /**
  61126. * Wraps an effect to be used for rendering
  61127. */
  61128. export class EffectWrapper {
  61129. /**
  61130. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61131. */
  61132. onApplyObservable: Observable<{}>;
  61133. /**
  61134. * The underlying effect
  61135. */
  61136. effect: Effect;
  61137. /**
  61138. * Creates an effect to be renderer
  61139. * @param creationOptions options to create the effect
  61140. */
  61141. constructor(creationOptions: EffectWrapperCreationOptions);
  61142. /**
  61143. * Disposes of the effect wrapper
  61144. */
  61145. dispose(): void;
  61146. }
  61147. }
  61148. declare module BABYLON {
  61149. /** @hidden */
  61150. export var hdrFilteringVertexShader: {
  61151. name: string;
  61152. shader: string;
  61153. };
  61154. }
  61155. declare module BABYLON {
  61156. /** @hidden */
  61157. export var hdrFilteringPixelShader: {
  61158. name: string;
  61159. shader: string;
  61160. };
  61161. }
  61162. declare module BABYLON {
  61163. /**
  61164. * Options for texture filtering
  61165. */
  61166. interface IHDRFilteringOptions {
  61167. /**
  61168. * Scales pixel intensity for the input HDR map.
  61169. */
  61170. hdrScale?: number;
  61171. /**
  61172. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61173. */
  61174. quality?: number;
  61175. }
  61176. /**
  61177. * Filters HDR maps to get correct renderings of PBR reflections
  61178. */
  61179. export class HDRFiltering {
  61180. private _engine;
  61181. private _effectRenderer;
  61182. private _effectWrapper;
  61183. private _lodGenerationOffset;
  61184. private _lodGenerationScale;
  61185. /**
  61186. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61187. * you care about baking speed.
  61188. */
  61189. quality: number;
  61190. /**
  61191. * Scales pixel intensity for the input HDR map.
  61192. */
  61193. hdrScale: number;
  61194. /**
  61195. * Instantiates HDR filter for reflection maps
  61196. *
  61197. * @param engine Thin engine
  61198. * @param options Options
  61199. */
  61200. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61201. private _createRenderTarget;
  61202. private _prefilterInternal;
  61203. private _createEffect;
  61204. /**
  61205. * Get a value indicating if the filter is ready to be used
  61206. * @param texture Texture to filter
  61207. * @returns true if the filter is ready
  61208. */
  61209. isReady(texture: BaseTexture): boolean;
  61210. /**
  61211. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61212. * Prefiltering will be invoked at the end of next rendering pass.
  61213. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61214. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61215. * @param texture Texture to filter
  61216. * @param onFinished Callback when filtering is done
  61217. * @return Promise called when prefiltering is done
  61218. */
  61219. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61220. }
  61221. }
  61222. declare module BABYLON {
  61223. /**
  61224. * This represents a texture coming from an HDR input.
  61225. *
  61226. * The only supported format is currently panorama picture stored in RGBE format.
  61227. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61228. */
  61229. export class HDRCubeTexture extends BaseTexture {
  61230. private static _facesMapping;
  61231. private _generateHarmonics;
  61232. private _noMipmap;
  61233. private _prefilterOnLoad;
  61234. private _textureMatrix;
  61235. private _size;
  61236. private _onLoad;
  61237. private _onError;
  61238. /**
  61239. * The texture URL.
  61240. */
  61241. url: string;
  61242. protected _isBlocking: boolean;
  61243. /**
  61244. * Sets wether or not the texture is blocking during loading.
  61245. */
  61246. set isBlocking(value: boolean);
  61247. /**
  61248. * Gets wether or not the texture is blocking during loading.
  61249. */
  61250. get isBlocking(): boolean;
  61251. protected _rotationY: number;
  61252. /**
  61253. * Sets texture matrix rotation angle around Y axis in radians.
  61254. */
  61255. set rotationY(value: number);
  61256. /**
  61257. * Gets texture matrix rotation angle around Y axis radians.
  61258. */
  61259. get rotationY(): number;
  61260. /**
  61261. * Gets or sets the center of the bounding box associated with the cube texture
  61262. * It must define where the camera used to render the texture was set
  61263. */
  61264. boundingBoxPosition: Vector3;
  61265. private _boundingBoxSize;
  61266. /**
  61267. * Gets or sets the size of the bounding box associated with the cube texture
  61268. * When defined, the cubemap will switch to local mode
  61269. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61270. * @example https://www.babylonjs-playground.com/#RNASML
  61271. */
  61272. set boundingBoxSize(value: Vector3);
  61273. get boundingBoxSize(): Vector3;
  61274. /**
  61275. * Instantiates an HDRTexture from the following parameters.
  61276. *
  61277. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61278. * @param sceneOrEngine The scene or engine the texture will be used in
  61279. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61280. * @param noMipmap Forces to not generate the mipmap if true
  61281. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61282. * @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)
  61283. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61284. */
  61285. 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>);
  61286. /**
  61287. * Get the current class name of the texture useful for serialization or dynamic coding.
  61288. * @returns "HDRCubeTexture"
  61289. */
  61290. getClassName(): string;
  61291. /**
  61292. * Occurs when the file is raw .hdr file.
  61293. */
  61294. private loadTexture;
  61295. clone(): HDRCubeTexture;
  61296. delayLoad(): void;
  61297. /**
  61298. * Get the texture reflection matrix used to rotate/transform the reflection.
  61299. * @returns the reflection matrix
  61300. */
  61301. getReflectionTextureMatrix(): Matrix;
  61302. /**
  61303. * Set the texture reflection matrix used to rotate/transform the reflection.
  61304. * @param value Define the reflection matrix to set
  61305. */
  61306. setReflectionTextureMatrix(value: Matrix): void;
  61307. /**
  61308. * Parses a JSON representation of an HDR Texture in order to create the texture
  61309. * @param parsedTexture Define the JSON representation
  61310. * @param scene Define the scene the texture should be created in
  61311. * @param rootUrl Define the root url in case we need to load relative dependencies
  61312. * @returns the newly created texture after parsing
  61313. */
  61314. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61315. serialize(): any;
  61316. }
  61317. }
  61318. declare module BABYLON {
  61319. /**
  61320. * Class used to control physics engine
  61321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61322. */
  61323. export class PhysicsEngine implements IPhysicsEngine {
  61324. private _physicsPlugin;
  61325. /**
  61326. * Global value used to control the smallest number supported by the simulation
  61327. */
  61328. static Epsilon: number;
  61329. private _impostors;
  61330. private _joints;
  61331. private _subTimeStep;
  61332. /**
  61333. * Gets the gravity vector used by the simulation
  61334. */
  61335. gravity: Vector3;
  61336. /**
  61337. * Factory used to create the default physics plugin.
  61338. * @returns The default physics plugin
  61339. */
  61340. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61341. /**
  61342. * Creates a new Physics Engine
  61343. * @param gravity defines the gravity vector used by the simulation
  61344. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61345. */
  61346. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61347. /**
  61348. * Sets the gravity vector used by the simulation
  61349. * @param gravity defines the gravity vector to use
  61350. */
  61351. setGravity(gravity: Vector3): void;
  61352. /**
  61353. * Set the time step of the physics engine.
  61354. * Default is 1/60.
  61355. * To slow it down, enter 1/600 for example.
  61356. * To speed it up, 1/30
  61357. * @param newTimeStep defines the new timestep to apply to this world.
  61358. */
  61359. setTimeStep(newTimeStep?: number): void;
  61360. /**
  61361. * Get the time step of the physics engine.
  61362. * @returns the current time step
  61363. */
  61364. getTimeStep(): number;
  61365. /**
  61366. * Set the sub time step of the physics engine.
  61367. * Default is 0 meaning there is no sub steps
  61368. * To increase physics resolution precision, set a small value (like 1 ms)
  61369. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61370. */
  61371. setSubTimeStep(subTimeStep?: number): void;
  61372. /**
  61373. * Get the sub time step of the physics engine.
  61374. * @returns the current sub time step
  61375. */
  61376. getSubTimeStep(): number;
  61377. /**
  61378. * Release all resources
  61379. */
  61380. dispose(): void;
  61381. /**
  61382. * Gets the name of the current physics plugin
  61383. * @returns the name of the plugin
  61384. */
  61385. getPhysicsPluginName(): string;
  61386. /**
  61387. * Adding a new impostor for the impostor tracking.
  61388. * This will be done by the impostor itself.
  61389. * @param impostor the impostor to add
  61390. */
  61391. addImpostor(impostor: PhysicsImpostor): void;
  61392. /**
  61393. * Remove an impostor from the engine.
  61394. * This impostor and its mesh will not longer be updated by the physics engine.
  61395. * @param impostor the impostor to remove
  61396. */
  61397. removeImpostor(impostor: PhysicsImpostor): void;
  61398. /**
  61399. * Add a joint to the physics engine
  61400. * @param mainImpostor defines the main impostor to which the joint is added.
  61401. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61402. * @param joint defines the joint that will connect both impostors.
  61403. */
  61404. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61405. /**
  61406. * Removes a joint from the simulation
  61407. * @param mainImpostor defines the impostor used with the joint
  61408. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61409. * @param joint defines the joint to remove
  61410. */
  61411. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61412. /**
  61413. * Called by the scene. No need to call it.
  61414. * @param delta defines the timespam between frames
  61415. */
  61416. _step(delta: number): void;
  61417. /**
  61418. * Gets the current plugin used to run the simulation
  61419. * @returns current plugin
  61420. */
  61421. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61422. /**
  61423. * Gets the list of physic impostors
  61424. * @returns an array of PhysicsImpostor
  61425. */
  61426. getImpostors(): Array<PhysicsImpostor>;
  61427. /**
  61428. * Gets the impostor for a physics enabled object
  61429. * @param object defines the object impersonated by the impostor
  61430. * @returns the PhysicsImpostor or null if not found
  61431. */
  61432. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61433. /**
  61434. * Gets the impostor for a physics body object
  61435. * @param body defines physics body used by the impostor
  61436. * @returns the PhysicsImpostor or null if not found
  61437. */
  61438. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61439. /**
  61440. * Does a raycast in the physics world
  61441. * @param from when should the ray start?
  61442. * @param to when should the ray end?
  61443. * @returns PhysicsRaycastResult
  61444. */
  61445. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61446. }
  61447. }
  61448. declare module BABYLON {
  61449. /** @hidden */
  61450. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61451. private _useDeltaForWorldStep;
  61452. world: any;
  61453. name: string;
  61454. private _physicsMaterials;
  61455. private _fixedTimeStep;
  61456. private _cannonRaycastResult;
  61457. private _raycastResult;
  61458. private _physicsBodysToRemoveAfterStep;
  61459. private _firstFrame;
  61460. BJSCANNON: any;
  61461. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61462. setGravity(gravity: Vector3): void;
  61463. setTimeStep(timeStep: number): void;
  61464. getTimeStep(): number;
  61465. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61466. private _removeMarkedPhysicsBodiesFromWorld;
  61467. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61468. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61469. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61470. private _processChildMeshes;
  61471. removePhysicsBody(impostor: PhysicsImpostor): void;
  61472. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61473. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61474. private _addMaterial;
  61475. private _checkWithEpsilon;
  61476. private _createShape;
  61477. private _createHeightmap;
  61478. private _minus90X;
  61479. private _plus90X;
  61480. private _tmpPosition;
  61481. private _tmpDeltaPosition;
  61482. private _tmpUnityRotation;
  61483. private _updatePhysicsBodyTransformation;
  61484. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61485. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61486. isSupported(): boolean;
  61487. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61488. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61489. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61490. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61491. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61492. getBodyMass(impostor: PhysicsImpostor): number;
  61493. getBodyFriction(impostor: PhysicsImpostor): number;
  61494. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61495. getBodyRestitution(impostor: PhysicsImpostor): number;
  61496. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61497. sleepBody(impostor: PhysicsImpostor): void;
  61498. wakeUpBody(impostor: PhysicsImpostor): void;
  61499. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61500. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61501. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61502. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61503. getRadius(impostor: PhysicsImpostor): number;
  61504. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61505. dispose(): void;
  61506. private _extendNamespace;
  61507. /**
  61508. * Does a raycast in the physics world
  61509. * @param from when should the ray start?
  61510. * @param to when should the ray end?
  61511. * @returns PhysicsRaycastResult
  61512. */
  61513. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61514. }
  61515. }
  61516. declare module BABYLON {
  61517. /** @hidden */
  61518. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61519. private _useDeltaForWorldStep;
  61520. world: any;
  61521. name: string;
  61522. BJSOIMO: any;
  61523. private _raycastResult;
  61524. private _fixedTimeStep;
  61525. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61526. setGravity(gravity: Vector3): void;
  61527. setTimeStep(timeStep: number): void;
  61528. getTimeStep(): number;
  61529. private _tmpImpostorsArray;
  61530. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61531. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61532. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61533. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61534. private _tmpPositionVector;
  61535. removePhysicsBody(impostor: PhysicsImpostor): void;
  61536. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61537. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61538. isSupported(): boolean;
  61539. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61540. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61541. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61542. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61543. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61544. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61545. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61546. getBodyMass(impostor: PhysicsImpostor): number;
  61547. getBodyFriction(impostor: PhysicsImpostor): number;
  61548. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61549. getBodyRestitution(impostor: PhysicsImpostor): number;
  61550. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61551. sleepBody(impostor: PhysicsImpostor): void;
  61552. wakeUpBody(impostor: PhysicsImpostor): void;
  61553. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61554. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61555. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61556. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61557. getRadius(impostor: PhysicsImpostor): number;
  61558. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61559. dispose(): void;
  61560. /**
  61561. * Does a raycast in the physics world
  61562. * @param from when should the ray start?
  61563. * @param to when should the ray end?
  61564. * @returns PhysicsRaycastResult
  61565. */
  61566. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61567. }
  61568. }
  61569. declare module BABYLON {
  61570. /**
  61571. * AmmoJS Physics plugin
  61572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61573. * @see https://github.com/kripken/ammo.js/
  61574. */
  61575. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61576. private _useDeltaForWorldStep;
  61577. /**
  61578. * Reference to the Ammo library
  61579. */
  61580. bjsAMMO: any;
  61581. /**
  61582. * Created ammoJS world which physics bodies are added to
  61583. */
  61584. world: any;
  61585. /**
  61586. * Name of the plugin
  61587. */
  61588. name: string;
  61589. private _timeStep;
  61590. private _fixedTimeStep;
  61591. private _maxSteps;
  61592. private _tmpQuaternion;
  61593. private _tmpAmmoTransform;
  61594. private _tmpAmmoQuaternion;
  61595. private _tmpAmmoConcreteContactResultCallback;
  61596. private _collisionConfiguration;
  61597. private _dispatcher;
  61598. private _overlappingPairCache;
  61599. private _solver;
  61600. private _softBodySolver;
  61601. private _tmpAmmoVectorA;
  61602. private _tmpAmmoVectorB;
  61603. private _tmpAmmoVectorC;
  61604. private _tmpAmmoVectorD;
  61605. private _tmpContactCallbackResult;
  61606. private _tmpAmmoVectorRCA;
  61607. private _tmpAmmoVectorRCB;
  61608. private _raycastResult;
  61609. private _tmpContactPoint;
  61610. private static readonly DISABLE_COLLISION_FLAG;
  61611. private static readonly KINEMATIC_FLAG;
  61612. private static readonly DISABLE_DEACTIVATION_FLAG;
  61613. /**
  61614. * Initializes the ammoJS plugin
  61615. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61616. * @param ammoInjection can be used to inject your own ammo reference
  61617. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61618. */
  61619. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61620. /**
  61621. * Sets the gravity of the physics world (m/(s^2))
  61622. * @param gravity Gravity to set
  61623. */
  61624. setGravity(gravity: Vector3): void;
  61625. /**
  61626. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61627. * @param timeStep timestep to use in seconds
  61628. */
  61629. setTimeStep(timeStep: number): void;
  61630. /**
  61631. * 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)
  61632. * @param fixedTimeStep fixedTimeStep to use in seconds
  61633. */
  61634. setFixedTimeStep(fixedTimeStep: number): void;
  61635. /**
  61636. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61637. * @param maxSteps the maximum number of steps by the physics engine per frame
  61638. */
  61639. setMaxSteps(maxSteps: number): void;
  61640. /**
  61641. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61642. * @returns the current timestep in seconds
  61643. */
  61644. getTimeStep(): number;
  61645. /**
  61646. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61647. */
  61648. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61649. private _isImpostorInContact;
  61650. private _isImpostorPairInContact;
  61651. private _stepSimulation;
  61652. /**
  61653. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61654. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61655. * After the step the babylon meshes are set to the position of the physics imposters
  61656. * @param delta amount of time to step forward
  61657. * @param impostors array of imposters to update before/after the step
  61658. */
  61659. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61660. /**
  61661. * Update babylon mesh to match physics world object
  61662. * @param impostor imposter to match
  61663. */
  61664. private _afterSoftStep;
  61665. /**
  61666. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61667. * @param impostor imposter to match
  61668. */
  61669. private _ropeStep;
  61670. /**
  61671. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61672. * @param impostor imposter to match
  61673. */
  61674. private _softbodyOrClothStep;
  61675. private _tmpMatrix;
  61676. /**
  61677. * Applies an impulse on the imposter
  61678. * @param impostor imposter to apply impulse to
  61679. * @param force amount of force to be applied to the imposter
  61680. * @param contactPoint the location to apply the impulse on the imposter
  61681. */
  61682. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61683. /**
  61684. * Applies a force on the imposter
  61685. * @param impostor imposter to apply force
  61686. * @param force amount of force to be applied to the imposter
  61687. * @param contactPoint the location to apply the force on the imposter
  61688. */
  61689. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61690. /**
  61691. * Creates a physics body using the plugin
  61692. * @param impostor the imposter to create the physics body on
  61693. */
  61694. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61695. /**
  61696. * Removes the physics body from the imposter and disposes of the body's memory
  61697. * @param impostor imposter to remove the physics body from
  61698. */
  61699. removePhysicsBody(impostor: PhysicsImpostor): void;
  61700. /**
  61701. * Generates a joint
  61702. * @param impostorJoint the imposter joint to create the joint with
  61703. */
  61704. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61705. /**
  61706. * Removes a joint
  61707. * @param impostorJoint the imposter joint to remove the joint from
  61708. */
  61709. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61710. private _addMeshVerts;
  61711. /**
  61712. * Initialise the soft body vertices to match its object's (mesh) vertices
  61713. * Softbody vertices (nodes) are in world space and to match this
  61714. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61715. * @param impostor to create the softbody for
  61716. */
  61717. private _softVertexData;
  61718. /**
  61719. * Create an impostor's soft body
  61720. * @param impostor to create the softbody for
  61721. */
  61722. private _createSoftbody;
  61723. /**
  61724. * Create cloth for an impostor
  61725. * @param impostor to create the softbody for
  61726. */
  61727. private _createCloth;
  61728. /**
  61729. * Create rope for an impostor
  61730. * @param impostor to create the softbody for
  61731. */
  61732. private _createRope;
  61733. /**
  61734. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61735. * @param impostor to create the custom physics shape for
  61736. */
  61737. private _createCustom;
  61738. private _addHullVerts;
  61739. private _createShape;
  61740. /**
  61741. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61742. * @param impostor imposter containing the physics body and babylon object
  61743. */
  61744. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61745. /**
  61746. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61747. * @param impostor imposter containing the physics body and babylon object
  61748. * @param newPosition new position
  61749. * @param newRotation new rotation
  61750. */
  61751. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61752. /**
  61753. * If this plugin is supported
  61754. * @returns true if its supported
  61755. */
  61756. isSupported(): boolean;
  61757. /**
  61758. * Sets the linear velocity of the physics body
  61759. * @param impostor imposter to set the velocity on
  61760. * @param velocity velocity to set
  61761. */
  61762. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61763. /**
  61764. * Sets the angular velocity of the physics body
  61765. * @param impostor imposter to set the velocity on
  61766. * @param velocity velocity to set
  61767. */
  61768. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61769. /**
  61770. * gets the linear velocity
  61771. * @param impostor imposter to get linear velocity from
  61772. * @returns linear velocity
  61773. */
  61774. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61775. /**
  61776. * gets the angular velocity
  61777. * @param impostor imposter to get angular velocity from
  61778. * @returns angular velocity
  61779. */
  61780. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61781. /**
  61782. * Sets the mass of physics body
  61783. * @param impostor imposter to set the mass on
  61784. * @param mass mass to set
  61785. */
  61786. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61787. /**
  61788. * Gets the mass of the physics body
  61789. * @param impostor imposter to get the mass from
  61790. * @returns mass
  61791. */
  61792. getBodyMass(impostor: PhysicsImpostor): number;
  61793. /**
  61794. * Gets friction of the impostor
  61795. * @param impostor impostor to get friction from
  61796. * @returns friction value
  61797. */
  61798. getBodyFriction(impostor: PhysicsImpostor): number;
  61799. /**
  61800. * Sets friction of the impostor
  61801. * @param impostor impostor to set friction on
  61802. * @param friction friction value
  61803. */
  61804. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61805. /**
  61806. * Gets restitution of the impostor
  61807. * @param impostor impostor to get restitution from
  61808. * @returns restitution value
  61809. */
  61810. getBodyRestitution(impostor: PhysicsImpostor): number;
  61811. /**
  61812. * Sets resitution of the impostor
  61813. * @param impostor impostor to set resitution on
  61814. * @param restitution resitution value
  61815. */
  61816. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61817. /**
  61818. * Gets pressure inside the impostor
  61819. * @param impostor impostor to get pressure from
  61820. * @returns pressure value
  61821. */
  61822. getBodyPressure(impostor: PhysicsImpostor): number;
  61823. /**
  61824. * Sets pressure inside a soft body impostor
  61825. * Cloth and rope must remain 0 pressure
  61826. * @param impostor impostor to set pressure on
  61827. * @param pressure pressure value
  61828. */
  61829. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61830. /**
  61831. * Gets stiffness of the impostor
  61832. * @param impostor impostor to get stiffness from
  61833. * @returns pressure value
  61834. */
  61835. getBodyStiffness(impostor: PhysicsImpostor): number;
  61836. /**
  61837. * Sets stiffness of the impostor
  61838. * @param impostor impostor to set stiffness on
  61839. * @param stiffness stiffness value from 0 to 1
  61840. */
  61841. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61842. /**
  61843. * Gets velocityIterations of the impostor
  61844. * @param impostor impostor to get velocity iterations from
  61845. * @returns velocityIterations value
  61846. */
  61847. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61848. /**
  61849. * Sets velocityIterations of the impostor
  61850. * @param impostor impostor to set velocity iterations on
  61851. * @param velocityIterations velocityIterations value
  61852. */
  61853. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61854. /**
  61855. * Gets positionIterations of the impostor
  61856. * @param impostor impostor to get position iterations from
  61857. * @returns positionIterations value
  61858. */
  61859. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61860. /**
  61861. * Sets positionIterations of the impostor
  61862. * @param impostor impostor to set position on
  61863. * @param positionIterations positionIterations value
  61864. */
  61865. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61866. /**
  61867. * Append an anchor to a cloth object
  61868. * @param impostor is the cloth impostor to add anchor to
  61869. * @param otherImpostor is the rigid impostor to anchor to
  61870. * @param width ratio across width from 0 to 1
  61871. * @param height ratio up height from 0 to 1
  61872. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61873. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61874. */
  61875. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61876. /**
  61877. * Append an hook to a rope object
  61878. * @param impostor is the rope impostor to add hook to
  61879. * @param otherImpostor is the rigid impostor to hook to
  61880. * @param length ratio along the rope from 0 to 1
  61881. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61882. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61883. */
  61884. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61885. /**
  61886. * Sleeps the physics body and stops it from being active
  61887. * @param impostor impostor to sleep
  61888. */
  61889. sleepBody(impostor: PhysicsImpostor): void;
  61890. /**
  61891. * Activates the physics body
  61892. * @param impostor impostor to activate
  61893. */
  61894. wakeUpBody(impostor: PhysicsImpostor): void;
  61895. /**
  61896. * Updates the distance parameters of the joint
  61897. * @param joint joint to update
  61898. * @param maxDistance maximum distance of the joint
  61899. * @param minDistance minimum distance of the joint
  61900. */
  61901. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61902. /**
  61903. * Sets a motor on the joint
  61904. * @param joint joint to set motor on
  61905. * @param speed speed of the motor
  61906. * @param maxForce maximum force of the motor
  61907. * @param motorIndex index of the motor
  61908. */
  61909. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61910. /**
  61911. * Sets the motors limit
  61912. * @param joint joint to set limit on
  61913. * @param upperLimit upper limit
  61914. * @param lowerLimit lower limit
  61915. */
  61916. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61917. /**
  61918. * Syncs the position and rotation of a mesh with the impostor
  61919. * @param mesh mesh to sync
  61920. * @param impostor impostor to update the mesh with
  61921. */
  61922. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61923. /**
  61924. * Gets the radius of the impostor
  61925. * @param impostor impostor to get radius from
  61926. * @returns the radius
  61927. */
  61928. getRadius(impostor: PhysicsImpostor): number;
  61929. /**
  61930. * Gets the box size of the impostor
  61931. * @param impostor impostor to get box size from
  61932. * @param result the resulting box size
  61933. */
  61934. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61935. /**
  61936. * Disposes of the impostor
  61937. */
  61938. dispose(): void;
  61939. /**
  61940. * Does a raycast in the physics world
  61941. * @param from when should the ray start?
  61942. * @param to when should the ray end?
  61943. * @returns PhysicsRaycastResult
  61944. */
  61945. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61946. }
  61947. }
  61948. declare module BABYLON {
  61949. interface AbstractScene {
  61950. /**
  61951. * The list of reflection probes added to the scene
  61952. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61953. */
  61954. reflectionProbes: Array<ReflectionProbe>;
  61955. /**
  61956. * Removes the given reflection probe from this scene.
  61957. * @param toRemove The reflection probe to remove
  61958. * @returns The index of the removed reflection probe
  61959. */
  61960. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61961. /**
  61962. * Adds the given reflection probe to this scene.
  61963. * @param newReflectionProbe The reflection probe to add
  61964. */
  61965. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61966. }
  61967. /**
  61968. * Class used to generate realtime reflection / refraction cube textures
  61969. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61970. */
  61971. export class ReflectionProbe {
  61972. /** defines the name of the probe */
  61973. name: string;
  61974. private _scene;
  61975. private _renderTargetTexture;
  61976. private _projectionMatrix;
  61977. private _viewMatrix;
  61978. private _target;
  61979. private _add;
  61980. private _attachedMesh;
  61981. private _invertYAxis;
  61982. /** Gets or sets probe position (center of the cube map) */
  61983. position: Vector3;
  61984. /**
  61985. * Creates a new reflection probe
  61986. * @param name defines the name of the probe
  61987. * @param size defines the texture resolution (for each face)
  61988. * @param scene defines the hosting scene
  61989. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61990. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61991. */
  61992. constructor(
  61993. /** defines the name of the probe */
  61994. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61995. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61996. get samples(): number;
  61997. set samples(value: number);
  61998. /** Gets or sets the refresh rate to use (on every frame by default) */
  61999. get refreshRate(): number;
  62000. set refreshRate(value: number);
  62001. /**
  62002. * Gets the hosting scene
  62003. * @returns a Scene
  62004. */
  62005. getScene(): Scene;
  62006. /** Gets the internal CubeTexture used to render to */
  62007. get cubeTexture(): RenderTargetTexture;
  62008. /** Gets the list of meshes to render */
  62009. get renderList(): Nullable<AbstractMesh[]>;
  62010. /**
  62011. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62012. * @param mesh defines the mesh to attach to
  62013. */
  62014. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62015. /**
  62016. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62017. * @param renderingGroupId The rendering group id corresponding to its index
  62018. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62019. */
  62020. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62021. /**
  62022. * Clean all associated resources
  62023. */
  62024. dispose(): void;
  62025. /**
  62026. * Converts the reflection probe information to a readable string for debug purpose.
  62027. * @param fullDetails Supports for multiple levels of logging within scene loading
  62028. * @returns the human readable reflection probe info
  62029. */
  62030. toString(fullDetails?: boolean): string;
  62031. /**
  62032. * Get the class name of the relfection probe.
  62033. * @returns "ReflectionProbe"
  62034. */
  62035. getClassName(): string;
  62036. /**
  62037. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62038. * @returns The JSON representation of the texture
  62039. */
  62040. serialize(): any;
  62041. /**
  62042. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62043. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62044. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62045. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62046. * @returns The parsed reflection probe if successful
  62047. */
  62048. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62049. }
  62050. }
  62051. declare module BABYLON {
  62052. /** @hidden */
  62053. export var _BabylonLoaderRegistered: boolean;
  62054. /**
  62055. * Helps setting up some configuration for the babylon file loader.
  62056. */
  62057. export class BabylonFileLoaderConfiguration {
  62058. /**
  62059. * The loader does not allow injecting custom physix engine into the plugins.
  62060. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62061. * So you could set this variable to your engine import to make it work.
  62062. */
  62063. static LoaderInjectedPhysicsEngine: any;
  62064. }
  62065. }
  62066. declare module BABYLON {
  62067. /**
  62068. * The Physically based simple base material of BJS.
  62069. *
  62070. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62071. * It is used as the base class for both the specGloss and metalRough conventions.
  62072. */
  62073. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62074. /**
  62075. * Number of Simultaneous lights allowed on the material.
  62076. */
  62077. maxSimultaneousLights: number;
  62078. /**
  62079. * If sets to true, disables all the lights affecting the material.
  62080. */
  62081. disableLighting: boolean;
  62082. /**
  62083. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62084. */
  62085. environmentTexture: BaseTexture;
  62086. /**
  62087. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62088. */
  62089. invertNormalMapX: boolean;
  62090. /**
  62091. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62092. */
  62093. invertNormalMapY: boolean;
  62094. /**
  62095. * Normal map used in the model.
  62096. */
  62097. normalTexture: BaseTexture;
  62098. /**
  62099. * Emissivie color used to self-illuminate the model.
  62100. */
  62101. emissiveColor: Color3;
  62102. /**
  62103. * Emissivie texture used to self-illuminate the model.
  62104. */
  62105. emissiveTexture: BaseTexture;
  62106. /**
  62107. * Occlusion Channel Strenght.
  62108. */
  62109. occlusionStrength: number;
  62110. /**
  62111. * Occlusion Texture of the material (adding extra occlusion effects).
  62112. */
  62113. occlusionTexture: BaseTexture;
  62114. /**
  62115. * Defines the alpha limits in alpha test mode.
  62116. */
  62117. alphaCutOff: number;
  62118. /**
  62119. * Gets the current double sided mode.
  62120. */
  62121. get doubleSided(): boolean;
  62122. /**
  62123. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62124. */
  62125. set doubleSided(value: boolean);
  62126. /**
  62127. * Stores the pre-calculated light information of a mesh in a texture.
  62128. */
  62129. lightmapTexture: BaseTexture;
  62130. /**
  62131. * If true, the light map contains occlusion information instead of lighting info.
  62132. */
  62133. useLightmapAsShadowmap: boolean;
  62134. /**
  62135. * Instantiates a new PBRMaterial instance.
  62136. *
  62137. * @param name The material name
  62138. * @param scene The scene the material will be use in.
  62139. */
  62140. constructor(name: string, scene: Scene);
  62141. getClassName(): string;
  62142. }
  62143. }
  62144. declare module BABYLON {
  62145. /**
  62146. * The PBR material of BJS following the metal roughness convention.
  62147. *
  62148. * This fits to the PBR convention in the GLTF definition:
  62149. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62150. */
  62151. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62152. /**
  62153. * The base color has two different interpretations depending on the value of metalness.
  62154. * When the material is a metal, the base color is the specific measured reflectance value
  62155. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62156. * of the material.
  62157. */
  62158. baseColor: Color3;
  62159. /**
  62160. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62161. * well as opacity information in the alpha channel.
  62162. */
  62163. baseTexture: BaseTexture;
  62164. /**
  62165. * Specifies the metallic scalar value of the material.
  62166. * Can also be used to scale the metalness values of the metallic texture.
  62167. */
  62168. metallic: number;
  62169. /**
  62170. * Specifies the roughness scalar value of the material.
  62171. * Can also be used to scale the roughness values of the metallic texture.
  62172. */
  62173. roughness: number;
  62174. /**
  62175. * Texture containing both the metallic value in the B channel and the
  62176. * roughness value in the G channel to keep better precision.
  62177. */
  62178. metallicRoughnessTexture: BaseTexture;
  62179. /**
  62180. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62181. *
  62182. * @param name The material name
  62183. * @param scene The scene the material will be use in.
  62184. */
  62185. constructor(name: string, scene: Scene);
  62186. /**
  62187. * Return the currrent class name of the material.
  62188. */
  62189. getClassName(): string;
  62190. /**
  62191. * Makes a duplicate of the current material.
  62192. * @param name - name to use for the new material.
  62193. */
  62194. clone(name: string): PBRMetallicRoughnessMaterial;
  62195. /**
  62196. * Serialize the material to a parsable JSON object.
  62197. */
  62198. serialize(): any;
  62199. /**
  62200. * Parses a JSON object correponding to the serialize function.
  62201. */
  62202. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62203. }
  62204. }
  62205. declare module BABYLON {
  62206. /**
  62207. * The PBR material of BJS following the specular glossiness convention.
  62208. *
  62209. * This fits to the PBR convention in the GLTF definition:
  62210. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62211. */
  62212. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62213. /**
  62214. * Specifies the diffuse color of the material.
  62215. */
  62216. diffuseColor: Color3;
  62217. /**
  62218. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62219. * channel.
  62220. */
  62221. diffuseTexture: BaseTexture;
  62222. /**
  62223. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62224. */
  62225. specularColor: Color3;
  62226. /**
  62227. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62228. */
  62229. glossiness: number;
  62230. /**
  62231. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62232. */
  62233. specularGlossinessTexture: BaseTexture;
  62234. /**
  62235. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62236. *
  62237. * @param name The material name
  62238. * @param scene The scene the material will be use in.
  62239. */
  62240. constructor(name: string, scene: Scene);
  62241. /**
  62242. * Return the currrent class name of the material.
  62243. */
  62244. getClassName(): string;
  62245. /**
  62246. * Makes a duplicate of the current material.
  62247. * @param name - name to use for the new material.
  62248. */
  62249. clone(name: string): PBRSpecularGlossinessMaterial;
  62250. /**
  62251. * Serialize the material to a parsable JSON object.
  62252. */
  62253. serialize(): any;
  62254. /**
  62255. * Parses a JSON object correponding to the serialize function.
  62256. */
  62257. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62258. }
  62259. }
  62260. declare module BABYLON {
  62261. /**
  62262. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62263. * It can help converting any input color in a desired output one. This can then be used to create effects
  62264. * from sepia, black and white to sixties or futuristic rendering...
  62265. *
  62266. * The only supported format is currently 3dl.
  62267. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62268. */
  62269. export class ColorGradingTexture extends BaseTexture {
  62270. /**
  62271. * The texture URL.
  62272. */
  62273. url: string;
  62274. /**
  62275. * Empty line regex stored for GC.
  62276. */
  62277. private static _noneEmptyLineRegex;
  62278. private _textureMatrix;
  62279. private _onLoad;
  62280. /**
  62281. * Instantiates a ColorGradingTexture from the following parameters.
  62282. *
  62283. * @param url The location of the color gradind data (currently only supporting 3dl)
  62284. * @param sceneOrEngine The scene or engine the texture will be used in
  62285. * @param onLoad defines a callback triggered when the texture has been loaded
  62286. */
  62287. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62288. /**
  62289. * Fires the onload event from the constructor if requested.
  62290. */
  62291. private _triggerOnLoad;
  62292. /**
  62293. * Returns the texture matrix used in most of the material.
  62294. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62295. */
  62296. getTextureMatrix(): Matrix;
  62297. /**
  62298. * Occurs when the file being loaded is a .3dl LUT file.
  62299. */
  62300. private load3dlTexture;
  62301. /**
  62302. * Starts the loading process of the texture.
  62303. */
  62304. private loadTexture;
  62305. /**
  62306. * Clones the color gradind texture.
  62307. */
  62308. clone(): ColorGradingTexture;
  62309. /**
  62310. * Called during delayed load for textures.
  62311. */
  62312. delayLoad(): void;
  62313. /**
  62314. * Parses a color grading texture serialized by Babylon.
  62315. * @param parsedTexture The texture information being parsedTexture
  62316. * @param scene The scene to load the texture in
  62317. * @param rootUrl The root url of the data assets to load
  62318. * @return A color gradind texture
  62319. */
  62320. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62321. /**
  62322. * Serializes the LUT texture to json format.
  62323. */
  62324. serialize(): any;
  62325. }
  62326. }
  62327. declare module BABYLON {
  62328. /**
  62329. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62330. */
  62331. export class EquiRectangularCubeTexture extends BaseTexture {
  62332. /** The six faces of the cube. */
  62333. private static _FacesMapping;
  62334. private _noMipmap;
  62335. private _onLoad;
  62336. private _onError;
  62337. /** The size of the cubemap. */
  62338. private _size;
  62339. /** The buffer of the image. */
  62340. private _buffer;
  62341. /** The width of the input image. */
  62342. private _width;
  62343. /** The height of the input image. */
  62344. private _height;
  62345. /** The URL to the image. */
  62346. url: string;
  62347. /**
  62348. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62349. * @param url The location of the image
  62350. * @param scene The scene the texture will be used in
  62351. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62352. * @param noMipmap Forces to not generate the mipmap if true
  62353. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62354. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62355. * @param onLoad — defines a callback called when texture is loaded
  62356. * @param onError — defines a callback called if there is an error
  62357. */
  62358. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62359. /**
  62360. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62361. */
  62362. private loadImage;
  62363. /**
  62364. * Convert the image buffer into a cubemap and create a CubeTexture.
  62365. */
  62366. private loadTexture;
  62367. /**
  62368. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62369. * @param buffer The ArrayBuffer that should be converted.
  62370. * @returns The buffer as Float32Array.
  62371. */
  62372. private getFloat32ArrayFromArrayBuffer;
  62373. /**
  62374. * Get the current class name of the texture useful for serialization or dynamic coding.
  62375. * @returns "EquiRectangularCubeTexture"
  62376. */
  62377. getClassName(): string;
  62378. /**
  62379. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62380. * @returns A clone of the current EquiRectangularCubeTexture.
  62381. */
  62382. clone(): EquiRectangularCubeTexture;
  62383. }
  62384. }
  62385. declare module BABYLON {
  62386. /**
  62387. * Defines the options related to the creation of an HtmlElementTexture
  62388. */
  62389. export interface IHtmlElementTextureOptions {
  62390. /**
  62391. * Defines wether mip maps should be created or not.
  62392. */
  62393. generateMipMaps?: boolean;
  62394. /**
  62395. * Defines the sampling mode of the texture.
  62396. */
  62397. samplingMode?: number;
  62398. /**
  62399. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62400. */
  62401. engine: Nullable<ThinEngine>;
  62402. /**
  62403. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62404. */
  62405. scene: Nullable<Scene>;
  62406. }
  62407. /**
  62408. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62409. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62410. * is automatically managed.
  62411. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62412. * in your application.
  62413. *
  62414. * As the update is not automatic, you need to call them manually.
  62415. */
  62416. export class HtmlElementTexture extends BaseTexture {
  62417. /**
  62418. * The texture URL.
  62419. */
  62420. element: HTMLVideoElement | HTMLCanvasElement;
  62421. private static readonly DefaultOptions;
  62422. private _textureMatrix;
  62423. private _isVideo;
  62424. private _generateMipMaps;
  62425. private _samplingMode;
  62426. /**
  62427. * Instantiates a HtmlElementTexture from the following parameters.
  62428. *
  62429. * @param name Defines the name of the texture
  62430. * @param element Defines the video or canvas the texture is filled with
  62431. * @param options Defines the other none mandatory texture creation options
  62432. */
  62433. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62434. private _createInternalTexture;
  62435. /**
  62436. * Returns the texture matrix used in most of the material.
  62437. */
  62438. getTextureMatrix(): Matrix;
  62439. /**
  62440. * Updates the content of the texture.
  62441. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62442. */
  62443. update(invertY?: Nullable<boolean>): void;
  62444. }
  62445. }
  62446. declare module BABYLON {
  62447. /**
  62448. * Based on jsTGALoader - Javascript loader for TGA file
  62449. * By Vincent Thibault
  62450. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62451. */
  62452. export class TGATools {
  62453. private static _TYPE_INDEXED;
  62454. private static _TYPE_RGB;
  62455. private static _TYPE_GREY;
  62456. private static _TYPE_RLE_INDEXED;
  62457. private static _TYPE_RLE_RGB;
  62458. private static _TYPE_RLE_GREY;
  62459. private static _ORIGIN_MASK;
  62460. private static _ORIGIN_SHIFT;
  62461. private static _ORIGIN_BL;
  62462. private static _ORIGIN_BR;
  62463. private static _ORIGIN_UL;
  62464. private static _ORIGIN_UR;
  62465. /**
  62466. * Gets the header of a TGA file
  62467. * @param data defines the TGA data
  62468. * @returns the header
  62469. */
  62470. static GetTGAHeader(data: Uint8Array): any;
  62471. /**
  62472. * Uploads TGA content to a Babylon Texture
  62473. * @hidden
  62474. */
  62475. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62476. /** @hidden */
  62477. 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;
  62478. /** @hidden */
  62479. 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;
  62480. /** @hidden */
  62481. 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;
  62482. /** @hidden */
  62483. 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;
  62484. /** @hidden */
  62485. 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;
  62486. /** @hidden */
  62487. 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;
  62488. }
  62489. }
  62490. declare module BABYLON {
  62491. /**
  62492. * Implementation of the TGA Texture Loader.
  62493. * @hidden
  62494. */
  62495. export class _TGATextureLoader implements IInternalTextureLoader {
  62496. /**
  62497. * Defines wether the loader supports cascade loading the different faces.
  62498. */
  62499. readonly supportCascades: boolean;
  62500. /**
  62501. * This returns if the loader support the current file information.
  62502. * @param extension defines the file extension of the file being loaded
  62503. * @returns true if the loader can load the specified file
  62504. */
  62505. canLoad(extension: string): boolean;
  62506. /**
  62507. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62508. * @param data contains the texture data
  62509. * @param texture defines the BabylonJS internal texture
  62510. * @param createPolynomials will be true if polynomials have been requested
  62511. * @param onLoad defines the callback to trigger once the texture is ready
  62512. * @param onError defines the callback to trigger in case of error
  62513. */
  62514. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62515. /**
  62516. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62517. * @param data contains the texture data
  62518. * @param texture defines the BabylonJS internal texture
  62519. * @param callback defines the method to call once ready to upload
  62520. */
  62521. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62522. }
  62523. }
  62524. declare module BABYLON {
  62525. /**
  62526. * Info about the .basis files
  62527. */
  62528. class BasisFileInfo {
  62529. /**
  62530. * If the file has alpha
  62531. */
  62532. hasAlpha: boolean;
  62533. /**
  62534. * Info about each image of the basis file
  62535. */
  62536. images: Array<{
  62537. levels: Array<{
  62538. width: number;
  62539. height: number;
  62540. transcodedPixels: ArrayBufferView;
  62541. }>;
  62542. }>;
  62543. }
  62544. /**
  62545. * Result of transcoding a basis file
  62546. */
  62547. class TranscodeResult {
  62548. /**
  62549. * Info about the .basis file
  62550. */
  62551. fileInfo: BasisFileInfo;
  62552. /**
  62553. * Format to use when loading the file
  62554. */
  62555. format: number;
  62556. }
  62557. /**
  62558. * Configuration options for the Basis transcoder
  62559. */
  62560. export class BasisTranscodeConfiguration {
  62561. /**
  62562. * Supported compression formats used to determine the supported output format of the transcoder
  62563. */
  62564. supportedCompressionFormats?: {
  62565. /**
  62566. * etc1 compression format
  62567. */
  62568. etc1?: boolean;
  62569. /**
  62570. * s3tc compression format
  62571. */
  62572. s3tc?: boolean;
  62573. /**
  62574. * pvrtc compression format
  62575. */
  62576. pvrtc?: boolean;
  62577. /**
  62578. * etc2 compression format
  62579. */
  62580. etc2?: boolean;
  62581. };
  62582. /**
  62583. * If mipmap levels should be loaded for transcoded images (Default: true)
  62584. */
  62585. loadMipmapLevels?: boolean;
  62586. /**
  62587. * Index of a single image to load (Default: all images)
  62588. */
  62589. loadSingleImage?: number;
  62590. }
  62591. /**
  62592. * Used to load .Basis files
  62593. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62594. */
  62595. export class BasisTools {
  62596. private static _IgnoreSupportedFormats;
  62597. /**
  62598. * URL to use when loading the basis transcoder
  62599. */
  62600. static JSModuleURL: string;
  62601. /**
  62602. * URL to use when loading the wasm module for the transcoder
  62603. */
  62604. static WasmModuleURL: string;
  62605. /**
  62606. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62607. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62608. * @returns internal format corresponding to the Basis format
  62609. */
  62610. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62611. private static _WorkerPromise;
  62612. private static _Worker;
  62613. private static _actionId;
  62614. private static _CreateWorkerAsync;
  62615. /**
  62616. * Transcodes a loaded image file to compressed pixel data
  62617. * @param data image data to transcode
  62618. * @param config configuration options for the transcoding
  62619. * @returns a promise resulting in the transcoded image
  62620. */
  62621. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62622. /**
  62623. * Loads a texture from the transcode result
  62624. * @param texture texture load to
  62625. * @param transcodeResult the result of transcoding the basis file to load from
  62626. */
  62627. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62628. }
  62629. }
  62630. declare module BABYLON {
  62631. /**
  62632. * Loader for .basis file format
  62633. */
  62634. export class _BasisTextureLoader implements IInternalTextureLoader {
  62635. /**
  62636. * Defines whether the loader supports cascade loading the different faces.
  62637. */
  62638. readonly supportCascades: boolean;
  62639. /**
  62640. * This returns if the loader support the current file information.
  62641. * @param extension defines the file extension of the file being loaded
  62642. * @returns true if the loader can load the specified file
  62643. */
  62644. canLoad(extension: string): boolean;
  62645. /**
  62646. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62647. * @param data contains the texture data
  62648. * @param texture defines the BabylonJS internal texture
  62649. * @param createPolynomials will be true if polynomials have been requested
  62650. * @param onLoad defines the callback to trigger once the texture is ready
  62651. * @param onError defines the callback to trigger in case of error
  62652. */
  62653. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62654. /**
  62655. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62656. * @param data contains the texture data
  62657. * @param texture defines the BabylonJS internal texture
  62658. * @param callback defines the method to call once ready to upload
  62659. */
  62660. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62661. }
  62662. }
  62663. declare module BABYLON {
  62664. /**
  62665. * Defines the basic options interface of a TexturePacker Frame
  62666. */
  62667. export interface ITexturePackerFrame {
  62668. /**
  62669. * The frame ID
  62670. */
  62671. id: number;
  62672. /**
  62673. * The frames Scale
  62674. */
  62675. scale: Vector2;
  62676. /**
  62677. * The Frames offset
  62678. */
  62679. offset: Vector2;
  62680. }
  62681. /**
  62682. * This is a support class for frame Data on texture packer sets.
  62683. */
  62684. export class TexturePackerFrame implements ITexturePackerFrame {
  62685. /**
  62686. * The frame ID
  62687. */
  62688. id: number;
  62689. /**
  62690. * The frames Scale
  62691. */
  62692. scale: Vector2;
  62693. /**
  62694. * The Frames offset
  62695. */
  62696. offset: Vector2;
  62697. /**
  62698. * Initializes a texture package frame.
  62699. * @param id The numerical frame identifier
  62700. * @param scale Scalar Vector2 for UV frame
  62701. * @param offset Vector2 for the frame position in UV units.
  62702. * @returns TexturePackerFrame
  62703. */
  62704. constructor(id: number, scale: Vector2, offset: Vector2);
  62705. }
  62706. }
  62707. declare module BABYLON {
  62708. /**
  62709. * Defines the basic options interface of a TexturePacker
  62710. */
  62711. export interface ITexturePackerOptions {
  62712. /**
  62713. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62714. */
  62715. map?: string[];
  62716. /**
  62717. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62718. */
  62719. uvsIn?: string;
  62720. /**
  62721. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62722. */
  62723. uvsOut?: string;
  62724. /**
  62725. * number representing the layout style. Defaults to LAYOUT_STRIP
  62726. */
  62727. layout?: number;
  62728. /**
  62729. * number of columns if using custom column count layout(2). This defaults to 4.
  62730. */
  62731. colnum?: number;
  62732. /**
  62733. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62734. */
  62735. updateInputMeshes?: boolean;
  62736. /**
  62737. * boolean flag to dispose all the source textures. Defaults to true.
  62738. */
  62739. disposeSources?: boolean;
  62740. /**
  62741. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62742. */
  62743. fillBlanks?: boolean;
  62744. /**
  62745. * string value representing the context fill style color. Defaults to 'black'.
  62746. */
  62747. customFillColor?: string;
  62748. /**
  62749. * Width and Height Value of each Frame in the TexturePacker Sets
  62750. */
  62751. frameSize?: number;
  62752. /**
  62753. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62754. */
  62755. paddingRatio?: number;
  62756. /**
  62757. * Number that declares the fill method for the padding gutter.
  62758. */
  62759. paddingMode?: number;
  62760. /**
  62761. * If in SUBUV_COLOR padding mode what color to use.
  62762. */
  62763. paddingColor?: Color3 | Color4;
  62764. }
  62765. /**
  62766. * Defines the basic interface of a TexturePacker JSON File
  62767. */
  62768. export interface ITexturePackerJSON {
  62769. /**
  62770. * The frame ID
  62771. */
  62772. name: string;
  62773. /**
  62774. * The base64 channel data
  62775. */
  62776. sets: any;
  62777. /**
  62778. * The options of the Packer
  62779. */
  62780. options: ITexturePackerOptions;
  62781. /**
  62782. * The frame data of the Packer
  62783. */
  62784. frames: Array<number>;
  62785. }
  62786. /**
  62787. * This is a support class that generates a series of packed texture sets.
  62788. * @see https://doc.babylonjs.com/babylon101/materials
  62789. */
  62790. export class TexturePacker {
  62791. /** Packer Layout Constant 0 */
  62792. static readonly LAYOUT_STRIP: number;
  62793. /** Packer Layout Constant 1 */
  62794. static readonly LAYOUT_POWER2: number;
  62795. /** Packer Layout Constant 2 */
  62796. static readonly LAYOUT_COLNUM: number;
  62797. /** Packer Layout Constant 0 */
  62798. static readonly SUBUV_WRAP: number;
  62799. /** Packer Layout Constant 1 */
  62800. static readonly SUBUV_EXTEND: number;
  62801. /** Packer Layout Constant 2 */
  62802. static readonly SUBUV_COLOR: number;
  62803. /** The Name of the Texture Package */
  62804. name: string;
  62805. /** The scene scope of the TexturePacker */
  62806. scene: Scene;
  62807. /** The Meshes to target */
  62808. meshes: AbstractMesh[];
  62809. /** Arguments passed with the Constructor */
  62810. options: ITexturePackerOptions;
  62811. /** The promise that is started upon initialization */
  62812. promise: Nullable<Promise<TexturePacker | string>>;
  62813. /** The Container object for the channel sets that are generated */
  62814. sets: object;
  62815. /** The Container array for the frames that are generated */
  62816. frames: TexturePackerFrame[];
  62817. /** The expected number of textures the system is parsing. */
  62818. private _expecting;
  62819. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62820. private _paddingValue;
  62821. /**
  62822. * Initializes a texture package series from an array of meshes or a single mesh.
  62823. * @param name The name of the package
  62824. * @param meshes The target meshes to compose the package from
  62825. * @param options The arguments that texture packer should follow while building.
  62826. * @param scene The scene which the textures are scoped to.
  62827. * @returns TexturePacker
  62828. */
  62829. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62830. /**
  62831. * Starts the package process
  62832. * @param resolve The promises resolution function
  62833. * @returns TexturePacker
  62834. */
  62835. private _createFrames;
  62836. /**
  62837. * Calculates the Size of the Channel Sets
  62838. * @returns Vector2
  62839. */
  62840. private _calculateSize;
  62841. /**
  62842. * Calculates the UV data for the frames.
  62843. * @param baseSize the base frameSize
  62844. * @param padding the base frame padding
  62845. * @param dtSize size of the Dynamic Texture for that channel
  62846. * @param dtUnits is 1/dtSize
  62847. * @param update flag to update the input meshes
  62848. */
  62849. private _calculateMeshUVFrames;
  62850. /**
  62851. * Calculates the frames Offset.
  62852. * @param index of the frame
  62853. * @returns Vector2
  62854. */
  62855. private _getFrameOffset;
  62856. /**
  62857. * Updates a Mesh to the frame data
  62858. * @param mesh that is the target
  62859. * @param frameID or the frame index
  62860. */
  62861. private _updateMeshUV;
  62862. /**
  62863. * Updates a Meshes materials to use the texture packer channels
  62864. * @param m is the mesh to target
  62865. * @param force all channels on the packer to be set.
  62866. */
  62867. private _updateTextureReferences;
  62868. /**
  62869. * Public method to set a Mesh to a frame
  62870. * @param m that is the target
  62871. * @param frameID or the frame index
  62872. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62873. */
  62874. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62875. /**
  62876. * Starts the async promise to compile the texture packer.
  62877. * @returns Promise<void>
  62878. */
  62879. processAsync(): Promise<void>;
  62880. /**
  62881. * Disposes all textures associated with this packer
  62882. */
  62883. dispose(): void;
  62884. /**
  62885. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62886. * @param imageType is the image type to use.
  62887. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62888. */
  62889. download(imageType?: string, quality?: number): void;
  62890. /**
  62891. * Public method to load a texturePacker JSON file.
  62892. * @param data of the JSON file in string format.
  62893. */
  62894. updateFromJSON(data: string): void;
  62895. }
  62896. }
  62897. declare module BABYLON {
  62898. /**
  62899. * 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.
  62900. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62901. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62902. */
  62903. export class CustomProceduralTexture extends ProceduralTexture {
  62904. private _animate;
  62905. private _time;
  62906. private _config;
  62907. private _texturePath;
  62908. /**
  62909. * Instantiates a new Custom Procedural Texture.
  62910. * 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.
  62911. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62912. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62913. * @param name Define the name of the texture
  62914. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62915. * @param size Define the size of the texture to create
  62916. * @param scene Define the scene the texture belongs to
  62917. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62918. * @param generateMipMaps Define if the texture should creates mip maps or not
  62919. */
  62920. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62921. private _loadJson;
  62922. /**
  62923. * Is the texture ready to be used ? (rendered at least once)
  62924. * @returns true if ready, otherwise, false.
  62925. */
  62926. isReady(): boolean;
  62927. /**
  62928. * Render the texture to its associated render target.
  62929. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62930. */
  62931. render(useCameraPostProcess?: boolean): void;
  62932. /**
  62933. * Update the list of dependant textures samplers in the shader.
  62934. */
  62935. updateTextures(): void;
  62936. /**
  62937. * Update the uniform values of the procedural texture in the shader.
  62938. */
  62939. updateShaderUniforms(): void;
  62940. /**
  62941. * Define if the texture animates or not.
  62942. */
  62943. get animate(): boolean;
  62944. set animate(value: boolean);
  62945. }
  62946. }
  62947. declare module BABYLON {
  62948. /** @hidden */
  62949. export var noisePixelShader: {
  62950. name: string;
  62951. shader: string;
  62952. };
  62953. }
  62954. declare module BABYLON {
  62955. /**
  62956. * Class used to generate noise procedural textures
  62957. */
  62958. export class NoiseProceduralTexture extends ProceduralTexture {
  62959. /** Gets or sets the start time (default is 0) */
  62960. time: number;
  62961. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62962. brightness: number;
  62963. /** Defines the number of octaves to process */
  62964. octaves: number;
  62965. /** Defines the level of persistence (0.8 by default) */
  62966. persistence: number;
  62967. /** Gets or sets animation speed factor (default is 1) */
  62968. animationSpeedFactor: number;
  62969. /**
  62970. * Creates a new NoiseProceduralTexture
  62971. * @param name defines the name fo the texture
  62972. * @param size defines the size of the texture (default is 256)
  62973. * @param scene defines the hosting scene
  62974. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62975. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62976. */
  62977. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62978. private _updateShaderUniforms;
  62979. protected _getDefines(): string;
  62980. /** Generate the current state of the procedural texture */
  62981. render(useCameraPostProcess?: boolean): void;
  62982. /**
  62983. * Serializes this noise procedural texture
  62984. * @returns a serialized noise procedural texture object
  62985. */
  62986. serialize(): any;
  62987. /**
  62988. * Clone the texture.
  62989. * @returns the cloned texture
  62990. */
  62991. clone(): NoiseProceduralTexture;
  62992. /**
  62993. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62994. * @param parsedTexture defines parsed texture data
  62995. * @param scene defines the current scene
  62996. * @param rootUrl defines the root URL containing noise procedural texture information
  62997. * @returns a parsed NoiseProceduralTexture
  62998. */
  62999. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63000. }
  63001. }
  63002. declare module BABYLON {
  63003. /**
  63004. * Raw cube texture where the raw buffers are passed in
  63005. */
  63006. export class RawCubeTexture extends CubeTexture {
  63007. /**
  63008. * Creates a cube texture where the raw buffers are passed in.
  63009. * @param scene defines the scene the texture is attached to
  63010. * @param data defines the array of data to use to create each face
  63011. * @param size defines the size of the textures
  63012. * @param format defines the format of the data
  63013. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63014. * @param generateMipMaps defines if the engine should generate the mip levels
  63015. * @param invertY defines if data must be stored with Y axis inverted
  63016. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63017. * @param compression defines the compression used (null by default)
  63018. */
  63019. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63020. /**
  63021. * Updates the raw cube texture.
  63022. * @param data defines the data to store
  63023. * @param format defines the data format
  63024. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63025. * @param invertY defines if data must be stored with Y axis inverted
  63026. * @param compression defines the compression used (null by default)
  63027. * @param level defines which level of the texture to update
  63028. */
  63029. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63030. /**
  63031. * Updates a raw cube texture with RGBD encoded data.
  63032. * @param data defines the array of data [mipmap][face] to use to create each face
  63033. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63034. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63035. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63036. * @returns a promsie that resolves when the operation is complete
  63037. */
  63038. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63039. /**
  63040. * Clones the raw cube texture.
  63041. * @return a new cube texture
  63042. */
  63043. clone(): CubeTexture;
  63044. /** @hidden */
  63045. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63046. }
  63047. }
  63048. declare module BABYLON {
  63049. /**
  63050. * Class used to store 2D array textures containing user data
  63051. */
  63052. export class RawTexture2DArray extends Texture {
  63053. /** Gets or sets the texture format to use */
  63054. format: number;
  63055. /**
  63056. * Create a new RawTexture2DArray
  63057. * @param data defines the data of the texture
  63058. * @param width defines the width of the texture
  63059. * @param height defines the height of the texture
  63060. * @param depth defines the number of layers of the texture
  63061. * @param format defines the texture format to use
  63062. * @param scene defines the hosting scene
  63063. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63064. * @param invertY defines if texture must be stored with Y axis inverted
  63065. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63066. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63067. */
  63068. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63069. /** Gets or sets the texture format to use */
  63070. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63071. /**
  63072. * Update the texture with new data
  63073. * @param data defines the data to store in the texture
  63074. */
  63075. update(data: ArrayBufferView): void;
  63076. }
  63077. }
  63078. declare module BABYLON {
  63079. /**
  63080. * Class used to store 3D textures containing user data
  63081. */
  63082. export class RawTexture3D extends Texture {
  63083. /** Gets or sets the texture format to use */
  63084. format: number;
  63085. /**
  63086. * Create a new RawTexture3D
  63087. * @param data defines the data of the texture
  63088. * @param width defines the width of the texture
  63089. * @param height defines the height of the texture
  63090. * @param depth defines the depth of the texture
  63091. * @param format defines the texture format to use
  63092. * @param scene defines the hosting scene
  63093. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63094. * @param invertY defines if texture must be stored with Y axis inverted
  63095. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63096. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63097. */
  63098. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63099. /** Gets or sets the texture format to use */
  63100. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63101. /**
  63102. * Update the texture with new data
  63103. * @param data defines the data to store in the texture
  63104. */
  63105. update(data: ArrayBufferView): void;
  63106. }
  63107. }
  63108. declare module BABYLON {
  63109. /**
  63110. * Creates a refraction texture used by refraction channel of the standard material.
  63111. * It is like a mirror but to see through a material.
  63112. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63113. */
  63114. export class RefractionTexture extends RenderTargetTexture {
  63115. /**
  63116. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63117. * 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.
  63118. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63119. */
  63120. refractionPlane: Plane;
  63121. /**
  63122. * Define how deep under the surface we should see.
  63123. */
  63124. depth: number;
  63125. /**
  63126. * Creates a refraction texture used by refraction channel of the standard material.
  63127. * It is like a mirror but to see through a material.
  63128. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63129. * @param name Define the texture name
  63130. * @param size Define the size of the underlying texture
  63131. * @param scene Define the scene the refraction belongs to
  63132. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63133. */
  63134. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63135. /**
  63136. * Clone the refraction texture.
  63137. * @returns the cloned texture
  63138. */
  63139. clone(): RefractionTexture;
  63140. /**
  63141. * Serialize the texture to a JSON representation you could use in Parse later on
  63142. * @returns the serialized JSON representation
  63143. */
  63144. serialize(): any;
  63145. }
  63146. }
  63147. declare module BABYLON {
  63148. /**
  63149. * Block used to add support for vertex skinning (bones)
  63150. */
  63151. export class BonesBlock extends NodeMaterialBlock {
  63152. /**
  63153. * Creates a new BonesBlock
  63154. * @param name defines the block name
  63155. */
  63156. constructor(name: string);
  63157. /**
  63158. * Initialize the block and prepare the context for build
  63159. * @param state defines the state that will be used for the build
  63160. */
  63161. initialize(state: NodeMaterialBuildState): void;
  63162. /**
  63163. * Gets the current class name
  63164. * @returns the class name
  63165. */
  63166. getClassName(): string;
  63167. /**
  63168. * Gets the matrix indices input component
  63169. */
  63170. get matricesIndices(): NodeMaterialConnectionPoint;
  63171. /**
  63172. * Gets the matrix weights input component
  63173. */
  63174. get matricesWeights(): NodeMaterialConnectionPoint;
  63175. /**
  63176. * Gets the extra matrix indices input component
  63177. */
  63178. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63179. /**
  63180. * Gets the extra matrix weights input component
  63181. */
  63182. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63183. /**
  63184. * Gets the world input component
  63185. */
  63186. get world(): NodeMaterialConnectionPoint;
  63187. /**
  63188. * Gets the output component
  63189. */
  63190. get output(): NodeMaterialConnectionPoint;
  63191. autoConfigure(material: NodeMaterial): void;
  63192. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63193. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63195. protected _buildBlock(state: NodeMaterialBuildState): this;
  63196. }
  63197. }
  63198. declare module BABYLON {
  63199. /**
  63200. * Block used to add support for instances
  63201. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63202. */
  63203. export class InstancesBlock extends NodeMaterialBlock {
  63204. /**
  63205. * Creates a new InstancesBlock
  63206. * @param name defines the block name
  63207. */
  63208. constructor(name: string);
  63209. /**
  63210. * Gets the current class name
  63211. * @returns the class name
  63212. */
  63213. getClassName(): string;
  63214. /**
  63215. * Gets the first world row input component
  63216. */
  63217. get world0(): NodeMaterialConnectionPoint;
  63218. /**
  63219. * Gets the second world row input component
  63220. */
  63221. get world1(): NodeMaterialConnectionPoint;
  63222. /**
  63223. * Gets the third world row input component
  63224. */
  63225. get world2(): NodeMaterialConnectionPoint;
  63226. /**
  63227. * Gets the forth world row input component
  63228. */
  63229. get world3(): NodeMaterialConnectionPoint;
  63230. /**
  63231. * Gets the world input component
  63232. */
  63233. get world(): NodeMaterialConnectionPoint;
  63234. /**
  63235. * Gets the output component
  63236. */
  63237. get output(): NodeMaterialConnectionPoint;
  63238. /**
  63239. * Gets the isntanceID component
  63240. */
  63241. get instanceID(): NodeMaterialConnectionPoint;
  63242. autoConfigure(material: NodeMaterial): void;
  63243. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63244. protected _buildBlock(state: NodeMaterialBuildState): this;
  63245. }
  63246. }
  63247. declare module BABYLON {
  63248. /**
  63249. * Block used to add morph targets support to vertex shader
  63250. */
  63251. export class MorphTargetsBlock extends NodeMaterialBlock {
  63252. private _repeatableContentAnchor;
  63253. /**
  63254. * Create a new MorphTargetsBlock
  63255. * @param name defines the block name
  63256. */
  63257. constructor(name: string);
  63258. /**
  63259. * Gets the current class name
  63260. * @returns the class name
  63261. */
  63262. getClassName(): string;
  63263. /**
  63264. * Gets the position input component
  63265. */
  63266. get position(): NodeMaterialConnectionPoint;
  63267. /**
  63268. * Gets the normal input component
  63269. */
  63270. get normal(): NodeMaterialConnectionPoint;
  63271. /**
  63272. * Gets the tangent input component
  63273. */
  63274. get tangent(): NodeMaterialConnectionPoint;
  63275. /**
  63276. * Gets the tangent input component
  63277. */
  63278. get uv(): NodeMaterialConnectionPoint;
  63279. /**
  63280. * Gets the position output component
  63281. */
  63282. get positionOutput(): NodeMaterialConnectionPoint;
  63283. /**
  63284. * Gets the normal output component
  63285. */
  63286. get normalOutput(): NodeMaterialConnectionPoint;
  63287. /**
  63288. * Gets the tangent output component
  63289. */
  63290. get tangentOutput(): NodeMaterialConnectionPoint;
  63291. /**
  63292. * Gets the tangent output component
  63293. */
  63294. get uvOutput(): NodeMaterialConnectionPoint;
  63295. initialize(state: NodeMaterialBuildState): void;
  63296. autoConfigure(material: NodeMaterial): void;
  63297. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63299. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63300. protected _buildBlock(state: NodeMaterialBuildState): this;
  63301. }
  63302. }
  63303. declare module BABYLON {
  63304. /**
  63305. * Block used to get data information from a light
  63306. */
  63307. export class LightInformationBlock extends NodeMaterialBlock {
  63308. private _lightDataUniformName;
  63309. private _lightColorUniformName;
  63310. private _lightTypeDefineName;
  63311. /**
  63312. * Gets or sets the light associated with this block
  63313. */
  63314. light: Nullable<Light>;
  63315. /**
  63316. * Creates a new LightInformationBlock
  63317. * @param name defines the block name
  63318. */
  63319. constructor(name: string);
  63320. /**
  63321. * Gets the current class name
  63322. * @returns the class name
  63323. */
  63324. getClassName(): string;
  63325. /**
  63326. * Gets the world position input component
  63327. */
  63328. get worldPosition(): NodeMaterialConnectionPoint;
  63329. /**
  63330. * Gets the direction output component
  63331. */
  63332. get direction(): NodeMaterialConnectionPoint;
  63333. /**
  63334. * Gets the direction output component
  63335. */
  63336. get color(): NodeMaterialConnectionPoint;
  63337. /**
  63338. * Gets the direction output component
  63339. */
  63340. get intensity(): NodeMaterialConnectionPoint;
  63341. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63343. protected _buildBlock(state: NodeMaterialBuildState): this;
  63344. serialize(): any;
  63345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63346. }
  63347. }
  63348. declare module BABYLON {
  63349. /**
  63350. * Block used to add image processing support to fragment shader
  63351. */
  63352. export class ImageProcessingBlock extends NodeMaterialBlock {
  63353. /**
  63354. * Create a new ImageProcessingBlock
  63355. * @param name defines the block name
  63356. */
  63357. constructor(name: string);
  63358. /**
  63359. * Gets the current class name
  63360. * @returns the class name
  63361. */
  63362. getClassName(): string;
  63363. /**
  63364. * Gets the color input component
  63365. */
  63366. get color(): NodeMaterialConnectionPoint;
  63367. /**
  63368. * Gets the output component
  63369. */
  63370. get output(): NodeMaterialConnectionPoint;
  63371. /**
  63372. * Initialize the block and prepare the context for build
  63373. * @param state defines the state that will be used for the build
  63374. */
  63375. initialize(state: NodeMaterialBuildState): void;
  63376. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63377. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63378. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63379. protected _buildBlock(state: NodeMaterialBuildState): this;
  63380. }
  63381. }
  63382. declare module BABYLON {
  63383. /**
  63384. * Block used to pertub normals based on a normal map
  63385. */
  63386. export class PerturbNormalBlock extends NodeMaterialBlock {
  63387. private _tangentSpaceParameterName;
  63388. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63389. invertX: boolean;
  63390. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63391. invertY: boolean;
  63392. /**
  63393. * Create a new PerturbNormalBlock
  63394. * @param name defines the block name
  63395. */
  63396. constructor(name: string);
  63397. /**
  63398. * Gets the current class name
  63399. * @returns the class name
  63400. */
  63401. getClassName(): string;
  63402. /**
  63403. * Gets the world position input component
  63404. */
  63405. get worldPosition(): NodeMaterialConnectionPoint;
  63406. /**
  63407. * Gets the world normal input component
  63408. */
  63409. get worldNormal(): NodeMaterialConnectionPoint;
  63410. /**
  63411. * Gets the world tangent input component
  63412. */
  63413. get worldTangent(): NodeMaterialConnectionPoint;
  63414. /**
  63415. * Gets the uv input component
  63416. */
  63417. get uv(): NodeMaterialConnectionPoint;
  63418. /**
  63419. * Gets the normal map color input component
  63420. */
  63421. get normalMapColor(): NodeMaterialConnectionPoint;
  63422. /**
  63423. * Gets the strength input component
  63424. */
  63425. get strength(): NodeMaterialConnectionPoint;
  63426. /**
  63427. * Gets the output component
  63428. */
  63429. get output(): NodeMaterialConnectionPoint;
  63430. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63431. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63432. autoConfigure(material: NodeMaterial): void;
  63433. protected _buildBlock(state: NodeMaterialBuildState): this;
  63434. protected _dumpPropertiesCode(): string;
  63435. serialize(): any;
  63436. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63437. }
  63438. }
  63439. declare module BABYLON {
  63440. /**
  63441. * Block used to discard a pixel if a value is smaller than a cutoff
  63442. */
  63443. export class DiscardBlock extends NodeMaterialBlock {
  63444. /**
  63445. * Create a new DiscardBlock
  63446. * @param name defines the block name
  63447. */
  63448. constructor(name: string);
  63449. /**
  63450. * Gets the current class name
  63451. * @returns the class name
  63452. */
  63453. getClassName(): string;
  63454. /**
  63455. * Gets the color input component
  63456. */
  63457. get value(): NodeMaterialConnectionPoint;
  63458. /**
  63459. * Gets the cutoff input component
  63460. */
  63461. get cutoff(): NodeMaterialConnectionPoint;
  63462. protected _buildBlock(state: NodeMaterialBuildState): this;
  63463. }
  63464. }
  63465. declare module BABYLON {
  63466. /**
  63467. * Block used to test if the fragment shader is front facing
  63468. */
  63469. export class FrontFacingBlock extends NodeMaterialBlock {
  63470. /**
  63471. * Creates a new FrontFacingBlock
  63472. * @param name defines the block name
  63473. */
  63474. constructor(name: string);
  63475. /**
  63476. * Gets the current class name
  63477. * @returns the class name
  63478. */
  63479. getClassName(): string;
  63480. /**
  63481. * Gets the output component
  63482. */
  63483. get output(): NodeMaterialConnectionPoint;
  63484. protected _buildBlock(state: NodeMaterialBuildState): this;
  63485. }
  63486. }
  63487. declare module BABYLON {
  63488. /**
  63489. * Block used to get the derivative value on x and y of a given input
  63490. */
  63491. export class DerivativeBlock extends NodeMaterialBlock {
  63492. /**
  63493. * Create a new DerivativeBlock
  63494. * @param name defines the block name
  63495. */
  63496. constructor(name: string);
  63497. /**
  63498. * Gets the current class name
  63499. * @returns the class name
  63500. */
  63501. getClassName(): string;
  63502. /**
  63503. * Gets the input component
  63504. */
  63505. get input(): NodeMaterialConnectionPoint;
  63506. /**
  63507. * Gets the derivative output on x
  63508. */
  63509. get dx(): NodeMaterialConnectionPoint;
  63510. /**
  63511. * Gets the derivative output on y
  63512. */
  63513. get dy(): NodeMaterialConnectionPoint;
  63514. protected _buildBlock(state: NodeMaterialBuildState): this;
  63515. }
  63516. }
  63517. declare module BABYLON {
  63518. /**
  63519. * Block used to make gl_FragCoord available
  63520. */
  63521. export class FragCoordBlock extends NodeMaterialBlock {
  63522. /**
  63523. * Creates a new FragCoordBlock
  63524. * @param name defines the block name
  63525. */
  63526. constructor(name: string);
  63527. /**
  63528. * Gets the current class name
  63529. * @returns the class name
  63530. */
  63531. getClassName(): string;
  63532. /**
  63533. * Gets the xy component
  63534. */
  63535. get xy(): NodeMaterialConnectionPoint;
  63536. /**
  63537. * Gets the xyz component
  63538. */
  63539. get xyz(): NodeMaterialConnectionPoint;
  63540. /**
  63541. * Gets the xyzw component
  63542. */
  63543. get xyzw(): NodeMaterialConnectionPoint;
  63544. /**
  63545. * Gets the x component
  63546. */
  63547. get x(): NodeMaterialConnectionPoint;
  63548. /**
  63549. * Gets the y component
  63550. */
  63551. get y(): NodeMaterialConnectionPoint;
  63552. /**
  63553. * Gets the z component
  63554. */
  63555. get z(): NodeMaterialConnectionPoint;
  63556. /**
  63557. * Gets the w component
  63558. */
  63559. get output(): NodeMaterialConnectionPoint;
  63560. protected writeOutputs(state: NodeMaterialBuildState): string;
  63561. protected _buildBlock(state: NodeMaterialBuildState): this;
  63562. }
  63563. }
  63564. declare module BABYLON {
  63565. /**
  63566. * Block used to get the screen sizes
  63567. */
  63568. export class ScreenSizeBlock extends NodeMaterialBlock {
  63569. private _varName;
  63570. private _scene;
  63571. /**
  63572. * Creates a new ScreenSizeBlock
  63573. * @param name defines the block name
  63574. */
  63575. constructor(name: string);
  63576. /**
  63577. * Gets the current class name
  63578. * @returns the class name
  63579. */
  63580. getClassName(): string;
  63581. /**
  63582. * Gets the xy component
  63583. */
  63584. get xy(): NodeMaterialConnectionPoint;
  63585. /**
  63586. * Gets the x component
  63587. */
  63588. get x(): NodeMaterialConnectionPoint;
  63589. /**
  63590. * Gets the y component
  63591. */
  63592. get y(): NodeMaterialConnectionPoint;
  63593. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63594. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63595. protected _buildBlock(state: NodeMaterialBuildState): this;
  63596. }
  63597. }
  63598. declare module BABYLON {
  63599. /**
  63600. * Block used to add support for scene fog
  63601. */
  63602. export class FogBlock extends NodeMaterialBlock {
  63603. private _fogDistanceName;
  63604. private _fogParameters;
  63605. /**
  63606. * Create a new FogBlock
  63607. * @param name defines the block name
  63608. */
  63609. constructor(name: string);
  63610. /**
  63611. * Gets the current class name
  63612. * @returns the class name
  63613. */
  63614. getClassName(): string;
  63615. /**
  63616. * Gets the world position input component
  63617. */
  63618. get worldPosition(): NodeMaterialConnectionPoint;
  63619. /**
  63620. * Gets the view input component
  63621. */
  63622. get view(): NodeMaterialConnectionPoint;
  63623. /**
  63624. * Gets the color input component
  63625. */
  63626. get input(): NodeMaterialConnectionPoint;
  63627. /**
  63628. * Gets the fog color input component
  63629. */
  63630. get fogColor(): NodeMaterialConnectionPoint;
  63631. /**
  63632. * Gets the output component
  63633. */
  63634. get output(): NodeMaterialConnectionPoint;
  63635. autoConfigure(material: NodeMaterial): void;
  63636. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63637. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63638. protected _buildBlock(state: NodeMaterialBuildState): this;
  63639. }
  63640. }
  63641. declare module BABYLON {
  63642. /**
  63643. * Block used to add light in the fragment shader
  63644. */
  63645. export class LightBlock extends NodeMaterialBlock {
  63646. private _lightId;
  63647. /**
  63648. * Gets or sets the light associated with this block
  63649. */
  63650. light: Nullable<Light>;
  63651. /**
  63652. * Create a new LightBlock
  63653. * @param name defines the block name
  63654. */
  63655. constructor(name: string);
  63656. /**
  63657. * Gets the current class name
  63658. * @returns the class name
  63659. */
  63660. getClassName(): string;
  63661. /**
  63662. * Gets the world position input component
  63663. */
  63664. get worldPosition(): NodeMaterialConnectionPoint;
  63665. /**
  63666. * Gets the world normal input component
  63667. */
  63668. get worldNormal(): NodeMaterialConnectionPoint;
  63669. /**
  63670. * Gets the camera (or eye) position component
  63671. */
  63672. get cameraPosition(): NodeMaterialConnectionPoint;
  63673. /**
  63674. * Gets the glossiness component
  63675. */
  63676. get glossiness(): NodeMaterialConnectionPoint;
  63677. /**
  63678. * Gets the glossinness power component
  63679. */
  63680. get glossPower(): NodeMaterialConnectionPoint;
  63681. /**
  63682. * Gets the diffuse color component
  63683. */
  63684. get diffuseColor(): NodeMaterialConnectionPoint;
  63685. /**
  63686. * Gets the specular color component
  63687. */
  63688. get specularColor(): NodeMaterialConnectionPoint;
  63689. /**
  63690. * Gets the view matrix component
  63691. */
  63692. get view(): NodeMaterialConnectionPoint;
  63693. /**
  63694. * Gets the diffuse output component
  63695. */
  63696. get diffuseOutput(): NodeMaterialConnectionPoint;
  63697. /**
  63698. * Gets the specular output component
  63699. */
  63700. get specularOutput(): NodeMaterialConnectionPoint;
  63701. /**
  63702. * Gets the shadow output component
  63703. */
  63704. get shadow(): NodeMaterialConnectionPoint;
  63705. autoConfigure(material: NodeMaterial): void;
  63706. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63707. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63708. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63709. private _injectVertexCode;
  63710. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63711. serialize(): any;
  63712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63713. }
  63714. }
  63715. declare module BABYLON {
  63716. /**
  63717. * Block used to read a reflection texture from a sampler
  63718. */
  63719. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63720. /**
  63721. * Create a new ReflectionTextureBlock
  63722. * @param name defines the block name
  63723. */
  63724. constructor(name: string);
  63725. /**
  63726. * Gets the current class name
  63727. * @returns the class name
  63728. */
  63729. getClassName(): string;
  63730. /**
  63731. * Gets the world position input component
  63732. */
  63733. get position(): NodeMaterialConnectionPoint;
  63734. /**
  63735. * Gets the world position input component
  63736. */
  63737. get worldPosition(): NodeMaterialConnectionPoint;
  63738. /**
  63739. * Gets the world normal input component
  63740. */
  63741. get worldNormal(): NodeMaterialConnectionPoint;
  63742. /**
  63743. * Gets the world input component
  63744. */
  63745. get world(): NodeMaterialConnectionPoint;
  63746. /**
  63747. * Gets the camera (or eye) position component
  63748. */
  63749. get cameraPosition(): NodeMaterialConnectionPoint;
  63750. /**
  63751. * Gets the view input component
  63752. */
  63753. get view(): NodeMaterialConnectionPoint;
  63754. /**
  63755. * Gets the rgb output component
  63756. */
  63757. get rgb(): NodeMaterialConnectionPoint;
  63758. /**
  63759. * Gets the rgba output component
  63760. */
  63761. get rgba(): NodeMaterialConnectionPoint;
  63762. /**
  63763. * Gets the r output component
  63764. */
  63765. get r(): NodeMaterialConnectionPoint;
  63766. /**
  63767. * Gets the g output component
  63768. */
  63769. get g(): NodeMaterialConnectionPoint;
  63770. /**
  63771. * Gets the b output component
  63772. */
  63773. get b(): NodeMaterialConnectionPoint;
  63774. /**
  63775. * Gets the a output component
  63776. */
  63777. get a(): NodeMaterialConnectionPoint;
  63778. autoConfigure(material: NodeMaterial): void;
  63779. protected _buildBlock(state: NodeMaterialBuildState): this;
  63780. }
  63781. }
  63782. declare module BABYLON {
  63783. /**
  63784. * Block used to add 2 vectors
  63785. */
  63786. export class AddBlock extends NodeMaterialBlock {
  63787. /**
  63788. * Creates a new AddBlock
  63789. * @param name defines the block name
  63790. */
  63791. constructor(name: string);
  63792. /**
  63793. * Gets the current class name
  63794. * @returns the class name
  63795. */
  63796. getClassName(): string;
  63797. /**
  63798. * Gets the left operand input component
  63799. */
  63800. get left(): NodeMaterialConnectionPoint;
  63801. /**
  63802. * Gets the right operand input component
  63803. */
  63804. get right(): NodeMaterialConnectionPoint;
  63805. /**
  63806. * Gets the output component
  63807. */
  63808. get output(): NodeMaterialConnectionPoint;
  63809. protected _buildBlock(state: NodeMaterialBuildState): this;
  63810. }
  63811. }
  63812. declare module BABYLON {
  63813. /**
  63814. * Block used to scale a vector by a float
  63815. */
  63816. export class ScaleBlock extends NodeMaterialBlock {
  63817. /**
  63818. * Creates a new ScaleBlock
  63819. * @param name defines the block name
  63820. */
  63821. constructor(name: string);
  63822. /**
  63823. * Gets the current class name
  63824. * @returns the class name
  63825. */
  63826. getClassName(): string;
  63827. /**
  63828. * Gets the input component
  63829. */
  63830. get input(): NodeMaterialConnectionPoint;
  63831. /**
  63832. * Gets the factor input component
  63833. */
  63834. get factor(): NodeMaterialConnectionPoint;
  63835. /**
  63836. * Gets the output component
  63837. */
  63838. get output(): NodeMaterialConnectionPoint;
  63839. protected _buildBlock(state: NodeMaterialBuildState): this;
  63840. }
  63841. }
  63842. declare module BABYLON {
  63843. /**
  63844. * Block used to clamp a float
  63845. */
  63846. export class ClampBlock extends NodeMaterialBlock {
  63847. /** Gets or sets the minimum range */
  63848. minimum: number;
  63849. /** Gets or sets the maximum range */
  63850. maximum: number;
  63851. /**
  63852. * Creates a new ClampBlock
  63853. * @param name defines the block name
  63854. */
  63855. constructor(name: string);
  63856. /**
  63857. * Gets the current class name
  63858. * @returns the class name
  63859. */
  63860. getClassName(): string;
  63861. /**
  63862. * Gets the value input component
  63863. */
  63864. get value(): NodeMaterialConnectionPoint;
  63865. /**
  63866. * Gets the output component
  63867. */
  63868. get output(): NodeMaterialConnectionPoint;
  63869. protected _buildBlock(state: NodeMaterialBuildState): this;
  63870. protected _dumpPropertiesCode(): string;
  63871. serialize(): any;
  63872. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63873. }
  63874. }
  63875. declare module BABYLON {
  63876. /**
  63877. * Block used to apply a cross product between 2 vectors
  63878. */
  63879. export class CrossBlock extends NodeMaterialBlock {
  63880. /**
  63881. * Creates a new CrossBlock
  63882. * @param name defines the block name
  63883. */
  63884. constructor(name: string);
  63885. /**
  63886. * Gets the current class name
  63887. * @returns the class name
  63888. */
  63889. getClassName(): string;
  63890. /**
  63891. * Gets the left operand input component
  63892. */
  63893. get left(): NodeMaterialConnectionPoint;
  63894. /**
  63895. * Gets the right operand input component
  63896. */
  63897. get right(): NodeMaterialConnectionPoint;
  63898. /**
  63899. * Gets the output component
  63900. */
  63901. get output(): NodeMaterialConnectionPoint;
  63902. protected _buildBlock(state: NodeMaterialBuildState): this;
  63903. }
  63904. }
  63905. declare module BABYLON {
  63906. /**
  63907. * Block used to apply a dot product between 2 vectors
  63908. */
  63909. export class DotBlock extends NodeMaterialBlock {
  63910. /**
  63911. * Creates a new DotBlock
  63912. * @param name defines the block name
  63913. */
  63914. constructor(name: string);
  63915. /**
  63916. * Gets the current class name
  63917. * @returns the class name
  63918. */
  63919. getClassName(): string;
  63920. /**
  63921. * Gets the left operand input component
  63922. */
  63923. get left(): NodeMaterialConnectionPoint;
  63924. /**
  63925. * Gets the right operand input component
  63926. */
  63927. get right(): NodeMaterialConnectionPoint;
  63928. /**
  63929. * Gets the output component
  63930. */
  63931. get output(): NodeMaterialConnectionPoint;
  63932. protected _buildBlock(state: NodeMaterialBuildState): this;
  63933. }
  63934. }
  63935. declare module BABYLON {
  63936. /**
  63937. * Block used to normalize a vector
  63938. */
  63939. export class NormalizeBlock extends NodeMaterialBlock {
  63940. /**
  63941. * Creates a new NormalizeBlock
  63942. * @param name defines the block name
  63943. */
  63944. constructor(name: string);
  63945. /**
  63946. * Gets the current class name
  63947. * @returns the class name
  63948. */
  63949. getClassName(): string;
  63950. /**
  63951. * Gets the input component
  63952. */
  63953. get input(): 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 create a Color3/4 out of individual inputs (one for each component)
  63964. */
  63965. export class ColorMergerBlock extends NodeMaterialBlock {
  63966. /**
  63967. * Create a new ColorMergerBlock
  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 rgb component (input)
  63978. */
  63979. get rgbIn(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the r component (input)
  63982. */
  63983. get r(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the g component (input)
  63986. */
  63987. get g(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the b component (input)
  63990. */
  63991. get b(): NodeMaterialConnectionPoint;
  63992. /**
  63993. * Gets the a component (input)
  63994. */
  63995. get a(): NodeMaterialConnectionPoint;
  63996. /**
  63997. * Gets the rgba component (output)
  63998. */
  63999. get rgba(): NodeMaterialConnectionPoint;
  64000. /**
  64001. * Gets the rgb component (output)
  64002. */
  64003. get rgbOut(): NodeMaterialConnectionPoint;
  64004. /**
  64005. * Gets the rgb component (output)
  64006. * @deprecated Please use rgbOut instead.
  64007. */
  64008. get rgb(): NodeMaterialConnectionPoint;
  64009. protected _buildBlock(state: NodeMaterialBuildState): this;
  64010. }
  64011. }
  64012. declare module BABYLON {
  64013. /**
  64014. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64015. */
  64016. export class VectorSplitterBlock extends NodeMaterialBlock {
  64017. /**
  64018. * Create a new VectorSplitterBlock
  64019. * @param name defines the block name
  64020. */
  64021. constructor(name: string);
  64022. /**
  64023. * Gets the current class name
  64024. * @returns the class name
  64025. */
  64026. getClassName(): string;
  64027. /**
  64028. * Gets the xyzw component (input)
  64029. */
  64030. get xyzw(): NodeMaterialConnectionPoint;
  64031. /**
  64032. * Gets the xyz component (input)
  64033. */
  64034. get xyzIn(): NodeMaterialConnectionPoint;
  64035. /**
  64036. * Gets the xy component (input)
  64037. */
  64038. get xyIn(): NodeMaterialConnectionPoint;
  64039. /**
  64040. * Gets the xyz component (output)
  64041. */
  64042. get xyzOut(): NodeMaterialConnectionPoint;
  64043. /**
  64044. * Gets the xy component (output)
  64045. */
  64046. get xyOut(): NodeMaterialConnectionPoint;
  64047. /**
  64048. * Gets the x component (output)
  64049. */
  64050. get x(): NodeMaterialConnectionPoint;
  64051. /**
  64052. * Gets the y component (output)
  64053. */
  64054. get y(): NodeMaterialConnectionPoint;
  64055. /**
  64056. * Gets the z component (output)
  64057. */
  64058. get z(): NodeMaterialConnectionPoint;
  64059. /**
  64060. * Gets the w component (output)
  64061. */
  64062. get w(): NodeMaterialConnectionPoint;
  64063. protected _inputRename(name: string): string;
  64064. protected _outputRename(name: string): string;
  64065. protected _buildBlock(state: NodeMaterialBuildState): this;
  64066. }
  64067. }
  64068. declare module BABYLON {
  64069. /**
  64070. * Block used to lerp between 2 values
  64071. */
  64072. export class LerpBlock extends NodeMaterialBlock {
  64073. /**
  64074. * Creates a new LerpBlock
  64075. * @param name defines the block name
  64076. */
  64077. constructor(name: string);
  64078. /**
  64079. * Gets the current class name
  64080. * @returns the class name
  64081. */
  64082. getClassName(): string;
  64083. /**
  64084. * Gets the left operand input component
  64085. */
  64086. get left(): NodeMaterialConnectionPoint;
  64087. /**
  64088. * Gets the right operand input component
  64089. */
  64090. get right(): NodeMaterialConnectionPoint;
  64091. /**
  64092. * Gets the gradient operand input component
  64093. */
  64094. get gradient(): NodeMaterialConnectionPoint;
  64095. /**
  64096. * Gets the output component
  64097. */
  64098. get output(): NodeMaterialConnectionPoint;
  64099. protected _buildBlock(state: NodeMaterialBuildState): this;
  64100. }
  64101. }
  64102. declare module BABYLON {
  64103. /**
  64104. * Block used to divide 2 vectors
  64105. */
  64106. export class DivideBlock extends NodeMaterialBlock {
  64107. /**
  64108. * Creates a new DivideBlock
  64109. * @param name defines the block name
  64110. */
  64111. constructor(name: string);
  64112. /**
  64113. * Gets the current class name
  64114. * @returns the class name
  64115. */
  64116. getClassName(): string;
  64117. /**
  64118. * Gets the left operand input component
  64119. */
  64120. get left(): NodeMaterialConnectionPoint;
  64121. /**
  64122. * Gets the right operand input component
  64123. */
  64124. get right(): NodeMaterialConnectionPoint;
  64125. /**
  64126. * Gets the output component
  64127. */
  64128. get output(): NodeMaterialConnectionPoint;
  64129. protected _buildBlock(state: NodeMaterialBuildState): this;
  64130. }
  64131. }
  64132. declare module BABYLON {
  64133. /**
  64134. * Block used to subtract 2 vectors
  64135. */
  64136. export class SubtractBlock extends NodeMaterialBlock {
  64137. /**
  64138. * Creates a new SubtractBlock
  64139. * @param name defines the block name
  64140. */
  64141. constructor(name: string);
  64142. /**
  64143. * Gets the current class name
  64144. * @returns the class name
  64145. */
  64146. getClassName(): string;
  64147. /**
  64148. * Gets the left operand input component
  64149. */
  64150. get left(): NodeMaterialConnectionPoint;
  64151. /**
  64152. * Gets the right operand input component
  64153. */
  64154. get right(): NodeMaterialConnectionPoint;
  64155. /**
  64156. * Gets the output component
  64157. */
  64158. get output(): NodeMaterialConnectionPoint;
  64159. protected _buildBlock(state: NodeMaterialBuildState): this;
  64160. }
  64161. }
  64162. declare module BABYLON {
  64163. /**
  64164. * Block used to step a value
  64165. */
  64166. export class StepBlock extends NodeMaterialBlock {
  64167. /**
  64168. * Creates a new StepBlock
  64169. * @param name defines the block name
  64170. */
  64171. constructor(name: string);
  64172. /**
  64173. * Gets the current class name
  64174. * @returns the class name
  64175. */
  64176. getClassName(): string;
  64177. /**
  64178. * Gets the value operand input component
  64179. */
  64180. get value(): NodeMaterialConnectionPoint;
  64181. /**
  64182. * Gets the edge operand input component
  64183. */
  64184. get edge(): NodeMaterialConnectionPoint;
  64185. /**
  64186. * Gets the output component
  64187. */
  64188. get output(): NodeMaterialConnectionPoint;
  64189. protected _buildBlock(state: NodeMaterialBuildState): this;
  64190. }
  64191. }
  64192. declare module BABYLON {
  64193. /**
  64194. * Block used to get the opposite (1 - x) of a value
  64195. */
  64196. export class OneMinusBlock extends NodeMaterialBlock {
  64197. /**
  64198. * Creates a new OneMinusBlock
  64199. * @param name defines the block name
  64200. */
  64201. constructor(name: string);
  64202. /**
  64203. * Gets the current class name
  64204. * @returns the class name
  64205. */
  64206. getClassName(): string;
  64207. /**
  64208. * Gets the input component
  64209. */
  64210. get input(): NodeMaterialConnectionPoint;
  64211. /**
  64212. * Gets the output component
  64213. */
  64214. get output(): NodeMaterialConnectionPoint;
  64215. protected _buildBlock(state: NodeMaterialBuildState): this;
  64216. }
  64217. }
  64218. declare module BABYLON {
  64219. /**
  64220. * Block used to get the view direction
  64221. */
  64222. export class ViewDirectionBlock extends NodeMaterialBlock {
  64223. /**
  64224. * Creates a new ViewDirectionBlock
  64225. * @param name defines the block name
  64226. */
  64227. constructor(name: string);
  64228. /**
  64229. * Gets the current class name
  64230. * @returns the class name
  64231. */
  64232. getClassName(): string;
  64233. /**
  64234. * Gets the world position component
  64235. */
  64236. get worldPosition(): NodeMaterialConnectionPoint;
  64237. /**
  64238. * Gets the camera position component
  64239. */
  64240. get cameraPosition(): NodeMaterialConnectionPoint;
  64241. /**
  64242. * Gets the output component
  64243. */
  64244. get output(): NodeMaterialConnectionPoint;
  64245. autoConfigure(material: NodeMaterial): void;
  64246. protected _buildBlock(state: NodeMaterialBuildState): this;
  64247. }
  64248. }
  64249. declare module BABYLON {
  64250. /**
  64251. * Block used to compute fresnel value
  64252. */
  64253. export class FresnelBlock extends NodeMaterialBlock {
  64254. /**
  64255. * Create a new FresnelBlock
  64256. * @param name defines the block name
  64257. */
  64258. constructor(name: string);
  64259. /**
  64260. * Gets the current class name
  64261. * @returns the class name
  64262. */
  64263. getClassName(): string;
  64264. /**
  64265. * Gets the world normal input component
  64266. */
  64267. get worldNormal(): NodeMaterialConnectionPoint;
  64268. /**
  64269. * Gets the view direction input component
  64270. */
  64271. get viewDirection(): NodeMaterialConnectionPoint;
  64272. /**
  64273. * Gets the bias input component
  64274. */
  64275. get bias(): NodeMaterialConnectionPoint;
  64276. /**
  64277. * Gets the camera (or eye) position component
  64278. */
  64279. get power(): NodeMaterialConnectionPoint;
  64280. /**
  64281. * Gets the fresnel output component
  64282. */
  64283. get fresnel(): NodeMaterialConnectionPoint;
  64284. autoConfigure(material: NodeMaterial): void;
  64285. protected _buildBlock(state: NodeMaterialBuildState): this;
  64286. }
  64287. }
  64288. declare module BABYLON {
  64289. /**
  64290. * Block used to get the max of 2 values
  64291. */
  64292. export class MaxBlock extends NodeMaterialBlock {
  64293. /**
  64294. * Creates a new MaxBlock
  64295. * @param name defines the block name
  64296. */
  64297. constructor(name: string);
  64298. /**
  64299. * Gets the current class name
  64300. * @returns the class name
  64301. */
  64302. getClassName(): string;
  64303. /**
  64304. * Gets the left operand input component
  64305. */
  64306. get left(): NodeMaterialConnectionPoint;
  64307. /**
  64308. * Gets the right operand input component
  64309. */
  64310. get right(): NodeMaterialConnectionPoint;
  64311. /**
  64312. * Gets the output component
  64313. */
  64314. get output(): NodeMaterialConnectionPoint;
  64315. protected _buildBlock(state: NodeMaterialBuildState): this;
  64316. }
  64317. }
  64318. declare module BABYLON {
  64319. /**
  64320. * Block used to get the min of 2 values
  64321. */
  64322. export class MinBlock extends NodeMaterialBlock {
  64323. /**
  64324. * Creates a new MinBlock
  64325. * @param name defines the block name
  64326. */
  64327. constructor(name: string);
  64328. /**
  64329. * Gets the current class name
  64330. * @returns the class name
  64331. */
  64332. getClassName(): string;
  64333. /**
  64334. * Gets the left operand input component
  64335. */
  64336. get left(): NodeMaterialConnectionPoint;
  64337. /**
  64338. * Gets the right operand input component
  64339. */
  64340. get right(): NodeMaterialConnectionPoint;
  64341. /**
  64342. * Gets the output component
  64343. */
  64344. get output(): NodeMaterialConnectionPoint;
  64345. protected _buildBlock(state: NodeMaterialBuildState): this;
  64346. }
  64347. }
  64348. declare module BABYLON {
  64349. /**
  64350. * Block used to get the distance between 2 values
  64351. */
  64352. export class DistanceBlock extends NodeMaterialBlock {
  64353. /**
  64354. * Creates a new DistanceBlock
  64355. * @param name defines the block name
  64356. */
  64357. constructor(name: string);
  64358. /**
  64359. * Gets the current class name
  64360. * @returns the class name
  64361. */
  64362. getClassName(): string;
  64363. /**
  64364. * Gets the left operand input component
  64365. */
  64366. get left(): NodeMaterialConnectionPoint;
  64367. /**
  64368. * Gets the right operand input component
  64369. */
  64370. get right(): NodeMaterialConnectionPoint;
  64371. /**
  64372. * Gets the output component
  64373. */
  64374. get output(): NodeMaterialConnectionPoint;
  64375. protected _buildBlock(state: NodeMaterialBuildState): this;
  64376. }
  64377. }
  64378. declare module BABYLON {
  64379. /**
  64380. * Block used to get the length of a vector
  64381. */
  64382. export class LengthBlock extends NodeMaterialBlock {
  64383. /**
  64384. * Creates a new LengthBlock
  64385. * @param name defines the block name
  64386. */
  64387. constructor(name: string);
  64388. /**
  64389. * Gets the current class name
  64390. * @returns the class name
  64391. */
  64392. getClassName(): string;
  64393. /**
  64394. * Gets the value input component
  64395. */
  64396. get value(): NodeMaterialConnectionPoint;
  64397. /**
  64398. * Gets the output component
  64399. */
  64400. get output(): NodeMaterialConnectionPoint;
  64401. protected _buildBlock(state: NodeMaterialBuildState): this;
  64402. }
  64403. }
  64404. declare module BABYLON {
  64405. /**
  64406. * Block used to get negative version of a value (i.e. x * -1)
  64407. */
  64408. export class NegateBlock extends NodeMaterialBlock {
  64409. /**
  64410. * Creates a new NegateBlock
  64411. * @param name defines the block name
  64412. */
  64413. constructor(name: string);
  64414. /**
  64415. * Gets the current class name
  64416. * @returns the class name
  64417. */
  64418. getClassName(): string;
  64419. /**
  64420. * Gets the value input component
  64421. */
  64422. get value(): NodeMaterialConnectionPoint;
  64423. /**
  64424. * Gets the output component
  64425. */
  64426. get output(): NodeMaterialConnectionPoint;
  64427. protected _buildBlock(state: NodeMaterialBuildState): this;
  64428. }
  64429. }
  64430. declare module BABYLON {
  64431. /**
  64432. * Block used to get the value of the first parameter raised to the power of the second
  64433. */
  64434. export class PowBlock extends NodeMaterialBlock {
  64435. /**
  64436. * Creates a new PowBlock
  64437. * @param name defines the block name
  64438. */
  64439. constructor(name: string);
  64440. /**
  64441. * Gets the current class name
  64442. * @returns the class name
  64443. */
  64444. getClassName(): string;
  64445. /**
  64446. * Gets the value operand input component
  64447. */
  64448. get value(): NodeMaterialConnectionPoint;
  64449. /**
  64450. * Gets the power operand input component
  64451. */
  64452. get power(): NodeMaterialConnectionPoint;
  64453. /**
  64454. * Gets the output component
  64455. */
  64456. get output(): NodeMaterialConnectionPoint;
  64457. protected _buildBlock(state: NodeMaterialBuildState): this;
  64458. }
  64459. }
  64460. declare module BABYLON {
  64461. /**
  64462. * Block used to get a random number
  64463. */
  64464. export class RandomNumberBlock extends NodeMaterialBlock {
  64465. /**
  64466. * Creates a new RandomNumberBlock
  64467. * @param name defines the block name
  64468. */
  64469. constructor(name: string);
  64470. /**
  64471. * Gets the current class name
  64472. * @returns the class name
  64473. */
  64474. getClassName(): string;
  64475. /**
  64476. * Gets the seed input component
  64477. */
  64478. get seed(): NodeMaterialConnectionPoint;
  64479. /**
  64480. * Gets the output component
  64481. */
  64482. get output(): NodeMaterialConnectionPoint;
  64483. protected _buildBlock(state: NodeMaterialBuildState): this;
  64484. }
  64485. }
  64486. declare module BABYLON {
  64487. /**
  64488. * Block used to compute arc tangent of 2 values
  64489. */
  64490. export class ArcTan2Block extends NodeMaterialBlock {
  64491. /**
  64492. * Creates a new ArcTan2Block
  64493. * @param name defines the block name
  64494. */
  64495. constructor(name: string);
  64496. /**
  64497. * Gets the current class name
  64498. * @returns the class name
  64499. */
  64500. getClassName(): string;
  64501. /**
  64502. * Gets the x operand input component
  64503. */
  64504. get x(): NodeMaterialConnectionPoint;
  64505. /**
  64506. * Gets the y operand input component
  64507. */
  64508. get y(): NodeMaterialConnectionPoint;
  64509. /**
  64510. * Gets the output component
  64511. */
  64512. get output(): NodeMaterialConnectionPoint;
  64513. protected _buildBlock(state: NodeMaterialBuildState): this;
  64514. }
  64515. }
  64516. declare module BABYLON {
  64517. /**
  64518. * Block used to smooth step a value
  64519. */
  64520. export class SmoothStepBlock extends NodeMaterialBlock {
  64521. /**
  64522. * Creates a new SmoothStepBlock
  64523. * @param name defines the block name
  64524. */
  64525. constructor(name: string);
  64526. /**
  64527. * Gets the current class name
  64528. * @returns the class name
  64529. */
  64530. getClassName(): string;
  64531. /**
  64532. * Gets the value operand input component
  64533. */
  64534. get value(): NodeMaterialConnectionPoint;
  64535. /**
  64536. * Gets the first edge operand input component
  64537. */
  64538. get edge0(): NodeMaterialConnectionPoint;
  64539. /**
  64540. * Gets the second edge operand input component
  64541. */
  64542. get edge1(): NodeMaterialConnectionPoint;
  64543. /**
  64544. * Gets the output component
  64545. */
  64546. get output(): NodeMaterialConnectionPoint;
  64547. protected _buildBlock(state: NodeMaterialBuildState): this;
  64548. }
  64549. }
  64550. declare module BABYLON {
  64551. /**
  64552. * Block used to get the reciprocal (1 / x) of a value
  64553. */
  64554. export class ReciprocalBlock extends NodeMaterialBlock {
  64555. /**
  64556. * Creates a new ReciprocalBlock
  64557. * @param name defines the block name
  64558. */
  64559. constructor(name: string);
  64560. /**
  64561. * Gets the current class name
  64562. * @returns the class name
  64563. */
  64564. getClassName(): string;
  64565. /**
  64566. * Gets the input component
  64567. */
  64568. get input(): NodeMaterialConnectionPoint;
  64569. /**
  64570. * Gets the output component
  64571. */
  64572. get output(): NodeMaterialConnectionPoint;
  64573. protected _buildBlock(state: NodeMaterialBuildState): this;
  64574. }
  64575. }
  64576. declare module BABYLON {
  64577. /**
  64578. * Block used to replace a color by another one
  64579. */
  64580. export class ReplaceColorBlock extends NodeMaterialBlock {
  64581. /**
  64582. * Creates a new ReplaceColorBlock
  64583. * @param name defines the block name
  64584. */
  64585. constructor(name: string);
  64586. /**
  64587. * Gets the current class name
  64588. * @returns the class name
  64589. */
  64590. getClassName(): string;
  64591. /**
  64592. * Gets the value input component
  64593. */
  64594. get value(): NodeMaterialConnectionPoint;
  64595. /**
  64596. * Gets the reference input component
  64597. */
  64598. get reference(): NodeMaterialConnectionPoint;
  64599. /**
  64600. * Gets the distance input component
  64601. */
  64602. get distance(): NodeMaterialConnectionPoint;
  64603. /**
  64604. * Gets the replacement input component
  64605. */
  64606. get replacement(): NodeMaterialConnectionPoint;
  64607. /**
  64608. * Gets the output component
  64609. */
  64610. get output(): NodeMaterialConnectionPoint;
  64611. protected _buildBlock(state: NodeMaterialBuildState): this;
  64612. }
  64613. }
  64614. declare module BABYLON {
  64615. /**
  64616. * Block used to posterize a value
  64617. * @see https://en.wikipedia.org/wiki/Posterization
  64618. */
  64619. export class PosterizeBlock extends NodeMaterialBlock {
  64620. /**
  64621. * Creates a new PosterizeBlock
  64622. * @param name defines the block name
  64623. */
  64624. constructor(name: string);
  64625. /**
  64626. * Gets the current class name
  64627. * @returns the class name
  64628. */
  64629. getClassName(): string;
  64630. /**
  64631. * Gets the value input component
  64632. */
  64633. get value(): NodeMaterialConnectionPoint;
  64634. /**
  64635. * Gets the steps input component
  64636. */
  64637. get steps(): NodeMaterialConnectionPoint;
  64638. /**
  64639. * Gets the output component
  64640. */
  64641. get output(): NodeMaterialConnectionPoint;
  64642. protected _buildBlock(state: NodeMaterialBuildState): this;
  64643. }
  64644. }
  64645. declare module BABYLON {
  64646. /**
  64647. * Operations supported by the Wave block
  64648. */
  64649. export enum WaveBlockKind {
  64650. /** SawTooth */
  64651. SawTooth = 0,
  64652. /** Square */
  64653. Square = 1,
  64654. /** Triangle */
  64655. Triangle = 2
  64656. }
  64657. /**
  64658. * Block used to apply wave operation to floats
  64659. */
  64660. export class WaveBlock extends NodeMaterialBlock {
  64661. /**
  64662. * Gets or sets the kibnd of wave to be applied by the block
  64663. */
  64664. kind: WaveBlockKind;
  64665. /**
  64666. * Creates a new WaveBlock
  64667. * @param name defines the block name
  64668. */
  64669. constructor(name: string);
  64670. /**
  64671. * Gets the current class name
  64672. * @returns the class name
  64673. */
  64674. getClassName(): string;
  64675. /**
  64676. * Gets the input component
  64677. */
  64678. get input(): NodeMaterialConnectionPoint;
  64679. /**
  64680. * Gets the output component
  64681. */
  64682. get output(): NodeMaterialConnectionPoint;
  64683. protected _buildBlock(state: NodeMaterialBuildState): this;
  64684. serialize(): any;
  64685. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64686. }
  64687. }
  64688. declare module BABYLON {
  64689. /**
  64690. * Class used to store a color step for the GradientBlock
  64691. */
  64692. export class GradientBlockColorStep {
  64693. private _step;
  64694. /**
  64695. * Gets value indicating which step this color is associated with (between 0 and 1)
  64696. */
  64697. get step(): number;
  64698. /**
  64699. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64700. */
  64701. set step(val: number);
  64702. private _color;
  64703. /**
  64704. * Gets the color associated with this step
  64705. */
  64706. get color(): Color3;
  64707. /**
  64708. * Sets the color associated with this step
  64709. */
  64710. set color(val: Color3);
  64711. /**
  64712. * Creates a new GradientBlockColorStep
  64713. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64714. * @param color defines the color associated with this step
  64715. */
  64716. constructor(step: number, color: Color3);
  64717. }
  64718. /**
  64719. * Block used to return a color from a gradient based on an input value between 0 and 1
  64720. */
  64721. export class GradientBlock extends NodeMaterialBlock {
  64722. /**
  64723. * Gets or sets the list of color steps
  64724. */
  64725. colorSteps: GradientBlockColorStep[];
  64726. /** Gets an observable raised when the value is changed */
  64727. onValueChangedObservable: Observable<GradientBlock>;
  64728. /** calls observable when the value is changed*/
  64729. colorStepsUpdated(): void;
  64730. /**
  64731. * Creates a new GradientBlock
  64732. * @param name defines the block name
  64733. */
  64734. constructor(name: string);
  64735. /**
  64736. * Gets the current class name
  64737. * @returns the class name
  64738. */
  64739. getClassName(): string;
  64740. /**
  64741. * Gets the gradient input component
  64742. */
  64743. get gradient(): NodeMaterialConnectionPoint;
  64744. /**
  64745. * Gets the output component
  64746. */
  64747. get output(): NodeMaterialConnectionPoint;
  64748. private _writeColorConstant;
  64749. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64750. serialize(): any;
  64751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64752. protected _dumpPropertiesCode(): string;
  64753. }
  64754. }
  64755. declare module BABYLON {
  64756. /**
  64757. * Block used to normalize lerp between 2 values
  64758. */
  64759. export class NLerpBlock extends NodeMaterialBlock {
  64760. /**
  64761. * Creates a new NLerpBlock
  64762. * @param name defines the block name
  64763. */
  64764. constructor(name: string);
  64765. /**
  64766. * Gets the current class name
  64767. * @returns the class name
  64768. */
  64769. getClassName(): string;
  64770. /**
  64771. * Gets the left operand input component
  64772. */
  64773. get left(): NodeMaterialConnectionPoint;
  64774. /**
  64775. * Gets the right operand input component
  64776. */
  64777. get right(): NodeMaterialConnectionPoint;
  64778. /**
  64779. * Gets the gradient operand input component
  64780. */
  64781. get gradient(): NodeMaterialConnectionPoint;
  64782. /**
  64783. * Gets the output component
  64784. */
  64785. get output(): NodeMaterialConnectionPoint;
  64786. protected _buildBlock(state: NodeMaterialBuildState): this;
  64787. }
  64788. }
  64789. declare module BABYLON {
  64790. /**
  64791. * block used to Generate a Worley Noise 3D Noise Pattern
  64792. */
  64793. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64794. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64795. manhattanDistance: boolean;
  64796. /**
  64797. * Creates a new WorleyNoise3DBlock
  64798. * @param name defines the block name
  64799. */
  64800. constructor(name: string);
  64801. /**
  64802. * Gets the current class name
  64803. * @returns the class name
  64804. */
  64805. getClassName(): string;
  64806. /**
  64807. * Gets the seed input component
  64808. */
  64809. get seed(): NodeMaterialConnectionPoint;
  64810. /**
  64811. * Gets the jitter input component
  64812. */
  64813. get jitter(): NodeMaterialConnectionPoint;
  64814. /**
  64815. * Gets the output component
  64816. */
  64817. get output(): NodeMaterialConnectionPoint;
  64818. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64819. /**
  64820. * Exposes the properties to the UI?
  64821. */
  64822. protected _dumpPropertiesCode(): string;
  64823. /**
  64824. * Exposes the properties to the Seralize?
  64825. */
  64826. serialize(): any;
  64827. /**
  64828. * Exposes the properties to the deseralize?
  64829. */
  64830. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64831. }
  64832. }
  64833. declare module BABYLON {
  64834. /**
  64835. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64836. */
  64837. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64838. /**
  64839. * Creates a new SimplexPerlin3DBlock
  64840. * @param name defines the block name
  64841. */
  64842. constructor(name: string);
  64843. /**
  64844. * Gets the current class name
  64845. * @returns the class name
  64846. */
  64847. getClassName(): string;
  64848. /**
  64849. * Gets the seed operand input component
  64850. */
  64851. get seed(): NodeMaterialConnectionPoint;
  64852. /**
  64853. * Gets the output component
  64854. */
  64855. get output(): NodeMaterialConnectionPoint;
  64856. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64857. }
  64858. }
  64859. declare module BABYLON {
  64860. /**
  64861. * Block used to blend normals
  64862. */
  64863. export class NormalBlendBlock extends NodeMaterialBlock {
  64864. /**
  64865. * Creates a new NormalBlendBlock
  64866. * @param name defines the block name
  64867. */
  64868. constructor(name: string);
  64869. /**
  64870. * Gets the current class name
  64871. * @returns the class name
  64872. */
  64873. getClassName(): string;
  64874. /**
  64875. * Gets the first input component
  64876. */
  64877. get normalMap0(): NodeMaterialConnectionPoint;
  64878. /**
  64879. * Gets the second input component
  64880. */
  64881. get normalMap1(): NodeMaterialConnectionPoint;
  64882. /**
  64883. * Gets the output component
  64884. */
  64885. get output(): NodeMaterialConnectionPoint;
  64886. protected _buildBlock(state: NodeMaterialBuildState): this;
  64887. }
  64888. }
  64889. declare module BABYLON {
  64890. /**
  64891. * Block used to rotate a 2d vector by a given angle
  64892. */
  64893. export class Rotate2dBlock extends NodeMaterialBlock {
  64894. /**
  64895. * Creates a new Rotate2dBlock
  64896. * @param name defines the block name
  64897. */
  64898. constructor(name: string);
  64899. /**
  64900. * Gets the current class name
  64901. * @returns the class name
  64902. */
  64903. getClassName(): string;
  64904. /**
  64905. * Gets the input vector
  64906. */
  64907. get input(): NodeMaterialConnectionPoint;
  64908. /**
  64909. * Gets the input angle
  64910. */
  64911. get angle(): NodeMaterialConnectionPoint;
  64912. /**
  64913. * Gets the output component
  64914. */
  64915. get output(): NodeMaterialConnectionPoint;
  64916. autoConfigure(material: NodeMaterial): void;
  64917. protected _buildBlock(state: NodeMaterialBuildState): this;
  64918. }
  64919. }
  64920. declare module BABYLON {
  64921. /**
  64922. * Block used to get the reflected vector from a direction and a normal
  64923. */
  64924. export class ReflectBlock extends NodeMaterialBlock {
  64925. /**
  64926. * Creates a new ReflectBlock
  64927. * @param name defines the block name
  64928. */
  64929. constructor(name: string);
  64930. /**
  64931. * Gets the current class name
  64932. * @returns the class name
  64933. */
  64934. getClassName(): string;
  64935. /**
  64936. * Gets the incident component
  64937. */
  64938. get incident(): NodeMaterialConnectionPoint;
  64939. /**
  64940. * Gets the normal component
  64941. */
  64942. get normal(): NodeMaterialConnectionPoint;
  64943. /**
  64944. * Gets the output component
  64945. */
  64946. get output(): NodeMaterialConnectionPoint;
  64947. protected _buildBlock(state: NodeMaterialBuildState): this;
  64948. }
  64949. }
  64950. declare module BABYLON {
  64951. /**
  64952. * Block used to get the refracted vector from a direction and a normal
  64953. */
  64954. export class RefractBlock extends NodeMaterialBlock {
  64955. /**
  64956. * Creates a new RefractBlock
  64957. * @param name defines the block name
  64958. */
  64959. constructor(name: string);
  64960. /**
  64961. * Gets the current class name
  64962. * @returns the class name
  64963. */
  64964. getClassName(): string;
  64965. /**
  64966. * Gets the incident component
  64967. */
  64968. get incident(): NodeMaterialConnectionPoint;
  64969. /**
  64970. * Gets the normal component
  64971. */
  64972. get normal(): NodeMaterialConnectionPoint;
  64973. /**
  64974. * Gets the index of refraction component
  64975. */
  64976. get ior(): NodeMaterialConnectionPoint;
  64977. /**
  64978. * Gets the output component
  64979. */
  64980. get output(): NodeMaterialConnectionPoint;
  64981. protected _buildBlock(state: NodeMaterialBuildState): this;
  64982. }
  64983. }
  64984. declare module BABYLON {
  64985. /**
  64986. * Block used to desaturate a color
  64987. */
  64988. export class DesaturateBlock extends NodeMaterialBlock {
  64989. /**
  64990. * Creates a new DesaturateBlock
  64991. * @param name defines the block name
  64992. */
  64993. constructor(name: string);
  64994. /**
  64995. * Gets the current class name
  64996. * @returns the class name
  64997. */
  64998. getClassName(): string;
  64999. /**
  65000. * Gets the color operand input component
  65001. */
  65002. get color(): NodeMaterialConnectionPoint;
  65003. /**
  65004. * Gets the level operand input component
  65005. */
  65006. get level(): NodeMaterialConnectionPoint;
  65007. /**
  65008. * Gets the output component
  65009. */
  65010. get output(): NodeMaterialConnectionPoint;
  65011. protected _buildBlock(state: NodeMaterialBuildState): this;
  65012. }
  65013. }
  65014. declare module BABYLON {
  65015. /**
  65016. * Block used to implement the ambient occlusion module of the PBR material
  65017. */
  65018. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65019. /**
  65020. * Create a new AmbientOcclusionBlock
  65021. * @param name defines the block name
  65022. */
  65023. constructor(name: string);
  65024. /**
  65025. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65026. */
  65027. useAmbientInGrayScale: boolean;
  65028. /**
  65029. * Initialize the block and prepare the context for build
  65030. * @param state defines the state that will be used for the build
  65031. */
  65032. initialize(state: NodeMaterialBuildState): void;
  65033. /**
  65034. * Gets the current class name
  65035. * @returns the class name
  65036. */
  65037. getClassName(): string;
  65038. /**
  65039. * Gets the texture input component
  65040. */
  65041. get texture(): NodeMaterialConnectionPoint;
  65042. /**
  65043. * Gets the texture intensity component
  65044. */
  65045. get intensity(): NodeMaterialConnectionPoint;
  65046. /**
  65047. * Gets the direct light intensity input component
  65048. */
  65049. get directLightIntensity(): NodeMaterialConnectionPoint;
  65050. /**
  65051. * Gets the ambient occlusion object output component
  65052. */
  65053. get ambientOcc(): NodeMaterialConnectionPoint;
  65054. /**
  65055. * Gets the main code of the block (fragment side)
  65056. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65057. * @returns the shader code
  65058. */
  65059. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65060. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65061. protected _buildBlock(state: NodeMaterialBuildState): this;
  65062. protected _dumpPropertiesCode(): string;
  65063. serialize(): any;
  65064. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65065. }
  65066. }
  65067. declare module BABYLON {
  65068. /**
  65069. * Block used to implement the reflection module of the PBR material
  65070. */
  65071. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65072. /** @hidden */
  65073. _defineLODReflectionAlpha: string;
  65074. /** @hidden */
  65075. _defineLinearSpecularReflection: string;
  65076. private _vEnvironmentIrradianceName;
  65077. /** @hidden */
  65078. _vReflectionMicrosurfaceInfosName: string;
  65079. /** @hidden */
  65080. _vReflectionInfosName: string;
  65081. /** @hidden */
  65082. _vReflectionFilteringInfoName: string;
  65083. private _scene;
  65084. /**
  65085. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65086. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65087. * It's less burden on the user side in the editor part.
  65088. */
  65089. /** @hidden */
  65090. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65091. /** @hidden */
  65092. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65093. /** @hidden */
  65094. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65095. /**
  65096. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65097. * diffuse part of the IBL.
  65098. */
  65099. useSphericalHarmonics: boolean;
  65100. /**
  65101. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65102. */
  65103. forceIrradianceInFragment: boolean;
  65104. /**
  65105. * Create a new ReflectionBlock
  65106. * @param name defines the block name
  65107. */
  65108. constructor(name: string);
  65109. /**
  65110. * Gets the current class name
  65111. * @returns the class name
  65112. */
  65113. getClassName(): string;
  65114. /**
  65115. * Gets the position input component
  65116. */
  65117. get position(): NodeMaterialConnectionPoint;
  65118. /**
  65119. * Gets the world position input component
  65120. */
  65121. get worldPosition(): NodeMaterialConnectionPoint;
  65122. /**
  65123. * Gets the world normal input component
  65124. */
  65125. get worldNormal(): NodeMaterialConnectionPoint;
  65126. /**
  65127. * Gets the world input component
  65128. */
  65129. get world(): NodeMaterialConnectionPoint;
  65130. /**
  65131. * Gets the camera (or eye) position component
  65132. */
  65133. get cameraPosition(): NodeMaterialConnectionPoint;
  65134. /**
  65135. * Gets the view input component
  65136. */
  65137. get view(): NodeMaterialConnectionPoint;
  65138. /**
  65139. * Gets the color input component
  65140. */
  65141. get color(): NodeMaterialConnectionPoint;
  65142. /**
  65143. * Gets the reflection object output component
  65144. */
  65145. get reflection(): NodeMaterialConnectionPoint;
  65146. /**
  65147. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65148. */
  65149. get hasTexture(): boolean;
  65150. /**
  65151. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65152. */
  65153. get reflectionColor(): string;
  65154. protected _getTexture(): Nullable<BaseTexture>;
  65155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65156. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65157. /**
  65158. * Gets the code to inject in the vertex shader
  65159. * @param state current state of the node material building
  65160. * @returns the shader code
  65161. */
  65162. handleVertexSide(state: NodeMaterialBuildState): string;
  65163. /**
  65164. * Gets the main code of the block (fragment side)
  65165. * @param state current state of the node material building
  65166. * @param normalVarName name of the existing variable corresponding to the normal
  65167. * @returns the shader code
  65168. */
  65169. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65170. protected _buildBlock(state: NodeMaterialBuildState): this;
  65171. protected _dumpPropertiesCode(): string;
  65172. serialize(): any;
  65173. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65174. }
  65175. }
  65176. declare module BABYLON {
  65177. /**
  65178. * Block used to implement the sheen module of the PBR material
  65179. */
  65180. export class SheenBlock extends NodeMaterialBlock {
  65181. /**
  65182. * Create a new SheenBlock
  65183. * @param name defines the block name
  65184. */
  65185. constructor(name: string);
  65186. /**
  65187. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65188. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65189. * making it easier to setup and tweak the effect
  65190. */
  65191. albedoScaling: boolean;
  65192. /**
  65193. * Defines if the sheen is linked to the sheen color.
  65194. */
  65195. linkSheenWithAlbedo: boolean;
  65196. /**
  65197. * Initialize the block and prepare the context for build
  65198. * @param state defines the state that will be used for the build
  65199. */
  65200. initialize(state: NodeMaterialBuildState): void;
  65201. /**
  65202. * Gets the current class name
  65203. * @returns the class name
  65204. */
  65205. getClassName(): string;
  65206. /**
  65207. * Gets the intensity input component
  65208. */
  65209. get intensity(): NodeMaterialConnectionPoint;
  65210. /**
  65211. * Gets the color input component
  65212. */
  65213. get color(): NodeMaterialConnectionPoint;
  65214. /**
  65215. * Gets the roughness input component
  65216. */
  65217. get roughness(): NodeMaterialConnectionPoint;
  65218. /**
  65219. * Gets the sheen object output component
  65220. */
  65221. get sheen(): NodeMaterialConnectionPoint;
  65222. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65223. /**
  65224. * Gets the main code of the block (fragment side)
  65225. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65226. * @returns the shader code
  65227. */
  65228. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65229. protected _buildBlock(state: NodeMaterialBuildState): this;
  65230. protected _dumpPropertiesCode(): string;
  65231. serialize(): any;
  65232. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65233. }
  65234. }
  65235. declare module BABYLON {
  65236. /**
  65237. * Block used to implement the reflectivity module of the PBR material
  65238. */
  65239. export class ReflectivityBlock extends NodeMaterialBlock {
  65240. private _metallicReflectanceColor;
  65241. private _metallicF0Factor;
  65242. /** @hidden */
  65243. _vMetallicReflectanceFactorsName: string;
  65244. /**
  65245. * The property below is set by the main PBR block prior to calling methods of this class.
  65246. */
  65247. /** @hidden */
  65248. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65249. /**
  65250. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65251. */
  65252. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65253. /**
  65254. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65255. */
  65256. useMetallnessFromMetallicTextureBlue: boolean;
  65257. /**
  65258. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65259. */
  65260. useRoughnessFromMetallicTextureAlpha: boolean;
  65261. /**
  65262. * Specifies if the metallic texture contains the roughness information in its green channel.
  65263. */
  65264. useRoughnessFromMetallicTextureGreen: boolean;
  65265. /**
  65266. * Create a new ReflectivityBlock
  65267. * @param name defines the block name
  65268. */
  65269. constructor(name: string);
  65270. /**
  65271. * Initialize the block and prepare the context for build
  65272. * @param state defines the state that will be used for the build
  65273. */
  65274. initialize(state: NodeMaterialBuildState): void;
  65275. /**
  65276. * Gets the current class name
  65277. * @returns the class name
  65278. */
  65279. getClassName(): string;
  65280. /**
  65281. * Gets the metallic input component
  65282. */
  65283. get metallic(): NodeMaterialConnectionPoint;
  65284. /**
  65285. * Gets the roughness input component
  65286. */
  65287. get roughness(): NodeMaterialConnectionPoint;
  65288. /**
  65289. * Gets the texture input component
  65290. */
  65291. get texture(): NodeMaterialConnectionPoint;
  65292. /**
  65293. * Gets the reflectivity object output component
  65294. */
  65295. get reflectivity(): NodeMaterialConnectionPoint;
  65296. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65297. /**
  65298. * Gets the main code of the block (fragment side)
  65299. * @param state current state of the node material building
  65300. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65301. * @returns the shader code
  65302. */
  65303. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65304. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65305. protected _buildBlock(state: NodeMaterialBuildState): this;
  65306. protected _dumpPropertiesCode(): string;
  65307. serialize(): any;
  65308. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65309. }
  65310. }
  65311. declare module BABYLON {
  65312. /**
  65313. * Block used to implement the anisotropy module of the PBR material
  65314. */
  65315. export class AnisotropyBlock extends NodeMaterialBlock {
  65316. /**
  65317. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65318. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65319. * It's less burden on the user side in the editor part.
  65320. */
  65321. /** @hidden */
  65322. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65323. /** @hidden */
  65324. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65325. /**
  65326. * Create a new AnisotropyBlock
  65327. * @param name defines the block name
  65328. */
  65329. constructor(name: string);
  65330. /**
  65331. * Initialize the block and prepare the context for build
  65332. * @param state defines the state that will be used for the build
  65333. */
  65334. initialize(state: NodeMaterialBuildState): void;
  65335. /**
  65336. * Gets the current class name
  65337. * @returns the class name
  65338. */
  65339. getClassName(): string;
  65340. /**
  65341. * Gets the intensity input component
  65342. */
  65343. get intensity(): NodeMaterialConnectionPoint;
  65344. /**
  65345. * Gets the direction input component
  65346. */
  65347. get direction(): NodeMaterialConnectionPoint;
  65348. /**
  65349. * Gets the texture input component
  65350. */
  65351. get texture(): NodeMaterialConnectionPoint;
  65352. /**
  65353. * Gets the uv input component
  65354. */
  65355. get uv(): NodeMaterialConnectionPoint;
  65356. /**
  65357. * Gets the worldTangent input component
  65358. */
  65359. get worldTangent(): NodeMaterialConnectionPoint;
  65360. /**
  65361. * Gets the anisotropy object output component
  65362. */
  65363. get anisotropy(): NodeMaterialConnectionPoint;
  65364. private _generateTBNSpace;
  65365. /**
  65366. * Gets the main code of the block (fragment side)
  65367. * @param state current state of the node material building
  65368. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65369. * @returns the shader code
  65370. */
  65371. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65372. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65373. protected _buildBlock(state: NodeMaterialBuildState): this;
  65374. }
  65375. }
  65376. declare module BABYLON {
  65377. /**
  65378. * Block used to implement the clear coat module of the PBR material
  65379. */
  65380. export class ClearCoatBlock extends NodeMaterialBlock {
  65381. private _scene;
  65382. /**
  65383. * Create a new ClearCoatBlock
  65384. * @param name defines the block name
  65385. */
  65386. constructor(name: string);
  65387. /**
  65388. * Initialize the block and prepare the context for build
  65389. * @param state defines the state that will be used for the build
  65390. */
  65391. initialize(state: NodeMaterialBuildState): void;
  65392. /**
  65393. * Gets the current class name
  65394. * @returns the class name
  65395. */
  65396. getClassName(): string;
  65397. /**
  65398. * Gets the intensity input component
  65399. */
  65400. get intensity(): NodeMaterialConnectionPoint;
  65401. /**
  65402. * Gets the roughness input component
  65403. */
  65404. get roughness(): NodeMaterialConnectionPoint;
  65405. /**
  65406. * Gets the ior input component
  65407. */
  65408. get ior(): NodeMaterialConnectionPoint;
  65409. /**
  65410. * Gets the texture input component
  65411. */
  65412. get texture(): NodeMaterialConnectionPoint;
  65413. /**
  65414. * Gets the bump texture input component
  65415. */
  65416. get bumpTexture(): NodeMaterialConnectionPoint;
  65417. /**
  65418. * Gets the uv input component
  65419. */
  65420. get uv(): NodeMaterialConnectionPoint;
  65421. /**
  65422. * Gets the tint color input component
  65423. */
  65424. get tintColor(): NodeMaterialConnectionPoint;
  65425. /**
  65426. * Gets the tint "at distance" input component
  65427. */
  65428. get tintAtDistance(): NodeMaterialConnectionPoint;
  65429. /**
  65430. * Gets the tint thickness input component
  65431. */
  65432. get tintThickness(): NodeMaterialConnectionPoint;
  65433. /**
  65434. * Gets the world tangent input component
  65435. */
  65436. get worldTangent(): NodeMaterialConnectionPoint;
  65437. /**
  65438. * Gets the clear coat object output component
  65439. */
  65440. get clearcoat(): NodeMaterialConnectionPoint;
  65441. autoConfigure(material: NodeMaterial): void;
  65442. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65443. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65444. private _generateTBNSpace;
  65445. /**
  65446. * Gets the main code of the block (fragment side)
  65447. * @param state current state of the node material building
  65448. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65449. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65450. * @param worldPosVarName name of the variable holding the world position
  65451. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65452. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65453. * @param worldNormalVarName name of the variable holding the world normal
  65454. * @returns the shader code
  65455. */
  65456. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65457. protected _buildBlock(state: NodeMaterialBuildState): this;
  65458. }
  65459. }
  65460. declare module BABYLON {
  65461. /**
  65462. * Block used to implement the sub surface module of the PBR material
  65463. */
  65464. export class SubSurfaceBlock extends NodeMaterialBlock {
  65465. /**
  65466. * Create a new SubSurfaceBlock
  65467. * @param name defines the block name
  65468. */
  65469. constructor(name: string);
  65470. /**
  65471. * Stores the intensity of the different subsurface effects in the thickness texture.
  65472. * * the green channel is the translucency intensity.
  65473. * * the blue channel is the scattering intensity.
  65474. * * the alpha channel is the refraction intensity.
  65475. */
  65476. useMaskFromThicknessTexture: boolean;
  65477. /**
  65478. * Initialize the block and prepare the context for build
  65479. * @param state defines the state that will be used for the build
  65480. */
  65481. initialize(state: NodeMaterialBuildState): void;
  65482. /**
  65483. * Gets the current class name
  65484. * @returns the class name
  65485. */
  65486. getClassName(): string;
  65487. /**
  65488. * Gets the min thickness input component
  65489. */
  65490. get minThickness(): NodeMaterialConnectionPoint;
  65491. /**
  65492. * Gets the max thickness input component
  65493. */
  65494. get maxThickness(): NodeMaterialConnectionPoint;
  65495. /**
  65496. * Gets the thickness texture component
  65497. */
  65498. get thicknessTexture(): NodeMaterialConnectionPoint;
  65499. /**
  65500. * Gets the tint color input component
  65501. */
  65502. get tintColor(): NodeMaterialConnectionPoint;
  65503. /**
  65504. * Gets the translucency intensity input component
  65505. */
  65506. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65507. /**
  65508. * Gets the translucency diffusion distance input component
  65509. */
  65510. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65511. /**
  65512. * Gets the refraction object parameters
  65513. */
  65514. get refraction(): NodeMaterialConnectionPoint;
  65515. /**
  65516. * Gets the sub surface object output component
  65517. */
  65518. get subsurface(): NodeMaterialConnectionPoint;
  65519. autoConfigure(material: NodeMaterial): void;
  65520. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65521. /**
  65522. * Gets the main code of the block (fragment side)
  65523. * @param state current state of the node material building
  65524. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65525. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65526. * @param worldPosVarName name of the variable holding the world position
  65527. * @returns the shader code
  65528. */
  65529. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65530. protected _buildBlock(state: NodeMaterialBuildState): this;
  65531. }
  65532. }
  65533. declare module BABYLON {
  65534. /**
  65535. * Block used to implement the PBR metallic/roughness model
  65536. */
  65537. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65538. /**
  65539. * Gets or sets the light associated with this block
  65540. */
  65541. light: Nullable<Light>;
  65542. private _lightId;
  65543. private _scene;
  65544. private _environmentBRDFTexture;
  65545. private _environmentBrdfSamplerName;
  65546. private _vNormalWName;
  65547. private _invertNormalName;
  65548. /**
  65549. * Create a new ReflectionBlock
  65550. * @param name defines the block name
  65551. */
  65552. constructor(name: string);
  65553. /**
  65554. * Intensity of the direct lights e.g. the four lights available in your scene.
  65555. * This impacts both the direct diffuse and specular highlights.
  65556. */
  65557. directIntensity: number;
  65558. /**
  65559. * Intensity of the environment e.g. how much the environment will light the object
  65560. * either through harmonics for rough material or through the refelction for shiny ones.
  65561. */
  65562. environmentIntensity: number;
  65563. /**
  65564. * This is a special control allowing the reduction of the specular highlights coming from the
  65565. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65566. */
  65567. specularIntensity: number;
  65568. /**
  65569. * Defines the falloff type used in this material.
  65570. * It by default is Physical.
  65571. */
  65572. lightFalloff: number;
  65573. /**
  65574. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65575. */
  65576. useAlphaFromAlbedoTexture: boolean;
  65577. /**
  65578. * Specifies that alpha test should be used
  65579. */
  65580. useAlphaTest: boolean;
  65581. /**
  65582. * Defines the alpha limits in alpha test mode.
  65583. */
  65584. alphaTestCutoff: number;
  65585. /**
  65586. * Specifies that alpha blending should be used
  65587. */
  65588. useAlphaBlending: boolean;
  65589. /**
  65590. * Defines if the alpha value should be determined via the rgb values.
  65591. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65592. */
  65593. opacityRGB: boolean;
  65594. /**
  65595. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65596. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65597. */
  65598. useRadianceOverAlpha: boolean;
  65599. /**
  65600. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65601. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65602. */
  65603. useSpecularOverAlpha: boolean;
  65604. /**
  65605. * Enables specular anti aliasing in the PBR shader.
  65606. * It will both interacts on the Geometry for analytical and IBL lighting.
  65607. * It also prefilter the roughness map based on the bump values.
  65608. */
  65609. enableSpecularAntiAliasing: boolean;
  65610. /**
  65611. * Enables realtime filtering on the texture.
  65612. */
  65613. realTimeFiltering: boolean;
  65614. /**
  65615. * Quality switch for realtime filtering
  65616. */
  65617. realTimeFilteringQuality: number;
  65618. /**
  65619. * Defines if the material uses energy conservation.
  65620. */
  65621. useEnergyConservation: boolean;
  65622. /**
  65623. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65624. * too much the area relying on ambient texture to define their ambient occlusion.
  65625. */
  65626. useRadianceOcclusion: boolean;
  65627. /**
  65628. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65629. * makes the reflect vector face the model (under horizon).
  65630. */
  65631. useHorizonOcclusion: boolean;
  65632. /**
  65633. * If set to true, no lighting calculations will be applied.
  65634. */
  65635. unlit: boolean;
  65636. /**
  65637. * Force normal to face away from face.
  65638. */
  65639. forceNormalForward: boolean;
  65640. /**
  65641. * Defines the material debug mode.
  65642. * It helps seeing only some components of the material while troubleshooting.
  65643. */
  65644. debugMode: number;
  65645. /**
  65646. * Specify from where on screen the debug mode should start.
  65647. * The value goes from -1 (full screen) to 1 (not visible)
  65648. * It helps with side by side comparison against the final render
  65649. * This defaults to 0
  65650. */
  65651. debugLimit: number;
  65652. /**
  65653. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65654. * You can use the factor to better multiply the final value.
  65655. */
  65656. debugFactor: number;
  65657. /**
  65658. * Initialize the block and prepare the context for build
  65659. * @param state defines the state that will be used for the build
  65660. */
  65661. initialize(state: NodeMaterialBuildState): void;
  65662. /**
  65663. * Gets the current class name
  65664. * @returns the class name
  65665. */
  65666. getClassName(): string;
  65667. /**
  65668. * Gets the world position input component
  65669. */
  65670. get worldPosition(): NodeMaterialConnectionPoint;
  65671. /**
  65672. * Gets the world normal input component
  65673. */
  65674. get worldNormal(): NodeMaterialConnectionPoint;
  65675. /**
  65676. * Gets the perturbed normal input component
  65677. */
  65678. get perturbedNormal(): NodeMaterialConnectionPoint;
  65679. /**
  65680. * Gets the camera position input component
  65681. */
  65682. get cameraPosition(): NodeMaterialConnectionPoint;
  65683. /**
  65684. * Gets the base color input component
  65685. */
  65686. get baseColor(): NodeMaterialConnectionPoint;
  65687. /**
  65688. * Gets the opacity texture input component
  65689. */
  65690. get opacityTexture(): NodeMaterialConnectionPoint;
  65691. /**
  65692. * Gets the ambient color input component
  65693. */
  65694. get ambientColor(): NodeMaterialConnectionPoint;
  65695. /**
  65696. * Gets the reflectivity object parameters
  65697. */
  65698. get reflectivity(): NodeMaterialConnectionPoint;
  65699. /**
  65700. * Gets the ambient occlusion object parameters
  65701. */
  65702. get ambientOcc(): NodeMaterialConnectionPoint;
  65703. /**
  65704. * Gets the reflection object parameters
  65705. */
  65706. get reflection(): NodeMaterialConnectionPoint;
  65707. /**
  65708. * Gets the sheen object parameters
  65709. */
  65710. get sheen(): NodeMaterialConnectionPoint;
  65711. /**
  65712. * Gets the clear coat object parameters
  65713. */
  65714. get clearcoat(): NodeMaterialConnectionPoint;
  65715. /**
  65716. * Gets the sub surface object parameters
  65717. */
  65718. get subsurface(): NodeMaterialConnectionPoint;
  65719. /**
  65720. * Gets the anisotropy object parameters
  65721. */
  65722. get anisotropy(): NodeMaterialConnectionPoint;
  65723. /**
  65724. * Gets the view matrix parameter
  65725. */
  65726. get view(): NodeMaterialConnectionPoint;
  65727. /**
  65728. * Gets the ambient output component
  65729. */
  65730. get ambient(): NodeMaterialConnectionPoint;
  65731. /**
  65732. * Gets the diffuse output component
  65733. */
  65734. get diffuse(): NodeMaterialConnectionPoint;
  65735. /**
  65736. * Gets the specular output component
  65737. */
  65738. get specular(): NodeMaterialConnectionPoint;
  65739. /**
  65740. * Gets the sheen output component
  65741. */
  65742. get sheenDir(): NodeMaterialConnectionPoint;
  65743. /**
  65744. * Gets the clear coat output component
  65745. */
  65746. get clearcoatDir(): NodeMaterialConnectionPoint;
  65747. /**
  65748. * Gets the indirect diffuse output component
  65749. */
  65750. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65751. /**
  65752. * Gets the indirect specular output component
  65753. */
  65754. get specularIndirect(): NodeMaterialConnectionPoint;
  65755. /**
  65756. * Gets the indirect sheen output component
  65757. */
  65758. get sheenIndirect(): NodeMaterialConnectionPoint;
  65759. /**
  65760. * Gets the indirect clear coat output component
  65761. */
  65762. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65763. /**
  65764. * Gets the refraction output component
  65765. */
  65766. get refraction(): NodeMaterialConnectionPoint;
  65767. /**
  65768. * Gets the global lighting output component
  65769. */
  65770. get lighting(): NodeMaterialConnectionPoint;
  65771. /**
  65772. * Gets the shadow output component
  65773. */
  65774. get shadow(): NodeMaterialConnectionPoint;
  65775. /**
  65776. * Gets the alpha output component
  65777. */
  65778. get alpha(): NodeMaterialConnectionPoint;
  65779. autoConfigure(material: NodeMaterial): void;
  65780. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65781. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65782. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65783. private _injectVertexCode;
  65784. /**
  65785. * Gets the code corresponding to the albedo/opacity module
  65786. * @returns the shader code
  65787. */
  65788. getAlbedoOpacityCode(): string;
  65789. protected _buildBlock(state: NodeMaterialBuildState): this;
  65790. protected _dumpPropertiesCode(): string;
  65791. serialize(): any;
  65792. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65793. }
  65794. }
  65795. declare module BABYLON {
  65796. /**
  65797. * Block used to compute value of one parameter modulo another
  65798. */
  65799. export class ModBlock extends NodeMaterialBlock {
  65800. /**
  65801. * Creates a new ModBlock
  65802. * @param name defines the block name
  65803. */
  65804. constructor(name: string);
  65805. /**
  65806. * Gets the current class name
  65807. * @returns the class name
  65808. */
  65809. getClassName(): string;
  65810. /**
  65811. * Gets the left operand input component
  65812. */
  65813. get left(): NodeMaterialConnectionPoint;
  65814. /**
  65815. * Gets the right operand input component
  65816. */
  65817. get right(): NodeMaterialConnectionPoint;
  65818. /**
  65819. * Gets the output component
  65820. */
  65821. get output(): NodeMaterialConnectionPoint;
  65822. protected _buildBlock(state: NodeMaterialBuildState): this;
  65823. }
  65824. }
  65825. declare module BABYLON {
  65826. /**
  65827. * Configuration for Draco compression
  65828. */
  65829. export interface IDracoCompressionConfiguration {
  65830. /**
  65831. * Configuration for the decoder.
  65832. */
  65833. decoder: {
  65834. /**
  65835. * The url to the WebAssembly module.
  65836. */
  65837. wasmUrl?: string;
  65838. /**
  65839. * The url to the WebAssembly binary.
  65840. */
  65841. wasmBinaryUrl?: string;
  65842. /**
  65843. * The url to the fallback JavaScript module.
  65844. */
  65845. fallbackUrl?: string;
  65846. };
  65847. }
  65848. /**
  65849. * Draco compression (https://google.github.io/draco/)
  65850. *
  65851. * This class wraps the Draco module.
  65852. *
  65853. * **Encoder**
  65854. *
  65855. * The encoder is not currently implemented.
  65856. *
  65857. * **Decoder**
  65858. *
  65859. * 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.
  65860. *
  65861. * To update the configuration, use the following code:
  65862. * ```javascript
  65863. * DracoCompression.Configuration = {
  65864. * decoder: {
  65865. * wasmUrl: "<url to the WebAssembly library>",
  65866. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65867. * fallbackUrl: "<url to the fallback JavaScript library>",
  65868. * }
  65869. * };
  65870. * ```
  65871. *
  65872. * 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.
  65873. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65874. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65875. *
  65876. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65877. * ```javascript
  65878. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65879. * ```
  65880. *
  65881. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65882. */
  65883. export class DracoCompression implements IDisposable {
  65884. private _workerPoolPromise?;
  65885. private _decoderModulePromise?;
  65886. /**
  65887. * The configuration. Defaults to the following urls:
  65888. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65889. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65890. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65891. */
  65892. static Configuration: IDracoCompressionConfiguration;
  65893. /**
  65894. * Returns true if the decoder configuration is available.
  65895. */
  65896. static get DecoderAvailable(): boolean;
  65897. /**
  65898. * Default number of workers to create when creating the draco compression object.
  65899. */
  65900. static DefaultNumWorkers: number;
  65901. private static GetDefaultNumWorkers;
  65902. private static _Default;
  65903. /**
  65904. * Default instance for the draco compression object.
  65905. */
  65906. static get Default(): DracoCompression;
  65907. /**
  65908. * Constructor
  65909. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65910. */
  65911. constructor(numWorkers?: number);
  65912. /**
  65913. * Stop all async operations and release resources.
  65914. */
  65915. dispose(): void;
  65916. /**
  65917. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65918. * @returns a promise that resolves when ready
  65919. */
  65920. whenReadyAsync(): Promise<void>;
  65921. /**
  65922. * Decode Draco compressed mesh data to vertex data.
  65923. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65924. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65925. * @returns A promise that resolves with the decoded vertex data
  65926. */
  65927. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65928. [kind: string]: number;
  65929. }): Promise<VertexData>;
  65930. }
  65931. }
  65932. declare module BABYLON {
  65933. /**
  65934. * Class for building Constructive Solid Geometry
  65935. */
  65936. export class CSG {
  65937. private polygons;
  65938. /**
  65939. * The world matrix
  65940. */
  65941. matrix: Matrix;
  65942. /**
  65943. * Stores the position
  65944. */
  65945. position: Vector3;
  65946. /**
  65947. * Stores the rotation
  65948. */
  65949. rotation: Vector3;
  65950. /**
  65951. * Stores the rotation quaternion
  65952. */
  65953. rotationQuaternion: Nullable<Quaternion>;
  65954. /**
  65955. * Stores the scaling vector
  65956. */
  65957. scaling: Vector3;
  65958. /**
  65959. * Convert the Mesh to CSG
  65960. * @param mesh The Mesh to convert to CSG
  65961. * @returns A new CSG from the Mesh
  65962. */
  65963. static FromMesh(mesh: Mesh): CSG;
  65964. /**
  65965. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65966. * @param polygons Polygons used to construct a CSG solid
  65967. */
  65968. private static FromPolygons;
  65969. /**
  65970. * Clones, or makes a deep copy, of the CSG
  65971. * @returns A new CSG
  65972. */
  65973. clone(): CSG;
  65974. /**
  65975. * Unions this CSG with another CSG
  65976. * @param csg The CSG to union against this CSG
  65977. * @returns The unioned CSG
  65978. */
  65979. union(csg: CSG): CSG;
  65980. /**
  65981. * Unions this CSG with another CSG in place
  65982. * @param csg The CSG to union against this CSG
  65983. */
  65984. unionInPlace(csg: CSG): void;
  65985. /**
  65986. * Subtracts this CSG with another CSG
  65987. * @param csg The CSG to subtract against this CSG
  65988. * @returns A new CSG
  65989. */
  65990. subtract(csg: CSG): CSG;
  65991. /**
  65992. * Subtracts this CSG with another CSG in place
  65993. * @param csg The CSG to subtact against this CSG
  65994. */
  65995. subtractInPlace(csg: CSG): void;
  65996. /**
  65997. * Intersect this CSG with another CSG
  65998. * @param csg The CSG to intersect against this CSG
  65999. * @returns A new CSG
  66000. */
  66001. intersect(csg: CSG): CSG;
  66002. /**
  66003. * Intersects this CSG with another CSG in place
  66004. * @param csg The CSG to intersect against this CSG
  66005. */
  66006. intersectInPlace(csg: CSG): void;
  66007. /**
  66008. * Return a new CSG solid with solid and empty space switched. This solid is
  66009. * not modified.
  66010. * @returns A new CSG solid with solid and empty space switched
  66011. */
  66012. inverse(): CSG;
  66013. /**
  66014. * Inverses the CSG in place
  66015. */
  66016. inverseInPlace(): void;
  66017. /**
  66018. * This is used to keep meshes transformations so they can be restored
  66019. * when we build back a Babylon Mesh
  66020. * NB : All CSG operations are performed in world coordinates
  66021. * @param csg The CSG to copy the transform attributes from
  66022. * @returns This CSG
  66023. */
  66024. copyTransformAttributes(csg: CSG): CSG;
  66025. /**
  66026. * Build Raw mesh from CSG
  66027. * Coordinates here are in world space
  66028. * @param name The name of the mesh geometry
  66029. * @param scene The Scene
  66030. * @param keepSubMeshes Specifies if the submeshes should be kept
  66031. * @returns A new Mesh
  66032. */
  66033. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66034. /**
  66035. * Build Mesh from CSG taking material and transforms into account
  66036. * @param name The name of the Mesh
  66037. * @param material The material of the Mesh
  66038. * @param scene The Scene
  66039. * @param keepSubMeshes Specifies if submeshes should be kept
  66040. * @returns The new Mesh
  66041. */
  66042. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66043. }
  66044. }
  66045. declare module BABYLON {
  66046. /**
  66047. * Class used to create a trail following a mesh
  66048. */
  66049. export class TrailMesh extends Mesh {
  66050. private _generator;
  66051. private _autoStart;
  66052. private _running;
  66053. private _diameter;
  66054. private _length;
  66055. private _sectionPolygonPointsCount;
  66056. private _sectionVectors;
  66057. private _sectionNormalVectors;
  66058. private _beforeRenderObserver;
  66059. /**
  66060. * @constructor
  66061. * @param name The value used by scene.getMeshByName() to do a lookup.
  66062. * @param generator The mesh or transform node to generate a trail.
  66063. * @param scene The scene to add this mesh to.
  66064. * @param diameter Diameter of trailing mesh. Default is 1.
  66065. * @param length Length of trailing mesh. Default is 60.
  66066. * @param autoStart Automatically start trailing mesh. Default true.
  66067. */
  66068. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66069. /**
  66070. * "TrailMesh"
  66071. * @returns "TrailMesh"
  66072. */
  66073. getClassName(): string;
  66074. private _createMesh;
  66075. /**
  66076. * Start trailing mesh.
  66077. */
  66078. start(): void;
  66079. /**
  66080. * Stop trailing mesh.
  66081. */
  66082. stop(): void;
  66083. /**
  66084. * Update trailing mesh geometry.
  66085. */
  66086. update(): void;
  66087. /**
  66088. * Returns a new TrailMesh object.
  66089. * @param name is a string, the name given to the new mesh
  66090. * @param newGenerator use new generator object for cloned trail mesh
  66091. * @returns a new mesh
  66092. */
  66093. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66094. /**
  66095. * Serializes this trail mesh
  66096. * @param serializationObject object to write serialization to
  66097. */
  66098. serialize(serializationObject: any): void;
  66099. /**
  66100. * Parses a serialized trail mesh
  66101. * @param parsedMesh the serialized mesh
  66102. * @param scene the scene to create the trail mesh in
  66103. * @returns the created trail mesh
  66104. */
  66105. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66106. }
  66107. }
  66108. declare module BABYLON {
  66109. /**
  66110. * Class containing static functions to help procedurally build meshes
  66111. */
  66112. export class TiledBoxBuilder {
  66113. /**
  66114. * Creates a box mesh
  66115. * 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)
  66116. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66118. * * 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
  66119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66120. * @param name defines the name of the mesh
  66121. * @param options defines the options used to create the mesh
  66122. * @param scene defines the hosting scene
  66123. * @returns the box mesh
  66124. */
  66125. static CreateTiledBox(name: string, options: {
  66126. pattern?: number;
  66127. width?: number;
  66128. height?: number;
  66129. depth?: number;
  66130. tileSize?: number;
  66131. tileWidth?: number;
  66132. tileHeight?: number;
  66133. alignHorizontal?: number;
  66134. alignVertical?: number;
  66135. faceUV?: Vector4[];
  66136. faceColors?: Color4[];
  66137. sideOrientation?: number;
  66138. updatable?: boolean;
  66139. }, scene?: Nullable<Scene>): Mesh;
  66140. }
  66141. }
  66142. declare module BABYLON {
  66143. /**
  66144. * Class containing static functions to help procedurally build meshes
  66145. */
  66146. export class TorusKnotBuilder {
  66147. /**
  66148. * Creates a torus knot mesh
  66149. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66150. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66151. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66152. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66154. * * 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
  66155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66156. * @param name defines the name of the mesh
  66157. * @param options defines the options used to create the mesh
  66158. * @param scene defines the hosting scene
  66159. * @returns the torus knot mesh
  66160. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66161. */
  66162. static CreateTorusKnot(name: string, options: {
  66163. radius?: number;
  66164. tube?: number;
  66165. radialSegments?: number;
  66166. tubularSegments?: number;
  66167. p?: number;
  66168. q?: number;
  66169. updatable?: boolean;
  66170. sideOrientation?: number;
  66171. frontUVs?: Vector4;
  66172. backUVs?: Vector4;
  66173. }, scene: any): Mesh;
  66174. }
  66175. }
  66176. declare module BABYLON {
  66177. /**
  66178. * Polygon
  66179. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66180. */
  66181. export class Polygon {
  66182. /**
  66183. * Creates a rectangle
  66184. * @param xmin bottom X coord
  66185. * @param ymin bottom Y coord
  66186. * @param xmax top X coord
  66187. * @param ymax top Y coord
  66188. * @returns points that make the resulting rectation
  66189. */
  66190. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66191. /**
  66192. * Creates a circle
  66193. * @param radius radius of circle
  66194. * @param cx scale in x
  66195. * @param cy scale in y
  66196. * @param numberOfSides number of sides that make up the circle
  66197. * @returns points that make the resulting circle
  66198. */
  66199. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66200. /**
  66201. * Creates a polygon from input string
  66202. * @param input Input polygon data
  66203. * @returns the parsed points
  66204. */
  66205. static Parse(input: string): Vector2[];
  66206. /**
  66207. * Starts building a polygon from x and y coordinates
  66208. * @param x x coordinate
  66209. * @param y y coordinate
  66210. * @returns the started path2
  66211. */
  66212. static StartingAt(x: number, y: number): Path2;
  66213. }
  66214. /**
  66215. * Builds a polygon
  66216. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66217. */
  66218. export class PolygonMeshBuilder {
  66219. private _points;
  66220. private _outlinepoints;
  66221. private _holes;
  66222. private _name;
  66223. private _scene;
  66224. private _epoints;
  66225. private _eholes;
  66226. private _addToepoint;
  66227. /**
  66228. * Babylon reference to the earcut plugin.
  66229. */
  66230. bjsEarcut: any;
  66231. /**
  66232. * Creates a PolygonMeshBuilder
  66233. * @param name name of the builder
  66234. * @param contours Path of the polygon
  66235. * @param scene scene to add to when creating the mesh
  66236. * @param earcutInjection can be used to inject your own earcut reference
  66237. */
  66238. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66239. /**
  66240. * Adds a whole within the polygon
  66241. * @param hole Array of points defining the hole
  66242. * @returns this
  66243. */
  66244. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66245. /**
  66246. * Creates the polygon
  66247. * @param updatable If the mesh should be updatable
  66248. * @param depth The depth of the mesh created
  66249. * @returns the created mesh
  66250. */
  66251. build(updatable?: boolean, depth?: number): Mesh;
  66252. /**
  66253. * Creates the polygon
  66254. * @param depth The depth of the mesh created
  66255. * @returns the created VertexData
  66256. */
  66257. buildVertexData(depth?: number): VertexData;
  66258. /**
  66259. * Adds a side to the polygon
  66260. * @param positions points that make the polygon
  66261. * @param normals normals of the polygon
  66262. * @param uvs uvs of the polygon
  66263. * @param indices indices of the polygon
  66264. * @param bounds bounds of the polygon
  66265. * @param points points of the polygon
  66266. * @param depth depth of the polygon
  66267. * @param flip flip of the polygon
  66268. */
  66269. private addSide;
  66270. }
  66271. }
  66272. declare module BABYLON {
  66273. /**
  66274. * Class containing static functions to help procedurally build meshes
  66275. */
  66276. export class PolygonBuilder {
  66277. /**
  66278. * Creates a polygon mesh
  66279. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66280. * * 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
  66281. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66283. * * 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)
  66284. * * Remember you can only change the shape positions, not their number when updating a polygon
  66285. * @param name defines the name of the mesh
  66286. * @param options defines the options used to create the mesh
  66287. * @param scene defines the hosting scene
  66288. * @param earcutInjection can be used to inject your own earcut reference
  66289. * @returns the polygon mesh
  66290. */
  66291. static CreatePolygon(name: string, options: {
  66292. shape: Vector3[];
  66293. holes?: Vector3[][];
  66294. depth?: number;
  66295. faceUV?: Vector4[];
  66296. faceColors?: Color4[];
  66297. updatable?: boolean;
  66298. sideOrientation?: number;
  66299. frontUVs?: Vector4;
  66300. backUVs?: Vector4;
  66301. wrap?: boolean;
  66302. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66303. /**
  66304. * Creates an extruded polygon mesh, with depth in the Y direction.
  66305. * * 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)
  66306. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66307. * @param name defines the name of the mesh
  66308. * @param options defines the options used to create the mesh
  66309. * @param scene defines the hosting scene
  66310. * @param earcutInjection can be used to inject your own earcut reference
  66311. * @returns the polygon mesh
  66312. */
  66313. static ExtrudePolygon(name: string, options: {
  66314. shape: Vector3[];
  66315. holes?: Vector3[][];
  66316. depth?: number;
  66317. faceUV?: Vector4[];
  66318. faceColors?: Color4[];
  66319. updatable?: boolean;
  66320. sideOrientation?: number;
  66321. frontUVs?: Vector4;
  66322. backUVs?: Vector4;
  66323. wrap?: boolean;
  66324. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66325. }
  66326. }
  66327. declare module BABYLON {
  66328. /**
  66329. * Class containing static functions to help procedurally build meshes
  66330. */
  66331. export class LatheBuilder {
  66332. /**
  66333. * Creates lathe mesh.
  66334. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66335. * * 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
  66336. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66337. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66338. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66339. * * 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
  66340. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66341. * * 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
  66342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66343. * * 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
  66344. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66346. * @param name defines the name of the mesh
  66347. * @param options defines the options used to create the mesh
  66348. * @param scene defines the hosting scene
  66349. * @returns the lathe mesh
  66350. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66351. */
  66352. static CreateLathe(name: string, options: {
  66353. shape: Vector3[];
  66354. radius?: number;
  66355. tessellation?: number;
  66356. clip?: number;
  66357. arc?: number;
  66358. closed?: boolean;
  66359. updatable?: boolean;
  66360. sideOrientation?: number;
  66361. frontUVs?: Vector4;
  66362. backUVs?: Vector4;
  66363. cap?: number;
  66364. invertUV?: boolean;
  66365. }, scene?: Nullable<Scene>): Mesh;
  66366. }
  66367. }
  66368. declare module BABYLON {
  66369. /**
  66370. * Class containing static functions to help procedurally build meshes
  66371. */
  66372. export class TiledPlaneBuilder {
  66373. /**
  66374. * Creates a tiled plane mesh
  66375. * * The parameter `pattern` will, depending on value, do nothing or
  66376. * * * flip (reflect about central vertical) alternate tiles across and up
  66377. * * * flip every tile on alternate rows
  66378. * * * rotate (180 degs) alternate tiles across and up
  66379. * * * rotate every tile on alternate rows
  66380. * * * flip and rotate alternate tiles across and up
  66381. * * * flip and rotate every tile on alternate rows
  66382. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66383. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66384. * * 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
  66385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66386. * * 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)
  66387. * * 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)
  66388. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66389. * @param name defines the name of the mesh
  66390. * @param options defines the options used to create the mesh
  66391. * @param scene defines the hosting scene
  66392. * @returns the box mesh
  66393. */
  66394. static CreateTiledPlane(name: string, options: {
  66395. pattern?: number;
  66396. tileSize?: number;
  66397. tileWidth?: number;
  66398. tileHeight?: number;
  66399. size?: number;
  66400. width?: number;
  66401. height?: number;
  66402. alignHorizontal?: number;
  66403. alignVertical?: number;
  66404. sideOrientation?: number;
  66405. frontUVs?: Vector4;
  66406. backUVs?: Vector4;
  66407. updatable?: boolean;
  66408. }, scene?: Nullable<Scene>): Mesh;
  66409. }
  66410. }
  66411. declare module BABYLON {
  66412. /**
  66413. * Class containing static functions to help procedurally build meshes
  66414. */
  66415. export class TubeBuilder {
  66416. /**
  66417. * Creates a tube mesh.
  66418. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66419. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66420. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66421. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66422. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66423. * * 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)
  66424. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66425. * * 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
  66426. * * 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
  66427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66428. * * 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
  66429. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66431. * @param name defines the name of the mesh
  66432. * @param options defines the options used to create the mesh
  66433. * @param scene defines the hosting scene
  66434. * @returns the tube mesh
  66435. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66436. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66437. */
  66438. static CreateTube(name: string, options: {
  66439. path: Vector3[];
  66440. radius?: number;
  66441. tessellation?: number;
  66442. radiusFunction?: {
  66443. (i: number, distance: number): number;
  66444. };
  66445. cap?: number;
  66446. arc?: number;
  66447. updatable?: boolean;
  66448. sideOrientation?: number;
  66449. frontUVs?: Vector4;
  66450. backUVs?: Vector4;
  66451. instance?: Mesh;
  66452. invertUV?: boolean;
  66453. }, scene?: Nullable<Scene>): Mesh;
  66454. }
  66455. }
  66456. declare module BABYLON {
  66457. /**
  66458. * Class containing static functions to help procedurally build meshes
  66459. */
  66460. export class IcoSphereBuilder {
  66461. /**
  66462. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66463. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66464. * * 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`)
  66465. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66466. * * 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
  66467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66468. * * 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
  66469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66470. * @param name defines the name of the mesh
  66471. * @param options defines the options used to create the mesh
  66472. * @param scene defines the hosting scene
  66473. * @returns the icosahedron mesh
  66474. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66475. */
  66476. static CreateIcoSphere(name: string, options: {
  66477. radius?: number;
  66478. radiusX?: number;
  66479. radiusY?: number;
  66480. radiusZ?: number;
  66481. flat?: boolean;
  66482. subdivisions?: number;
  66483. sideOrientation?: number;
  66484. frontUVs?: Vector4;
  66485. backUVs?: Vector4;
  66486. updatable?: boolean;
  66487. }, scene?: Nullable<Scene>): Mesh;
  66488. }
  66489. }
  66490. declare module BABYLON {
  66491. /**
  66492. * Class containing static functions to help procedurally build meshes
  66493. */
  66494. export class DecalBuilder {
  66495. /**
  66496. * Creates a decal mesh.
  66497. * 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
  66498. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66499. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66500. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66501. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66502. * @param name defines the name of the mesh
  66503. * @param sourceMesh defines the mesh where the decal must be applied
  66504. * @param options defines the options used to create the mesh
  66505. * @param scene defines the hosting scene
  66506. * @returns the decal mesh
  66507. * @see https://doc.babylonjs.com/how_to/decals
  66508. */
  66509. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66510. position?: Vector3;
  66511. normal?: Vector3;
  66512. size?: Vector3;
  66513. angle?: number;
  66514. }): Mesh;
  66515. }
  66516. }
  66517. declare module BABYLON {
  66518. /**
  66519. * Class containing static functions to help procedurally build meshes
  66520. */
  66521. export class MeshBuilder {
  66522. /**
  66523. * Creates a box mesh
  66524. * * The parameter `size` sets the size (float) of each box side (default 1)
  66525. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66526. * * 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)
  66527. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66529. * * 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
  66530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66531. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66532. * @param name defines the name of the mesh
  66533. * @param options defines the options used to create the mesh
  66534. * @param scene defines the hosting scene
  66535. * @returns the box mesh
  66536. */
  66537. static CreateBox(name: string, options: {
  66538. size?: number;
  66539. width?: number;
  66540. height?: number;
  66541. depth?: number;
  66542. faceUV?: Vector4[];
  66543. faceColors?: Color4[];
  66544. sideOrientation?: number;
  66545. frontUVs?: Vector4;
  66546. backUVs?: Vector4;
  66547. wrap?: boolean;
  66548. topBaseAt?: number;
  66549. bottomBaseAt?: number;
  66550. updatable?: boolean;
  66551. }, scene?: Nullable<Scene>): Mesh;
  66552. /**
  66553. * Creates a tiled box mesh
  66554. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66556. * @param name defines the name of the mesh
  66557. * @param options defines the options used to create the mesh
  66558. * @param scene defines the hosting scene
  66559. * @returns the tiled box mesh
  66560. */
  66561. static CreateTiledBox(name: string, options: {
  66562. pattern?: number;
  66563. size?: number;
  66564. width?: number;
  66565. height?: number;
  66566. depth: number;
  66567. tileSize?: number;
  66568. tileWidth?: number;
  66569. tileHeight?: number;
  66570. faceUV?: Vector4[];
  66571. faceColors?: Color4[];
  66572. alignHorizontal?: number;
  66573. alignVertical?: number;
  66574. sideOrientation?: number;
  66575. updatable?: boolean;
  66576. }, scene?: Nullable<Scene>): Mesh;
  66577. /**
  66578. * Creates a sphere mesh
  66579. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66580. * * 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`)
  66581. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66582. * * 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
  66583. * * 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)
  66584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66585. * * 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
  66586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66587. * @param name defines the name of the mesh
  66588. * @param options defines the options used to create the mesh
  66589. * @param scene defines the hosting scene
  66590. * @returns the sphere mesh
  66591. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66592. */
  66593. static CreateSphere(name: string, options: {
  66594. segments?: number;
  66595. diameter?: number;
  66596. diameterX?: number;
  66597. diameterY?: number;
  66598. diameterZ?: number;
  66599. arc?: number;
  66600. slice?: number;
  66601. sideOrientation?: number;
  66602. frontUVs?: Vector4;
  66603. backUVs?: Vector4;
  66604. updatable?: boolean;
  66605. }, scene?: Nullable<Scene>): Mesh;
  66606. /**
  66607. * Creates a plane polygonal mesh. By default, this is a disc
  66608. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66609. * * 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
  66610. * * 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
  66611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66612. * * 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
  66613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66614. * @param name defines the name of the mesh
  66615. * @param options defines the options used to create the mesh
  66616. * @param scene defines the hosting scene
  66617. * @returns the plane polygonal mesh
  66618. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66619. */
  66620. static CreateDisc(name: string, options: {
  66621. radius?: number;
  66622. tessellation?: number;
  66623. arc?: number;
  66624. updatable?: boolean;
  66625. sideOrientation?: number;
  66626. frontUVs?: Vector4;
  66627. backUVs?: Vector4;
  66628. }, scene?: Nullable<Scene>): Mesh;
  66629. /**
  66630. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66631. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66632. * * 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`)
  66633. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66634. * * 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
  66635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66636. * * 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
  66637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66638. * @param name defines the name of the mesh
  66639. * @param options defines the options used to create the mesh
  66640. * @param scene defines the hosting scene
  66641. * @returns the icosahedron mesh
  66642. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66643. */
  66644. static CreateIcoSphere(name: string, options: {
  66645. radius?: number;
  66646. radiusX?: number;
  66647. radiusY?: number;
  66648. radiusZ?: number;
  66649. flat?: boolean;
  66650. subdivisions?: number;
  66651. sideOrientation?: number;
  66652. frontUVs?: Vector4;
  66653. backUVs?: Vector4;
  66654. updatable?: boolean;
  66655. }, scene?: Nullable<Scene>): Mesh;
  66656. /**
  66657. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66658. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66659. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66660. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66661. * * 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
  66662. * * 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
  66663. * * 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
  66664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66665. * * 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
  66666. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66667. * * 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
  66668. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66669. * * 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
  66670. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66672. * @param name defines the name of the mesh
  66673. * @param options defines the options used to create the mesh
  66674. * @param scene defines the hosting scene
  66675. * @returns the ribbon mesh
  66676. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66677. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66678. */
  66679. static CreateRibbon(name: string, options: {
  66680. pathArray: Vector3[][];
  66681. closeArray?: boolean;
  66682. closePath?: boolean;
  66683. offset?: number;
  66684. updatable?: boolean;
  66685. sideOrientation?: number;
  66686. frontUVs?: Vector4;
  66687. backUVs?: Vector4;
  66688. instance?: Mesh;
  66689. invertUV?: boolean;
  66690. uvs?: Vector2[];
  66691. colors?: Color4[];
  66692. }, scene?: Nullable<Scene>): Mesh;
  66693. /**
  66694. * Creates a cylinder or a cone mesh
  66695. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66696. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66697. * * 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.
  66698. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66699. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66700. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66701. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66702. * * 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).
  66703. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66704. * * 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).
  66705. * * 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
  66706. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66707. * * 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
  66708. * * 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.
  66709. * * If `enclose` is false, a ring surface is one element.
  66710. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66711. * * 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
  66712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66713. * * 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
  66714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66715. * @param name defines the name of the mesh
  66716. * @param options defines the options used to create the mesh
  66717. * @param scene defines the hosting scene
  66718. * @returns the cylinder mesh
  66719. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66720. */
  66721. static CreateCylinder(name: string, options: {
  66722. height?: number;
  66723. diameterTop?: number;
  66724. diameterBottom?: number;
  66725. diameter?: number;
  66726. tessellation?: number;
  66727. subdivisions?: number;
  66728. arc?: number;
  66729. faceColors?: Color4[];
  66730. faceUV?: Vector4[];
  66731. updatable?: boolean;
  66732. hasRings?: boolean;
  66733. enclose?: boolean;
  66734. cap?: number;
  66735. sideOrientation?: number;
  66736. frontUVs?: Vector4;
  66737. backUVs?: Vector4;
  66738. }, scene?: Nullable<Scene>): Mesh;
  66739. /**
  66740. * Creates a torus mesh
  66741. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66742. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66743. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66745. * * 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
  66746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66747. * @param name defines the name of the mesh
  66748. * @param options defines the options used to create the mesh
  66749. * @param scene defines the hosting scene
  66750. * @returns the torus mesh
  66751. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66752. */
  66753. static CreateTorus(name: string, options: {
  66754. diameter?: number;
  66755. thickness?: number;
  66756. tessellation?: number;
  66757. updatable?: boolean;
  66758. sideOrientation?: number;
  66759. frontUVs?: Vector4;
  66760. backUVs?: Vector4;
  66761. }, scene?: Nullable<Scene>): Mesh;
  66762. /**
  66763. * Creates a torus knot mesh
  66764. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66765. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66766. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66767. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66769. * * 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
  66770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66771. * @param name defines the name of the mesh
  66772. * @param options defines the options used to create the mesh
  66773. * @param scene defines the hosting scene
  66774. * @returns the torus knot mesh
  66775. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66776. */
  66777. static CreateTorusKnot(name: string, options: {
  66778. radius?: number;
  66779. tube?: number;
  66780. radialSegments?: number;
  66781. tubularSegments?: number;
  66782. p?: number;
  66783. q?: number;
  66784. updatable?: boolean;
  66785. sideOrientation?: number;
  66786. frontUVs?: Vector4;
  66787. backUVs?: Vector4;
  66788. }, scene?: Nullable<Scene>): Mesh;
  66789. /**
  66790. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66791. * * 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
  66792. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66793. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66794. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66795. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66796. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66797. * * 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
  66798. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66801. * @param name defines the name of the new line system
  66802. * @param options defines the options used to create the line system
  66803. * @param scene defines the hosting scene
  66804. * @returns a new line system mesh
  66805. */
  66806. static CreateLineSystem(name: string, options: {
  66807. lines: Vector3[][];
  66808. updatable?: boolean;
  66809. instance?: Nullable<LinesMesh>;
  66810. colors?: Nullable<Color4[][]>;
  66811. useVertexAlpha?: boolean;
  66812. }, scene: Nullable<Scene>): LinesMesh;
  66813. /**
  66814. * Creates a line mesh
  66815. * 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
  66816. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66817. * * The parameter `points` is an array successive Vector3
  66818. * * 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
  66819. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66820. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66821. * * When updating an instance, remember that only point positions can change, not the number of points
  66822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66823. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66824. * @param name defines the name of the new line system
  66825. * @param options defines the options used to create the line system
  66826. * @param scene defines the hosting scene
  66827. * @returns a new line mesh
  66828. */
  66829. static CreateLines(name: string, options: {
  66830. points: Vector3[];
  66831. updatable?: boolean;
  66832. instance?: Nullable<LinesMesh>;
  66833. colors?: Color4[];
  66834. useVertexAlpha?: boolean;
  66835. }, scene?: Nullable<Scene>): LinesMesh;
  66836. /**
  66837. * Creates a dashed line mesh
  66838. * * 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
  66839. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66840. * * The parameter `points` is an array successive Vector3
  66841. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66842. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66843. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66844. * * 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
  66845. * * When updating an instance, remember that only point positions can change, not the number of points
  66846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66847. * @param name defines the name of the mesh
  66848. * @param options defines the options used to create the mesh
  66849. * @param scene defines the hosting scene
  66850. * @returns the dashed line mesh
  66851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66852. */
  66853. static CreateDashedLines(name: string, options: {
  66854. points: Vector3[];
  66855. dashSize?: number;
  66856. gapSize?: number;
  66857. dashNb?: number;
  66858. updatable?: boolean;
  66859. instance?: LinesMesh;
  66860. }, scene?: Nullable<Scene>): LinesMesh;
  66861. /**
  66862. * 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.
  66863. * * 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.
  66864. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66865. * * 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.
  66866. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66867. * * 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
  66868. * * 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
  66869. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66871. * * 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
  66872. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66874. * @param name defines the name of the mesh
  66875. * @param options defines the options used to create the mesh
  66876. * @param scene defines the hosting scene
  66877. * @returns the extruded shape mesh
  66878. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66880. */
  66881. static ExtrudeShape(name: string, options: {
  66882. shape: Vector3[];
  66883. path: Vector3[];
  66884. scale?: number;
  66885. rotation?: number;
  66886. cap?: number;
  66887. updatable?: boolean;
  66888. sideOrientation?: number;
  66889. frontUVs?: Vector4;
  66890. backUVs?: Vector4;
  66891. instance?: Mesh;
  66892. invertUV?: boolean;
  66893. }, scene?: Nullable<Scene>): Mesh;
  66894. /**
  66895. * Creates an custom extruded shape mesh.
  66896. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66897. * * 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.
  66898. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66899. * * 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
  66900. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66901. * * 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
  66902. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66903. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66904. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66905. * * 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
  66906. * * 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
  66907. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66909. * * 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
  66910. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66912. * @param name defines the name of the mesh
  66913. * @param options defines the options used to create the mesh
  66914. * @param scene defines the hosting scene
  66915. * @returns the custom extruded shape mesh
  66916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66917. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66919. */
  66920. static ExtrudeShapeCustom(name: string, options: {
  66921. shape: Vector3[];
  66922. path: Vector3[];
  66923. scaleFunction?: any;
  66924. rotationFunction?: any;
  66925. ribbonCloseArray?: boolean;
  66926. ribbonClosePath?: boolean;
  66927. cap?: number;
  66928. updatable?: boolean;
  66929. sideOrientation?: number;
  66930. frontUVs?: Vector4;
  66931. backUVs?: Vector4;
  66932. instance?: Mesh;
  66933. invertUV?: boolean;
  66934. }, scene?: Nullable<Scene>): Mesh;
  66935. /**
  66936. * Creates lathe mesh.
  66937. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66938. * * 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
  66939. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66940. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66941. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66942. * * 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
  66943. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66944. * * 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
  66945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66946. * * 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
  66947. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66949. * @param name defines the name of the mesh
  66950. * @param options defines the options used to create the mesh
  66951. * @param scene defines the hosting scene
  66952. * @returns the lathe mesh
  66953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66954. */
  66955. static CreateLathe(name: string, options: {
  66956. shape: Vector3[];
  66957. radius?: number;
  66958. tessellation?: number;
  66959. clip?: number;
  66960. arc?: number;
  66961. closed?: boolean;
  66962. updatable?: boolean;
  66963. sideOrientation?: number;
  66964. frontUVs?: Vector4;
  66965. backUVs?: Vector4;
  66966. cap?: number;
  66967. invertUV?: boolean;
  66968. }, scene?: Nullable<Scene>): Mesh;
  66969. /**
  66970. * Creates a tiled plane mesh
  66971. * * You can set a limited pattern arrangement with the tiles
  66972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66973. * * 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
  66974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66975. * @param name defines the name of the mesh
  66976. * @param options defines the options used to create the mesh
  66977. * @param scene defines the hosting scene
  66978. * @returns the plane mesh
  66979. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66980. */
  66981. static CreateTiledPlane(name: string, options: {
  66982. pattern?: number;
  66983. tileSize?: number;
  66984. tileWidth?: number;
  66985. tileHeight?: number;
  66986. size?: number;
  66987. width?: number;
  66988. height?: number;
  66989. alignHorizontal?: number;
  66990. alignVertical?: number;
  66991. sideOrientation?: number;
  66992. frontUVs?: Vector4;
  66993. backUVs?: Vector4;
  66994. updatable?: boolean;
  66995. }, scene?: Nullable<Scene>): Mesh;
  66996. /**
  66997. * Creates a plane mesh
  66998. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66999. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67000. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67002. * * 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
  67003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67004. * @param name defines the name of the mesh
  67005. * @param options defines the options used to create the mesh
  67006. * @param scene defines the hosting scene
  67007. * @returns the plane mesh
  67008. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67009. */
  67010. static CreatePlane(name: string, options: {
  67011. size?: number;
  67012. width?: number;
  67013. height?: number;
  67014. sideOrientation?: number;
  67015. frontUVs?: Vector4;
  67016. backUVs?: Vector4;
  67017. updatable?: boolean;
  67018. sourcePlane?: Plane;
  67019. }, scene?: Nullable<Scene>): Mesh;
  67020. /**
  67021. * Creates a ground mesh
  67022. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67023. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67025. * @param name defines the name of the mesh
  67026. * @param options defines the options used to create the mesh
  67027. * @param scene defines the hosting scene
  67028. * @returns the ground mesh
  67029. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67030. */
  67031. static CreateGround(name: string, options: {
  67032. width?: number;
  67033. height?: number;
  67034. subdivisions?: number;
  67035. subdivisionsX?: number;
  67036. subdivisionsY?: number;
  67037. updatable?: boolean;
  67038. }, scene?: Nullable<Scene>): Mesh;
  67039. /**
  67040. * Creates a tiled ground mesh
  67041. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67042. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67043. * * 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
  67044. * * 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
  67045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67046. * @param name defines the name of the mesh
  67047. * @param options defines the options used to create the mesh
  67048. * @param scene defines the hosting scene
  67049. * @returns the tiled ground mesh
  67050. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67051. */
  67052. static CreateTiledGround(name: string, options: {
  67053. xmin: number;
  67054. zmin: number;
  67055. xmax: number;
  67056. zmax: number;
  67057. subdivisions?: {
  67058. w: number;
  67059. h: number;
  67060. };
  67061. precision?: {
  67062. w: number;
  67063. h: number;
  67064. };
  67065. updatable?: boolean;
  67066. }, scene?: Nullable<Scene>): Mesh;
  67067. /**
  67068. * Creates a ground mesh from a height map
  67069. * * The parameter `url` sets the URL of the height map image resource.
  67070. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67071. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67072. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67073. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67074. * * 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.
  67075. * * 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).
  67076. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67078. * @param name defines the name of the mesh
  67079. * @param url defines the url to the height map
  67080. * @param options defines the options used to create the mesh
  67081. * @param scene defines the hosting scene
  67082. * @returns the ground mesh
  67083. * @see https://doc.babylonjs.com/babylon101/height_map
  67084. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67085. */
  67086. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67087. width?: number;
  67088. height?: number;
  67089. subdivisions?: number;
  67090. minHeight?: number;
  67091. maxHeight?: number;
  67092. colorFilter?: Color3;
  67093. alphaFilter?: number;
  67094. updatable?: boolean;
  67095. onReady?: (mesh: GroundMesh) => void;
  67096. }, scene?: Nullable<Scene>): GroundMesh;
  67097. /**
  67098. * Creates a polygon mesh
  67099. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67100. * * 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
  67101. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67103. * * 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)
  67104. * * Remember you can only change the shape positions, not their number when updating a polygon
  67105. * @param name defines the name of the mesh
  67106. * @param options defines the options used to create the mesh
  67107. * @param scene defines the hosting scene
  67108. * @param earcutInjection can be used to inject your own earcut reference
  67109. * @returns the polygon mesh
  67110. */
  67111. static CreatePolygon(name: string, options: {
  67112. shape: Vector3[];
  67113. holes?: Vector3[][];
  67114. depth?: number;
  67115. faceUV?: Vector4[];
  67116. faceColors?: Color4[];
  67117. updatable?: boolean;
  67118. sideOrientation?: number;
  67119. frontUVs?: Vector4;
  67120. backUVs?: Vector4;
  67121. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67122. /**
  67123. * Creates an extruded polygon mesh, with depth in the Y direction.
  67124. * * 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)
  67125. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67126. * @param name defines the name of the mesh
  67127. * @param options defines the options used to create the mesh
  67128. * @param scene defines the hosting scene
  67129. * @param earcutInjection can be used to inject your own earcut reference
  67130. * @returns the polygon mesh
  67131. */
  67132. static ExtrudePolygon(name: string, options: {
  67133. shape: Vector3[];
  67134. holes?: Vector3[][];
  67135. depth?: number;
  67136. faceUV?: Vector4[];
  67137. faceColors?: Color4[];
  67138. updatable?: boolean;
  67139. sideOrientation?: number;
  67140. frontUVs?: Vector4;
  67141. backUVs?: Vector4;
  67142. wrap?: boolean;
  67143. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67144. /**
  67145. * Creates a tube mesh.
  67146. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67147. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67148. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67149. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67150. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67151. * * 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)
  67152. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67153. * * 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
  67154. * * 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
  67155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67156. * * 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
  67157. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67159. * @param name defines the name of the mesh
  67160. * @param options defines the options used to create the mesh
  67161. * @param scene defines the hosting scene
  67162. * @returns the tube mesh
  67163. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67164. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67165. */
  67166. static CreateTube(name: string, options: {
  67167. path: Vector3[];
  67168. radius?: number;
  67169. tessellation?: number;
  67170. radiusFunction?: {
  67171. (i: number, distance: number): number;
  67172. };
  67173. cap?: number;
  67174. arc?: number;
  67175. updatable?: boolean;
  67176. sideOrientation?: number;
  67177. frontUVs?: Vector4;
  67178. backUVs?: Vector4;
  67179. instance?: Mesh;
  67180. invertUV?: boolean;
  67181. }, scene?: Nullable<Scene>): Mesh;
  67182. /**
  67183. * Creates a polyhedron mesh
  67184. * * 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
  67185. * * The parameter `size` (positive float, default 1) sets the polygon size
  67186. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67187. * * 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`
  67188. * * 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
  67189. * * 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)`)
  67190. * * 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
  67191. * * 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
  67192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67193. * * 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
  67194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67195. * @param name defines the name of the mesh
  67196. * @param options defines the options used to create the mesh
  67197. * @param scene defines the hosting scene
  67198. * @returns the polyhedron mesh
  67199. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67200. */
  67201. static CreatePolyhedron(name: string, options: {
  67202. type?: number;
  67203. size?: number;
  67204. sizeX?: number;
  67205. sizeY?: number;
  67206. sizeZ?: number;
  67207. custom?: any;
  67208. faceUV?: Vector4[];
  67209. faceColors?: Color4[];
  67210. flat?: boolean;
  67211. updatable?: boolean;
  67212. sideOrientation?: number;
  67213. frontUVs?: Vector4;
  67214. backUVs?: Vector4;
  67215. }, scene?: Nullable<Scene>): Mesh;
  67216. /**
  67217. * Creates a decal mesh.
  67218. * 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
  67219. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67220. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67221. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67222. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67223. * @param name defines the name of the mesh
  67224. * @param sourceMesh defines the mesh where the decal must be applied
  67225. * @param options defines the options used to create the mesh
  67226. * @param scene defines the hosting scene
  67227. * @returns the decal mesh
  67228. * @see https://doc.babylonjs.com/how_to/decals
  67229. */
  67230. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67231. position?: Vector3;
  67232. normal?: Vector3;
  67233. size?: Vector3;
  67234. angle?: number;
  67235. }): Mesh;
  67236. /**
  67237. * Creates a Capsule Mesh
  67238. * @param name defines the name of the mesh.
  67239. * @param options the constructors options used to shape the mesh.
  67240. * @param scene defines the scene the mesh is scoped to.
  67241. * @returns the capsule mesh
  67242. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67243. */
  67244. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67245. }
  67246. }
  67247. declare module BABYLON {
  67248. /**
  67249. * A simplifier interface for future simplification implementations
  67250. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67251. */
  67252. export interface ISimplifier {
  67253. /**
  67254. * Simplification of a given mesh according to the given settings.
  67255. * Since this requires computation, it is assumed that the function runs async.
  67256. * @param settings The settings of the simplification, including quality and distance
  67257. * @param successCallback A callback that will be called after the mesh was simplified.
  67258. * @param errorCallback in case of an error, this callback will be called. optional.
  67259. */
  67260. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67261. }
  67262. /**
  67263. * Expected simplification settings.
  67264. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67265. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67266. */
  67267. export interface ISimplificationSettings {
  67268. /**
  67269. * Gets or sets the expected quality
  67270. */
  67271. quality: number;
  67272. /**
  67273. * Gets or sets the distance when this optimized version should be used
  67274. */
  67275. distance: number;
  67276. /**
  67277. * Gets an already optimized mesh
  67278. */
  67279. optimizeMesh?: boolean;
  67280. }
  67281. /**
  67282. * Class used to specify simplification options
  67283. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67284. */
  67285. export class SimplificationSettings implements ISimplificationSettings {
  67286. /** expected quality */
  67287. quality: number;
  67288. /** distance when this optimized version should be used */
  67289. distance: number;
  67290. /** already optimized mesh */
  67291. optimizeMesh?: boolean | undefined;
  67292. /**
  67293. * Creates a SimplificationSettings
  67294. * @param quality expected quality
  67295. * @param distance distance when this optimized version should be used
  67296. * @param optimizeMesh already optimized mesh
  67297. */
  67298. constructor(
  67299. /** expected quality */
  67300. quality: number,
  67301. /** distance when this optimized version should be used */
  67302. distance: number,
  67303. /** already optimized mesh */
  67304. optimizeMesh?: boolean | undefined);
  67305. }
  67306. /**
  67307. * Interface used to define a simplification task
  67308. */
  67309. export interface ISimplificationTask {
  67310. /**
  67311. * Array of settings
  67312. */
  67313. settings: Array<ISimplificationSettings>;
  67314. /**
  67315. * Simplification type
  67316. */
  67317. simplificationType: SimplificationType;
  67318. /**
  67319. * Mesh to simplify
  67320. */
  67321. mesh: Mesh;
  67322. /**
  67323. * Callback called on success
  67324. */
  67325. successCallback?: () => void;
  67326. /**
  67327. * Defines if parallel processing can be used
  67328. */
  67329. parallelProcessing: boolean;
  67330. }
  67331. /**
  67332. * Queue used to order the simplification tasks
  67333. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67334. */
  67335. export class SimplificationQueue {
  67336. private _simplificationArray;
  67337. /**
  67338. * Gets a boolean indicating that the process is still running
  67339. */
  67340. running: boolean;
  67341. /**
  67342. * Creates a new queue
  67343. */
  67344. constructor();
  67345. /**
  67346. * Adds a new simplification task
  67347. * @param task defines a task to add
  67348. */
  67349. addTask(task: ISimplificationTask): void;
  67350. /**
  67351. * Execute next task
  67352. */
  67353. executeNext(): void;
  67354. /**
  67355. * Execute a simplification task
  67356. * @param task defines the task to run
  67357. */
  67358. runSimplification(task: ISimplificationTask): void;
  67359. private getSimplifier;
  67360. }
  67361. /**
  67362. * The implemented types of simplification
  67363. * At the moment only Quadratic Error Decimation is implemented
  67364. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67365. */
  67366. export enum SimplificationType {
  67367. /** Quadratic error decimation */
  67368. QUADRATIC = 0
  67369. }
  67370. /**
  67371. * An implementation of the Quadratic Error simplification algorithm.
  67372. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67373. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67374. * @author RaananW
  67375. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67376. */
  67377. export class QuadraticErrorSimplification implements ISimplifier {
  67378. private _mesh;
  67379. private triangles;
  67380. private vertices;
  67381. private references;
  67382. private _reconstructedMesh;
  67383. /** Gets or sets the number pf sync interations */
  67384. syncIterations: number;
  67385. /** Gets or sets the aggressiveness of the simplifier */
  67386. aggressiveness: number;
  67387. /** Gets or sets the number of allowed iterations for decimation */
  67388. decimationIterations: number;
  67389. /** Gets or sets the espilon to use for bounding box computation */
  67390. boundingBoxEpsilon: number;
  67391. /**
  67392. * Creates a new QuadraticErrorSimplification
  67393. * @param _mesh defines the target mesh
  67394. */
  67395. constructor(_mesh: Mesh);
  67396. /**
  67397. * Simplification of a given mesh according to the given settings.
  67398. * Since this requires computation, it is assumed that the function runs async.
  67399. * @param settings The settings of the simplification, including quality and distance
  67400. * @param successCallback A callback that will be called after the mesh was simplified.
  67401. */
  67402. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67403. private runDecimation;
  67404. private initWithMesh;
  67405. private init;
  67406. private reconstructMesh;
  67407. private initDecimatedMesh;
  67408. private isFlipped;
  67409. private updateTriangles;
  67410. private identifyBorder;
  67411. private updateMesh;
  67412. private vertexError;
  67413. private calculateError;
  67414. }
  67415. }
  67416. declare module BABYLON {
  67417. interface Scene {
  67418. /** @hidden (Backing field) */
  67419. _simplificationQueue: SimplificationQueue;
  67420. /**
  67421. * Gets or sets the simplification queue attached to the scene
  67422. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67423. */
  67424. simplificationQueue: SimplificationQueue;
  67425. }
  67426. interface Mesh {
  67427. /**
  67428. * Simplify the mesh according to the given array of settings.
  67429. * Function will return immediately and will simplify async
  67430. * @param settings a collection of simplification settings
  67431. * @param parallelProcessing should all levels calculate parallel or one after the other
  67432. * @param simplificationType the type of simplification to run
  67433. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67434. * @returns the current mesh
  67435. */
  67436. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67437. }
  67438. /**
  67439. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67440. * created in a scene
  67441. */
  67442. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67443. /**
  67444. * The component name helpfull to identify the component in the list of scene components.
  67445. */
  67446. readonly name: string;
  67447. /**
  67448. * The scene the component belongs to.
  67449. */
  67450. scene: Scene;
  67451. /**
  67452. * Creates a new instance of the component for the given scene
  67453. * @param scene Defines the scene to register the component in
  67454. */
  67455. constructor(scene: Scene);
  67456. /**
  67457. * Registers the component in a given scene
  67458. */
  67459. register(): void;
  67460. /**
  67461. * Rebuilds the elements related to this component in case of
  67462. * context lost for instance.
  67463. */
  67464. rebuild(): void;
  67465. /**
  67466. * Disposes the component and the associated ressources
  67467. */
  67468. dispose(): void;
  67469. private _beforeCameraUpdate;
  67470. }
  67471. }
  67472. declare module BABYLON {
  67473. interface Mesh {
  67474. /**
  67475. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67476. */
  67477. thinInstanceEnablePicking: boolean;
  67478. /**
  67479. * Creates a new thin instance
  67480. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67481. * @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
  67482. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67483. */
  67484. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67485. /**
  67486. * Adds the transformation (matrix) of the current mesh as a thin instance
  67487. * @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
  67488. * @returns the thin instance index number
  67489. */
  67490. thinInstanceAddSelf(refresh: boolean): number;
  67491. /**
  67492. * Registers a custom attribute to be used with thin instances
  67493. * @param kind name of the attribute
  67494. * @param stride size in floats of the attribute
  67495. */
  67496. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67497. /**
  67498. * Sets the matrix of a thin instance
  67499. * @param index index of the thin instance
  67500. * @param matrix matrix to set
  67501. * @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
  67502. */
  67503. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67504. /**
  67505. * Sets the value of a custom attribute for a thin instance
  67506. * @param kind name of the attribute
  67507. * @param index index of the thin instance
  67508. * @param value value to set
  67509. * @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
  67510. */
  67511. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67512. /**
  67513. * 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.
  67514. */
  67515. thinInstanceCount: number;
  67516. /**
  67517. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67518. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67519. * @param buffer buffer to set
  67520. * @param stride size in floats of each value of the buffer
  67521. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67522. */
  67523. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67524. /**
  67525. * Gets the list of world matrices
  67526. * @return an array containing all the world matrices from the thin instances
  67527. */
  67528. thinInstanceGetWorldMatrices(): Matrix[];
  67529. /**
  67530. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67531. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67532. */
  67533. thinInstanceBufferUpdated(kind: string): void;
  67534. /**
  67535. * Applies a partial update to a buffer directly on the GPU
  67536. * 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
  67537. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67538. * @param data the data to set in the GPU buffer
  67539. * @param offset the offset in the GPU buffer where to update the data
  67540. */
  67541. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67542. /**
  67543. * Refreshes the bounding info, taking into account all the thin instances defined
  67544. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67545. */
  67546. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67547. /** @hidden */
  67548. _thinInstanceInitializeUserStorage(): void;
  67549. /** @hidden */
  67550. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67551. /** @hidden */
  67552. _userThinInstanceBuffersStorage: {
  67553. data: {
  67554. [key: string]: Float32Array;
  67555. };
  67556. sizes: {
  67557. [key: string]: number;
  67558. };
  67559. vertexBuffers: {
  67560. [key: string]: Nullable<VertexBuffer>;
  67561. };
  67562. strides: {
  67563. [key: string]: number;
  67564. };
  67565. };
  67566. }
  67567. }
  67568. declare module BABYLON {
  67569. /**
  67570. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67571. */
  67572. export interface INavigationEnginePlugin {
  67573. /**
  67574. * plugin name
  67575. */
  67576. name: string;
  67577. /**
  67578. * Creates a navigation mesh
  67579. * @param meshes array of all the geometry used to compute the navigatio mesh
  67580. * @param parameters bunch of parameters used to filter geometry
  67581. */
  67582. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67583. /**
  67584. * Create a navigation mesh debug mesh
  67585. * @param scene is where the mesh will be added
  67586. * @returns debug display mesh
  67587. */
  67588. createDebugNavMesh(scene: Scene): Mesh;
  67589. /**
  67590. * Get a navigation mesh constrained position, closest to the parameter position
  67591. * @param position world position
  67592. * @returns the closest point to position constrained by the navigation mesh
  67593. */
  67594. getClosestPoint(position: Vector3): Vector3;
  67595. /**
  67596. * Get a navigation mesh constrained position, closest to the parameter position
  67597. * @param position world position
  67598. * @param result output the closest point to position constrained by the navigation mesh
  67599. */
  67600. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67601. /**
  67602. * Get a navigation mesh constrained position, within a particular radius
  67603. * @param position world position
  67604. * @param maxRadius the maximum distance to the constrained world position
  67605. * @returns the closest point to position constrained by the navigation mesh
  67606. */
  67607. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67608. /**
  67609. * Get a navigation mesh constrained position, within a particular radius
  67610. * @param position world position
  67611. * @param maxRadius the maximum distance to the constrained world position
  67612. * @param result output the closest point to position constrained by the navigation mesh
  67613. */
  67614. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67615. /**
  67616. * Compute the final position from a segment made of destination-position
  67617. * @param position world position
  67618. * @param destination world position
  67619. * @returns the resulting point along the navmesh
  67620. */
  67621. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67622. /**
  67623. * Compute the final position from a segment made of destination-position
  67624. * @param position world position
  67625. * @param destination world position
  67626. * @param result output the resulting point along the navmesh
  67627. */
  67628. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67629. /**
  67630. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67631. * @param start world position
  67632. * @param end world position
  67633. * @returns array containing world position composing the path
  67634. */
  67635. computePath(start: Vector3, end: Vector3): Vector3[];
  67636. /**
  67637. * If this plugin is supported
  67638. * @returns true if plugin is supported
  67639. */
  67640. isSupported(): boolean;
  67641. /**
  67642. * Create a new Crowd so you can add agents
  67643. * @param maxAgents the maximum agent count in the crowd
  67644. * @param maxAgentRadius the maximum radius an agent can have
  67645. * @param scene to attach the crowd to
  67646. * @returns the crowd you can add agents to
  67647. */
  67648. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67649. /**
  67650. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67651. * The queries will try to find a solution within those bounds
  67652. * default is (1,1,1)
  67653. * @param extent x,y,z value that define the extent around the queries point of reference
  67654. */
  67655. setDefaultQueryExtent(extent: Vector3): void;
  67656. /**
  67657. * Get the Bounding box extent specified by setDefaultQueryExtent
  67658. * @returns the box extent values
  67659. */
  67660. getDefaultQueryExtent(): Vector3;
  67661. /**
  67662. * build the navmesh from a previously saved state using getNavmeshData
  67663. * @param data the Uint8Array returned by getNavmeshData
  67664. */
  67665. buildFromNavmeshData(data: Uint8Array): void;
  67666. /**
  67667. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67668. * @returns data the Uint8Array that can be saved and reused
  67669. */
  67670. getNavmeshData(): Uint8Array;
  67671. /**
  67672. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67673. * @param result output the box extent values
  67674. */
  67675. getDefaultQueryExtentToRef(result: Vector3): void;
  67676. /**
  67677. * Release all resources
  67678. */
  67679. dispose(): void;
  67680. }
  67681. /**
  67682. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67683. */
  67684. export interface ICrowd {
  67685. /**
  67686. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67687. * You can attach anything to that node. The node position is updated in the scene update tick.
  67688. * @param pos world position that will be constrained by the navigation mesh
  67689. * @param parameters agent parameters
  67690. * @param transform hooked to the agent that will be update by the scene
  67691. * @returns agent index
  67692. */
  67693. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67694. /**
  67695. * Returns the agent position in world space
  67696. * @param index agent index returned by addAgent
  67697. * @returns world space position
  67698. */
  67699. getAgentPosition(index: number): Vector3;
  67700. /**
  67701. * Gets the agent position result in world space
  67702. * @param index agent index returned by addAgent
  67703. * @param result output world space position
  67704. */
  67705. getAgentPositionToRef(index: number, result: Vector3): void;
  67706. /**
  67707. * Gets the agent velocity in world space
  67708. * @param index agent index returned by addAgent
  67709. * @returns world space velocity
  67710. */
  67711. getAgentVelocity(index: number): Vector3;
  67712. /**
  67713. * Gets the agent velocity result in world space
  67714. * @param index agent index returned by addAgent
  67715. * @param result output world space velocity
  67716. */
  67717. getAgentVelocityToRef(index: number, result: Vector3): void;
  67718. /**
  67719. * remove a particular agent previously created
  67720. * @param index agent index returned by addAgent
  67721. */
  67722. removeAgent(index: number): void;
  67723. /**
  67724. * get the list of all agents attached to this crowd
  67725. * @returns list of agent indices
  67726. */
  67727. getAgents(): number[];
  67728. /**
  67729. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67730. * @param deltaTime in seconds
  67731. */
  67732. update(deltaTime: number): void;
  67733. /**
  67734. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67735. * @param index agent index returned by addAgent
  67736. * @param destination targeted world position
  67737. */
  67738. agentGoto(index: number, destination: Vector3): void;
  67739. /**
  67740. * Teleport the agent to a new position
  67741. * @param index agent index returned by addAgent
  67742. * @param destination targeted world position
  67743. */
  67744. agentTeleport(index: number, destination: Vector3): void;
  67745. /**
  67746. * Update agent parameters
  67747. * @param index agent index returned by addAgent
  67748. * @param parameters agent parameters
  67749. */
  67750. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67751. /**
  67752. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67753. * The queries will try to find a solution within those bounds
  67754. * default is (1,1,1)
  67755. * @param extent x,y,z value that define the extent around the queries point of reference
  67756. */
  67757. setDefaultQueryExtent(extent: Vector3): void;
  67758. /**
  67759. * Get the Bounding box extent specified by setDefaultQueryExtent
  67760. * @returns the box extent values
  67761. */
  67762. getDefaultQueryExtent(): Vector3;
  67763. /**
  67764. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67765. * @param result output the box extent values
  67766. */
  67767. getDefaultQueryExtentToRef(result: Vector3): void;
  67768. /**
  67769. * Release all resources
  67770. */
  67771. dispose(): void;
  67772. }
  67773. /**
  67774. * Configures an agent
  67775. */
  67776. export interface IAgentParameters {
  67777. /**
  67778. * Agent radius. [Limit: >= 0]
  67779. */
  67780. radius: number;
  67781. /**
  67782. * Agent height. [Limit: > 0]
  67783. */
  67784. height: number;
  67785. /**
  67786. * Maximum allowed acceleration. [Limit: >= 0]
  67787. */
  67788. maxAcceleration: number;
  67789. /**
  67790. * Maximum allowed speed. [Limit: >= 0]
  67791. */
  67792. maxSpeed: number;
  67793. /**
  67794. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67795. */
  67796. collisionQueryRange: number;
  67797. /**
  67798. * The path visibility optimization range. [Limit: > 0]
  67799. */
  67800. pathOptimizationRange: number;
  67801. /**
  67802. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67803. */
  67804. separationWeight: number;
  67805. }
  67806. /**
  67807. * Configures the navigation mesh creation
  67808. */
  67809. export interface INavMeshParameters {
  67810. /**
  67811. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67812. */
  67813. cs: number;
  67814. /**
  67815. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67816. */
  67817. ch: number;
  67818. /**
  67819. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67820. */
  67821. walkableSlopeAngle: number;
  67822. /**
  67823. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67824. * be considered walkable. [Limit: >= 3] [Units: vx]
  67825. */
  67826. walkableHeight: number;
  67827. /**
  67828. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67829. */
  67830. walkableClimb: number;
  67831. /**
  67832. * The distance to erode/shrink the walkable area of the heightfield away from
  67833. * obstructions. [Limit: >=0] [Units: vx]
  67834. */
  67835. walkableRadius: number;
  67836. /**
  67837. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67838. */
  67839. maxEdgeLen: number;
  67840. /**
  67841. * The maximum distance a simplfied contour's border edges should deviate
  67842. * the original raw contour. [Limit: >=0] [Units: vx]
  67843. */
  67844. maxSimplificationError: number;
  67845. /**
  67846. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67847. */
  67848. minRegionArea: number;
  67849. /**
  67850. * Any regions with a span count smaller than this value will, if possible,
  67851. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67852. */
  67853. mergeRegionArea: number;
  67854. /**
  67855. * The maximum number of vertices allowed for polygons generated during the
  67856. * contour to polygon conversion process. [Limit: >= 3]
  67857. */
  67858. maxVertsPerPoly: number;
  67859. /**
  67860. * Sets the sampling distance to use when generating the detail mesh.
  67861. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67862. */
  67863. detailSampleDist: number;
  67864. /**
  67865. * The maximum distance the detail mesh surface should deviate from heightfield
  67866. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67867. */
  67868. detailSampleMaxError: number;
  67869. }
  67870. }
  67871. declare module BABYLON {
  67872. /**
  67873. * RecastJS navigation plugin
  67874. */
  67875. export class RecastJSPlugin implements INavigationEnginePlugin {
  67876. /**
  67877. * Reference to the Recast library
  67878. */
  67879. bjsRECAST: any;
  67880. /**
  67881. * plugin name
  67882. */
  67883. name: string;
  67884. /**
  67885. * the first navmesh created. We might extend this to support multiple navmeshes
  67886. */
  67887. navMesh: any;
  67888. /**
  67889. * Initializes the recastJS plugin
  67890. * @param recastInjection can be used to inject your own recast reference
  67891. */
  67892. constructor(recastInjection?: any);
  67893. /**
  67894. * Creates a navigation mesh
  67895. * @param meshes array of all the geometry used to compute the navigatio mesh
  67896. * @param parameters bunch of parameters used to filter geometry
  67897. */
  67898. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67899. /**
  67900. * Create a navigation mesh debug mesh
  67901. * @param scene is where the mesh will be added
  67902. * @returns debug display mesh
  67903. */
  67904. createDebugNavMesh(scene: Scene): Mesh;
  67905. /**
  67906. * Get a navigation mesh constrained position, closest to the parameter position
  67907. * @param position world position
  67908. * @returns the closest point to position constrained by the navigation mesh
  67909. */
  67910. getClosestPoint(position: Vector3): Vector3;
  67911. /**
  67912. * Get a navigation mesh constrained position, closest to the parameter position
  67913. * @param position world position
  67914. * @param result output the closest point to position constrained by the navigation mesh
  67915. */
  67916. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67917. /**
  67918. * Get a navigation mesh constrained position, within a particular radius
  67919. * @param position world position
  67920. * @param maxRadius the maximum distance to the constrained world position
  67921. * @returns the closest point to position constrained by the navigation mesh
  67922. */
  67923. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67924. /**
  67925. * Get a navigation mesh constrained position, within a particular radius
  67926. * @param position world position
  67927. * @param maxRadius the maximum distance to the constrained world position
  67928. * @param result output the closest point to position constrained by the navigation mesh
  67929. */
  67930. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67931. /**
  67932. * Compute the final position from a segment made of destination-position
  67933. * @param position world position
  67934. * @param destination world position
  67935. * @returns the resulting point along the navmesh
  67936. */
  67937. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67938. /**
  67939. * Compute the final position from a segment made of destination-position
  67940. * @param position world position
  67941. * @param destination world position
  67942. * @param result output the resulting point along the navmesh
  67943. */
  67944. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67945. /**
  67946. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67947. * @param start world position
  67948. * @param end world position
  67949. * @returns array containing world position composing the path
  67950. */
  67951. computePath(start: Vector3, end: Vector3): Vector3[];
  67952. /**
  67953. * Create a new Crowd so you can add agents
  67954. * @param maxAgents the maximum agent count in the crowd
  67955. * @param maxAgentRadius the maximum radius an agent can have
  67956. * @param scene to attach the crowd to
  67957. * @returns the crowd you can add agents to
  67958. */
  67959. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67960. /**
  67961. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67962. * The queries will try to find a solution within those bounds
  67963. * default is (1,1,1)
  67964. * @param extent x,y,z value that define the extent around the queries point of reference
  67965. */
  67966. setDefaultQueryExtent(extent: Vector3): void;
  67967. /**
  67968. * Get the Bounding box extent specified by setDefaultQueryExtent
  67969. * @returns the box extent values
  67970. */
  67971. getDefaultQueryExtent(): Vector3;
  67972. /**
  67973. * build the navmesh from a previously saved state using getNavmeshData
  67974. * @param data the Uint8Array returned by getNavmeshData
  67975. */
  67976. buildFromNavmeshData(data: Uint8Array): void;
  67977. /**
  67978. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67979. * @returns data the Uint8Array that can be saved and reused
  67980. */
  67981. getNavmeshData(): Uint8Array;
  67982. /**
  67983. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67984. * @param result output the box extent values
  67985. */
  67986. getDefaultQueryExtentToRef(result: Vector3): void;
  67987. /**
  67988. * Disposes
  67989. */
  67990. dispose(): void;
  67991. /**
  67992. * If this plugin is supported
  67993. * @returns true if plugin is supported
  67994. */
  67995. isSupported(): boolean;
  67996. }
  67997. /**
  67998. * Recast detour crowd implementation
  67999. */
  68000. export class RecastJSCrowd implements ICrowd {
  68001. /**
  68002. * Recast/detour plugin
  68003. */
  68004. bjsRECASTPlugin: RecastJSPlugin;
  68005. /**
  68006. * Link to the detour crowd
  68007. */
  68008. recastCrowd: any;
  68009. /**
  68010. * One transform per agent
  68011. */
  68012. transforms: TransformNode[];
  68013. /**
  68014. * All agents created
  68015. */
  68016. agents: number[];
  68017. /**
  68018. * Link to the scene is kept to unregister the crowd from the scene
  68019. */
  68020. private _scene;
  68021. /**
  68022. * Observer for crowd updates
  68023. */
  68024. private _onBeforeAnimationsObserver;
  68025. /**
  68026. * Constructor
  68027. * @param plugin recastJS plugin
  68028. * @param maxAgents the maximum agent count in the crowd
  68029. * @param maxAgentRadius the maximum radius an agent can have
  68030. * @param scene to attach the crowd to
  68031. * @returns the crowd you can add agents to
  68032. */
  68033. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68034. /**
  68035. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68036. * You can attach anything to that node. The node position is updated in the scene update tick.
  68037. * @param pos world position that will be constrained by the navigation mesh
  68038. * @param parameters agent parameters
  68039. * @param transform hooked to the agent that will be update by the scene
  68040. * @returns agent index
  68041. */
  68042. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68043. /**
  68044. * Returns the agent position in world space
  68045. * @param index agent index returned by addAgent
  68046. * @returns world space position
  68047. */
  68048. getAgentPosition(index: number): Vector3;
  68049. /**
  68050. * Returns the agent position result in world space
  68051. * @param index agent index returned by addAgent
  68052. * @param result output world space position
  68053. */
  68054. getAgentPositionToRef(index: number, result: Vector3): void;
  68055. /**
  68056. * Returns the agent velocity in world space
  68057. * @param index agent index returned by addAgent
  68058. * @returns world space velocity
  68059. */
  68060. getAgentVelocity(index: number): Vector3;
  68061. /**
  68062. * Returns the agent velocity result in world space
  68063. * @param index agent index returned by addAgent
  68064. * @param result output world space velocity
  68065. */
  68066. getAgentVelocityToRef(index: number, result: Vector3): void;
  68067. /**
  68068. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68069. * @param index agent index returned by addAgent
  68070. * @param destination targeted world position
  68071. */
  68072. agentGoto(index: number, destination: Vector3): void;
  68073. /**
  68074. * Teleport the agent to a new position
  68075. * @param index agent index returned by addAgent
  68076. * @param destination targeted world position
  68077. */
  68078. agentTeleport(index: number, destination: Vector3): void;
  68079. /**
  68080. * Update agent parameters
  68081. * @param index agent index returned by addAgent
  68082. * @param parameters agent parameters
  68083. */
  68084. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68085. /**
  68086. * remove a particular agent previously created
  68087. * @param index agent index returned by addAgent
  68088. */
  68089. removeAgent(index: number): void;
  68090. /**
  68091. * get the list of all agents attached to this crowd
  68092. * @returns list of agent indices
  68093. */
  68094. getAgents(): number[];
  68095. /**
  68096. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68097. * @param deltaTime in seconds
  68098. */
  68099. update(deltaTime: number): void;
  68100. /**
  68101. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68102. * The queries will try to find a solution within those bounds
  68103. * default is (1,1,1)
  68104. * @param extent x,y,z value that define the extent around the queries point of reference
  68105. */
  68106. setDefaultQueryExtent(extent: Vector3): void;
  68107. /**
  68108. * Get the Bounding box extent specified by setDefaultQueryExtent
  68109. * @returns the box extent values
  68110. */
  68111. getDefaultQueryExtent(): Vector3;
  68112. /**
  68113. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68114. * @param result output the box extent values
  68115. */
  68116. getDefaultQueryExtentToRef(result: Vector3): void;
  68117. /**
  68118. * Release all resources
  68119. */
  68120. dispose(): void;
  68121. }
  68122. }
  68123. declare module BABYLON {
  68124. /**
  68125. * Class used to enable access to IndexedDB
  68126. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68127. */
  68128. export class Database implements IOfflineProvider {
  68129. private _callbackManifestChecked;
  68130. private _currentSceneUrl;
  68131. private _db;
  68132. private _enableSceneOffline;
  68133. private _enableTexturesOffline;
  68134. private _manifestVersionFound;
  68135. private _mustUpdateRessources;
  68136. private _hasReachedQuota;
  68137. private _isSupported;
  68138. private _idbFactory;
  68139. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68140. private static IsUASupportingBlobStorage;
  68141. /**
  68142. * Gets a boolean indicating if Database storate is enabled (off by default)
  68143. */
  68144. static IDBStorageEnabled: boolean;
  68145. /**
  68146. * Gets a boolean indicating if scene must be saved in the database
  68147. */
  68148. get enableSceneOffline(): boolean;
  68149. /**
  68150. * Gets a boolean indicating if textures must be saved in the database
  68151. */
  68152. get enableTexturesOffline(): boolean;
  68153. /**
  68154. * Creates a new Database
  68155. * @param urlToScene defines the url to load the scene
  68156. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68157. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68158. */
  68159. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68160. private static _ParseURL;
  68161. private static _ReturnFullUrlLocation;
  68162. private _checkManifestFile;
  68163. /**
  68164. * Open the database and make it available
  68165. * @param successCallback defines the callback to call on success
  68166. * @param errorCallback defines the callback to call on error
  68167. */
  68168. open(successCallback: () => void, errorCallback: () => void): void;
  68169. /**
  68170. * Loads an image from the database
  68171. * @param url defines the url to load from
  68172. * @param image defines the target DOM image
  68173. */
  68174. loadImage(url: string, image: HTMLImageElement): void;
  68175. private _loadImageFromDBAsync;
  68176. private _saveImageIntoDBAsync;
  68177. private _checkVersionFromDB;
  68178. private _loadVersionFromDBAsync;
  68179. private _saveVersionIntoDBAsync;
  68180. /**
  68181. * Loads a file from database
  68182. * @param url defines the URL to load from
  68183. * @param sceneLoaded defines a callback to call on success
  68184. * @param progressCallBack defines a callback to call when progress changed
  68185. * @param errorCallback defines a callback to call on error
  68186. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68187. */
  68188. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68189. private _loadFileAsync;
  68190. private _saveFileAsync;
  68191. /**
  68192. * Validates if xhr data is correct
  68193. * @param xhr defines the request to validate
  68194. * @param dataType defines the expected data type
  68195. * @returns true if data is correct
  68196. */
  68197. private static _ValidateXHRData;
  68198. }
  68199. }
  68200. declare module BABYLON {
  68201. /** @hidden */
  68202. export var gpuUpdateParticlesPixelShader: {
  68203. name: string;
  68204. shader: string;
  68205. };
  68206. }
  68207. declare module BABYLON {
  68208. /** @hidden */
  68209. export var gpuUpdateParticlesVertexShader: {
  68210. name: string;
  68211. shader: string;
  68212. };
  68213. }
  68214. declare module BABYLON {
  68215. /** @hidden */
  68216. export var clipPlaneFragmentDeclaration2: {
  68217. name: string;
  68218. shader: string;
  68219. };
  68220. }
  68221. declare module BABYLON {
  68222. /** @hidden */
  68223. export var gpuRenderParticlesPixelShader: {
  68224. name: string;
  68225. shader: string;
  68226. };
  68227. }
  68228. declare module BABYLON {
  68229. /** @hidden */
  68230. export var clipPlaneVertexDeclaration2: {
  68231. name: string;
  68232. shader: string;
  68233. };
  68234. }
  68235. declare module BABYLON {
  68236. /** @hidden */
  68237. export var gpuRenderParticlesVertexShader: {
  68238. name: string;
  68239. shader: string;
  68240. };
  68241. }
  68242. declare module BABYLON {
  68243. /**
  68244. * This represents a GPU particle system in Babylon
  68245. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68246. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68247. */
  68248. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68249. /**
  68250. * The layer mask we are rendering the particles through.
  68251. */
  68252. layerMask: number;
  68253. private _capacity;
  68254. private _activeCount;
  68255. private _currentActiveCount;
  68256. private _accumulatedCount;
  68257. private _renderEffect;
  68258. private _updateEffect;
  68259. private _buffer0;
  68260. private _buffer1;
  68261. private _spriteBuffer;
  68262. private _updateVAO;
  68263. private _renderVAO;
  68264. private _targetIndex;
  68265. private _sourceBuffer;
  68266. private _targetBuffer;
  68267. private _currentRenderId;
  68268. private _started;
  68269. private _stopped;
  68270. private _timeDelta;
  68271. private _randomTexture;
  68272. private _randomTexture2;
  68273. private _attributesStrideSize;
  68274. private _updateEffectOptions;
  68275. private _randomTextureSize;
  68276. private _actualFrame;
  68277. private _customEffect;
  68278. private readonly _rawTextureWidth;
  68279. /**
  68280. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68281. */
  68282. static get IsSupported(): boolean;
  68283. /**
  68284. * An event triggered when the system is disposed.
  68285. */
  68286. onDisposeObservable: Observable<IParticleSystem>;
  68287. /**
  68288. * An event triggered when the system is stopped
  68289. */
  68290. onStoppedObservable: Observable<IParticleSystem>;
  68291. /**
  68292. * Gets the maximum number of particles active at the same time.
  68293. * @returns The max number of active particles.
  68294. */
  68295. getCapacity(): number;
  68296. /**
  68297. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68298. * to override the particles.
  68299. */
  68300. forceDepthWrite: boolean;
  68301. /**
  68302. * Gets or set the number of active particles
  68303. */
  68304. get activeParticleCount(): number;
  68305. set activeParticleCount(value: number);
  68306. private _preWarmDone;
  68307. /**
  68308. * Specifies if the particles are updated in emitter local space or world space.
  68309. */
  68310. isLocal: boolean;
  68311. /** Gets or sets a matrix to use to compute projection */
  68312. defaultProjectionMatrix: Matrix;
  68313. /**
  68314. * Is this system ready to be used/rendered
  68315. * @return true if the system is ready
  68316. */
  68317. isReady(): boolean;
  68318. /**
  68319. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68320. * @returns True if it has been started, otherwise false.
  68321. */
  68322. isStarted(): boolean;
  68323. /**
  68324. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68325. * @returns True if it has been stopped, otherwise false.
  68326. */
  68327. isStopped(): boolean;
  68328. /**
  68329. * Gets a boolean indicating that the system is stopping
  68330. * @returns true if the system is currently stopping
  68331. */
  68332. isStopping(): boolean;
  68333. /**
  68334. * Gets the number of particles active at the same time.
  68335. * @returns The number of active particles.
  68336. */
  68337. getActiveCount(): number;
  68338. /**
  68339. * Starts the particle system and begins to emit
  68340. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68341. */
  68342. start(delay?: number): void;
  68343. /**
  68344. * Stops the particle system.
  68345. */
  68346. stop(): void;
  68347. /**
  68348. * Remove all active particles
  68349. */
  68350. reset(): void;
  68351. /**
  68352. * Returns the string "GPUParticleSystem"
  68353. * @returns a string containing the class name
  68354. */
  68355. getClassName(): string;
  68356. /**
  68357. * Gets the custom effect used to render the particles
  68358. * @param blendMode Blend mode for which the effect should be retrieved
  68359. * @returns The effect
  68360. */
  68361. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68362. /**
  68363. * Sets the custom effect used to render the particles
  68364. * @param effect The effect to set
  68365. * @param blendMode Blend mode for which the effect should be set
  68366. */
  68367. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68368. /** @hidden */
  68369. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68370. /**
  68371. * Observable that will be called just before the particles are drawn
  68372. */
  68373. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68374. /**
  68375. * Gets the name of the particle vertex shader
  68376. */
  68377. get vertexShaderName(): string;
  68378. private _colorGradientsTexture;
  68379. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68380. /**
  68381. * Adds a new color gradient
  68382. * @param gradient defines the gradient to use (between 0 and 1)
  68383. * @param color1 defines the color to affect to the specified gradient
  68384. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68385. * @returns the current particle system
  68386. */
  68387. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68388. private _refreshColorGradient;
  68389. /** Force the system to rebuild all gradients that need to be resync */
  68390. forceRefreshGradients(): void;
  68391. /**
  68392. * Remove a specific color gradient
  68393. * @param gradient defines the gradient to remove
  68394. * @returns the current particle system
  68395. */
  68396. removeColorGradient(gradient: number): GPUParticleSystem;
  68397. private _angularSpeedGradientsTexture;
  68398. private _sizeGradientsTexture;
  68399. private _velocityGradientsTexture;
  68400. private _limitVelocityGradientsTexture;
  68401. private _dragGradientsTexture;
  68402. private _addFactorGradient;
  68403. /**
  68404. * Adds a new size gradient
  68405. * @param gradient defines the gradient to use (between 0 and 1)
  68406. * @param factor defines the size factor to affect to the specified gradient
  68407. * @returns the current particle system
  68408. */
  68409. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68410. /**
  68411. * Remove a specific size gradient
  68412. * @param gradient defines the gradient to remove
  68413. * @returns the current particle system
  68414. */
  68415. removeSizeGradient(gradient: number): GPUParticleSystem;
  68416. private _refreshFactorGradient;
  68417. /**
  68418. * Adds a new angular speed gradient
  68419. * @param gradient defines the gradient to use (between 0 and 1)
  68420. * @param factor defines the angular speed to affect to the specified gradient
  68421. * @returns the current particle system
  68422. */
  68423. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68424. /**
  68425. * Remove a specific angular speed gradient
  68426. * @param gradient defines the gradient to remove
  68427. * @returns the current particle system
  68428. */
  68429. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68430. /**
  68431. * Adds a new velocity gradient
  68432. * @param gradient defines the gradient to use (between 0 and 1)
  68433. * @param factor defines the velocity to affect to the specified gradient
  68434. * @returns the current particle system
  68435. */
  68436. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68437. /**
  68438. * Remove a specific velocity gradient
  68439. * @param gradient defines the gradient to remove
  68440. * @returns the current particle system
  68441. */
  68442. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68443. /**
  68444. * Adds a new limit velocity gradient
  68445. * @param gradient defines the gradient to use (between 0 and 1)
  68446. * @param factor defines the limit velocity value to affect to the specified gradient
  68447. * @returns the current particle system
  68448. */
  68449. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68450. /**
  68451. * Remove a specific limit velocity gradient
  68452. * @param gradient defines the gradient to remove
  68453. * @returns the current particle system
  68454. */
  68455. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68456. /**
  68457. * Adds a new drag gradient
  68458. * @param gradient defines the gradient to use (between 0 and 1)
  68459. * @param factor defines the drag value to affect to the specified gradient
  68460. * @returns the current particle system
  68461. */
  68462. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68463. /**
  68464. * Remove a specific drag gradient
  68465. * @param gradient defines the gradient to remove
  68466. * @returns the current particle system
  68467. */
  68468. removeDragGradient(gradient: number): GPUParticleSystem;
  68469. /**
  68470. * Not supported by GPUParticleSystem
  68471. * @param gradient defines the gradient to use (between 0 and 1)
  68472. * @param factor defines the emit rate value to affect to the specified gradient
  68473. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68474. * @returns the current particle system
  68475. */
  68476. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68477. /**
  68478. * Not supported by GPUParticleSystem
  68479. * @param gradient defines the gradient to remove
  68480. * @returns the current particle system
  68481. */
  68482. removeEmitRateGradient(gradient: number): IParticleSystem;
  68483. /**
  68484. * Not supported by GPUParticleSystem
  68485. * @param gradient defines the gradient to use (between 0 and 1)
  68486. * @param factor defines the start size value to affect to the specified gradient
  68487. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68488. * @returns the current particle system
  68489. */
  68490. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68491. /**
  68492. * Not supported by GPUParticleSystem
  68493. * @param gradient defines the gradient to remove
  68494. * @returns the current particle system
  68495. */
  68496. removeStartSizeGradient(gradient: number): IParticleSystem;
  68497. /**
  68498. * Not supported by GPUParticleSystem
  68499. * @param gradient defines the gradient to use (between 0 and 1)
  68500. * @param min defines the color remap minimal range
  68501. * @param max defines the color remap maximal range
  68502. * @returns the current particle system
  68503. */
  68504. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68505. /**
  68506. * Not supported by GPUParticleSystem
  68507. * @param gradient defines the gradient to remove
  68508. * @returns the current particle system
  68509. */
  68510. removeColorRemapGradient(): IParticleSystem;
  68511. /**
  68512. * Not supported by GPUParticleSystem
  68513. * @param gradient defines the gradient to use (between 0 and 1)
  68514. * @param min defines the alpha remap minimal range
  68515. * @param max defines the alpha remap maximal range
  68516. * @returns the current particle system
  68517. */
  68518. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68519. /**
  68520. * Not supported by GPUParticleSystem
  68521. * @param gradient defines the gradient to remove
  68522. * @returns the current particle system
  68523. */
  68524. removeAlphaRemapGradient(): IParticleSystem;
  68525. /**
  68526. * Not supported by GPUParticleSystem
  68527. * @param gradient defines the gradient to use (between 0 and 1)
  68528. * @param color defines the color to affect to the specified gradient
  68529. * @returns the current particle system
  68530. */
  68531. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68532. /**
  68533. * Not supported by GPUParticleSystem
  68534. * @param gradient defines the gradient to remove
  68535. * @returns the current particle system
  68536. */
  68537. removeRampGradient(): IParticleSystem;
  68538. /**
  68539. * Not supported by GPUParticleSystem
  68540. * @returns the list of ramp gradients
  68541. */
  68542. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68543. /**
  68544. * Not supported by GPUParticleSystem
  68545. * Gets or sets a boolean indicating that ramp gradients must be used
  68546. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68547. */
  68548. get useRampGradients(): boolean;
  68549. set useRampGradients(value: boolean);
  68550. /**
  68551. * Not supported by GPUParticleSystem
  68552. * @param gradient defines the gradient to use (between 0 and 1)
  68553. * @param factor defines the life time factor to affect to the specified gradient
  68554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68555. * @returns the current particle system
  68556. */
  68557. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68558. /**
  68559. * Not supported by GPUParticleSystem
  68560. * @param gradient defines the gradient to remove
  68561. * @returns the current particle system
  68562. */
  68563. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68564. /**
  68565. * Instantiates a GPU particle system.
  68566. * 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.
  68567. * @param name The name of the particle system
  68568. * @param options The options used to create the system
  68569. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68570. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68571. * @param customEffect a custom effect used to change the way particles are rendered by default
  68572. */
  68573. constructor(name: string, options: Partial<{
  68574. capacity: number;
  68575. randomTextureSize: number;
  68576. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68577. protected _reset(): void;
  68578. private _createUpdateVAO;
  68579. private _createRenderVAO;
  68580. private _initialize;
  68581. /** @hidden */
  68582. _recreateUpdateEffect(): void;
  68583. private _getEffect;
  68584. /**
  68585. * Fill the defines array according to the current settings of the particle system
  68586. * @param defines Array to be updated
  68587. * @param blendMode blend mode to take into account when updating the array
  68588. */
  68589. fillDefines(defines: Array<string>, blendMode?: number): void;
  68590. /**
  68591. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68592. * @param uniforms Uniforms array to fill
  68593. * @param attributes Attributes array to fill
  68594. * @param samplers Samplers array to fill
  68595. */
  68596. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68597. /** @hidden */
  68598. _recreateRenderEffect(): Effect;
  68599. /**
  68600. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68601. * @param preWarm defines if we are in the pre-warmimg phase
  68602. */
  68603. animate(preWarm?: boolean): void;
  68604. private _createFactorGradientTexture;
  68605. private _createSizeGradientTexture;
  68606. private _createAngularSpeedGradientTexture;
  68607. private _createVelocityGradientTexture;
  68608. private _createLimitVelocityGradientTexture;
  68609. private _createDragGradientTexture;
  68610. private _createColorGradientTexture;
  68611. /**
  68612. * Renders the particle system in its current state
  68613. * @param preWarm defines if the system should only update the particles but not render them
  68614. * @returns the current number of particles
  68615. */
  68616. render(preWarm?: boolean): number;
  68617. /**
  68618. * Rebuilds the particle system
  68619. */
  68620. rebuild(): void;
  68621. private _releaseBuffers;
  68622. private _releaseVAOs;
  68623. /**
  68624. * Disposes the particle system and free the associated resources
  68625. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68626. */
  68627. dispose(disposeTexture?: boolean): void;
  68628. /**
  68629. * Clones the particle system.
  68630. * @param name The name of the cloned object
  68631. * @param newEmitter The new emitter to use
  68632. * @returns the cloned particle system
  68633. */
  68634. clone(name: string, newEmitter: any): GPUParticleSystem;
  68635. /**
  68636. * Serializes the particle system to a JSON object
  68637. * @param serializeTexture defines if the texture must be serialized as well
  68638. * @returns the JSON object
  68639. */
  68640. serialize(serializeTexture?: boolean): any;
  68641. /**
  68642. * Parses a JSON object to create a GPU particle system.
  68643. * @param parsedParticleSystem The JSON object to parse
  68644. * @param sceneOrEngine The scene or the engine to create the particle system in
  68645. * @param rootUrl The root url to use to load external dependencies like texture
  68646. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68647. * @returns the parsed GPU particle system
  68648. */
  68649. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68650. }
  68651. }
  68652. declare module BABYLON {
  68653. /**
  68654. * Represents a set of particle systems working together to create a specific effect
  68655. */
  68656. export class ParticleSystemSet implements IDisposable {
  68657. /**
  68658. * Gets or sets base Assets URL
  68659. */
  68660. static BaseAssetsUrl: string;
  68661. private _emitterCreationOptions;
  68662. private _emitterNode;
  68663. /**
  68664. * Gets the particle system list
  68665. */
  68666. systems: IParticleSystem[];
  68667. /**
  68668. * Gets the emitter node used with this set
  68669. */
  68670. get emitterNode(): Nullable<TransformNode>;
  68671. /**
  68672. * Creates a new emitter mesh as a sphere
  68673. * @param options defines the options used to create the sphere
  68674. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68675. * @param scene defines the hosting scene
  68676. */
  68677. setEmitterAsSphere(options: {
  68678. diameter: number;
  68679. segments: number;
  68680. color: Color3;
  68681. }, renderingGroupId: number, scene: Scene): void;
  68682. /**
  68683. * Starts all particle systems of the set
  68684. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68685. */
  68686. start(emitter?: AbstractMesh): void;
  68687. /**
  68688. * Release all associated resources
  68689. */
  68690. dispose(): void;
  68691. /**
  68692. * Serialize the set into a JSON compatible object
  68693. * @param serializeTexture defines if the texture must be serialized as well
  68694. * @returns a JSON compatible representation of the set
  68695. */
  68696. serialize(serializeTexture?: boolean): any;
  68697. /**
  68698. * Parse a new ParticleSystemSet from a serialized source
  68699. * @param data defines a JSON compatible representation of the set
  68700. * @param scene defines the hosting scene
  68701. * @param gpu defines if we want GPU particles or CPU particles
  68702. * @returns a new ParticleSystemSet
  68703. */
  68704. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68705. }
  68706. }
  68707. declare module BABYLON {
  68708. /**
  68709. * This class is made for on one-liner static method to help creating particle system set.
  68710. */
  68711. export class ParticleHelper {
  68712. /**
  68713. * Gets or sets base Assets URL
  68714. */
  68715. static BaseAssetsUrl: string;
  68716. /** Define the Url to load snippets */
  68717. static SnippetUrl: string;
  68718. /**
  68719. * Create a default particle system that you can tweak
  68720. * @param emitter defines the emitter to use
  68721. * @param capacity defines the system capacity (default is 500 particles)
  68722. * @param scene defines the hosting scene
  68723. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68724. * @returns the new Particle system
  68725. */
  68726. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68727. /**
  68728. * This is the main static method (one-liner) of this helper to create different particle systems
  68729. * @param type This string represents the type to the particle system to create
  68730. * @param scene The scene where the particle system should live
  68731. * @param gpu If the system will use gpu
  68732. * @returns the ParticleSystemSet created
  68733. */
  68734. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68735. /**
  68736. * Static function used to export a particle system to a ParticleSystemSet variable.
  68737. * Please note that the emitter shape is not exported
  68738. * @param systems defines the particle systems to export
  68739. * @returns the created particle system set
  68740. */
  68741. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68742. /**
  68743. * Creates a particle system from a snippet saved in a remote file
  68744. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68745. * @param url defines the url to load from
  68746. * @param scene defines the hosting scene
  68747. * @param gpu If the system will use gpu
  68748. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68749. * @returns a promise that will resolve to the new particle system
  68750. */
  68751. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68752. /**
  68753. * Creates a particle system from a snippet saved by the particle system editor
  68754. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68755. * @param scene defines the hosting scene
  68756. * @param gpu If the system will use gpu
  68757. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68758. * @returns a promise that will resolve to the new particle system
  68759. */
  68760. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68761. }
  68762. }
  68763. declare module BABYLON {
  68764. interface Engine {
  68765. /**
  68766. * Create an effect to use with particle systems.
  68767. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68768. * the particle system for which you want to create a custom effect in the last parameter
  68769. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68770. * @param uniformsNames defines a list of attribute names
  68771. * @param samplers defines an array of string used to represent textures
  68772. * @param defines defines the string containing the defines to use to compile the shaders
  68773. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68774. * @param onCompiled defines a function to call when the effect creation is successful
  68775. * @param onError defines a function to call when the effect creation has failed
  68776. * @param particleSystem the particle system you want to create the effect for
  68777. * @returns the new Effect
  68778. */
  68779. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68780. }
  68781. interface Mesh {
  68782. /**
  68783. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68784. * @returns an array of IParticleSystem
  68785. */
  68786. getEmittedParticleSystems(): IParticleSystem[];
  68787. /**
  68788. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68789. * @returns an array of IParticleSystem
  68790. */
  68791. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68792. }
  68793. }
  68794. declare module BABYLON {
  68795. /** Defines the 4 color options */
  68796. export enum PointColor {
  68797. /** color value */
  68798. Color = 2,
  68799. /** uv value */
  68800. UV = 1,
  68801. /** random value */
  68802. Random = 0,
  68803. /** stated value */
  68804. Stated = 3
  68805. }
  68806. /**
  68807. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68808. * 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.
  68809. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68810. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68811. *
  68812. * Full documentation here : TO BE ENTERED
  68813. */
  68814. export class PointsCloudSystem implements IDisposable {
  68815. /**
  68816. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68817. * Example : var p = SPS.particles[i];
  68818. */
  68819. particles: CloudPoint[];
  68820. /**
  68821. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68822. */
  68823. nbParticles: number;
  68824. /**
  68825. * This a counter for your own usage. It's not set by any SPS functions.
  68826. */
  68827. counter: number;
  68828. /**
  68829. * The PCS name. This name is also given to the underlying mesh.
  68830. */
  68831. name: string;
  68832. /**
  68833. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68834. */
  68835. mesh: Mesh;
  68836. /**
  68837. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68838. * Please read :
  68839. */
  68840. vars: any;
  68841. /**
  68842. * @hidden
  68843. */
  68844. _size: number;
  68845. private _scene;
  68846. private _promises;
  68847. private _positions;
  68848. private _indices;
  68849. private _normals;
  68850. private _colors;
  68851. private _uvs;
  68852. private _indices32;
  68853. private _positions32;
  68854. private _colors32;
  68855. private _uvs32;
  68856. private _updatable;
  68857. private _isVisibilityBoxLocked;
  68858. private _alwaysVisible;
  68859. private _groups;
  68860. private _groupCounter;
  68861. private _computeParticleColor;
  68862. private _computeParticleTexture;
  68863. private _computeParticleRotation;
  68864. private _computeBoundingBox;
  68865. private _isReady;
  68866. /**
  68867. * Creates a PCS (Points Cloud System) object
  68868. * @param name (String) is the PCS name, this will be the underlying mesh name
  68869. * @param pointSize (number) is the size for each point
  68870. * @param scene (Scene) is the scene in which the PCS is added
  68871. * @param options defines the options of the PCS e.g.
  68872. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68873. */
  68874. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68875. updatable?: boolean;
  68876. });
  68877. /**
  68878. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68879. * If no points were added to the PCS, the returned mesh is just a single point.
  68880. * @returns a promise for the created mesh
  68881. */
  68882. buildMeshAsync(): Promise<Mesh>;
  68883. /**
  68884. * @hidden
  68885. */
  68886. private _buildMesh;
  68887. private _addParticle;
  68888. private _randomUnitVector;
  68889. private _getColorIndicesForCoord;
  68890. private _setPointsColorOrUV;
  68891. private _colorFromTexture;
  68892. private _calculateDensity;
  68893. /**
  68894. * Adds points to the PCS in random positions within a unit sphere
  68895. * @param nb (positive integer) the number of particles to be created from this model
  68896. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68897. * @returns the number of groups in the system
  68898. */
  68899. addPoints(nb: number, pointFunction?: any): number;
  68900. /**
  68901. * Adds points to the PCS from the surface of the model shape
  68902. * @param mesh is any Mesh object that will be used as a surface model for the points
  68903. * @param nb (positive integer) the number of particles to be created from this model
  68904. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68905. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68906. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68907. * @returns the number of groups in the system
  68908. */
  68909. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68910. /**
  68911. * Adds points to the PCS inside the model shape
  68912. * @param mesh is any Mesh object that will be used as a surface model for the points
  68913. * @param nb (positive integer) the number of particles to be created from this model
  68914. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68915. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68916. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68917. * @returns the number of groups in the system
  68918. */
  68919. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68920. /**
  68921. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68922. * This method calls `updateParticle()` for each particle of the SPS.
  68923. * For an animated SPS, it is usually called within the render loop.
  68924. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68925. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68926. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68927. * @returns the PCS.
  68928. */
  68929. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68930. /**
  68931. * Disposes the PCS.
  68932. */
  68933. dispose(): void;
  68934. /**
  68935. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68936. * doc :
  68937. * @returns the PCS.
  68938. */
  68939. refreshVisibleSize(): PointsCloudSystem;
  68940. /**
  68941. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68942. * @param size the size (float) of the visibility box
  68943. * note : this doesn't lock the PCS mesh bounding box.
  68944. * doc :
  68945. */
  68946. setVisibilityBox(size: number): void;
  68947. /**
  68948. * Gets whether the PCS is always visible or not
  68949. * doc :
  68950. */
  68951. get isAlwaysVisible(): boolean;
  68952. /**
  68953. * Sets the PCS as always visible or not
  68954. * doc :
  68955. */
  68956. set isAlwaysVisible(val: boolean);
  68957. /**
  68958. * Tells to `setParticles()` to compute the particle rotations or not
  68959. * Default value : false. The PCS is faster when it's set to false
  68960. * Note : particle rotations are only applied to parent particles
  68961. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68962. */
  68963. set computeParticleRotation(val: boolean);
  68964. /**
  68965. * Tells to `setParticles()` to compute the particle colors or not.
  68966. * Default value : true. The PCS is faster when it's set to false.
  68967. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68968. */
  68969. set computeParticleColor(val: boolean);
  68970. set computeParticleTexture(val: boolean);
  68971. /**
  68972. * Gets if `setParticles()` computes the particle colors or not.
  68973. * Default value : false. The PCS is faster when it's set to false.
  68974. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68975. */
  68976. get computeParticleColor(): boolean;
  68977. /**
  68978. * Gets if `setParticles()` computes the particle textures or not.
  68979. * Default value : false. The PCS is faster when it's set to false.
  68980. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68981. */
  68982. get computeParticleTexture(): boolean;
  68983. /**
  68984. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68985. */
  68986. set computeBoundingBox(val: boolean);
  68987. /**
  68988. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68989. */
  68990. get computeBoundingBox(): boolean;
  68991. /**
  68992. * This function does nothing. It may be overwritten to set all the particle first values.
  68993. * The PCS doesn't call this function, you may have to call it by your own.
  68994. * doc :
  68995. */
  68996. initParticles(): void;
  68997. /**
  68998. * This function does nothing. It may be overwritten to recycle a particle
  68999. * The PCS doesn't call this function, you can to call it
  69000. * doc :
  69001. * @param particle The particle to recycle
  69002. * @returns the recycled particle
  69003. */
  69004. recycleParticle(particle: CloudPoint): CloudPoint;
  69005. /**
  69006. * Updates a particle : this function should be overwritten by the user.
  69007. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69008. * doc :
  69009. * @example : just set a particle position or velocity and recycle conditions
  69010. * @param particle The particle to update
  69011. * @returns the updated particle
  69012. */
  69013. updateParticle(particle: CloudPoint): CloudPoint;
  69014. /**
  69015. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69016. * This does nothing and may be overwritten by the user.
  69017. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69018. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69019. * @param update the boolean update value actually passed to setParticles()
  69020. */
  69021. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69022. /**
  69023. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69024. * This will be passed three parameters.
  69025. * This does nothing and may be overwritten by the user.
  69026. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69027. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69028. * @param update the boolean update value actually passed to setParticles()
  69029. */
  69030. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69031. }
  69032. }
  69033. declare module BABYLON {
  69034. /**
  69035. * Represents one particle of a points cloud system.
  69036. */
  69037. export class CloudPoint {
  69038. /**
  69039. * particle global index
  69040. */
  69041. idx: number;
  69042. /**
  69043. * The color of the particle
  69044. */
  69045. color: Nullable<Color4>;
  69046. /**
  69047. * The world space position of the particle.
  69048. */
  69049. position: Vector3;
  69050. /**
  69051. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69052. */
  69053. rotation: Vector3;
  69054. /**
  69055. * The world space rotation quaternion of the particle.
  69056. */
  69057. rotationQuaternion: Nullable<Quaternion>;
  69058. /**
  69059. * The uv of the particle.
  69060. */
  69061. uv: Nullable<Vector2>;
  69062. /**
  69063. * The current speed of the particle.
  69064. */
  69065. velocity: Vector3;
  69066. /**
  69067. * The pivot point in the particle local space.
  69068. */
  69069. pivot: Vector3;
  69070. /**
  69071. * Must the particle be translated from its pivot point in its local space ?
  69072. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69073. * Default : false
  69074. */
  69075. translateFromPivot: boolean;
  69076. /**
  69077. * Index of this particle in the global "positions" array (Internal use)
  69078. * @hidden
  69079. */
  69080. _pos: number;
  69081. /**
  69082. * @hidden Index of this particle in the global "indices" array (Internal use)
  69083. */
  69084. _ind: number;
  69085. /**
  69086. * Group this particle belongs to
  69087. */
  69088. _group: PointsGroup;
  69089. /**
  69090. * Group id of this particle
  69091. */
  69092. groupId: number;
  69093. /**
  69094. * Index of the particle in its group id (Internal use)
  69095. */
  69096. idxInGroup: number;
  69097. /**
  69098. * @hidden Particle BoundingInfo object (Internal use)
  69099. */
  69100. _boundingInfo: BoundingInfo;
  69101. /**
  69102. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69103. */
  69104. _pcs: PointsCloudSystem;
  69105. /**
  69106. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69107. */
  69108. _stillInvisible: boolean;
  69109. /**
  69110. * @hidden Last computed particle rotation matrix
  69111. */
  69112. _rotationMatrix: number[];
  69113. /**
  69114. * Parent particle Id, if any.
  69115. * Default null.
  69116. */
  69117. parentId: Nullable<number>;
  69118. /**
  69119. * @hidden Internal global position in the PCS.
  69120. */
  69121. _globalPosition: Vector3;
  69122. /**
  69123. * Creates a Point Cloud object.
  69124. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69125. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69126. * @param group (PointsGroup) is the group the particle belongs to
  69127. * @param groupId (integer) is the group identifier in the PCS.
  69128. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69129. * @param pcs defines the PCS it is associated to
  69130. */
  69131. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69132. /**
  69133. * get point size
  69134. */
  69135. get size(): Vector3;
  69136. /**
  69137. * Set point size
  69138. */
  69139. set size(scale: Vector3);
  69140. /**
  69141. * Legacy support, changed quaternion to rotationQuaternion
  69142. */
  69143. get quaternion(): Nullable<Quaternion>;
  69144. /**
  69145. * Legacy support, changed quaternion to rotationQuaternion
  69146. */
  69147. set quaternion(q: Nullable<Quaternion>);
  69148. /**
  69149. * Returns a boolean. True if the particle intersects a mesh, else false
  69150. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69151. * @param target is the object (point or mesh) what the intersection is computed against
  69152. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69153. * @returns true if it intersects
  69154. */
  69155. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69156. /**
  69157. * get the rotation matrix of the particle
  69158. * @hidden
  69159. */
  69160. getRotationMatrix(m: Matrix): void;
  69161. }
  69162. /**
  69163. * Represents a group of points in a points cloud system
  69164. * * PCS internal tool, don't use it manually.
  69165. */
  69166. export class PointsGroup {
  69167. /**
  69168. * The group id
  69169. * @hidden
  69170. */
  69171. groupID: number;
  69172. /**
  69173. * image data for group (internal use)
  69174. * @hidden
  69175. */
  69176. _groupImageData: Nullable<ArrayBufferView>;
  69177. /**
  69178. * Image Width (internal use)
  69179. * @hidden
  69180. */
  69181. _groupImgWidth: number;
  69182. /**
  69183. * Image Height (internal use)
  69184. * @hidden
  69185. */
  69186. _groupImgHeight: number;
  69187. /**
  69188. * Custom position function (internal use)
  69189. * @hidden
  69190. */
  69191. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69192. /**
  69193. * density per facet for surface points
  69194. * @hidden
  69195. */
  69196. _groupDensity: number[];
  69197. /**
  69198. * Only when points are colored by texture carries pointer to texture list array
  69199. * @hidden
  69200. */
  69201. _textureNb: number;
  69202. /**
  69203. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69204. * PCS internal tool, don't use it manually.
  69205. * @hidden
  69206. */
  69207. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69208. }
  69209. }
  69210. declare module BABYLON {
  69211. interface Scene {
  69212. /** @hidden (Backing field) */
  69213. _physicsEngine: Nullable<IPhysicsEngine>;
  69214. /** @hidden */
  69215. _physicsTimeAccumulator: number;
  69216. /**
  69217. * Gets the current physics engine
  69218. * @returns a IPhysicsEngine or null if none attached
  69219. */
  69220. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69221. /**
  69222. * Enables physics to the current scene
  69223. * @param gravity defines the scene's gravity for the physics engine
  69224. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69225. * @return a boolean indicating if the physics engine was initialized
  69226. */
  69227. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69228. /**
  69229. * Disables and disposes the physics engine associated with the scene
  69230. */
  69231. disablePhysicsEngine(): void;
  69232. /**
  69233. * Gets a boolean indicating if there is an active physics engine
  69234. * @returns a boolean indicating if there is an active physics engine
  69235. */
  69236. isPhysicsEnabled(): boolean;
  69237. /**
  69238. * Deletes a physics compound impostor
  69239. * @param compound defines the compound to delete
  69240. */
  69241. deleteCompoundImpostor(compound: any): void;
  69242. /**
  69243. * An event triggered when physic simulation is about to be run
  69244. */
  69245. onBeforePhysicsObservable: Observable<Scene>;
  69246. /**
  69247. * An event triggered when physic simulation has been done
  69248. */
  69249. onAfterPhysicsObservable: Observable<Scene>;
  69250. }
  69251. interface AbstractMesh {
  69252. /** @hidden */
  69253. _physicsImpostor: Nullable<PhysicsImpostor>;
  69254. /**
  69255. * Gets or sets impostor used for physic simulation
  69256. * @see https://doc.babylonjs.com/features/physics_engine
  69257. */
  69258. physicsImpostor: Nullable<PhysicsImpostor>;
  69259. /**
  69260. * Gets the current physics impostor
  69261. * @see https://doc.babylonjs.com/features/physics_engine
  69262. * @returns a physics impostor or null
  69263. */
  69264. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69265. /** Apply a physic impulse to the mesh
  69266. * @param force defines the force to apply
  69267. * @param contactPoint defines where to apply the force
  69268. * @returns the current mesh
  69269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69270. */
  69271. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69272. /**
  69273. * Creates a physic joint between two meshes
  69274. * @param otherMesh defines the other mesh to use
  69275. * @param pivot1 defines the pivot to use on this mesh
  69276. * @param pivot2 defines the pivot to use on the other mesh
  69277. * @param options defines additional options (can be plugin dependent)
  69278. * @returns the current mesh
  69279. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69280. */
  69281. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69282. /** @hidden */
  69283. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69284. }
  69285. /**
  69286. * Defines the physics engine scene component responsible to manage a physics engine
  69287. */
  69288. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69289. /**
  69290. * The component name helpful to identify the component in the list of scene components.
  69291. */
  69292. readonly name: string;
  69293. /**
  69294. * The scene the component belongs to.
  69295. */
  69296. scene: Scene;
  69297. /**
  69298. * Creates a new instance of the component for the given scene
  69299. * @param scene Defines the scene to register the component in
  69300. */
  69301. constructor(scene: Scene);
  69302. /**
  69303. * Registers the component in a given scene
  69304. */
  69305. register(): void;
  69306. /**
  69307. * Rebuilds the elements related to this component in case of
  69308. * context lost for instance.
  69309. */
  69310. rebuild(): void;
  69311. /**
  69312. * Disposes the component and the associated ressources
  69313. */
  69314. dispose(): void;
  69315. }
  69316. }
  69317. declare module BABYLON {
  69318. /**
  69319. * A helper for physics simulations
  69320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69321. */
  69322. export class PhysicsHelper {
  69323. private _scene;
  69324. private _physicsEngine;
  69325. /**
  69326. * Initializes the Physics helper
  69327. * @param scene Babylon.js scene
  69328. */
  69329. constructor(scene: Scene);
  69330. /**
  69331. * Applies a radial explosion impulse
  69332. * @param origin the origin of the explosion
  69333. * @param radiusOrEventOptions the radius or the options of radial explosion
  69334. * @param strength the explosion strength
  69335. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69336. * @returns A physics radial explosion event, or null
  69337. */
  69338. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69339. /**
  69340. * Applies a radial explosion force
  69341. * @param origin the origin of the explosion
  69342. * @param radiusOrEventOptions the radius or the options of radial explosion
  69343. * @param strength the explosion strength
  69344. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69345. * @returns A physics radial explosion event, or null
  69346. */
  69347. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69348. /**
  69349. * Creates a gravitational field
  69350. * @param origin the origin of the explosion
  69351. * @param radiusOrEventOptions the radius or the options of radial explosion
  69352. * @param strength the explosion strength
  69353. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69354. * @returns A physics gravitational field event, or null
  69355. */
  69356. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69357. /**
  69358. * Creates a physics updraft event
  69359. * @param origin the origin of the updraft
  69360. * @param radiusOrEventOptions the radius or the options of the updraft
  69361. * @param strength the strength of the updraft
  69362. * @param height the height of the updraft
  69363. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69364. * @returns A physics updraft event, or null
  69365. */
  69366. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69367. /**
  69368. * Creates a physics vortex event
  69369. * @param origin the of the vortex
  69370. * @param radiusOrEventOptions the radius or the options of the vortex
  69371. * @param strength the strength of the vortex
  69372. * @param height the height of the vortex
  69373. * @returns a Physics vortex event, or null
  69374. * A physics vortex event or null
  69375. */
  69376. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69377. }
  69378. /**
  69379. * Represents a physics radial explosion event
  69380. */
  69381. class PhysicsRadialExplosionEvent {
  69382. private _scene;
  69383. private _options;
  69384. private _sphere;
  69385. private _dataFetched;
  69386. /**
  69387. * Initializes a radial explosioin event
  69388. * @param _scene BabylonJS scene
  69389. * @param _options The options for the vortex event
  69390. */
  69391. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69392. /**
  69393. * Returns the data related to the radial explosion event (sphere).
  69394. * @returns The radial explosion event data
  69395. */
  69396. getData(): PhysicsRadialExplosionEventData;
  69397. /**
  69398. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69399. * @param impostor A physics imposter
  69400. * @param origin the origin of the explosion
  69401. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69402. */
  69403. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69404. /**
  69405. * Triggers affecterd impostors callbacks
  69406. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69407. */
  69408. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69409. /**
  69410. * Disposes the sphere.
  69411. * @param force Specifies if the sphere should be disposed by force
  69412. */
  69413. dispose(force?: boolean): void;
  69414. /*** Helpers ***/
  69415. private _prepareSphere;
  69416. private _intersectsWithSphere;
  69417. }
  69418. /**
  69419. * Represents a gravitational field event
  69420. */
  69421. class PhysicsGravitationalFieldEvent {
  69422. private _physicsHelper;
  69423. private _scene;
  69424. private _origin;
  69425. private _options;
  69426. private _tickCallback;
  69427. private _sphere;
  69428. private _dataFetched;
  69429. /**
  69430. * Initializes the physics gravitational field event
  69431. * @param _physicsHelper A physics helper
  69432. * @param _scene BabylonJS scene
  69433. * @param _origin The origin position of the gravitational field event
  69434. * @param _options The options for the vortex event
  69435. */
  69436. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69437. /**
  69438. * Returns the data related to the gravitational field event (sphere).
  69439. * @returns A gravitational field event
  69440. */
  69441. getData(): PhysicsGravitationalFieldEventData;
  69442. /**
  69443. * Enables the gravitational field.
  69444. */
  69445. enable(): void;
  69446. /**
  69447. * Disables the gravitational field.
  69448. */
  69449. disable(): void;
  69450. /**
  69451. * Disposes the sphere.
  69452. * @param force The force to dispose from the gravitational field event
  69453. */
  69454. dispose(force?: boolean): void;
  69455. private _tick;
  69456. }
  69457. /**
  69458. * Represents a physics updraft event
  69459. */
  69460. class PhysicsUpdraftEvent {
  69461. private _scene;
  69462. private _origin;
  69463. private _options;
  69464. private _physicsEngine;
  69465. private _originTop;
  69466. private _originDirection;
  69467. private _tickCallback;
  69468. private _cylinder;
  69469. private _cylinderPosition;
  69470. private _dataFetched;
  69471. /**
  69472. * Initializes the physics updraft event
  69473. * @param _scene BabylonJS scene
  69474. * @param _origin The origin position of the updraft
  69475. * @param _options The options for the updraft event
  69476. */
  69477. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69478. /**
  69479. * Returns the data related to the updraft event (cylinder).
  69480. * @returns A physics updraft event
  69481. */
  69482. getData(): PhysicsUpdraftEventData;
  69483. /**
  69484. * Enables the updraft.
  69485. */
  69486. enable(): void;
  69487. /**
  69488. * Disables the updraft.
  69489. */
  69490. disable(): void;
  69491. /**
  69492. * Disposes the cylinder.
  69493. * @param force Specifies if the updraft should be disposed by force
  69494. */
  69495. dispose(force?: boolean): void;
  69496. private getImpostorHitData;
  69497. private _tick;
  69498. /*** Helpers ***/
  69499. private _prepareCylinder;
  69500. private _intersectsWithCylinder;
  69501. }
  69502. /**
  69503. * Represents a physics vortex event
  69504. */
  69505. class PhysicsVortexEvent {
  69506. private _scene;
  69507. private _origin;
  69508. private _options;
  69509. private _physicsEngine;
  69510. private _originTop;
  69511. private _tickCallback;
  69512. private _cylinder;
  69513. private _cylinderPosition;
  69514. private _dataFetched;
  69515. /**
  69516. * Initializes the physics vortex event
  69517. * @param _scene The BabylonJS scene
  69518. * @param _origin The origin position of the vortex
  69519. * @param _options The options for the vortex event
  69520. */
  69521. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69522. /**
  69523. * Returns the data related to the vortex event (cylinder).
  69524. * @returns The physics vortex event data
  69525. */
  69526. getData(): PhysicsVortexEventData;
  69527. /**
  69528. * Enables the vortex.
  69529. */
  69530. enable(): void;
  69531. /**
  69532. * Disables the cortex.
  69533. */
  69534. disable(): void;
  69535. /**
  69536. * Disposes the sphere.
  69537. * @param force
  69538. */
  69539. dispose(force?: boolean): void;
  69540. private getImpostorHitData;
  69541. private _tick;
  69542. /*** Helpers ***/
  69543. private _prepareCylinder;
  69544. private _intersectsWithCylinder;
  69545. }
  69546. /**
  69547. * Options fot the radial explosion event
  69548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69549. */
  69550. export class PhysicsRadialExplosionEventOptions {
  69551. /**
  69552. * The radius of the sphere for the radial explosion.
  69553. */
  69554. radius: number;
  69555. /**
  69556. * The strenth of the explosion.
  69557. */
  69558. strength: number;
  69559. /**
  69560. * The strenght of the force in correspondence to the distance of the affected object
  69561. */
  69562. falloff: PhysicsRadialImpulseFalloff;
  69563. /**
  69564. * Sphere options for the radial explosion.
  69565. */
  69566. sphere: {
  69567. segments: number;
  69568. diameter: number;
  69569. };
  69570. /**
  69571. * Sphere options for the radial explosion.
  69572. */
  69573. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69574. }
  69575. /**
  69576. * Options fot the updraft event
  69577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69578. */
  69579. export class PhysicsUpdraftEventOptions {
  69580. /**
  69581. * The radius of the cylinder for the vortex
  69582. */
  69583. radius: number;
  69584. /**
  69585. * The strenth of the updraft.
  69586. */
  69587. strength: number;
  69588. /**
  69589. * The height of the cylinder for the updraft.
  69590. */
  69591. height: number;
  69592. /**
  69593. * The mode for the the updraft.
  69594. */
  69595. updraftMode: PhysicsUpdraftMode;
  69596. }
  69597. /**
  69598. * Options fot the vortex event
  69599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69600. */
  69601. export class PhysicsVortexEventOptions {
  69602. /**
  69603. * The radius of the cylinder for the vortex
  69604. */
  69605. radius: number;
  69606. /**
  69607. * The strenth of the vortex.
  69608. */
  69609. strength: number;
  69610. /**
  69611. * The height of the cylinder for the vortex.
  69612. */
  69613. height: number;
  69614. /**
  69615. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69616. */
  69617. centripetalForceThreshold: number;
  69618. /**
  69619. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69620. */
  69621. centripetalForceMultiplier: number;
  69622. /**
  69623. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69624. */
  69625. centrifugalForceMultiplier: number;
  69626. /**
  69627. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69628. */
  69629. updraftForceMultiplier: number;
  69630. }
  69631. /**
  69632. * The strenght of the force in correspondence to the distance of the affected object
  69633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69634. */
  69635. export enum PhysicsRadialImpulseFalloff {
  69636. /** Defines that impulse is constant in strength across it's whole radius */
  69637. Constant = 0,
  69638. /** Defines that impulse gets weaker if it's further from the origin */
  69639. Linear = 1
  69640. }
  69641. /**
  69642. * The strength of the force in correspondence to the distance of the affected object
  69643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69644. */
  69645. export enum PhysicsUpdraftMode {
  69646. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69647. Center = 0,
  69648. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69649. Perpendicular = 1
  69650. }
  69651. /**
  69652. * Interface for a physics hit data
  69653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69654. */
  69655. export interface PhysicsHitData {
  69656. /**
  69657. * The force applied at the contact point
  69658. */
  69659. force: Vector3;
  69660. /**
  69661. * The contact point
  69662. */
  69663. contactPoint: Vector3;
  69664. /**
  69665. * The distance from the origin to the contact point
  69666. */
  69667. distanceFromOrigin: number;
  69668. }
  69669. /**
  69670. * Interface for radial explosion event data
  69671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69672. */
  69673. export interface PhysicsRadialExplosionEventData {
  69674. /**
  69675. * A sphere used for the radial explosion event
  69676. */
  69677. sphere: Mesh;
  69678. }
  69679. /**
  69680. * Interface for gravitational field event data
  69681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69682. */
  69683. export interface PhysicsGravitationalFieldEventData {
  69684. /**
  69685. * A sphere mesh used for the gravitational field event
  69686. */
  69687. sphere: Mesh;
  69688. }
  69689. /**
  69690. * Interface for updraft event data
  69691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69692. */
  69693. export interface PhysicsUpdraftEventData {
  69694. /**
  69695. * A cylinder used for the updraft event
  69696. */
  69697. cylinder: Mesh;
  69698. }
  69699. /**
  69700. * Interface for vortex event data
  69701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69702. */
  69703. export interface PhysicsVortexEventData {
  69704. /**
  69705. * A cylinder used for the vortex event
  69706. */
  69707. cylinder: Mesh;
  69708. }
  69709. /**
  69710. * Interface for an affected physics impostor
  69711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69712. */
  69713. export interface PhysicsAffectedImpostorWithData {
  69714. /**
  69715. * The impostor affected by the effect
  69716. */
  69717. impostor: PhysicsImpostor;
  69718. /**
  69719. * The data about the hit/horce from the explosion
  69720. */
  69721. hitData: PhysicsHitData;
  69722. }
  69723. }
  69724. declare module BABYLON {
  69725. /** @hidden */
  69726. export var blackAndWhitePixelShader: {
  69727. name: string;
  69728. shader: string;
  69729. };
  69730. }
  69731. declare module BABYLON {
  69732. /**
  69733. * Post process used to render in black and white
  69734. */
  69735. export class BlackAndWhitePostProcess extends PostProcess {
  69736. /**
  69737. * Linear about to convert he result to black and white (default: 1)
  69738. */
  69739. degree: number;
  69740. /**
  69741. * Gets a string identifying the name of the class
  69742. * @returns "BlackAndWhitePostProcess" string
  69743. */
  69744. getClassName(): string;
  69745. /**
  69746. * Creates a black and white post process
  69747. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69748. * @param name The name of the effect.
  69749. * @param options The required width/height ratio to downsize to before computing the render pass.
  69750. * @param camera The camera to apply the render pass to.
  69751. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69752. * @param engine The engine which the post process will be applied. (default: current engine)
  69753. * @param reusable If the post process can be reused on the same frame. (default: false)
  69754. */
  69755. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69756. /** @hidden */
  69757. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69758. }
  69759. }
  69760. declare module BABYLON {
  69761. /**
  69762. * This represents a set of one or more post processes in Babylon.
  69763. * A post process can be used to apply a shader to a texture after it is rendered.
  69764. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69765. */
  69766. export class PostProcessRenderEffect {
  69767. private _postProcesses;
  69768. private _getPostProcesses;
  69769. private _singleInstance;
  69770. private _cameras;
  69771. private _indicesForCamera;
  69772. /**
  69773. * Name of the effect
  69774. * @hidden
  69775. */
  69776. _name: string;
  69777. /**
  69778. * Instantiates a post process render effect.
  69779. * A post process can be used to apply a shader to a texture after it is rendered.
  69780. * @param engine The engine the effect is tied to
  69781. * @param name The name of the effect
  69782. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69783. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69784. */
  69785. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69786. /**
  69787. * Checks if all the post processes in the effect are supported.
  69788. */
  69789. get isSupported(): boolean;
  69790. /**
  69791. * Updates the current state of the effect
  69792. * @hidden
  69793. */
  69794. _update(): void;
  69795. /**
  69796. * Attaches the effect on cameras
  69797. * @param cameras The camera to attach to.
  69798. * @hidden
  69799. */
  69800. _attachCameras(cameras: Camera): void;
  69801. /**
  69802. * Attaches the effect on cameras
  69803. * @param cameras The camera to attach to.
  69804. * @hidden
  69805. */
  69806. _attachCameras(cameras: Camera[]): void;
  69807. /**
  69808. * Detaches the effect on cameras
  69809. * @param cameras The camera to detatch from.
  69810. * @hidden
  69811. */
  69812. _detachCameras(cameras: Camera): void;
  69813. /**
  69814. * Detatches the effect on cameras
  69815. * @param cameras The camera to detatch from.
  69816. * @hidden
  69817. */
  69818. _detachCameras(cameras: Camera[]): void;
  69819. /**
  69820. * Enables the effect on given cameras
  69821. * @param cameras The camera to enable.
  69822. * @hidden
  69823. */
  69824. _enable(cameras: Camera): void;
  69825. /**
  69826. * Enables the effect on given cameras
  69827. * @param cameras The camera to enable.
  69828. * @hidden
  69829. */
  69830. _enable(cameras: Nullable<Camera[]>): void;
  69831. /**
  69832. * Disables the effect on the given cameras
  69833. * @param cameras The camera to disable.
  69834. * @hidden
  69835. */
  69836. _disable(cameras: Camera): void;
  69837. /**
  69838. * Disables the effect on the given cameras
  69839. * @param cameras The camera to disable.
  69840. * @hidden
  69841. */
  69842. _disable(cameras: Nullable<Camera[]>): void;
  69843. /**
  69844. * Gets a list of the post processes contained in the effect.
  69845. * @param camera The camera to get the post processes on.
  69846. * @returns The list of the post processes in the effect.
  69847. */
  69848. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69849. }
  69850. }
  69851. declare module BABYLON {
  69852. /** @hidden */
  69853. export var extractHighlightsPixelShader: {
  69854. name: string;
  69855. shader: string;
  69856. };
  69857. }
  69858. declare module BABYLON {
  69859. /**
  69860. * 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.
  69861. */
  69862. export class ExtractHighlightsPostProcess extends PostProcess {
  69863. /**
  69864. * The luminance threshold, pixels below this value will be set to black.
  69865. */
  69866. threshold: number;
  69867. /** @hidden */
  69868. _exposure: number;
  69869. /**
  69870. * Post process which has the input texture to be used when performing highlight extraction
  69871. * @hidden
  69872. */
  69873. _inputPostProcess: Nullable<PostProcess>;
  69874. /**
  69875. * Gets a string identifying the name of the class
  69876. * @returns "ExtractHighlightsPostProcess" string
  69877. */
  69878. getClassName(): string;
  69879. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69880. }
  69881. }
  69882. declare module BABYLON {
  69883. /** @hidden */
  69884. export var bloomMergePixelShader: {
  69885. name: string;
  69886. shader: string;
  69887. };
  69888. }
  69889. declare module BABYLON {
  69890. /**
  69891. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69892. */
  69893. export class BloomMergePostProcess extends PostProcess {
  69894. /** Weight of the bloom to be added to the original input. */
  69895. weight: number;
  69896. /**
  69897. * Gets a string identifying the name of the class
  69898. * @returns "BloomMergePostProcess" string
  69899. */
  69900. getClassName(): string;
  69901. /**
  69902. * Creates a new instance of @see BloomMergePostProcess
  69903. * @param name The name of the effect.
  69904. * @param originalFromInput Post process which's input will be used for the merge.
  69905. * @param blurred Blurred highlights post process which's output will be used.
  69906. * @param weight Weight of the bloom to be added to the original input.
  69907. * @param options The required width/height ratio to downsize to before computing the render pass.
  69908. * @param camera The camera to apply the render pass to.
  69909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69910. * @param engine The engine which the post process will be applied. (default: current engine)
  69911. * @param reusable If the post process can be reused on the same frame. (default: false)
  69912. * @param textureType Type of textures used when performing the post process. (default: 0)
  69913. * @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)
  69914. */
  69915. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69916. /** Weight of the bloom to be added to the original input. */
  69917. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69918. }
  69919. }
  69920. declare module BABYLON {
  69921. /**
  69922. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69923. */
  69924. export class BloomEffect extends PostProcessRenderEffect {
  69925. private bloomScale;
  69926. /**
  69927. * @hidden Internal
  69928. */
  69929. _effects: Array<PostProcess>;
  69930. /**
  69931. * @hidden Internal
  69932. */
  69933. _downscale: ExtractHighlightsPostProcess;
  69934. private _blurX;
  69935. private _blurY;
  69936. private _merge;
  69937. /**
  69938. * The luminance threshold to find bright areas of the image to bloom.
  69939. */
  69940. get threshold(): number;
  69941. set threshold(value: number);
  69942. /**
  69943. * The strength of the bloom.
  69944. */
  69945. get weight(): number;
  69946. set weight(value: number);
  69947. /**
  69948. * Specifies the size of the bloom blur kernel, relative to the final output size
  69949. */
  69950. get kernel(): number;
  69951. set kernel(value: number);
  69952. /**
  69953. * Creates a new instance of @see BloomEffect
  69954. * @param scene The scene the effect belongs to.
  69955. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69956. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69957. * @param bloomWeight The the strength of bloom.
  69958. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69959. * @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)
  69960. */
  69961. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69962. /**
  69963. * Disposes each of the internal effects for a given camera.
  69964. * @param camera The camera to dispose the effect on.
  69965. */
  69966. disposeEffects(camera: Camera): void;
  69967. /**
  69968. * @hidden Internal
  69969. */
  69970. _updateEffects(): void;
  69971. /**
  69972. * Internal
  69973. * @returns if all the contained post processes are ready.
  69974. * @hidden
  69975. */
  69976. _isReady(): boolean;
  69977. }
  69978. }
  69979. declare module BABYLON {
  69980. /** @hidden */
  69981. export var chromaticAberrationPixelShader: {
  69982. name: string;
  69983. shader: string;
  69984. };
  69985. }
  69986. declare module BABYLON {
  69987. /**
  69988. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69989. */
  69990. export class ChromaticAberrationPostProcess extends PostProcess {
  69991. /**
  69992. * The amount of seperation of rgb channels (default: 30)
  69993. */
  69994. aberrationAmount: number;
  69995. /**
  69996. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69997. */
  69998. radialIntensity: number;
  69999. /**
  70000. * 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))
  70001. */
  70002. direction: Vector2;
  70003. /**
  70004. * 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))
  70005. */
  70006. centerPosition: Vector2;
  70007. /** The width of the screen to apply the effect on */
  70008. screenWidth: number;
  70009. /** The height of the screen to apply the effect on */
  70010. screenHeight: number;
  70011. /**
  70012. * Gets a string identifying the name of the class
  70013. * @returns "ChromaticAberrationPostProcess" string
  70014. */
  70015. getClassName(): string;
  70016. /**
  70017. * Creates a new instance ChromaticAberrationPostProcess
  70018. * @param name The name of the effect.
  70019. * @param screenWidth The width of the screen to apply the effect on.
  70020. * @param screenHeight The height of the screen to apply the effect on.
  70021. * @param options The required width/height ratio to downsize to before computing the render pass.
  70022. * @param camera The camera to apply the render pass to.
  70023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70024. * @param engine The engine which the post process will be applied. (default: current engine)
  70025. * @param reusable If the post process can be reused on the same frame. (default: false)
  70026. * @param textureType Type of textures used when performing the post process. (default: 0)
  70027. * @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)
  70028. */
  70029. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70030. /** @hidden */
  70031. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70032. }
  70033. }
  70034. declare module BABYLON {
  70035. /** @hidden */
  70036. export var circleOfConfusionPixelShader: {
  70037. name: string;
  70038. shader: string;
  70039. };
  70040. }
  70041. declare module BABYLON {
  70042. /**
  70043. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70044. */
  70045. export class CircleOfConfusionPostProcess extends PostProcess {
  70046. /**
  70047. * 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.
  70048. */
  70049. lensSize: number;
  70050. /**
  70051. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70052. */
  70053. fStop: number;
  70054. /**
  70055. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70056. */
  70057. focusDistance: number;
  70058. /**
  70059. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70060. */
  70061. focalLength: number;
  70062. /**
  70063. * Gets a string identifying the name of the class
  70064. * @returns "CircleOfConfusionPostProcess" string
  70065. */
  70066. getClassName(): string;
  70067. private _depthTexture;
  70068. /**
  70069. * Creates a new instance CircleOfConfusionPostProcess
  70070. * @param name The name of the effect.
  70071. * @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.
  70072. * @param options The required width/height ratio to downsize to before computing the render pass.
  70073. * @param camera The camera to apply the render pass to.
  70074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70075. * @param engine The engine which the post process will be applied. (default: current engine)
  70076. * @param reusable If the post process can be reused on the same frame. (default: false)
  70077. * @param textureType Type of textures used when performing the post process. (default: 0)
  70078. * @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)
  70079. */
  70080. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70081. /**
  70082. * 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.
  70083. */
  70084. set depthTexture(value: RenderTargetTexture);
  70085. }
  70086. }
  70087. declare module BABYLON {
  70088. /** @hidden */
  70089. export var colorCorrectionPixelShader: {
  70090. name: string;
  70091. shader: string;
  70092. };
  70093. }
  70094. declare module BABYLON {
  70095. /**
  70096. *
  70097. * This post-process allows the modification of rendered colors by using
  70098. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70099. *
  70100. * The object needs to be provided an url to a texture containing the color
  70101. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70102. * Use an image editing software to tweak the LUT to match your needs.
  70103. *
  70104. * For an example of a color LUT, see here:
  70105. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70106. * For explanations on color grading, see here:
  70107. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70108. *
  70109. */
  70110. export class ColorCorrectionPostProcess extends PostProcess {
  70111. private _colorTableTexture;
  70112. /**
  70113. * Gets the color table url used to create the LUT texture
  70114. */
  70115. colorTableUrl: string;
  70116. /**
  70117. * Gets a string identifying the name of the class
  70118. * @returns "ColorCorrectionPostProcess" string
  70119. */
  70120. getClassName(): string;
  70121. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70122. /** @hidden */
  70123. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70124. }
  70125. }
  70126. declare module BABYLON {
  70127. /** @hidden */
  70128. export var convolutionPixelShader: {
  70129. name: string;
  70130. shader: string;
  70131. };
  70132. }
  70133. declare module BABYLON {
  70134. /**
  70135. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70136. * input texture to perform effects such as edge detection or sharpening
  70137. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70138. */
  70139. export class ConvolutionPostProcess extends PostProcess {
  70140. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70141. kernel: number[];
  70142. /**
  70143. * Gets a string identifying the name of the class
  70144. * @returns "ConvolutionPostProcess" string
  70145. */
  70146. getClassName(): string;
  70147. /**
  70148. * Creates a new instance ConvolutionPostProcess
  70149. * @param name The name of the effect.
  70150. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70151. * @param options The required width/height ratio to downsize to before computing the render pass.
  70152. * @param camera The camera to apply the render pass to.
  70153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70154. * @param engine The engine which the post process will be applied. (default: current engine)
  70155. * @param reusable If the post process can be reused on the same frame. (default: false)
  70156. * @param textureType Type of textures used when performing the post process. (default: 0)
  70157. */
  70158. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70159. /** @hidden */
  70160. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70161. /**
  70162. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70163. */
  70164. static EdgeDetect0Kernel: number[];
  70165. /**
  70166. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70167. */
  70168. static EdgeDetect1Kernel: number[];
  70169. /**
  70170. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70171. */
  70172. static EdgeDetect2Kernel: number[];
  70173. /**
  70174. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70175. */
  70176. static SharpenKernel: number[];
  70177. /**
  70178. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70179. */
  70180. static EmbossKernel: number[];
  70181. /**
  70182. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70183. */
  70184. static GaussianKernel: number[];
  70185. }
  70186. }
  70187. declare module BABYLON {
  70188. /**
  70189. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70190. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70191. * based on samples that have a large difference in distance than the center pixel.
  70192. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70193. */
  70194. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70195. /**
  70196. * The direction the blur should be applied
  70197. */
  70198. direction: Vector2;
  70199. /**
  70200. * Gets a string identifying the name of the class
  70201. * @returns "DepthOfFieldBlurPostProcess" string
  70202. */
  70203. getClassName(): string;
  70204. /**
  70205. * Creates a new instance CircleOfConfusionPostProcess
  70206. * @param name The name of the effect.
  70207. * @param scene The scene the effect belongs to.
  70208. * @param direction The direction the blur should be applied.
  70209. * @param kernel The size of the kernel used to blur.
  70210. * @param options The required width/height ratio to downsize to before computing the render pass.
  70211. * @param camera The camera to apply the render pass to.
  70212. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70213. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70215. * @param engine The engine which the post process will be applied. (default: current engine)
  70216. * @param reusable If the post process can be reused on the same frame. (default: false)
  70217. * @param textureType Type of textures used when performing the post process. (default: 0)
  70218. * @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)
  70219. */
  70220. 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);
  70221. }
  70222. }
  70223. declare module BABYLON {
  70224. /** @hidden */
  70225. export var depthOfFieldMergePixelShader: {
  70226. name: string;
  70227. shader: string;
  70228. };
  70229. }
  70230. declare module BABYLON {
  70231. /**
  70232. * Options to be set when merging outputs from the default pipeline.
  70233. */
  70234. export class DepthOfFieldMergePostProcessOptions {
  70235. /**
  70236. * The original image to merge on top of
  70237. */
  70238. originalFromInput: PostProcess;
  70239. /**
  70240. * Parameters to perform the merge of the depth of field effect
  70241. */
  70242. depthOfField?: {
  70243. circleOfConfusion: PostProcess;
  70244. blurSteps: Array<PostProcess>;
  70245. };
  70246. /**
  70247. * Parameters to perform the merge of bloom effect
  70248. */
  70249. bloom?: {
  70250. blurred: PostProcess;
  70251. weight: number;
  70252. };
  70253. }
  70254. /**
  70255. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70256. */
  70257. export class DepthOfFieldMergePostProcess extends PostProcess {
  70258. private blurSteps;
  70259. /**
  70260. * Gets a string identifying the name of the class
  70261. * @returns "DepthOfFieldMergePostProcess" string
  70262. */
  70263. getClassName(): string;
  70264. /**
  70265. * Creates a new instance of DepthOfFieldMergePostProcess
  70266. * @param name The name of the effect.
  70267. * @param originalFromInput Post process which's input will be used for the merge.
  70268. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70269. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70270. * @param options The required width/height ratio to downsize to before computing the render pass.
  70271. * @param camera The camera to apply the render pass to.
  70272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70273. * @param engine The engine which the post process will be applied. (default: current engine)
  70274. * @param reusable If the post process can be reused on the same frame. (default: false)
  70275. * @param textureType Type of textures used when performing the post process. (default: 0)
  70276. * @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)
  70277. */
  70278. 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);
  70279. /**
  70280. * Updates the effect with the current post process compile time values and recompiles the shader.
  70281. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70282. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70283. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70284. * @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
  70285. * @param onCompiled Called when the shader has been compiled.
  70286. * @param onError Called if there is an error when compiling a shader.
  70287. */
  70288. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70289. }
  70290. }
  70291. declare module BABYLON {
  70292. /**
  70293. * Specifies the level of max blur that should be applied when using the depth of field effect
  70294. */
  70295. export enum DepthOfFieldEffectBlurLevel {
  70296. /**
  70297. * Subtle blur
  70298. */
  70299. Low = 0,
  70300. /**
  70301. * Medium blur
  70302. */
  70303. Medium = 1,
  70304. /**
  70305. * Large blur
  70306. */
  70307. High = 2
  70308. }
  70309. /**
  70310. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70311. */
  70312. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70313. private _circleOfConfusion;
  70314. /**
  70315. * @hidden Internal, blurs from high to low
  70316. */
  70317. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70318. private _depthOfFieldBlurY;
  70319. private _dofMerge;
  70320. /**
  70321. * @hidden Internal post processes in depth of field effect
  70322. */
  70323. _effects: Array<PostProcess>;
  70324. /**
  70325. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70326. */
  70327. set focalLength(value: number);
  70328. get focalLength(): number;
  70329. /**
  70330. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70331. */
  70332. set fStop(value: number);
  70333. get fStop(): number;
  70334. /**
  70335. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70336. */
  70337. set focusDistance(value: number);
  70338. get focusDistance(): number;
  70339. /**
  70340. * 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.
  70341. */
  70342. set lensSize(value: number);
  70343. get lensSize(): number;
  70344. /**
  70345. * Creates a new instance DepthOfFieldEffect
  70346. * @param scene The scene the effect belongs to.
  70347. * @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.
  70348. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70349. * @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)
  70350. */
  70351. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70352. /**
  70353. * Get the current class name of the current effet
  70354. * @returns "DepthOfFieldEffect"
  70355. */
  70356. getClassName(): string;
  70357. /**
  70358. * 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.
  70359. */
  70360. set depthTexture(value: RenderTargetTexture);
  70361. /**
  70362. * Disposes each of the internal effects for a given camera.
  70363. * @param camera The camera to dispose the effect on.
  70364. */
  70365. disposeEffects(camera: Camera): void;
  70366. /**
  70367. * @hidden Internal
  70368. */
  70369. _updateEffects(): void;
  70370. /**
  70371. * Internal
  70372. * @returns if all the contained post processes are ready.
  70373. * @hidden
  70374. */
  70375. _isReady(): boolean;
  70376. }
  70377. }
  70378. declare module BABYLON {
  70379. /** @hidden */
  70380. export var displayPassPixelShader: {
  70381. name: string;
  70382. shader: string;
  70383. };
  70384. }
  70385. declare module BABYLON {
  70386. /**
  70387. * DisplayPassPostProcess which produces an output the same as it's input
  70388. */
  70389. export class DisplayPassPostProcess extends PostProcess {
  70390. /**
  70391. * Gets a string identifying the name of the class
  70392. * @returns "DisplayPassPostProcess" string
  70393. */
  70394. getClassName(): string;
  70395. /**
  70396. * Creates the DisplayPassPostProcess
  70397. * @param name The name of the effect.
  70398. * @param options The required width/height ratio to downsize to before computing the render pass.
  70399. * @param camera The camera to apply the render pass to.
  70400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70401. * @param engine The engine which the post process will be applied. (default: current engine)
  70402. * @param reusable If the post process can be reused on the same frame. (default: false)
  70403. */
  70404. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70405. /** @hidden */
  70406. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70407. }
  70408. }
  70409. declare module BABYLON {
  70410. /** @hidden */
  70411. export var filterPixelShader: {
  70412. name: string;
  70413. shader: string;
  70414. };
  70415. }
  70416. declare module BABYLON {
  70417. /**
  70418. * Applies a kernel filter to the image
  70419. */
  70420. export class FilterPostProcess extends PostProcess {
  70421. /** The matrix to be applied to the image */
  70422. kernelMatrix: Matrix;
  70423. /**
  70424. * Gets a string identifying the name of the class
  70425. * @returns "FilterPostProcess" string
  70426. */
  70427. getClassName(): string;
  70428. /**
  70429. *
  70430. * @param name The name of the effect.
  70431. * @param kernelMatrix The matrix to be applied to the image
  70432. * @param options The required width/height ratio to downsize to before computing the render pass.
  70433. * @param camera The camera to apply the render pass to.
  70434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70435. * @param engine The engine which the post process will be applied. (default: current engine)
  70436. * @param reusable If the post process can be reused on the same frame. (default: false)
  70437. */
  70438. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70439. /** @hidden */
  70440. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70441. }
  70442. }
  70443. declare module BABYLON {
  70444. /** @hidden */
  70445. export var fxaaPixelShader: {
  70446. name: string;
  70447. shader: string;
  70448. };
  70449. }
  70450. declare module BABYLON {
  70451. /** @hidden */
  70452. export var fxaaVertexShader: {
  70453. name: string;
  70454. shader: string;
  70455. };
  70456. }
  70457. declare module BABYLON {
  70458. /**
  70459. * Fxaa post process
  70460. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70461. */
  70462. export class FxaaPostProcess extends PostProcess {
  70463. /**
  70464. * Gets a string identifying the name of the class
  70465. * @returns "FxaaPostProcess" string
  70466. */
  70467. getClassName(): string;
  70468. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70469. private _getDefines;
  70470. /** @hidden */
  70471. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70472. }
  70473. }
  70474. declare module BABYLON {
  70475. /** @hidden */
  70476. export var grainPixelShader: {
  70477. name: string;
  70478. shader: string;
  70479. };
  70480. }
  70481. declare module BABYLON {
  70482. /**
  70483. * The GrainPostProcess adds noise to the image at mid luminance levels
  70484. */
  70485. export class GrainPostProcess extends PostProcess {
  70486. /**
  70487. * The intensity of the grain added (default: 30)
  70488. */
  70489. intensity: number;
  70490. /**
  70491. * If the grain should be randomized on every frame
  70492. */
  70493. animated: boolean;
  70494. /**
  70495. * Gets a string identifying the name of the class
  70496. * @returns "GrainPostProcess" string
  70497. */
  70498. getClassName(): string;
  70499. /**
  70500. * Creates a new instance of @see GrainPostProcess
  70501. * @param name The name of the effect.
  70502. * @param options The required width/height ratio to downsize to before computing the render pass.
  70503. * @param camera The camera to apply the render pass to.
  70504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70505. * @param engine The engine which the post process will be applied. (default: current engine)
  70506. * @param reusable If the post process can be reused on the same frame. (default: false)
  70507. * @param textureType Type of textures used when performing the post process. (default: 0)
  70508. * @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)
  70509. */
  70510. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70511. /** @hidden */
  70512. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70513. }
  70514. }
  70515. declare module BABYLON {
  70516. /** @hidden */
  70517. export var highlightsPixelShader: {
  70518. name: string;
  70519. shader: string;
  70520. };
  70521. }
  70522. declare module BABYLON {
  70523. /**
  70524. * Extracts highlights from the image
  70525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70526. */
  70527. export class HighlightsPostProcess extends PostProcess {
  70528. /**
  70529. * Gets a string identifying the name of the class
  70530. * @returns "HighlightsPostProcess" string
  70531. */
  70532. getClassName(): string;
  70533. /**
  70534. * Extracts highlights from the image
  70535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70536. * @param name The name of the effect.
  70537. * @param options The required width/height ratio to downsize to before computing the render pass.
  70538. * @param camera The camera to apply the render pass to.
  70539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70540. * @param engine The engine which the post process will be applied. (default: current engine)
  70541. * @param reusable If the post process can be reused on the same frame. (default: false)
  70542. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70543. */
  70544. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70545. }
  70546. }
  70547. declare module BABYLON {
  70548. /**
  70549. * Contains all parameters needed for the prepass to perform
  70550. * motion blur
  70551. */
  70552. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70553. /**
  70554. * Is motion blur enabled
  70555. */
  70556. enabled: boolean;
  70557. /**
  70558. * Name of the configuration
  70559. */
  70560. name: string;
  70561. /**
  70562. * Textures that should be present in the MRT for this effect to work
  70563. */
  70564. readonly texturesRequired: number[];
  70565. }
  70566. }
  70567. declare module BABYLON {
  70568. interface Scene {
  70569. /** @hidden (Backing field) */
  70570. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70571. /**
  70572. * Gets or Sets the current geometry buffer associated to the scene.
  70573. */
  70574. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70575. /**
  70576. * Enables a GeometryBufferRender and associates it with the scene
  70577. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70578. * @returns the GeometryBufferRenderer
  70579. */
  70580. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70581. /**
  70582. * Disables the GeometryBufferRender associated with the scene
  70583. */
  70584. disableGeometryBufferRenderer(): void;
  70585. }
  70586. /**
  70587. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70588. * in several rendering techniques.
  70589. */
  70590. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70591. /**
  70592. * The component name helpful to identify the component in the list of scene components.
  70593. */
  70594. readonly name: string;
  70595. /**
  70596. * The scene the component belongs to.
  70597. */
  70598. scene: Scene;
  70599. /**
  70600. * Creates a new instance of the component for the given scene
  70601. * @param scene Defines the scene to register the component in
  70602. */
  70603. constructor(scene: Scene);
  70604. /**
  70605. * Registers the component in a given scene
  70606. */
  70607. register(): void;
  70608. /**
  70609. * Rebuilds the elements related to this component in case of
  70610. * context lost for instance.
  70611. */
  70612. rebuild(): void;
  70613. /**
  70614. * Disposes the component and the associated ressources
  70615. */
  70616. dispose(): void;
  70617. private _gatherRenderTargets;
  70618. }
  70619. }
  70620. declare module BABYLON {
  70621. /** @hidden */
  70622. export var motionBlurPixelShader: {
  70623. name: string;
  70624. shader: string;
  70625. };
  70626. }
  70627. declare module BABYLON {
  70628. /**
  70629. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70630. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70631. * As an example, all you have to do is to create the post-process:
  70632. * var mb = new BABYLON.MotionBlurPostProcess(
  70633. * 'mb', // The name of the effect.
  70634. * scene, // The scene containing the objects to blur according to their velocity.
  70635. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70636. * camera // The camera to apply the render pass to.
  70637. * );
  70638. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70639. */
  70640. export class MotionBlurPostProcess extends PostProcess {
  70641. /**
  70642. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70643. */
  70644. motionStrength: number;
  70645. /**
  70646. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70647. */
  70648. get motionBlurSamples(): number;
  70649. /**
  70650. * Sets the number of iterations to be used for motion blur quality
  70651. */
  70652. set motionBlurSamples(samples: number);
  70653. private _motionBlurSamples;
  70654. private _forceGeometryBuffer;
  70655. private _geometryBufferRenderer;
  70656. private _prePassRenderer;
  70657. /**
  70658. * Gets a string identifying the name of the class
  70659. * @returns "MotionBlurPostProcess" string
  70660. */
  70661. getClassName(): string;
  70662. /**
  70663. * Creates a new instance MotionBlurPostProcess
  70664. * @param name The name of the effect.
  70665. * @param scene The scene containing the objects to blur according to their velocity.
  70666. * @param options The required width/height ratio to downsize to before computing the render pass.
  70667. * @param camera The camera to apply the render pass to.
  70668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70669. * @param engine The engine which the post process will be applied. (default: current engine)
  70670. * @param reusable If the post process can be reused on the same frame. (default: false)
  70671. * @param textureType Type of textures used when performing the post process. (default: 0)
  70672. * @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)
  70673. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  70674. */
  70675. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  70676. /**
  70677. * Excludes the given skinned mesh from computing bones velocities.
  70678. * 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.
  70679. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70680. */
  70681. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70682. /**
  70683. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70684. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70685. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70686. */
  70687. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70688. /**
  70689. * Disposes the post process.
  70690. * @param camera The camera to dispose the post process on.
  70691. */
  70692. dispose(camera?: Camera): void;
  70693. /** @hidden */
  70694. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70695. }
  70696. }
  70697. declare module BABYLON {
  70698. /** @hidden */
  70699. export var refractionPixelShader: {
  70700. name: string;
  70701. shader: string;
  70702. };
  70703. }
  70704. declare module BABYLON {
  70705. /**
  70706. * Post process which applies a refractin texture
  70707. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70708. */
  70709. export class RefractionPostProcess extends PostProcess {
  70710. private _refTexture;
  70711. private _ownRefractionTexture;
  70712. /** the base color of the refraction (used to taint the rendering) */
  70713. color: Color3;
  70714. /** simulated refraction depth */
  70715. depth: number;
  70716. /** the coefficient of the base color (0 to remove base color tainting) */
  70717. colorLevel: number;
  70718. /** Gets the url used to load the refraction texture */
  70719. refractionTextureUrl: string;
  70720. /**
  70721. * Gets or sets the refraction texture
  70722. * Please note that you are responsible for disposing the texture if you set it manually
  70723. */
  70724. get refractionTexture(): Texture;
  70725. set refractionTexture(value: Texture);
  70726. /**
  70727. * Gets a string identifying the name of the class
  70728. * @returns "RefractionPostProcess" string
  70729. */
  70730. getClassName(): string;
  70731. /**
  70732. * Initializes the RefractionPostProcess
  70733. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70734. * @param name The name of the effect.
  70735. * @param refractionTextureUrl Url of the refraction texture to use
  70736. * @param color the base color of the refraction (used to taint the rendering)
  70737. * @param depth simulated refraction depth
  70738. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70739. * @param camera The camera to apply the render pass to.
  70740. * @param options The required width/height ratio to downsize to before computing the render pass.
  70741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70742. * @param engine The engine which the post process will be applied. (default: current engine)
  70743. * @param reusable If the post process can be reused on the same frame. (default: false)
  70744. */
  70745. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70746. /**
  70747. * Disposes of the post process
  70748. * @param camera Camera to dispose post process on
  70749. */
  70750. dispose(camera: Camera): void;
  70751. /** @hidden */
  70752. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70753. }
  70754. }
  70755. declare module BABYLON {
  70756. /** @hidden */
  70757. export var sharpenPixelShader: {
  70758. name: string;
  70759. shader: string;
  70760. };
  70761. }
  70762. declare module BABYLON {
  70763. /**
  70764. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70765. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70766. */
  70767. export class SharpenPostProcess extends PostProcess {
  70768. /**
  70769. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70770. */
  70771. colorAmount: number;
  70772. /**
  70773. * How much sharpness should be applied (default: 0.3)
  70774. */
  70775. edgeAmount: number;
  70776. /**
  70777. * Gets a string identifying the name of the class
  70778. * @returns "SharpenPostProcess" string
  70779. */
  70780. getClassName(): string;
  70781. /**
  70782. * Creates a new instance ConvolutionPostProcess
  70783. * @param name The name of the effect.
  70784. * @param options The required width/height ratio to downsize to before computing the render pass.
  70785. * @param camera The camera to apply the render pass to.
  70786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70787. * @param engine The engine which the post process will be applied. (default: current engine)
  70788. * @param reusable If the post process can be reused on the same frame. (default: false)
  70789. * @param textureType Type of textures used when performing the post process. (default: 0)
  70790. * @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)
  70791. */
  70792. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70793. /** @hidden */
  70794. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70795. }
  70796. }
  70797. declare module BABYLON {
  70798. /**
  70799. * PostProcessRenderPipeline
  70800. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70801. */
  70802. export class PostProcessRenderPipeline {
  70803. private engine;
  70804. private _renderEffects;
  70805. private _renderEffectsForIsolatedPass;
  70806. /**
  70807. * List of inspectable custom properties (used by the Inspector)
  70808. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70809. */
  70810. inspectableCustomProperties: IInspectable[];
  70811. /**
  70812. * @hidden
  70813. */
  70814. protected _cameras: Camera[];
  70815. /** @hidden */
  70816. _name: string;
  70817. /**
  70818. * Gets pipeline name
  70819. */
  70820. get name(): string;
  70821. /** Gets the list of attached cameras */
  70822. get cameras(): Camera[];
  70823. /**
  70824. * Initializes a PostProcessRenderPipeline
  70825. * @param engine engine to add the pipeline to
  70826. * @param name name of the pipeline
  70827. */
  70828. constructor(engine: Engine, name: string);
  70829. /**
  70830. * Gets the class name
  70831. * @returns "PostProcessRenderPipeline"
  70832. */
  70833. getClassName(): string;
  70834. /**
  70835. * If all the render effects in the pipeline are supported
  70836. */
  70837. get isSupported(): boolean;
  70838. /**
  70839. * Adds an effect to the pipeline
  70840. * @param renderEffect the effect to add
  70841. */
  70842. addEffect(renderEffect: PostProcessRenderEffect): void;
  70843. /** @hidden */
  70844. _rebuild(): void;
  70845. /** @hidden */
  70846. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70847. /** @hidden */
  70848. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70849. /** @hidden */
  70850. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70851. /** @hidden */
  70852. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70853. /** @hidden */
  70854. _attachCameras(cameras: Camera, unique: boolean): void;
  70855. /** @hidden */
  70856. _attachCameras(cameras: Camera[], unique: boolean): void;
  70857. /** @hidden */
  70858. _detachCameras(cameras: Camera): void;
  70859. /** @hidden */
  70860. _detachCameras(cameras: Nullable<Camera[]>): void;
  70861. /** @hidden */
  70862. _update(): void;
  70863. /** @hidden */
  70864. _reset(): void;
  70865. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70866. /**
  70867. * Sets the required values to the prepass renderer.
  70868. * @param prePassRenderer defines the prepass renderer to setup.
  70869. * @returns true if the pre pass is needed.
  70870. */
  70871. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70872. /**
  70873. * Disposes of the pipeline
  70874. */
  70875. dispose(): void;
  70876. }
  70877. }
  70878. declare module BABYLON {
  70879. /**
  70880. * PostProcessRenderPipelineManager class
  70881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70882. */
  70883. export class PostProcessRenderPipelineManager {
  70884. private _renderPipelines;
  70885. /**
  70886. * Initializes a PostProcessRenderPipelineManager
  70887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70888. */
  70889. constructor();
  70890. /**
  70891. * Gets the list of supported render pipelines
  70892. */
  70893. get supportedPipelines(): PostProcessRenderPipeline[];
  70894. /**
  70895. * Adds a pipeline to the manager
  70896. * @param renderPipeline The pipeline to add
  70897. */
  70898. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70899. /**
  70900. * Attaches a camera to the pipeline
  70901. * @param renderPipelineName The name of the pipeline to attach to
  70902. * @param cameras the camera to attach
  70903. * @param unique if the camera can be attached multiple times to the pipeline
  70904. */
  70905. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70906. /**
  70907. * Detaches a camera from the pipeline
  70908. * @param renderPipelineName The name of the pipeline to detach from
  70909. * @param cameras the camera to detach
  70910. */
  70911. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70912. /**
  70913. * Enables an effect by name on a pipeline
  70914. * @param renderPipelineName the name of the pipeline to enable the effect in
  70915. * @param renderEffectName the name of the effect to enable
  70916. * @param cameras the cameras that the effect should be enabled on
  70917. */
  70918. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70919. /**
  70920. * Disables an effect by name on a pipeline
  70921. * @param renderPipelineName the name of the pipeline to disable the effect in
  70922. * @param renderEffectName the name of the effect to disable
  70923. * @param cameras the cameras that the effect should be disabled on
  70924. */
  70925. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70926. /**
  70927. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70928. */
  70929. update(): void;
  70930. /** @hidden */
  70931. _rebuild(): void;
  70932. /**
  70933. * Disposes of the manager and pipelines
  70934. */
  70935. dispose(): void;
  70936. }
  70937. }
  70938. declare module BABYLON {
  70939. interface Scene {
  70940. /** @hidden (Backing field) */
  70941. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70942. /**
  70943. * Gets the postprocess render pipeline manager
  70944. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70945. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70946. */
  70947. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70948. }
  70949. /**
  70950. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70951. */
  70952. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70953. /**
  70954. * The component name helpfull to identify the component in the list of scene components.
  70955. */
  70956. readonly name: string;
  70957. /**
  70958. * The scene the component belongs to.
  70959. */
  70960. scene: Scene;
  70961. /**
  70962. * Creates a new instance of the component for the given scene
  70963. * @param scene Defines the scene to register the component in
  70964. */
  70965. constructor(scene: Scene);
  70966. /**
  70967. * Registers the component in a given scene
  70968. */
  70969. register(): void;
  70970. /**
  70971. * Rebuilds the elements related to this component in case of
  70972. * context lost for instance.
  70973. */
  70974. rebuild(): void;
  70975. /**
  70976. * Disposes the component and the associated ressources
  70977. */
  70978. dispose(): void;
  70979. private _gatherRenderTargets;
  70980. }
  70981. }
  70982. declare module BABYLON {
  70983. /**
  70984. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70985. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70986. */
  70987. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70988. private _scene;
  70989. private _camerasToBeAttached;
  70990. /**
  70991. * ID of the sharpen post process,
  70992. */
  70993. private readonly SharpenPostProcessId;
  70994. /**
  70995. * @ignore
  70996. * ID of the image processing post process;
  70997. */
  70998. readonly ImageProcessingPostProcessId: string;
  70999. /**
  71000. * @ignore
  71001. * ID of the Fast Approximate Anti-Aliasing post process;
  71002. */
  71003. readonly FxaaPostProcessId: string;
  71004. /**
  71005. * ID of the chromatic aberration post process,
  71006. */
  71007. private readonly ChromaticAberrationPostProcessId;
  71008. /**
  71009. * ID of the grain post process
  71010. */
  71011. private readonly GrainPostProcessId;
  71012. /**
  71013. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71014. */
  71015. sharpen: SharpenPostProcess;
  71016. private _sharpenEffect;
  71017. private bloom;
  71018. /**
  71019. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71020. */
  71021. depthOfField: DepthOfFieldEffect;
  71022. /**
  71023. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71024. */
  71025. fxaa: FxaaPostProcess;
  71026. /**
  71027. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71028. */
  71029. imageProcessing: ImageProcessingPostProcess;
  71030. /**
  71031. * Chromatic aberration post process which will shift rgb colors in the image
  71032. */
  71033. chromaticAberration: ChromaticAberrationPostProcess;
  71034. private _chromaticAberrationEffect;
  71035. /**
  71036. * Grain post process which add noise to the image
  71037. */
  71038. grain: GrainPostProcess;
  71039. private _grainEffect;
  71040. /**
  71041. * Glow post process which adds a glow to emissive areas of the image
  71042. */
  71043. private _glowLayer;
  71044. /**
  71045. * Animations which can be used to tweak settings over a period of time
  71046. */
  71047. animations: Animation[];
  71048. private _imageProcessingConfigurationObserver;
  71049. private _sharpenEnabled;
  71050. private _bloomEnabled;
  71051. private _depthOfFieldEnabled;
  71052. private _depthOfFieldBlurLevel;
  71053. private _fxaaEnabled;
  71054. private _imageProcessingEnabled;
  71055. private _defaultPipelineTextureType;
  71056. private _bloomScale;
  71057. private _chromaticAberrationEnabled;
  71058. private _grainEnabled;
  71059. private _buildAllowed;
  71060. /**
  71061. * Gets active scene
  71062. */
  71063. get scene(): Scene;
  71064. /**
  71065. * Enable or disable the sharpen process from the pipeline
  71066. */
  71067. set sharpenEnabled(enabled: boolean);
  71068. get sharpenEnabled(): boolean;
  71069. private _resizeObserver;
  71070. private _hardwareScaleLevel;
  71071. private _bloomKernel;
  71072. /**
  71073. * Specifies the size of the bloom blur kernel, relative to the final output size
  71074. */
  71075. get bloomKernel(): number;
  71076. set bloomKernel(value: number);
  71077. /**
  71078. * Specifies the weight of the bloom in the final rendering
  71079. */
  71080. private _bloomWeight;
  71081. /**
  71082. * Specifies the luma threshold for the area that will be blurred by the bloom
  71083. */
  71084. private _bloomThreshold;
  71085. private _hdr;
  71086. /**
  71087. * The strength of the bloom.
  71088. */
  71089. set bloomWeight(value: number);
  71090. get bloomWeight(): number;
  71091. /**
  71092. * The strength of the bloom.
  71093. */
  71094. set bloomThreshold(value: number);
  71095. get bloomThreshold(): number;
  71096. /**
  71097. * The scale of the bloom, lower value will provide better performance.
  71098. */
  71099. set bloomScale(value: number);
  71100. get bloomScale(): number;
  71101. /**
  71102. * Enable or disable the bloom from the pipeline
  71103. */
  71104. set bloomEnabled(enabled: boolean);
  71105. get bloomEnabled(): boolean;
  71106. private _rebuildBloom;
  71107. /**
  71108. * If the depth of field is enabled.
  71109. */
  71110. get depthOfFieldEnabled(): boolean;
  71111. set depthOfFieldEnabled(enabled: boolean);
  71112. /**
  71113. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71114. */
  71115. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71116. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71117. /**
  71118. * If the anti aliasing is enabled.
  71119. */
  71120. set fxaaEnabled(enabled: boolean);
  71121. get fxaaEnabled(): boolean;
  71122. private _samples;
  71123. /**
  71124. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71125. */
  71126. set samples(sampleCount: number);
  71127. get samples(): number;
  71128. /**
  71129. * If image processing is enabled.
  71130. */
  71131. set imageProcessingEnabled(enabled: boolean);
  71132. get imageProcessingEnabled(): boolean;
  71133. /**
  71134. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71135. */
  71136. set glowLayerEnabled(enabled: boolean);
  71137. get glowLayerEnabled(): boolean;
  71138. /**
  71139. * Gets the glow layer (or null if not defined)
  71140. */
  71141. get glowLayer(): Nullable<GlowLayer>;
  71142. /**
  71143. * Enable or disable the chromaticAberration process from the pipeline
  71144. */
  71145. set chromaticAberrationEnabled(enabled: boolean);
  71146. get chromaticAberrationEnabled(): boolean;
  71147. /**
  71148. * Enable or disable the grain process from the pipeline
  71149. */
  71150. set grainEnabled(enabled: boolean);
  71151. get grainEnabled(): boolean;
  71152. /**
  71153. * @constructor
  71154. * @param name - The rendering pipeline name (default: "")
  71155. * @param hdr - If high dynamic range textures should be used (default: true)
  71156. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71157. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71158. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71159. */
  71160. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71161. /**
  71162. * Get the class name
  71163. * @returns "DefaultRenderingPipeline"
  71164. */
  71165. getClassName(): string;
  71166. /**
  71167. * Force the compilation of the entire pipeline.
  71168. */
  71169. prepare(): void;
  71170. private _hasCleared;
  71171. private _prevPostProcess;
  71172. private _prevPrevPostProcess;
  71173. private _setAutoClearAndTextureSharing;
  71174. private _depthOfFieldSceneObserver;
  71175. private _buildPipeline;
  71176. private _disposePostProcesses;
  71177. /**
  71178. * Adds a camera to the pipeline
  71179. * @param camera the camera to be added
  71180. */
  71181. addCamera(camera: Camera): void;
  71182. /**
  71183. * Removes a camera from the pipeline
  71184. * @param camera the camera to remove
  71185. */
  71186. removeCamera(camera: Camera): void;
  71187. /**
  71188. * Dispose of the pipeline and stop all post processes
  71189. */
  71190. dispose(): void;
  71191. /**
  71192. * Serialize the rendering pipeline (Used when exporting)
  71193. * @returns the serialized object
  71194. */
  71195. serialize(): any;
  71196. /**
  71197. * Parse the serialized pipeline
  71198. * @param source Source pipeline.
  71199. * @param scene The scene to load the pipeline to.
  71200. * @param rootUrl The URL of the serialized pipeline.
  71201. * @returns An instantiated pipeline from the serialized object.
  71202. */
  71203. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71204. }
  71205. }
  71206. declare module BABYLON {
  71207. /** @hidden */
  71208. export var lensHighlightsPixelShader: {
  71209. name: string;
  71210. shader: string;
  71211. };
  71212. }
  71213. declare module BABYLON {
  71214. /** @hidden */
  71215. export var depthOfFieldPixelShader: {
  71216. name: string;
  71217. shader: string;
  71218. };
  71219. }
  71220. declare module BABYLON {
  71221. /**
  71222. * BABYLON.JS Chromatic Aberration GLSL Shader
  71223. * Author: Olivier Guyot
  71224. * Separates very slightly R, G and B colors on the edges of the screen
  71225. * Inspired by Francois Tarlier & Martins Upitis
  71226. */
  71227. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71228. /**
  71229. * @ignore
  71230. * The chromatic aberration PostProcess id in the pipeline
  71231. */
  71232. LensChromaticAberrationEffect: string;
  71233. /**
  71234. * @ignore
  71235. * The highlights enhancing PostProcess id in the pipeline
  71236. */
  71237. HighlightsEnhancingEffect: string;
  71238. /**
  71239. * @ignore
  71240. * The depth-of-field PostProcess id in the pipeline
  71241. */
  71242. LensDepthOfFieldEffect: string;
  71243. private _scene;
  71244. private _depthTexture;
  71245. private _grainTexture;
  71246. private _chromaticAberrationPostProcess;
  71247. private _highlightsPostProcess;
  71248. private _depthOfFieldPostProcess;
  71249. private _edgeBlur;
  71250. private _grainAmount;
  71251. private _chromaticAberration;
  71252. private _distortion;
  71253. private _highlightsGain;
  71254. private _highlightsThreshold;
  71255. private _dofDistance;
  71256. private _dofAperture;
  71257. private _dofDarken;
  71258. private _dofPentagon;
  71259. private _blurNoise;
  71260. /**
  71261. * @constructor
  71262. *
  71263. * Effect parameters are as follow:
  71264. * {
  71265. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71266. * edge_blur: number; // from 0 to x (1 for realism)
  71267. * distortion: number; // from 0 to x (1 for realism)
  71268. * grain_amount: number; // from 0 to 1
  71269. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71270. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71271. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71272. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71273. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71274. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71275. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71276. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71277. * }
  71278. * Note: if an effect parameter is unset, effect is disabled
  71279. *
  71280. * @param name The rendering pipeline name
  71281. * @param parameters - An object containing all parameters (see above)
  71282. * @param scene The scene linked to this pipeline
  71283. * @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)
  71284. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71285. */
  71286. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71287. /**
  71288. * Get the class name
  71289. * @returns "LensRenderingPipeline"
  71290. */
  71291. getClassName(): string;
  71292. /**
  71293. * Gets associated scene
  71294. */
  71295. get scene(): Scene;
  71296. /**
  71297. * Gets or sets the edge blur
  71298. */
  71299. get edgeBlur(): number;
  71300. set edgeBlur(value: number);
  71301. /**
  71302. * Gets or sets the grain amount
  71303. */
  71304. get grainAmount(): number;
  71305. set grainAmount(value: number);
  71306. /**
  71307. * Gets or sets the chromatic aberration amount
  71308. */
  71309. get chromaticAberration(): number;
  71310. set chromaticAberration(value: number);
  71311. /**
  71312. * Gets or sets the depth of field aperture
  71313. */
  71314. get dofAperture(): number;
  71315. set dofAperture(value: number);
  71316. /**
  71317. * Gets or sets the edge distortion
  71318. */
  71319. get edgeDistortion(): number;
  71320. set edgeDistortion(value: number);
  71321. /**
  71322. * Gets or sets the depth of field distortion
  71323. */
  71324. get dofDistortion(): number;
  71325. set dofDistortion(value: number);
  71326. /**
  71327. * Gets or sets the darken out of focus amount
  71328. */
  71329. get darkenOutOfFocus(): number;
  71330. set darkenOutOfFocus(value: number);
  71331. /**
  71332. * Gets or sets a boolean indicating if blur noise is enabled
  71333. */
  71334. get blurNoise(): boolean;
  71335. set blurNoise(value: boolean);
  71336. /**
  71337. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71338. */
  71339. get pentagonBokeh(): boolean;
  71340. set pentagonBokeh(value: boolean);
  71341. /**
  71342. * Gets or sets the highlight grain amount
  71343. */
  71344. get highlightsGain(): number;
  71345. set highlightsGain(value: number);
  71346. /**
  71347. * Gets or sets the highlight threshold
  71348. */
  71349. get highlightsThreshold(): number;
  71350. set highlightsThreshold(value: number);
  71351. /**
  71352. * Sets the amount of blur at the edges
  71353. * @param amount blur amount
  71354. */
  71355. setEdgeBlur(amount: number): void;
  71356. /**
  71357. * Sets edge blur to 0
  71358. */
  71359. disableEdgeBlur(): void;
  71360. /**
  71361. * Sets the amout of grain
  71362. * @param amount Amount of grain
  71363. */
  71364. setGrainAmount(amount: number): void;
  71365. /**
  71366. * Set grain amount to 0
  71367. */
  71368. disableGrain(): void;
  71369. /**
  71370. * Sets the chromatic aberration amount
  71371. * @param amount amount of chromatic aberration
  71372. */
  71373. setChromaticAberration(amount: number): void;
  71374. /**
  71375. * Sets chromatic aberration amount to 0
  71376. */
  71377. disableChromaticAberration(): void;
  71378. /**
  71379. * Sets the EdgeDistortion amount
  71380. * @param amount amount of EdgeDistortion
  71381. */
  71382. setEdgeDistortion(amount: number): void;
  71383. /**
  71384. * Sets edge distortion to 0
  71385. */
  71386. disableEdgeDistortion(): void;
  71387. /**
  71388. * Sets the FocusDistance amount
  71389. * @param amount amount of FocusDistance
  71390. */
  71391. setFocusDistance(amount: number): void;
  71392. /**
  71393. * Disables depth of field
  71394. */
  71395. disableDepthOfField(): void;
  71396. /**
  71397. * Sets the Aperture amount
  71398. * @param amount amount of Aperture
  71399. */
  71400. setAperture(amount: number): void;
  71401. /**
  71402. * Sets the DarkenOutOfFocus amount
  71403. * @param amount amount of DarkenOutOfFocus
  71404. */
  71405. setDarkenOutOfFocus(amount: number): void;
  71406. private _pentagonBokehIsEnabled;
  71407. /**
  71408. * Creates a pentagon bokeh effect
  71409. */
  71410. enablePentagonBokeh(): void;
  71411. /**
  71412. * Disables the pentagon bokeh effect
  71413. */
  71414. disablePentagonBokeh(): void;
  71415. /**
  71416. * Enables noise blur
  71417. */
  71418. enableNoiseBlur(): void;
  71419. /**
  71420. * Disables noise blur
  71421. */
  71422. disableNoiseBlur(): void;
  71423. /**
  71424. * Sets the HighlightsGain amount
  71425. * @param amount amount of HighlightsGain
  71426. */
  71427. setHighlightsGain(amount: number): void;
  71428. /**
  71429. * Sets the HighlightsThreshold amount
  71430. * @param amount amount of HighlightsThreshold
  71431. */
  71432. setHighlightsThreshold(amount: number): void;
  71433. /**
  71434. * Disables highlights
  71435. */
  71436. disableHighlights(): void;
  71437. /**
  71438. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71439. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71440. */
  71441. dispose(disableDepthRender?: boolean): void;
  71442. private _createChromaticAberrationPostProcess;
  71443. private _createHighlightsPostProcess;
  71444. private _createDepthOfFieldPostProcess;
  71445. private _createGrainTexture;
  71446. }
  71447. }
  71448. declare module BABYLON {
  71449. /**
  71450. * Contains all parameters needed for the prepass to perform
  71451. * screen space subsurface scattering
  71452. */
  71453. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71454. /**
  71455. * Is subsurface enabled
  71456. */
  71457. enabled: boolean;
  71458. /**
  71459. * Name of the configuration
  71460. */
  71461. name: string;
  71462. /**
  71463. * Textures that should be present in the MRT for this effect to work
  71464. */
  71465. readonly texturesRequired: number[];
  71466. }
  71467. }
  71468. declare module BABYLON {
  71469. /** @hidden */
  71470. export var ssao2PixelShader: {
  71471. name: string;
  71472. shader: string;
  71473. };
  71474. }
  71475. declare module BABYLON {
  71476. /** @hidden */
  71477. export var ssaoCombinePixelShader: {
  71478. name: string;
  71479. shader: string;
  71480. };
  71481. }
  71482. declare module BABYLON {
  71483. /**
  71484. * Render pipeline to produce ssao effect
  71485. */
  71486. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71487. /**
  71488. * @ignore
  71489. * The PassPostProcess id in the pipeline that contains the original scene color
  71490. */
  71491. SSAOOriginalSceneColorEffect: string;
  71492. /**
  71493. * @ignore
  71494. * The SSAO PostProcess id in the pipeline
  71495. */
  71496. SSAORenderEffect: string;
  71497. /**
  71498. * @ignore
  71499. * The horizontal blur PostProcess id in the pipeline
  71500. */
  71501. SSAOBlurHRenderEffect: string;
  71502. /**
  71503. * @ignore
  71504. * The vertical blur PostProcess id in the pipeline
  71505. */
  71506. SSAOBlurVRenderEffect: string;
  71507. /**
  71508. * @ignore
  71509. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71510. */
  71511. SSAOCombineRenderEffect: string;
  71512. /**
  71513. * The output strength of the SSAO post-process. Default value is 1.0.
  71514. */
  71515. totalStrength: number;
  71516. /**
  71517. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71518. */
  71519. maxZ: number;
  71520. /**
  71521. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71522. */
  71523. minZAspect: number;
  71524. private _samples;
  71525. /**
  71526. * Number of samples used for the SSAO calculations. Default value is 8
  71527. */
  71528. set samples(n: number);
  71529. get samples(): number;
  71530. private _textureSamples;
  71531. /**
  71532. * Number of samples to use for antialiasing
  71533. */
  71534. set textureSamples(n: number);
  71535. get textureSamples(): number;
  71536. /**
  71537. * Force rendering the geometry through geometry buffer
  71538. */
  71539. private _forceGeometryBuffer;
  71540. /**
  71541. * Ratio object used for SSAO ratio and blur ratio
  71542. */
  71543. private _ratio;
  71544. /**
  71545. * Dynamically generated sphere sampler.
  71546. */
  71547. private _sampleSphere;
  71548. /**
  71549. * Blur filter offsets
  71550. */
  71551. private _samplerOffsets;
  71552. private _expensiveBlur;
  71553. /**
  71554. * If bilateral blur should be used
  71555. */
  71556. set expensiveBlur(b: boolean);
  71557. get expensiveBlur(): boolean;
  71558. /**
  71559. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71560. */
  71561. radius: number;
  71562. /**
  71563. * The base color of the SSAO post-process
  71564. * The final result is "base + ssao" between [0, 1]
  71565. */
  71566. base: number;
  71567. /**
  71568. * Support test.
  71569. */
  71570. static get IsSupported(): boolean;
  71571. private _scene;
  71572. private _randomTexture;
  71573. private _originalColorPostProcess;
  71574. private _ssaoPostProcess;
  71575. private _blurHPostProcess;
  71576. private _blurVPostProcess;
  71577. private _ssaoCombinePostProcess;
  71578. private _prePassRenderer;
  71579. /**
  71580. * Gets active scene
  71581. */
  71582. get scene(): Scene;
  71583. /**
  71584. * @constructor
  71585. * @param name The rendering pipeline name
  71586. * @param scene The scene linked to this pipeline
  71587. * @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 }
  71588. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71589. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71590. */
  71591. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71592. /**
  71593. * Get the class name
  71594. * @returns "SSAO2RenderingPipeline"
  71595. */
  71596. getClassName(): string;
  71597. /**
  71598. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71599. */
  71600. dispose(disableGeometryBufferRenderer?: boolean): void;
  71601. private _createBlurPostProcess;
  71602. /** @hidden */
  71603. _rebuild(): void;
  71604. private _bits;
  71605. private _radicalInverse_VdC;
  71606. private _hammersley;
  71607. private _hemisphereSample_uniform;
  71608. private _generateHemisphere;
  71609. private _getDefinesForSSAO;
  71610. private _createSSAOPostProcess;
  71611. private _createSSAOCombinePostProcess;
  71612. private _createRandomTexture;
  71613. /**
  71614. * Serialize the rendering pipeline (Used when exporting)
  71615. * @returns the serialized object
  71616. */
  71617. serialize(): any;
  71618. /**
  71619. * Parse the serialized pipeline
  71620. * @param source Source pipeline.
  71621. * @param scene The scene to load the pipeline to.
  71622. * @param rootUrl The URL of the serialized pipeline.
  71623. * @returns An instantiated pipeline from the serialized object.
  71624. */
  71625. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71626. }
  71627. }
  71628. declare module BABYLON {
  71629. /** @hidden */
  71630. export var ssaoPixelShader: {
  71631. name: string;
  71632. shader: string;
  71633. };
  71634. }
  71635. declare module BABYLON {
  71636. /**
  71637. * Render pipeline to produce ssao effect
  71638. */
  71639. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71640. /**
  71641. * @ignore
  71642. * The PassPostProcess id in the pipeline that contains the original scene color
  71643. */
  71644. SSAOOriginalSceneColorEffect: string;
  71645. /**
  71646. * @ignore
  71647. * The SSAO PostProcess id in the pipeline
  71648. */
  71649. SSAORenderEffect: string;
  71650. /**
  71651. * @ignore
  71652. * The horizontal blur PostProcess id in the pipeline
  71653. */
  71654. SSAOBlurHRenderEffect: string;
  71655. /**
  71656. * @ignore
  71657. * The vertical blur PostProcess id in the pipeline
  71658. */
  71659. SSAOBlurVRenderEffect: string;
  71660. /**
  71661. * @ignore
  71662. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71663. */
  71664. SSAOCombineRenderEffect: string;
  71665. /**
  71666. * The output strength of the SSAO post-process. Default value is 1.0.
  71667. */
  71668. totalStrength: number;
  71669. /**
  71670. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71671. */
  71672. radius: number;
  71673. /**
  71674. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71675. * Must not be equal to fallOff and superior to fallOff.
  71676. * Default value is 0.0075
  71677. */
  71678. area: number;
  71679. /**
  71680. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71681. * Must not be equal to area and inferior to area.
  71682. * Default value is 0.000001
  71683. */
  71684. fallOff: number;
  71685. /**
  71686. * The base color of the SSAO post-process
  71687. * The final result is "base + ssao" between [0, 1]
  71688. */
  71689. base: number;
  71690. private _scene;
  71691. private _depthTexture;
  71692. private _randomTexture;
  71693. private _originalColorPostProcess;
  71694. private _ssaoPostProcess;
  71695. private _blurHPostProcess;
  71696. private _blurVPostProcess;
  71697. private _ssaoCombinePostProcess;
  71698. private _firstUpdate;
  71699. /**
  71700. * Gets active scene
  71701. */
  71702. get scene(): Scene;
  71703. /**
  71704. * @constructor
  71705. * @param name - The rendering pipeline name
  71706. * @param scene - The scene linked to this pipeline
  71707. * @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 }
  71708. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71709. */
  71710. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71711. /**
  71712. * Get the class name
  71713. * @returns "SSAORenderingPipeline"
  71714. */
  71715. getClassName(): string;
  71716. /**
  71717. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71718. */
  71719. dispose(disableDepthRender?: boolean): void;
  71720. private _createBlurPostProcess;
  71721. /** @hidden */
  71722. _rebuild(): void;
  71723. private _createSSAOPostProcess;
  71724. private _createSSAOCombinePostProcess;
  71725. private _createRandomTexture;
  71726. }
  71727. }
  71728. declare module BABYLON {
  71729. /**
  71730. * Contains all parameters needed for the prepass to perform
  71731. * screen space reflections
  71732. */
  71733. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  71734. /**
  71735. * Is ssr enabled
  71736. */
  71737. enabled: boolean;
  71738. /**
  71739. * Name of the configuration
  71740. */
  71741. name: string;
  71742. /**
  71743. * Textures that should be present in the MRT for this effect to work
  71744. */
  71745. readonly texturesRequired: number[];
  71746. }
  71747. }
  71748. declare module BABYLON {
  71749. /** @hidden */
  71750. export var screenSpaceReflectionPixelShader: {
  71751. name: string;
  71752. shader: string;
  71753. };
  71754. }
  71755. declare module BABYLON {
  71756. /**
  71757. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71758. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71759. */
  71760. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71761. /**
  71762. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71763. */
  71764. threshold: number;
  71765. /**
  71766. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71767. */
  71768. strength: number;
  71769. /**
  71770. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71771. */
  71772. reflectionSpecularFalloffExponent: number;
  71773. /**
  71774. * 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]
  71775. */
  71776. step: number;
  71777. /**
  71778. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71779. */
  71780. roughnessFactor: number;
  71781. private _forceGeometryBuffer;
  71782. private _geometryBufferRenderer;
  71783. private _prePassRenderer;
  71784. private _enableSmoothReflections;
  71785. private _reflectionSamples;
  71786. private _smoothSteps;
  71787. /**
  71788. * Gets a string identifying the name of the class
  71789. * @returns "ScreenSpaceReflectionPostProcess" string
  71790. */
  71791. getClassName(): string;
  71792. /**
  71793. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71794. * @param name The name of the effect.
  71795. * @param scene The scene containing the objects to calculate reflections.
  71796. * @param options The required width/height ratio to downsize to before computing the render pass.
  71797. * @param camera The camera to apply the render pass to.
  71798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71799. * @param engine The engine which the post process will be applied. (default: current engine)
  71800. * @param reusable If the post process can be reused on the same frame. (default: false)
  71801. * @param textureType Type of textures used when performing the post process. (default: 0)
  71802. * @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)
  71803. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71804. */
  71805. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71806. /**
  71807. * Gets wether or not smoothing reflections is enabled.
  71808. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71809. */
  71810. get enableSmoothReflections(): boolean;
  71811. /**
  71812. * Sets wether or not smoothing reflections is enabled.
  71813. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71814. */
  71815. set enableSmoothReflections(enabled: boolean);
  71816. /**
  71817. * Gets the number of samples taken while computing reflections. More samples count is high,
  71818. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71819. */
  71820. get reflectionSamples(): number;
  71821. /**
  71822. * Sets the number of samples taken while computing reflections. More samples count is high,
  71823. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71824. */
  71825. set reflectionSamples(samples: number);
  71826. /**
  71827. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71828. * more the post-process will require GPU power and can generate a drop in FPS.
  71829. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71830. */
  71831. get smoothSteps(): number;
  71832. set smoothSteps(steps: number);
  71833. private _updateEffectDefines;
  71834. /** @hidden */
  71835. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71836. }
  71837. }
  71838. declare module BABYLON {
  71839. /** @hidden */
  71840. export var standardPixelShader: {
  71841. name: string;
  71842. shader: string;
  71843. };
  71844. }
  71845. declare module BABYLON {
  71846. /**
  71847. * Standard rendering pipeline
  71848. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71849. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71850. */
  71851. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71852. /**
  71853. * Public members
  71854. */
  71855. /**
  71856. * Post-process which contains the original scene color before the pipeline applies all the effects
  71857. */
  71858. originalPostProcess: Nullable<PostProcess>;
  71859. /**
  71860. * Post-process used to down scale an image x4
  71861. */
  71862. downSampleX4PostProcess: Nullable<PostProcess>;
  71863. /**
  71864. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71865. */
  71866. brightPassPostProcess: Nullable<PostProcess>;
  71867. /**
  71868. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71869. */
  71870. blurHPostProcesses: PostProcess[];
  71871. /**
  71872. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71873. */
  71874. blurVPostProcesses: PostProcess[];
  71875. /**
  71876. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71877. */
  71878. textureAdderPostProcess: Nullable<PostProcess>;
  71879. /**
  71880. * Post-process used to create volumetric lighting effect
  71881. */
  71882. volumetricLightPostProcess: Nullable<PostProcess>;
  71883. /**
  71884. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71885. */
  71886. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71887. /**
  71888. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71889. */
  71890. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71891. /**
  71892. * Post-process used to merge the volumetric light effect and the real scene color
  71893. */
  71894. volumetricLightMergePostProces: Nullable<PostProcess>;
  71895. /**
  71896. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71897. */
  71898. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71899. /**
  71900. * Base post-process used to calculate the average luminance of the final image for HDR
  71901. */
  71902. luminancePostProcess: Nullable<PostProcess>;
  71903. /**
  71904. * Post-processes used to create down sample post-processes in order to get
  71905. * the average luminance of the final image for HDR
  71906. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71907. */
  71908. luminanceDownSamplePostProcesses: PostProcess[];
  71909. /**
  71910. * Post-process used to create a HDR effect (light adaptation)
  71911. */
  71912. hdrPostProcess: Nullable<PostProcess>;
  71913. /**
  71914. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71915. */
  71916. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71917. /**
  71918. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71919. */
  71920. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71921. /**
  71922. * Post-process used to merge the final HDR post-process and the real scene color
  71923. */
  71924. hdrFinalPostProcess: Nullable<PostProcess>;
  71925. /**
  71926. * Post-process used to create a lens flare effect
  71927. */
  71928. lensFlarePostProcess: Nullable<PostProcess>;
  71929. /**
  71930. * Post-process that merges the result of the lens flare post-process and the real scene color
  71931. */
  71932. lensFlareComposePostProcess: Nullable<PostProcess>;
  71933. /**
  71934. * Post-process used to create a motion blur effect
  71935. */
  71936. motionBlurPostProcess: Nullable<PostProcess>;
  71937. /**
  71938. * Post-process used to create a depth of field effect
  71939. */
  71940. depthOfFieldPostProcess: Nullable<PostProcess>;
  71941. /**
  71942. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71943. */
  71944. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71945. /**
  71946. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71947. */
  71948. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71949. /**
  71950. * Represents the brightness threshold in order to configure the illuminated surfaces
  71951. */
  71952. brightThreshold: number;
  71953. /**
  71954. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71955. */
  71956. blurWidth: number;
  71957. /**
  71958. * Sets if the blur for highlighted surfaces must be only horizontal
  71959. */
  71960. horizontalBlur: boolean;
  71961. /**
  71962. * Gets the overall exposure used by the pipeline
  71963. */
  71964. get exposure(): number;
  71965. /**
  71966. * Sets the overall exposure used by the pipeline
  71967. */
  71968. set exposure(value: number);
  71969. /**
  71970. * Texture used typically to simulate "dirty" on camera lens
  71971. */
  71972. lensTexture: Nullable<Texture>;
  71973. /**
  71974. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71975. */
  71976. volumetricLightCoefficient: number;
  71977. /**
  71978. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71979. */
  71980. volumetricLightPower: number;
  71981. /**
  71982. * Used the set the blur intensity to smooth the volumetric lights
  71983. */
  71984. volumetricLightBlurScale: number;
  71985. /**
  71986. * Light (spot or directional) used to generate the volumetric lights rays
  71987. * The source light must have a shadow generate so the pipeline can get its
  71988. * depth map
  71989. */
  71990. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71991. /**
  71992. * For eye adaptation, represents the minimum luminance the eye can see
  71993. */
  71994. hdrMinimumLuminance: number;
  71995. /**
  71996. * For eye adaptation, represents the decrease luminance speed
  71997. */
  71998. hdrDecreaseRate: number;
  71999. /**
  72000. * For eye adaptation, represents the increase luminance speed
  72001. */
  72002. hdrIncreaseRate: number;
  72003. /**
  72004. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72005. */
  72006. get hdrAutoExposure(): boolean;
  72007. /**
  72008. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72009. */
  72010. set hdrAutoExposure(value: boolean);
  72011. /**
  72012. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72013. */
  72014. lensColorTexture: Nullable<Texture>;
  72015. /**
  72016. * The overall strengh for the lens flare effect
  72017. */
  72018. lensFlareStrength: number;
  72019. /**
  72020. * Dispersion coefficient for lens flare ghosts
  72021. */
  72022. lensFlareGhostDispersal: number;
  72023. /**
  72024. * Main lens flare halo width
  72025. */
  72026. lensFlareHaloWidth: number;
  72027. /**
  72028. * Based on the lens distortion effect, defines how much the lens flare result
  72029. * is distorted
  72030. */
  72031. lensFlareDistortionStrength: number;
  72032. /**
  72033. * Configures the blur intensity used for for lens flare (halo)
  72034. */
  72035. lensFlareBlurWidth: number;
  72036. /**
  72037. * Lens star texture must be used to simulate rays on the flares and is available
  72038. * in the documentation
  72039. */
  72040. lensStarTexture: Nullable<Texture>;
  72041. /**
  72042. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72043. * flare effect by taking account of the dirt texture
  72044. */
  72045. lensFlareDirtTexture: Nullable<Texture>;
  72046. /**
  72047. * Represents the focal length for the depth of field effect
  72048. */
  72049. depthOfFieldDistance: number;
  72050. /**
  72051. * Represents the blur intensity for the blurred part of the depth of field effect
  72052. */
  72053. depthOfFieldBlurWidth: number;
  72054. /**
  72055. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72056. */
  72057. get motionStrength(): number;
  72058. /**
  72059. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72060. */
  72061. set motionStrength(strength: number);
  72062. /**
  72063. * Gets wether or not the motion blur post-process is object based or screen based.
  72064. */
  72065. get objectBasedMotionBlur(): boolean;
  72066. /**
  72067. * Sets wether or not the motion blur post-process should be object based or screen based
  72068. */
  72069. set objectBasedMotionBlur(value: boolean);
  72070. /**
  72071. * List of animations for the pipeline (IAnimatable implementation)
  72072. */
  72073. animations: Animation[];
  72074. /**
  72075. * Private members
  72076. */
  72077. private _scene;
  72078. private _currentDepthOfFieldSource;
  72079. private _basePostProcess;
  72080. private _fixedExposure;
  72081. private _currentExposure;
  72082. private _hdrAutoExposure;
  72083. private _hdrCurrentLuminance;
  72084. private _motionStrength;
  72085. private _isObjectBasedMotionBlur;
  72086. private _floatTextureType;
  72087. private _camerasToBeAttached;
  72088. private _ratio;
  72089. private _bloomEnabled;
  72090. private _depthOfFieldEnabled;
  72091. private _vlsEnabled;
  72092. private _lensFlareEnabled;
  72093. private _hdrEnabled;
  72094. private _motionBlurEnabled;
  72095. private _fxaaEnabled;
  72096. private _screenSpaceReflectionsEnabled;
  72097. private _motionBlurSamples;
  72098. private _volumetricLightStepsCount;
  72099. private _samples;
  72100. /**
  72101. * @ignore
  72102. * Specifies if the bloom pipeline is enabled
  72103. */
  72104. get BloomEnabled(): boolean;
  72105. set BloomEnabled(enabled: boolean);
  72106. /**
  72107. * @ignore
  72108. * Specifies if the depth of field pipeline is enabed
  72109. */
  72110. get DepthOfFieldEnabled(): boolean;
  72111. set DepthOfFieldEnabled(enabled: boolean);
  72112. /**
  72113. * @ignore
  72114. * Specifies if the lens flare pipeline is enabed
  72115. */
  72116. get LensFlareEnabled(): boolean;
  72117. set LensFlareEnabled(enabled: boolean);
  72118. /**
  72119. * @ignore
  72120. * Specifies if the HDR pipeline is enabled
  72121. */
  72122. get HDREnabled(): boolean;
  72123. set HDREnabled(enabled: boolean);
  72124. /**
  72125. * @ignore
  72126. * Specifies if the volumetric lights scattering effect is enabled
  72127. */
  72128. get VLSEnabled(): boolean;
  72129. set VLSEnabled(enabled: boolean);
  72130. /**
  72131. * @ignore
  72132. * Specifies if the motion blur effect is enabled
  72133. */
  72134. get MotionBlurEnabled(): boolean;
  72135. set MotionBlurEnabled(enabled: boolean);
  72136. /**
  72137. * Specifies if anti-aliasing is enabled
  72138. */
  72139. get fxaaEnabled(): boolean;
  72140. set fxaaEnabled(enabled: boolean);
  72141. /**
  72142. * Specifies if screen space reflections are enabled.
  72143. */
  72144. get screenSpaceReflectionsEnabled(): boolean;
  72145. set screenSpaceReflectionsEnabled(enabled: boolean);
  72146. /**
  72147. * Specifies the number of steps used to calculate the volumetric lights
  72148. * Typically in interval [50, 200]
  72149. */
  72150. get volumetricLightStepsCount(): number;
  72151. set volumetricLightStepsCount(count: number);
  72152. /**
  72153. * Specifies the number of samples used for the motion blur effect
  72154. * Typically in interval [16, 64]
  72155. */
  72156. get motionBlurSamples(): number;
  72157. set motionBlurSamples(samples: number);
  72158. /**
  72159. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72160. */
  72161. get samples(): number;
  72162. set samples(sampleCount: number);
  72163. /**
  72164. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72165. * @constructor
  72166. * @param name The rendering pipeline name
  72167. * @param scene The scene linked to this pipeline
  72168. * @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)
  72169. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72170. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72171. */
  72172. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72173. private _buildPipeline;
  72174. private _createDownSampleX4PostProcess;
  72175. private _createBrightPassPostProcess;
  72176. private _createBlurPostProcesses;
  72177. private _createTextureAdderPostProcess;
  72178. private _createVolumetricLightPostProcess;
  72179. private _createLuminancePostProcesses;
  72180. private _createHdrPostProcess;
  72181. private _createLensFlarePostProcess;
  72182. private _createDepthOfFieldPostProcess;
  72183. private _createMotionBlurPostProcess;
  72184. private _getDepthTexture;
  72185. private _disposePostProcesses;
  72186. /**
  72187. * Dispose of the pipeline and stop all post processes
  72188. */
  72189. dispose(): void;
  72190. /**
  72191. * Serialize the rendering pipeline (Used when exporting)
  72192. * @returns the serialized object
  72193. */
  72194. serialize(): any;
  72195. /**
  72196. * Parse the serialized pipeline
  72197. * @param source Source pipeline.
  72198. * @param scene The scene to load the pipeline to.
  72199. * @param rootUrl The URL of the serialized pipeline.
  72200. * @returns An instantiated pipeline from the serialized object.
  72201. */
  72202. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72203. /**
  72204. * Luminance steps
  72205. */
  72206. static LuminanceSteps: number;
  72207. }
  72208. }
  72209. declare module BABYLON {
  72210. /** @hidden */
  72211. export var stereoscopicInterlacePixelShader: {
  72212. name: string;
  72213. shader: string;
  72214. };
  72215. }
  72216. declare module BABYLON {
  72217. /**
  72218. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72219. */
  72220. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72221. private _stepSize;
  72222. private _passedProcess;
  72223. /**
  72224. * Gets a string identifying the name of the class
  72225. * @returns "StereoscopicInterlacePostProcessI" string
  72226. */
  72227. getClassName(): string;
  72228. /**
  72229. * Initializes a StereoscopicInterlacePostProcessI
  72230. * @param name The name of the effect.
  72231. * @param rigCameras The rig cameras to be appled to the post process
  72232. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72233. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72235. * @param engine The engine which the post process will be applied. (default: current engine)
  72236. * @param reusable If the post process can be reused on the same frame. (default: false)
  72237. */
  72238. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72239. }
  72240. /**
  72241. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72242. */
  72243. export class StereoscopicInterlacePostProcess extends PostProcess {
  72244. private _stepSize;
  72245. private _passedProcess;
  72246. /**
  72247. * Gets a string identifying the name of the class
  72248. * @returns "StereoscopicInterlacePostProcess" string
  72249. */
  72250. getClassName(): string;
  72251. /**
  72252. * Initializes a StereoscopicInterlacePostProcess
  72253. * @param name The name of the effect.
  72254. * @param rigCameras The rig cameras to be appled to the post process
  72255. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72257. * @param engine The engine which the post process will be applied. (default: current engine)
  72258. * @param reusable If the post process can be reused on the same frame. (default: false)
  72259. */
  72260. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72261. }
  72262. }
  72263. declare module BABYLON {
  72264. /** @hidden */
  72265. export var tonemapPixelShader: {
  72266. name: string;
  72267. shader: string;
  72268. };
  72269. }
  72270. declare module BABYLON {
  72271. /** Defines operator used for tonemapping */
  72272. export enum TonemappingOperator {
  72273. /** Hable */
  72274. Hable = 0,
  72275. /** Reinhard */
  72276. Reinhard = 1,
  72277. /** HejiDawson */
  72278. HejiDawson = 2,
  72279. /** Photographic */
  72280. Photographic = 3
  72281. }
  72282. /**
  72283. * Defines a post process to apply tone mapping
  72284. */
  72285. export class TonemapPostProcess extends PostProcess {
  72286. private _operator;
  72287. /** Defines the required exposure adjustement */
  72288. exposureAdjustment: number;
  72289. /**
  72290. * Gets a string identifying the name of the class
  72291. * @returns "TonemapPostProcess" string
  72292. */
  72293. getClassName(): string;
  72294. /**
  72295. * Creates a new TonemapPostProcess
  72296. * @param name defines the name of the postprocess
  72297. * @param _operator defines the operator to use
  72298. * @param exposureAdjustment defines the required exposure adjustement
  72299. * @param camera defines the camera to use (can be null)
  72300. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72301. * @param engine defines the hosting engine (can be ignore if camera is set)
  72302. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72303. */
  72304. constructor(name: string, _operator: TonemappingOperator,
  72305. /** Defines the required exposure adjustement */
  72306. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72307. }
  72308. }
  72309. declare module BABYLON {
  72310. /** @hidden */
  72311. export var volumetricLightScatteringPixelShader: {
  72312. name: string;
  72313. shader: string;
  72314. };
  72315. }
  72316. declare module BABYLON {
  72317. /** @hidden */
  72318. export var volumetricLightScatteringPassVertexShader: {
  72319. name: string;
  72320. shader: string;
  72321. };
  72322. }
  72323. declare module BABYLON {
  72324. /** @hidden */
  72325. export var volumetricLightScatteringPassPixelShader: {
  72326. name: string;
  72327. shader: string;
  72328. };
  72329. }
  72330. declare module BABYLON {
  72331. /**
  72332. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72333. */
  72334. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72335. private _volumetricLightScatteringPass;
  72336. private _volumetricLightScatteringRTT;
  72337. private _viewPort;
  72338. private _screenCoordinates;
  72339. private _cachedDefines;
  72340. /**
  72341. * If not undefined, the mesh position is computed from the attached node position
  72342. */
  72343. attachedNode: {
  72344. position: Vector3;
  72345. };
  72346. /**
  72347. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72348. */
  72349. customMeshPosition: Vector3;
  72350. /**
  72351. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72352. */
  72353. useCustomMeshPosition: boolean;
  72354. /**
  72355. * If the post-process should inverse the light scattering direction
  72356. */
  72357. invert: boolean;
  72358. /**
  72359. * The internal mesh used by the post-process
  72360. */
  72361. mesh: Mesh;
  72362. /**
  72363. * @hidden
  72364. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72365. */
  72366. get useDiffuseColor(): boolean;
  72367. set useDiffuseColor(useDiffuseColor: boolean);
  72368. /**
  72369. * Array containing the excluded meshes not rendered in the internal pass
  72370. */
  72371. excludedMeshes: AbstractMesh[];
  72372. /**
  72373. * Controls the overall intensity of the post-process
  72374. */
  72375. exposure: number;
  72376. /**
  72377. * Dissipates each sample's contribution in range [0, 1]
  72378. */
  72379. decay: number;
  72380. /**
  72381. * Controls the overall intensity of each sample
  72382. */
  72383. weight: number;
  72384. /**
  72385. * Controls the density of each sample
  72386. */
  72387. density: number;
  72388. /**
  72389. * @constructor
  72390. * @param name The post-process name
  72391. * @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)
  72392. * @param camera The camera that the post-process will be attached to
  72393. * @param mesh The mesh used to create the light scattering
  72394. * @param samples The post-process quality, default 100
  72395. * @param samplingModeThe post-process filtering mode
  72396. * @param engine The babylon engine
  72397. * @param reusable If the post-process is reusable
  72398. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72399. */
  72400. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72401. /**
  72402. * Returns the string "VolumetricLightScatteringPostProcess"
  72403. * @returns "VolumetricLightScatteringPostProcess"
  72404. */
  72405. getClassName(): string;
  72406. private _isReady;
  72407. /**
  72408. * Sets the new light position for light scattering effect
  72409. * @param position The new custom light position
  72410. */
  72411. setCustomMeshPosition(position: Vector3): void;
  72412. /**
  72413. * Returns the light position for light scattering effect
  72414. * @return Vector3 The custom light position
  72415. */
  72416. getCustomMeshPosition(): Vector3;
  72417. /**
  72418. * Disposes the internal assets and detaches the post-process from the camera
  72419. */
  72420. dispose(camera: Camera): void;
  72421. /**
  72422. * Returns the render target texture used by the post-process
  72423. * @return the render target texture used by the post-process
  72424. */
  72425. getPass(): RenderTargetTexture;
  72426. private _meshExcluded;
  72427. private _createPass;
  72428. private _updateMeshScreenCoordinates;
  72429. /**
  72430. * Creates a default mesh for the Volumeric Light Scattering post-process
  72431. * @param name The mesh name
  72432. * @param scene The scene where to create the mesh
  72433. * @return the default mesh
  72434. */
  72435. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72436. }
  72437. }
  72438. declare module BABYLON {
  72439. /** @hidden */
  72440. export var screenSpaceCurvaturePixelShader: {
  72441. name: string;
  72442. shader: string;
  72443. };
  72444. }
  72445. declare module BABYLON {
  72446. /**
  72447. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72448. */
  72449. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72450. /**
  72451. * Defines how much ridge the curvature effect displays.
  72452. */
  72453. ridge: number;
  72454. /**
  72455. * Defines how much valley the curvature effect displays.
  72456. */
  72457. valley: number;
  72458. private _geometryBufferRenderer;
  72459. /**
  72460. * Gets a string identifying the name of the class
  72461. * @returns "ScreenSpaceCurvaturePostProcess" string
  72462. */
  72463. getClassName(): string;
  72464. /**
  72465. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72466. * @param name The name of the effect.
  72467. * @param scene The scene containing the objects to blur according to their velocity.
  72468. * @param options The required width/height ratio to downsize to before computing the render pass.
  72469. * @param camera The camera to apply the render pass to.
  72470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72471. * @param engine The engine which the post process will be applied. (default: current engine)
  72472. * @param reusable If the post process can be reused on the same frame. (default: false)
  72473. * @param textureType Type of textures used when performing the post process. (default: 0)
  72474. * @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)
  72475. */
  72476. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72477. /**
  72478. * Support test.
  72479. */
  72480. static get IsSupported(): boolean;
  72481. /** @hidden */
  72482. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72483. }
  72484. }
  72485. declare module BABYLON {
  72486. interface Scene {
  72487. /** @hidden (Backing field) */
  72488. _boundingBoxRenderer: BoundingBoxRenderer;
  72489. /** @hidden (Backing field) */
  72490. _forceShowBoundingBoxes: boolean;
  72491. /**
  72492. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72493. */
  72494. forceShowBoundingBoxes: boolean;
  72495. /**
  72496. * Gets the bounding box renderer associated with the scene
  72497. * @returns a BoundingBoxRenderer
  72498. */
  72499. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72500. }
  72501. interface AbstractMesh {
  72502. /** @hidden (Backing field) */
  72503. _showBoundingBox: boolean;
  72504. /**
  72505. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72506. */
  72507. showBoundingBox: boolean;
  72508. }
  72509. /**
  72510. * Component responsible of rendering the bounding box of the meshes in a scene.
  72511. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72512. */
  72513. export class BoundingBoxRenderer implements ISceneComponent {
  72514. /**
  72515. * The component name helpfull to identify the component in the list of scene components.
  72516. */
  72517. readonly name: string;
  72518. /**
  72519. * The scene the component belongs to.
  72520. */
  72521. scene: Scene;
  72522. /**
  72523. * Color of the bounding box lines placed in front of an object
  72524. */
  72525. frontColor: Color3;
  72526. /**
  72527. * Color of the bounding box lines placed behind an object
  72528. */
  72529. backColor: Color3;
  72530. /**
  72531. * Defines if the renderer should show the back lines or not
  72532. */
  72533. showBackLines: boolean;
  72534. /**
  72535. * Observable raised before rendering a bounding box
  72536. */
  72537. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72538. /**
  72539. * Observable raised after rendering a bounding box
  72540. */
  72541. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72542. /**
  72543. * When false, no bounding boxes will be rendered
  72544. */
  72545. enabled: boolean;
  72546. /**
  72547. * @hidden
  72548. */
  72549. renderList: SmartArray<BoundingBox>;
  72550. private _colorShader;
  72551. private _vertexBuffers;
  72552. private _indexBuffer;
  72553. private _fillIndexBuffer;
  72554. private _fillIndexData;
  72555. /**
  72556. * Instantiates a new bounding box renderer in a scene.
  72557. * @param scene the scene the renderer renders in
  72558. */
  72559. constructor(scene: Scene);
  72560. /**
  72561. * Registers the component in a given scene
  72562. */
  72563. register(): void;
  72564. private _evaluateSubMesh;
  72565. private _preActiveMesh;
  72566. private _prepareRessources;
  72567. private _createIndexBuffer;
  72568. /**
  72569. * Rebuilds the elements related to this component in case of
  72570. * context lost for instance.
  72571. */
  72572. rebuild(): void;
  72573. /**
  72574. * @hidden
  72575. */
  72576. reset(): void;
  72577. /**
  72578. * Render the bounding boxes of a specific rendering group
  72579. * @param renderingGroupId defines the rendering group to render
  72580. */
  72581. render(renderingGroupId: number): void;
  72582. /**
  72583. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72584. * @param mesh Define the mesh to render the occlusion bounding box for
  72585. */
  72586. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72587. /**
  72588. * Dispose and release the resources attached to this renderer.
  72589. */
  72590. dispose(): void;
  72591. }
  72592. }
  72593. declare module BABYLON {
  72594. interface Scene {
  72595. /** @hidden (Backing field) */
  72596. _depthRenderer: {
  72597. [id: string]: DepthRenderer;
  72598. };
  72599. /**
  72600. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72601. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72602. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72603. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72604. * @returns the created depth renderer
  72605. */
  72606. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72607. /**
  72608. * Disables a depth renderer for a given camera
  72609. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72610. */
  72611. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72612. }
  72613. /**
  72614. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72615. * in several rendering techniques.
  72616. */
  72617. export class DepthRendererSceneComponent implements ISceneComponent {
  72618. /**
  72619. * The component name helpfull to identify the component in the list of scene components.
  72620. */
  72621. readonly name: string;
  72622. /**
  72623. * The scene the component belongs to.
  72624. */
  72625. scene: Scene;
  72626. /**
  72627. * Creates a new instance of the component for the given scene
  72628. * @param scene Defines the scene to register the component in
  72629. */
  72630. constructor(scene: Scene);
  72631. /**
  72632. * Registers the component in a given scene
  72633. */
  72634. register(): void;
  72635. /**
  72636. * Rebuilds the elements related to this component in case of
  72637. * context lost for instance.
  72638. */
  72639. rebuild(): void;
  72640. /**
  72641. * Disposes the component and the associated ressources
  72642. */
  72643. dispose(): void;
  72644. private _gatherRenderTargets;
  72645. private _gatherActiveCameraRenderTargets;
  72646. }
  72647. }
  72648. declare module BABYLON {
  72649. interface AbstractScene {
  72650. /** @hidden (Backing field) */
  72651. _prePassRenderer: Nullable<PrePassRenderer>;
  72652. /**
  72653. * Gets or Sets the current prepass renderer associated to the scene.
  72654. */
  72655. prePassRenderer: Nullable<PrePassRenderer>;
  72656. /**
  72657. * Enables the prepass and associates it with the scene
  72658. * @returns the PrePassRenderer
  72659. */
  72660. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72661. /**
  72662. * Disables the prepass associated with the scene
  72663. */
  72664. disablePrePassRenderer(): void;
  72665. }
  72666. /**
  72667. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72668. * in several rendering techniques.
  72669. */
  72670. export class PrePassRendererSceneComponent implements ISceneComponent {
  72671. /**
  72672. * The component name helpful to identify the component in the list of scene components.
  72673. */
  72674. readonly name: string;
  72675. /**
  72676. * The scene the component belongs to.
  72677. */
  72678. scene: Scene;
  72679. /**
  72680. * Creates a new instance of the component for the given scene
  72681. * @param scene Defines the scene to register the component in
  72682. */
  72683. constructor(scene: Scene);
  72684. /**
  72685. * Registers the component in a given scene
  72686. */
  72687. register(): void;
  72688. private _beforeCameraDraw;
  72689. private _afterCameraDraw;
  72690. private _beforeClearStage;
  72691. /**
  72692. * Rebuilds the elements related to this component in case of
  72693. * context lost for instance.
  72694. */
  72695. rebuild(): void;
  72696. /**
  72697. * Disposes the component and the associated ressources
  72698. */
  72699. dispose(): void;
  72700. }
  72701. }
  72702. declare module BABYLON {
  72703. /** @hidden */
  72704. export var fibonacci: {
  72705. name: string;
  72706. shader: string;
  72707. };
  72708. }
  72709. declare module BABYLON {
  72710. /** @hidden */
  72711. export var diffusionProfile: {
  72712. name: string;
  72713. shader: string;
  72714. };
  72715. }
  72716. declare module BABYLON {
  72717. /** @hidden */
  72718. export var subSurfaceScatteringPixelShader: {
  72719. name: string;
  72720. shader: string;
  72721. };
  72722. }
  72723. declare module BABYLON {
  72724. /**
  72725. * Sub surface scattering post process
  72726. */
  72727. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72728. /**
  72729. * Gets a string identifying the name of the class
  72730. * @returns "SubSurfaceScatteringPostProcess" string
  72731. */
  72732. getClassName(): string;
  72733. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72734. }
  72735. }
  72736. declare module BABYLON {
  72737. /**
  72738. * Contains all parameters needed for the prepass to perform
  72739. * screen space subsurface scattering
  72740. */
  72741. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72742. /** @hidden */
  72743. static _SceneComponentInitialization: (scene: Scene) => void;
  72744. private _ssDiffusionS;
  72745. private _ssFilterRadii;
  72746. private _ssDiffusionD;
  72747. /**
  72748. * Post process to attach for screen space subsurface scattering
  72749. */
  72750. postProcess: SubSurfaceScatteringPostProcess;
  72751. /**
  72752. * Diffusion profile color for subsurface scattering
  72753. */
  72754. get ssDiffusionS(): number[];
  72755. /**
  72756. * Diffusion profile max color channel value for subsurface scattering
  72757. */
  72758. get ssDiffusionD(): number[];
  72759. /**
  72760. * Diffusion profile filter radius for subsurface scattering
  72761. */
  72762. get ssFilterRadii(): number[];
  72763. /**
  72764. * Is subsurface enabled
  72765. */
  72766. enabled: boolean;
  72767. /**
  72768. * Name of the configuration
  72769. */
  72770. name: string;
  72771. /**
  72772. * Diffusion profile colors for subsurface scattering
  72773. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72774. * See ...
  72775. * Note that you can only store up to 5 of them
  72776. */
  72777. ssDiffusionProfileColors: Color3[];
  72778. /**
  72779. * Defines the ratio real world => scene units.
  72780. * Used for subsurface scattering
  72781. */
  72782. metersPerUnit: number;
  72783. /**
  72784. * Textures that should be present in the MRT for this effect to work
  72785. */
  72786. readonly texturesRequired: number[];
  72787. private _scene;
  72788. /**
  72789. * Builds a subsurface configuration object
  72790. * @param scene The scene
  72791. */
  72792. constructor(scene: Scene);
  72793. /**
  72794. * Adds a new diffusion profile.
  72795. * Useful for more realistic subsurface scattering on diverse materials.
  72796. * @param color The color of the diffusion profile. Should be the average color of the material.
  72797. * @return The index of the diffusion profile for the material subsurface configuration
  72798. */
  72799. addDiffusionProfile(color: Color3): number;
  72800. /**
  72801. * Creates the sss post process
  72802. * @return The created post process
  72803. */
  72804. createPostProcess(): SubSurfaceScatteringPostProcess;
  72805. /**
  72806. * Deletes all diffusion profiles.
  72807. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72808. */
  72809. clearAllDiffusionProfiles(): void;
  72810. /**
  72811. * Disposes this object
  72812. */
  72813. dispose(): void;
  72814. /**
  72815. * @hidden
  72816. * https://zero-radiance.github.io/post/sampling-diffusion/
  72817. *
  72818. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72819. * ------------------------------------------------------------------------------------
  72820. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72821. * PDF[r, phi, s] = r * R[r, phi, s]
  72822. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72823. * ------------------------------------------------------------------------------------
  72824. * We importance sample the color channel with the widest scattering distance.
  72825. */
  72826. getDiffusionProfileParameters(color: Color3): number;
  72827. /**
  72828. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72829. * 'u' is the random number (the value of the CDF): [0, 1).
  72830. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72831. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72832. */
  72833. private _sampleBurleyDiffusionProfile;
  72834. }
  72835. }
  72836. declare module BABYLON {
  72837. interface AbstractScene {
  72838. /** @hidden (Backing field) */
  72839. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72840. /**
  72841. * Gets or Sets the current prepass renderer associated to the scene.
  72842. */
  72843. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72844. /**
  72845. * Enables the subsurface effect for prepass
  72846. * @returns the SubSurfaceConfiguration
  72847. */
  72848. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72849. /**
  72850. * Disables the subsurface effect for prepass
  72851. */
  72852. disableSubSurfaceForPrePass(): void;
  72853. }
  72854. /**
  72855. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72856. * in several rendering techniques.
  72857. */
  72858. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72859. /**
  72860. * The component name helpful to identify the component in the list of scene components.
  72861. */
  72862. readonly name: string;
  72863. /**
  72864. * The scene the component belongs to.
  72865. */
  72866. scene: Scene;
  72867. /**
  72868. * Creates a new instance of the component for the given scene
  72869. * @param scene Defines the scene to register the component in
  72870. */
  72871. constructor(scene: Scene);
  72872. /**
  72873. * Registers the component in a given scene
  72874. */
  72875. register(): void;
  72876. /**
  72877. * Serializes the component data to the specified json object
  72878. * @param serializationObject The object to serialize to
  72879. */
  72880. serialize(serializationObject: any): void;
  72881. /**
  72882. * Adds all the elements from the container to the scene
  72883. * @param container the container holding the elements
  72884. */
  72885. addFromContainer(container: AbstractScene): void;
  72886. /**
  72887. * Removes all the elements in the container from the scene
  72888. * @param container contains the elements to remove
  72889. * @param dispose if the removed element should be disposed (default: false)
  72890. */
  72891. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72892. /**
  72893. * Rebuilds the elements related to this component in case of
  72894. * context lost for instance.
  72895. */
  72896. rebuild(): void;
  72897. /**
  72898. * Disposes the component and the associated ressources
  72899. */
  72900. dispose(): void;
  72901. }
  72902. }
  72903. declare module BABYLON {
  72904. /** @hidden */
  72905. export var outlinePixelShader: {
  72906. name: string;
  72907. shader: string;
  72908. };
  72909. }
  72910. declare module BABYLON {
  72911. /** @hidden */
  72912. export var outlineVertexShader: {
  72913. name: string;
  72914. shader: string;
  72915. };
  72916. }
  72917. declare module BABYLON {
  72918. interface Scene {
  72919. /** @hidden */
  72920. _outlineRenderer: OutlineRenderer;
  72921. /**
  72922. * Gets the outline renderer associated with the scene
  72923. * @returns a OutlineRenderer
  72924. */
  72925. getOutlineRenderer(): OutlineRenderer;
  72926. }
  72927. interface AbstractMesh {
  72928. /** @hidden (Backing field) */
  72929. _renderOutline: boolean;
  72930. /**
  72931. * Gets or sets a boolean indicating if the outline must be rendered as well
  72932. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72933. */
  72934. renderOutline: boolean;
  72935. /** @hidden (Backing field) */
  72936. _renderOverlay: boolean;
  72937. /**
  72938. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72939. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72940. */
  72941. renderOverlay: boolean;
  72942. }
  72943. /**
  72944. * This class is responsible to draw bothe outline/overlay of meshes.
  72945. * It should not be used directly but through the available method on mesh.
  72946. */
  72947. export class OutlineRenderer implements ISceneComponent {
  72948. /**
  72949. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72950. */
  72951. private static _StencilReference;
  72952. /**
  72953. * The name of the component. Each component must have a unique name.
  72954. */
  72955. name: string;
  72956. /**
  72957. * The scene the component belongs to.
  72958. */
  72959. scene: Scene;
  72960. /**
  72961. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72962. */
  72963. zOffset: number;
  72964. private _engine;
  72965. private _effect;
  72966. private _cachedDefines;
  72967. private _savedDepthWrite;
  72968. /**
  72969. * Instantiates a new outline renderer. (There could be only one per scene).
  72970. * @param scene Defines the scene it belongs to
  72971. */
  72972. constructor(scene: Scene);
  72973. /**
  72974. * Register the component to one instance of a scene.
  72975. */
  72976. register(): void;
  72977. /**
  72978. * Rebuilds the elements related to this component in case of
  72979. * context lost for instance.
  72980. */
  72981. rebuild(): void;
  72982. /**
  72983. * Disposes the component and the associated ressources.
  72984. */
  72985. dispose(): void;
  72986. /**
  72987. * Renders the outline in the canvas.
  72988. * @param subMesh Defines the sumesh to render
  72989. * @param batch Defines the batch of meshes in case of instances
  72990. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72991. */
  72992. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72993. /**
  72994. * Returns whether or not the outline renderer is ready for a given submesh.
  72995. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72996. * @param subMesh Defines the submesh to check readyness for
  72997. * @param useInstances Defines wheter wee are trying to render instances or not
  72998. * @returns true if ready otherwise false
  72999. */
  73000. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73001. private _beforeRenderingMesh;
  73002. private _afterRenderingMesh;
  73003. }
  73004. }
  73005. declare module BABYLON {
  73006. /**
  73007. * Defines the basic options interface of a Sprite Frame Source Size.
  73008. */
  73009. export interface ISpriteJSONSpriteSourceSize {
  73010. /**
  73011. * number of the original width of the Frame
  73012. */
  73013. w: number;
  73014. /**
  73015. * number of the original height of the Frame
  73016. */
  73017. h: number;
  73018. }
  73019. /**
  73020. * Defines the basic options interface of a Sprite Frame Data.
  73021. */
  73022. export interface ISpriteJSONSpriteFrameData {
  73023. /**
  73024. * number of the x offset of the Frame
  73025. */
  73026. x: number;
  73027. /**
  73028. * number of the y offset of the Frame
  73029. */
  73030. y: number;
  73031. /**
  73032. * number of the width of the Frame
  73033. */
  73034. w: number;
  73035. /**
  73036. * number of the height of the Frame
  73037. */
  73038. h: number;
  73039. }
  73040. /**
  73041. * Defines the basic options interface of a JSON Sprite.
  73042. */
  73043. export interface ISpriteJSONSprite {
  73044. /**
  73045. * string name of the Frame
  73046. */
  73047. filename: string;
  73048. /**
  73049. * ISpriteJSONSpriteFrame basic object of the frame data
  73050. */
  73051. frame: ISpriteJSONSpriteFrameData;
  73052. /**
  73053. * boolean to flag is the frame was rotated.
  73054. */
  73055. rotated: boolean;
  73056. /**
  73057. * boolean to flag is the frame was trimmed.
  73058. */
  73059. trimmed: boolean;
  73060. /**
  73061. * ISpriteJSONSpriteFrame basic object of the source data
  73062. */
  73063. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73064. /**
  73065. * ISpriteJSONSpriteFrame basic object of the source data
  73066. */
  73067. sourceSize: ISpriteJSONSpriteSourceSize;
  73068. }
  73069. /**
  73070. * Defines the basic options interface of a JSON atlas.
  73071. */
  73072. export interface ISpriteJSONAtlas {
  73073. /**
  73074. * Array of objects that contain the frame data.
  73075. */
  73076. frames: Array<ISpriteJSONSprite>;
  73077. /**
  73078. * object basic object containing the sprite meta data.
  73079. */
  73080. meta?: object;
  73081. }
  73082. }
  73083. declare module BABYLON {
  73084. /** @hidden */
  73085. export var spriteMapPixelShader: {
  73086. name: string;
  73087. shader: string;
  73088. };
  73089. }
  73090. declare module BABYLON {
  73091. /** @hidden */
  73092. export var spriteMapVertexShader: {
  73093. name: string;
  73094. shader: string;
  73095. };
  73096. }
  73097. declare module BABYLON {
  73098. /**
  73099. * Defines the basic options interface of a SpriteMap
  73100. */
  73101. export interface ISpriteMapOptions {
  73102. /**
  73103. * Vector2 of the number of cells in the grid.
  73104. */
  73105. stageSize?: Vector2;
  73106. /**
  73107. * Vector2 of the size of the output plane in World Units.
  73108. */
  73109. outputSize?: Vector2;
  73110. /**
  73111. * Vector3 of the position of the output plane in World Units.
  73112. */
  73113. outputPosition?: Vector3;
  73114. /**
  73115. * Vector3 of the rotation of the output plane.
  73116. */
  73117. outputRotation?: Vector3;
  73118. /**
  73119. * number of layers that the system will reserve in resources.
  73120. */
  73121. layerCount?: number;
  73122. /**
  73123. * number of max animation frames a single cell will reserve in resources.
  73124. */
  73125. maxAnimationFrames?: number;
  73126. /**
  73127. * number cell index of the base tile when the system compiles.
  73128. */
  73129. baseTile?: number;
  73130. /**
  73131. * boolean flip the sprite after its been repositioned by the framing data.
  73132. */
  73133. flipU?: boolean;
  73134. /**
  73135. * Vector3 scalar of the global RGB values of the SpriteMap.
  73136. */
  73137. colorMultiply?: Vector3;
  73138. }
  73139. /**
  73140. * Defines the IDisposable interface in order to be cleanable from resources.
  73141. */
  73142. export interface ISpriteMap extends IDisposable {
  73143. /**
  73144. * String name of the SpriteMap.
  73145. */
  73146. name: string;
  73147. /**
  73148. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73149. */
  73150. atlasJSON: ISpriteJSONAtlas;
  73151. /**
  73152. * Texture of the SpriteMap.
  73153. */
  73154. spriteSheet: Texture;
  73155. /**
  73156. * The parameters to initialize the SpriteMap with.
  73157. */
  73158. options: ISpriteMapOptions;
  73159. }
  73160. /**
  73161. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73162. */
  73163. export class SpriteMap implements ISpriteMap {
  73164. /** The Name of the spriteMap */
  73165. name: string;
  73166. /** The JSON file with the frame and meta data */
  73167. atlasJSON: ISpriteJSONAtlas;
  73168. /** The systems Sprite Sheet Texture */
  73169. spriteSheet: Texture;
  73170. /** Arguments passed with the Constructor */
  73171. options: ISpriteMapOptions;
  73172. /** Public Sprite Storage array, parsed from atlasJSON */
  73173. sprites: Array<ISpriteJSONSprite>;
  73174. /** Returns the Number of Sprites in the System */
  73175. get spriteCount(): number;
  73176. /** Returns the Position of Output Plane*/
  73177. get position(): Vector3;
  73178. /** Returns the Position of Output Plane*/
  73179. set position(v: Vector3);
  73180. /** Returns the Rotation of Output Plane*/
  73181. get rotation(): Vector3;
  73182. /** Returns the Rotation of Output Plane*/
  73183. set rotation(v: Vector3);
  73184. /** Sets the AnimationMap*/
  73185. get animationMap(): RawTexture;
  73186. /** Sets the AnimationMap*/
  73187. set animationMap(v: RawTexture);
  73188. /** Scene that the SpriteMap was created in */
  73189. private _scene;
  73190. /** Texture Buffer of Float32 that holds tile frame data*/
  73191. private _frameMap;
  73192. /** Texture Buffers of Float32 that holds tileMap data*/
  73193. private _tileMaps;
  73194. /** Texture Buffer of Float32 that holds Animation Data*/
  73195. private _animationMap;
  73196. /** Custom ShaderMaterial Central to the System*/
  73197. private _material;
  73198. /** Custom ShaderMaterial Central to the System*/
  73199. private _output;
  73200. /** Systems Time Ticker*/
  73201. private _time;
  73202. /**
  73203. * Creates a new SpriteMap
  73204. * @param name defines the SpriteMaps Name
  73205. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73206. * @param spriteSheet is the Texture that the Sprites are on.
  73207. * @param options a basic deployment configuration
  73208. * @param scene The Scene that the map is deployed on
  73209. */
  73210. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73211. /**
  73212. * Returns tileID location
  73213. * @returns Vector2 the cell position ID
  73214. */
  73215. getTileID(): Vector2;
  73216. /**
  73217. * Gets the UV location of the mouse over the SpriteMap.
  73218. * @returns Vector2 the UV position of the mouse interaction
  73219. */
  73220. getMousePosition(): Vector2;
  73221. /**
  73222. * Creates the "frame" texture Buffer
  73223. * -------------------------------------
  73224. * Structure of frames
  73225. * "filename": "Falling-Water-2.png",
  73226. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73227. * "rotated": true,
  73228. * "trimmed": true,
  73229. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73230. * "sourceSize": {"w":32,"h":32}
  73231. * @returns RawTexture of the frameMap
  73232. */
  73233. private _createFrameBuffer;
  73234. /**
  73235. * Creates the tileMap texture Buffer
  73236. * @param buffer normally and array of numbers, or a false to generate from scratch
  73237. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73238. * @returns RawTexture of the tileMap
  73239. */
  73240. private _createTileBuffer;
  73241. /**
  73242. * Modifies the data of the tileMaps
  73243. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73244. * @param pos is the iVector2 Coordinates of the Tile
  73245. * @param tile The SpriteIndex of the new Tile
  73246. */
  73247. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73248. /**
  73249. * Creates the animationMap texture Buffer
  73250. * @param buffer normally and array of numbers, or a false to generate from scratch
  73251. * @returns RawTexture of the animationMap
  73252. */
  73253. private _createTileAnimationBuffer;
  73254. /**
  73255. * Modifies the data of the animationMap
  73256. * @param cellID is the Index of the Sprite
  73257. * @param _frame is the target Animation frame
  73258. * @param toCell is the Target Index of the next frame of the animation
  73259. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73260. * @param speed is a global scalar of the time variable on the map.
  73261. */
  73262. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73263. /**
  73264. * Exports the .tilemaps file
  73265. */
  73266. saveTileMaps(): void;
  73267. /**
  73268. * Imports the .tilemaps file
  73269. * @param url of the .tilemaps file
  73270. */
  73271. loadTileMaps(url: string): void;
  73272. /**
  73273. * Release associated resources
  73274. */
  73275. dispose(): void;
  73276. }
  73277. }
  73278. declare module BABYLON {
  73279. /**
  73280. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73281. * @see https://doc.babylonjs.com/babylon101/sprites
  73282. */
  73283. export class SpritePackedManager extends SpriteManager {
  73284. /** defines the packed manager's name */
  73285. name: string;
  73286. /**
  73287. * Creates a new sprite manager from a packed sprite sheet
  73288. * @param name defines the manager's name
  73289. * @param imgUrl defines the sprite sheet url
  73290. * @param capacity defines the maximum allowed number of sprites
  73291. * @param scene defines the hosting scene
  73292. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73293. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73294. * @param samplingMode defines the smapling mode to use with spritesheet
  73295. * @param fromPacked set to true; do not alter
  73296. */
  73297. constructor(
  73298. /** defines the packed manager's name */
  73299. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73300. }
  73301. }
  73302. declare module BABYLON {
  73303. /**
  73304. * Defines the list of states available for a task inside a AssetsManager
  73305. */
  73306. export enum AssetTaskState {
  73307. /**
  73308. * Initialization
  73309. */
  73310. INIT = 0,
  73311. /**
  73312. * Running
  73313. */
  73314. RUNNING = 1,
  73315. /**
  73316. * Done
  73317. */
  73318. DONE = 2,
  73319. /**
  73320. * Error
  73321. */
  73322. ERROR = 3
  73323. }
  73324. /**
  73325. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73326. */
  73327. export abstract class AbstractAssetTask {
  73328. /**
  73329. * Task name
  73330. */ name: string;
  73331. /**
  73332. * Callback called when the task is successful
  73333. */
  73334. onSuccess: (task: any) => void;
  73335. /**
  73336. * Callback called when the task is not successful
  73337. */
  73338. onError: (task: any, message?: string, exception?: any) => void;
  73339. /**
  73340. * Creates a new AssetsManager
  73341. * @param name defines the name of the task
  73342. */
  73343. constructor(
  73344. /**
  73345. * Task name
  73346. */ name: string);
  73347. private _isCompleted;
  73348. private _taskState;
  73349. private _errorObject;
  73350. /**
  73351. * Get if the task is completed
  73352. */
  73353. get isCompleted(): boolean;
  73354. /**
  73355. * Gets the current state of the task
  73356. */
  73357. get taskState(): AssetTaskState;
  73358. /**
  73359. * Gets the current error object (if task is in error)
  73360. */
  73361. get errorObject(): {
  73362. message?: string;
  73363. exception?: any;
  73364. };
  73365. /**
  73366. * Internal only
  73367. * @hidden
  73368. */
  73369. _setErrorObject(message?: string, exception?: any): void;
  73370. /**
  73371. * Execute the current task
  73372. * @param scene defines the scene where you want your assets to be loaded
  73373. * @param onSuccess is a callback called when the task is successfully executed
  73374. * @param onError is a callback called if an error occurs
  73375. */
  73376. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73377. /**
  73378. * Execute the current task
  73379. * @param scene defines the scene where you want your assets to be loaded
  73380. * @param onSuccess is a callback called when the task is successfully executed
  73381. * @param onError is a callback called if an error occurs
  73382. */
  73383. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73384. /**
  73385. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73386. * This can be used with failed tasks that have the reason for failure fixed.
  73387. */
  73388. reset(): void;
  73389. private onErrorCallback;
  73390. private onDoneCallback;
  73391. }
  73392. /**
  73393. * Define the interface used by progress events raised during assets loading
  73394. */
  73395. export interface IAssetsProgressEvent {
  73396. /**
  73397. * Defines the number of remaining tasks to process
  73398. */
  73399. remainingCount: number;
  73400. /**
  73401. * Defines the total number of tasks
  73402. */
  73403. totalCount: number;
  73404. /**
  73405. * Defines the task that was just processed
  73406. */
  73407. task: AbstractAssetTask;
  73408. }
  73409. /**
  73410. * Class used to share progress information about assets loading
  73411. */
  73412. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73413. /**
  73414. * Defines the number of remaining tasks to process
  73415. */
  73416. remainingCount: number;
  73417. /**
  73418. * Defines the total number of tasks
  73419. */
  73420. totalCount: number;
  73421. /**
  73422. * Defines the task that was just processed
  73423. */
  73424. task: AbstractAssetTask;
  73425. /**
  73426. * Creates a AssetsProgressEvent
  73427. * @param remainingCount defines the number of remaining tasks to process
  73428. * @param totalCount defines the total number of tasks
  73429. * @param task defines the task that was just processed
  73430. */
  73431. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73432. }
  73433. /**
  73434. * Define a task used by AssetsManager to load assets into a container
  73435. */
  73436. export class ContainerAssetTask extends AbstractAssetTask {
  73437. /**
  73438. * Defines the name of the task
  73439. */
  73440. name: string;
  73441. /**
  73442. * Defines the list of mesh's names you want to load
  73443. */
  73444. meshesNames: any;
  73445. /**
  73446. * Defines the root url to use as a base to load your meshes and associated resources
  73447. */
  73448. rootUrl: string;
  73449. /**
  73450. * Defines the filename or File of the scene to load from
  73451. */
  73452. sceneFilename: string | File;
  73453. /**
  73454. * Get the loaded asset container
  73455. */
  73456. loadedContainer: AssetContainer;
  73457. /**
  73458. * Gets the list of loaded meshes
  73459. */
  73460. loadedMeshes: Array<AbstractMesh>;
  73461. /**
  73462. * Gets the list of loaded particle systems
  73463. */
  73464. loadedParticleSystems: Array<IParticleSystem>;
  73465. /**
  73466. * Gets the list of loaded skeletons
  73467. */
  73468. loadedSkeletons: Array<Skeleton>;
  73469. /**
  73470. * Gets the list of loaded animation groups
  73471. */
  73472. loadedAnimationGroups: Array<AnimationGroup>;
  73473. /**
  73474. * Callback called when the task is successful
  73475. */
  73476. onSuccess: (task: ContainerAssetTask) => void;
  73477. /**
  73478. * Callback called when the task is successful
  73479. */
  73480. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73481. /**
  73482. * Creates a new ContainerAssetTask
  73483. * @param name defines the name of the task
  73484. * @param meshesNames defines the list of mesh's names you want to load
  73485. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73486. * @param sceneFilename defines the filename or File of the scene to load from
  73487. */
  73488. constructor(
  73489. /**
  73490. * Defines the name of the task
  73491. */
  73492. name: string,
  73493. /**
  73494. * Defines the list of mesh's names you want to load
  73495. */
  73496. meshesNames: any,
  73497. /**
  73498. * Defines the root url to use as a base to load your meshes and associated resources
  73499. */
  73500. rootUrl: string,
  73501. /**
  73502. * Defines the filename or File of the scene to load from
  73503. */
  73504. sceneFilename: string | File);
  73505. /**
  73506. * Execute the current task
  73507. * @param scene defines the scene where you want your assets to be loaded
  73508. * @param onSuccess is a callback called when the task is successfully executed
  73509. * @param onError is a callback called if an error occurs
  73510. */
  73511. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73512. }
  73513. /**
  73514. * Define a task used by AssetsManager to load meshes
  73515. */
  73516. export class MeshAssetTask extends AbstractAssetTask {
  73517. /**
  73518. * Defines the name of the task
  73519. */
  73520. name: string;
  73521. /**
  73522. * Defines the list of mesh's names you want to load
  73523. */
  73524. meshesNames: any;
  73525. /**
  73526. * Defines the root url to use as a base to load your meshes and associated resources
  73527. */
  73528. rootUrl: string;
  73529. /**
  73530. * Defines the filename or File of the scene to load from
  73531. */
  73532. sceneFilename: string | File;
  73533. /**
  73534. * Gets the list of loaded meshes
  73535. */
  73536. loadedMeshes: Array<AbstractMesh>;
  73537. /**
  73538. * Gets the list of loaded particle systems
  73539. */
  73540. loadedParticleSystems: Array<IParticleSystem>;
  73541. /**
  73542. * Gets the list of loaded skeletons
  73543. */
  73544. loadedSkeletons: Array<Skeleton>;
  73545. /**
  73546. * Gets the list of loaded animation groups
  73547. */
  73548. loadedAnimationGroups: Array<AnimationGroup>;
  73549. /**
  73550. * Callback called when the task is successful
  73551. */
  73552. onSuccess: (task: MeshAssetTask) => void;
  73553. /**
  73554. * Callback called when the task is successful
  73555. */
  73556. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73557. /**
  73558. * Creates a new MeshAssetTask
  73559. * @param name defines the name of the task
  73560. * @param meshesNames defines the list of mesh's names you want to load
  73561. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73562. * @param sceneFilename defines the filename or File of the scene to load from
  73563. */
  73564. constructor(
  73565. /**
  73566. * Defines the name of the task
  73567. */
  73568. name: string,
  73569. /**
  73570. * Defines the list of mesh's names you want to load
  73571. */
  73572. meshesNames: any,
  73573. /**
  73574. * Defines the root url to use as a base to load your meshes and associated resources
  73575. */
  73576. rootUrl: string,
  73577. /**
  73578. * Defines the filename or File of the scene to load from
  73579. */
  73580. sceneFilename: string | File);
  73581. /**
  73582. * Execute the current task
  73583. * @param scene defines the scene where you want your assets to be loaded
  73584. * @param onSuccess is a callback called when the task is successfully executed
  73585. * @param onError is a callback called if an error occurs
  73586. */
  73587. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73588. }
  73589. /**
  73590. * Define a task used by AssetsManager to load text content
  73591. */
  73592. export class TextFileAssetTask extends AbstractAssetTask {
  73593. /**
  73594. * Defines the name of the task
  73595. */
  73596. name: string;
  73597. /**
  73598. * Defines the location of the file to load
  73599. */
  73600. url: string;
  73601. /**
  73602. * Gets the loaded text string
  73603. */
  73604. text: string;
  73605. /**
  73606. * Callback called when the task is successful
  73607. */
  73608. onSuccess: (task: TextFileAssetTask) => void;
  73609. /**
  73610. * Callback called when the task is successful
  73611. */
  73612. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73613. /**
  73614. * Creates a new TextFileAssetTask object
  73615. * @param name defines the name of the task
  73616. * @param url defines the location of the file to load
  73617. */
  73618. constructor(
  73619. /**
  73620. * Defines the name of the task
  73621. */
  73622. name: string,
  73623. /**
  73624. * Defines the location of the file to load
  73625. */
  73626. url: string);
  73627. /**
  73628. * Execute the current task
  73629. * @param scene defines the scene where you want your assets to be loaded
  73630. * @param onSuccess is a callback called when the task is successfully executed
  73631. * @param onError is a callback called if an error occurs
  73632. */
  73633. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73634. }
  73635. /**
  73636. * Define a task used by AssetsManager to load binary data
  73637. */
  73638. export class BinaryFileAssetTask extends AbstractAssetTask {
  73639. /**
  73640. * Defines the name of the task
  73641. */
  73642. name: string;
  73643. /**
  73644. * Defines the location of the file to load
  73645. */
  73646. url: string;
  73647. /**
  73648. * Gets the lodaded data (as an array buffer)
  73649. */
  73650. data: ArrayBuffer;
  73651. /**
  73652. * Callback called when the task is successful
  73653. */
  73654. onSuccess: (task: BinaryFileAssetTask) => void;
  73655. /**
  73656. * Callback called when the task is successful
  73657. */
  73658. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73659. /**
  73660. * Creates a new BinaryFileAssetTask object
  73661. * @param name defines the name of the new task
  73662. * @param url defines the location of the file to load
  73663. */
  73664. constructor(
  73665. /**
  73666. * Defines the name of the task
  73667. */
  73668. name: string,
  73669. /**
  73670. * Defines the location of the file to load
  73671. */
  73672. url: string);
  73673. /**
  73674. * Execute the current task
  73675. * @param scene defines the scene where you want your assets to be loaded
  73676. * @param onSuccess is a callback called when the task is successfully executed
  73677. * @param onError is a callback called if an error occurs
  73678. */
  73679. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73680. }
  73681. /**
  73682. * Define a task used by AssetsManager to load images
  73683. */
  73684. export class ImageAssetTask extends AbstractAssetTask {
  73685. /**
  73686. * Defines the name of the task
  73687. */
  73688. name: string;
  73689. /**
  73690. * Defines the location of the image to load
  73691. */
  73692. url: string;
  73693. /**
  73694. * Gets the loaded images
  73695. */
  73696. image: HTMLImageElement;
  73697. /**
  73698. * Callback called when the task is successful
  73699. */
  73700. onSuccess: (task: ImageAssetTask) => void;
  73701. /**
  73702. * Callback called when the task is successful
  73703. */
  73704. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73705. /**
  73706. * Creates a new ImageAssetTask
  73707. * @param name defines the name of the task
  73708. * @param url defines the location of the image to load
  73709. */
  73710. constructor(
  73711. /**
  73712. * Defines the name of the task
  73713. */
  73714. name: string,
  73715. /**
  73716. * Defines the location of the image to load
  73717. */
  73718. url: string);
  73719. /**
  73720. * Execute the current task
  73721. * @param scene defines the scene where you want your assets to be loaded
  73722. * @param onSuccess is a callback called when the task is successfully executed
  73723. * @param onError is a callback called if an error occurs
  73724. */
  73725. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73726. }
  73727. /**
  73728. * Defines the interface used by texture loading tasks
  73729. */
  73730. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73731. /**
  73732. * Gets the loaded texture
  73733. */
  73734. texture: TEX;
  73735. }
  73736. /**
  73737. * Define a task used by AssetsManager to load 2D textures
  73738. */
  73739. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73740. /**
  73741. * Defines the name of the task
  73742. */
  73743. name: string;
  73744. /**
  73745. * Defines the location of the file to load
  73746. */
  73747. url: string;
  73748. /**
  73749. * Defines if mipmap should not be generated (default is false)
  73750. */
  73751. noMipmap?: boolean | undefined;
  73752. /**
  73753. * Defines if texture must be inverted on Y axis (default is true)
  73754. */
  73755. invertY: boolean;
  73756. /**
  73757. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73758. */
  73759. samplingMode: number;
  73760. /**
  73761. * Gets the loaded texture
  73762. */
  73763. texture: Texture;
  73764. /**
  73765. * Callback called when the task is successful
  73766. */
  73767. onSuccess: (task: TextureAssetTask) => void;
  73768. /**
  73769. * Callback called when the task is successful
  73770. */
  73771. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73772. /**
  73773. * Creates a new TextureAssetTask object
  73774. * @param name defines the name of the task
  73775. * @param url defines the location of the file to load
  73776. * @param noMipmap defines if mipmap should not be generated (default is false)
  73777. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73778. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73779. */
  73780. constructor(
  73781. /**
  73782. * Defines the name of the task
  73783. */
  73784. name: string,
  73785. /**
  73786. * Defines the location of the file to load
  73787. */
  73788. url: string,
  73789. /**
  73790. * Defines if mipmap should not be generated (default is false)
  73791. */
  73792. noMipmap?: boolean | undefined,
  73793. /**
  73794. * Defines if texture must be inverted on Y axis (default is true)
  73795. */
  73796. invertY?: boolean,
  73797. /**
  73798. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73799. */
  73800. samplingMode?: number);
  73801. /**
  73802. * Execute the current task
  73803. * @param scene defines the scene where you want your assets to be loaded
  73804. * @param onSuccess is a callback called when the task is successfully executed
  73805. * @param onError is a callback called if an error occurs
  73806. */
  73807. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73808. }
  73809. /**
  73810. * Define a task used by AssetsManager to load cube textures
  73811. */
  73812. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73813. /**
  73814. * Defines the name of the task
  73815. */
  73816. name: string;
  73817. /**
  73818. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73819. */
  73820. url: string;
  73821. /**
  73822. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73823. */
  73824. extensions?: string[] | undefined;
  73825. /**
  73826. * Defines if mipmaps should not be generated (default is false)
  73827. */
  73828. noMipmap?: boolean | undefined;
  73829. /**
  73830. * Defines the explicit list of files (undefined by default)
  73831. */
  73832. files?: string[] | undefined;
  73833. /**
  73834. * Gets the loaded texture
  73835. */
  73836. texture: CubeTexture;
  73837. /**
  73838. * Callback called when the task is successful
  73839. */
  73840. onSuccess: (task: CubeTextureAssetTask) => void;
  73841. /**
  73842. * Callback called when the task is successful
  73843. */
  73844. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73845. /**
  73846. * Creates a new CubeTextureAssetTask
  73847. * @param name defines the name of the task
  73848. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73849. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73850. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73851. * @param files defines the explicit list of files (undefined by default)
  73852. */
  73853. constructor(
  73854. /**
  73855. * Defines the name of the task
  73856. */
  73857. name: string,
  73858. /**
  73859. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73860. */
  73861. url: string,
  73862. /**
  73863. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73864. */
  73865. extensions?: string[] | undefined,
  73866. /**
  73867. * Defines if mipmaps should not be generated (default is false)
  73868. */
  73869. noMipmap?: boolean | undefined,
  73870. /**
  73871. * Defines the explicit list of files (undefined by default)
  73872. */
  73873. files?: string[] | undefined);
  73874. /**
  73875. * Execute the current task
  73876. * @param scene defines the scene where you want your assets to be loaded
  73877. * @param onSuccess is a callback called when the task is successfully executed
  73878. * @param onError is a callback called if an error occurs
  73879. */
  73880. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73881. }
  73882. /**
  73883. * Define a task used by AssetsManager to load HDR cube textures
  73884. */
  73885. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73886. /**
  73887. * Defines the name of the task
  73888. */
  73889. name: string;
  73890. /**
  73891. * Defines the location of the file to load
  73892. */
  73893. url: string;
  73894. /**
  73895. * Defines the desired size (the more it increases the longer the generation will be)
  73896. */
  73897. size: number;
  73898. /**
  73899. * Defines if mipmaps should not be generated (default is false)
  73900. */
  73901. noMipmap: boolean;
  73902. /**
  73903. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73904. */
  73905. generateHarmonics: boolean;
  73906. /**
  73907. * 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)
  73908. */
  73909. gammaSpace: boolean;
  73910. /**
  73911. * Internal Use Only
  73912. */
  73913. reserved: boolean;
  73914. /**
  73915. * Gets the loaded texture
  73916. */
  73917. texture: HDRCubeTexture;
  73918. /**
  73919. * Callback called when the task is successful
  73920. */
  73921. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73922. /**
  73923. * Callback called when the task is successful
  73924. */
  73925. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73926. /**
  73927. * Creates a new HDRCubeTextureAssetTask object
  73928. * @param name defines the name of the task
  73929. * @param url defines the location of the file to load
  73930. * @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.
  73931. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73932. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73933. * @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)
  73934. * @param reserved Internal use only
  73935. */
  73936. constructor(
  73937. /**
  73938. * Defines the name of the task
  73939. */
  73940. name: string,
  73941. /**
  73942. * Defines the location of the file to load
  73943. */
  73944. url: string,
  73945. /**
  73946. * Defines the desired size (the more it increases the longer the generation will be)
  73947. */
  73948. size: number,
  73949. /**
  73950. * Defines if mipmaps should not be generated (default is false)
  73951. */
  73952. noMipmap?: boolean,
  73953. /**
  73954. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73955. */
  73956. generateHarmonics?: boolean,
  73957. /**
  73958. * 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)
  73959. */
  73960. gammaSpace?: boolean,
  73961. /**
  73962. * Internal Use Only
  73963. */
  73964. reserved?: boolean);
  73965. /**
  73966. * Execute the current task
  73967. * @param scene defines the scene where you want your assets to be loaded
  73968. * @param onSuccess is a callback called when the task is successfully executed
  73969. * @param onError is a callback called if an error occurs
  73970. */
  73971. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73972. }
  73973. /**
  73974. * Define a task used by AssetsManager to load Equirectangular cube textures
  73975. */
  73976. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73977. /**
  73978. * Defines the name of the task
  73979. */
  73980. name: string;
  73981. /**
  73982. * Defines the location of the file to load
  73983. */
  73984. url: string;
  73985. /**
  73986. * Defines the desired size (the more it increases the longer the generation will be)
  73987. */
  73988. size: number;
  73989. /**
  73990. * Defines if mipmaps should not be generated (default is false)
  73991. */
  73992. noMipmap: boolean;
  73993. /**
  73994. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73995. * but the standard material would require them in Gamma space) (default is true)
  73996. */
  73997. gammaSpace: boolean;
  73998. /**
  73999. * Gets the loaded texture
  74000. */
  74001. texture: EquiRectangularCubeTexture;
  74002. /**
  74003. * Callback called when the task is successful
  74004. */
  74005. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74006. /**
  74007. * Callback called when the task is successful
  74008. */
  74009. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74010. /**
  74011. * Creates a new EquiRectangularCubeTextureAssetTask object
  74012. * @param name defines the name of the task
  74013. * @param url defines the location of the file to load
  74014. * @param size defines the desired size (the more it increases the longer the generation will be)
  74015. * If the size is omitted this implies you are using a preprocessed cubemap.
  74016. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74017. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74018. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74019. * (default is true)
  74020. */
  74021. constructor(
  74022. /**
  74023. * Defines the name of the task
  74024. */
  74025. name: string,
  74026. /**
  74027. * Defines the location of the file to load
  74028. */
  74029. url: string,
  74030. /**
  74031. * Defines the desired size (the more it increases the longer the generation will be)
  74032. */
  74033. size: number,
  74034. /**
  74035. * Defines if mipmaps should not be generated (default is false)
  74036. */
  74037. noMipmap?: boolean,
  74038. /**
  74039. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74040. * but the standard material would require them in Gamma space) (default is true)
  74041. */
  74042. gammaSpace?: boolean);
  74043. /**
  74044. * Execute the current task
  74045. * @param scene defines the scene where you want your assets to be loaded
  74046. * @param onSuccess is a callback called when the task is successfully executed
  74047. * @param onError is a callback called if an error occurs
  74048. */
  74049. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74050. }
  74051. /**
  74052. * This class can be used to easily import assets into a scene
  74053. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74054. */
  74055. export class AssetsManager {
  74056. private _scene;
  74057. private _isLoading;
  74058. protected _tasks: AbstractAssetTask[];
  74059. protected _waitingTasksCount: number;
  74060. protected _totalTasksCount: number;
  74061. /**
  74062. * Callback called when all tasks are processed
  74063. */
  74064. onFinish: (tasks: AbstractAssetTask[]) => void;
  74065. /**
  74066. * Callback called when a task is successful
  74067. */
  74068. onTaskSuccess: (task: AbstractAssetTask) => void;
  74069. /**
  74070. * Callback called when a task had an error
  74071. */
  74072. onTaskError: (task: AbstractAssetTask) => void;
  74073. /**
  74074. * Callback called when a task is done (whatever the result is)
  74075. */
  74076. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74077. /**
  74078. * Observable called when all tasks are processed
  74079. */
  74080. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74081. /**
  74082. * Observable called when a task had an error
  74083. */
  74084. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74085. /**
  74086. * Observable called when all tasks were executed
  74087. */
  74088. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74089. /**
  74090. * Observable called when a task is done (whatever the result is)
  74091. */
  74092. onProgressObservable: Observable<IAssetsProgressEvent>;
  74093. /**
  74094. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74095. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74096. */
  74097. useDefaultLoadingScreen: boolean;
  74098. /**
  74099. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74100. * when all assets have been downloaded.
  74101. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74102. */
  74103. autoHideLoadingUI: boolean;
  74104. /**
  74105. * Creates a new AssetsManager
  74106. * @param scene defines the scene to work on
  74107. */
  74108. constructor(scene: Scene);
  74109. /**
  74110. * Add a ContainerAssetTask to the list of active tasks
  74111. * @param taskName defines the name of the new task
  74112. * @param meshesNames defines the name of meshes to load
  74113. * @param rootUrl defines the root url to use to locate files
  74114. * @param sceneFilename defines the filename of the scene file
  74115. * @returns a new ContainerAssetTask object
  74116. */
  74117. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74118. /**
  74119. * Add a MeshAssetTask to the list of active tasks
  74120. * @param taskName defines the name of the new task
  74121. * @param meshesNames defines the name of meshes to load
  74122. * @param rootUrl defines the root url to use to locate files
  74123. * @param sceneFilename defines the filename of the scene file
  74124. * @returns a new MeshAssetTask object
  74125. */
  74126. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74127. /**
  74128. * Add a TextFileAssetTask to the list of active tasks
  74129. * @param taskName defines the name of the new task
  74130. * @param url defines the url of the file to load
  74131. * @returns a new TextFileAssetTask object
  74132. */
  74133. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74134. /**
  74135. * Add a BinaryFileAssetTask to the list of active tasks
  74136. * @param taskName defines the name of the new task
  74137. * @param url defines the url of the file to load
  74138. * @returns a new BinaryFileAssetTask object
  74139. */
  74140. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74141. /**
  74142. * Add a ImageAssetTask to the list of active tasks
  74143. * @param taskName defines the name of the new task
  74144. * @param url defines the url of the file to load
  74145. * @returns a new ImageAssetTask object
  74146. */
  74147. addImageTask(taskName: string, url: string): ImageAssetTask;
  74148. /**
  74149. * Add a TextureAssetTask to the list of active tasks
  74150. * @param taskName defines the name of the new task
  74151. * @param url defines the url of the file to load
  74152. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74153. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74154. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74155. * @returns a new TextureAssetTask object
  74156. */
  74157. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74158. /**
  74159. * Add a CubeTextureAssetTask to the list of active tasks
  74160. * @param taskName defines the name of the new task
  74161. * @param url defines the url of the file to load
  74162. * @param extensions defines the extension to use to load the cube map (can be null)
  74163. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74164. * @param files defines the list of files to load (can be null)
  74165. * @returns a new CubeTextureAssetTask object
  74166. */
  74167. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74168. /**
  74169. *
  74170. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74171. * @param taskName defines the name of the new task
  74172. * @param url defines the url of the file to load
  74173. * @param size defines the size you want for the cubemap (can be null)
  74174. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74175. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74176. * @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)
  74177. * @param reserved Internal use only
  74178. * @returns a new HDRCubeTextureAssetTask object
  74179. */
  74180. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74181. /**
  74182. *
  74183. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74184. * @param taskName defines the name of the new task
  74185. * @param url defines the url of the file to load
  74186. * @param size defines the size you want for the cubemap (can be null)
  74187. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74188. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74189. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74190. * @returns a new EquiRectangularCubeTextureAssetTask object
  74191. */
  74192. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74193. /**
  74194. * Remove a task from the assets manager.
  74195. * @param task the task to remove
  74196. */
  74197. removeTask(task: AbstractAssetTask): void;
  74198. private _decreaseWaitingTasksCount;
  74199. private _runTask;
  74200. /**
  74201. * Reset the AssetsManager and remove all tasks
  74202. * @return the current instance of the AssetsManager
  74203. */
  74204. reset(): AssetsManager;
  74205. /**
  74206. * Start the loading process
  74207. * @return the current instance of the AssetsManager
  74208. */
  74209. load(): AssetsManager;
  74210. /**
  74211. * Start the loading process as an async operation
  74212. * @return a promise returning the list of failed tasks
  74213. */
  74214. loadAsync(): Promise<void>;
  74215. }
  74216. }
  74217. declare module BABYLON {
  74218. /**
  74219. * Wrapper class for promise with external resolve and reject.
  74220. */
  74221. export class Deferred<T> {
  74222. /**
  74223. * The promise associated with this deferred object.
  74224. */
  74225. readonly promise: Promise<T>;
  74226. private _resolve;
  74227. private _reject;
  74228. /**
  74229. * The resolve method of the promise associated with this deferred object.
  74230. */
  74231. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74232. /**
  74233. * The reject method of the promise associated with this deferred object.
  74234. */
  74235. get reject(): (reason?: any) => void;
  74236. /**
  74237. * Constructor for this deferred object.
  74238. */
  74239. constructor();
  74240. }
  74241. }
  74242. declare module BABYLON {
  74243. /**
  74244. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74245. */
  74246. export class MeshExploder {
  74247. private _centerMesh;
  74248. private _meshes;
  74249. private _meshesOrigins;
  74250. private _toCenterVectors;
  74251. private _scaledDirection;
  74252. private _newPosition;
  74253. private _centerPosition;
  74254. /**
  74255. * Explodes meshes from a center mesh.
  74256. * @param meshes The meshes to explode.
  74257. * @param centerMesh The mesh to be center of explosion.
  74258. */
  74259. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74260. private _setCenterMesh;
  74261. /**
  74262. * Get class name
  74263. * @returns "MeshExploder"
  74264. */
  74265. getClassName(): string;
  74266. /**
  74267. * "Exploded meshes"
  74268. * @returns Array of meshes with the centerMesh at index 0.
  74269. */
  74270. getMeshes(): Array<Mesh>;
  74271. /**
  74272. * Explodes meshes giving a specific direction
  74273. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74274. */
  74275. explode(direction?: number): void;
  74276. }
  74277. }
  74278. declare module BABYLON {
  74279. /**
  74280. * Class used to help managing file picking and drag'n'drop
  74281. */
  74282. export class FilesInput {
  74283. /**
  74284. * List of files ready to be loaded
  74285. */
  74286. static get FilesToLoad(): {
  74287. [key: string]: File;
  74288. };
  74289. /**
  74290. * Callback called when a file is processed
  74291. */
  74292. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74293. private _engine;
  74294. private _currentScene;
  74295. private _sceneLoadedCallback;
  74296. private _progressCallback;
  74297. private _additionalRenderLoopLogicCallback;
  74298. private _textureLoadingCallback;
  74299. private _startingProcessingFilesCallback;
  74300. private _onReloadCallback;
  74301. private _errorCallback;
  74302. private _elementToMonitor;
  74303. private _sceneFileToLoad;
  74304. private _filesToLoad;
  74305. /**
  74306. * Creates a new FilesInput
  74307. * @param engine defines the rendering engine
  74308. * @param scene defines the hosting scene
  74309. * @param sceneLoadedCallback callback called when scene is loaded
  74310. * @param progressCallback callback called to track progress
  74311. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74312. * @param textureLoadingCallback callback called when a texture is loading
  74313. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74314. * @param onReloadCallback callback called when a reload is requested
  74315. * @param errorCallback callback call if an error occurs
  74316. */
  74317. 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>);
  74318. private _dragEnterHandler;
  74319. private _dragOverHandler;
  74320. private _dropHandler;
  74321. /**
  74322. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74323. * @param elementToMonitor defines the DOM element to track
  74324. */
  74325. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74326. /** Gets the current list of files to load */
  74327. get filesToLoad(): File[];
  74328. /**
  74329. * Release all associated resources
  74330. */
  74331. dispose(): void;
  74332. private renderFunction;
  74333. private drag;
  74334. private drop;
  74335. private _traverseFolder;
  74336. private _processFiles;
  74337. /**
  74338. * Load files from a drop event
  74339. * @param event defines the drop event to use as source
  74340. */
  74341. loadFiles(event: any): void;
  74342. private _processReload;
  74343. /**
  74344. * Reload the current scene from the loaded files
  74345. */
  74346. reload(): void;
  74347. }
  74348. }
  74349. declare module BABYLON {
  74350. /**
  74351. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74352. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74353. */
  74354. export class SceneOptimization {
  74355. /**
  74356. * Defines the priority of this optimization (0 by default which means first in the list)
  74357. */
  74358. priority: number;
  74359. /**
  74360. * Gets a string describing the action executed by the current optimization
  74361. * @returns description string
  74362. */
  74363. getDescription(): string;
  74364. /**
  74365. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74366. * @param scene defines the current scene where to apply this optimization
  74367. * @param optimizer defines the current optimizer
  74368. * @returns true if everything that can be done was applied
  74369. */
  74370. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74371. /**
  74372. * Creates the SceneOptimization object
  74373. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74374. * @param desc defines the description associated with the optimization
  74375. */
  74376. constructor(
  74377. /**
  74378. * Defines the priority of this optimization (0 by default which means first in the list)
  74379. */
  74380. priority?: number);
  74381. }
  74382. /**
  74383. * Defines an optimization used to reduce the size of render target textures
  74384. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74385. */
  74386. export class TextureOptimization extends SceneOptimization {
  74387. /**
  74388. * Defines the priority of this optimization (0 by default which means first in the list)
  74389. */
  74390. priority: number;
  74391. /**
  74392. * 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
  74393. */
  74394. maximumSize: number;
  74395. /**
  74396. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74397. */
  74398. step: number;
  74399. /**
  74400. * Gets a string describing the action executed by the current optimization
  74401. * @returns description string
  74402. */
  74403. getDescription(): string;
  74404. /**
  74405. * Creates the TextureOptimization object
  74406. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74407. * @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
  74408. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74409. */
  74410. constructor(
  74411. /**
  74412. * Defines the priority of this optimization (0 by default which means first in the list)
  74413. */
  74414. priority?: number,
  74415. /**
  74416. * 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
  74417. */
  74418. maximumSize?: number,
  74419. /**
  74420. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74421. */
  74422. step?: number);
  74423. /**
  74424. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74425. * @param scene defines the current scene where to apply this optimization
  74426. * @param optimizer defines the current optimizer
  74427. * @returns true if everything that can be done was applied
  74428. */
  74429. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74430. }
  74431. /**
  74432. * Defines an optimization used to increase or decrease the rendering resolution
  74433. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74434. */
  74435. export class HardwareScalingOptimization extends SceneOptimization {
  74436. /**
  74437. * Defines the priority of this optimization (0 by default which means first in the list)
  74438. */
  74439. priority: number;
  74440. /**
  74441. * Defines the maximum scale to use (2 by default)
  74442. */
  74443. maximumScale: number;
  74444. /**
  74445. * Defines the step to use between two passes (0.5 by default)
  74446. */
  74447. step: number;
  74448. private _currentScale;
  74449. private _directionOffset;
  74450. /**
  74451. * Gets a string describing the action executed by the current optimization
  74452. * @return description string
  74453. */
  74454. getDescription(): string;
  74455. /**
  74456. * Creates the HardwareScalingOptimization object
  74457. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74458. * @param maximumScale defines the maximum scale to use (2 by default)
  74459. * @param step defines the step to use between two passes (0.5 by default)
  74460. */
  74461. constructor(
  74462. /**
  74463. * Defines the priority of this optimization (0 by default which means first in the list)
  74464. */
  74465. priority?: number,
  74466. /**
  74467. * Defines the maximum scale to use (2 by default)
  74468. */
  74469. maximumScale?: number,
  74470. /**
  74471. * Defines the step to use between two passes (0.5 by default)
  74472. */
  74473. step?: number);
  74474. /**
  74475. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74476. * @param scene defines the current scene where to apply this optimization
  74477. * @param optimizer defines the current optimizer
  74478. * @returns true if everything that can be done was applied
  74479. */
  74480. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74481. }
  74482. /**
  74483. * Defines an optimization used to remove shadows
  74484. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74485. */
  74486. export class ShadowsOptimization extends SceneOptimization {
  74487. /**
  74488. * Gets a string describing the action executed by the current optimization
  74489. * @return description string
  74490. */
  74491. getDescription(): string;
  74492. /**
  74493. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74494. * @param scene defines the current scene where to apply this optimization
  74495. * @param optimizer defines the current optimizer
  74496. * @returns true if everything that can be done was applied
  74497. */
  74498. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74499. }
  74500. /**
  74501. * Defines an optimization used to turn post-processes off
  74502. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74503. */
  74504. export class PostProcessesOptimization extends SceneOptimization {
  74505. /**
  74506. * Gets a string describing the action executed by the current optimization
  74507. * @return description string
  74508. */
  74509. getDescription(): string;
  74510. /**
  74511. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74512. * @param scene defines the current scene where to apply this optimization
  74513. * @param optimizer defines the current optimizer
  74514. * @returns true if everything that can be done was applied
  74515. */
  74516. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74517. }
  74518. /**
  74519. * Defines an optimization used to turn lens flares off
  74520. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74521. */
  74522. export class LensFlaresOptimization extends SceneOptimization {
  74523. /**
  74524. * Gets a string describing the action executed by the current optimization
  74525. * @return description string
  74526. */
  74527. getDescription(): string;
  74528. /**
  74529. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74530. * @param scene defines the current scene where to apply this optimization
  74531. * @param optimizer defines the current optimizer
  74532. * @returns true if everything that can be done was applied
  74533. */
  74534. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74535. }
  74536. /**
  74537. * Defines an optimization based on user defined callback.
  74538. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74539. */
  74540. export class CustomOptimization extends SceneOptimization {
  74541. /**
  74542. * Callback called to apply the custom optimization.
  74543. */
  74544. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74545. /**
  74546. * Callback called to get custom description
  74547. */
  74548. onGetDescription: () => string;
  74549. /**
  74550. * Gets a string describing the action executed by the current optimization
  74551. * @returns description string
  74552. */
  74553. getDescription(): string;
  74554. /**
  74555. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74556. * @param scene defines the current scene where to apply this optimization
  74557. * @param optimizer defines the current optimizer
  74558. * @returns true if everything that can be done was applied
  74559. */
  74560. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74561. }
  74562. /**
  74563. * Defines an optimization used to turn particles off
  74564. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74565. */
  74566. export class ParticlesOptimization extends SceneOptimization {
  74567. /**
  74568. * Gets a string describing the action executed by the current optimization
  74569. * @return description string
  74570. */
  74571. getDescription(): string;
  74572. /**
  74573. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74574. * @param scene defines the current scene where to apply this optimization
  74575. * @param optimizer defines the current optimizer
  74576. * @returns true if everything that can be done was applied
  74577. */
  74578. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74579. }
  74580. /**
  74581. * Defines an optimization used to turn render targets off
  74582. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74583. */
  74584. export class RenderTargetsOptimization extends SceneOptimization {
  74585. /**
  74586. * Gets a string describing the action executed by the current optimization
  74587. * @return description string
  74588. */
  74589. getDescription(): string;
  74590. /**
  74591. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74592. * @param scene defines the current scene where to apply this optimization
  74593. * @param optimizer defines the current optimizer
  74594. * @returns true if everything that can be done was applied
  74595. */
  74596. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74597. }
  74598. /**
  74599. * Defines an optimization used to merge meshes with compatible materials
  74600. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74601. */
  74602. export class MergeMeshesOptimization extends SceneOptimization {
  74603. private static _UpdateSelectionTree;
  74604. /**
  74605. * Gets or sets a boolean which defines if optimization octree has to be updated
  74606. */
  74607. static get UpdateSelectionTree(): boolean;
  74608. /**
  74609. * Gets or sets a boolean which defines if optimization octree has to be updated
  74610. */
  74611. static set UpdateSelectionTree(value: boolean);
  74612. /**
  74613. * Gets a string describing the action executed by the current optimization
  74614. * @return description string
  74615. */
  74616. getDescription(): string;
  74617. private _canBeMerged;
  74618. /**
  74619. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74620. * @param scene defines the current scene where to apply this optimization
  74621. * @param optimizer defines the current optimizer
  74622. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74623. * @returns true if everything that can be done was applied
  74624. */
  74625. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74626. }
  74627. /**
  74628. * Defines a list of options used by SceneOptimizer
  74629. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74630. */
  74631. export class SceneOptimizerOptions {
  74632. /**
  74633. * Defines the target frame rate to reach (60 by default)
  74634. */
  74635. targetFrameRate: number;
  74636. /**
  74637. * Defines the interval between two checkes (2000ms by default)
  74638. */
  74639. trackerDuration: number;
  74640. /**
  74641. * Gets the list of optimizations to apply
  74642. */
  74643. optimizations: SceneOptimization[];
  74644. /**
  74645. * Creates a new list of options used by SceneOptimizer
  74646. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74647. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74648. */
  74649. constructor(
  74650. /**
  74651. * Defines the target frame rate to reach (60 by default)
  74652. */
  74653. targetFrameRate?: number,
  74654. /**
  74655. * Defines the interval between two checkes (2000ms by default)
  74656. */
  74657. trackerDuration?: number);
  74658. /**
  74659. * Add a new optimization
  74660. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74661. * @returns the current SceneOptimizerOptions
  74662. */
  74663. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74664. /**
  74665. * Add a new custom optimization
  74666. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74667. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74668. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74669. * @returns the current SceneOptimizerOptions
  74670. */
  74671. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74672. /**
  74673. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74674. * @param targetFrameRate defines the target frame rate (60 by default)
  74675. * @returns a SceneOptimizerOptions object
  74676. */
  74677. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74678. /**
  74679. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74680. * @param targetFrameRate defines the target frame rate (60 by default)
  74681. * @returns a SceneOptimizerOptions object
  74682. */
  74683. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74684. /**
  74685. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74686. * @param targetFrameRate defines the target frame rate (60 by default)
  74687. * @returns a SceneOptimizerOptions object
  74688. */
  74689. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74690. }
  74691. /**
  74692. * Class used to run optimizations in order to reach a target frame rate
  74693. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74694. */
  74695. export class SceneOptimizer implements IDisposable {
  74696. private _isRunning;
  74697. private _options;
  74698. private _scene;
  74699. private _currentPriorityLevel;
  74700. private _targetFrameRate;
  74701. private _trackerDuration;
  74702. private _currentFrameRate;
  74703. private _sceneDisposeObserver;
  74704. private _improvementMode;
  74705. /**
  74706. * Defines an observable called when the optimizer reaches the target frame rate
  74707. */
  74708. onSuccessObservable: Observable<SceneOptimizer>;
  74709. /**
  74710. * Defines an observable called when the optimizer enables an optimization
  74711. */
  74712. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74713. /**
  74714. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74715. */
  74716. onFailureObservable: Observable<SceneOptimizer>;
  74717. /**
  74718. * Gets a boolean indicating if the optimizer is in improvement mode
  74719. */
  74720. get isInImprovementMode(): boolean;
  74721. /**
  74722. * Gets the current priority level (0 at start)
  74723. */
  74724. get currentPriorityLevel(): number;
  74725. /**
  74726. * Gets the current frame rate checked by the SceneOptimizer
  74727. */
  74728. get currentFrameRate(): number;
  74729. /**
  74730. * Gets or sets the current target frame rate (60 by default)
  74731. */
  74732. get targetFrameRate(): number;
  74733. /**
  74734. * Gets or sets the current target frame rate (60 by default)
  74735. */
  74736. set targetFrameRate(value: number);
  74737. /**
  74738. * Gets or sets the current interval between two checks (every 2000ms by default)
  74739. */
  74740. get trackerDuration(): number;
  74741. /**
  74742. * Gets or sets the current interval between two checks (every 2000ms by default)
  74743. */
  74744. set trackerDuration(value: number);
  74745. /**
  74746. * Gets the list of active optimizations
  74747. */
  74748. get optimizations(): SceneOptimization[];
  74749. /**
  74750. * Creates a new SceneOptimizer
  74751. * @param scene defines the scene to work on
  74752. * @param options defines the options to use with the SceneOptimizer
  74753. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74754. * @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)
  74755. */
  74756. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74757. /**
  74758. * Stops the current optimizer
  74759. */
  74760. stop(): void;
  74761. /**
  74762. * Reset the optimizer to initial step (current priority level = 0)
  74763. */
  74764. reset(): void;
  74765. /**
  74766. * Start the optimizer. By default it will try to reach a specific framerate
  74767. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74768. */
  74769. start(): void;
  74770. private _checkCurrentState;
  74771. /**
  74772. * Release all resources
  74773. */
  74774. dispose(): void;
  74775. /**
  74776. * Helper function to create a SceneOptimizer with one single line of code
  74777. * @param scene defines the scene to work on
  74778. * @param options defines the options to use with the SceneOptimizer
  74779. * @param onSuccess defines a callback to call on success
  74780. * @param onFailure defines a callback to call on failure
  74781. * @returns the new SceneOptimizer object
  74782. */
  74783. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74784. }
  74785. }
  74786. declare module BABYLON {
  74787. /**
  74788. * Class used to serialize a scene into a string
  74789. */
  74790. export class SceneSerializer {
  74791. /**
  74792. * Clear cache used by a previous serialization
  74793. */
  74794. static ClearCache(): void;
  74795. /**
  74796. * Serialize a scene into a JSON compatible object
  74797. * @param scene defines the scene to serialize
  74798. * @returns a JSON compatible object
  74799. */
  74800. static Serialize(scene: Scene): any;
  74801. /**
  74802. * Serialize a mesh into a JSON compatible object
  74803. * @param toSerialize defines the mesh to serialize
  74804. * @param withParents defines if parents must be serialized as well
  74805. * @param withChildren defines if children must be serialized as well
  74806. * @returns a JSON compatible object
  74807. */
  74808. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74809. }
  74810. }
  74811. declare module BABYLON {
  74812. /**
  74813. * Class used to host texture specific utilities
  74814. */
  74815. export class TextureTools {
  74816. /**
  74817. * Uses the GPU to create a copy texture rescaled at a given size
  74818. * @param texture Texture to copy from
  74819. * @param width defines the desired width
  74820. * @param height defines the desired height
  74821. * @param useBilinearMode defines if bilinear mode has to be used
  74822. * @return the generated texture
  74823. */
  74824. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74825. }
  74826. }
  74827. declare module BABYLON {
  74828. /**
  74829. * This represents the different options available for the video capture.
  74830. */
  74831. export interface VideoRecorderOptions {
  74832. /** Defines the mime type of the video. */
  74833. mimeType: string;
  74834. /** Defines the FPS the video should be recorded at. */
  74835. fps: number;
  74836. /** Defines the chunk size for the recording data. */
  74837. recordChunckSize: number;
  74838. /** The audio tracks to attach to the recording. */
  74839. audioTracks?: MediaStreamTrack[];
  74840. }
  74841. /**
  74842. * This can help with recording videos from BabylonJS.
  74843. * This is based on the available WebRTC functionalities of the browser.
  74844. *
  74845. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74846. */
  74847. export class VideoRecorder {
  74848. private static readonly _defaultOptions;
  74849. /**
  74850. * Returns whether or not the VideoRecorder is available in your browser.
  74851. * @param engine Defines the Babylon Engine.
  74852. * @returns true if supported otherwise false.
  74853. */
  74854. static IsSupported(engine: Engine): boolean;
  74855. private readonly _options;
  74856. private _canvas;
  74857. private _mediaRecorder;
  74858. private _recordedChunks;
  74859. private _fileName;
  74860. private _resolve;
  74861. private _reject;
  74862. /**
  74863. * True when a recording is already in progress.
  74864. */
  74865. get isRecording(): boolean;
  74866. /**
  74867. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74868. * @param engine Defines the BabylonJS Engine you wish to record.
  74869. * @param options Defines options that can be used to customize the capture.
  74870. */
  74871. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74872. /**
  74873. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74874. */
  74875. stopRecording(): void;
  74876. /**
  74877. * Starts recording the canvas for a max duration specified in parameters.
  74878. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74879. * If null no automatic download will start and you can rely on the promise to get the data back.
  74880. * @param maxDuration Defines the maximum recording time in seconds.
  74881. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74882. * @return A promise callback at the end of the recording with the video data in Blob.
  74883. */
  74884. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74885. /**
  74886. * Releases internal resources used during the recording.
  74887. */
  74888. dispose(): void;
  74889. private _handleDataAvailable;
  74890. private _handleError;
  74891. private _handleStop;
  74892. }
  74893. }
  74894. declare module BABYLON {
  74895. /**
  74896. * Class containing a set of static utilities functions for screenshots
  74897. */
  74898. export class ScreenshotTools {
  74899. /**
  74900. * Captures a screenshot of the current rendering
  74901. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74902. * @param engine defines the rendering engine
  74903. * @param camera defines the source camera
  74904. * @param size This parameter can be set to a single number or to an object with the
  74905. * following (optional) properties: precision, width, height. If a single number is passed,
  74906. * it will be used for both width and height. If an object is passed, the screenshot size
  74907. * will be derived from the parameters. The precision property is a multiplier allowing
  74908. * rendering at a higher or lower resolution
  74909. * @param successCallback defines the callback receives a single parameter which contains the
  74910. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74911. * src parameter of an <img> to display it
  74912. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74913. * Check your browser for supported MIME types
  74914. */
  74915. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74916. /**
  74917. * Captures a screenshot of the current rendering
  74918. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74919. * @param engine defines the rendering engine
  74920. * @param camera defines the source camera
  74921. * @param size This parameter can be set to a single number or to an object with the
  74922. * following (optional) properties: precision, width, height. If a single number is passed,
  74923. * it will be used for both width and height. If an object is passed, the screenshot size
  74924. * will be derived from the parameters. The precision property is a multiplier allowing
  74925. * rendering at a higher or lower resolution
  74926. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74927. * Check your browser for supported MIME types
  74928. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74929. * to the src parameter of an <img> to display it
  74930. */
  74931. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74932. /**
  74933. * Generates an image screenshot from the specified camera.
  74934. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74935. * @param engine The engine to use for rendering
  74936. * @param camera The camera to use for rendering
  74937. * @param size This parameter can be set to a single number or to an object with the
  74938. * following (optional) properties: precision, width, height. If a single number is passed,
  74939. * it will be used for both width and height. If an object is passed, the screenshot size
  74940. * will be derived from the parameters. The precision property is a multiplier allowing
  74941. * rendering at a higher or lower resolution
  74942. * @param successCallback The callback receives a single parameter which contains the
  74943. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74944. * src parameter of an <img> to display it
  74945. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74946. * Check your browser for supported MIME types
  74947. * @param samples Texture samples (default: 1)
  74948. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74949. * @param fileName A name for for the downloaded file.
  74950. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74951. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74952. */
  74953. 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;
  74954. /**
  74955. * Generates an image screenshot from the specified camera.
  74956. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74957. * @param engine The engine to use for rendering
  74958. * @param camera The camera to use for rendering
  74959. * @param size This parameter can be set to a single number or to an object with the
  74960. * following (optional) properties: precision, width, height. If a single number is passed,
  74961. * it will be used for both width and height. If an object is passed, the screenshot size
  74962. * will be derived from the parameters. The precision property is a multiplier allowing
  74963. * rendering at a higher or lower resolution
  74964. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74965. * Check your browser for supported MIME types
  74966. * @param samples Texture samples (default: 1)
  74967. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74968. * @param fileName A name for for the downloaded file.
  74969. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74970. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74971. * to the src parameter of an <img> to display it
  74972. */
  74973. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74974. /**
  74975. * Gets height and width for screenshot size
  74976. * @private
  74977. */
  74978. private static _getScreenshotSize;
  74979. }
  74980. }
  74981. declare module BABYLON {
  74982. /**
  74983. * Interface for a data buffer
  74984. */
  74985. export interface IDataBuffer {
  74986. /**
  74987. * Reads bytes from the data buffer.
  74988. * @param byteOffset The byte offset to read
  74989. * @param byteLength The byte length to read
  74990. * @returns A promise that resolves when the bytes are read
  74991. */
  74992. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74993. /**
  74994. * The byte length of the buffer.
  74995. */
  74996. readonly byteLength: number;
  74997. }
  74998. /**
  74999. * Utility class for reading from a data buffer
  75000. */
  75001. export class DataReader {
  75002. /**
  75003. * The data buffer associated with this data reader.
  75004. */
  75005. readonly buffer: IDataBuffer;
  75006. /**
  75007. * The current byte offset from the beginning of the data buffer.
  75008. */
  75009. byteOffset: number;
  75010. private _dataView;
  75011. private _dataByteOffset;
  75012. /**
  75013. * Constructor
  75014. * @param buffer The buffer to read
  75015. */
  75016. constructor(buffer: IDataBuffer);
  75017. /**
  75018. * Loads the given byte length.
  75019. * @param byteLength The byte length to load
  75020. * @returns A promise that resolves when the load is complete
  75021. */
  75022. loadAsync(byteLength: number): Promise<void>;
  75023. /**
  75024. * Read a unsigned 32-bit integer from the currently loaded data range.
  75025. * @returns The 32-bit integer read
  75026. */
  75027. readUint32(): number;
  75028. /**
  75029. * Read a byte array from the currently loaded data range.
  75030. * @param byteLength The byte length to read
  75031. * @returns The byte array read
  75032. */
  75033. readUint8Array(byteLength: number): Uint8Array;
  75034. /**
  75035. * Read a string from the currently loaded data range.
  75036. * @param byteLength The byte length to read
  75037. * @returns The string read
  75038. */
  75039. readString(byteLength: number): string;
  75040. /**
  75041. * Skips the given byte length the currently loaded data range.
  75042. * @param byteLength The byte length to skip
  75043. */
  75044. skipBytes(byteLength: number): void;
  75045. }
  75046. }
  75047. declare module BABYLON {
  75048. /**
  75049. * Class for storing data to local storage if available or in-memory storage otherwise
  75050. */
  75051. export class DataStorage {
  75052. private static _Storage;
  75053. private static _GetStorage;
  75054. /**
  75055. * Reads a string from the data storage
  75056. * @param key The key to read
  75057. * @param defaultValue The value if the key doesn't exist
  75058. * @returns The string value
  75059. */
  75060. static ReadString(key: string, defaultValue: string): string;
  75061. /**
  75062. * Writes a string to the data storage
  75063. * @param key The key to write
  75064. * @param value The value to write
  75065. */
  75066. static WriteString(key: string, value: string): void;
  75067. /**
  75068. * Reads a boolean from the data storage
  75069. * @param key The key to read
  75070. * @param defaultValue The value if the key doesn't exist
  75071. * @returns The boolean value
  75072. */
  75073. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75074. /**
  75075. * Writes a boolean to the data storage
  75076. * @param key The key to write
  75077. * @param value The value to write
  75078. */
  75079. static WriteBoolean(key: string, value: boolean): void;
  75080. /**
  75081. * Reads a number from the data storage
  75082. * @param key The key to read
  75083. * @param defaultValue The value if the key doesn't exist
  75084. * @returns The number value
  75085. */
  75086. static ReadNumber(key: string, defaultValue: number): number;
  75087. /**
  75088. * Writes a number to the data storage
  75089. * @param key The key to write
  75090. * @param value The value to write
  75091. */
  75092. static WriteNumber(key: string, value: number): void;
  75093. }
  75094. }
  75095. declare module BABYLON {
  75096. /**
  75097. * Class used to record delta files between 2 scene states
  75098. */
  75099. export class SceneRecorder {
  75100. private _trackedScene;
  75101. private _savedJSON;
  75102. /**
  75103. * Track a given scene. This means the current scene state will be considered the original state
  75104. * @param scene defines the scene to track
  75105. */
  75106. track(scene: Scene): void;
  75107. /**
  75108. * Get the delta between current state and original state
  75109. * @returns a string containing the delta
  75110. */
  75111. getDelta(): any;
  75112. private _compareArray;
  75113. private _compareObjects;
  75114. private _compareCollections;
  75115. private static GetShadowGeneratorById;
  75116. /**
  75117. * Apply a given delta to a given scene
  75118. * @param deltaJSON defines the JSON containing the delta
  75119. * @param scene defines the scene to apply the delta to
  75120. */
  75121. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75122. private static _ApplyPropertiesToEntity;
  75123. private static _ApplyDeltaForEntity;
  75124. }
  75125. }
  75126. declare module BABYLON {
  75127. /**
  75128. * A 3D trajectory consisting of an order list of vectors describing a
  75129. * path of motion through 3D space.
  75130. */
  75131. export class Trajectory {
  75132. private _points;
  75133. private readonly _segmentLength;
  75134. /**
  75135. * Serialize to JSON.
  75136. * @returns serialized JSON string
  75137. */
  75138. serialize(): string;
  75139. /**
  75140. * Deserialize from JSON.
  75141. * @param json serialized JSON string
  75142. * @returns deserialized Trajectory
  75143. */
  75144. static Deserialize(json: string): Trajectory;
  75145. /**
  75146. * Create a new empty Trajectory.
  75147. * @param segmentLength radius of discretization for Trajectory points
  75148. */
  75149. constructor(segmentLength?: number);
  75150. /**
  75151. * Get the length of the Trajectory.
  75152. * @returns length of the Trajectory
  75153. */
  75154. getLength(): number;
  75155. /**
  75156. * Append a new point to the Trajectory.
  75157. * NOTE: This implementation has many allocations.
  75158. * @param point point to append to the Trajectory
  75159. */
  75160. add(point: DeepImmutable<Vector3>): void;
  75161. /**
  75162. * Create a new Trajectory with a segment length chosen to make it
  75163. * probable that the new Trajectory will have a specified number of
  75164. * segments. This operation is imprecise.
  75165. * @param targetResolution number of segments desired
  75166. * @returns new Trajectory with approximately the requested number of segments
  75167. */
  75168. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75169. /**
  75170. * Convert Trajectory segments into tokenized representation. This
  75171. * representation is an array of numbers where each nth number is the
  75172. * index of the token which is most similar to the nth segment of the
  75173. * Trajectory.
  75174. * @param tokens list of vectors which serve as discrete tokens
  75175. * @returns list of indices of most similar token per segment
  75176. */
  75177. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75178. private static _forwardDir;
  75179. private static _inverseFromVec;
  75180. private static _upDir;
  75181. private static _fromToVec;
  75182. private static _lookMatrix;
  75183. /**
  75184. * Transform the rotation (i.e., direction) of a segment to isolate
  75185. * the relative transformation represented by the segment. This operation
  75186. * may or may not succeed due to singularities in the equations that define
  75187. * motion relativity in this context.
  75188. * @param priorVec the origin of the prior segment
  75189. * @param fromVec the origin of the current segment
  75190. * @param toVec the destination of the current segment
  75191. * @param result reference to output variable
  75192. * @returns whether or not transformation was successful
  75193. */
  75194. private static _transformSegmentDirToRef;
  75195. private static _bestMatch;
  75196. private static _score;
  75197. private static _bestScore;
  75198. /**
  75199. * Determine which token vector is most similar to the
  75200. * segment vector.
  75201. * @param segment segment vector
  75202. * @param tokens token vector list
  75203. * @returns index of the most similar token to the segment
  75204. */
  75205. private static _tokenizeSegment;
  75206. }
  75207. /**
  75208. * Class representing a set of known, named trajectories to which Trajectories can be
  75209. * added and using which Trajectories can be recognized.
  75210. */
  75211. export class TrajectoryClassifier {
  75212. private _maximumAllowableMatchCost;
  75213. private _vector3Alphabet;
  75214. private _levenshteinAlphabet;
  75215. private _nameToDescribedTrajectory;
  75216. /**
  75217. * Serialize to JSON.
  75218. * @returns JSON serialization
  75219. */
  75220. serialize(): string;
  75221. /**
  75222. * Deserialize from JSON.
  75223. * @param json JSON serialization
  75224. * @returns deserialized TrajectorySet
  75225. */
  75226. static Deserialize(json: string): TrajectoryClassifier;
  75227. /**
  75228. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75229. * VERY naive, need to be generating these things from known
  75230. * sets. Better version later, probably eliminating this one.
  75231. * @returns auto-generated TrajectorySet
  75232. */
  75233. static Generate(): TrajectoryClassifier;
  75234. private constructor();
  75235. /**
  75236. * Add a new Trajectory to the set with a given name.
  75237. * @param trajectory new Trajectory to be added
  75238. * @param classification name to which to add the Trajectory
  75239. */
  75240. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75241. /**
  75242. * Remove a known named trajectory and all Trajectories associated with it.
  75243. * @param classification name to remove
  75244. * @returns whether anything was removed
  75245. */
  75246. deleteClassification(classification: string): boolean;
  75247. /**
  75248. * Attempt to recognize a Trajectory from among all the classifications
  75249. * already known to the classifier.
  75250. * @param trajectory Trajectory to be recognized
  75251. * @returns classification of Trajectory if recognized, null otherwise
  75252. */
  75253. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75254. }
  75255. }
  75256. declare module BABYLON {
  75257. /**
  75258. * An interface for all Hit test features
  75259. */
  75260. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75261. /**
  75262. * Triggered when new babylon (transformed) hit test results are available
  75263. */
  75264. onHitTestResultObservable: Observable<T[]>;
  75265. }
  75266. /**
  75267. * Options used for hit testing
  75268. */
  75269. export interface IWebXRLegacyHitTestOptions {
  75270. /**
  75271. * Only test when user interacted with the scene. Default - hit test every frame
  75272. */
  75273. testOnPointerDownOnly?: boolean;
  75274. /**
  75275. * The node to use to transform the local results to world coordinates
  75276. */
  75277. worldParentNode?: TransformNode;
  75278. }
  75279. /**
  75280. * Interface defining the babylon result of raycasting/hit-test
  75281. */
  75282. export interface IWebXRLegacyHitResult {
  75283. /**
  75284. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75285. */
  75286. transformationMatrix: Matrix;
  75287. /**
  75288. * The native hit test result
  75289. */
  75290. xrHitResult: XRHitResult | XRHitTestResult;
  75291. }
  75292. /**
  75293. * The currently-working hit-test module.
  75294. * Hit test (or Ray-casting) is used to interact with the real world.
  75295. * For further information read here - https://github.com/immersive-web/hit-test
  75296. */
  75297. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75298. /**
  75299. * options to use when constructing this feature
  75300. */
  75301. readonly options: IWebXRLegacyHitTestOptions;
  75302. private _direction;
  75303. private _mat;
  75304. private _onSelectEnabled;
  75305. private _origin;
  75306. /**
  75307. * The module's name
  75308. */
  75309. static readonly Name: string;
  75310. /**
  75311. * The (Babylon) version of this module.
  75312. * This is an integer representing the implementation version.
  75313. * This number does not correspond to the WebXR specs version
  75314. */
  75315. static readonly Version: number;
  75316. /**
  75317. * Populated with the last native XR Hit Results
  75318. */
  75319. lastNativeXRHitResults: XRHitResult[];
  75320. /**
  75321. * Triggered when new babylon (transformed) hit test results are available
  75322. */
  75323. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75324. /**
  75325. * Creates a new instance of the (legacy version) hit test feature
  75326. * @param _xrSessionManager an instance of WebXRSessionManager
  75327. * @param options options to use when constructing this feature
  75328. */
  75329. constructor(_xrSessionManager: WebXRSessionManager,
  75330. /**
  75331. * options to use when constructing this feature
  75332. */
  75333. options?: IWebXRLegacyHitTestOptions);
  75334. /**
  75335. * execute a hit test with an XR Ray
  75336. *
  75337. * @param xrSession a native xrSession that will execute this hit test
  75338. * @param xrRay the ray (position and direction) to use for ray-casting
  75339. * @param referenceSpace native XR reference space to use for the hit-test
  75340. * @param filter filter function that will filter the results
  75341. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75342. */
  75343. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75344. /**
  75345. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75346. * @param event the (select) event to use to select with
  75347. * @param referenceSpace the reference space to use for this hit test
  75348. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75349. */
  75350. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75351. /**
  75352. * attach this feature
  75353. * Will usually be called by the features manager
  75354. *
  75355. * @returns true if successful.
  75356. */
  75357. attach(): boolean;
  75358. /**
  75359. * detach this feature.
  75360. * Will usually be called by the features manager
  75361. *
  75362. * @returns true if successful.
  75363. */
  75364. detach(): boolean;
  75365. /**
  75366. * Dispose this feature and all of the resources attached
  75367. */
  75368. dispose(): void;
  75369. protected _onXRFrame(frame: XRFrame): void;
  75370. private _onHitTestResults;
  75371. private _onSelect;
  75372. }
  75373. }
  75374. declare module BABYLON {
  75375. /**
  75376. * Options used for hit testing (version 2)
  75377. */
  75378. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75379. /**
  75380. * Do not create a permanent hit test. Will usually be used when only
  75381. * transient inputs are needed.
  75382. */
  75383. disablePermanentHitTest?: boolean;
  75384. /**
  75385. * Enable transient (for example touch-based) hit test inspections
  75386. */
  75387. enableTransientHitTest?: boolean;
  75388. /**
  75389. * Offset ray for the permanent hit test
  75390. */
  75391. offsetRay?: Vector3;
  75392. /**
  75393. * Offset ray for the transient hit test
  75394. */
  75395. transientOffsetRay?: Vector3;
  75396. /**
  75397. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75398. */
  75399. useReferenceSpace?: boolean;
  75400. /**
  75401. * Override the default entity type(s) of the hit-test result
  75402. */
  75403. entityTypes?: XRHitTestTrackableType[];
  75404. }
  75405. /**
  75406. * Interface defining the babylon result of hit-test
  75407. */
  75408. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75409. /**
  75410. * The input source that generated this hit test (if transient)
  75411. */
  75412. inputSource?: XRInputSource;
  75413. /**
  75414. * Is this a transient hit test
  75415. */
  75416. isTransient?: boolean;
  75417. /**
  75418. * Position of the hit test result
  75419. */
  75420. position: Vector3;
  75421. /**
  75422. * Rotation of the hit test result
  75423. */
  75424. rotationQuaternion: Quaternion;
  75425. /**
  75426. * The native hit test result
  75427. */
  75428. xrHitResult: XRHitTestResult;
  75429. }
  75430. /**
  75431. * The currently-working hit-test module.
  75432. * Hit test (or Ray-casting) is used to interact with the real world.
  75433. * For further information read here - https://github.com/immersive-web/hit-test
  75434. *
  75435. * Tested on chrome (mobile) 80.
  75436. */
  75437. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75438. /**
  75439. * options to use when constructing this feature
  75440. */
  75441. readonly options: IWebXRHitTestOptions;
  75442. private _tmpMat;
  75443. private _tmpPos;
  75444. private _tmpQuat;
  75445. private _transientXrHitTestSource;
  75446. private _xrHitTestSource;
  75447. private initHitTestSource;
  75448. /**
  75449. * The module's name
  75450. */
  75451. static readonly Name: string;
  75452. /**
  75453. * The (Babylon) version of this module.
  75454. * This is an integer representing the implementation version.
  75455. * This number does not correspond to the WebXR specs version
  75456. */
  75457. static readonly Version: number;
  75458. /**
  75459. * When set to true, each hit test will have its own position/rotation objects
  75460. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75461. * the developers will clone them or copy them as they see fit.
  75462. */
  75463. autoCloneTransformation: boolean;
  75464. /**
  75465. * Triggered when new babylon (transformed) hit test results are available
  75466. * Note - this will be called when results come back from the device. It can be an empty array!!
  75467. */
  75468. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75469. /**
  75470. * Use this to temporarily pause hit test checks.
  75471. */
  75472. paused: boolean;
  75473. /**
  75474. * Creates a new instance of the hit test feature
  75475. * @param _xrSessionManager an instance of WebXRSessionManager
  75476. * @param options options to use when constructing this feature
  75477. */
  75478. constructor(_xrSessionManager: WebXRSessionManager,
  75479. /**
  75480. * options to use when constructing this feature
  75481. */
  75482. options?: IWebXRHitTestOptions);
  75483. /**
  75484. * attach this feature
  75485. * Will usually be called by the features manager
  75486. *
  75487. * @returns true if successful.
  75488. */
  75489. attach(): boolean;
  75490. /**
  75491. * detach this feature.
  75492. * Will usually be called by the features manager
  75493. *
  75494. * @returns true if successful.
  75495. */
  75496. detach(): boolean;
  75497. /**
  75498. * Dispose this feature and all of the resources attached
  75499. */
  75500. dispose(): void;
  75501. protected _onXRFrame(frame: XRFrame): void;
  75502. private _processWebXRHitTestResult;
  75503. }
  75504. }
  75505. declare module BABYLON {
  75506. /**
  75507. * Configuration options of the anchor system
  75508. */
  75509. export interface IWebXRAnchorSystemOptions {
  75510. /**
  75511. * a node that will be used to convert local to world coordinates
  75512. */
  75513. worldParentNode?: TransformNode;
  75514. /**
  75515. * If set to true a reference of the created anchors will be kept until the next session starts
  75516. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75517. */
  75518. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75519. }
  75520. /**
  75521. * A babylon container for an XR Anchor
  75522. */
  75523. export interface IWebXRAnchor {
  75524. /**
  75525. * A babylon-assigned ID for this anchor
  75526. */
  75527. id: number;
  75528. /**
  75529. * Transformation matrix to apply to an object attached to this anchor
  75530. */
  75531. transformationMatrix: Matrix;
  75532. /**
  75533. * The native anchor object
  75534. */
  75535. xrAnchor: XRAnchor;
  75536. /**
  75537. * if defined, this object will be constantly updated by the anchor's position and rotation
  75538. */
  75539. attachedNode?: TransformNode;
  75540. }
  75541. /**
  75542. * An implementation of the anchor system for WebXR.
  75543. * For further information see https://github.com/immersive-web/anchors/
  75544. */
  75545. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75546. private _options;
  75547. private _lastFrameDetected;
  75548. private _trackedAnchors;
  75549. private _referenceSpaceForFrameAnchors;
  75550. private _futureAnchors;
  75551. /**
  75552. * The module's name
  75553. */
  75554. static readonly Name: string;
  75555. /**
  75556. * The (Babylon) version of this module.
  75557. * This is an integer representing the implementation version.
  75558. * This number does not correspond to the WebXR specs version
  75559. */
  75560. static readonly Version: number;
  75561. /**
  75562. * Observers registered here will be executed when a new anchor was added to the session
  75563. */
  75564. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75565. /**
  75566. * Observers registered here will be executed when an anchor was removed from the session
  75567. */
  75568. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75569. /**
  75570. * Observers registered here will be executed when an existing anchor updates
  75571. * This can execute N times every frame
  75572. */
  75573. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75574. /**
  75575. * Set the reference space to use for anchor creation, when not using a hit test.
  75576. * Will default to the session's reference space if not defined
  75577. */
  75578. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75579. /**
  75580. * constructs a new anchor system
  75581. * @param _xrSessionManager an instance of WebXRSessionManager
  75582. * @param _options configuration object for this feature
  75583. */
  75584. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75585. private _tmpVector;
  75586. private _tmpQuaternion;
  75587. private _populateTmpTransformation;
  75588. /**
  75589. * Create a new anchor point using a hit test result at a specific point in the scene
  75590. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75591. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75592. *
  75593. * @param hitTestResult The hit test result to use for this anchor creation
  75594. * @param position an optional position offset for this anchor
  75595. * @param rotationQuaternion an optional rotation offset for this anchor
  75596. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75597. */
  75598. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75599. /**
  75600. * Add a new anchor at a specific position and rotation
  75601. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75602. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75603. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75604. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75605. *
  75606. * @param position the position in which to add an anchor
  75607. * @param rotationQuaternion an optional rotation for the anchor transformation
  75608. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75609. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75610. */
  75611. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75612. /**
  75613. * detach this feature.
  75614. * Will usually be called by the features manager
  75615. *
  75616. * @returns true if successful.
  75617. */
  75618. detach(): boolean;
  75619. /**
  75620. * Dispose this feature and all of the resources attached
  75621. */
  75622. dispose(): void;
  75623. protected _onXRFrame(frame: XRFrame): void;
  75624. /**
  75625. * avoiding using Array.find for global support.
  75626. * @param xrAnchor the plane to find in the array
  75627. */
  75628. private _findIndexInAnchorArray;
  75629. private _updateAnchorWithXRFrame;
  75630. private _createAnchorAtTransformation;
  75631. }
  75632. }
  75633. declare module BABYLON {
  75634. /**
  75635. * Options used in the plane detector module
  75636. */
  75637. export interface IWebXRPlaneDetectorOptions {
  75638. /**
  75639. * The node to use to transform the local results to world coordinates
  75640. */
  75641. worldParentNode?: TransformNode;
  75642. /**
  75643. * If set to true a reference of the created planes will be kept until the next session starts
  75644. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75645. */
  75646. doNotRemovePlanesOnSessionEnded?: boolean;
  75647. }
  75648. /**
  75649. * A babylon interface for a WebXR plane.
  75650. * A Plane is actually a polygon, built from N points in space
  75651. *
  75652. * Supported in chrome 79, not supported in canary 81 ATM
  75653. */
  75654. export interface IWebXRPlane {
  75655. /**
  75656. * a babylon-assigned ID for this polygon
  75657. */
  75658. id: number;
  75659. /**
  75660. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75661. */
  75662. polygonDefinition: Array<Vector3>;
  75663. /**
  75664. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75665. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75666. */
  75667. transformationMatrix: Matrix;
  75668. /**
  75669. * the native xr-plane object
  75670. */
  75671. xrPlane: XRPlane;
  75672. }
  75673. /**
  75674. * The plane detector is used to detect planes in the real world when in AR
  75675. * For more information see https://github.com/immersive-web/real-world-geometry/
  75676. */
  75677. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75678. private _options;
  75679. private _detectedPlanes;
  75680. private _enabled;
  75681. private _lastFrameDetected;
  75682. /**
  75683. * The module's name
  75684. */
  75685. static readonly Name: string;
  75686. /**
  75687. * The (Babylon) version of this module.
  75688. * This is an integer representing the implementation version.
  75689. * This number does not correspond to the WebXR specs version
  75690. */
  75691. static readonly Version: number;
  75692. /**
  75693. * Observers registered here will be executed when a new plane was added to the session
  75694. */
  75695. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75696. /**
  75697. * Observers registered here will be executed when a plane is no longer detected in the session
  75698. */
  75699. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75700. /**
  75701. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75702. * This can execute N times every frame
  75703. */
  75704. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75705. /**
  75706. * construct a new Plane Detector
  75707. * @param _xrSessionManager an instance of xr Session manager
  75708. * @param _options configuration to use when constructing this feature
  75709. */
  75710. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75711. /**
  75712. * detach this feature.
  75713. * Will usually be called by the features manager
  75714. *
  75715. * @returns true if successful.
  75716. */
  75717. detach(): boolean;
  75718. /**
  75719. * Dispose this feature and all of the resources attached
  75720. */
  75721. dispose(): void;
  75722. protected _onXRFrame(frame: XRFrame): void;
  75723. private _init;
  75724. private _updatePlaneWithXRPlane;
  75725. /**
  75726. * avoiding using Array.find for global support.
  75727. * @param xrPlane the plane to find in the array
  75728. */
  75729. private findIndexInPlaneArray;
  75730. }
  75731. }
  75732. declare module BABYLON {
  75733. /**
  75734. * Options interface for the background remover plugin
  75735. */
  75736. export interface IWebXRBackgroundRemoverOptions {
  75737. /**
  75738. * Further background meshes to disable when entering AR
  75739. */
  75740. backgroundMeshes?: AbstractMesh[];
  75741. /**
  75742. * flags to configure the removal of the environment helper.
  75743. * If not set, the entire background will be removed. If set, flags should be set as well.
  75744. */
  75745. environmentHelperRemovalFlags?: {
  75746. /**
  75747. * Should the skybox be removed (default false)
  75748. */
  75749. skyBox?: boolean;
  75750. /**
  75751. * Should the ground be removed (default false)
  75752. */
  75753. ground?: boolean;
  75754. };
  75755. /**
  75756. * don't disable the environment helper
  75757. */
  75758. ignoreEnvironmentHelper?: boolean;
  75759. }
  75760. /**
  75761. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75762. */
  75763. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75764. /**
  75765. * read-only options to be used in this module
  75766. */
  75767. readonly options: IWebXRBackgroundRemoverOptions;
  75768. /**
  75769. * The module's name
  75770. */
  75771. static readonly Name: string;
  75772. /**
  75773. * The (Babylon) version of this module.
  75774. * This is an integer representing the implementation version.
  75775. * This number does not correspond to the WebXR specs version
  75776. */
  75777. static readonly Version: number;
  75778. /**
  75779. * registered observers will be triggered when the background state changes
  75780. */
  75781. onBackgroundStateChangedObservable: Observable<boolean>;
  75782. /**
  75783. * constructs a new background remover module
  75784. * @param _xrSessionManager the session manager for this module
  75785. * @param options read-only options to be used in this module
  75786. */
  75787. constructor(_xrSessionManager: WebXRSessionManager,
  75788. /**
  75789. * read-only options to be used in this module
  75790. */
  75791. options?: IWebXRBackgroundRemoverOptions);
  75792. /**
  75793. * attach this feature
  75794. * Will usually be called by the features manager
  75795. *
  75796. * @returns true if successful.
  75797. */
  75798. attach(): boolean;
  75799. /**
  75800. * detach this feature.
  75801. * Will usually be called by the features manager
  75802. *
  75803. * @returns true if successful.
  75804. */
  75805. detach(): boolean;
  75806. /**
  75807. * Dispose this feature and all of the resources attached
  75808. */
  75809. dispose(): void;
  75810. protected _onXRFrame(_xrFrame: XRFrame): void;
  75811. private _setBackgroundState;
  75812. }
  75813. }
  75814. declare module BABYLON {
  75815. /**
  75816. * Options for the controller physics feature
  75817. */
  75818. export class IWebXRControllerPhysicsOptions {
  75819. /**
  75820. * Should the headset get its own impostor
  75821. */
  75822. enableHeadsetImpostor?: boolean;
  75823. /**
  75824. * Optional parameters for the headset impostor
  75825. */
  75826. headsetImpostorParams?: {
  75827. /**
  75828. * The type of impostor to create. Default is sphere
  75829. */
  75830. impostorType: number;
  75831. /**
  75832. * the size of the impostor. Defaults to 10cm
  75833. */
  75834. impostorSize?: number | {
  75835. width: number;
  75836. height: number;
  75837. depth: number;
  75838. };
  75839. /**
  75840. * Friction definitions
  75841. */
  75842. friction?: number;
  75843. /**
  75844. * Restitution
  75845. */
  75846. restitution?: number;
  75847. };
  75848. /**
  75849. * The physics properties of the future impostors
  75850. */
  75851. physicsProperties?: {
  75852. /**
  75853. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75854. * Note that this requires a physics engine that supports mesh impostors!
  75855. */
  75856. useControllerMesh?: boolean;
  75857. /**
  75858. * The type of impostor to create. Default is sphere
  75859. */
  75860. impostorType?: number;
  75861. /**
  75862. * the size of the impostor. Defaults to 10cm
  75863. */
  75864. impostorSize?: number | {
  75865. width: number;
  75866. height: number;
  75867. depth: number;
  75868. };
  75869. /**
  75870. * Friction definitions
  75871. */
  75872. friction?: number;
  75873. /**
  75874. * Restitution
  75875. */
  75876. restitution?: number;
  75877. };
  75878. /**
  75879. * the xr input to use with this pointer selection
  75880. */
  75881. xrInput: WebXRInput;
  75882. }
  75883. /**
  75884. * Add physics impostor to your webxr controllers,
  75885. * including naive calculation of their linear and angular velocity
  75886. */
  75887. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75888. private readonly _options;
  75889. private _attachController;
  75890. private _controllers;
  75891. private _debugMode;
  75892. private _delta;
  75893. private _headsetImpostor?;
  75894. private _headsetMesh?;
  75895. private _lastTimestamp;
  75896. private _tmpQuaternion;
  75897. private _tmpVector;
  75898. /**
  75899. * The module's name
  75900. */
  75901. static readonly Name: string;
  75902. /**
  75903. * The (Babylon) version of this module.
  75904. * This is an integer representing the implementation version.
  75905. * This number does not correspond to the webxr specs version
  75906. */
  75907. static readonly Version: number;
  75908. /**
  75909. * Construct a new Controller Physics Feature
  75910. * @param _xrSessionManager the corresponding xr session manager
  75911. * @param _options options to create this feature with
  75912. */
  75913. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75914. /**
  75915. * @hidden
  75916. * enable debugging - will show console outputs and the impostor mesh
  75917. */
  75918. _enablePhysicsDebug(): void;
  75919. /**
  75920. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75921. * @param xrController the controller to add
  75922. */
  75923. addController(xrController: WebXRInputSource): void;
  75924. /**
  75925. * attach this feature
  75926. * Will usually be called by the features manager
  75927. *
  75928. * @returns true if successful.
  75929. */
  75930. attach(): boolean;
  75931. /**
  75932. * detach this feature.
  75933. * Will usually be called by the features manager
  75934. *
  75935. * @returns true if successful.
  75936. */
  75937. detach(): boolean;
  75938. /**
  75939. * Get the headset impostor, if enabled
  75940. * @returns the impostor
  75941. */
  75942. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75943. /**
  75944. * Get the physics impostor of a specific controller.
  75945. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75946. * @param controller the controller or the controller id of which to get the impostor
  75947. * @returns the impostor or null
  75948. */
  75949. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75950. /**
  75951. * Update the physics properties provided in the constructor
  75952. * @param newProperties the new properties object
  75953. */
  75954. setPhysicsProperties(newProperties: {
  75955. impostorType?: number;
  75956. impostorSize?: number | {
  75957. width: number;
  75958. height: number;
  75959. depth: number;
  75960. };
  75961. friction?: number;
  75962. restitution?: number;
  75963. }): void;
  75964. protected _onXRFrame(_xrFrame: any): void;
  75965. private _detachController;
  75966. }
  75967. }
  75968. declare module BABYLON {
  75969. /**
  75970. * A babylon interface for a "WebXR" feature point.
  75971. * Represents the position and confidence value of a given feature point.
  75972. */
  75973. export interface IWebXRFeaturePoint {
  75974. /**
  75975. * Represents the position of the feature point in world space.
  75976. */
  75977. position: Vector3;
  75978. /**
  75979. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75980. */
  75981. confidenceValue: number;
  75982. }
  75983. /**
  75984. * The feature point system is used to detect feature points from real world geometry.
  75985. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75986. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75987. */
  75988. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75989. private _enabled;
  75990. private _featurePointCloud;
  75991. /**
  75992. * The module's name
  75993. */
  75994. static readonly Name: string;
  75995. /**
  75996. * The (Babylon) version of this module.
  75997. * This is an integer representing the implementation version.
  75998. * This number does not correspond to the WebXR specs version
  75999. */
  76000. static readonly Version: number;
  76001. /**
  76002. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76003. * Will notify the observers about which feature points have been added.
  76004. */
  76005. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76006. /**
  76007. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76008. * Will notify the observers about which feature points have been updated.
  76009. */
  76010. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76011. /**
  76012. * The current feature point cloud maintained across frames.
  76013. */
  76014. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76015. /**
  76016. * construct the feature point system
  76017. * @param _xrSessionManager an instance of xr Session manager
  76018. */
  76019. constructor(_xrSessionManager: WebXRSessionManager);
  76020. /**
  76021. * Detach this feature.
  76022. * Will usually be called by the features manager
  76023. *
  76024. * @returns true if successful.
  76025. */
  76026. detach(): boolean;
  76027. /**
  76028. * Dispose this feature and all of the resources attached
  76029. */
  76030. dispose(): void;
  76031. /**
  76032. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76033. */
  76034. protected _onXRFrame(frame: XRFrame): void;
  76035. /**
  76036. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76037. */
  76038. private _init;
  76039. }
  76040. }
  76041. declare module BABYLON {
  76042. /**
  76043. * Configuration interface for the hand tracking feature
  76044. */
  76045. export interface IWebXRHandTrackingOptions {
  76046. /**
  76047. * The xrInput that will be used as source for new hands
  76048. */
  76049. xrInput: WebXRInput;
  76050. /**
  76051. * Configuration object for the joint meshes
  76052. */
  76053. jointMeshes?: {
  76054. /**
  76055. * Should the meshes created be invisible (defaults to false)
  76056. */
  76057. invisible?: boolean;
  76058. /**
  76059. * A source mesh to be used to create instances. Defaults to a sphere.
  76060. * This mesh will be the source for all other (25) meshes.
  76061. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76062. */
  76063. sourceMesh?: Mesh;
  76064. /**
  76065. * This function will be called after a mesh was created for a specific joint.
  76066. * Using this function you can either manipulate the instance or return a new mesh.
  76067. * When returning a new mesh the instance created before will be disposed
  76068. */
  76069. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76070. /**
  76071. * Should the source mesh stay visible. Defaults to false
  76072. */
  76073. keepOriginalVisible?: boolean;
  76074. /**
  76075. * Scale factor for all instances (defaults to 2)
  76076. */
  76077. scaleFactor?: number;
  76078. /**
  76079. * Should each instance have its own physics impostor
  76080. */
  76081. enablePhysics?: boolean;
  76082. /**
  76083. * If enabled, override default physics properties
  76084. */
  76085. physicsProps?: {
  76086. friction?: number;
  76087. restitution?: number;
  76088. impostorType?: number;
  76089. };
  76090. /**
  76091. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76092. */
  76093. handMesh?: AbstractMesh;
  76094. };
  76095. }
  76096. /**
  76097. * Parts of the hands divided to writs and finger names
  76098. */
  76099. export const enum HandPart {
  76100. /**
  76101. * HandPart - Wrist
  76102. */
  76103. WRIST = "wrist",
  76104. /**
  76105. * HandPart - The THumb
  76106. */
  76107. THUMB = "thumb",
  76108. /**
  76109. * HandPart - Index finger
  76110. */
  76111. INDEX = "index",
  76112. /**
  76113. * HandPart - Middle finger
  76114. */
  76115. MIDDLE = "middle",
  76116. /**
  76117. * HandPart - Ring finger
  76118. */
  76119. RING = "ring",
  76120. /**
  76121. * HandPart - Little finger
  76122. */
  76123. LITTLE = "little"
  76124. }
  76125. /**
  76126. * Representing a single hand (with its corresponding native XRHand object)
  76127. */
  76128. export class WebXRHand implements IDisposable {
  76129. /** the controller to which the hand correlates */
  76130. readonly xrController: WebXRInputSource;
  76131. /** the meshes to be used to track the hand joints */
  76132. readonly trackedMeshes: AbstractMesh[];
  76133. /**
  76134. * Hand-parts definition (key is HandPart)
  76135. */
  76136. handPartsDefinition: {
  76137. [key: string]: number[];
  76138. };
  76139. /**
  76140. * Populate the HandPartsDefinition object.
  76141. * This is called as a side effect since certain browsers don't have XRHand defined.
  76142. */
  76143. private generateHandPartsDefinition;
  76144. /**
  76145. * Construct a new hand object
  76146. * @param xrController the controller to which the hand correlates
  76147. * @param trackedMeshes the meshes to be used to track the hand joints
  76148. */
  76149. constructor(
  76150. /** the controller to which the hand correlates */
  76151. xrController: WebXRInputSource,
  76152. /** the meshes to be used to track the hand joints */
  76153. trackedMeshes: AbstractMesh[]);
  76154. /**
  76155. * Update this hand from the latest xr frame
  76156. * @param xrFrame xrFrame to update from
  76157. * @param referenceSpace The current viewer reference space
  76158. * @param scaleFactor optional scale factor for the meshes
  76159. */
  76160. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76161. /**
  76162. * Get meshes of part of the hand
  76163. * @param part the part of hand to get
  76164. * @returns An array of meshes that correlate to the hand part requested
  76165. */
  76166. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76167. /**
  76168. * Dispose this Hand object
  76169. */
  76170. dispose(): void;
  76171. }
  76172. /**
  76173. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76174. */
  76175. export class WebXRHandTracking extends WebXRAbstractFeature {
  76176. /**
  76177. * options to use when constructing this feature
  76178. */
  76179. readonly options: IWebXRHandTrackingOptions;
  76180. private static _idCounter;
  76181. /**
  76182. * The module's name
  76183. */
  76184. static readonly Name: string;
  76185. /**
  76186. * The (Babylon) version of this module.
  76187. * This is an integer representing the implementation version.
  76188. * This number does not correspond to the WebXR specs version
  76189. */
  76190. static readonly Version: number;
  76191. /**
  76192. * This observable will notify registered observers when a new hand object was added and initialized
  76193. */
  76194. onHandAddedObservable: Observable<WebXRHand>;
  76195. /**
  76196. * This observable will notify its observers right before the hand object is disposed
  76197. */
  76198. onHandRemovedObservable: Observable<WebXRHand>;
  76199. private _hands;
  76200. /**
  76201. * Creates a new instance of the hit test feature
  76202. * @param _xrSessionManager an instance of WebXRSessionManager
  76203. * @param options options to use when constructing this feature
  76204. */
  76205. constructor(_xrSessionManager: WebXRSessionManager,
  76206. /**
  76207. * options to use when constructing this feature
  76208. */
  76209. options: IWebXRHandTrackingOptions);
  76210. /**
  76211. * Check if the needed objects are defined.
  76212. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76213. */
  76214. isCompatible(): boolean;
  76215. /**
  76216. * attach this feature
  76217. * Will usually be called by the features manager
  76218. *
  76219. * @returns true if successful.
  76220. */
  76221. attach(): boolean;
  76222. /**
  76223. * detach this feature.
  76224. * Will usually be called by the features manager
  76225. *
  76226. * @returns true if successful.
  76227. */
  76228. detach(): boolean;
  76229. /**
  76230. * Dispose this feature and all of the resources attached
  76231. */
  76232. dispose(): void;
  76233. /**
  76234. * Get the hand object according to the controller id
  76235. * @param controllerId the controller id to which we want to get the hand
  76236. * @returns null if not found or the WebXRHand object if found
  76237. */
  76238. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76239. /**
  76240. * Get a hand object according to the requested handedness
  76241. * @param handedness the handedness to request
  76242. * @returns null if not found or the WebXRHand object if found
  76243. */
  76244. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76245. protected _onXRFrame(_xrFrame: XRFrame): void;
  76246. private _attachHand;
  76247. private _detachHand;
  76248. }
  76249. }
  76250. declare module BABYLON {
  76251. /**
  76252. * The motion controller class for all microsoft mixed reality controllers
  76253. */
  76254. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76255. protected readonly _mapping: {
  76256. defaultButton: {
  76257. valueNodeName: string;
  76258. unpressedNodeName: string;
  76259. pressedNodeName: string;
  76260. };
  76261. defaultAxis: {
  76262. valueNodeName: string;
  76263. minNodeName: string;
  76264. maxNodeName: string;
  76265. };
  76266. buttons: {
  76267. "xr-standard-trigger": {
  76268. rootNodeName: string;
  76269. componentProperty: string;
  76270. states: string[];
  76271. };
  76272. "xr-standard-squeeze": {
  76273. rootNodeName: string;
  76274. componentProperty: string;
  76275. states: string[];
  76276. };
  76277. "xr-standard-touchpad": {
  76278. rootNodeName: string;
  76279. labelAnchorNodeName: string;
  76280. touchPointNodeName: string;
  76281. };
  76282. "xr-standard-thumbstick": {
  76283. rootNodeName: string;
  76284. componentProperty: string;
  76285. states: string[];
  76286. };
  76287. };
  76288. axes: {
  76289. "xr-standard-touchpad": {
  76290. "x-axis": {
  76291. rootNodeName: string;
  76292. };
  76293. "y-axis": {
  76294. rootNodeName: string;
  76295. };
  76296. };
  76297. "xr-standard-thumbstick": {
  76298. "x-axis": {
  76299. rootNodeName: string;
  76300. };
  76301. "y-axis": {
  76302. rootNodeName: string;
  76303. };
  76304. };
  76305. };
  76306. };
  76307. /**
  76308. * The base url used to load the left and right controller models
  76309. */
  76310. static MODEL_BASE_URL: string;
  76311. /**
  76312. * The name of the left controller model file
  76313. */
  76314. static MODEL_LEFT_FILENAME: string;
  76315. /**
  76316. * The name of the right controller model file
  76317. */
  76318. static MODEL_RIGHT_FILENAME: string;
  76319. profileId: string;
  76320. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76321. protected _getFilenameAndPath(): {
  76322. filename: string;
  76323. path: string;
  76324. };
  76325. protected _getModelLoadingConstraints(): boolean;
  76326. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76327. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76328. protected _updateModel(): void;
  76329. }
  76330. }
  76331. declare module BABYLON {
  76332. /**
  76333. * The motion controller class for oculus touch (quest, rift).
  76334. * This class supports legacy mapping as well the standard xr mapping
  76335. */
  76336. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76337. private _forceLegacyControllers;
  76338. private _modelRootNode;
  76339. /**
  76340. * The base url used to load the left and right controller models
  76341. */
  76342. static MODEL_BASE_URL: string;
  76343. /**
  76344. * The name of the left controller model file
  76345. */
  76346. static MODEL_LEFT_FILENAME: string;
  76347. /**
  76348. * The name of the right controller model file
  76349. */
  76350. static MODEL_RIGHT_FILENAME: string;
  76351. /**
  76352. * Base Url for the Quest controller model.
  76353. */
  76354. static QUEST_MODEL_BASE_URL: string;
  76355. profileId: string;
  76356. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76357. protected _getFilenameAndPath(): {
  76358. filename: string;
  76359. path: string;
  76360. };
  76361. protected _getModelLoadingConstraints(): boolean;
  76362. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76363. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76364. protected _updateModel(): void;
  76365. /**
  76366. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76367. * between the touch and touch 2.
  76368. */
  76369. private _isQuest;
  76370. }
  76371. }
  76372. declare module BABYLON {
  76373. /**
  76374. * The motion controller class for the standard HTC-Vive controllers
  76375. */
  76376. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76377. private _modelRootNode;
  76378. /**
  76379. * The base url used to load the left and right controller models
  76380. */
  76381. static MODEL_BASE_URL: string;
  76382. /**
  76383. * File name for the controller model.
  76384. */
  76385. static MODEL_FILENAME: string;
  76386. profileId: string;
  76387. /**
  76388. * Create a new Vive motion controller object
  76389. * @param scene the scene to use to create this controller
  76390. * @param gamepadObject the corresponding gamepad object
  76391. * @param handedness the handedness of the controller
  76392. */
  76393. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76394. protected _getFilenameAndPath(): {
  76395. filename: string;
  76396. path: string;
  76397. };
  76398. protected _getModelLoadingConstraints(): boolean;
  76399. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76400. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76401. protected _updateModel(): void;
  76402. }
  76403. }
  76404. declare module BABYLON {
  76405. /**
  76406. * A cursor which tracks a point on a path
  76407. */
  76408. export class PathCursor {
  76409. private path;
  76410. /**
  76411. * Stores path cursor callbacks for when an onchange event is triggered
  76412. */
  76413. private _onchange;
  76414. /**
  76415. * The value of the path cursor
  76416. */
  76417. value: number;
  76418. /**
  76419. * The animation array of the path cursor
  76420. */
  76421. animations: Animation[];
  76422. /**
  76423. * Initializes the path cursor
  76424. * @param path The path to track
  76425. */
  76426. constructor(path: Path2);
  76427. /**
  76428. * Gets the cursor point on the path
  76429. * @returns A point on the path cursor at the cursor location
  76430. */
  76431. getPoint(): Vector3;
  76432. /**
  76433. * Moves the cursor ahead by the step amount
  76434. * @param step The amount to move the cursor forward
  76435. * @returns This path cursor
  76436. */
  76437. moveAhead(step?: number): PathCursor;
  76438. /**
  76439. * Moves the cursor behind by the step amount
  76440. * @param step The amount to move the cursor back
  76441. * @returns This path cursor
  76442. */
  76443. moveBack(step?: number): PathCursor;
  76444. /**
  76445. * Moves the cursor by the step amount
  76446. * If the step amount is greater than one, an exception is thrown
  76447. * @param step The amount to move the cursor
  76448. * @returns This path cursor
  76449. */
  76450. move(step: number): PathCursor;
  76451. /**
  76452. * Ensures that the value is limited between zero and one
  76453. * @returns This path cursor
  76454. */
  76455. private ensureLimits;
  76456. /**
  76457. * Runs onchange callbacks on change (used by the animation engine)
  76458. * @returns This path cursor
  76459. */
  76460. private raiseOnChange;
  76461. /**
  76462. * Executes a function on change
  76463. * @param f A path cursor onchange callback
  76464. * @returns This path cursor
  76465. */
  76466. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76467. }
  76468. }
  76469. declare module BABYLON {
  76470. /** @hidden */
  76471. export var blurPixelShader: {
  76472. name: string;
  76473. shader: string;
  76474. };
  76475. }
  76476. declare module BABYLON {
  76477. /** @hidden */
  76478. export var pointCloudVertexDeclaration: {
  76479. name: string;
  76480. shader: string;
  76481. };
  76482. }
  76483. // Mixins
  76484. interface Window {
  76485. mozIndexedDB: IDBFactory;
  76486. webkitIndexedDB: IDBFactory;
  76487. msIndexedDB: IDBFactory;
  76488. webkitURL: typeof URL;
  76489. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76490. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76491. WebGLRenderingContext: WebGLRenderingContext;
  76492. MSGesture: MSGesture;
  76493. CANNON: any;
  76494. AudioContext: AudioContext;
  76495. webkitAudioContext: AudioContext;
  76496. PointerEvent: any;
  76497. Math: Math;
  76498. Uint8Array: Uint8ArrayConstructor;
  76499. Float32Array: Float32ArrayConstructor;
  76500. mozURL: typeof URL;
  76501. msURL: typeof URL;
  76502. VRFrameData: any; // WebVR, from specs 1.1
  76503. DracoDecoderModule: any;
  76504. setImmediate(handler: (...args: any[]) => void): number;
  76505. }
  76506. interface HTMLCanvasElement {
  76507. requestPointerLock(): void;
  76508. msRequestPointerLock?(): void;
  76509. mozRequestPointerLock?(): void;
  76510. webkitRequestPointerLock?(): void;
  76511. /** Track wether a record is in progress */
  76512. isRecording: boolean;
  76513. /** Capture Stream method defined by some browsers */
  76514. captureStream(fps?: number): MediaStream;
  76515. }
  76516. interface CanvasRenderingContext2D {
  76517. msImageSmoothingEnabled: boolean;
  76518. }
  76519. interface MouseEvent {
  76520. mozMovementX: number;
  76521. mozMovementY: number;
  76522. webkitMovementX: number;
  76523. webkitMovementY: number;
  76524. msMovementX: number;
  76525. msMovementY: number;
  76526. }
  76527. interface Navigator {
  76528. mozGetVRDevices: (any: any) => any;
  76529. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76530. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76531. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76532. webkitGetGamepads(): Gamepad[];
  76533. msGetGamepads(): Gamepad[];
  76534. webkitGamepads(): Gamepad[];
  76535. }
  76536. interface HTMLVideoElement {
  76537. mozSrcObject: any;
  76538. }
  76539. interface Math {
  76540. fround(x: number): number;
  76541. imul(a: number, b: number): number;
  76542. }
  76543. interface WebGLRenderingContext {
  76544. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76545. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76546. vertexAttribDivisor(index: number, divisor: number): void;
  76547. createVertexArray(): any;
  76548. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76549. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76550. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76551. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76552. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76553. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76554. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76555. // Queries
  76556. createQuery(): WebGLQuery;
  76557. deleteQuery(query: WebGLQuery): void;
  76558. beginQuery(target: number, query: WebGLQuery): void;
  76559. endQuery(target: number): void;
  76560. getQueryParameter(query: WebGLQuery, pname: number): any;
  76561. getQuery(target: number, pname: number): any;
  76562. MAX_SAMPLES: number;
  76563. RGBA8: number;
  76564. READ_FRAMEBUFFER: number;
  76565. DRAW_FRAMEBUFFER: number;
  76566. UNIFORM_BUFFER: number;
  76567. HALF_FLOAT_OES: number;
  76568. RGBA16F: number;
  76569. RGBA32F: number;
  76570. R32F: number;
  76571. RG32F: number;
  76572. RGB32F: number;
  76573. R16F: number;
  76574. RG16F: number;
  76575. RGB16F: number;
  76576. RED: number;
  76577. RG: number;
  76578. R8: number;
  76579. RG8: number;
  76580. UNSIGNED_INT_24_8: number;
  76581. DEPTH24_STENCIL8: number;
  76582. MIN: number;
  76583. MAX: number;
  76584. /* Multiple Render Targets */
  76585. drawBuffers(buffers: number[]): void;
  76586. readBuffer(src: number): void;
  76587. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76588. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76589. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76590. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76591. // Occlusion Query
  76592. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76593. ANY_SAMPLES_PASSED: number;
  76594. QUERY_RESULT_AVAILABLE: number;
  76595. QUERY_RESULT: number;
  76596. }
  76597. interface WebGLProgram {
  76598. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76599. }
  76600. interface EXT_disjoint_timer_query {
  76601. QUERY_COUNTER_BITS_EXT: number;
  76602. TIME_ELAPSED_EXT: number;
  76603. TIMESTAMP_EXT: number;
  76604. GPU_DISJOINT_EXT: number;
  76605. QUERY_RESULT_EXT: number;
  76606. QUERY_RESULT_AVAILABLE_EXT: number;
  76607. queryCounterEXT(query: WebGLQuery, target: number): void;
  76608. createQueryEXT(): WebGLQuery;
  76609. beginQueryEXT(target: number, query: WebGLQuery): void;
  76610. endQueryEXT(target: number): void;
  76611. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76612. deleteQueryEXT(query: WebGLQuery): void;
  76613. }
  76614. interface WebGLUniformLocation {
  76615. _currentState: any;
  76616. }
  76617. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76618. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76619. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76620. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76621. interface WebGLRenderingContext {
  76622. readonly RASTERIZER_DISCARD: number;
  76623. readonly DEPTH_COMPONENT24: number;
  76624. readonly TEXTURE_3D: number;
  76625. readonly TEXTURE_2D_ARRAY: number;
  76626. readonly TEXTURE_COMPARE_FUNC: number;
  76627. readonly TEXTURE_COMPARE_MODE: number;
  76628. readonly COMPARE_REF_TO_TEXTURE: number;
  76629. readonly TEXTURE_WRAP_R: number;
  76630. readonly HALF_FLOAT: number;
  76631. readonly RGB8: number;
  76632. readonly RED_INTEGER: number;
  76633. readonly RG_INTEGER: number;
  76634. readonly RGB_INTEGER: number;
  76635. readonly RGBA_INTEGER: number;
  76636. readonly R8_SNORM: number;
  76637. readonly RG8_SNORM: number;
  76638. readonly RGB8_SNORM: number;
  76639. readonly RGBA8_SNORM: number;
  76640. readonly R8I: number;
  76641. readonly RG8I: number;
  76642. readonly RGB8I: number;
  76643. readonly RGBA8I: number;
  76644. readonly R8UI: number;
  76645. readonly RG8UI: number;
  76646. readonly RGB8UI: number;
  76647. readonly RGBA8UI: number;
  76648. readonly R16I: number;
  76649. readonly RG16I: number;
  76650. readonly RGB16I: number;
  76651. readonly RGBA16I: number;
  76652. readonly R16UI: number;
  76653. readonly RG16UI: number;
  76654. readonly RGB16UI: number;
  76655. readonly RGBA16UI: number;
  76656. readonly R32I: number;
  76657. readonly RG32I: number;
  76658. readonly RGB32I: number;
  76659. readonly RGBA32I: number;
  76660. readonly R32UI: number;
  76661. readonly RG32UI: number;
  76662. readonly RGB32UI: number;
  76663. readonly RGBA32UI: number;
  76664. readonly RGB10_A2UI: number;
  76665. readonly R11F_G11F_B10F: number;
  76666. readonly RGB9_E5: number;
  76667. readonly RGB10_A2: number;
  76668. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76669. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76670. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76671. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76672. readonly DEPTH_COMPONENT32F: number;
  76673. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76674. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76675. 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;
  76676. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76677. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76678. readonly TRANSFORM_FEEDBACK: number;
  76679. readonly INTERLEAVED_ATTRIBS: number;
  76680. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76681. createTransformFeedback(): WebGLTransformFeedback;
  76682. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76683. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76684. beginTransformFeedback(primitiveMode: number): void;
  76685. endTransformFeedback(): void;
  76686. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76687. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76688. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76689. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76690. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76691. }
  76692. interface ImageBitmap {
  76693. readonly width: number;
  76694. readonly height: number;
  76695. close(): void;
  76696. }
  76697. interface WebGLQuery extends WebGLObject {
  76698. }
  76699. declare var WebGLQuery: {
  76700. prototype: WebGLQuery;
  76701. new(): WebGLQuery;
  76702. };
  76703. interface WebGLSampler extends WebGLObject {
  76704. }
  76705. declare var WebGLSampler: {
  76706. prototype: WebGLSampler;
  76707. new(): WebGLSampler;
  76708. };
  76709. interface WebGLSync extends WebGLObject {
  76710. }
  76711. declare var WebGLSync: {
  76712. prototype: WebGLSync;
  76713. new(): WebGLSync;
  76714. };
  76715. interface WebGLTransformFeedback extends WebGLObject {
  76716. }
  76717. declare var WebGLTransformFeedback: {
  76718. prototype: WebGLTransformFeedback;
  76719. new(): WebGLTransformFeedback;
  76720. };
  76721. interface WebGLVertexArrayObject extends WebGLObject {
  76722. }
  76723. declare var WebGLVertexArrayObject: {
  76724. prototype: WebGLVertexArrayObject;
  76725. new(): WebGLVertexArrayObject;
  76726. };
  76727. // Type definitions for WebVR API
  76728. // Project: https://w3c.github.io/webvr/
  76729. // Definitions by: six a <https://github.com/lostfictions>
  76730. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76731. interface VRDisplay extends EventTarget {
  76732. /**
  76733. * Dictionary of capabilities describing the VRDisplay.
  76734. */
  76735. readonly capabilities: VRDisplayCapabilities;
  76736. /**
  76737. * z-depth defining the far plane of the eye view frustum
  76738. * enables mapping of values in the render target depth
  76739. * attachment to scene coordinates. Initially set to 10000.0.
  76740. */
  76741. depthFar: number;
  76742. /**
  76743. * z-depth defining the near plane of the eye view frustum
  76744. * enables mapping of values in the render target depth
  76745. * attachment to scene coordinates. Initially set to 0.01.
  76746. */
  76747. depthNear: number;
  76748. /**
  76749. * An identifier for this distinct VRDisplay. Used as an
  76750. * association point in the Gamepad API.
  76751. */
  76752. readonly displayId: number;
  76753. /**
  76754. * A display name, a user-readable name identifying it.
  76755. */
  76756. readonly displayName: string;
  76757. readonly isConnected: boolean;
  76758. readonly isPresenting: boolean;
  76759. /**
  76760. * If this VRDisplay supports room-scale experiences, the optional
  76761. * stage attribute contains details on the room-scale parameters.
  76762. */
  76763. readonly stageParameters: VRStageParameters | null;
  76764. /**
  76765. * Passing the value returned by `requestAnimationFrame` to
  76766. * `cancelAnimationFrame` will unregister the callback.
  76767. * @param handle Define the hanle of the request to cancel
  76768. */
  76769. cancelAnimationFrame(handle: number): void;
  76770. /**
  76771. * Stops presenting to the VRDisplay.
  76772. * @returns a promise to know when it stopped
  76773. */
  76774. exitPresent(): Promise<void>;
  76775. /**
  76776. * Return the current VREyeParameters for the given eye.
  76777. * @param whichEye Define the eye we want the parameter for
  76778. * @returns the eye parameters
  76779. */
  76780. getEyeParameters(whichEye: string): VREyeParameters;
  76781. /**
  76782. * Populates the passed VRFrameData with the information required to render
  76783. * the current frame.
  76784. * @param frameData Define the data structure to populate
  76785. * @returns true if ok otherwise false
  76786. */
  76787. getFrameData(frameData: VRFrameData): boolean;
  76788. /**
  76789. * Get the layers currently being presented.
  76790. * @returns the list of VR layers
  76791. */
  76792. getLayers(): VRLayer[];
  76793. /**
  76794. * Return a VRPose containing the future predicted pose of the VRDisplay
  76795. * when the current frame will be presented. The value returned will not
  76796. * change until JavaScript has returned control to the browser.
  76797. *
  76798. * The VRPose will contain the position, orientation, velocity,
  76799. * and acceleration of each of these properties.
  76800. * @returns the pose object
  76801. */
  76802. getPose(): VRPose;
  76803. /**
  76804. * Return the current instantaneous pose of the VRDisplay, with no
  76805. * prediction applied.
  76806. * @returns the current instantaneous pose
  76807. */
  76808. getImmediatePose(): VRPose;
  76809. /**
  76810. * The callback passed to `requestAnimationFrame` will be called
  76811. * any time a new frame should be rendered. When the VRDisplay is
  76812. * presenting the callback will be called at the native refresh
  76813. * rate of the HMD. When not presenting this function acts
  76814. * identically to how window.requestAnimationFrame acts. Content should
  76815. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76816. * asynchronously from other displays and at differing refresh rates.
  76817. * @param callback Define the eaction to run next frame
  76818. * @returns the request handle it
  76819. */
  76820. requestAnimationFrame(callback: FrameRequestCallback): number;
  76821. /**
  76822. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76823. * Repeat calls while already presenting will update the VRLayers being displayed.
  76824. * @param layers Define the list of layer to present
  76825. * @returns a promise to know when the request has been fulfilled
  76826. */
  76827. requestPresent(layers: VRLayer[]): Promise<void>;
  76828. /**
  76829. * Reset the pose for this display, treating its current position and
  76830. * orientation as the "origin/zero" values. VRPose.position,
  76831. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76832. * updated when calling resetPose(). This should be called in only
  76833. * sitting-space experiences.
  76834. */
  76835. resetPose(): void;
  76836. /**
  76837. * The VRLayer provided to the VRDisplay will be captured and presented
  76838. * in the HMD. Calling this function has the same effect on the source
  76839. * canvas as any other operation that uses its source image, and canvases
  76840. * created without preserveDrawingBuffer set to true will be cleared.
  76841. * @param pose Define the pose to submit
  76842. */
  76843. submitFrame(pose?: VRPose): void;
  76844. }
  76845. declare var VRDisplay: {
  76846. prototype: VRDisplay;
  76847. new(): VRDisplay;
  76848. };
  76849. interface VRLayer {
  76850. leftBounds?: number[] | Float32Array | null;
  76851. rightBounds?: number[] | Float32Array | null;
  76852. source?: HTMLCanvasElement | null;
  76853. }
  76854. interface VRDisplayCapabilities {
  76855. readonly canPresent: boolean;
  76856. readonly hasExternalDisplay: boolean;
  76857. readonly hasOrientation: boolean;
  76858. readonly hasPosition: boolean;
  76859. readonly maxLayers: number;
  76860. }
  76861. interface VREyeParameters {
  76862. /** @deprecated */
  76863. readonly fieldOfView: VRFieldOfView;
  76864. readonly offset: Float32Array;
  76865. readonly renderHeight: number;
  76866. readonly renderWidth: number;
  76867. }
  76868. interface VRFieldOfView {
  76869. readonly downDegrees: number;
  76870. readonly leftDegrees: number;
  76871. readonly rightDegrees: number;
  76872. readonly upDegrees: number;
  76873. }
  76874. interface VRFrameData {
  76875. readonly leftProjectionMatrix: Float32Array;
  76876. readonly leftViewMatrix: Float32Array;
  76877. readonly pose: VRPose;
  76878. readonly rightProjectionMatrix: Float32Array;
  76879. readonly rightViewMatrix: Float32Array;
  76880. readonly timestamp: number;
  76881. }
  76882. interface VRPose {
  76883. readonly angularAcceleration: Float32Array | null;
  76884. readonly angularVelocity: Float32Array | null;
  76885. readonly linearAcceleration: Float32Array | null;
  76886. readonly linearVelocity: Float32Array | null;
  76887. readonly orientation: Float32Array | null;
  76888. readonly position: Float32Array | null;
  76889. readonly timestamp: number;
  76890. }
  76891. interface VRStageParameters {
  76892. sittingToStandingTransform?: Float32Array;
  76893. sizeX?: number;
  76894. sizeY?: number;
  76895. }
  76896. interface Navigator {
  76897. getVRDisplays(): Promise<VRDisplay[]>;
  76898. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76899. }
  76900. interface Window {
  76901. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76902. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76903. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76904. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76905. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76906. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76907. }
  76908. interface Gamepad {
  76909. readonly displayId: number;
  76910. }
  76911. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76912. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76913. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76914. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76915. type XRHandedness = "none" | "left" | "right";
  76916. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76917. type XREye = "none" | "left" | "right";
  76918. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76919. interface XRSpace extends EventTarget {}
  76920. interface XRRenderState {
  76921. depthNear?: number;
  76922. depthFar?: number;
  76923. inlineVerticalFieldOfView?: number;
  76924. baseLayer?: XRWebGLLayer;
  76925. }
  76926. interface XRInputSource {
  76927. handedness: XRHandedness;
  76928. targetRayMode: XRTargetRayMode;
  76929. targetRaySpace: XRSpace;
  76930. gripSpace: XRSpace | undefined;
  76931. gamepad: Gamepad | undefined;
  76932. profiles: Array<string>;
  76933. hand: XRHand | undefined;
  76934. }
  76935. interface XRSessionInit {
  76936. optionalFeatures?: string[];
  76937. requiredFeatures?: string[];
  76938. }
  76939. interface XRSession {
  76940. addEventListener: Function;
  76941. removeEventListener: Function;
  76942. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76943. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76944. requestAnimationFrame: Function;
  76945. end(): Promise<void>;
  76946. renderState: XRRenderState;
  76947. inputSources: Array<XRInputSource>;
  76948. // hit test
  76949. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76950. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76951. // legacy AR hit test
  76952. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76953. // legacy plane detection
  76954. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76955. }
  76956. interface XRReferenceSpace extends XRSpace {
  76957. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76958. onreset: any;
  76959. }
  76960. type XRPlaneSet = Set<XRPlane>;
  76961. type XRAnchorSet = Set<XRAnchor>;
  76962. interface XRFrame {
  76963. session: XRSession;
  76964. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76965. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76966. // AR
  76967. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76968. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76969. // Anchors
  76970. trackedAnchors?: XRAnchorSet;
  76971. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76972. // Planes
  76973. worldInformation: {
  76974. detectedPlanes?: XRPlaneSet;
  76975. };
  76976. // Hand tracking
  76977. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76978. }
  76979. interface XRViewerPose extends XRPose {
  76980. views: Array<XRView>;
  76981. }
  76982. interface XRPose {
  76983. transform: XRRigidTransform;
  76984. emulatedPosition: boolean;
  76985. }
  76986. interface XRWebGLLayerOptions {
  76987. antialias?: boolean;
  76988. depth?: boolean;
  76989. stencil?: boolean;
  76990. alpha?: boolean;
  76991. multiview?: boolean;
  76992. framebufferScaleFactor?: number;
  76993. }
  76994. declare var XRWebGLLayer: {
  76995. prototype: XRWebGLLayer;
  76996. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76997. };
  76998. interface XRWebGLLayer {
  76999. framebuffer: WebGLFramebuffer;
  77000. framebufferWidth: number;
  77001. framebufferHeight: number;
  77002. getViewport: Function;
  77003. }
  77004. declare class XRRigidTransform {
  77005. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  77006. position: DOMPointReadOnly;
  77007. orientation: DOMPointReadOnly;
  77008. matrix: Float32Array;
  77009. inverse: XRRigidTransform;
  77010. }
  77011. interface XRView {
  77012. eye: XREye;
  77013. projectionMatrix: Float32Array;
  77014. transform: XRRigidTransform;
  77015. }
  77016. interface XRInputSourceChangeEvent {
  77017. session: XRSession;
  77018. removed: Array<XRInputSource>;
  77019. added: Array<XRInputSource>;
  77020. }
  77021. interface XRInputSourceEvent extends Event {
  77022. readonly frame: XRFrame;
  77023. readonly inputSource: XRInputSource;
  77024. }
  77025. // Experimental(er) features
  77026. declare class XRRay {
  77027. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77028. origin: DOMPointReadOnly;
  77029. direction: DOMPointReadOnly;
  77030. matrix: Float32Array;
  77031. }
  77032. declare enum XRHitTestTrackableType {
  77033. "point",
  77034. "plane",
  77035. "mesh",
  77036. }
  77037. interface XRHitResult {
  77038. hitMatrix: Float32Array;
  77039. }
  77040. interface XRTransientInputHitTestResult {
  77041. readonly inputSource: XRInputSource;
  77042. readonly results: Array<XRHitTestResult>;
  77043. }
  77044. interface XRHitTestResult {
  77045. getPose(baseSpace: XRSpace): XRPose | undefined;
  77046. // When anchor system is enabled
  77047. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77048. }
  77049. interface XRHitTestSource {
  77050. cancel(): void;
  77051. }
  77052. interface XRTransientInputHitTestSource {
  77053. cancel(): void;
  77054. }
  77055. interface XRHitTestOptionsInit {
  77056. space: XRSpace;
  77057. entityTypes?: Array<XRHitTestTrackableType>;
  77058. offsetRay?: XRRay;
  77059. }
  77060. interface XRTransientInputHitTestOptionsInit {
  77061. profile: string;
  77062. entityTypes?: Array<XRHitTestTrackableType>;
  77063. offsetRay?: XRRay;
  77064. }
  77065. interface XRAnchor {
  77066. anchorSpace: XRSpace;
  77067. delete(): void;
  77068. }
  77069. interface XRPlane {
  77070. orientation: "Horizontal" | "Vertical";
  77071. planeSpace: XRSpace;
  77072. polygon: Array<DOMPointReadOnly>;
  77073. lastChangedTime: number;
  77074. }
  77075. interface XRJointSpace extends XRSpace {}
  77076. interface XRJointPose extends XRPose {
  77077. radius: number | undefined;
  77078. }
  77079. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  77080. readonly length: number;
  77081. [index: number]: XRJointSpace;
  77082. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  77083. readonly WRIST: number;
  77084. readonly THUMB_METACARPAL: number;
  77085. readonly THUMB_PHALANX_PROXIMAL: number;
  77086. readonly THUMB_PHALANX_DISTAL: number;
  77087. readonly THUMB_PHALANX_TIP: number;
  77088. readonly INDEX_METACARPAL: number;
  77089. readonly INDEX_PHALANX_PROXIMAL: number;
  77090. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77091. readonly INDEX_PHALANX_DISTAL: number;
  77092. readonly INDEX_PHALANX_TIP: number;
  77093. readonly MIDDLE_METACARPAL: number;
  77094. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77095. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77096. readonly MIDDLE_PHALANX_DISTAL: number;
  77097. readonly MIDDLE_PHALANX_TIP: number;
  77098. readonly RING_METACARPAL: number;
  77099. readonly RING_PHALANX_PROXIMAL: number;
  77100. readonly RING_PHALANX_INTERMEDIATE: number;
  77101. readonly RING_PHALANX_DISTAL: number;
  77102. readonly RING_PHALANX_TIP: number;
  77103. readonly LITTLE_METACARPAL: number;
  77104. readonly LITTLE_PHALANX_PROXIMAL: number;
  77105. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77106. readonly LITTLE_PHALANX_DISTAL: number;
  77107. readonly LITTLE_PHALANX_TIP: number;
  77108. }
  77109. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77110. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77111. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77112. interface XRSession {
  77113. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77114. }
  77115. interface XRFrame {
  77116. featurePointCloud? : Array<number>;
  77117. }
  77118. /**
  77119. * @ignore
  77120. */
  77121. declare module BABYLON.GLTF2.Exporter {
  77122. }
  77123. /**
  77124. * @ignore
  77125. */
  77126. declare module BABYLON.GLTF1 {
  77127. }
  77128. declare module BABYLON.GUI {
  77129. /**
  77130. * Class used to specific a value and its associated unit
  77131. */
  77132. export class ValueAndUnit {
  77133. /** defines the unit to store */
  77134. unit: number;
  77135. /** defines a boolean indicating if the value can be negative */
  77136. negativeValueAllowed: boolean;
  77137. private _value;
  77138. private _originalUnit;
  77139. /**
  77140. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77141. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77142. */
  77143. ignoreAdaptiveScaling: boolean;
  77144. /**
  77145. * Creates a new ValueAndUnit
  77146. * @param value defines the value to store
  77147. * @param unit defines the unit to store
  77148. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77149. */
  77150. constructor(value: number,
  77151. /** defines the unit to store */
  77152. unit?: number,
  77153. /** defines a boolean indicating if the value can be negative */
  77154. negativeValueAllowed?: boolean);
  77155. /** Gets a boolean indicating if the value is a percentage */
  77156. get isPercentage(): boolean;
  77157. /** Gets a boolean indicating if the value is store as pixel */
  77158. get isPixel(): boolean;
  77159. /** Gets direct internal value */
  77160. get internalValue(): number;
  77161. /**
  77162. * Gets value as pixel
  77163. * @param host defines the root host
  77164. * @param refValue defines the reference value for percentages
  77165. * @returns the value as pixel
  77166. */
  77167. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77168. /**
  77169. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77170. * @param value defines the value to store
  77171. * @param unit defines the unit to store
  77172. * @returns the current ValueAndUnit
  77173. */
  77174. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77175. /**
  77176. * Gets the value accordingly to its unit
  77177. * @param host defines the root host
  77178. * @returns the value
  77179. */
  77180. getValue(host: AdvancedDynamicTexture): number;
  77181. /**
  77182. * Gets a string representation of the value
  77183. * @param host defines the root host
  77184. * @param decimals defines an optional number of decimals to display
  77185. * @returns a string
  77186. */
  77187. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77188. /**
  77189. * Store a value parsed from a string
  77190. * @param source defines the source string
  77191. * @returns true if the value was successfully parsed
  77192. */
  77193. fromString(source: string | number): boolean;
  77194. private static _Regex;
  77195. private static _UNITMODE_PERCENTAGE;
  77196. private static _UNITMODE_PIXEL;
  77197. /** UNITMODE_PERCENTAGE */
  77198. static get UNITMODE_PERCENTAGE(): number;
  77199. /** UNITMODE_PIXEL */
  77200. static get UNITMODE_PIXEL(): number;
  77201. }
  77202. }
  77203. declare module BABYLON.GUI {
  77204. /**
  77205. * Define a style used by control to automatically setup properties based on a template.
  77206. * Only support font related properties so far
  77207. */
  77208. export class Style implements BABYLON.IDisposable {
  77209. private _fontFamily;
  77210. private _fontStyle;
  77211. private _fontWeight;
  77212. /** @hidden */
  77213. _host: AdvancedDynamicTexture;
  77214. /** @hidden */
  77215. _fontSize: ValueAndUnit;
  77216. /**
  77217. * BABYLON.Observable raised when the style values are changed
  77218. */
  77219. onChangedObservable: BABYLON.Observable<Style>;
  77220. /**
  77221. * Creates a new style object
  77222. * @param host defines the AdvancedDynamicTexture which hosts this style
  77223. */
  77224. constructor(host: AdvancedDynamicTexture);
  77225. /**
  77226. * Gets or sets the font size
  77227. */
  77228. get fontSize(): string | number;
  77229. set fontSize(value: string | number);
  77230. /**
  77231. * Gets or sets the font family
  77232. */
  77233. get fontFamily(): string;
  77234. set fontFamily(value: string);
  77235. /**
  77236. * Gets or sets the font style
  77237. */
  77238. get fontStyle(): string;
  77239. set fontStyle(value: string);
  77240. /** Gets or sets font weight */
  77241. get fontWeight(): string;
  77242. set fontWeight(value: string);
  77243. /** Dispose all associated resources */
  77244. dispose(): void;
  77245. }
  77246. }
  77247. declare module BABYLON.GUI {
  77248. /**
  77249. * Class used to transport BABYLON.Vector2 information for pointer events
  77250. */
  77251. export class Vector2WithInfo extends BABYLON.Vector2 {
  77252. /** defines the current mouse button index */
  77253. buttonIndex: number;
  77254. /**
  77255. * Creates a new Vector2WithInfo
  77256. * @param source defines the vector2 data to transport
  77257. * @param buttonIndex defines the current mouse button index
  77258. */
  77259. constructor(source: BABYLON.Vector2,
  77260. /** defines the current mouse button index */
  77261. buttonIndex?: number);
  77262. }
  77263. /** Class used to provide 2D matrix features */
  77264. export class Matrix2D {
  77265. /** Gets the internal array of 6 floats used to store matrix data */
  77266. m: Float32Array;
  77267. /**
  77268. * Creates a new matrix
  77269. * @param m00 defines value for (0, 0)
  77270. * @param m01 defines value for (0, 1)
  77271. * @param m10 defines value for (1, 0)
  77272. * @param m11 defines value for (1, 1)
  77273. * @param m20 defines value for (2, 0)
  77274. * @param m21 defines value for (2, 1)
  77275. */
  77276. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77277. /**
  77278. * Fills the matrix from direct values
  77279. * @param m00 defines value for (0, 0)
  77280. * @param m01 defines value for (0, 1)
  77281. * @param m10 defines value for (1, 0)
  77282. * @param m11 defines value for (1, 1)
  77283. * @param m20 defines value for (2, 0)
  77284. * @param m21 defines value for (2, 1)
  77285. * @returns the current modified matrix
  77286. */
  77287. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77288. /**
  77289. * Gets matrix determinant
  77290. * @returns the determinant
  77291. */
  77292. determinant(): number;
  77293. /**
  77294. * Inverses the matrix and stores it in a target matrix
  77295. * @param result defines the target matrix
  77296. * @returns the current matrix
  77297. */
  77298. invertToRef(result: Matrix2D): Matrix2D;
  77299. /**
  77300. * Multiplies the current matrix with another one
  77301. * @param other defines the second operand
  77302. * @param result defines the target matrix
  77303. * @returns the current matrix
  77304. */
  77305. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77306. /**
  77307. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77308. * @param x defines the x coordinate to transform
  77309. * @param y defines the x coordinate to transform
  77310. * @param result defines the target vector2
  77311. * @returns the current matrix
  77312. */
  77313. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77314. /**
  77315. * Creates an identity matrix
  77316. * @returns a new matrix
  77317. */
  77318. static Identity(): Matrix2D;
  77319. /**
  77320. * Creates a translation matrix and stores it in a target matrix
  77321. * @param x defines the x coordinate of the translation
  77322. * @param y defines the y coordinate of the translation
  77323. * @param result defines the target matrix
  77324. */
  77325. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77326. /**
  77327. * Creates a scaling matrix and stores it in a target matrix
  77328. * @param x defines the x coordinate of the scaling
  77329. * @param y defines the y coordinate of the scaling
  77330. * @param result defines the target matrix
  77331. */
  77332. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77333. /**
  77334. * Creates a rotation matrix and stores it in a target matrix
  77335. * @param angle defines the rotation angle
  77336. * @param result defines the target matrix
  77337. */
  77338. static RotationToRef(angle: number, result: Matrix2D): void;
  77339. private static _TempPreTranslationMatrix;
  77340. private static _TempPostTranslationMatrix;
  77341. private static _TempRotationMatrix;
  77342. private static _TempScalingMatrix;
  77343. private static _TempCompose0;
  77344. private static _TempCompose1;
  77345. private static _TempCompose2;
  77346. /**
  77347. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77348. * @param tx defines the x coordinate of the translation
  77349. * @param ty defines the y coordinate of the translation
  77350. * @param angle defines the rotation angle
  77351. * @param scaleX defines the x coordinate of the scaling
  77352. * @param scaleY defines the y coordinate of the scaling
  77353. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77354. * @param result defines the target matrix
  77355. */
  77356. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77357. }
  77358. }
  77359. declare module BABYLON.GUI {
  77360. /**
  77361. * Class used to store 2D control sizes
  77362. */
  77363. export class Measure {
  77364. /** defines left coordinate */
  77365. left: number;
  77366. /** defines top coordinate */
  77367. top: number;
  77368. /** defines width dimension */
  77369. width: number;
  77370. /** defines height dimension */
  77371. height: number;
  77372. /**
  77373. * Creates a new measure
  77374. * @param left defines left coordinate
  77375. * @param top defines top coordinate
  77376. * @param width defines width dimension
  77377. * @param height defines height dimension
  77378. */
  77379. constructor(
  77380. /** defines left coordinate */
  77381. left: number,
  77382. /** defines top coordinate */
  77383. top: number,
  77384. /** defines width dimension */
  77385. width: number,
  77386. /** defines height dimension */
  77387. height: number);
  77388. /**
  77389. * Copy from another measure
  77390. * @param other defines the other measure to copy from
  77391. */
  77392. copyFrom(other: Measure): void;
  77393. /**
  77394. * Copy from a group of 4 floats
  77395. * @param left defines left coordinate
  77396. * @param top defines top coordinate
  77397. * @param width defines width dimension
  77398. * @param height defines height dimension
  77399. */
  77400. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77401. /**
  77402. * Computes the axis aligned bounding box measure for two given measures
  77403. * @param a Input measure
  77404. * @param b Input measure
  77405. * @param result the resulting bounding measure
  77406. */
  77407. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77408. /**
  77409. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77410. * @param transform the matrix to transform the measure before computing the AABB
  77411. * @param addX number to add to left
  77412. * @param addY number to add to top
  77413. * @param addWidth number to add to width
  77414. * @param addHeight number to add to height
  77415. * @param result the resulting AABB
  77416. */
  77417. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77418. /**
  77419. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77420. * @param transform the matrix to transform the measure before computing the AABB
  77421. * @param result the resulting AABB
  77422. */
  77423. transformToRef(transform: Matrix2D, result: Measure): void;
  77424. /**
  77425. * Check equality between this measure and another one
  77426. * @param other defines the other measures
  77427. * @returns true if both measures are equals
  77428. */
  77429. isEqualsTo(other: Measure): boolean;
  77430. /**
  77431. * Creates an empty measure
  77432. * @returns a new measure
  77433. */
  77434. static Empty(): Measure;
  77435. }
  77436. }
  77437. declare module BABYLON.GUI {
  77438. /**
  77439. * Interface used to define a control that can receive focus
  77440. */
  77441. export interface IFocusableControl {
  77442. /**
  77443. * Function called when the control receives the focus
  77444. */
  77445. onFocus(): void;
  77446. /**
  77447. * Function called when the control loses the focus
  77448. */
  77449. onBlur(): void;
  77450. /**
  77451. * Function called to let the control handle keyboard events
  77452. * @param evt defines the current keyboard event
  77453. */
  77454. processKeyboard(evt: KeyboardEvent): void;
  77455. /**
  77456. * Function called to get the list of controls that should not steal the focus from this control
  77457. * @returns an array of controls
  77458. */
  77459. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77460. }
  77461. /**
  77462. * Class used to create texture to support 2D GUI elements
  77463. * @see https://doc.babylonjs.com/how_to/gui
  77464. */
  77465. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77466. private _isDirty;
  77467. private _renderObserver;
  77468. private _resizeObserver;
  77469. private _preKeyboardObserver;
  77470. private _pointerMoveObserver;
  77471. private _pointerObserver;
  77472. private _canvasPointerOutObserver;
  77473. private _canvasBlurObserver;
  77474. private _background;
  77475. /** @hidden */
  77476. _rootContainer: Container;
  77477. /** @hidden */
  77478. _lastPickedControl: Control;
  77479. /** @hidden */
  77480. _lastControlOver: {
  77481. [pointerId: number]: Control;
  77482. };
  77483. /** @hidden */
  77484. _lastControlDown: {
  77485. [pointerId: number]: Control;
  77486. };
  77487. /** @hidden */
  77488. _capturingControl: {
  77489. [pointerId: number]: Control;
  77490. };
  77491. /** @hidden */
  77492. _shouldBlockPointer: boolean;
  77493. /** @hidden */
  77494. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77495. /** @hidden */
  77496. _linkedControls: Control[];
  77497. private _isFullscreen;
  77498. private _fullscreenViewport;
  77499. private _idealWidth;
  77500. private _idealHeight;
  77501. private _useSmallestIdeal;
  77502. private _renderAtIdealSize;
  77503. private _focusedControl;
  77504. private _blockNextFocusCheck;
  77505. private _renderScale;
  77506. private _rootElement;
  77507. private _cursorChanged;
  77508. private _defaultMousePointerId;
  77509. /** @hidden */
  77510. _numLayoutCalls: number;
  77511. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77512. get numLayoutCalls(): number;
  77513. /** @hidden */
  77514. _numRenderCalls: number;
  77515. /** Gets the number of render calls made the last time the ADT has been rendered */
  77516. get numRenderCalls(): number;
  77517. /**
  77518. * Define type to string to ensure compatibility across browsers
  77519. * Safari doesn't support DataTransfer constructor
  77520. */
  77521. private _clipboardData;
  77522. /**
  77523. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77524. */
  77525. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77526. /**
  77527. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77528. */
  77529. onControlPickedObservable: BABYLON.Observable<Control>;
  77530. /**
  77531. * BABYLON.Observable event triggered before layout is evaluated
  77532. */
  77533. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77534. /**
  77535. * BABYLON.Observable event triggered after the layout was evaluated
  77536. */
  77537. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77538. /**
  77539. * BABYLON.Observable event triggered before the texture is rendered
  77540. */
  77541. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77542. /**
  77543. * BABYLON.Observable event triggered after the texture was rendered
  77544. */
  77545. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77546. /**
  77547. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77548. */
  77549. premulAlpha: boolean;
  77550. /**
  77551. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77552. * Useful when you want more antialiasing
  77553. */
  77554. get renderScale(): number;
  77555. set renderScale(value: number);
  77556. /** Gets or sets the background color */
  77557. get background(): string;
  77558. set background(value: string);
  77559. /**
  77560. * Gets or sets the ideal width used to design controls.
  77561. * The GUI will then rescale everything accordingly
  77562. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77563. */
  77564. get idealWidth(): number;
  77565. set idealWidth(value: number);
  77566. /**
  77567. * Gets or sets the ideal height used to design controls.
  77568. * The GUI will then rescale everything accordingly
  77569. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77570. */
  77571. get idealHeight(): number;
  77572. set idealHeight(value: number);
  77573. /**
  77574. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77575. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77576. */
  77577. get useSmallestIdeal(): boolean;
  77578. set useSmallestIdeal(value: boolean);
  77579. /**
  77580. * Gets or sets a boolean indicating if adaptive scaling must be used
  77581. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77582. */
  77583. get renderAtIdealSize(): boolean;
  77584. set renderAtIdealSize(value: boolean);
  77585. /**
  77586. * Gets the ratio used when in "ideal mode"
  77587. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77588. * */
  77589. get idealRatio(): number;
  77590. /**
  77591. * Gets the underlying layer used to render the texture when in fullscreen mode
  77592. */
  77593. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77594. /**
  77595. * Gets the root container control
  77596. */
  77597. get rootContainer(): Container;
  77598. /**
  77599. * Returns an array containing the root container.
  77600. * This is mostly used to let the Inspector introspects the ADT
  77601. * @returns an array containing the rootContainer
  77602. */
  77603. getChildren(): Array<Container>;
  77604. /**
  77605. * Will return all controls that are inside this texture
  77606. * @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
  77607. * @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
  77608. * @return all child controls
  77609. */
  77610. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77611. /**
  77612. * Gets or sets the current focused control
  77613. */
  77614. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77615. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77616. /**
  77617. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77618. */
  77619. get isForeground(): boolean;
  77620. set isForeground(value: boolean);
  77621. /**
  77622. * Gets or set information about clipboardData
  77623. */
  77624. get clipboardData(): string;
  77625. set clipboardData(value: string);
  77626. /**
  77627. * Creates a new AdvancedDynamicTexture
  77628. * @param name defines the name of the texture
  77629. * @param width defines the width of the texture
  77630. * @param height defines the height of the texture
  77631. * @param scene defines the hosting scene
  77632. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77633. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77634. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77635. */
  77636. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  77637. /**
  77638. * Get the current class name of the texture useful for serialization or dynamic coding.
  77639. * @returns "AdvancedDynamicTexture"
  77640. */
  77641. getClassName(): string;
  77642. /**
  77643. * Function used to execute a function on all controls
  77644. * @param func defines the function to execute
  77645. * @param container defines the container where controls belong. If null the root container will be used
  77646. */
  77647. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77648. private _useInvalidateRectOptimization;
  77649. /**
  77650. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77651. */
  77652. get useInvalidateRectOptimization(): boolean;
  77653. set useInvalidateRectOptimization(value: boolean);
  77654. private _invalidatedRectangle;
  77655. /**
  77656. * Invalidates a rectangle area on the gui texture
  77657. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77658. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77659. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77660. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77661. */
  77662. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77663. /**
  77664. * Marks the texture as dirty forcing a complete update
  77665. */
  77666. markAsDirty(): void;
  77667. /**
  77668. * Helper function used to create a new style
  77669. * @returns a new style
  77670. * @see https://doc.babylonjs.com/how_to/gui#styles
  77671. */
  77672. createStyle(): Style;
  77673. /**
  77674. * Adds a new control to the root container
  77675. * @param control defines the control to add
  77676. * @returns the current texture
  77677. */
  77678. addControl(control: Control): AdvancedDynamicTexture;
  77679. /**
  77680. * Removes a control from the root container
  77681. * @param control defines the control to remove
  77682. * @returns the current texture
  77683. */
  77684. removeControl(control: Control): AdvancedDynamicTexture;
  77685. /**
  77686. * Release all resources
  77687. */
  77688. dispose(): void;
  77689. private _onResize;
  77690. /** @hidden */
  77691. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77692. /**
  77693. * Get screen coordinates for a vector3
  77694. * @param position defines the position to project
  77695. * @param worldMatrix defines the world matrix to use
  77696. * @returns the projected position
  77697. */
  77698. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77699. private _checkUpdate;
  77700. private _clearMeasure;
  77701. private _render;
  77702. /** @hidden */
  77703. _changeCursor(cursor: string): void;
  77704. /** @hidden */
  77705. _registerLastControlDown(control: Control, pointerId: number): void;
  77706. private _doPicking;
  77707. /** @hidden */
  77708. _cleanControlAfterRemovalFromList(list: {
  77709. [pointerId: number]: Control;
  77710. }, control: Control): void;
  77711. /** @hidden */
  77712. _cleanControlAfterRemoval(control: Control): void;
  77713. /** Attach to all scene events required to support pointer events */
  77714. attach(): void;
  77715. /** @hidden */
  77716. private onClipboardCopy;
  77717. /** @hidden */
  77718. private onClipboardCut;
  77719. /** @hidden */
  77720. private onClipboardPaste;
  77721. /**
  77722. * Register the clipboard Events onto the canvas
  77723. */
  77724. registerClipboardEvents(): void;
  77725. /**
  77726. * Unregister the clipboard Events from the canvas
  77727. */
  77728. unRegisterClipboardEvents(): void;
  77729. /**
  77730. * Connect the texture to a hosting mesh to enable interactions
  77731. * @param mesh defines the mesh to attach to
  77732. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77733. */
  77734. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77735. /**
  77736. * Move the focus to a specific control
  77737. * @param control defines the control which will receive the focus
  77738. */
  77739. moveFocusToControl(control: IFocusableControl): void;
  77740. private _manageFocus;
  77741. private _attachToOnPointerOut;
  77742. private _attachToOnBlur;
  77743. /**
  77744. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77745. * @param mesh defines the mesh which will receive the texture
  77746. * @param width defines the texture width (1024 by default)
  77747. * @param height defines the texture height (1024 by default)
  77748. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77749. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77750. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77751. * @returns a new AdvancedDynamicTexture
  77752. */
  77753. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  77754. /**
  77755. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77756. * In this mode the texture will rely on a layer for its rendering.
  77757. * This allows it to be treated like any other layer.
  77758. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77759. * LayerMask is set through advancedTexture.layer.layerMask
  77760. * @param name defines name for the texture
  77761. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77762. * @param scene defines the hsoting scene
  77763. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77764. * @returns a new AdvancedDynamicTexture
  77765. */
  77766. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77767. }
  77768. }
  77769. declare module BABYLON.GUI {
  77770. /**
  77771. * Root class used for all 2D controls
  77772. * @see https://doc.babylonjs.com/how_to/gui#controls
  77773. */
  77774. export class Control {
  77775. /** defines the name of the control */
  77776. name?: string | undefined;
  77777. /**
  77778. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77779. */
  77780. static AllowAlphaInheritance: boolean;
  77781. private _alpha;
  77782. private _alphaSet;
  77783. private _zIndex;
  77784. /** @hidden */
  77785. _host: AdvancedDynamicTexture;
  77786. /** Gets or sets the control parent */
  77787. parent: BABYLON.Nullable<Container>;
  77788. /** @hidden */
  77789. _currentMeasure: Measure;
  77790. private _fontFamily;
  77791. private _fontStyle;
  77792. private _fontWeight;
  77793. private _fontSize;
  77794. private _font;
  77795. /** @hidden */
  77796. _width: ValueAndUnit;
  77797. /** @hidden */
  77798. _height: ValueAndUnit;
  77799. /** @hidden */
  77800. protected _fontOffset: {
  77801. ascent: number;
  77802. height: number;
  77803. descent: number;
  77804. };
  77805. private _color;
  77806. private _style;
  77807. private _styleObserver;
  77808. /** @hidden */
  77809. protected _horizontalAlignment: number;
  77810. /** @hidden */
  77811. protected _verticalAlignment: number;
  77812. /** @hidden */
  77813. protected _isDirty: boolean;
  77814. /** @hidden */
  77815. protected _wasDirty: boolean;
  77816. /** @hidden */
  77817. _tempParentMeasure: Measure;
  77818. /** @hidden */
  77819. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77820. /** @hidden */
  77821. protected _cachedParentMeasure: Measure;
  77822. private _paddingLeft;
  77823. private _paddingRight;
  77824. private _paddingTop;
  77825. private _paddingBottom;
  77826. /** @hidden */
  77827. _left: ValueAndUnit;
  77828. /** @hidden */
  77829. _top: ValueAndUnit;
  77830. private _scaleX;
  77831. private _scaleY;
  77832. private _rotation;
  77833. private _transformCenterX;
  77834. private _transformCenterY;
  77835. /** @hidden */
  77836. _transformMatrix: Matrix2D;
  77837. /** @hidden */
  77838. protected _invertTransformMatrix: Matrix2D;
  77839. /** @hidden */
  77840. protected _transformedPosition: BABYLON.Vector2;
  77841. private _isMatrixDirty;
  77842. private _cachedOffsetX;
  77843. private _cachedOffsetY;
  77844. private _isVisible;
  77845. private _isHighlighted;
  77846. /** @hidden */
  77847. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  77848. private _fontSet;
  77849. private _dummyVector2;
  77850. private _downCount;
  77851. private _enterCount;
  77852. private _doNotRender;
  77853. private _downPointerIds;
  77854. protected _isEnabled: boolean;
  77855. protected _disabledColor: string;
  77856. protected _disabledColorItem: string;
  77857. /** @hidden */
  77858. protected _rebuildLayout: boolean;
  77859. /** @hidden */
  77860. _customData: any;
  77861. /** @hidden */
  77862. _isClipped: boolean;
  77863. /** @hidden */
  77864. _automaticSize: boolean;
  77865. /** @hidden */
  77866. _tag: any;
  77867. /**
  77868. * 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
  77869. */
  77870. uniqueId: number;
  77871. /**
  77872. * Gets or sets an object used to store user defined information for the node
  77873. */
  77874. metadata: any;
  77875. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77876. isHitTestVisible: boolean;
  77877. /** Gets or sets a boolean indicating if the control can block pointer events */
  77878. isPointerBlocker: boolean;
  77879. /** Gets or sets a boolean indicating if the control can be focusable */
  77880. isFocusInvisible: boolean;
  77881. /**
  77882. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77883. * 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
  77884. */
  77885. clipChildren: boolean;
  77886. /**
  77887. * Gets or sets a boolean indicating that control content must be clipped
  77888. * 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
  77889. */
  77890. clipContent: boolean;
  77891. /**
  77892. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77893. */
  77894. useBitmapCache: boolean;
  77895. private _cacheData;
  77896. private _shadowOffsetX;
  77897. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77898. get shadowOffsetX(): number;
  77899. set shadowOffsetX(value: number);
  77900. private _shadowOffsetY;
  77901. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77902. get shadowOffsetY(): number;
  77903. set shadowOffsetY(value: number);
  77904. private _shadowBlur;
  77905. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77906. get shadowBlur(): number;
  77907. set shadowBlur(value: number);
  77908. private _shadowColor;
  77909. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77910. get shadowColor(): string;
  77911. set shadowColor(value: string);
  77912. /** Gets or sets the cursor to use when the control is hovered */
  77913. hoverCursor: string;
  77914. /** @hidden */
  77915. protected _linkOffsetX: ValueAndUnit;
  77916. /** @hidden */
  77917. protected _linkOffsetY: ValueAndUnit;
  77918. /** Gets the control type name */
  77919. get typeName(): string;
  77920. /**
  77921. * Get the current class name of the control.
  77922. * @returns current class name
  77923. */
  77924. getClassName(): string;
  77925. /**
  77926. * An event triggered when pointer wheel is scrolled
  77927. */
  77928. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77929. /**
  77930. * An event triggered when the pointer move over the control.
  77931. */
  77932. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77933. /**
  77934. * An event triggered when the pointer move out of the control.
  77935. */
  77936. onPointerOutObservable: BABYLON.Observable<Control>;
  77937. /**
  77938. * An event triggered when the pointer taps the control
  77939. */
  77940. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77941. /**
  77942. * An event triggered when pointer up
  77943. */
  77944. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77945. /**
  77946. * An event triggered when a control is clicked on
  77947. */
  77948. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77949. /**
  77950. * An event triggered when pointer enters the control
  77951. */
  77952. onPointerEnterObservable: BABYLON.Observable<Control>;
  77953. /**
  77954. * An event triggered when the control is marked as dirty
  77955. */
  77956. onDirtyObservable: BABYLON.Observable<Control>;
  77957. /**
  77958. * An event triggered before drawing the control
  77959. */
  77960. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77961. /**
  77962. * An event triggered after the control was drawn
  77963. */
  77964. onAfterDrawObservable: BABYLON.Observable<Control>;
  77965. /**
  77966. * An event triggered when the control has been disposed
  77967. */
  77968. onDisposeObservable: BABYLON.Observable<Control>;
  77969. /**
  77970. * Get the hosting AdvancedDynamicTexture
  77971. */
  77972. get host(): AdvancedDynamicTexture;
  77973. /** Gets or set information about font offsets (used to render and align text) */
  77974. get fontOffset(): {
  77975. ascent: number;
  77976. height: number;
  77977. descent: number;
  77978. };
  77979. set fontOffset(offset: {
  77980. ascent: number;
  77981. height: number;
  77982. descent: number;
  77983. });
  77984. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77985. get alpha(): number;
  77986. set alpha(value: number);
  77987. /**
  77988. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77989. */
  77990. get isHighlighted(): boolean;
  77991. set isHighlighted(value: boolean);
  77992. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77993. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77994. */
  77995. get scaleX(): number;
  77996. set scaleX(value: number);
  77997. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77998. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77999. */
  78000. get scaleY(): number;
  78001. set scaleY(value: number);
  78002. /** Gets or sets the rotation angle (0 by default)
  78003. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78004. */
  78005. get rotation(): number;
  78006. set rotation(value: number);
  78007. /** Gets or sets the transformation center on Y axis (0 by default)
  78008. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78009. */
  78010. get transformCenterY(): number;
  78011. set transformCenterY(value: number);
  78012. /** Gets or sets the transformation center on X axis (0 by default)
  78013. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78014. */
  78015. get transformCenterX(): number;
  78016. set transformCenterX(value: number);
  78017. /**
  78018. * Gets or sets the horizontal alignment
  78019. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78020. */
  78021. get horizontalAlignment(): number;
  78022. set horizontalAlignment(value: number);
  78023. /**
  78024. * Gets or sets the vertical alignment
  78025. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78026. */
  78027. get verticalAlignment(): number;
  78028. set verticalAlignment(value: number);
  78029. /**
  78030. * Gets or sets a fixed ratio for this control.
  78031. * When different from 0, the ratio is used to compute the "second" dimension.
  78032. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78033. * second dimension is computed as first dimension * fixedRatio
  78034. */
  78035. fixedRatio: number;
  78036. private _fixedRatioMasterIsWidth;
  78037. /**
  78038. * Gets or sets control width
  78039. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78040. */
  78041. get width(): string | number;
  78042. set width(value: string | number);
  78043. /**
  78044. * Gets or sets the control width in pixel
  78045. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78046. */
  78047. get widthInPixels(): number;
  78048. set widthInPixels(value: number);
  78049. /**
  78050. * Gets or sets control height
  78051. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78052. */
  78053. get height(): string | number;
  78054. set height(value: string | number);
  78055. /**
  78056. * Gets or sets control height in pixel
  78057. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78058. */
  78059. get heightInPixels(): number;
  78060. set heightInPixels(value: number);
  78061. /** Gets or set font family */
  78062. get fontFamily(): string;
  78063. set fontFamily(value: string);
  78064. /** Gets or sets font style */
  78065. get fontStyle(): string;
  78066. set fontStyle(value: string);
  78067. /** Gets or sets font weight */
  78068. get fontWeight(): string;
  78069. set fontWeight(value: string);
  78070. /**
  78071. * Gets or sets style
  78072. * @see https://doc.babylonjs.com/how_to/gui#styles
  78073. */
  78074. get style(): BABYLON.Nullable<Style>;
  78075. set style(value: BABYLON.Nullable<Style>);
  78076. /** @hidden */
  78077. get _isFontSizeInPercentage(): boolean;
  78078. /** Gets or sets font size in pixels */
  78079. get fontSizeInPixels(): number;
  78080. set fontSizeInPixels(value: number);
  78081. /** Gets or sets font size */
  78082. get fontSize(): string | number;
  78083. set fontSize(value: string | number);
  78084. /** Gets or sets foreground color */
  78085. get color(): string;
  78086. set color(value: string);
  78087. /** Gets or sets z index which is used to reorder controls on the z axis */
  78088. get zIndex(): number;
  78089. set zIndex(value: number);
  78090. /** Gets or sets a boolean indicating if the control can be rendered */
  78091. get notRenderable(): boolean;
  78092. set notRenderable(value: boolean);
  78093. /** Gets or sets a boolean indicating if the control is visible */
  78094. get isVisible(): boolean;
  78095. set isVisible(value: boolean);
  78096. /** Gets a boolean indicating that the control needs to update its rendering */
  78097. get isDirty(): boolean;
  78098. /**
  78099. * Gets the current linked mesh (or null if none)
  78100. */
  78101. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78102. /**
  78103. * Gets or sets a value indicating the padding to use on the left of the control
  78104. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78105. */
  78106. get paddingLeft(): string | number;
  78107. set paddingLeft(value: string | number);
  78108. /**
  78109. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78110. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78111. */
  78112. get paddingLeftInPixels(): number;
  78113. set paddingLeftInPixels(value: number);
  78114. /**
  78115. * Gets or sets a value indicating the padding to use on the right of the control
  78116. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78117. */
  78118. get paddingRight(): string | number;
  78119. set paddingRight(value: string | number);
  78120. /**
  78121. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78122. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78123. */
  78124. get paddingRightInPixels(): number;
  78125. set paddingRightInPixels(value: number);
  78126. /**
  78127. * Gets or sets a value indicating the padding to use on the top of the control
  78128. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78129. */
  78130. get paddingTop(): string | number;
  78131. set paddingTop(value: string | number);
  78132. /**
  78133. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78134. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78135. */
  78136. get paddingTopInPixels(): number;
  78137. set paddingTopInPixels(value: number);
  78138. /**
  78139. * Gets or sets a value indicating the padding to use on the bottom of the control
  78140. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78141. */
  78142. get paddingBottom(): string | number;
  78143. set paddingBottom(value: string | number);
  78144. /**
  78145. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78146. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78147. */
  78148. get paddingBottomInPixels(): number;
  78149. set paddingBottomInPixels(value: number);
  78150. /**
  78151. * Gets or sets a value indicating the left coordinate of the control
  78152. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78153. */
  78154. get left(): string | number;
  78155. set left(value: string | number);
  78156. /**
  78157. * Gets or sets a value indicating the left coordinate in pixels of the control
  78158. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78159. */
  78160. get leftInPixels(): number;
  78161. set leftInPixels(value: number);
  78162. /**
  78163. * Gets or sets a value indicating the top coordinate of the control
  78164. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78165. */
  78166. get top(): string | number;
  78167. set top(value: string | number);
  78168. /**
  78169. * Gets or sets a value indicating the top coordinate in pixels of the control
  78170. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78171. */
  78172. get topInPixels(): number;
  78173. set topInPixels(value: number);
  78174. /**
  78175. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78176. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78177. */
  78178. get linkOffsetX(): string | number;
  78179. set linkOffsetX(value: string | number);
  78180. /**
  78181. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78182. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78183. */
  78184. get linkOffsetXInPixels(): number;
  78185. set linkOffsetXInPixels(value: number);
  78186. /**
  78187. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78188. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78189. */
  78190. get linkOffsetY(): string | number;
  78191. set linkOffsetY(value: string | number);
  78192. /**
  78193. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78194. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78195. */
  78196. get linkOffsetYInPixels(): number;
  78197. set linkOffsetYInPixels(value: number);
  78198. /** Gets the center coordinate on X axis */
  78199. get centerX(): number;
  78200. /** Gets the center coordinate on Y axis */
  78201. get centerY(): number;
  78202. /** Gets or sets if control is Enabled*/
  78203. get isEnabled(): boolean;
  78204. set isEnabled(value: boolean);
  78205. /** Gets or sets background color of control if it's disabled*/
  78206. get disabledColor(): string;
  78207. set disabledColor(value: string);
  78208. /** Gets or sets front color of control if it's disabled*/
  78209. get disabledColorItem(): string;
  78210. set disabledColorItem(value: string);
  78211. /**
  78212. * Creates a new control
  78213. * @param name defines the name of the control
  78214. */
  78215. constructor(
  78216. /** defines the name of the control */
  78217. name?: string | undefined);
  78218. /** @hidden */
  78219. protected _getTypeName(): string;
  78220. /**
  78221. * Gets the first ascendant in the hierarchy of the given type
  78222. * @param className defines the required type
  78223. * @returns the ascendant or null if not found
  78224. */
  78225. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78226. /** @hidden */
  78227. _resetFontCache(): void;
  78228. /**
  78229. * Determines if a container is an ascendant of the current control
  78230. * @param container defines the container to look for
  78231. * @returns true if the container is one of the ascendant of the control
  78232. */
  78233. isAscendant(container: Control): boolean;
  78234. /**
  78235. * Gets coordinates in local control space
  78236. * @param globalCoordinates defines the coordinates to transform
  78237. * @returns the new coordinates in local space
  78238. */
  78239. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78240. /**
  78241. * Gets coordinates in local control space
  78242. * @param globalCoordinates defines the coordinates to transform
  78243. * @param result defines the target vector2 where to store the result
  78244. * @returns the current control
  78245. */
  78246. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78247. /**
  78248. * Gets coordinates in parent local control space
  78249. * @param globalCoordinates defines the coordinates to transform
  78250. * @returns the new coordinates in parent local space
  78251. */
  78252. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78253. /**
  78254. * Move the current control to a vector3 position projected onto the screen.
  78255. * @param position defines the target position
  78256. * @param scene defines the hosting scene
  78257. */
  78258. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78259. /**
  78260. * Will store all controls that have this control as ascendant in a given array
  78261. * @param results defines the array where to store the descendants
  78262. * @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
  78263. * @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
  78264. */
  78265. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78266. /**
  78267. * Will return all controls that have this control as ascendant
  78268. * @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
  78269. * @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
  78270. * @return all child controls
  78271. */
  78272. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78273. /**
  78274. * Link current control with a target mesh
  78275. * @param mesh defines the mesh to link with
  78276. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78277. */
  78278. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  78279. /** @hidden */
  78280. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78281. /** @hidden */
  78282. _offsetLeft(offset: number): void;
  78283. /** @hidden */
  78284. _offsetTop(offset: number): void;
  78285. /** @hidden */
  78286. _markMatrixAsDirty(): void;
  78287. /** @hidden */
  78288. _flagDescendantsAsMatrixDirty(): void;
  78289. /** @hidden */
  78290. _intersectsRect(rect: Measure): boolean;
  78291. /** @hidden */
  78292. protected invalidateRect(): void;
  78293. /** @hidden */
  78294. _markAsDirty(force?: boolean): void;
  78295. /** @hidden */
  78296. _markAllAsDirty(): void;
  78297. /** @hidden */
  78298. _link(host: AdvancedDynamicTexture): void;
  78299. /** @hidden */
  78300. protected _transform(context?: CanvasRenderingContext2D): void;
  78301. /** @hidden */
  78302. _renderHighlight(context: CanvasRenderingContext2D): void;
  78303. /** @hidden */
  78304. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78305. /** @hidden */
  78306. protected _applyStates(context: CanvasRenderingContext2D): void;
  78307. /** @hidden */
  78308. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78309. /** @hidden */
  78310. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78311. protected _evaluateClippingState(parentMeasure: Measure): void;
  78312. /** @hidden */
  78313. _measure(): void;
  78314. /** @hidden */
  78315. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78316. /** @hidden */
  78317. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78318. /** @hidden */
  78319. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78320. /** @hidden */
  78321. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78322. private static _ClipMeasure;
  78323. private _tmpMeasureA;
  78324. private _clip;
  78325. /** @hidden */
  78326. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78327. /** @hidden */
  78328. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78329. /**
  78330. * Tests if a given coordinates belong to the current control
  78331. * @param x defines x coordinate to test
  78332. * @param y defines y coordinate to test
  78333. * @returns true if the coordinates are inside the control
  78334. */
  78335. contains(x: number, y: number): boolean;
  78336. /** @hidden */
  78337. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78338. /** @hidden */
  78339. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78340. /** @hidden */
  78341. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78342. /** @hidden */
  78343. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78344. /** @hidden */
  78345. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78346. /** @hidden */
  78347. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78348. /** @hidden */
  78349. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78350. /** @hidden */
  78351. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78352. /** @hidden */
  78353. _onCanvasBlur(): void;
  78354. /** @hidden */
  78355. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78356. private _prepareFont;
  78357. /** Releases associated resources */
  78358. dispose(): void;
  78359. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78360. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78361. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78362. private static _VERTICAL_ALIGNMENT_TOP;
  78363. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78364. private static _VERTICAL_ALIGNMENT_CENTER;
  78365. /** HORIZONTAL_ALIGNMENT_LEFT */
  78366. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78367. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78368. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78369. /** HORIZONTAL_ALIGNMENT_CENTER */
  78370. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78371. /** VERTICAL_ALIGNMENT_TOP */
  78372. static get VERTICAL_ALIGNMENT_TOP(): number;
  78373. /** VERTICAL_ALIGNMENT_BOTTOM */
  78374. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78375. /** VERTICAL_ALIGNMENT_CENTER */
  78376. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78377. private static _FontHeightSizes;
  78378. /** @hidden */
  78379. static _GetFontOffset(font: string): {
  78380. ascent: number;
  78381. height: number;
  78382. descent: number;
  78383. };
  78384. /**
  78385. * Creates a stack panel that can be used to render headers
  78386. * @param control defines the control to associate with the header
  78387. * @param text defines the text of the header
  78388. * @param size defines the size of the header
  78389. * @param options defines options used to configure the header
  78390. * @returns a new StackPanel
  78391. * @ignore
  78392. * @hidden
  78393. */
  78394. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78395. isHorizontal: boolean;
  78396. controlFirst: boolean;
  78397. }) => any;
  78398. /** @hidden */
  78399. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78400. }
  78401. }
  78402. declare module BABYLON.GUI {
  78403. /**
  78404. * Root class for 2D containers
  78405. * @see https://doc.babylonjs.com/how_to/gui#containers
  78406. */
  78407. export class Container extends Control {
  78408. name?: string | undefined;
  78409. /** @hidden */
  78410. _children: Control[];
  78411. /** @hidden */
  78412. protected _measureForChildren: Measure;
  78413. /** @hidden */
  78414. protected _background: string;
  78415. /** @hidden */
  78416. protected _adaptWidthToChildren: boolean;
  78417. /** @hidden */
  78418. protected _adaptHeightToChildren: boolean;
  78419. /**
  78420. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78421. */
  78422. logLayoutCycleErrors: boolean;
  78423. /**
  78424. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78425. */
  78426. maxLayoutCycle: number;
  78427. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78428. get adaptHeightToChildren(): boolean;
  78429. set adaptHeightToChildren(value: boolean);
  78430. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78431. get adaptWidthToChildren(): boolean;
  78432. set adaptWidthToChildren(value: boolean);
  78433. /** Gets or sets background color */
  78434. get background(): string;
  78435. set background(value: string);
  78436. /** Gets the list of children */
  78437. get children(): Control[];
  78438. /**
  78439. * Creates a new Container
  78440. * @param name defines the name of the container
  78441. */
  78442. constructor(name?: string | undefined);
  78443. protected _getTypeName(): string;
  78444. _flagDescendantsAsMatrixDirty(): void;
  78445. /**
  78446. * Gets a child using its name
  78447. * @param name defines the child name to look for
  78448. * @returns the child control if found
  78449. */
  78450. getChildByName(name: string): BABYLON.Nullable<Control>;
  78451. /**
  78452. * Gets a child using its type and its name
  78453. * @param name defines the child name to look for
  78454. * @param type defines the child type to look for
  78455. * @returns the child control if found
  78456. */
  78457. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78458. /**
  78459. * Search for a specific control in children
  78460. * @param control defines the control to look for
  78461. * @returns true if the control is in child list
  78462. */
  78463. containsControl(control: Control): boolean;
  78464. /**
  78465. * Adds a new control to the current container
  78466. * @param control defines the control to add
  78467. * @returns the current container
  78468. */
  78469. addControl(control: BABYLON.Nullable<Control>): Container;
  78470. /**
  78471. * Removes all controls from the current container
  78472. * @returns the current container
  78473. */
  78474. clearControls(): Container;
  78475. /**
  78476. * Removes a control from the current container
  78477. * @param control defines the control to remove
  78478. * @returns the current container
  78479. */
  78480. removeControl(control: Control): Container;
  78481. /** @hidden */
  78482. _reOrderControl(control: Control): void;
  78483. /** @hidden */
  78484. _offsetLeft(offset: number): void;
  78485. /** @hidden */
  78486. _offsetTop(offset: number): void;
  78487. /** @hidden */
  78488. _markAllAsDirty(): void;
  78489. /** @hidden */
  78490. protected _localDraw(context: CanvasRenderingContext2D): void;
  78491. /** @hidden */
  78492. _link(host: AdvancedDynamicTexture): void;
  78493. /** @hidden */
  78494. protected _beforeLayout(): void;
  78495. /** @hidden */
  78496. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78497. /** @hidden */
  78498. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78499. protected _postMeasure(): void;
  78500. /** @hidden */
  78501. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78502. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78503. /** @hidden */
  78504. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78505. /** @hidden */
  78506. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78507. /** Releases associated resources */
  78508. dispose(): void;
  78509. }
  78510. }
  78511. declare module BABYLON.GUI {
  78512. /** Class used to create rectangle container */
  78513. export class Rectangle extends Container {
  78514. name?: string | undefined;
  78515. private _thickness;
  78516. private _cornerRadius;
  78517. /** Gets or sets border thickness */
  78518. get thickness(): number;
  78519. set thickness(value: number);
  78520. /** Gets or sets the corner radius angle */
  78521. get cornerRadius(): number;
  78522. set cornerRadius(value: number);
  78523. /**
  78524. * Creates a new Rectangle
  78525. * @param name defines the control name
  78526. */
  78527. constructor(name?: string | undefined);
  78528. protected _getTypeName(): string;
  78529. protected _localDraw(context: CanvasRenderingContext2D): void;
  78530. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78531. private _drawRoundedRect;
  78532. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78533. }
  78534. }
  78535. declare module BABYLON.GUI {
  78536. /**
  78537. * Enum that determines the text-wrapping mode to use.
  78538. */
  78539. export enum TextWrapping {
  78540. /**
  78541. * Clip the text when it's larger than Control.width; this is the default mode.
  78542. */
  78543. Clip = 0,
  78544. /**
  78545. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78546. */
  78547. WordWrap = 1,
  78548. /**
  78549. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78550. */
  78551. Ellipsis = 2
  78552. }
  78553. /**
  78554. * Class used to create text block control
  78555. */
  78556. export class TextBlock extends Control {
  78557. /**
  78558. * Defines the name of the control
  78559. */
  78560. name?: string | undefined;
  78561. private _text;
  78562. private _textWrapping;
  78563. private _textHorizontalAlignment;
  78564. private _textVerticalAlignment;
  78565. private _lines;
  78566. private _resizeToFit;
  78567. private _lineSpacing;
  78568. private _outlineWidth;
  78569. private _outlineColor;
  78570. private _underline;
  78571. private _lineThrough;
  78572. /**
  78573. * An event triggered after the text is changed
  78574. */
  78575. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78576. /**
  78577. * An event triggered after the text was broken up into lines
  78578. */
  78579. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78580. /**
  78581. * Function used to split a string into words. By default, a string is split at each space character found
  78582. */
  78583. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78584. /**
  78585. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78586. */
  78587. get lines(): any[];
  78588. /**
  78589. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78590. */
  78591. get resizeToFit(): boolean;
  78592. /**
  78593. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78594. */
  78595. set resizeToFit(value: boolean);
  78596. /**
  78597. * Gets or sets a boolean indicating if text must be wrapped
  78598. */
  78599. get textWrapping(): TextWrapping | boolean;
  78600. /**
  78601. * Gets or sets a boolean indicating if text must be wrapped
  78602. */
  78603. set textWrapping(value: TextWrapping | boolean);
  78604. /**
  78605. * Gets or sets text to display
  78606. */
  78607. get text(): string;
  78608. /**
  78609. * Gets or sets text to display
  78610. */
  78611. set text(value: string);
  78612. /**
  78613. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78614. */
  78615. get textHorizontalAlignment(): number;
  78616. /**
  78617. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78618. */
  78619. set textHorizontalAlignment(value: number);
  78620. /**
  78621. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78622. */
  78623. get textVerticalAlignment(): number;
  78624. /**
  78625. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78626. */
  78627. set textVerticalAlignment(value: number);
  78628. /**
  78629. * Gets or sets line spacing value
  78630. */
  78631. set lineSpacing(value: string | number);
  78632. /**
  78633. * Gets or sets line spacing value
  78634. */
  78635. get lineSpacing(): string | number;
  78636. /**
  78637. * Gets or sets outlineWidth of the text to display
  78638. */
  78639. get outlineWidth(): number;
  78640. /**
  78641. * Gets or sets outlineWidth of the text to display
  78642. */
  78643. set outlineWidth(value: number);
  78644. /**
  78645. * Gets or sets a boolean indicating that text must have underline
  78646. */
  78647. get underline(): boolean;
  78648. /**
  78649. * Gets or sets a boolean indicating that text must have underline
  78650. */
  78651. set underline(value: boolean);
  78652. /**
  78653. * Gets or sets an boolean indicating that text must be crossed out
  78654. */
  78655. get lineThrough(): boolean;
  78656. /**
  78657. * Gets or sets an boolean indicating that text must be crossed out
  78658. */
  78659. set lineThrough(value: boolean);
  78660. /**
  78661. * Gets or sets outlineColor of the text to display
  78662. */
  78663. get outlineColor(): string;
  78664. /**
  78665. * Gets or sets outlineColor of the text to display
  78666. */
  78667. set outlineColor(value: string);
  78668. /**
  78669. * Creates a new TextBlock object
  78670. * @param name defines the name of the control
  78671. * @param text defines the text to display (emptry string by default)
  78672. */
  78673. constructor(
  78674. /**
  78675. * Defines the name of the control
  78676. */
  78677. name?: string | undefined, text?: string);
  78678. protected _getTypeName(): string;
  78679. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78680. private _drawText;
  78681. /** @hidden */
  78682. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78683. protected _applyStates(context: CanvasRenderingContext2D): void;
  78684. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78685. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78686. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78687. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78688. protected _renderLines(context: CanvasRenderingContext2D): void;
  78689. /**
  78690. * Given a width constraint applied on the text block, find the expected height
  78691. * @returns expected height
  78692. */
  78693. computeExpectedHeight(): number;
  78694. dispose(): void;
  78695. }
  78696. }
  78697. declare module BABYLON.GUI {
  78698. /**
  78699. * Class used to create 2D images
  78700. */
  78701. export class Image extends Control {
  78702. name?: string | undefined;
  78703. private _workingCanvas;
  78704. private _domImage;
  78705. private _imageWidth;
  78706. private _imageHeight;
  78707. private _loaded;
  78708. private _stretch;
  78709. private _source;
  78710. private _autoScale;
  78711. private _sourceLeft;
  78712. private _sourceTop;
  78713. private _sourceWidth;
  78714. private _sourceHeight;
  78715. private _svgAttributesComputationCompleted;
  78716. private _isSVG;
  78717. private _cellWidth;
  78718. private _cellHeight;
  78719. private _cellId;
  78720. private _populateNinePatchSlicesFromImage;
  78721. private _sliceLeft;
  78722. private _sliceRight;
  78723. private _sliceTop;
  78724. private _sliceBottom;
  78725. private _detectPointerOnOpaqueOnly;
  78726. private _imageDataCache;
  78727. /**
  78728. * BABYLON.Observable notified when the content is loaded
  78729. */
  78730. onImageLoadedObservable: BABYLON.Observable<Image>;
  78731. /**
  78732. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78733. */
  78734. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78735. /**
  78736. * Gets a boolean indicating that the content is loaded
  78737. */
  78738. get isLoaded(): boolean;
  78739. /**
  78740. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78741. */
  78742. get populateNinePatchSlicesFromImage(): boolean;
  78743. set populateNinePatchSlicesFromImage(value: boolean);
  78744. /**
  78745. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78746. * Beware using this as this will comsume more memory as the image has to be stored twice
  78747. */
  78748. get detectPointerOnOpaqueOnly(): boolean;
  78749. set detectPointerOnOpaqueOnly(value: boolean);
  78750. /**
  78751. * Gets or sets the left value for slicing (9-patch)
  78752. */
  78753. get sliceLeft(): number;
  78754. set sliceLeft(value: number);
  78755. /**
  78756. * Gets or sets the right value for slicing (9-patch)
  78757. */
  78758. get sliceRight(): number;
  78759. set sliceRight(value: number);
  78760. /**
  78761. * Gets or sets the top value for slicing (9-patch)
  78762. */
  78763. get sliceTop(): number;
  78764. set sliceTop(value: number);
  78765. /**
  78766. * Gets or sets the bottom value for slicing (9-patch)
  78767. */
  78768. get sliceBottom(): number;
  78769. set sliceBottom(value: number);
  78770. /**
  78771. * Gets or sets the left coordinate in the source image
  78772. */
  78773. get sourceLeft(): number;
  78774. set sourceLeft(value: number);
  78775. /**
  78776. * Gets or sets the top coordinate in the source image
  78777. */
  78778. get sourceTop(): number;
  78779. set sourceTop(value: number);
  78780. /**
  78781. * Gets or sets the width to capture in the source image
  78782. */
  78783. get sourceWidth(): number;
  78784. set sourceWidth(value: number);
  78785. /**
  78786. * Gets or sets the height to capture in the source image
  78787. */
  78788. get sourceHeight(): number;
  78789. set sourceHeight(value: number);
  78790. /** Indicates if the format of the image is SVG */
  78791. get isSVG(): boolean;
  78792. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78793. get svgAttributesComputationCompleted(): boolean;
  78794. /**
  78795. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78796. * @see https://doc.babylonjs.com/how_to/gui#image
  78797. */
  78798. get autoScale(): boolean;
  78799. set autoScale(value: boolean);
  78800. /** Gets or sets the streching mode used by the image */
  78801. get stretch(): number;
  78802. set stretch(value: number);
  78803. /** @hidden */
  78804. _rotate90(n: number, preserveProperties?: boolean): Image;
  78805. private _handleRotationForSVGImage;
  78806. private _rotate90SourceProperties;
  78807. /**
  78808. * Gets or sets the internal DOM image used to render the control
  78809. */
  78810. set domImage(value: HTMLImageElement);
  78811. get domImage(): HTMLImageElement;
  78812. private _onImageLoaded;
  78813. private _extractNinePatchSliceDataFromImage;
  78814. /**
  78815. * Gets or sets image source url
  78816. */
  78817. set source(value: BABYLON.Nullable<string>);
  78818. /**
  78819. * Checks for svg document with icon id present
  78820. */
  78821. private _svgCheck;
  78822. /**
  78823. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78824. * given external svg file and icon id
  78825. */
  78826. private _getSVGAttribs;
  78827. /**
  78828. * Gets or sets the cell width to use when animation sheet is enabled
  78829. * @see https://doc.babylonjs.com/how_to/gui#image
  78830. */
  78831. get cellWidth(): number;
  78832. set cellWidth(value: number);
  78833. /**
  78834. * Gets or sets the cell height to use when animation sheet is enabled
  78835. * @see https://doc.babylonjs.com/how_to/gui#image
  78836. */
  78837. get cellHeight(): number;
  78838. set cellHeight(value: number);
  78839. /**
  78840. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78841. * @see https://doc.babylonjs.com/how_to/gui#image
  78842. */
  78843. get cellId(): number;
  78844. set cellId(value: number);
  78845. /**
  78846. * Creates a new Image
  78847. * @param name defines the control name
  78848. * @param url defines the image url
  78849. */
  78850. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78851. /**
  78852. * Tests if a given coordinates belong to the current control
  78853. * @param x defines x coordinate to test
  78854. * @param y defines y coordinate to test
  78855. * @returns true if the coordinates are inside the control
  78856. */
  78857. contains(x: number, y: number): boolean;
  78858. protected _getTypeName(): string;
  78859. /** Force the control to synchronize with its content */
  78860. synchronizeSizeWithContent(): void;
  78861. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78862. private _prepareWorkingCanvasForOpaqueDetection;
  78863. private _drawImage;
  78864. _draw(context: CanvasRenderingContext2D): void;
  78865. private _renderCornerPatch;
  78866. private _renderNinePatch;
  78867. dispose(): void;
  78868. /** STRETCH_NONE */
  78869. static readonly STRETCH_NONE: number;
  78870. /** STRETCH_FILL */
  78871. static readonly STRETCH_FILL: number;
  78872. /** STRETCH_UNIFORM */
  78873. static readonly STRETCH_UNIFORM: number;
  78874. /** STRETCH_EXTEND */
  78875. static readonly STRETCH_EXTEND: number;
  78876. /** NINE_PATCH */
  78877. static readonly STRETCH_NINE_PATCH: number;
  78878. }
  78879. }
  78880. declare module BABYLON.GUI {
  78881. /**
  78882. * Class used to create 2D buttons
  78883. */
  78884. export class Button extends Rectangle {
  78885. name?: string | undefined;
  78886. /**
  78887. * Function called to generate a pointer enter animation
  78888. */
  78889. pointerEnterAnimation: () => void;
  78890. /**
  78891. * Function called to generate a pointer out animation
  78892. */
  78893. pointerOutAnimation: () => void;
  78894. /**
  78895. * Function called to generate a pointer down animation
  78896. */
  78897. pointerDownAnimation: () => void;
  78898. /**
  78899. * Function called to generate a pointer up animation
  78900. */
  78901. pointerUpAnimation: () => void;
  78902. /**
  78903. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78904. */
  78905. delegatePickingToChildren: boolean;
  78906. private _image;
  78907. /**
  78908. * Returns the image part of the button (if any)
  78909. */
  78910. get image(): BABYLON.Nullable<Image>;
  78911. private _textBlock;
  78912. /**
  78913. * Returns the image part of the button (if any)
  78914. */
  78915. get textBlock(): BABYLON.Nullable<TextBlock>;
  78916. /**
  78917. * Creates a new Button
  78918. * @param name defines the name of the button
  78919. */
  78920. constructor(name?: string | undefined);
  78921. protected _getTypeName(): string;
  78922. /** @hidden */
  78923. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78924. /** @hidden */
  78925. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78926. /** @hidden */
  78927. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  78928. /** @hidden */
  78929. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78930. /** @hidden */
  78931. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  78932. /**
  78933. * Creates a new button made with an image and a text
  78934. * @param name defines the name of the button
  78935. * @param text defines the text of the button
  78936. * @param imageUrl defines the url of the image
  78937. * @returns a new Button
  78938. */
  78939. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78940. /**
  78941. * Creates a new button made with an image
  78942. * @param name defines the name of the button
  78943. * @param imageUrl defines the url of the image
  78944. * @returns a new Button
  78945. */
  78946. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78947. /**
  78948. * Creates a new button made with a text
  78949. * @param name defines the name of the button
  78950. * @param text defines the text of the button
  78951. * @returns a new Button
  78952. */
  78953. static CreateSimpleButton(name: string, text: string): Button;
  78954. /**
  78955. * Creates a new button made with an image and a centered text
  78956. * @param name defines the name of the button
  78957. * @param text defines the text of the button
  78958. * @param imageUrl defines the url of the image
  78959. * @returns a new Button
  78960. */
  78961. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78962. }
  78963. }
  78964. declare module BABYLON.GUI {
  78965. /**
  78966. * Class used to create a 2D stack panel container
  78967. */
  78968. export class StackPanel extends Container {
  78969. name?: string | undefined;
  78970. private _isVertical;
  78971. private _manualWidth;
  78972. private _manualHeight;
  78973. private _doNotTrackManualChanges;
  78974. /**
  78975. * Gets or sets a boolean indicating that layou warnings should be ignored
  78976. */
  78977. ignoreLayoutWarnings: boolean;
  78978. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78979. get isVertical(): boolean;
  78980. set isVertical(value: boolean);
  78981. /**
  78982. * Gets or sets panel width.
  78983. * This value should not be set when in horizontal mode as it will be computed automatically
  78984. */
  78985. set width(value: string | number);
  78986. get width(): string | number;
  78987. /**
  78988. * Gets or sets panel height.
  78989. * This value should not be set when in vertical mode as it will be computed automatically
  78990. */
  78991. set height(value: string | number);
  78992. get height(): string | number;
  78993. /**
  78994. * Creates a new StackPanel
  78995. * @param name defines control name
  78996. */
  78997. constructor(name?: string | undefined);
  78998. protected _getTypeName(): string;
  78999. /** @hidden */
  79000. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79001. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79002. protected _postMeasure(): void;
  79003. }
  79004. }
  79005. declare module BABYLON.GUI {
  79006. /**
  79007. * Class used to represent a 2D checkbox
  79008. */
  79009. export class Checkbox extends Control {
  79010. name?: string | undefined;
  79011. private _isChecked;
  79012. private _background;
  79013. private _checkSizeRatio;
  79014. private _thickness;
  79015. /** Gets or sets border thickness */
  79016. get thickness(): number;
  79017. set thickness(value: number);
  79018. /**
  79019. * BABYLON.Observable raised when isChecked property changes
  79020. */
  79021. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79022. /** Gets or sets a value indicating the ratio between overall size and check size */
  79023. get checkSizeRatio(): number;
  79024. set checkSizeRatio(value: number);
  79025. /** Gets or sets background color */
  79026. get background(): string;
  79027. set background(value: string);
  79028. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79029. get isChecked(): boolean;
  79030. set isChecked(value: boolean);
  79031. /**
  79032. * Creates a new CheckBox
  79033. * @param name defines the control name
  79034. */
  79035. constructor(name?: string | undefined);
  79036. protected _getTypeName(): string;
  79037. /** @hidden */
  79038. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79039. /** @hidden */
  79040. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79041. /**
  79042. * Utility function to easily create a checkbox with a header
  79043. * @param title defines the label to use for the header
  79044. * @param onValueChanged defines the callback to call when value changes
  79045. * @returns a StackPanel containing the checkbox and a textBlock
  79046. */
  79047. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79048. }
  79049. }
  79050. declare module BABYLON.GUI {
  79051. /**
  79052. * Class used to store key control properties
  79053. */
  79054. export class KeyPropertySet {
  79055. /** Width */
  79056. width?: string;
  79057. /** Height */
  79058. height?: string;
  79059. /** Left padding */
  79060. paddingLeft?: string;
  79061. /** Right padding */
  79062. paddingRight?: string;
  79063. /** Top padding */
  79064. paddingTop?: string;
  79065. /** Bottom padding */
  79066. paddingBottom?: string;
  79067. /** Foreground color */
  79068. color?: string;
  79069. /** Background color */
  79070. background?: string;
  79071. }
  79072. /**
  79073. * Class used to create virtual keyboard
  79074. */
  79075. export class VirtualKeyboard extends StackPanel {
  79076. /** BABYLON.Observable raised when a key is pressed */
  79077. onKeyPressObservable: BABYLON.Observable<string>;
  79078. /** Gets or sets default key button width */
  79079. defaultButtonWidth: string;
  79080. /** Gets or sets default key button height */
  79081. defaultButtonHeight: string;
  79082. /** Gets or sets default key button left padding */
  79083. defaultButtonPaddingLeft: string;
  79084. /** Gets or sets default key button right padding */
  79085. defaultButtonPaddingRight: string;
  79086. /** Gets or sets default key button top padding */
  79087. defaultButtonPaddingTop: string;
  79088. /** Gets or sets default key button bottom padding */
  79089. defaultButtonPaddingBottom: string;
  79090. /** Gets or sets default key button foreground color */
  79091. defaultButtonColor: string;
  79092. /** Gets or sets default key button background color */
  79093. defaultButtonBackground: string;
  79094. /** Gets or sets shift button foreground color */
  79095. shiftButtonColor: string;
  79096. /** Gets or sets shift button thickness*/
  79097. selectedShiftThickness: number;
  79098. /** Gets shift key state */
  79099. shiftState: number;
  79100. protected _getTypeName(): string;
  79101. private _createKey;
  79102. /**
  79103. * Adds a new row of keys
  79104. * @param keys defines the list of keys to add
  79105. * @param propertySets defines the associated property sets
  79106. */
  79107. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79108. /**
  79109. * Set the shift key to a specific state
  79110. * @param shiftState defines the new shift state
  79111. */
  79112. applyShiftState(shiftState: number): void;
  79113. private _currentlyConnectedInputText;
  79114. private _connectedInputTexts;
  79115. private _onKeyPressObserver;
  79116. /** Gets the input text control currently attached to the keyboard */
  79117. get connectedInputText(): BABYLON.Nullable<InputText>;
  79118. /**
  79119. * Connects the keyboard with an input text control
  79120. *
  79121. * @param input defines the target control
  79122. */
  79123. connect(input: InputText): void;
  79124. /**
  79125. * Disconnects the keyboard from connected InputText controls
  79126. *
  79127. * @param input optionally defines a target control, otherwise all are disconnected
  79128. */
  79129. disconnect(input?: InputText): void;
  79130. private _removeConnectedInputObservables;
  79131. /**
  79132. * Release all resources
  79133. */
  79134. dispose(): void;
  79135. /**
  79136. * Creates a new keyboard using a default layout
  79137. *
  79138. * @param name defines control name
  79139. * @returns a new VirtualKeyboard
  79140. */
  79141. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79142. }
  79143. }
  79144. declare module BABYLON.GUI {
  79145. /**
  79146. * Class used to create input text control
  79147. */
  79148. export class InputText extends Control implements IFocusableControl {
  79149. name?: string | undefined;
  79150. private _text;
  79151. private _placeholderText;
  79152. private _background;
  79153. private _focusedBackground;
  79154. private _focusedColor;
  79155. private _placeholderColor;
  79156. private _thickness;
  79157. private _margin;
  79158. private _autoStretchWidth;
  79159. private _maxWidth;
  79160. private _isFocused;
  79161. private _blinkTimeout;
  79162. private _blinkIsEven;
  79163. private _cursorOffset;
  79164. private _scrollLeft;
  79165. private _textWidth;
  79166. private _clickedCoordinate;
  79167. private _deadKey;
  79168. private _addKey;
  79169. private _currentKey;
  79170. private _isTextHighlightOn;
  79171. private _textHighlightColor;
  79172. private _highligherOpacity;
  79173. private _highlightedText;
  79174. private _startHighlightIndex;
  79175. private _endHighlightIndex;
  79176. private _cursorIndex;
  79177. private _onFocusSelectAll;
  79178. private _isPointerDown;
  79179. private _onClipboardObserver;
  79180. private _onPointerDblTapObserver;
  79181. /** @hidden */
  79182. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79183. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79184. promptMessage: string;
  79185. /** Force disable prompt on mobile device */
  79186. disableMobilePrompt: boolean;
  79187. /** BABYLON.Observable raised when the text changes */
  79188. onTextChangedObservable: BABYLON.Observable<InputText>;
  79189. /** BABYLON.Observable raised just before an entered character is to be added */
  79190. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79191. /** BABYLON.Observable raised when the control gets the focus */
  79192. onFocusObservable: BABYLON.Observable<InputText>;
  79193. /** BABYLON.Observable raised when the control loses the focus */
  79194. onBlurObservable: BABYLON.Observable<InputText>;
  79195. /**Observable raised when the text is highlighted */
  79196. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79197. /**Observable raised when copy event is triggered */
  79198. onTextCopyObservable: BABYLON.Observable<InputText>;
  79199. /** BABYLON.Observable raised when cut event is triggered */
  79200. onTextCutObservable: BABYLON.Observable<InputText>;
  79201. /** BABYLON.Observable raised when paste event is triggered */
  79202. onTextPasteObservable: BABYLON.Observable<InputText>;
  79203. /** BABYLON.Observable raised when a key event was processed */
  79204. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79205. /** Gets or sets the maximum width allowed by the control */
  79206. get maxWidth(): string | number;
  79207. /** Gets the maximum width allowed by the control in pixels */
  79208. get maxWidthInPixels(): number;
  79209. set maxWidth(value: string | number);
  79210. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79211. get highligherOpacity(): number;
  79212. set highligherOpacity(value: number);
  79213. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79214. get onFocusSelectAll(): boolean;
  79215. set onFocusSelectAll(value: boolean);
  79216. /** Gets or sets the text hightlight color */
  79217. get textHighlightColor(): string;
  79218. set textHighlightColor(value: string);
  79219. /** Gets or sets control margin */
  79220. get margin(): string;
  79221. /** Gets control margin in pixels */
  79222. get marginInPixels(): number;
  79223. set margin(value: string);
  79224. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79225. get autoStretchWidth(): boolean;
  79226. set autoStretchWidth(value: boolean);
  79227. /** Gets or sets border thickness */
  79228. get thickness(): number;
  79229. set thickness(value: number);
  79230. /** Gets or sets the background color when focused */
  79231. get focusedBackground(): string;
  79232. set focusedBackground(value: string);
  79233. /** Gets or sets the background color when focused */
  79234. get focusedColor(): string;
  79235. set focusedColor(value: string);
  79236. /** Gets or sets the background color */
  79237. get background(): string;
  79238. set background(value: string);
  79239. /** Gets or sets the placeholder color */
  79240. get placeholderColor(): string;
  79241. set placeholderColor(value: string);
  79242. /** Gets or sets the text displayed when the control is empty */
  79243. get placeholderText(): string;
  79244. set placeholderText(value: string);
  79245. /** Gets or sets the dead key flag */
  79246. get deadKey(): boolean;
  79247. set deadKey(flag: boolean);
  79248. /** Gets or sets the highlight text */
  79249. get highlightedText(): string;
  79250. set highlightedText(text: string);
  79251. /** Gets or sets if the current key should be added */
  79252. get addKey(): boolean;
  79253. set addKey(flag: boolean);
  79254. /** Gets or sets the value of the current key being entered */
  79255. get currentKey(): string;
  79256. set currentKey(key: string);
  79257. /** Gets or sets the text displayed in the control */
  79258. get text(): string;
  79259. set text(value: string);
  79260. /** Gets or sets control width */
  79261. get width(): string | number;
  79262. set width(value: string | number);
  79263. /**
  79264. * Creates a new InputText
  79265. * @param name defines the control name
  79266. * @param text defines the text of the control
  79267. */
  79268. constructor(name?: string | undefined, text?: string);
  79269. /** @hidden */
  79270. onBlur(): void;
  79271. /** @hidden */
  79272. onFocus(): void;
  79273. protected _getTypeName(): string;
  79274. /**
  79275. * Function called to get the list of controls that should not steal the focus from this control
  79276. * @returns an array of controls
  79277. */
  79278. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79279. /** @hidden */
  79280. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79281. /** @hidden */
  79282. private _updateValueFromCursorIndex;
  79283. /** @hidden */
  79284. private _processDblClick;
  79285. /** @hidden */
  79286. private _selectAllText;
  79287. /**
  79288. * Handles the keyboard event
  79289. * @param evt Defines the KeyboardEvent
  79290. */
  79291. processKeyboard(evt: KeyboardEvent): void;
  79292. /** @hidden */
  79293. private _onCopyText;
  79294. /** @hidden */
  79295. private _onCutText;
  79296. /** @hidden */
  79297. private _onPasteText;
  79298. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79299. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79300. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79301. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79302. protected _beforeRenderText(text: string): string;
  79303. dispose(): void;
  79304. }
  79305. }
  79306. declare module BABYLON.GUI {
  79307. /**
  79308. * Class used to create a 2D grid container
  79309. */
  79310. export class Grid extends Container {
  79311. name?: string | undefined;
  79312. private _rowDefinitions;
  79313. private _columnDefinitions;
  79314. private _cells;
  79315. private _childControls;
  79316. /**
  79317. * Gets the number of columns
  79318. */
  79319. get columnCount(): number;
  79320. /**
  79321. * Gets the number of rows
  79322. */
  79323. get rowCount(): number;
  79324. /** Gets the list of children */
  79325. get children(): Control[];
  79326. /** Gets the list of cells (e.g. the containers) */
  79327. get cells(): {
  79328. [key: string]: Container;
  79329. };
  79330. /**
  79331. * Gets the definition of a specific row
  79332. * @param index defines the index of the row
  79333. * @returns the row definition
  79334. */
  79335. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79336. /**
  79337. * Gets the definition of a specific column
  79338. * @param index defines the index of the column
  79339. * @returns the column definition
  79340. */
  79341. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79342. /**
  79343. * Adds a new row to the grid
  79344. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79345. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79346. * @returns the current grid
  79347. */
  79348. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79349. /**
  79350. * Adds a new column to the grid
  79351. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79352. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79353. * @returns the current grid
  79354. */
  79355. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79356. /**
  79357. * Update a row definition
  79358. * @param index defines the index of the row to update
  79359. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79360. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79361. * @returns the current grid
  79362. */
  79363. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79364. /**
  79365. * Update a column definition
  79366. * @param index defines the index of the column to update
  79367. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79368. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79369. * @returns the current grid
  79370. */
  79371. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79372. /**
  79373. * Gets the list of children stored in a specific cell
  79374. * @param row defines the row to check
  79375. * @param column defines the column to check
  79376. * @returns the list of controls
  79377. */
  79378. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79379. /**
  79380. * Gets a string representing the child cell info (row x column)
  79381. * @param child defines the control to get info from
  79382. * @returns a string containing the child cell info (row x column)
  79383. */
  79384. getChildCellInfo(child: Control): string;
  79385. private _removeCell;
  79386. private _offsetCell;
  79387. /**
  79388. * Remove a column definition at specified index
  79389. * @param index defines the index of the column to remove
  79390. * @returns the current grid
  79391. */
  79392. removeColumnDefinition(index: number): Grid;
  79393. /**
  79394. * Remove a row definition at specified index
  79395. * @param index defines the index of the row to remove
  79396. * @returns the current grid
  79397. */
  79398. removeRowDefinition(index: number): Grid;
  79399. /**
  79400. * Adds a new control to the current grid
  79401. * @param control defines the control to add
  79402. * @param row defines the row where to add the control (0 by default)
  79403. * @param column defines the column where to add the control (0 by default)
  79404. * @returns the current grid
  79405. */
  79406. addControl(control: Control, row?: number, column?: number): Grid;
  79407. /**
  79408. * Removes a control from the current container
  79409. * @param control defines the control to remove
  79410. * @returns the current container
  79411. */
  79412. removeControl(control: Control): Container;
  79413. /**
  79414. * Creates a new Grid
  79415. * @param name defines control name
  79416. */
  79417. constructor(name?: string | undefined);
  79418. protected _getTypeName(): string;
  79419. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79420. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79421. _flagDescendantsAsMatrixDirty(): void;
  79422. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79423. /** Releases associated resources */
  79424. dispose(): void;
  79425. }
  79426. }
  79427. declare module BABYLON.GUI {
  79428. /** Class used to create color pickers */
  79429. export class ColorPicker extends Control {
  79430. name?: string | undefined;
  79431. private static _Epsilon;
  79432. private _colorWheelCanvas;
  79433. private _value;
  79434. private _tmpColor;
  79435. private _pointerStartedOnSquare;
  79436. private _pointerStartedOnWheel;
  79437. private _squareLeft;
  79438. private _squareTop;
  79439. private _squareSize;
  79440. private _h;
  79441. private _s;
  79442. private _v;
  79443. private _lastPointerDownID;
  79444. /**
  79445. * BABYLON.Observable raised when the value changes
  79446. */
  79447. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79448. /** Gets or sets the color of the color picker */
  79449. get value(): BABYLON.Color3;
  79450. set value(value: BABYLON.Color3);
  79451. /**
  79452. * Gets or sets control width
  79453. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79454. */
  79455. get width(): string | number;
  79456. set width(value: string | number);
  79457. /**
  79458. * Gets or sets control height
  79459. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79460. */
  79461. get height(): string | number;
  79462. /** Gets or sets control height */
  79463. set height(value: string | number);
  79464. /** Gets or sets control size */
  79465. get size(): string | number;
  79466. set size(value: string | number);
  79467. /**
  79468. * Creates a new ColorPicker
  79469. * @param name defines the control name
  79470. */
  79471. constructor(name?: string | undefined);
  79472. protected _getTypeName(): string;
  79473. /** @hidden */
  79474. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79475. private _updateSquareProps;
  79476. private _drawGradientSquare;
  79477. private _drawCircle;
  79478. private _createColorWheelCanvas;
  79479. /** @hidden */
  79480. _draw(context: CanvasRenderingContext2D): void;
  79481. private _pointerIsDown;
  79482. private _updateValueFromPointer;
  79483. private _isPointOnSquare;
  79484. private _isPointOnWheel;
  79485. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79486. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79487. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79488. _onCanvasBlur(): void;
  79489. /**
  79490. * This function expands the color picker by creating a color picker dialog with manual
  79491. * color value input and the ability to save colors into an array to be used later in
  79492. * subsequent launches of the dialogue.
  79493. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79494. * @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.
  79495. * @returns picked color as a hex string and the saved colors array as hex strings.
  79496. */
  79497. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79498. pickerWidth?: string;
  79499. pickerHeight?: string;
  79500. headerHeight?: string;
  79501. lastColor?: string;
  79502. swatchLimit?: number;
  79503. numSwatchesPerLine?: number;
  79504. savedColors?: Array<string>;
  79505. }): Promise<{
  79506. savedColors?: string[];
  79507. pickedColor: string;
  79508. }>;
  79509. }
  79510. }
  79511. declare module BABYLON.GUI {
  79512. /** Class used to create 2D ellipse containers */
  79513. export class Ellipse extends Container {
  79514. name?: string | undefined;
  79515. private _thickness;
  79516. /** Gets or sets border thickness */
  79517. get thickness(): number;
  79518. set thickness(value: number);
  79519. /**
  79520. * Creates a new Ellipse
  79521. * @param name defines the control name
  79522. */
  79523. constructor(name?: string | undefined);
  79524. protected _getTypeName(): string;
  79525. protected _localDraw(context: CanvasRenderingContext2D): void;
  79526. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79527. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79528. }
  79529. }
  79530. declare module BABYLON.GUI {
  79531. /**
  79532. * Class used to create a password control
  79533. */
  79534. export class InputPassword extends InputText {
  79535. protected _beforeRenderText(text: string): string;
  79536. }
  79537. }
  79538. declare module BABYLON.GUI {
  79539. /** Class used to render 2D lines */
  79540. export class Line extends Control {
  79541. name?: string | undefined;
  79542. private _lineWidth;
  79543. private _x1;
  79544. private _y1;
  79545. private _x2;
  79546. private _y2;
  79547. private _dash;
  79548. private _connectedControl;
  79549. private _connectedControlDirtyObserver;
  79550. /** Gets or sets the dash pattern */
  79551. get dash(): Array<number>;
  79552. set dash(value: Array<number>);
  79553. /** Gets or sets the control connected with the line end */
  79554. get connectedControl(): Control;
  79555. set connectedControl(value: Control);
  79556. /** Gets or sets start coordinates on X axis */
  79557. get x1(): string | number;
  79558. set x1(value: string | number);
  79559. /** Gets or sets start coordinates on Y axis */
  79560. get y1(): string | number;
  79561. set y1(value: string | number);
  79562. /** Gets or sets end coordinates on X axis */
  79563. get x2(): string | number;
  79564. set x2(value: string | number);
  79565. /** Gets or sets end coordinates on Y axis */
  79566. get y2(): string | number;
  79567. set y2(value: string | number);
  79568. /** Gets or sets line width */
  79569. get lineWidth(): number;
  79570. set lineWidth(value: number);
  79571. /** Gets or sets horizontal alignment */
  79572. set horizontalAlignment(value: number);
  79573. /** Gets or sets vertical alignment */
  79574. set verticalAlignment(value: number);
  79575. private get _effectiveX2();
  79576. private get _effectiveY2();
  79577. /**
  79578. * Creates a new Line
  79579. * @param name defines the control name
  79580. */
  79581. constructor(name?: string | undefined);
  79582. protected _getTypeName(): string;
  79583. _draw(context: CanvasRenderingContext2D): void;
  79584. _measure(): void;
  79585. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79586. /**
  79587. * Move one end of the line given 3D cartesian coordinates.
  79588. * @param position Targeted world position
  79589. * @param scene BABYLON.Scene
  79590. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79591. */
  79592. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79593. /**
  79594. * Move one end of the line to a position in screen absolute space.
  79595. * @param projectedPosition Position in screen absolute space (X, Y)
  79596. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79597. */
  79598. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79599. }
  79600. }
  79601. declare module BABYLON.GUI {
  79602. /**
  79603. * Class used to store a point for a MultiLine object.
  79604. * The point can be pure 2D coordinates, a mesh or a control
  79605. */
  79606. export class MultiLinePoint {
  79607. private _multiLine;
  79608. private _x;
  79609. private _y;
  79610. private _control;
  79611. private _mesh;
  79612. private _controlObserver;
  79613. private _meshObserver;
  79614. /** @hidden */
  79615. _point: BABYLON.Vector2;
  79616. /**
  79617. * Creates a new MultiLinePoint
  79618. * @param multiLine defines the source MultiLine object
  79619. */
  79620. constructor(multiLine: MultiLine);
  79621. /** Gets or sets x coordinate */
  79622. get x(): string | number;
  79623. set x(value: string | number);
  79624. /** Gets or sets y coordinate */
  79625. get y(): string | number;
  79626. set y(value: string | number);
  79627. /** Gets or sets the control associated with this point */
  79628. get control(): BABYLON.Nullable<Control>;
  79629. set control(value: BABYLON.Nullable<Control>);
  79630. /** Gets or sets the mesh associated with this point */
  79631. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79632. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79633. /** Resets links */
  79634. resetLinks(): void;
  79635. /**
  79636. * Gets a translation vector
  79637. * @returns the translation vector
  79638. */
  79639. translate(): BABYLON.Vector2;
  79640. private _translatePoint;
  79641. /** Release associated resources */
  79642. dispose(): void;
  79643. }
  79644. }
  79645. declare module BABYLON.GUI {
  79646. /**
  79647. * Class used to create multi line control
  79648. */
  79649. export class MultiLine extends Control {
  79650. name?: string | undefined;
  79651. private _lineWidth;
  79652. private _dash;
  79653. private _points;
  79654. private _minX;
  79655. private _minY;
  79656. private _maxX;
  79657. private _maxY;
  79658. /**
  79659. * Creates a new MultiLine
  79660. * @param name defines the control name
  79661. */
  79662. constructor(name?: string | undefined);
  79663. /** Gets or sets dash pattern */
  79664. get dash(): Array<number>;
  79665. set dash(value: Array<number>);
  79666. /**
  79667. * Gets point stored at specified index
  79668. * @param index defines the index to look for
  79669. * @returns the requested point if found
  79670. */
  79671. getAt(index: number): MultiLinePoint;
  79672. /** Function called when a point is updated */
  79673. onPointUpdate: () => void;
  79674. /**
  79675. * Adds new points to the point collection
  79676. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79677. * @returns the list of created MultiLinePoint
  79678. */
  79679. add(...items: (AbstractMesh | Control | {
  79680. x: string | number;
  79681. y: string | number;
  79682. })[]): MultiLinePoint[];
  79683. /**
  79684. * Adds a new point to the point collection
  79685. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79686. * @returns the created MultiLinePoint
  79687. */
  79688. push(item?: (AbstractMesh | Control | {
  79689. x: string | number;
  79690. y: string | number;
  79691. })): MultiLinePoint;
  79692. /**
  79693. * Remove a specific value or point from the active point collection
  79694. * @param value defines the value or point to remove
  79695. */
  79696. remove(value: number | MultiLinePoint): void;
  79697. /**
  79698. * Resets this object to initial state (no point)
  79699. */
  79700. reset(): void;
  79701. /**
  79702. * Resets all links
  79703. */
  79704. resetLinks(): void;
  79705. /** Gets or sets line width */
  79706. get lineWidth(): number;
  79707. set lineWidth(value: number);
  79708. set horizontalAlignment(value: number);
  79709. set verticalAlignment(value: number);
  79710. protected _getTypeName(): string;
  79711. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79712. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79713. _measure(): void;
  79714. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79715. dispose(): void;
  79716. }
  79717. }
  79718. declare module BABYLON.GUI {
  79719. /**
  79720. * Class used to create radio button controls
  79721. */
  79722. export class RadioButton extends Control {
  79723. name?: string | undefined;
  79724. private _isChecked;
  79725. private _background;
  79726. private _checkSizeRatio;
  79727. private _thickness;
  79728. /** Gets or sets border thickness */
  79729. get thickness(): number;
  79730. set thickness(value: number);
  79731. /** Gets or sets group name */
  79732. group: string;
  79733. /** BABYLON.Observable raised when isChecked is changed */
  79734. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79735. /** Gets or sets a value indicating the ratio between overall size and check size */
  79736. get checkSizeRatio(): number;
  79737. set checkSizeRatio(value: number);
  79738. /** Gets or sets background color */
  79739. get background(): string;
  79740. set background(value: string);
  79741. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79742. get isChecked(): boolean;
  79743. set isChecked(value: boolean);
  79744. /**
  79745. * Creates a new RadioButton
  79746. * @param name defines the control name
  79747. */
  79748. constructor(name?: string | undefined);
  79749. protected _getTypeName(): string;
  79750. _draw(context: CanvasRenderingContext2D): void;
  79751. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79752. /**
  79753. * Utility function to easily create a radio button with a header
  79754. * @param title defines the label to use for the header
  79755. * @param group defines the group to use for the radio button
  79756. * @param isChecked defines the initial state of the radio button
  79757. * @param onValueChanged defines the callback to call when value changes
  79758. * @returns a StackPanel containing the radio button and a textBlock
  79759. */
  79760. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79761. }
  79762. }
  79763. declare module BABYLON.GUI {
  79764. /**
  79765. * Class used to create slider controls
  79766. */
  79767. export class BaseSlider extends Control {
  79768. name?: string | undefined;
  79769. protected _thumbWidth: ValueAndUnit;
  79770. private _minimum;
  79771. private _maximum;
  79772. private _value;
  79773. private _isVertical;
  79774. protected _barOffset: ValueAndUnit;
  79775. private _isThumbClamped;
  79776. protected _displayThumb: boolean;
  79777. private _step;
  79778. private _lastPointerDownID;
  79779. protected _effectiveBarOffset: number;
  79780. protected _renderLeft: number;
  79781. protected _renderTop: number;
  79782. protected _renderWidth: number;
  79783. protected _renderHeight: number;
  79784. protected _backgroundBoxLength: number;
  79785. protected _backgroundBoxThickness: number;
  79786. protected _effectiveThumbThickness: number;
  79787. /** BABYLON.Observable raised when the sldier value changes */
  79788. onValueChangedObservable: BABYLON.Observable<number>;
  79789. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79790. get displayThumb(): boolean;
  79791. set displayThumb(value: boolean);
  79792. /** Gets or sets a step to apply to values (0 by default) */
  79793. get step(): number;
  79794. set step(value: number);
  79795. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79796. get barOffset(): string | number;
  79797. /** Gets main bar offset in pixels*/
  79798. get barOffsetInPixels(): number;
  79799. set barOffset(value: string | number);
  79800. /** Gets or sets thumb width */
  79801. get thumbWidth(): string | number;
  79802. /** Gets thumb width in pixels */
  79803. get thumbWidthInPixels(): number;
  79804. set thumbWidth(value: string | number);
  79805. /** Gets or sets minimum value */
  79806. get minimum(): number;
  79807. set minimum(value: number);
  79808. /** Gets or sets maximum value */
  79809. get maximum(): number;
  79810. set maximum(value: number);
  79811. /** Gets or sets current value */
  79812. get value(): number;
  79813. set value(value: number);
  79814. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79815. get isVertical(): boolean;
  79816. set isVertical(value: boolean);
  79817. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79818. get isThumbClamped(): boolean;
  79819. set isThumbClamped(value: boolean);
  79820. /**
  79821. * Creates a new BaseSlider
  79822. * @param name defines the control name
  79823. */
  79824. constructor(name?: string | undefined);
  79825. protected _getTypeName(): string;
  79826. protected _getThumbPosition(): number;
  79827. protected _getThumbThickness(type: string): number;
  79828. protected _prepareRenderingData(type: string): void;
  79829. private _pointerIsDown;
  79830. /** @hidden */
  79831. protected _updateValueFromPointer(x: number, y: number): void;
  79832. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79833. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79834. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79835. _onCanvasBlur(): void;
  79836. }
  79837. }
  79838. declare module BABYLON.GUI {
  79839. /**
  79840. * Class used to create slider controls
  79841. */
  79842. export class Slider extends BaseSlider {
  79843. name?: string | undefined;
  79844. private _background;
  79845. private _borderColor;
  79846. private _thumbColor;
  79847. private _isThumbCircle;
  79848. protected _displayValueBar: boolean;
  79849. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79850. get displayValueBar(): boolean;
  79851. set displayValueBar(value: boolean);
  79852. /** Gets or sets border color */
  79853. get borderColor(): string;
  79854. set borderColor(value: string);
  79855. /** Gets or sets background color */
  79856. get background(): string;
  79857. set background(value: string);
  79858. /** Gets or sets thumb's color */
  79859. get thumbColor(): string;
  79860. set thumbColor(value: string);
  79861. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79862. get isThumbCircle(): boolean;
  79863. set isThumbCircle(value: boolean);
  79864. /**
  79865. * Creates a new Slider
  79866. * @param name defines the control name
  79867. */
  79868. constructor(name?: string | undefined);
  79869. protected _getTypeName(): string;
  79870. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79871. }
  79872. }
  79873. declare module BABYLON.GUI {
  79874. /** Class used to create a RadioGroup
  79875. * which contains groups of radio buttons
  79876. */
  79877. export class SelectorGroup {
  79878. /** name of SelectorGroup */
  79879. name: string;
  79880. private _groupPanel;
  79881. private _selectors;
  79882. private _groupHeader;
  79883. /**
  79884. * Creates a new SelectorGroup
  79885. * @param name of group, used as a group heading
  79886. */
  79887. constructor(
  79888. /** name of SelectorGroup */
  79889. name: string);
  79890. /** Gets the groupPanel of the SelectorGroup */
  79891. get groupPanel(): StackPanel;
  79892. /** Gets the selectors array */
  79893. get selectors(): StackPanel[];
  79894. /** Gets and sets the group header */
  79895. get header(): string;
  79896. set header(label: string);
  79897. /** @hidden */
  79898. private _addGroupHeader;
  79899. /** @hidden*/
  79900. _getSelector(selectorNb: number): StackPanel | undefined;
  79901. /** Removes the selector at the given position
  79902. * @param selectorNb the position of the selector within the group
  79903. */
  79904. removeSelector(selectorNb: number): void;
  79905. }
  79906. /** Class used to create a CheckboxGroup
  79907. * which contains groups of checkbox buttons
  79908. */
  79909. export class CheckboxGroup extends SelectorGroup {
  79910. /** Adds a checkbox as a control
  79911. * @param text is the label for the selector
  79912. * @param func is the function called when the Selector is checked
  79913. * @param checked is true when Selector is checked
  79914. */
  79915. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79916. /** @hidden */
  79917. _setSelectorLabel(selectorNb: number, label: string): void;
  79918. /** @hidden */
  79919. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79920. /** @hidden */
  79921. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79922. /** @hidden */
  79923. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79924. }
  79925. /** Class used to create a RadioGroup
  79926. * which contains groups of radio buttons
  79927. */
  79928. export class RadioGroup extends SelectorGroup {
  79929. private _selectNb;
  79930. /** Adds a radio button as a control
  79931. * @param label is the label for the selector
  79932. * @param func is the function called when the Selector is checked
  79933. * @param checked is true when Selector is checked
  79934. */
  79935. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79936. /** @hidden */
  79937. _setSelectorLabel(selectorNb: number, label: string): void;
  79938. /** @hidden */
  79939. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79940. /** @hidden */
  79941. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79942. /** @hidden */
  79943. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79944. }
  79945. /** Class used to create a SliderGroup
  79946. * which contains groups of slider buttons
  79947. */
  79948. export class SliderGroup extends SelectorGroup {
  79949. /**
  79950. * Adds a slider to the SelectorGroup
  79951. * @param label is the label for the SliderBar
  79952. * @param func is the function called when the Slider moves
  79953. * @param unit is a string describing the units used, eg degrees or metres
  79954. * @param min is the minimum value for the Slider
  79955. * @param max is the maximum value for the Slider
  79956. * @param value is the start value for the Slider between min and max
  79957. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79958. */
  79959. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79960. /** @hidden */
  79961. _setSelectorLabel(selectorNb: number, label: string): void;
  79962. /** @hidden */
  79963. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79964. /** @hidden */
  79965. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79966. /** @hidden */
  79967. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79968. }
  79969. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79970. * @see https://doc.babylonjs.com/how_to/selector
  79971. */
  79972. export class SelectionPanel extends Rectangle {
  79973. /** name of SelectionPanel */
  79974. name: string;
  79975. /** an array of SelectionGroups */
  79976. groups: SelectorGroup[];
  79977. private _panel;
  79978. private _buttonColor;
  79979. private _buttonBackground;
  79980. private _headerColor;
  79981. private _barColor;
  79982. private _barHeight;
  79983. private _spacerHeight;
  79984. private _labelColor;
  79985. private _groups;
  79986. private _bars;
  79987. /**
  79988. * Creates a new SelectionPanel
  79989. * @param name of SelectionPanel
  79990. * @param groups is an array of SelectionGroups
  79991. */
  79992. constructor(
  79993. /** name of SelectionPanel */
  79994. name: string,
  79995. /** an array of SelectionGroups */
  79996. groups?: SelectorGroup[]);
  79997. protected _getTypeName(): string;
  79998. /** Gets the (stack) panel of the SelectionPanel */
  79999. get panel(): StackPanel;
  80000. /** Gets or sets the headerColor */
  80001. get headerColor(): string;
  80002. set headerColor(color: string);
  80003. private _setHeaderColor;
  80004. /** Gets or sets the button color */
  80005. get buttonColor(): string;
  80006. set buttonColor(color: string);
  80007. private _setbuttonColor;
  80008. /** Gets or sets the label color */
  80009. get labelColor(): string;
  80010. set labelColor(color: string);
  80011. private _setLabelColor;
  80012. /** Gets or sets the button background */
  80013. get buttonBackground(): string;
  80014. set buttonBackground(color: string);
  80015. private _setButtonBackground;
  80016. /** Gets or sets the color of separator bar */
  80017. get barColor(): string;
  80018. set barColor(color: string);
  80019. private _setBarColor;
  80020. /** Gets or sets the height of separator bar */
  80021. get barHeight(): string;
  80022. set barHeight(value: string);
  80023. private _setBarHeight;
  80024. /** Gets or sets the height of spacers*/
  80025. get spacerHeight(): string;
  80026. set spacerHeight(value: string);
  80027. private _setSpacerHeight;
  80028. /** Adds a bar between groups */
  80029. private _addSpacer;
  80030. /** Add a group to the selection panel
  80031. * @param group is the selector group to add
  80032. */
  80033. addGroup(group: SelectorGroup): void;
  80034. /** Remove the group from the given position
  80035. * @param groupNb is the position of the group in the list
  80036. */
  80037. removeGroup(groupNb: number): void;
  80038. /** Change a group header label
  80039. * @param label is the new group header label
  80040. * @param groupNb is the number of the group to relabel
  80041. * */
  80042. setHeaderName(label: string, groupNb: number): void;
  80043. /** Change selector label to the one given
  80044. * @param label is the new selector label
  80045. * @param groupNb is the number of the groupcontaining the selector
  80046. * @param selectorNb is the number of the selector within a group to relabel
  80047. * */
  80048. relabel(label: string, groupNb: number, selectorNb: number): void;
  80049. /** For a given group position remove the selector at the given position
  80050. * @param groupNb is the number of the group to remove the selector from
  80051. * @param selectorNb is the number of the selector within the group
  80052. */
  80053. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80054. /** For a given group position of correct type add a checkbox button
  80055. * @param groupNb is the number of the group to remove the selector from
  80056. * @param label is the label for the selector
  80057. * @param func is the function called when the Selector is checked
  80058. * @param checked is true when Selector is checked
  80059. */
  80060. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80061. /** For a given group position of correct type add a radio button
  80062. * @param groupNb is the number of the group to remove the selector from
  80063. * @param label is the label for the selector
  80064. * @param func is the function called when the Selector is checked
  80065. * @param checked is true when Selector is checked
  80066. */
  80067. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80068. /**
  80069. * For a given slider group add a slider
  80070. * @param groupNb is the number of the group to add the slider to
  80071. * @param label is the label for the Slider
  80072. * @param func is the function called when the Slider moves
  80073. * @param unit is a string describing the units used, eg degrees or metres
  80074. * @param min is the minimum value for the Slider
  80075. * @param max is the maximum value for the Slider
  80076. * @param value is the start value for the Slider between min and max
  80077. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80078. */
  80079. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80080. }
  80081. }
  80082. declare module BABYLON.GUI {
  80083. /**
  80084. * Class used to hold a the container for ScrollViewer
  80085. * @hidden
  80086. */
  80087. export class _ScrollViewerWindow extends Container {
  80088. parentClientWidth: number;
  80089. parentClientHeight: number;
  80090. private _freezeControls;
  80091. private _parentMeasure;
  80092. private _oldLeft;
  80093. private _oldTop;
  80094. get freezeControls(): boolean;
  80095. set freezeControls(value: boolean);
  80096. private _bucketWidth;
  80097. private _bucketHeight;
  80098. private _buckets;
  80099. private _bucketLen;
  80100. get bucketWidth(): number;
  80101. get bucketHeight(): number;
  80102. setBucketSizes(width: number, height: number): void;
  80103. private _useBuckets;
  80104. private _makeBuckets;
  80105. private _dispatchInBuckets;
  80106. private _updateMeasures;
  80107. private _updateChildrenMeasures;
  80108. private _restoreMeasures;
  80109. /**
  80110. * Creates a new ScrollViewerWindow
  80111. * @param name of ScrollViewerWindow
  80112. */
  80113. constructor(name?: string);
  80114. protected _getTypeName(): string;
  80115. /** @hidden */
  80116. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80117. /** @hidden */
  80118. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80119. private _scrollChildren;
  80120. private _scrollChildrenWithBuckets;
  80121. /** @hidden */
  80122. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80123. protected _postMeasure(): void;
  80124. }
  80125. }
  80126. declare module BABYLON.GUI {
  80127. /**
  80128. * Class used to create slider controls
  80129. */
  80130. export class ScrollBar extends BaseSlider {
  80131. name?: string | undefined;
  80132. private _background;
  80133. private _borderColor;
  80134. private _tempMeasure;
  80135. /** Gets or sets border color */
  80136. get borderColor(): string;
  80137. set borderColor(value: string);
  80138. /** Gets or sets background color */
  80139. get background(): string;
  80140. set background(value: string);
  80141. /**
  80142. * Creates a new Slider
  80143. * @param name defines the control name
  80144. */
  80145. constructor(name?: string | undefined);
  80146. protected _getTypeName(): string;
  80147. protected _getThumbThickness(): number;
  80148. _draw(context: CanvasRenderingContext2D): void;
  80149. private _first;
  80150. private _originX;
  80151. private _originY;
  80152. /** @hidden */
  80153. protected _updateValueFromPointer(x: number, y: number): void;
  80154. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80155. }
  80156. }
  80157. declare module BABYLON.GUI {
  80158. /**
  80159. * Class used to create slider controls
  80160. */
  80161. export class ImageScrollBar extends BaseSlider {
  80162. name?: string | undefined;
  80163. private _backgroundBaseImage;
  80164. private _backgroundImage;
  80165. private _thumbImage;
  80166. private _thumbBaseImage;
  80167. private _thumbLength;
  80168. private _thumbHeight;
  80169. private _barImageHeight;
  80170. private _tempMeasure;
  80171. /** Number of 90° rotation to apply on the images when in vertical mode */
  80172. num90RotationInVerticalMode: number;
  80173. /**
  80174. * Gets or sets the image used to render the background for horizontal bar
  80175. */
  80176. get backgroundImage(): Image;
  80177. set backgroundImage(value: Image);
  80178. /**
  80179. * Gets or sets the image used to render the thumb
  80180. */
  80181. get thumbImage(): Image;
  80182. set thumbImage(value: Image);
  80183. /**
  80184. * Gets or sets the length of the thumb
  80185. */
  80186. get thumbLength(): number;
  80187. set thumbLength(value: number);
  80188. /**
  80189. * Gets or sets the height of the thumb
  80190. */
  80191. get thumbHeight(): number;
  80192. set thumbHeight(value: number);
  80193. /**
  80194. * Gets or sets the height of the bar image
  80195. */
  80196. get barImageHeight(): number;
  80197. set barImageHeight(value: number);
  80198. /**
  80199. * Creates a new ImageScrollBar
  80200. * @param name defines the control name
  80201. */
  80202. constructor(name?: string | undefined);
  80203. protected _getTypeName(): string;
  80204. protected _getThumbThickness(): number;
  80205. _draw(context: CanvasRenderingContext2D): void;
  80206. private _first;
  80207. private _originX;
  80208. private _originY;
  80209. /** @hidden */
  80210. protected _updateValueFromPointer(x: number, y: number): void;
  80211. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80212. }
  80213. }
  80214. declare module BABYLON.GUI {
  80215. /**
  80216. * Class used to hold a viewer window and sliders in a grid
  80217. */
  80218. export class ScrollViewer extends Rectangle {
  80219. private _grid;
  80220. private _horizontalBarSpace;
  80221. private _verticalBarSpace;
  80222. private _dragSpace;
  80223. private _horizontalBar;
  80224. private _verticalBar;
  80225. private _barColor;
  80226. private _barBackground;
  80227. private _barImage;
  80228. private _horizontalBarImage;
  80229. private _verticalBarImage;
  80230. private _barBackgroundImage;
  80231. private _horizontalBarBackgroundImage;
  80232. private _verticalBarBackgroundImage;
  80233. private _barSize;
  80234. private _window;
  80235. private _pointerIsOver;
  80236. private _wheelPrecision;
  80237. private _onWheelObserver;
  80238. private _clientWidth;
  80239. private _clientHeight;
  80240. private _useImageBar;
  80241. private _thumbLength;
  80242. private _thumbHeight;
  80243. private _barImageHeight;
  80244. private _horizontalBarImageHeight;
  80245. private _verticalBarImageHeight;
  80246. private _oldWindowContentsWidth;
  80247. private _oldWindowContentsHeight;
  80248. /**
  80249. * Gets the horizontal scrollbar
  80250. */
  80251. get horizontalBar(): ScrollBar | ImageScrollBar;
  80252. /**
  80253. * Gets the vertical scrollbar
  80254. */
  80255. get verticalBar(): ScrollBar | ImageScrollBar;
  80256. /**
  80257. * Adds a new control to the current container
  80258. * @param control defines the control to add
  80259. * @returns the current container
  80260. */
  80261. addControl(control: BABYLON.Nullable<Control>): Container;
  80262. /**
  80263. * Removes a control from the current container
  80264. * @param control defines the control to remove
  80265. * @returns the current container
  80266. */
  80267. removeControl(control: Control): Container;
  80268. /** Gets the list of children */
  80269. get children(): Control[];
  80270. _flagDescendantsAsMatrixDirty(): void;
  80271. /**
  80272. * Freezes or unfreezes the controls in the window.
  80273. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80274. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80275. */
  80276. get freezeControls(): boolean;
  80277. set freezeControls(value: boolean);
  80278. /** Gets the bucket width */
  80279. get bucketWidth(): number;
  80280. /** Gets the bucket height */
  80281. get bucketHeight(): number;
  80282. /**
  80283. * Sets the bucket sizes.
  80284. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80285. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80286. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80287. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80288. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80289. * used), that's why it is not enabled by default.
  80290. * @param width width of the bucket
  80291. * @param height height of the bucket
  80292. */
  80293. setBucketSizes(width: number, height: number): void;
  80294. private _forceHorizontalBar;
  80295. private _forceVerticalBar;
  80296. /**
  80297. * Forces the horizontal scroll bar to be displayed
  80298. */
  80299. get forceHorizontalBar(): boolean;
  80300. set forceHorizontalBar(value: boolean);
  80301. /**
  80302. * Forces the vertical scroll bar to be displayed
  80303. */
  80304. get forceVerticalBar(): boolean;
  80305. set forceVerticalBar(value: boolean);
  80306. /**
  80307. * Creates a new ScrollViewer
  80308. * @param name of ScrollViewer
  80309. */
  80310. constructor(name?: string, isImageBased?: boolean);
  80311. /** Reset the scroll viewer window to initial size */
  80312. resetWindow(): void;
  80313. protected _getTypeName(): string;
  80314. private _buildClientSizes;
  80315. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80316. protected _postMeasure(): void;
  80317. /**
  80318. * Gets or sets the mouse wheel precision
  80319. * from 0 to 1 with a default value of 0.05
  80320. * */
  80321. get wheelPrecision(): number;
  80322. set wheelPrecision(value: number);
  80323. /** Gets or sets the scroll bar container background color */
  80324. get scrollBackground(): string;
  80325. set scrollBackground(color: string);
  80326. /** Gets or sets the bar color */
  80327. get barColor(): string;
  80328. set barColor(color: string);
  80329. /** Gets or sets the bar image */
  80330. get thumbImage(): Image;
  80331. set thumbImage(value: Image);
  80332. /** Gets or sets the horizontal bar image */
  80333. get horizontalThumbImage(): Image;
  80334. set horizontalThumbImage(value: Image);
  80335. /** Gets or sets the vertical bar image */
  80336. get verticalThumbImage(): Image;
  80337. set verticalThumbImage(value: Image);
  80338. /** Gets or sets the size of the bar */
  80339. get barSize(): number;
  80340. set barSize(value: number);
  80341. /** Gets or sets the length of the thumb */
  80342. get thumbLength(): number;
  80343. set thumbLength(value: number);
  80344. /** Gets or sets the height of the thumb */
  80345. get thumbHeight(): number;
  80346. set thumbHeight(value: number);
  80347. /** Gets or sets the height of the bar image */
  80348. get barImageHeight(): number;
  80349. set barImageHeight(value: number);
  80350. /** Gets or sets the height of the horizontal bar image */
  80351. get horizontalBarImageHeight(): number;
  80352. set horizontalBarImageHeight(value: number);
  80353. /** Gets or sets the height of the vertical bar image */
  80354. get verticalBarImageHeight(): number;
  80355. set verticalBarImageHeight(value: number);
  80356. /** Gets or sets the bar background */
  80357. get barBackground(): string;
  80358. set barBackground(color: string);
  80359. /** Gets or sets the bar background image */
  80360. get barImage(): Image;
  80361. set barImage(value: Image);
  80362. /** Gets or sets the horizontal bar background image */
  80363. get horizontalBarImage(): Image;
  80364. set horizontalBarImage(value: Image);
  80365. /** Gets or sets the vertical bar background image */
  80366. get verticalBarImage(): Image;
  80367. set verticalBarImage(value: Image);
  80368. private _setWindowPosition;
  80369. /** @hidden */
  80370. private _updateScroller;
  80371. _link(host: AdvancedDynamicTexture): void;
  80372. /** @hidden */
  80373. private _addBar;
  80374. /** @hidden */
  80375. private _attachWheel;
  80376. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80377. /** Releases associated resources */
  80378. dispose(): void;
  80379. }
  80380. }
  80381. declare module BABYLON.GUI {
  80382. /** Class used to render a grid */
  80383. export class DisplayGrid extends Control {
  80384. name?: string | undefined;
  80385. private _cellWidth;
  80386. private _cellHeight;
  80387. private _minorLineTickness;
  80388. private _minorLineColor;
  80389. private _majorLineTickness;
  80390. private _majorLineColor;
  80391. private _majorLineFrequency;
  80392. private _background;
  80393. private _displayMajorLines;
  80394. private _displayMinorLines;
  80395. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80396. get displayMinorLines(): boolean;
  80397. set displayMinorLines(value: boolean);
  80398. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80399. get displayMajorLines(): boolean;
  80400. set displayMajorLines(value: boolean);
  80401. /** Gets or sets background color (Black by default) */
  80402. get background(): string;
  80403. set background(value: string);
  80404. /** Gets or sets the width of each cell (20 by default) */
  80405. get cellWidth(): number;
  80406. set cellWidth(value: number);
  80407. /** Gets or sets the height of each cell (20 by default) */
  80408. get cellHeight(): number;
  80409. set cellHeight(value: number);
  80410. /** Gets or sets the tickness of minor lines (1 by default) */
  80411. get minorLineTickness(): number;
  80412. set minorLineTickness(value: number);
  80413. /** Gets or sets the color of minor lines (DarkGray by default) */
  80414. get minorLineColor(): string;
  80415. set minorLineColor(value: string);
  80416. /** Gets or sets the tickness of major lines (2 by default) */
  80417. get majorLineTickness(): number;
  80418. set majorLineTickness(value: number);
  80419. /** Gets or sets the color of major lines (White by default) */
  80420. get majorLineColor(): string;
  80421. set majorLineColor(value: string);
  80422. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80423. get majorLineFrequency(): number;
  80424. set majorLineFrequency(value: number);
  80425. /**
  80426. * Creates a new GridDisplayRectangle
  80427. * @param name defines the control name
  80428. */
  80429. constructor(name?: string | undefined);
  80430. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80431. protected _getTypeName(): string;
  80432. }
  80433. }
  80434. declare module BABYLON.GUI {
  80435. /**
  80436. * Class used to create slider controls based on images
  80437. */
  80438. export class ImageBasedSlider extends BaseSlider {
  80439. name?: string | undefined;
  80440. private _backgroundImage;
  80441. private _thumbImage;
  80442. private _valueBarImage;
  80443. private _tempMeasure;
  80444. get displayThumb(): boolean;
  80445. set displayThumb(value: boolean);
  80446. /**
  80447. * Gets or sets the image used to render the background
  80448. */
  80449. get backgroundImage(): Image;
  80450. set backgroundImage(value: Image);
  80451. /**
  80452. * Gets or sets the image used to render the value bar
  80453. */
  80454. get valueBarImage(): Image;
  80455. set valueBarImage(value: Image);
  80456. /**
  80457. * Gets or sets the image used to render the thumb
  80458. */
  80459. get thumbImage(): Image;
  80460. set thumbImage(value: Image);
  80461. /**
  80462. * Creates a new ImageBasedSlider
  80463. * @param name defines the control name
  80464. */
  80465. constructor(name?: string | undefined);
  80466. protected _getTypeName(): string;
  80467. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80468. }
  80469. }
  80470. declare module BABYLON.GUI {
  80471. /**
  80472. * Forcing an export so that this code will execute
  80473. * @hidden
  80474. */
  80475. const name = "Statics";
  80476. }
  80477. declare module BABYLON.GUI {
  80478. /**
  80479. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80480. */
  80481. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80482. /**
  80483. * Define the instrumented AdvancedDynamicTexture.
  80484. */
  80485. texture: AdvancedDynamicTexture;
  80486. private _captureRenderTime;
  80487. private _renderTime;
  80488. private _captureLayoutTime;
  80489. private _layoutTime;
  80490. private _onBeginRenderObserver;
  80491. private _onEndRenderObserver;
  80492. private _onBeginLayoutObserver;
  80493. private _onEndLayoutObserver;
  80494. /**
  80495. * Gets the perf counter used to capture render time
  80496. */
  80497. get renderTimeCounter(): BABYLON.PerfCounter;
  80498. /**
  80499. * Gets the perf counter used to capture layout time
  80500. */
  80501. get layoutTimeCounter(): BABYLON.PerfCounter;
  80502. /**
  80503. * Enable or disable the render time capture
  80504. */
  80505. get captureRenderTime(): boolean;
  80506. set captureRenderTime(value: boolean);
  80507. /**
  80508. * Enable or disable the layout time capture
  80509. */
  80510. get captureLayoutTime(): boolean;
  80511. set captureLayoutTime(value: boolean);
  80512. /**
  80513. * Instantiates a new advanced dynamic texture instrumentation.
  80514. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80515. * @param texture Defines the AdvancedDynamicTexture to instrument
  80516. */
  80517. constructor(
  80518. /**
  80519. * Define the instrumented AdvancedDynamicTexture.
  80520. */
  80521. texture: AdvancedDynamicTexture);
  80522. /**
  80523. * Dispose and release associated resources.
  80524. */
  80525. dispose(): void;
  80526. }
  80527. }
  80528. declare module BABYLON.GUI {
  80529. /**
  80530. * Class used to load GUI via XML.
  80531. */
  80532. export class XmlLoader {
  80533. private _nodes;
  80534. private _nodeTypes;
  80535. private _isLoaded;
  80536. private _objectAttributes;
  80537. private _parentClass;
  80538. /**
  80539. * Create a new xml loader
  80540. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80541. */
  80542. constructor(parentClass?: null);
  80543. private _getChainElement;
  80544. private _getClassAttribute;
  80545. private _createGuiElement;
  80546. private _parseGrid;
  80547. private _parseElement;
  80548. private _prepareSourceElement;
  80549. private _parseElementsFromSource;
  80550. private _parseXml;
  80551. /**
  80552. * Gets if the loading has finished.
  80553. * @returns whether the loading has finished or not
  80554. */
  80555. isLoaded(): boolean;
  80556. /**
  80557. * Gets a loaded node / control by id.
  80558. * @param id the Controls id set in the xml
  80559. * @returns element of type Control
  80560. */
  80561. getNodeById(id: string): any;
  80562. /**
  80563. * Gets all loaded nodes / controls
  80564. * @returns Array of controls
  80565. */
  80566. getNodes(): any;
  80567. /**
  80568. * Initiates the xml layout loading
  80569. * @param xmlFile defines the xml layout to load
  80570. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80571. * @param callback defines the callback called on layout load.
  80572. */
  80573. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80574. }
  80575. }
  80576. declare module BABYLON.GUI {
  80577. /**
  80578. * Class used to create containers for controls
  80579. */
  80580. export class Container3D extends Control3D {
  80581. private _blockLayout;
  80582. /**
  80583. * Gets the list of child controls
  80584. */
  80585. protected _children: Control3D[];
  80586. /**
  80587. * Gets the list of child controls
  80588. */
  80589. get children(): Array<Control3D>;
  80590. /**
  80591. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80592. * This is helpful to optimize layout operation when adding multiple children in a row
  80593. */
  80594. get blockLayout(): boolean;
  80595. set blockLayout(value: boolean);
  80596. /**
  80597. * Creates a new container
  80598. * @param name defines the container name
  80599. */
  80600. constructor(name?: string);
  80601. /**
  80602. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80603. * @returns the current container
  80604. */
  80605. updateLayout(): Container3D;
  80606. /**
  80607. * Gets a boolean indicating if the given control is in the children of this control
  80608. * @param control defines the control to check
  80609. * @returns true if the control is in the child list
  80610. */
  80611. containsControl(control: Control3D): boolean;
  80612. /**
  80613. * Adds a control to the children of this control
  80614. * @param control defines the control to add
  80615. * @returns the current container
  80616. */
  80617. addControl(control: Control3D): Container3D;
  80618. /**
  80619. * This function will be called everytime a new control is added
  80620. */
  80621. protected _arrangeChildren(): void;
  80622. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80623. /**
  80624. * Removes a control from the children of this control
  80625. * @param control defines the control to remove
  80626. * @returns the current container
  80627. */
  80628. removeControl(control: Control3D): Container3D;
  80629. protected _getTypeName(): string;
  80630. /**
  80631. * Releases all associated resources
  80632. */
  80633. dispose(): void;
  80634. /** Control rotation will remain unchanged */
  80635. static readonly UNSET_ORIENTATION: number;
  80636. /** Control will rotate to make it look at sphere central axis */
  80637. static readonly FACEORIGIN_ORIENTATION: number;
  80638. /** Control will rotate to make it look back at sphere central axis */
  80639. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80640. /** Control will rotate to look at z axis (0, 0, 1) */
  80641. static readonly FACEFORWARD_ORIENTATION: number;
  80642. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80643. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80644. }
  80645. }
  80646. declare module BABYLON.GUI {
  80647. /**
  80648. * Class used to manage 3D user interface
  80649. * @see https://doc.babylonjs.com/how_to/gui3d
  80650. */
  80651. export class GUI3DManager implements BABYLON.IDisposable {
  80652. private _scene;
  80653. private _sceneDisposeObserver;
  80654. private _utilityLayer;
  80655. private _rootContainer;
  80656. private _pointerObserver;
  80657. private _pointerOutObserver;
  80658. /** @hidden */
  80659. _lastPickedControl: Control3D;
  80660. /** @hidden */
  80661. _lastControlOver: {
  80662. [pointerId: number]: Control3D;
  80663. };
  80664. /** @hidden */
  80665. _lastControlDown: {
  80666. [pointerId: number]: Control3D;
  80667. };
  80668. /**
  80669. * BABYLON.Observable raised when the point picked by the pointer events changed
  80670. */
  80671. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80672. /** @hidden */
  80673. _sharedMaterials: {
  80674. [key: string]: BABYLON.Material;
  80675. };
  80676. /** Gets the hosting scene */
  80677. get scene(): BABYLON.Scene;
  80678. /** Gets associated utility layer */
  80679. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80680. /**
  80681. * Creates a new GUI3DManager
  80682. * @param scene
  80683. */
  80684. constructor(scene?: BABYLON.Scene);
  80685. private _handlePointerOut;
  80686. private _doPicking;
  80687. /**
  80688. * Gets the root container
  80689. */
  80690. get rootContainer(): Container3D;
  80691. /**
  80692. * Gets a boolean indicating if the given control is in the root child list
  80693. * @param control defines the control to check
  80694. * @returns true if the control is in the root child list
  80695. */
  80696. containsControl(control: Control3D): boolean;
  80697. /**
  80698. * Adds a control to the root child list
  80699. * @param control defines the control to add
  80700. * @returns the current manager
  80701. */
  80702. addControl(control: Control3D): GUI3DManager;
  80703. /**
  80704. * Removes a control from the root child list
  80705. * @param control defines the control to remove
  80706. * @returns the current container
  80707. */
  80708. removeControl(control: Control3D): GUI3DManager;
  80709. /**
  80710. * Releases all associated resources
  80711. */
  80712. dispose(): void;
  80713. }
  80714. }
  80715. declare module BABYLON.GUI {
  80716. /**
  80717. * Class used to transport BABYLON.Vector3 information for pointer events
  80718. */
  80719. export class Vector3WithInfo extends BABYLON.Vector3 {
  80720. /** defines the current mouse button index */
  80721. buttonIndex: number;
  80722. /**
  80723. * Creates a new Vector3WithInfo
  80724. * @param source defines the vector3 data to transport
  80725. * @param buttonIndex defines the current mouse button index
  80726. */
  80727. constructor(source: BABYLON.Vector3,
  80728. /** defines the current mouse button index */
  80729. buttonIndex?: number);
  80730. }
  80731. }
  80732. declare module BABYLON.GUI {
  80733. /**
  80734. * Class used as base class for controls
  80735. */
  80736. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80737. /** Defines the control name */
  80738. name?: string | undefined;
  80739. /** @hidden */
  80740. _host: GUI3DManager;
  80741. private _node;
  80742. private _downCount;
  80743. private _enterCount;
  80744. private _downPointerIds;
  80745. private _isVisible;
  80746. /** Gets or sets the control position in world space */
  80747. get position(): BABYLON.Vector3;
  80748. set position(value: BABYLON.Vector3);
  80749. /** Gets or sets the control scaling in world space */
  80750. get scaling(): BABYLON.Vector3;
  80751. set scaling(value: BABYLON.Vector3);
  80752. /** Callback used to start pointer enter animation */
  80753. pointerEnterAnimation: () => void;
  80754. /** Callback used to start pointer out animation */
  80755. pointerOutAnimation: () => void;
  80756. /** Callback used to start pointer down animation */
  80757. pointerDownAnimation: () => void;
  80758. /** Callback used to start pointer up animation */
  80759. pointerUpAnimation: () => void;
  80760. /**
  80761. * An event triggered when the pointer move over the control
  80762. */
  80763. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80764. /**
  80765. * An event triggered when the pointer move out of the control
  80766. */
  80767. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80768. /**
  80769. * An event triggered when the pointer taps the control
  80770. */
  80771. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80772. /**
  80773. * An event triggered when pointer is up
  80774. */
  80775. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80776. /**
  80777. * An event triggered when a control is clicked on (with a mouse)
  80778. */
  80779. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80780. /**
  80781. * An event triggered when pointer enters the control
  80782. */
  80783. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80784. /**
  80785. * Gets or sets the parent container
  80786. */
  80787. parent: BABYLON.Nullable<Container3D>;
  80788. private _behaviors;
  80789. /**
  80790. * Gets the list of attached behaviors
  80791. * @see https://doc.babylonjs.com/features/behaviour
  80792. */
  80793. get behaviors(): BABYLON.Behavior<Control3D>[];
  80794. /**
  80795. * Attach a behavior to the control
  80796. * @see https://doc.babylonjs.com/features/behaviour
  80797. * @param behavior defines the behavior to attach
  80798. * @returns the current control
  80799. */
  80800. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80801. /**
  80802. * Remove an attached behavior
  80803. * @see https://doc.babylonjs.com/features/behaviour
  80804. * @param behavior defines the behavior to attach
  80805. * @returns the current control
  80806. */
  80807. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80808. /**
  80809. * Gets an attached behavior by name
  80810. * @param name defines the name of the behavior to look for
  80811. * @see https://doc.babylonjs.com/features/behaviour
  80812. * @returns null if behavior was not found else the requested behavior
  80813. */
  80814. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80815. /** Gets or sets a boolean indicating if the control is visible */
  80816. get isVisible(): boolean;
  80817. set isVisible(value: boolean);
  80818. /**
  80819. * Creates a new control
  80820. * @param name defines the control name
  80821. */
  80822. constructor(
  80823. /** Defines the control name */
  80824. name?: string | undefined);
  80825. /**
  80826. * Gets a string representing the class name
  80827. */
  80828. get typeName(): string;
  80829. /**
  80830. * Get the current class name of the control.
  80831. * @returns current class name
  80832. */
  80833. getClassName(): string;
  80834. protected _getTypeName(): string;
  80835. /**
  80836. * Gets the transform node used by this control
  80837. */
  80838. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80839. /**
  80840. * Gets the mesh used to render this control
  80841. */
  80842. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80843. /**
  80844. * Link the control as child of the given node
  80845. * @param node defines the node to link to. Use null to unlink the control
  80846. * @returns the current control
  80847. */
  80848. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80849. /** @hidden **/
  80850. _prepareNode(scene: BABYLON.Scene): void;
  80851. /**
  80852. * Node creation.
  80853. * Can be overriden by children
  80854. * @param scene defines the scene where the node must be attached
  80855. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80856. */
  80857. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80858. /**
  80859. * Affect a material to the given mesh
  80860. * @param mesh defines the mesh which will represent the control
  80861. */
  80862. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80863. /** @hidden */
  80864. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80865. /** @hidden */
  80866. _onPointerEnter(target: Control3D): boolean;
  80867. /** @hidden */
  80868. _onPointerOut(target: Control3D): void;
  80869. /** @hidden */
  80870. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80871. /** @hidden */
  80872. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80873. /** @hidden */
  80874. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80875. /** @hidden */
  80876. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80877. /** @hidden */
  80878. _disposeNode(): void;
  80879. /**
  80880. * Releases all associated resources
  80881. */
  80882. dispose(): void;
  80883. }
  80884. }
  80885. declare module BABYLON.GUI {
  80886. /**
  80887. * Class used as a root to all buttons
  80888. */
  80889. export class AbstractButton3D extends Control3D {
  80890. /**
  80891. * Creates a new button
  80892. * @param name defines the control name
  80893. */
  80894. constructor(name?: string);
  80895. protected _getTypeName(): string;
  80896. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80897. }
  80898. }
  80899. declare module BABYLON.GUI {
  80900. /**
  80901. * Class used to create a button in 3D
  80902. */
  80903. export class Button3D extends AbstractButton3D {
  80904. /** @hidden */
  80905. protected _currentMaterial: BABYLON.Material;
  80906. private _facadeTexture;
  80907. private _content;
  80908. private _contentResolution;
  80909. private _contentScaleRatio;
  80910. /**
  80911. * Gets or sets the texture resolution used to render content (512 by default)
  80912. */
  80913. get contentResolution(): BABYLON.int;
  80914. set contentResolution(value: BABYLON.int);
  80915. /**
  80916. * Gets or sets the texture scale ratio used to render content (2 by default)
  80917. */
  80918. get contentScaleRatio(): number;
  80919. set contentScaleRatio(value: number);
  80920. protected _disposeFacadeTexture(): void;
  80921. protected _resetContent(): void;
  80922. /**
  80923. * Creates a new button
  80924. * @param name defines the control name
  80925. */
  80926. constructor(name?: string);
  80927. /**
  80928. * Gets or sets the GUI 2D content used to display the button's facade
  80929. */
  80930. get content(): Control;
  80931. set content(value: Control);
  80932. /**
  80933. * Apply the facade texture (created from the content property).
  80934. * This function can be overloaded by child classes
  80935. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80936. */
  80937. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80938. protected _getTypeName(): string;
  80939. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80940. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80941. /**
  80942. * Releases all associated resources
  80943. */
  80944. dispose(): void;
  80945. }
  80946. }
  80947. declare module BABYLON.GUI {
  80948. /**
  80949. * Abstract class used to create a container panel deployed on the surface of a volume
  80950. */
  80951. export abstract class VolumeBasedPanel extends Container3D {
  80952. private _columns;
  80953. private _rows;
  80954. private _rowThenColum;
  80955. private _orientation;
  80956. protected _cellWidth: number;
  80957. protected _cellHeight: number;
  80958. /**
  80959. * Gets or sets the distance between elements
  80960. */
  80961. margin: number;
  80962. /**
  80963. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80964. * | Value | Type | Description |
  80965. * | ----- | ----------------------------------- | ----------- |
  80966. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80967. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80968. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80969. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80970. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80971. */
  80972. get orientation(): number;
  80973. set orientation(value: number);
  80974. /**
  80975. * Gets or sets the number of columns requested (10 by default).
  80976. * The panel will automatically compute the number of rows based on number of child controls.
  80977. */
  80978. get columns(): BABYLON.int;
  80979. set columns(value: BABYLON.int);
  80980. /**
  80981. * Gets or sets a the number of rows requested.
  80982. * The panel will automatically compute the number of columns based on number of child controls.
  80983. */
  80984. get rows(): BABYLON.int;
  80985. set rows(value: BABYLON.int);
  80986. /**
  80987. * Creates new VolumeBasedPanel
  80988. */
  80989. constructor();
  80990. protected _arrangeChildren(): void;
  80991. /** Child classes must implement this function to provide correct control positioning */
  80992. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80993. /** Child classes can implement this function to provide additional processing */
  80994. protected _finalProcessing(): void;
  80995. }
  80996. }
  80997. declare module BABYLON.GUI {
  80998. /**
  80999. * Class used to create a container panel deployed on the surface of a cylinder
  81000. */
  81001. export class CylinderPanel extends VolumeBasedPanel {
  81002. private _radius;
  81003. /**
  81004. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81005. */
  81006. get radius(): BABYLON.float;
  81007. set radius(value: BABYLON.float);
  81008. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81009. private _cylindricalMapping;
  81010. }
  81011. }
  81012. declare module BABYLON.GUI {
  81013. /** @hidden */
  81014. export var fluentVertexShader: {
  81015. name: string;
  81016. shader: string;
  81017. };
  81018. }
  81019. declare module BABYLON.GUI {
  81020. /** @hidden */
  81021. export var fluentPixelShader: {
  81022. name: string;
  81023. shader: string;
  81024. };
  81025. }
  81026. declare module BABYLON.GUI {
  81027. /** @hidden */
  81028. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81029. INNERGLOW: boolean;
  81030. BORDER: boolean;
  81031. HOVERLIGHT: boolean;
  81032. TEXTURE: boolean;
  81033. constructor();
  81034. }
  81035. /**
  81036. * Class used to render controls with fluent desgin
  81037. */
  81038. export class FluentMaterial extends BABYLON.PushMaterial {
  81039. /**
  81040. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81041. */
  81042. innerGlowColorIntensity: number;
  81043. /**
  81044. * Gets or sets the inner glow color (white by default)
  81045. */
  81046. innerGlowColor: BABYLON.Color3;
  81047. /**
  81048. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81049. */
  81050. albedoColor: BABYLON.Color3;
  81051. /**
  81052. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81053. */
  81054. renderBorders: boolean;
  81055. /**
  81056. * Gets or sets border width (default is 0.5)
  81057. */
  81058. borderWidth: number;
  81059. /**
  81060. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81061. */
  81062. edgeSmoothingValue: number;
  81063. /**
  81064. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81065. */
  81066. borderMinValue: number;
  81067. /**
  81068. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81069. */
  81070. renderHoverLight: boolean;
  81071. /**
  81072. * Gets or sets the radius used to render the hover light (default is 1.0)
  81073. */
  81074. hoverRadius: number;
  81075. /**
  81076. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81077. */
  81078. hoverColor: BABYLON.Color4;
  81079. /**
  81080. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81081. */
  81082. hoverPosition: BABYLON.Vector3;
  81083. private _albedoTexture;
  81084. /** Gets or sets the texture to use for albedo color */
  81085. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81086. /**
  81087. * Creates a new Fluent material
  81088. * @param name defines the name of the material
  81089. * @param scene defines the hosting scene
  81090. */
  81091. constructor(name: string, scene: BABYLON.Scene);
  81092. needAlphaBlending(): boolean;
  81093. needAlphaTesting(): boolean;
  81094. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81095. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81096. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81097. getActiveTextures(): BABYLON.BaseTexture[];
  81098. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81099. dispose(forceDisposeEffect?: boolean): void;
  81100. clone(name: string): FluentMaterial;
  81101. serialize(): any;
  81102. getClassName(): string;
  81103. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81104. }
  81105. }
  81106. declare module BABYLON.GUI {
  81107. /**
  81108. * Class used to create a holographic button in 3D
  81109. */
  81110. export class HolographicButton extends Button3D {
  81111. private _backPlate;
  81112. private _textPlate;
  81113. private _frontPlate;
  81114. private _text;
  81115. private _imageUrl;
  81116. private _shareMaterials;
  81117. private _frontMaterial;
  81118. private _backMaterial;
  81119. private _plateMaterial;
  81120. private _pickedPointObserver;
  81121. private _tooltipFade;
  81122. private _tooltipTextBlock;
  81123. private _tooltipTexture;
  81124. private _tooltipMesh;
  81125. private _tooltipHoverObserver;
  81126. private _tooltipOutObserver;
  81127. private _disposeTooltip;
  81128. /**
  81129. * Rendering ground id of all the mesh in the button
  81130. */
  81131. set renderingGroupId(id: number);
  81132. get renderingGroupId(): number;
  81133. /**
  81134. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81135. */
  81136. set tooltipText(text: BABYLON.Nullable<string>);
  81137. get tooltipText(): BABYLON.Nullable<string>;
  81138. /**
  81139. * Gets or sets text for the button
  81140. */
  81141. get text(): string;
  81142. set text(value: string);
  81143. /**
  81144. * Gets or sets the image url for the button
  81145. */
  81146. get imageUrl(): string;
  81147. set imageUrl(value: string);
  81148. /**
  81149. * Gets the back material used by this button
  81150. */
  81151. get backMaterial(): FluentMaterial;
  81152. /**
  81153. * Gets the front material used by this button
  81154. */
  81155. get frontMaterial(): FluentMaterial;
  81156. /**
  81157. * Gets the plate material used by this button
  81158. */
  81159. get plateMaterial(): BABYLON.StandardMaterial;
  81160. /**
  81161. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81162. */
  81163. get shareMaterials(): boolean;
  81164. /**
  81165. * Creates a new button
  81166. * @param name defines the control name
  81167. */
  81168. constructor(name?: string, shareMaterials?: boolean);
  81169. protected _getTypeName(): string;
  81170. private _rebuildContent;
  81171. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81172. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81173. private _createBackMaterial;
  81174. private _createFrontMaterial;
  81175. private _createPlateMaterial;
  81176. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81177. /**
  81178. * Releases all associated resources
  81179. */
  81180. dispose(): void;
  81181. }
  81182. }
  81183. declare module BABYLON.GUI {
  81184. /**
  81185. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81186. */
  81187. export class MeshButton3D extends Button3D {
  81188. /** @hidden */
  81189. protected _currentMesh: BABYLON.Mesh;
  81190. /**
  81191. * Creates a new 3D button based on a mesh
  81192. * @param mesh mesh to become a 3D button
  81193. * @param name defines the control name
  81194. */
  81195. constructor(mesh: BABYLON.Mesh, name?: string);
  81196. protected _getTypeName(): string;
  81197. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81198. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81199. }
  81200. }
  81201. declare module BABYLON.GUI {
  81202. /**
  81203. * Class used to create a container panel deployed on the surface of a plane
  81204. */
  81205. export class PlanePanel extends VolumeBasedPanel {
  81206. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81207. }
  81208. }
  81209. declare module BABYLON.GUI {
  81210. /**
  81211. * Class used to create a container panel where items get randomized planar mapping
  81212. */
  81213. export class ScatterPanel extends VolumeBasedPanel {
  81214. private _iteration;
  81215. /**
  81216. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81217. */
  81218. get iteration(): BABYLON.float;
  81219. set iteration(value: BABYLON.float);
  81220. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81221. private _scatterMapping;
  81222. protected _finalProcessing(): void;
  81223. }
  81224. }
  81225. declare module BABYLON.GUI {
  81226. /**
  81227. * Class used to create a container panel deployed on the surface of a sphere
  81228. */
  81229. export class SpherePanel extends VolumeBasedPanel {
  81230. private _radius;
  81231. /**
  81232. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81233. */
  81234. get radius(): BABYLON.float;
  81235. set radius(value: BABYLON.float);
  81236. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81237. private _sphericalMapping;
  81238. }
  81239. }
  81240. declare module BABYLON.GUI {
  81241. /**
  81242. * Class used to create a stack panel in 3D on XY plane
  81243. */
  81244. export class StackPanel3D extends Container3D {
  81245. private _isVertical;
  81246. /**
  81247. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81248. */
  81249. get isVertical(): boolean;
  81250. set isVertical(value: boolean);
  81251. /**
  81252. * Gets or sets the distance between elements
  81253. */
  81254. margin: number;
  81255. /**
  81256. * Creates new StackPanel
  81257. * @param isVertical
  81258. */
  81259. constructor(isVertical?: boolean);
  81260. protected _arrangeChildren(): void;
  81261. }
  81262. }
  81263. declare module BABYLON {
  81264. /**
  81265. * Configuration for glTF validation
  81266. */
  81267. export interface IGLTFValidationConfiguration {
  81268. /**
  81269. * The url of the glTF validator.
  81270. */
  81271. url: string;
  81272. }
  81273. /**
  81274. * glTF validation
  81275. */
  81276. export class GLTFValidation {
  81277. /**
  81278. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81279. */
  81280. static Configuration: IGLTFValidationConfiguration;
  81281. private static _LoadScriptPromise;
  81282. /**
  81283. * Validate a glTF asset using the glTF-Validator.
  81284. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81285. * @param rootUrl The root url for the glTF
  81286. * @param fileName The file name for the glTF
  81287. * @param getExternalResource The callback to get external resources for the glTF validator
  81288. * @returns A promise that resolves with the glTF validation results once complete
  81289. */
  81290. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81291. }
  81292. }
  81293. declare module BABYLON {
  81294. /**
  81295. * Mode that determines the coordinate system to use.
  81296. */
  81297. export enum GLTFLoaderCoordinateSystemMode {
  81298. /**
  81299. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81300. */
  81301. AUTO = 0,
  81302. /**
  81303. * Sets the useRightHandedSystem flag on the scene.
  81304. */
  81305. FORCE_RIGHT_HANDED = 1
  81306. }
  81307. /**
  81308. * Mode that determines what animations will start.
  81309. */
  81310. export enum GLTFLoaderAnimationStartMode {
  81311. /**
  81312. * No animation will start.
  81313. */
  81314. NONE = 0,
  81315. /**
  81316. * The first animation will start.
  81317. */
  81318. FIRST = 1,
  81319. /**
  81320. * All animations will start.
  81321. */
  81322. ALL = 2
  81323. }
  81324. /**
  81325. * Interface that contains the data for the glTF asset.
  81326. */
  81327. export interface IGLTFLoaderData {
  81328. /**
  81329. * The object that represents the glTF JSON.
  81330. */
  81331. json: Object;
  81332. /**
  81333. * The BIN chunk of a binary glTF.
  81334. */
  81335. bin: Nullable<IDataBuffer>;
  81336. }
  81337. /**
  81338. * Interface for extending the loader.
  81339. */
  81340. export interface IGLTFLoaderExtension {
  81341. /**
  81342. * The name of this extension.
  81343. */
  81344. readonly name: string;
  81345. /**
  81346. * Defines whether this extension is enabled.
  81347. */
  81348. enabled: boolean;
  81349. /**
  81350. * Defines the order of this extension.
  81351. * The loader sorts the extensions using these values when loading.
  81352. */
  81353. order?: number;
  81354. }
  81355. /**
  81356. * Loader state.
  81357. */
  81358. export enum GLTFLoaderState {
  81359. /**
  81360. * The asset is loading.
  81361. */
  81362. LOADING = 0,
  81363. /**
  81364. * The asset is ready for rendering.
  81365. */
  81366. READY = 1,
  81367. /**
  81368. * The asset is completely loaded.
  81369. */
  81370. COMPLETE = 2
  81371. }
  81372. /** @hidden */
  81373. export interface IImportMeshAsyncOutput {
  81374. meshes: AbstractMesh[];
  81375. geometries: Geometry[];
  81376. particleSystems: IParticleSystem[];
  81377. skeletons: Skeleton[];
  81378. animationGroups: AnimationGroup[];
  81379. lights: Light[];
  81380. transformNodes: TransformNode[];
  81381. }
  81382. /** @hidden */
  81383. export interface IGLTFLoader extends IDisposable {
  81384. readonly state: Nullable<GLTFLoaderState>;
  81385. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81386. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81387. }
  81388. /**
  81389. * File loader for loading glTF files into a scene.
  81390. */
  81391. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81392. /** @hidden */
  81393. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81394. /** @hidden */
  81395. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81396. /**
  81397. * Raised when the asset has been parsed
  81398. */
  81399. onParsedObservable: Observable<IGLTFLoaderData>;
  81400. private _onParsedObserver;
  81401. /**
  81402. * Raised when the asset has been parsed
  81403. */
  81404. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81405. /**
  81406. * 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.
  81407. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81408. * Defaults to true.
  81409. * @hidden
  81410. */
  81411. static IncrementalLoading: boolean;
  81412. /**
  81413. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81414. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81415. * @hidden
  81416. */
  81417. static HomogeneousCoordinates: boolean;
  81418. /**
  81419. * The coordinate system mode. Defaults to AUTO.
  81420. */
  81421. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81422. /**
  81423. * The animation start mode. Defaults to FIRST.
  81424. */
  81425. animationStartMode: GLTFLoaderAnimationStartMode;
  81426. /**
  81427. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81428. */
  81429. compileMaterials: boolean;
  81430. /**
  81431. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81432. */
  81433. useClipPlane: boolean;
  81434. /**
  81435. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81436. */
  81437. compileShadowGenerators: boolean;
  81438. /**
  81439. * Defines if the Alpha blended materials are only applied as coverage.
  81440. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81441. * If true, no extra effects are applied to transparent pixels.
  81442. */
  81443. transparencyAsCoverage: boolean;
  81444. /**
  81445. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81446. * Enabling will disable offline support and glTF validator.
  81447. * Defaults to false.
  81448. */
  81449. useRangeRequests: boolean;
  81450. /**
  81451. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81452. */
  81453. createInstances: boolean;
  81454. /**
  81455. * 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.
  81456. */
  81457. alwaysComputeBoundingBox: boolean;
  81458. /**
  81459. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81460. */
  81461. loadAllMaterials: boolean;
  81462. /**
  81463. * Function called before loading a url referenced by the asset.
  81464. */
  81465. preprocessUrlAsync: (url: string) => Promise<string>;
  81466. /**
  81467. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81468. * 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, ...)
  81469. */
  81470. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81471. private _onMeshLoadedObserver;
  81472. /**
  81473. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81474. * 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, ...)
  81475. */
  81476. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81477. /**
  81478. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81479. */
  81480. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81481. private _onTextureLoadedObserver;
  81482. /**
  81483. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81484. */
  81485. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81486. /**
  81487. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81488. */
  81489. readonly onMaterialLoadedObservable: Observable<Material>;
  81490. private _onMaterialLoadedObserver;
  81491. /**
  81492. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81493. */
  81494. set onMaterialLoaded(callback: (material: Material) => void);
  81495. /**
  81496. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81497. */
  81498. readonly onCameraLoadedObservable: Observable<Camera>;
  81499. private _onCameraLoadedObserver;
  81500. /**
  81501. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81502. */
  81503. set onCameraLoaded(callback: (camera: Camera) => void);
  81504. /**
  81505. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81506. * For assets with LODs, raised when all of the LODs are complete.
  81507. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81508. */
  81509. readonly onCompleteObservable: Observable<void>;
  81510. private _onCompleteObserver;
  81511. /**
  81512. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81513. * For assets with LODs, raised when all of the LODs are complete.
  81514. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81515. */
  81516. set onComplete(callback: () => void);
  81517. /**
  81518. * Observable raised when an error occurs.
  81519. */
  81520. readonly onErrorObservable: Observable<any>;
  81521. private _onErrorObserver;
  81522. /**
  81523. * Callback raised when an error occurs.
  81524. */
  81525. set onError(callback: (reason: any) => void);
  81526. /**
  81527. * Observable raised after the loader is disposed.
  81528. */
  81529. readonly onDisposeObservable: Observable<void>;
  81530. private _onDisposeObserver;
  81531. /**
  81532. * Callback raised after the loader is disposed.
  81533. */
  81534. set onDispose(callback: () => void);
  81535. /**
  81536. * Observable raised after a loader extension is created.
  81537. * Set additional options for a loader extension in this event.
  81538. */
  81539. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81540. private _onExtensionLoadedObserver;
  81541. /**
  81542. * Callback raised after a loader extension is created.
  81543. */
  81544. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81545. /**
  81546. * Defines if the loader logging is enabled.
  81547. */
  81548. get loggingEnabled(): boolean;
  81549. set loggingEnabled(value: boolean);
  81550. /**
  81551. * Defines if the loader should capture performance counters.
  81552. */
  81553. get capturePerformanceCounters(): boolean;
  81554. set capturePerformanceCounters(value: boolean);
  81555. /**
  81556. * Defines if the loader should validate the asset.
  81557. */
  81558. validate: boolean;
  81559. /**
  81560. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81561. */
  81562. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81563. private _onValidatedObserver;
  81564. /**
  81565. * Callback raised after a loader extension is created.
  81566. */
  81567. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81568. private _loader;
  81569. private _progressCallback?;
  81570. private _requests;
  81571. private static magicBase64Encoded;
  81572. /**
  81573. * Name of the loader ("gltf")
  81574. */
  81575. name: string;
  81576. /** @hidden */
  81577. extensions: ISceneLoaderPluginExtensions;
  81578. /**
  81579. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81580. */
  81581. dispose(): void;
  81582. /** @hidden */
  81583. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81584. /** @hidden */
  81585. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81586. /** @hidden */
  81587. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81588. meshes: AbstractMesh[];
  81589. particleSystems: IParticleSystem[];
  81590. skeletons: Skeleton[];
  81591. animationGroups: AnimationGroup[];
  81592. }>;
  81593. /** @hidden */
  81594. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81595. /** @hidden */
  81596. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81597. /** @hidden */
  81598. canDirectLoad(data: string): boolean;
  81599. /** @hidden */
  81600. directLoad(scene: Scene, data: string): Promise<any>;
  81601. /**
  81602. * The callback that allows custom handling of the root url based on the response url.
  81603. * @param rootUrl the original root url
  81604. * @param responseURL the response url if available
  81605. * @returns the new root url
  81606. */
  81607. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81608. /** @hidden */
  81609. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81610. /**
  81611. * The loader state or null if the loader is not active.
  81612. */
  81613. get loaderState(): Nullable<GLTFLoaderState>;
  81614. /**
  81615. * Returns a promise that resolves when the asset is completely loaded.
  81616. * @returns a promise that resolves when the asset is completely loaded.
  81617. */
  81618. whenCompleteAsync(): Promise<void>;
  81619. /** @hidden */
  81620. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81621. /** @hidden */
  81622. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81623. private _onProgress;
  81624. private _validate;
  81625. private _getLoader;
  81626. private _parseJson;
  81627. private _unpackBinaryAsync;
  81628. private _unpackBinaryV1Async;
  81629. private _unpackBinaryV2Async;
  81630. private static _parseVersion;
  81631. private static _compareVersion;
  81632. private static readonly _logSpaces;
  81633. private _logIndentLevel;
  81634. private _loggingEnabled;
  81635. /** @hidden */
  81636. _log: (message: string) => void;
  81637. /** @hidden */
  81638. _logOpen(message: string): void;
  81639. /** @hidden */
  81640. _logClose(): void;
  81641. private _logEnabled;
  81642. private _logDisabled;
  81643. private _capturePerformanceCounters;
  81644. /** @hidden */
  81645. _startPerformanceCounter: (counterName: string) => void;
  81646. /** @hidden */
  81647. _endPerformanceCounter: (counterName: string) => void;
  81648. private _startPerformanceCounterEnabled;
  81649. private _startPerformanceCounterDisabled;
  81650. private _endPerformanceCounterEnabled;
  81651. private _endPerformanceCounterDisabled;
  81652. }
  81653. }
  81654. declare module BABYLON.GLTF1 {
  81655. /**
  81656. * Enums
  81657. * @hidden
  81658. */
  81659. export enum EComponentType {
  81660. BYTE = 5120,
  81661. UNSIGNED_BYTE = 5121,
  81662. SHORT = 5122,
  81663. UNSIGNED_SHORT = 5123,
  81664. FLOAT = 5126
  81665. }
  81666. /** @hidden */
  81667. export enum EShaderType {
  81668. FRAGMENT = 35632,
  81669. VERTEX = 35633
  81670. }
  81671. /** @hidden */
  81672. export enum EParameterType {
  81673. BYTE = 5120,
  81674. UNSIGNED_BYTE = 5121,
  81675. SHORT = 5122,
  81676. UNSIGNED_SHORT = 5123,
  81677. INT = 5124,
  81678. UNSIGNED_INT = 5125,
  81679. FLOAT = 5126,
  81680. FLOAT_VEC2 = 35664,
  81681. FLOAT_VEC3 = 35665,
  81682. FLOAT_VEC4 = 35666,
  81683. INT_VEC2 = 35667,
  81684. INT_VEC3 = 35668,
  81685. INT_VEC4 = 35669,
  81686. BOOL = 35670,
  81687. BOOL_VEC2 = 35671,
  81688. BOOL_VEC3 = 35672,
  81689. BOOL_VEC4 = 35673,
  81690. FLOAT_MAT2 = 35674,
  81691. FLOAT_MAT3 = 35675,
  81692. FLOAT_MAT4 = 35676,
  81693. SAMPLER_2D = 35678
  81694. }
  81695. /** @hidden */
  81696. export enum ETextureWrapMode {
  81697. CLAMP_TO_EDGE = 33071,
  81698. MIRRORED_REPEAT = 33648,
  81699. REPEAT = 10497
  81700. }
  81701. /** @hidden */
  81702. export enum ETextureFilterType {
  81703. NEAREST = 9728,
  81704. LINEAR = 9728,
  81705. NEAREST_MIPMAP_NEAREST = 9984,
  81706. LINEAR_MIPMAP_NEAREST = 9985,
  81707. NEAREST_MIPMAP_LINEAR = 9986,
  81708. LINEAR_MIPMAP_LINEAR = 9987
  81709. }
  81710. /** @hidden */
  81711. export enum ETextureFormat {
  81712. ALPHA = 6406,
  81713. RGB = 6407,
  81714. RGBA = 6408,
  81715. LUMINANCE = 6409,
  81716. LUMINANCE_ALPHA = 6410
  81717. }
  81718. /** @hidden */
  81719. export enum ECullingType {
  81720. FRONT = 1028,
  81721. BACK = 1029,
  81722. FRONT_AND_BACK = 1032
  81723. }
  81724. /** @hidden */
  81725. export enum EBlendingFunction {
  81726. ZERO = 0,
  81727. ONE = 1,
  81728. SRC_COLOR = 768,
  81729. ONE_MINUS_SRC_COLOR = 769,
  81730. DST_COLOR = 774,
  81731. ONE_MINUS_DST_COLOR = 775,
  81732. SRC_ALPHA = 770,
  81733. ONE_MINUS_SRC_ALPHA = 771,
  81734. DST_ALPHA = 772,
  81735. ONE_MINUS_DST_ALPHA = 773,
  81736. CONSTANT_COLOR = 32769,
  81737. ONE_MINUS_CONSTANT_COLOR = 32770,
  81738. CONSTANT_ALPHA = 32771,
  81739. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81740. SRC_ALPHA_SATURATE = 776
  81741. }
  81742. /** @hidden */
  81743. export interface IGLTFProperty {
  81744. extensions?: {
  81745. [key: string]: any;
  81746. };
  81747. extras?: Object;
  81748. }
  81749. /** @hidden */
  81750. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81751. name?: string;
  81752. }
  81753. /** @hidden */
  81754. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81755. bufferView: string;
  81756. byteOffset: number;
  81757. byteStride: number;
  81758. count: number;
  81759. type: string;
  81760. componentType: EComponentType;
  81761. max?: number[];
  81762. min?: number[];
  81763. name?: string;
  81764. }
  81765. /** @hidden */
  81766. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81767. buffer: string;
  81768. byteOffset: number;
  81769. byteLength: number;
  81770. byteStride: number;
  81771. target?: number;
  81772. }
  81773. /** @hidden */
  81774. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81775. uri: string;
  81776. byteLength?: number;
  81777. type?: string;
  81778. }
  81779. /** @hidden */
  81780. export interface IGLTFShader extends IGLTFChildRootProperty {
  81781. uri: string;
  81782. type: EShaderType;
  81783. }
  81784. /** @hidden */
  81785. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81786. attributes: string[];
  81787. fragmentShader: string;
  81788. vertexShader: string;
  81789. }
  81790. /** @hidden */
  81791. export interface IGLTFTechniqueParameter {
  81792. type: number;
  81793. count?: number;
  81794. semantic?: string;
  81795. node?: string;
  81796. value?: number | boolean | string | Array<any>;
  81797. source?: string;
  81798. babylonValue?: any;
  81799. }
  81800. /** @hidden */
  81801. export interface IGLTFTechniqueCommonProfile {
  81802. lightingModel: string;
  81803. texcoordBindings: Object;
  81804. parameters?: Array<any>;
  81805. }
  81806. /** @hidden */
  81807. export interface IGLTFTechniqueStatesFunctions {
  81808. blendColor?: number[];
  81809. blendEquationSeparate?: number[];
  81810. blendFuncSeparate?: number[];
  81811. colorMask: boolean[];
  81812. cullFace: number[];
  81813. }
  81814. /** @hidden */
  81815. export interface IGLTFTechniqueStates {
  81816. enable: number[];
  81817. functions: IGLTFTechniqueStatesFunctions;
  81818. }
  81819. /** @hidden */
  81820. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81821. parameters: {
  81822. [key: string]: IGLTFTechniqueParameter;
  81823. };
  81824. program: string;
  81825. attributes: {
  81826. [key: string]: string;
  81827. };
  81828. uniforms: {
  81829. [key: string]: string;
  81830. };
  81831. states: IGLTFTechniqueStates;
  81832. }
  81833. /** @hidden */
  81834. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81835. technique?: string;
  81836. values: string[];
  81837. }
  81838. /** @hidden */
  81839. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81840. attributes: {
  81841. [key: string]: string;
  81842. };
  81843. indices: string;
  81844. material: string;
  81845. mode?: number;
  81846. }
  81847. /** @hidden */
  81848. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81849. primitives: IGLTFMeshPrimitive[];
  81850. }
  81851. /** @hidden */
  81852. export interface IGLTFImage extends IGLTFChildRootProperty {
  81853. uri: string;
  81854. }
  81855. /** @hidden */
  81856. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81857. magFilter?: number;
  81858. minFilter?: number;
  81859. wrapS?: number;
  81860. wrapT?: number;
  81861. }
  81862. /** @hidden */
  81863. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81864. sampler: string;
  81865. source: string;
  81866. format?: ETextureFormat;
  81867. internalFormat?: ETextureFormat;
  81868. target?: number;
  81869. type?: number;
  81870. babylonTexture?: Texture;
  81871. }
  81872. /** @hidden */
  81873. export interface IGLTFAmbienLight {
  81874. color?: number[];
  81875. }
  81876. /** @hidden */
  81877. export interface IGLTFDirectionalLight {
  81878. color?: number[];
  81879. }
  81880. /** @hidden */
  81881. export interface IGLTFPointLight {
  81882. color?: number[];
  81883. constantAttenuation?: number;
  81884. linearAttenuation?: number;
  81885. quadraticAttenuation?: number;
  81886. }
  81887. /** @hidden */
  81888. export interface IGLTFSpotLight {
  81889. color?: number[];
  81890. constantAttenuation?: number;
  81891. fallOfAngle?: number;
  81892. fallOffExponent?: number;
  81893. linearAttenuation?: number;
  81894. quadraticAttenuation?: number;
  81895. }
  81896. /** @hidden */
  81897. export interface IGLTFLight extends IGLTFChildRootProperty {
  81898. type: string;
  81899. }
  81900. /** @hidden */
  81901. export interface IGLTFCameraOrthographic {
  81902. xmag: number;
  81903. ymag: number;
  81904. zfar: number;
  81905. znear: number;
  81906. }
  81907. /** @hidden */
  81908. export interface IGLTFCameraPerspective {
  81909. aspectRatio: number;
  81910. yfov: number;
  81911. zfar: number;
  81912. znear: number;
  81913. }
  81914. /** @hidden */
  81915. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81916. type: string;
  81917. }
  81918. /** @hidden */
  81919. export interface IGLTFAnimationChannelTarget {
  81920. id: string;
  81921. path: string;
  81922. }
  81923. /** @hidden */
  81924. export interface IGLTFAnimationChannel {
  81925. sampler: string;
  81926. target: IGLTFAnimationChannelTarget;
  81927. }
  81928. /** @hidden */
  81929. export interface IGLTFAnimationSampler {
  81930. input: string;
  81931. output: string;
  81932. interpolation?: string;
  81933. }
  81934. /** @hidden */
  81935. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81936. channels?: IGLTFAnimationChannel[];
  81937. parameters?: {
  81938. [key: string]: string;
  81939. };
  81940. samplers?: {
  81941. [key: string]: IGLTFAnimationSampler;
  81942. };
  81943. }
  81944. /** @hidden */
  81945. export interface IGLTFNodeInstanceSkin {
  81946. skeletons: string[];
  81947. skin: string;
  81948. meshes: string[];
  81949. }
  81950. /** @hidden */
  81951. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81952. bindShapeMatrix: number[];
  81953. inverseBindMatrices: string;
  81954. jointNames: string[];
  81955. babylonSkeleton?: Skeleton;
  81956. }
  81957. /** @hidden */
  81958. export interface IGLTFNode extends IGLTFChildRootProperty {
  81959. camera?: string;
  81960. children: string[];
  81961. skin?: string;
  81962. jointName?: string;
  81963. light?: string;
  81964. matrix: number[];
  81965. mesh?: string;
  81966. meshes?: string[];
  81967. rotation?: number[];
  81968. scale?: number[];
  81969. translation?: number[];
  81970. babylonNode?: Node;
  81971. }
  81972. /** @hidden */
  81973. export interface IGLTFScene extends IGLTFChildRootProperty {
  81974. nodes: string[];
  81975. }
  81976. /** @hidden */
  81977. export interface IGLTFRuntime {
  81978. extensions: {
  81979. [key: string]: any;
  81980. };
  81981. accessors: {
  81982. [key: string]: IGLTFAccessor;
  81983. };
  81984. buffers: {
  81985. [key: string]: IGLTFBuffer;
  81986. };
  81987. bufferViews: {
  81988. [key: string]: IGLTFBufferView;
  81989. };
  81990. meshes: {
  81991. [key: string]: IGLTFMesh;
  81992. };
  81993. lights: {
  81994. [key: string]: IGLTFLight;
  81995. };
  81996. cameras: {
  81997. [key: string]: IGLTFCamera;
  81998. };
  81999. nodes: {
  82000. [key: string]: IGLTFNode;
  82001. };
  82002. images: {
  82003. [key: string]: IGLTFImage;
  82004. };
  82005. textures: {
  82006. [key: string]: IGLTFTexture;
  82007. };
  82008. shaders: {
  82009. [key: string]: IGLTFShader;
  82010. };
  82011. programs: {
  82012. [key: string]: IGLTFProgram;
  82013. };
  82014. samplers: {
  82015. [key: string]: IGLTFSampler;
  82016. };
  82017. techniques: {
  82018. [key: string]: IGLTFTechnique;
  82019. };
  82020. materials: {
  82021. [key: string]: IGLTFMaterial;
  82022. };
  82023. animations: {
  82024. [key: string]: IGLTFAnimation;
  82025. };
  82026. skins: {
  82027. [key: string]: IGLTFSkins;
  82028. };
  82029. currentScene?: Object;
  82030. scenes: {
  82031. [key: string]: IGLTFScene;
  82032. };
  82033. extensionsUsed: string[];
  82034. extensionsRequired?: string[];
  82035. buffersCount: number;
  82036. shaderscount: number;
  82037. scene: Scene;
  82038. rootUrl: string;
  82039. loadedBufferCount: number;
  82040. loadedBufferViews: {
  82041. [name: string]: ArrayBufferView;
  82042. };
  82043. loadedShaderCount: number;
  82044. importOnlyMeshes: boolean;
  82045. importMeshesNames?: string[];
  82046. dummyNodes: Node[];
  82047. forAssetContainer: boolean;
  82048. }
  82049. /** @hidden */
  82050. export interface INodeToRoot {
  82051. bone: Bone;
  82052. node: IGLTFNode;
  82053. id: string;
  82054. }
  82055. /** @hidden */
  82056. export interface IJointNode {
  82057. node: IGLTFNode;
  82058. id: string;
  82059. }
  82060. }
  82061. declare module BABYLON.GLTF1 {
  82062. /**
  82063. * Utils functions for GLTF
  82064. * @hidden
  82065. */
  82066. export class GLTFUtils {
  82067. /**
  82068. * Sets the given "parameter" matrix
  82069. * @param scene: the Scene object
  82070. * @param source: the source node where to pick the matrix
  82071. * @param parameter: the GLTF technique parameter
  82072. * @param uniformName: the name of the shader's uniform
  82073. * @param shaderMaterial: the shader material
  82074. */
  82075. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82076. /**
  82077. * Sets the given "parameter" matrix
  82078. * @param shaderMaterial: the shader material
  82079. * @param uniform: the name of the shader's uniform
  82080. * @param value: the value of the uniform
  82081. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82082. */
  82083. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82084. /**
  82085. * Returns the wrap mode of the texture
  82086. * @param mode: the mode value
  82087. */
  82088. static GetWrapMode(mode: number): number;
  82089. /**
  82090. * Returns the byte stride giving an accessor
  82091. * @param accessor: the GLTF accessor objet
  82092. */
  82093. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82094. /**
  82095. * Returns the texture filter mode giving a mode value
  82096. * @param mode: the filter mode value
  82097. */
  82098. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82099. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82100. /**
  82101. * Returns a buffer from its accessor
  82102. * @param gltfRuntime: the GLTF runtime
  82103. * @param accessor: the GLTF accessor
  82104. */
  82105. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82106. /**
  82107. * Decodes a buffer view into a string
  82108. * @param view: the buffer view
  82109. */
  82110. static DecodeBufferToText(view: ArrayBufferView): string;
  82111. /**
  82112. * Returns the default material of gltf. Related to
  82113. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82114. * @param scene: the Babylon.js scene
  82115. */
  82116. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82117. private static _DefaultMaterial;
  82118. }
  82119. }
  82120. declare module BABYLON.GLTF1 {
  82121. /**
  82122. * Implementation of the base glTF spec
  82123. * @hidden
  82124. */
  82125. export class GLTFLoaderBase {
  82126. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82127. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82128. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82129. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82130. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82131. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82132. }
  82133. /**
  82134. * glTF V1 Loader
  82135. * @hidden
  82136. */
  82137. export class GLTFLoader implements IGLTFLoader {
  82138. static Extensions: {
  82139. [name: string]: GLTFLoaderExtension;
  82140. };
  82141. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82142. state: Nullable<GLTFLoaderState>;
  82143. dispose(): void;
  82144. private _importMeshAsync;
  82145. /**
  82146. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82147. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82148. * @param scene the scene the meshes should be added to
  82149. * @param forAssetContainer defines if the entities must be stored in the scene
  82150. * @param data gltf data containing information of the meshes in a loaded file
  82151. * @param rootUrl root url to load from
  82152. * @param onProgress event that fires when loading progress has occured
  82153. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82154. */
  82155. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82156. private _loadAsync;
  82157. /**
  82158. * Imports all objects from a loaded gltf file and adds them to the scene
  82159. * @param scene the scene the objects should be added to
  82160. * @param data gltf data containing information of the meshes in a loaded file
  82161. * @param rootUrl root url to load from
  82162. * @param onProgress event that fires when loading progress has occured
  82163. * @returns a promise which completes when objects have been loaded to the scene
  82164. */
  82165. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82166. private _loadShadersAsync;
  82167. private _loadBuffersAsync;
  82168. private _createNodes;
  82169. }
  82170. /** @hidden */
  82171. export abstract class GLTFLoaderExtension {
  82172. private _name;
  82173. constructor(name: string);
  82174. get name(): string;
  82175. /**
  82176. * Defines an override for loading the runtime
  82177. * Return true to stop further extensions from loading the runtime
  82178. */
  82179. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82180. /**
  82181. * Defines an onverride for creating gltf runtime
  82182. * Return true to stop further extensions from creating the runtime
  82183. */
  82184. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82185. /**
  82186. * Defines an override for loading buffers
  82187. * Return true to stop further extensions from loading this buffer
  82188. */
  82189. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82190. /**
  82191. * Defines an override for loading texture buffers
  82192. * Return true to stop further extensions from loading this texture data
  82193. */
  82194. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82195. /**
  82196. * Defines an override for creating textures
  82197. * Return true to stop further extensions from loading this texture
  82198. */
  82199. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82200. /**
  82201. * Defines an override for loading shader strings
  82202. * Return true to stop further extensions from loading this shader data
  82203. */
  82204. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82205. /**
  82206. * Defines an override for loading materials
  82207. * Return true to stop further extensions from loading this material
  82208. */
  82209. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82210. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82211. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82212. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82213. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82214. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82215. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82216. private static LoadTextureBufferAsync;
  82217. private static CreateTextureAsync;
  82218. private static ApplyExtensions;
  82219. }
  82220. }
  82221. declare module BABYLON.GLTF1 {
  82222. /** @hidden */
  82223. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82224. private _bin;
  82225. constructor();
  82226. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82227. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82228. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82229. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82230. }
  82231. }
  82232. declare module BABYLON.GLTF1 {
  82233. /** @hidden */
  82234. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82235. constructor();
  82236. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82237. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82238. private _loadTexture;
  82239. }
  82240. }
  82241. declare module BABYLON.GLTF2.Loader {
  82242. /**
  82243. * Loader interface with an index field.
  82244. */
  82245. export interface IArrayItem {
  82246. /**
  82247. * The index of this item in the array.
  82248. */
  82249. index: number;
  82250. }
  82251. /**
  82252. * Loader interface with additional members.
  82253. */
  82254. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82255. /** @hidden */
  82256. _data?: Promise<ArrayBufferView>;
  82257. /** @hidden */
  82258. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82259. }
  82260. /**
  82261. * Loader interface with additional members.
  82262. */
  82263. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82264. }
  82265. /** @hidden */
  82266. export interface _IAnimationSamplerData {
  82267. input: Float32Array;
  82268. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82269. output: Float32Array;
  82270. }
  82271. /**
  82272. * Loader interface with additional members.
  82273. */
  82274. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82275. /** @hidden */
  82276. _data?: Promise<_IAnimationSamplerData>;
  82277. }
  82278. /**
  82279. * Loader interface with additional members.
  82280. */
  82281. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82282. channels: IAnimationChannel[];
  82283. samplers: IAnimationSampler[];
  82284. /** @hidden */
  82285. _babylonAnimationGroup?: AnimationGroup;
  82286. }
  82287. /**
  82288. * Loader interface with additional members.
  82289. */
  82290. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82291. /** @hidden */
  82292. _data?: Promise<ArrayBufferView>;
  82293. }
  82294. /**
  82295. * Loader interface with additional members.
  82296. */
  82297. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82298. /** @hidden */
  82299. _data?: Promise<ArrayBufferView>;
  82300. /** @hidden */
  82301. _babylonBuffer?: Promise<Buffer>;
  82302. }
  82303. /**
  82304. * Loader interface with additional members.
  82305. */
  82306. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82307. }
  82308. /**
  82309. * Loader interface with additional members.
  82310. */
  82311. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82312. /** @hidden */
  82313. _data?: Promise<ArrayBufferView>;
  82314. }
  82315. /**
  82316. * Loader interface with additional members.
  82317. */
  82318. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82319. }
  82320. /**
  82321. * Loader interface with additional members.
  82322. */
  82323. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82324. }
  82325. /**
  82326. * Loader interface with additional members.
  82327. */
  82328. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82329. baseColorTexture?: ITextureInfo;
  82330. metallicRoughnessTexture?: ITextureInfo;
  82331. }
  82332. /**
  82333. * Loader interface with additional members.
  82334. */
  82335. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82336. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82337. normalTexture?: IMaterialNormalTextureInfo;
  82338. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82339. emissiveTexture?: ITextureInfo;
  82340. /** @hidden */
  82341. _data?: {
  82342. [babylonDrawMode: number]: {
  82343. babylonMaterial: Material;
  82344. babylonMeshes: AbstractMesh[];
  82345. promise: Promise<void>;
  82346. };
  82347. };
  82348. }
  82349. /**
  82350. * Loader interface with additional members.
  82351. */
  82352. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82353. primitives: IMeshPrimitive[];
  82354. }
  82355. /**
  82356. * Loader interface with additional members.
  82357. */
  82358. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82359. /** @hidden */
  82360. _instanceData?: {
  82361. babylonSourceMesh: Mesh;
  82362. promise: Promise<any>;
  82363. };
  82364. }
  82365. /**
  82366. * Loader interface with additional members.
  82367. */
  82368. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82369. /**
  82370. * The parent glTF node.
  82371. */
  82372. parent?: INode;
  82373. /** @hidden */
  82374. _babylonTransformNode?: TransformNode;
  82375. /** @hidden */
  82376. _primitiveBabylonMeshes?: AbstractMesh[];
  82377. /** @hidden */
  82378. _babylonBones?: Bone[];
  82379. /** @hidden */
  82380. _numMorphTargets?: number;
  82381. }
  82382. /** @hidden */
  82383. export interface _ISamplerData {
  82384. noMipMaps: boolean;
  82385. samplingMode: number;
  82386. wrapU: number;
  82387. wrapV: number;
  82388. }
  82389. /**
  82390. * Loader interface with additional members.
  82391. */
  82392. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82393. /** @hidden */
  82394. _data?: _ISamplerData;
  82395. }
  82396. /**
  82397. * Loader interface with additional members.
  82398. */
  82399. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82400. }
  82401. /**
  82402. * Loader interface with additional members.
  82403. */
  82404. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82405. /** @hidden */
  82406. _data?: {
  82407. babylonSkeleton: Skeleton;
  82408. promise: Promise<void>;
  82409. };
  82410. }
  82411. /**
  82412. * Loader interface with additional members.
  82413. */
  82414. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82415. }
  82416. /**
  82417. * Loader interface with additional members.
  82418. */
  82419. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82420. }
  82421. /**
  82422. * Loader interface with additional members.
  82423. */
  82424. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82425. accessors?: IAccessor[];
  82426. animations?: IAnimation[];
  82427. buffers?: IBuffer[];
  82428. bufferViews?: IBufferView[];
  82429. cameras?: ICamera[];
  82430. images?: IImage[];
  82431. materials?: IMaterial[];
  82432. meshes?: IMesh[];
  82433. nodes?: INode[];
  82434. samplers?: ISampler[];
  82435. scenes?: IScene[];
  82436. skins?: ISkin[];
  82437. textures?: ITexture[];
  82438. }
  82439. }
  82440. declare module BABYLON.GLTF2 {
  82441. /**
  82442. * Interface for a glTF loader extension.
  82443. */
  82444. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82445. /**
  82446. * Called after the loader state changes to LOADING.
  82447. */
  82448. onLoading?(): void;
  82449. /**
  82450. * Called after the loader state changes to READY.
  82451. */
  82452. onReady?(): void;
  82453. /**
  82454. * Define this method to modify the default behavior when loading scenes.
  82455. * @param context The context when loading the asset
  82456. * @param scene The glTF scene property
  82457. * @returns A promise that resolves when the load is complete or null if not handled
  82458. */
  82459. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82460. /**
  82461. * Define this method to modify the default behavior when loading nodes.
  82462. * @param context The context when loading the asset
  82463. * @param node The glTF node property
  82464. * @param assign A function called synchronously after parsing the glTF properties
  82465. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82466. */
  82467. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82468. /**
  82469. * Define this method to modify the default behavior when loading cameras.
  82470. * @param context The context when loading the asset
  82471. * @param camera The glTF camera property
  82472. * @param assign A function called synchronously after parsing the glTF properties
  82473. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82474. */
  82475. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82476. /**
  82477. * @hidden
  82478. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82479. * @param context The context when loading the asset
  82480. * @param primitive The glTF mesh primitive property
  82481. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82482. */
  82483. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82484. /**
  82485. * @hidden
  82486. * Define this method to modify the default behavior when loading data for mesh primitives.
  82487. * @param context The context when loading the asset
  82488. * @param name The mesh name when loading the asset
  82489. * @param node The glTF node when loading the asset
  82490. * @param mesh The glTF mesh when loading the asset
  82491. * @param primitive The glTF mesh primitive property
  82492. * @param assign A function called synchronously after parsing the glTF properties
  82493. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82494. */
  82495. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82496. /**
  82497. * @hidden
  82498. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82499. * @param context The context when loading the asset
  82500. * @param material The glTF material property
  82501. * @param assign A function called synchronously after parsing the glTF properties
  82502. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82503. */
  82504. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82505. /**
  82506. * Define this method to modify the default behavior when creating materials.
  82507. * @param context The context when loading the asset
  82508. * @param material The glTF material property
  82509. * @param babylonDrawMode The draw mode for the Babylon material
  82510. * @returns The Babylon material or null if not handled
  82511. */
  82512. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82513. /**
  82514. * Define this method to modify the default behavior when loading material properties.
  82515. * @param context The context when loading the asset
  82516. * @param material The glTF material property
  82517. * @param babylonMaterial The Babylon material
  82518. * @returns A promise that resolves when the load is complete or null if not handled
  82519. */
  82520. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82521. /**
  82522. * Define this method to modify the default behavior when loading texture infos.
  82523. * @param context The context when loading the asset
  82524. * @param textureInfo The glTF texture info property
  82525. * @param assign A function called synchronously after parsing the glTF properties
  82526. * @param isColorData true if the texture held color data, else false
  82527. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82528. */
  82529. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void, isColorData: boolean): Nullable<Promise<BaseTexture>>;
  82530. /**
  82531. * @hidden
  82532. * Define this method to modify the default behavior when loading textures.
  82533. * @param context The context when loading the asset
  82534. * @param texture The glTF texture property
  82535. * @param assign A function called synchronously after parsing the glTF properties
  82536. * @param isColorData true if the texture held color data, else false
  82537. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82538. */
  82539. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void, isColorData: boolean): Nullable<Promise<BaseTexture>>;
  82540. /**
  82541. * Define this method to modify the default behavior when loading animations.
  82542. * @param context The context when loading the asset
  82543. * @param animation The glTF animation property
  82544. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82545. */
  82546. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82547. /**
  82548. * @hidden
  82549. * Define this method to modify the default behavior when loading skins.
  82550. * @param context The context when loading the asset
  82551. * @param node The glTF node property
  82552. * @param skin The glTF skin property
  82553. * @returns A promise that resolves when the load is complete or null if not handled
  82554. */
  82555. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82556. /**
  82557. * @hidden
  82558. * Define this method to modify the default behavior when loading uris.
  82559. * @param context The context when loading the asset
  82560. * @param property The glTF property associated with the uri
  82561. * @param uri The uri to load
  82562. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82563. */
  82564. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82565. /**
  82566. * Define this method to modify the default behavior when loading buffer views.
  82567. * @param context The context when loading the asset
  82568. * @param bufferView The glTF buffer view property
  82569. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82570. */
  82571. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82572. /**
  82573. * Define this method to modify the default behavior when loading buffers.
  82574. * @param context The context when loading the asset
  82575. * @param buffer The glTF buffer property
  82576. * @param byteOffset The byte offset to load
  82577. * @param byteLength The byte length to load
  82578. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82579. */
  82580. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82581. }
  82582. }
  82583. declare module BABYLON.GLTF2 {
  82584. /**
  82585. * Helper class for working with arrays when loading the glTF asset
  82586. */
  82587. export class ArrayItem {
  82588. /**
  82589. * Gets an item from the given array.
  82590. * @param context The context when loading the asset
  82591. * @param array The array to get the item from
  82592. * @param index The index to the array
  82593. * @returns The array item
  82594. */
  82595. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82596. /**
  82597. * Assign an `index` field to each item of the given array.
  82598. * @param array The array of items
  82599. */
  82600. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82601. }
  82602. /**
  82603. * The glTF 2.0 loader
  82604. */
  82605. export class GLTFLoader implements IGLTFLoader {
  82606. /** @hidden */
  82607. _completePromises: Promise<any>[];
  82608. /** @hidden */
  82609. _forAssetContainer: boolean;
  82610. /** Storage */
  82611. _babylonLights: Light[];
  82612. /** @hidden */
  82613. _disableInstancedMesh: number;
  82614. private _disposed;
  82615. private _parent;
  82616. private _state;
  82617. private _extensions;
  82618. private _rootUrl;
  82619. private _fileName;
  82620. private _uniqueRootUrl;
  82621. private _gltf;
  82622. private _bin;
  82623. private _babylonScene;
  82624. private _rootBabylonMesh;
  82625. private _defaultBabylonMaterialData;
  82626. private static _RegisteredExtensions;
  82627. /**
  82628. * The default glTF sampler.
  82629. */
  82630. static readonly DefaultSampler: ISampler;
  82631. /**
  82632. * Registers a loader extension.
  82633. * @param name The name of the loader extension.
  82634. * @param factory The factory function that creates the loader extension.
  82635. */
  82636. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82637. /**
  82638. * Unregisters a loader extension.
  82639. * @param name The name of the loader extension.
  82640. * @returns A boolean indicating whether the extension has been unregistered
  82641. */
  82642. static UnregisterExtension(name: string): boolean;
  82643. /**
  82644. * The loader state.
  82645. */
  82646. get state(): Nullable<GLTFLoaderState>;
  82647. /**
  82648. * The object that represents the glTF JSON.
  82649. */
  82650. get gltf(): IGLTF;
  82651. /**
  82652. * The BIN chunk of a binary glTF.
  82653. */
  82654. get bin(): Nullable<IDataBuffer>;
  82655. /**
  82656. * The parent file loader.
  82657. */
  82658. get parent(): GLTFFileLoader;
  82659. /**
  82660. * The Babylon scene when loading the asset.
  82661. */
  82662. get babylonScene(): Scene;
  82663. /**
  82664. * The root Babylon mesh when loading the asset.
  82665. */
  82666. get rootBabylonMesh(): Mesh;
  82667. /** @hidden */
  82668. constructor(parent: GLTFFileLoader);
  82669. /** @hidden */
  82670. dispose(): void;
  82671. /** @hidden */
  82672. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82673. /** @hidden */
  82674. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82675. private _loadAsync;
  82676. private _loadData;
  82677. private _setupData;
  82678. private _loadExtensions;
  82679. private _checkExtensions;
  82680. private _setState;
  82681. private _createRootNode;
  82682. /**
  82683. * Loads a glTF scene.
  82684. * @param context The context when loading the asset
  82685. * @param scene The glTF scene property
  82686. * @returns A promise that resolves when the load is complete
  82687. */
  82688. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82689. private _forEachPrimitive;
  82690. private _getGeometries;
  82691. private _getMeshes;
  82692. private _getTransformNodes;
  82693. private _getSkeletons;
  82694. private _getAnimationGroups;
  82695. private _startAnimations;
  82696. /**
  82697. * Loads a glTF node.
  82698. * @param context The context when loading the asset
  82699. * @param node The glTF node property
  82700. * @param assign A function called synchronously after parsing the glTF properties
  82701. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82702. */
  82703. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82704. private _loadMeshAsync;
  82705. /**
  82706. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82707. * @param context The context when loading the asset
  82708. * @param name The mesh name when loading the asset
  82709. * @param node The glTF node when loading the asset
  82710. * @param mesh The glTF mesh when loading the asset
  82711. * @param primitive The glTF mesh primitive property
  82712. * @param assign A function called synchronously after parsing the glTF properties
  82713. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82714. */
  82715. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82716. private _loadVertexDataAsync;
  82717. private _createMorphTargets;
  82718. private _loadMorphTargetsAsync;
  82719. private _loadMorphTargetVertexDataAsync;
  82720. private static _LoadTransform;
  82721. private _loadSkinAsync;
  82722. private _loadBones;
  82723. private _loadBone;
  82724. private _loadSkinInverseBindMatricesDataAsync;
  82725. private _updateBoneMatrices;
  82726. private _getNodeMatrix;
  82727. /**
  82728. * Loads a glTF camera.
  82729. * @param context The context when loading the asset
  82730. * @param camera The glTF camera property
  82731. * @param assign A function called synchronously after parsing the glTF properties
  82732. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82733. */
  82734. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82735. private _loadAnimationsAsync;
  82736. /**
  82737. * Loads a glTF animation.
  82738. * @param context The context when loading the asset
  82739. * @param animation The glTF animation property
  82740. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82741. */
  82742. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82743. /**
  82744. * @hidden Loads a glTF animation channel.
  82745. * @param context The context when loading the asset
  82746. * @param animationContext The context of the animation when loading the asset
  82747. * @param animation The glTF animation property
  82748. * @param channel The glTF animation channel property
  82749. * @param babylonAnimationGroup The babylon animation group property
  82750. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82751. * @returns A void promise when the channel load is complete
  82752. */
  82753. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82754. private _loadAnimationSamplerAsync;
  82755. private _loadBufferAsync;
  82756. /**
  82757. * Loads a glTF buffer view.
  82758. * @param context The context when loading the asset
  82759. * @param bufferView The glTF buffer view property
  82760. * @returns A promise that resolves with the loaded data when the load is complete
  82761. */
  82762. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82763. private _loadAccessorAsync;
  82764. /** @hidden */
  82765. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82766. private _loadIndicesAccessorAsync;
  82767. private _loadVertexBufferViewAsync;
  82768. private _loadVertexAccessorAsync;
  82769. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82770. /** @hidden */
  82771. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82772. private _createDefaultMaterial;
  82773. /**
  82774. * Creates a Babylon material from a glTF material.
  82775. * @param context The context when loading the asset
  82776. * @param material The glTF material property
  82777. * @param babylonDrawMode The draw mode for the Babylon material
  82778. * @returns The Babylon material
  82779. */
  82780. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82781. /**
  82782. * Loads properties from a glTF material into a Babylon material.
  82783. * @param context The context when loading the asset
  82784. * @param material The glTF material property
  82785. * @param babylonMaterial The Babylon material
  82786. * @returns A promise that resolves when the load is complete
  82787. */
  82788. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82789. /**
  82790. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82791. * @param context The context when loading the asset
  82792. * @param material The glTF material property
  82793. * @param babylonMaterial The Babylon material
  82794. * @returns A promise that resolves when the load is complete
  82795. */
  82796. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82797. /**
  82798. * Loads the alpha properties from a glTF material into a Babylon material.
  82799. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82800. * @param context The context when loading the asset
  82801. * @param material The glTF material property
  82802. * @param babylonMaterial The Babylon material
  82803. */
  82804. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82805. /**
  82806. * Loads a glTF texture info.
  82807. * @param context The context when loading the asset
  82808. * @param textureInfo The glTF texture info property
  82809. * @param assign A function called synchronously after parsing the glTF properties
  82810. * @param isColorData true if the texture held color data, else false
  82811. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82812. */
  82813. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void, isColorData?: boolean): Promise<BaseTexture>;
  82814. /** @hidden */
  82815. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void, isColorData?: boolean): Promise<BaseTexture>;
  82816. /** @hidden */
  82817. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  82818. private _loadSampler;
  82819. /**
  82820. * Loads a glTF image.
  82821. * @param context The context when loading the asset
  82822. * @param image The glTF image property
  82823. * @returns A promise that resolves with the loaded data when the load is complete
  82824. */
  82825. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82826. /**
  82827. * Loads a glTF uri.
  82828. * @param context The context when loading the asset
  82829. * @param property The glTF property associated with the uri
  82830. * @param uri The base64 or relative uri
  82831. * @returns A promise that resolves with the loaded data when the load is complete
  82832. */
  82833. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82834. /**
  82835. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82836. * @param babylonObject the Babylon object with metadata
  82837. * @param pointer the JSON pointer
  82838. */
  82839. static AddPointerMetadata(babylonObject: {
  82840. metadata: any;
  82841. }, pointer: string): void;
  82842. private static _GetTextureWrapMode;
  82843. private static _GetTextureSamplingMode;
  82844. private static _GetTypedArrayConstructor;
  82845. private static _GetTypedArray;
  82846. private static _GetNumComponents;
  82847. private static _ValidateUri;
  82848. /** @hidden */
  82849. static _GetDrawMode(context: string, mode: number | undefined): number;
  82850. private _compileMaterialsAsync;
  82851. private _compileShadowGeneratorsAsync;
  82852. private _forEachExtensions;
  82853. private _applyExtensions;
  82854. private _extensionsOnLoading;
  82855. private _extensionsOnReady;
  82856. private _extensionsLoadSceneAsync;
  82857. private _extensionsLoadNodeAsync;
  82858. private _extensionsLoadCameraAsync;
  82859. private _extensionsLoadVertexDataAsync;
  82860. private _extensionsLoadMeshPrimitiveAsync;
  82861. private _extensionsLoadMaterialAsync;
  82862. private _extensionsCreateMaterial;
  82863. private _extensionsLoadMaterialPropertiesAsync;
  82864. private _extensionsLoadTextureInfoAsync;
  82865. private _extensionsLoadTextureAsync;
  82866. private _extensionsLoadAnimationAsync;
  82867. private _extensionsLoadSkinAsync;
  82868. private _extensionsLoadUriAsync;
  82869. private _extensionsLoadBufferViewAsync;
  82870. private _extensionsLoadBufferAsync;
  82871. /**
  82872. * Helper method called by a loader extension to load an glTF extension.
  82873. * @param context The context when loading the asset
  82874. * @param property The glTF property to load the extension from
  82875. * @param extensionName The name of the extension to load
  82876. * @param actionAsync The action to run
  82877. * @returns The promise returned by actionAsync or null if the extension does not exist
  82878. */
  82879. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82880. /**
  82881. * Helper method called by a loader extension to load a glTF extra.
  82882. * @param context The context when loading the asset
  82883. * @param property The glTF property to load the extra from
  82884. * @param extensionName The name of the extension to load
  82885. * @param actionAsync The action to run
  82886. * @returns The promise returned by actionAsync or null if the extra does not exist
  82887. */
  82888. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82889. /**
  82890. * Checks for presence of an extension.
  82891. * @param name The name of the extension to check
  82892. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82893. */
  82894. isExtensionUsed(name: string): boolean;
  82895. /**
  82896. * Increments the indentation level and logs a message.
  82897. * @param message The message to log
  82898. */
  82899. logOpen(message: string): void;
  82900. /**
  82901. * Decrements the indentation level.
  82902. */
  82903. logClose(): void;
  82904. /**
  82905. * Logs a message
  82906. * @param message The message to log
  82907. */
  82908. log(message: string): void;
  82909. /**
  82910. * Starts a performance counter.
  82911. * @param counterName The name of the performance counter
  82912. */
  82913. startPerformanceCounter(counterName: string): void;
  82914. /**
  82915. * Ends a performance counter.
  82916. * @param counterName The name of the performance counter
  82917. */
  82918. endPerformanceCounter(counterName: string): void;
  82919. }
  82920. }
  82921. declare module BABYLON.GLTF2.Loader.Extensions {
  82922. /** @hidden */
  82923. interface IEXTLightsImageBased_LightImageBased {
  82924. _babylonTexture?: BaseTexture;
  82925. _loaded?: Promise<void>;
  82926. }
  82927. /**
  82928. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82929. */
  82930. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82931. /**
  82932. * The name of this extension.
  82933. */
  82934. readonly name: string;
  82935. /**
  82936. * Defines whether this extension is enabled.
  82937. */
  82938. enabled: boolean;
  82939. private _loader;
  82940. private _lights?;
  82941. /** @hidden */
  82942. constructor(loader: GLTFLoader);
  82943. /** @hidden */
  82944. dispose(): void;
  82945. /** @hidden */
  82946. onLoading(): void;
  82947. /** @hidden */
  82948. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82949. private _loadLightAsync;
  82950. }
  82951. }
  82952. declare module BABYLON.GLTF2.Loader.Extensions {
  82953. /**
  82954. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82955. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82956. * !!! Experimental Extension Subject to Changes !!!
  82957. */
  82958. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82959. /**
  82960. * The name of this extension.
  82961. */
  82962. readonly name: string;
  82963. /**
  82964. * Defines whether this extension is enabled.
  82965. */
  82966. enabled: boolean;
  82967. private _loader;
  82968. /** @hidden */
  82969. constructor(loader: GLTFLoader);
  82970. /** @hidden */
  82971. dispose(): void;
  82972. /** @hidden */
  82973. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82974. }
  82975. }
  82976. declare module BABYLON.GLTF2.Loader.Extensions {
  82977. /**
  82978. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82979. */
  82980. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82981. /** The name of this extension. */
  82982. readonly name: string;
  82983. /** Defines whether this extension is enabled. */
  82984. enabled: boolean;
  82985. private _loader;
  82986. /** @hidden */
  82987. constructor(loader: GLTFLoader);
  82988. /** @hidden */
  82989. dispose(): void;
  82990. /** @hidden */
  82991. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82992. }
  82993. }
  82994. declare module BABYLON.GLTF2.Loader.Extensions {
  82995. /**
  82996. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82997. */
  82998. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82999. /**
  83000. * The name of this extension.
  83001. */
  83002. readonly name: string;
  83003. /**
  83004. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83005. */
  83006. dracoCompression?: DracoCompression;
  83007. /**
  83008. * Defines whether this extension is enabled.
  83009. */
  83010. enabled: boolean;
  83011. private _loader;
  83012. /** @hidden */
  83013. constructor(loader: GLTFLoader);
  83014. /** @hidden */
  83015. dispose(): void;
  83016. /** @hidden */
  83017. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83018. }
  83019. }
  83020. declare module BABYLON.GLTF2.Loader.Extensions {
  83021. /**
  83022. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83023. */
  83024. export class KHR_lights implements IGLTFLoaderExtension {
  83025. /**
  83026. * The name of this extension.
  83027. */
  83028. readonly name: string;
  83029. /**
  83030. * Defines whether this extension is enabled.
  83031. */
  83032. enabled: boolean;
  83033. private _loader;
  83034. private _lights?;
  83035. /** @hidden */
  83036. constructor(loader: GLTFLoader);
  83037. /** @hidden */
  83038. dispose(): void;
  83039. /** @hidden */
  83040. onLoading(): void;
  83041. /** @hidden */
  83042. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83043. }
  83044. }
  83045. declare module BABYLON.GLTF2.Loader.Extensions {
  83046. /**
  83047. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83048. */
  83049. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83050. /**
  83051. * The name of this extension.
  83052. */
  83053. readonly name: string;
  83054. /**
  83055. * Defines whether this extension is enabled.
  83056. */
  83057. enabled: boolean;
  83058. /**
  83059. * Defines a number that determines the order the extensions are applied.
  83060. */
  83061. order: number;
  83062. private _loader;
  83063. /** @hidden */
  83064. constructor(loader: GLTFLoader);
  83065. /** @hidden */
  83066. dispose(): void;
  83067. /** @hidden */
  83068. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83069. private _loadSpecularGlossinessPropertiesAsync;
  83070. }
  83071. }
  83072. declare module BABYLON.GLTF2.Loader.Extensions {
  83073. /**
  83074. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83075. */
  83076. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83077. /**
  83078. * The name of this extension.
  83079. */
  83080. readonly name: string;
  83081. /**
  83082. * Defines whether this extension is enabled.
  83083. */
  83084. enabled: boolean;
  83085. /**
  83086. * Defines a number that determines the order the extensions are applied.
  83087. */
  83088. order: number;
  83089. private _loader;
  83090. /** @hidden */
  83091. constructor(loader: GLTFLoader);
  83092. /** @hidden */
  83093. dispose(): void;
  83094. /** @hidden */
  83095. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83096. private _loadUnlitPropertiesAsync;
  83097. }
  83098. }
  83099. declare module BABYLON.GLTF2.Loader.Extensions {
  83100. /**
  83101. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83102. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83103. */
  83104. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83105. /**
  83106. * The name of this extension.
  83107. */
  83108. readonly name: string;
  83109. /**
  83110. * Defines whether this extension is enabled.
  83111. */
  83112. enabled: boolean;
  83113. /**
  83114. * Defines a number that determines the order the extensions are applied.
  83115. */
  83116. order: number;
  83117. private _loader;
  83118. /** @hidden */
  83119. constructor(loader: GLTFLoader);
  83120. /** @hidden */
  83121. dispose(): void;
  83122. /** @hidden */
  83123. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83124. private _loadClearCoatPropertiesAsync;
  83125. }
  83126. }
  83127. declare module BABYLON.GLTF2.Loader.Extensions {
  83128. /**
  83129. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83130. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83131. * !!! Experimental Extension Subject to Changes !!!
  83132. */
  83133. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83134. /**
  83135. * The name of this extension.
  83136. */
  83137. readonly name: string;
  83138. /**
  83139. * Defines whether this extension is enabled.
  83140. */
  83141. enabled: boolean;
  83142. /**
  83143. * Defines a number that determines the order the extensions are applied.
  83144. */
  83145. order: number;
  83146. private _loader;
  83147. /** @hidden */
  83148. constructor(loader: GLTFLoader);
  83149. /** @hidden */
  83150. dispose(): void;
  83151. /** @hidden */
  83152. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83153. private _loadSheenPropertiesAsync;
  83154. }
  83155. }
  83156. declare module BABYLON.GLTF2.Loader.Extensions {
  83157. /**
  83158. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83159. * !!! Experimental Extension Subject to Changes !!!
  83160. */
  83161. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83162. /**
  83163. * The name of this extension.
  83164. */
  83165. readonly name: string;
  83166. /**
  83167. * Defines whether this extension is enabled.
  83168. */
  83169. enabled: boolean;
  83170. /**
  83171. * Defines a number that determines the order the extensions are applied.
  83172. */
  83173. order: number;
  83174. private _loader;
  83175. /** @hidden */
  83176. constructor(loader: GLTFLoader);
  83177. /** @hidden */
  83178. dispose(): void;
  83179. /** @hidden */
  83180. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83181. private _loadSpecularPropertiesAsync;
  83182. }
  83183. }
  83184. declare module BABYLON.GLTF2.Loader.Extensions {
  83185. /**
  83186. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83187. * !!! Experimental Extension Subject to Changes !!!
  83188. */
  83189. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83190. /**
  83191. * Default ior Value from the spec.
  83192. */
  83193. private static readonly _DEFAULT_IOR;
  83194. /**
  83195. * The name of this extension.
  83196. */
  83197. readonly name: string;
  83198. /**
  83199. * Defines whether this extension is enabled.
  83200. */
  83201. enabled: boolean;
  83202. /**
  83203. * Defines a number that determines the order the extensions are applied.
  83204. */
  83205. order: number;
  83206. private _loader;
  83207. /** @hidden */
  83208. constructor(loader: GLTFLoader);
  83209. /** @hidden */
  83210. dispose(): void;
  83211. /** @hidden */
  83212. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83213. private _loadIorPropertiesAsync;
  83214. }
  83215. }
  83216. declare module BABYLON.GLTF2.Loader.Extensions {
  83217. /**
  83218. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83219. * !!! Experimental Extension Subject to Changes !!!
  83220. */
  83221. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83222. /**
  83223. * The name of this extension.
  83224. */
  83225. readonly name: string;
  83226. /**
  83227. * Defines whether this extension is enabled.
  83228. */
  83229. enabled: boolean;
  83230. private _loader;
  83231. private _variants?;
  83232. /** @hidden */
  83233. constructor(loader: GLTFLoader);
  83234. /** @hidden */
  83235. dispose(): void;
  83236. /**
  83237. * Gets the list of available variant names for this asset.
  83238. * @param rootMesh The glTF root mesh
  83239. * @returns the list of all the variant names for this model
  83240. */
  83241. static GetAvailableVariants(rootMesh: Mesh): string[];
  83242. /**
  83243. * Gets the list of available variant names for this asset.
  83244. * @param rootMesh The glTF root mesh
  83245. * @returns the list of all the variant names for this model
  83246. */
  83247. getAvailableVariants(rootMesh: Mesh): string[];
  83248. /**
  83249. * Select a variant given a variant name or a list of variant names.
  83250. * @param rootMesh The glTF root mesh
  83251. * @param variantName The variant name(s) to select.
  83252. */
  83253. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83254. /**
  83255. * Select a variant given a variant name or a list of variant names.
  83256. * @param rootMesh The glTF root mesh
  83257. * @param variantName The variant name(s) to select.
  83258. */
  83259. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83260. /**
  83261. * Reset back to the original before selecting a variant.
  83262. * @param rootMesh The glTF root mesh
  83263. */
  83264. static Reset(rootMesh: Mesh): void;
  83265. /**
  83266. * Reset back to the original before selecting a variant.
  83267. * @param rootMesh The glTF root mesh
  83268. */
  83269. reset(rootMesh: Mesh): void;
  83270. /**
  83271. * Gets the last selected variant name(s) or null if original.
  83272. * @param rootMesh The glTF root mesh
  83273. * @returns The selected variant name(s).
  83274. */
  83275. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83276. /**
  83277. * Gets the last selected variant name(s) or null if original.
  83278. * @param rootMesh The glTF root mesh
  83279. * @returns The selected variant name(s).
  83280. */
  83281. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83282. private static _GetExtensionMetadata;
  83283. /** @hidden */
  83284. onLoading(): void;
  83285. /** @hidden */
  83286. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83287. }
  83288. }
  83289. declare module BABYLON.GLTF2.Loader.Extensions {
  83290. /**
  83291. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83292. * !!! Experimental Extension Subject to Changes !!!
  83293. */
  83294. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83295. /**
  83296. * The name of this extension.
  83297. */
  83298. readonly name: string;
  83299. /**
  83300. * Defines whether this extension is enabled.
  83301. */
  83302. enabled: boolean;
  83303. /**
  83304. * Defines a number that determines the order the extensions are applied.
  83305. */
  83306. order: number;
  83307. private _loader;
  83308. /** @hidden */
  83309. constructor(loader: GLTFLoader);
  83310. /** @hidden */
  83311. dispose(): void;
  83312. /** @hidden */
  83313. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83314. private _loadTransparentPropertiesAsync;
  83315. }
  83316. }
  83317. declare module BABYLON.GLTF2.Loader.Extensions {
  83318. /**
  83319. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83320. */
  83321. export class KHR_mesh_quantization 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. /** @hidden */
  83331. constructor(loader: GLTFLoader);
  83332. /** @hidden */
  83333. dispose(): void;
  83334. }
  83335. }
  83336. declare module BABYLON.GLTF2.Loader.Extensions {
  83337. /**
  83338. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83339. * !!! Experimental Extension Subject to Changes !!!
  83340. */
  83341. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83342. /** The name of this extension. */
  83343. readonly name: string;
  83344. /** Defines whether this extension is enabled. */
  83345. enabled: boolean;
  83346. private _loader;
  83347. /** @hidden */
  83348. constructor(loader: GLTFLoader);
  83349. /** @hidden */
  83350. dispose(): void;
  83351. /** @hidden */
  83352. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void, isColorData?: boolean): Nullable<Promise<BaseTexture>>;
  83353. }
  83354. }
  83355. declare module BABYLON.GLTF2.Loader.Extensions {
  83356. /**
  83357. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83358. */
  83359. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83360. /**
  83361. * The name of this extension.
  83362. */
  83363. readonly name: string;
  83364. /**
  83365. * Defines whether this extension is enabled.
  83366. */
  83367. enabled: boolean;
  83368. private _loader;
  83369. /** @hidden */
  83370. constructor(loader: GLTFLoader);
  83371. /** @hidden */
  83372. dispose(): void;
  83373. /** @hidden */
  83374. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void, isColorData?: boolean): Nullable<Promise<BaseTexture>>;
  83375. }
  83376. }
  83377. declare module BABYLON.GLTF2.Loader.Extensions {
  83378. /**
  83379. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83380. * !!! Experimental Extension Subject to Changes !!!
  83381. */
  83382. export class KHR_xmp implements IGLTFLoaderExtension {
  83383. /**
  83384. * The name of this extension.
  83385. */
  83386. readonly name: string;
  83387. /**
  83388. * Defines whether this extension is enabled.
  83389. */
  83390. enabled: boolean;
  83391. /**
  83392. * Defines a number that determines the order the extensions are applied.
  83393. */
  83394. order: number;
  83395. private _loader;
  83396. /** @hidden */
  83397. constructor(loader: GLTFLoader);
  83398. /** @hidden */
  83399. dispose(): void;
  83400. /**
  83401. * Called after the loader state changes to LOADING.
  83402. */
  83403. onLoading(): void;
  83404. }
  83405. }
  83406. declare module BABYLON.GLTF2.Loader.Extensions {
  83407. /**
  83408. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83409. */
  83410. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83411. /**
  83412. * The name of this extension.
  83413. */
  83414. readonly name: string;
  83415. /**
  83416. * Defines whether this extension is enabled.
  83417. */
  83418. enabled: boolean;
  83419. private _loader;
  83420. private _clips;
  83421. private _emitters;
  83422. /** @hidden */
  83423. constructor(loader: GLTFLoader);
  83424. /** @hidden */
  83425. dispose(): void;
  83426. /** @hidden */
  83427. onLoading(): void;
  83428. /** @hidden */
  83429. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83430. /** @hidden */
  83431. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83432. /** @hidden */
  83433. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83434. private _loadClipAsync;
  83435. private _loadEmitterAsync;
  83436. private _getEventAction;
  83437. private _loadAnimationEventAsync;
  83438. }
  83439. }
  83440. declare module BABYLON.GLTF2.Loader.Extensions {
  83441. /**
  83442. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83443. */
  83444. export class MSFT_lod implements IGLTFLoaderExtension {
  83445. /**
  83446. * The name of this extension.
  83447. */
  83448. readonly name: string;
  83449. /**
  83450. * Defines whether this extension is enabled.
  83451. */
  83452. enabled: boolean;
  83453. /**
  83454. * Defines a number that determines the order the extensions are applied.
  83455. */
  83456. order: number;
  83457. /**
  83458. * Maximum number of LODs to load, starting from the lowest LOD.
  83459. */
  83460. maxLODsToLoad: number;
  83461. /**
  83462. * Observable raised when all node LODs of one level are loaded.
  83463. * The event data is the index of the loaded LOD starting from zero.
  83464. * Dispose the loader to cancel the loading of the next level of LODs.
  83465. */
  83466. onNodeLODsLoadedObservable: Observable<number>;
  83467. /**
  83468. * Observable raised when all material LODs of one level are loaded.
  83469. * The event data is the index of the loaded LOD starting from zero.
  83470. * Dispose the loader to cancel the loading of the next level of LODs.
  83471. */
  83472. onMaterialLODsLoadedObservable: Observable<number>;
  83473. private _loader;
  83474. private _bufferLODs;
  83475. private _nodeIndexLOD;
  83476. private _nodeSignalLODs;
  83477. private _nodePromiseLODs;
  83478. private _nodeBufferLODs;
  83479. private _materialIndexLOD;
  83480. private _materialSignalLODs;
  83481. private _materialPromiseLODs;
  83482. private _materialBufferLODs;
  83483. /** @hidden */
  83484. constructor(loader: GLTFLoader);
  83485. /** @hidden */
  83486. dispose(): void;
  83487. /** @hidden */
  83488. onReady(): void;
  83489. /** @hidden */
  83490. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83491. /** @hidden */
  83492. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83493. /** @hidden */
  83494. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83495. /** @hidden */
  83496. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83497. /** @hidden */
  83498. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83499. private _loadBufferLOD;
  83500. /**
  83501. * Gets an array of LOD properties from lowest to highest.
  83502. */
  83503. private _getLODs;
  83504. private _disposeTransformNode;
  83505. private _disposeMaterials;
  83506. }
  83507. }
  83508. declare module BABYLON.GLTF2.Loader.Extensions {
  83509. /** @hidden */
  83510. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83511. readonly name: string;
  83512. enabled: boolean;
  83513. private _loader;
  83514. constructor(loader: GLTFLoader);
  83515. dispose(): void;
  83516. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83517. }
  83518. }
  83519. declare module BABYLON.GLTF2.Loader.Extensions {
  83520. /** @hidden */
  83521. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83522. readonly name: string;
  83523. enabled: boolean;
  83524. private _loader;
  83525. constructor(loader: GLTFLoader);
  83526. dispose(): void;
  83527. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83528. }
  83529. }
  83530. declare module BABYLON.GLTF2.Loader.Extensions {
  83531. /**
  83532. * Store glTF extras (if present) in BJS objects' metadata
  83533. */
  83534. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83535. /**
  83536. * The name of this extension.
  83537. */
  83538. readonly name: string;
  83539. /**
  83540. * Defines whether this extension is enabled.
  83541. */
  83542. enabled: boolean;
  83543. private _loader;
  83544. private _assignExtras;
  83545. /** @hidden */
  83546. constructor(loader: GLTFLoader);
  83547. /** @hidden */
  83548. dispose(): void;
  83549. /** @hidden */
  83550. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83551. /** @hidden */
  83552. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83553. /** @hidden */
  83554. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83555. }
  83556. }
  83557. declare module BABYLON {
  83558. /**
  83559. * Class reading and parsing the MTL file bundled with the obj file.
  83560. */
  83561. export class MTLFileLoader {
  83562. /**
  83563. * Invert Y-Axis of referenced textures on load
  83564. */
  83565. static INVERT_TEXTURE_Y: boolean;
  83566. /**
  83567. * All material loaded from the mtl will be set here
  83568. */
  83569. materials: StandardMaterial[];
  83570. /**
  83571. * This function will read the mtl file and create each material described inside
  83572. * This function could be improve by adding :
  83573. * -some component missing (Ni, Tf...)
  83574. * -including the specific options available
  83575. *
  83576. * @param scene defines the scene the material will be created in
  83577. * @param data defines the mtl data to parse
  83578. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83579. * @param forAssetContainer defines if the material should be registered in the scene
  83580. */
  83581. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83582. /**
  83583. * Gets the texture for the material.
  83584. *
  83585. * If the material is imported from input file,
  83586. * We sanitize the url to ensure it takes the textre from aside the material.
  83587. *
  83588. * @param rootUrl The root url to load from
  83589. * @param value The value stored in the mtl
  83590. * @return The Texture
  83591. */
  83592. private static _getTexture;
  83593. }
  83594. }
  83595. declare module BABYLON {
  83596. /**
  83597. * Options for loading OBJ/MTL files
  83598. */
  83599. type MeshLoadOptions = {
  83600. /**
  83601. * Defines if UVs are optimized by default during load.
  83602. */
  83603. OptimizeWithUV: boolean;
  83604. /**
  83605. * Defines custom scaling of UV coordinates of loaded meshes.
  83606. */
  83607. UVScaling: Vector2;
  83608. /**
  83609. * Invert model on y-axis (does a model scaling inversion)
  83610. */
  83611. InvertY: boolean;
  83612. /**
  83613. * Invert Y-Axis of referenced textures on load
  83614. */
  83615. InvertTextureY: boolean;
  83616. /**
  83617. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83618. */
  83619. ImportVertexColors: boolean;
  83620. /**
  83621. * Compute the normals for the model, even if normals are present in the file.
  83622. */
  83623. ComputeNormals: boolean;
  83624. /**
  83625. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83626. */
  83627. SkipMaterials: boolean;
  83628. /**
  83629. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83630. */
  83631. MaterialLoadingFailsSilently: boolean;
  83632. };
  83633. /**
  83634. * OBJ file type loader.
  83635. * This is a babylon scene loader plugin.
  83636. */
  83637. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83638. /**
  83639. * Defines if UVs are optimized by default during load.
  83640. */
  83641. static OPTIMIZE_WITH_UV: boolean;
  83642. /**
  83643. * Invert model on y-axis (does a model scaling inversion)
  83644. */
  83645. static INVERT_Y: boolean;
  83646. /**
  83647. * Invert Y-Axis of referenced textures on load
  83648. */
  83649. static get INVERT_TEXTURE_Y(): boolean;
  83650. static set INVERT_TEXTURE_Y(value: boolean);
  83651. /**
  83652. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83653. */
  83654. static IMPORT_VERTEX_COLORS: boolean;
  83655. /**
  83656. * Compute the normals for the model, even if normals are present in the file.
  83657. */
  83658. static COMPUTE_NORMALS: boolean;
  83659. /**
  83660. * Defines custom scaling of UV coordinates of loaded meshes.
  83661. */
  83662. static UV_SCALING: Vector2;
  83663. /**
  83664. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83665. */
  83666. static SKIP_MATERIALS: boolean;
  83667. /**
  83668. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83669. *
  83670. * Defaults to true for backwards compatibility.
  83671. */
  83672. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83673. /**
  83674. * Defines the name of the plugin.
  83675. */
  83676. name: string;
  83677. /**
  83678. * Defines the extension the plugin is able to load.
  83679. */
  83680. extensions: string;
  83681. /** @hidden */
  83682. obj: RegExp;
  83683. /** @hidden */
  83684. group: RegExp;
  83685. /** @hidden */
  83686. mtllib: RegExp;
  83687. /** @hidden */
  83688. usemtl: RegExp;
  83689. /** @hidden */
  83690. smooth: RegExp;
  83691. /** @hidden */
  83692. vertexPattern: RegExp;
  83693. /** @hidden */
  83694. normalPattern: RegExp;
  83695. /** @hidden */
  83696. uvPattern: RegExp;
  83697. /** @hidden */
  83698. facePattern1: RegExp;
  83699. /** @hidden */
  83700. facePattern2: RegExp;
  83701. /** @hidden */
  83702. facePattern3: RegExp;
  83703. /** @hidden */
  83704. facePattern4: RegExp;
  83705. /** @hidden */
  83706. facePattern5: RegExp;
  83707. private _forAssetContainer;
  83708. private _meshLoadOptions;
  83709. /**
  83710. * Creates loader for .OBJ files
  83711. *
  83712. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83713. */
  83714. constructor(meshLoadOptions?: MeshLoadOptions);
  83715. private static get currentMeshLoadOptions();
  83716. /**
  83717. * Calls synchronously the MTL file attached to this obj.
  83718. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83719. * Without this function materials are not displayed in the first frame (but displayed after).
  83720. * In consequence it is impossible to get material information in your HTML file
  83721. *
  83722. * @param url The URL of the MTL file
  83723. * @param rootUrl
  83724. * @param onSuccess Callback function to be called when the MTL file is loaded
  83725. * @private
  83726. */
  83727. private _loadMTL;
  83728. /**
  83729. * Instantiates a OBJ file loader plugin.
  83730. * @returns the created plugin
  83731. */
  83732. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83733. /**
  83734. * If the data string can be loaded directly.
  83735. *
  83736. * @param data string containing the file data
  83737. * @returns if the data can be loaded directly
  83738. */
  83739. canDirectLoad(data: string): boolean;
  83740. /**
  83741. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83742. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83743. * @param scene the scene the meshes should be added to
  83744. * @param data the OBJ data to load
  83745. * @param rootUrl root url to load from
  83746. * @param onProgress event that fires when loading progress has occured
  83747. * @param fileName Defines the name of the file to load
  83748. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83749. */
  83750. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83751. meshes: AbstractMesh[];
  83752. particleSystems: IParticleSystem[];
  83753. skeletons: Skeleton[];
  83754. animationGroups: AnimationGroup[];
  83755. }>;
  83756. /**
  83757. * Imports all objects from the loaded OBJ data and adds them to the scene
  83758. * @param scene the scene the objects should be added to
  83759. * @param data the OBJ data to load
  83760. * @param rootUrl root url to load from
  83761. * @param onProgress event that fires when loading progress has occured
  83762. * @param fileName Defines the name of the file to load
  83763. * @returns a promise which completes when objects have been loaded to the scene
  83764. */
  83765. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83766. /**
  83767. * Load into an asset container.
  83768. * @param scene The scene to load into
  83769. * @param data The data to import
  83770. * @param rootUrl The root url for scene and resources
  83771. * @param onProgress The callback when the load progresses
  83772. * @param fileName Defines the name of the file to load
  83773. * @returns The loaded asset container
  83774. */
  83775. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83776. /**
  83777. * Read the OBJ file and create an Array of meshes.
  83778. * Each mesh contains all information given by the OBJ and the MTL file.
  83779. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83780. *
  83781. * @param meshesNames
  83782. * @param scene Scene The scene where are displayed the data
  83783. * @param data String The content of the obj file
  83784. * @param rootUrl String The path to the folder
  83785. * @returns Array<AbstractMesh>
  83786. * @private
  83787. */
  83788. private _parseSolid;
  83789. }
  83790. }
  83791. declare module BABYLON {
  83792. /**
  83793. * STL file type loader.
  83794. * This is a babylon scene loader plugin.
  83795. */
  83796. export class STLFileLoader implements ISceneLoaderPlugin {
  83797. /** @hidden */
  83798. solidPattern: RegExp;
  83799. /** @hidden */
  83800. facetsPattern: RegExp;
  83801. /** @hidden */
  83802. normalPattern: RegExp;
  83803. /** @hidden */
  83804. vertexPattern: RegExp;
  83805. /**
  83806. * Defines the name of the plugin.
  83807. */
  83808. name: string;
  83809. /**
  83810. * Defines the extensions the stl loader is able to load.
  83811. * force data to come in as an ArrayBuffer
  83812. * we'll convert to string if it looks like it's an ASCII .stl
  83813. */
  83814. extensions: ISceneLoaderPluginExtensions;
  83815. /**
  83816. * Import meshes into a scene.
  83817. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83818. * @param scene The scene to import into
  83819. * @param data The data to import
  83820. * @param rootUrl The root url for scene and resources
  83821. * @param meshes The meshes array to import into
  83822. * @param particleSystems The particle systems array to import into
  83823. * @param skeletons The skeletons array to import into
  83824. * @param onError The callback when import fails
  83825. * @returns True if successful or false otherwise
  83826. */
  83827. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83828. /**
  83829. * Load into a scene.
  83830. * @param scene The scene to load into
  83831. * @param data The data to import
  83832. * @param rootUrl The root url for scene and resources
  83833. * @param onError The callback when import fails
  83834. * @returns true if successful or false otherwise
  83835. */
  83836. load(scene: Scene, data: any, rootUrl: string): boolean;
  83837. /**
  83838. * Load into an asset container.
  83839. * @param scene The scene to load into
  83840. * @param data The data to import
  83841. * @param rootUrl The root url for scene and resources
  83842. * @param onError The callback when import fails
  83843. * @returns The loaded asset container
  83844. */
  83845. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83846. private _isBinary;
  83847. private _parseBinary;
  83848. private _parseASCII;
  83849. }
  83850. }
  83851. declare module BABYLON {
  83852. /**
  83853. * Class for generating OBJ data from a Babylon scene.
  83854. */
  83855. export class OBJExport {
  83856. /**
  83857. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83858. * @param mesh defines the list of meshes to serialize
  83859. * @param materials defines if materials should be exported
  83860. * @param matlibname defines the name of the associated mtl file
  83861. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83862. * @returns the OBJ content
  83863. */
  83864. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83865. /**
  83866. * Exports the material(s) of a mesh in .MTL file format (text)
  83867. * @param mesh defines the mesh to extract the material from
  83868. * @returns the mtl content
  83869. */
  83870. static MTL(mesh: Mesh): string;
  83871. }
  83872. }
  83873. declare module BABYLON {
  83874. /** @hidden */
  83875. export var __IGLTFExporterExtension: number;
  83876. /**
  83877. * Interface for extending the exporter
  83878. * @hidden
  83879. */
  83880. export interface IGLTFExporterExtension {
  83881. /**
  83882. * The name of this extension
  83883. */
  83884. readonly name: string;
  83885. /**
  83886. * Defines whether this extension is enabled
  83887. */
  83888. enabled: boolean;
  83889. /**
  83890. * Defines whether this extension is required
  83891. */
  83892. required: boolean;
  83893. }
  83894. }
  83895. declare module BABYLON.GLTF2.Exporter {
  83896. /** @hidden */
  83897. export var __IGLTFExporterExtensionV2: number;
  83898. /**
  83899. * Interface for a glTF exporter extension
  83900. * @hidden
  83901. */
  83902. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83903. /**
  83904. * Define this method to modify the default behavior before exporting a texture
  83905. * @param context The context when loading the asset
  83906. * @param babylonTexture The Babylon.js texture
  83907. * @param mimeType The mime-type of the generated image
  83908. * @returns A promise that resolves with the exported texture
  83909. */
  83910. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83911. /**
  83912. * Define this method to get notified when a texture info is created
  83913. * @param context The context when loading the asset
  83914. * @param textureInfo The glTF texture info
  83915. * @param babylonTexture The Babylon.js texture
  83916. */
  83917. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83918. /**
  83919. * Define this method to modify the default behavior when exporting texture info
  83920. * @param context The context when loading the asset
  83921. * @param meshPrimitive glTF mesh primitive
  83922. * @param babylonSubMesh Babylon submesh
  83923. * @param binaryWriter glTF serializer binary writer instance
  83924. * @returns nullable IMeshPrimitive promise
  83925. */
  83926. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83927. /**
  83928. * Define this method to modify the default behavior when exporting a node
  83929. * @param context The context when exporting the node
  83930. * @param node glTF node
  83931. * @param babylonNode BabylonJS node
  83932. * @returns nullable INode promise
  83933. */
  83934. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83935. [key: number]: number;
  83936. }): Promise<Nullable<INode>>;
  83937. /**
  83938. * Define this method to modify the default behavior when exporting a material
  83939. * @param material glTF material
  83940. * @param babylonMaterial BabylonJS material
  83941. * @returns nullable IMaterial promise
  83942. */
  83943. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83944. /**
  83945. * Define this method to return additional textures to export from a material
  83946. * @param material glTF material
  83947. * @param babylonMaterial BabylonJS material
  83948. * @returns List of textures
  83949. */
  83950. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83951. /** Gets a boolean indicating that this extension was used */
  83952. wasUsed: boolean;
  83953. /** Gets a boolean indicating that this extension is required for the file to work */
  83954. required: boolean;
  83955. /**
  83956. * Called after the exporter state changes to EXPORTING
  83957. */
  83958. onExporting?(): void;
  83959. }
  83960. }
  83961. declare module BABYLON.GLTF2.Exporter {
  83962. /**
  83963. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83964. * @hidden
  83965. */
  83966. export class _GLTFMaterialExporter {
  83967. /**
  83968. * Represents the dielectric specular values for R, G and B
  83969. */
  83970. private static readonly _DielectricSpecular;
  83971. /**
  83972. * Allows the maximum specular power to be defined for material calculations
  83973. */
  83974. private static readonly _MaxSpecularPower;
  83975. /**
  83976. * Mapping to store textures
  83977. */
  83978. private _textureMap;
  83979. /**
  83980. * Numeric tolerance value
  83981. */
  83982. private static readonly _Epsilon;
  83983. /**
  83984. * Reference to the glTF Exporter
  83985. */
  83986. private _exporter;
  83987. constructor(exporter: _Exporter);
  83988. /**
  83989. * Specifies if two colors are approximately equal in value
  83990. * @param color1 first color to compare to
  83991. * @param color2 second color to compare to
  83992. * @param epsilon threshold value
  83993. */
  83994. private static FuzzyEquals;
  83995. /**
  83996. * Gets the materials from a Babylon scene and converts them to glTF materials
  83997. * @param scene babylonjs scene
  83998. * @param mimeType texture mime type
  83999. * @param images array of images
  84000. * @param textures array of textures
  84001. * @param materials array of materials
  84002. * @param imageData mapping of texture names to base64 textures
  84003. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84004. */
  84005. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84006. /**
  84007. * Makes a copy of the glTF material without the texture parameters
  84008. * @param originalMaterial original glTF material
  84009. * @returns glTF material without texture parameters
  84010. */
  84011. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84012. /**
  84013. * Specifies if the material has any texture parameters present
  84014. * @param material glTF Material
  84015. * @returns boolean specifying if texture parameters are present
  84016. */
  84017. _hasTexturesPresent(material: IMaterial): boolean;
  84018. /**
  84019. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84020. * @param babylonStandardMaterial
  84021. * @returns glTF Metallic Roughness Material representation
  84022. */
  84023. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84024. /**
  84025. * Computes the metallic factor
  84026. * @param diffuse diffused value
  84027. * @param specular specular value
  84028. * @param oneMinusSpecularStrength one minus the specular strength
  84029. * @returns metallic value
  84030. */
  84031. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84032. /**
  84033. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84034. * @param glTFMaterial glTF material
  84035. * @param babylonMaterial Babylon material
  84036. */
  84037. private static _SetAlphaMode;
  84038. /**
  84039. * Converts a Babylon Standard Material to a glTF Material
  84040. * @param babylonStandardMaterial BJS Standard Material
  84041. * @param mimeType mime type to use for the textures
  84042. * @param images array of glTF image interfaces
  84043. * @param textures array of glTF texture interfaces
  84044. * @param materials array of glTF material interfaces
  84045. * @param imageData map of image file name to data
  84046. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84047. */
  84048. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84049. private _finishMaterial;
  84050. /**
  84051. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84052. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84053. * @param mimeType mime type to use for the textures
  84054. * @param images array of glTF image interfaces
  84055. * @param textures array of glTF texture interfaces
  84056. * @param materials array of glTF material interfaces
  84057. * @param imageData map of image file name to data
  84058. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84059. */
  84060. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84061. /**
  84062. * Converts an image typed array buffer to a base64 image
  84063. * @param buffer typed array buffer
  84064. * @param width width of the image
  84065. * @param height height of the image
  84066. * @param mimeType mimetype of the image
  84067. * @returns base64 image string
  84068. */
  84069. private _createBase64FromCanvasAsync;
  84070. /**
  84071. * Generates a white texture based on the specified width and height
  84072. * @param width width of the texture in pixels
  84073. * @param height height of the texture in pixels
  84074. * @param scene babylonjs scene
  84075. * @returns white texture
  84076. */
  84077. private _createWhiteTexture;
  84078. /**
  84079. * 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
  84080. * @param texture1 first texture to resize
  84081. * @param texture2 second texture to resize
  84082. * @param scene babylonjs scene
  84083. * @returns resized textures or null
  84084. */
  84085. private _resizeTexturesToSameDimensions;
  84086. /**
  84087. * Converts an array of pixels to a Float32Array
  84088. * Throws an error if the pixel format is not supported
  84089. * @param pixels - array buffer containing pixel values
  84090. * @returns Float32 of pixels
  84091. */
  84092. private _convertPixelArrayToFloat32;
  84093. /**
  84094. * Convert Specular Glossiness Textures to Metallic Roughness
  84095. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84096. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84097. * @param diffuseTexture texture used to store diffuse information
  84098. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84099. * @param factors specular glossiness material factors
  84100. * @param mimeType the mime type to use for the texture
  84101. * @returns pbr metallic roughness interface or null
  84102. */
  84103. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84104. /**
  84105. * Converts specular glossiness material properties to metallic roughness
  84106. * @param specularGlossiness interface with specular glossiness material properties
  84107. * @returns interface with metallic roughness material properties
  84108. */
  84109. private _convertSpecularGlossinessToMetallicRoughness;
  84110. /**
  84111. * Calculates the surface reflectance, independent of lighting conditions
  84112. * @param color Color source to calculate brightness from
  84113. * @returns number representing the perceived brightness, or zero if color is undefined
  84114. */
  84115. private _getPerceivedBrightness;
  84116. /**
  84117. * Returns the maximum color component value
  84118. * @param color
  84119. * @returns maximum color component value, or zero if color is null or undefined
  84120. */
  84121. private _getMaxComponent;
  84122. /**
  84123. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84124. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84125. * @param mimeType mime type to use for the textures
  84126. * @param images array of glTF image interfaces
  84127. * @param textures array of glTF texture interfaces
  84128. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84129. * @param imageData map of image file name to data
  84130. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84131. * @returns glTF PBR Metallic Roughness factors
  84132. */
  84133. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84134. private _getGLTFTextureSampler;
  84135. private _getGLTFTextureWrapMode;
  84136. private _getGLTFTextureWrapModesSampler;
  84137. /**
  84138. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84139. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84140. * @param mimeType mime type to use for the textures
  84141. * @param images array of glTF image interfaces
  84142. * @param textures array of glTF texture interfaces
  84143. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84144. * @param imageData map of image file name to data
  84145. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84146. * @returns glTF PBR Metallic Roughness factors
  84147. */
  84148. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84149. /**
  84150. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84151. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84152. * @param mimeType mime type to use for the textures
  84153. * @param images array of glTF image interfaces
  84154. * @param textures array of glTF texture interfaces
  84155. * @param materials array of glTF material interfaces
  84156. * @param imageData map of image file name to data
  84157. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84158. */
  84159. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84160. private setMetallicRoughnessPbrMaterial;
  84161. private getPixelsFromTexture;
  84162. /**
  84163. * Extracts a texture from a Babylon texture into file data and glTF data
  84164. * @param babylonTexture Babylon texture to extract
  84165. * @param mimeType Mime Type of the babylonTexture
  84166. * @return glTF texture info, or null if the texture format is not supported
  84167. */
  84168. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84169. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84170. /**
  84171. * Builds a texture from base64 string
  84172. * @param base64Texture base64 texture string
  84173. * @param baseTextureName Name to use for the texture
  84174. * @param mimeType image mime type for the texture
  84175. * @param images array of images
  84176. * @param textures array of textures
  84177. * @param imageData map of image data
  84178. * @returns glTF texture info, or null if the texture format is not supported
  84179. */
  84180. private _getTextureInfoFromBase64;
  84181. }
  84182. }
  84183. declare module BABYLON {
  84184. /**
  84185. * Class for holding and downloading glTF file data
  84186. */
  84187. export class GLTFData {
  84188. /**
  84189. * Object which contains the file name as the key and its data as the value
  84190. */
  84191. glTFFiles: {
  84192. [fileName: string]: string | Blob;
  84193. };
  84194. /**
  84195. * Initializes the glTF file object
  84196. */
  84197. constructor();
  84198. /**
  84199. * Downloads the glTF data as files based on their names and data
  84200. */
  84201. downloadFiles(): void;
  84202. }
  84203. }
  84204. declare module BABYLON {
  84205. /**
  84206. * Holds a collection of exporter options and parameters
  84207. */
  84208. export interface IExportOptions {
  84209. /**
  84210. * Function which indicates whether a babylon node should be exported or not
  84211. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84212. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84213. */
  84214. shouldExportNode?(node: Node): boolean;
  84215. /**
  84216. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84217. * @param metadata source metadata to read from
  84218. * @returns the data to store to glTF node extras
  84219. */
  84220. metadataSelector?(metadata: any): any;
  84221. /**
  84222. * The sample rate to bake animation curves
  84223. */
  84224. animationSampleRate?: number;
  84225. /**
  84226. * Begin serialization without waiting for the scene to be ready
  84227. */
  84228. exportWithoutWaitingForScene?: boolean;
  84229. /**
  84230. * Indicates if coordinate system swapping root nodes should be included in export
  84231. */
  84232. includeCoordinateSystemConversionNodes?: boolean;
  84233. }
  84234. /**
  84235. * Class for generating glTF data from a Babylon scene.
  84236. */
  84237. export class GLTF2Export {
  84238. /**
  84239. * Exports the geometry of the scene to .gltf file format asynchronously
  84240. * @param scene Babylon scene with scene hierarchy information
  84241. * @param filePrefix File prefix to use when generating the glTF file
  84242. * @param options Exporter options
  84243. * @returns Returns an object with a .gltf file and associates texture names
  84244. * as keys and their data and paths as values
  84245. */
  84246. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84247. private static _PreExportAsync;
  84248. private static _PostExportAsync;
  84249. /**
  84250. * Exports the geometry of the scene to .glb file format asychronously
  84251. * @param scene Babylon scene with scene hierarchy information
  84252. * @param filePrefix File prefix to use when generating glb file
  84253. * @param options Exporter options
  84254. * @returns Returns an object with a .glb filename as key and data as value
  84255. */
  84256. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84257. }
  84258. }
  84259. declare module BABYLON.GLTF2.Exporter {
  84260. /**
  84261. * @hidden
  84262. */
  84263. export class _GLTFUtilities {
  84264. /**
  84265. * Creates a buffer view based on the supplied arguments
  84266. * @param bufferIndex index value of the specified buffer
  84267. * @param byteOffset byte offset value
  84268. * @param byteLength byte length of the bufferView
  84269. * @param byteStride byte distance between conequential elements
  84270. * @param name name of the buffer view
  84271. * @returns bufferView for glTF
  84272. */
  84273. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84274. /**
  84275. * Creates an accessor based on the supplied arguments
  84276. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84277. * @param name The name of the accessor
  84278. * @param type The type of the accessor
  84279. * @param componentType The datatype of components in the attribute
  84280. * @param count The number of attributes referenced by this accessor
  84281. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84282. * @param min Minimum value of each component in this attribute
  84283. * @param max Maximum value of each component in this attribute
  84284. * @returns accessor for glTF
  84285. */
  84286. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84287. /**
  84288. * Calculates the minimum and maximum values of an array of position floats
  84289. * @param positions Positions array of a mesh
  84290. * @param vertexStart Starting vertex offset to calculate min and max values
  84291. * @param vertexCount Number of vertices to check for min and max values
  84292. * @returns min number array and max number array
  84293. */
  84294. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84295. min: number[];
  84296. max: number[];
  84297. };
  84298. /**
  84299. * Converts a new right-handed Vector3
  84300. * @param vector vector3 array
  84301. * @returns right-handed Vector3
  84302. */
  84303. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84304. /**
  84305. * Converts a Vector3 to right-handed
  84306. * @param vector Vector3 to convert to right-handed
  84307. */
  84308. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84309. /**
  84310. * Converts a three element number array to right-handed
  84311. * @param vector number array to convert to right-handed
  84312. */
  84313. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84314. /**
  84315. * Converts a new right-handed Vector3
  84316. * @param vector vector3 array
  84317. * @returns right-handed Vector3
  84318. */
  84319. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84320. /**
  84321. * Converts a Vector3 to right-handed
  84322. * @param vector Vector3 to convert to right-handed
  84323. */
  84324. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84325. /**
  84326. * Converts a three element number array to right-handed
  84327. * @param vector number array to convert to right-handed
  84328. */
  84329. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84330. /**
  84331. * Converts a Vector4 to right-handed
  84332. * @param vector Vector4 to convert to right-handed
  84333. */
  84334. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84335. /**
  84336. * Converts a Vector4 to right-handed
  84337. * @param vector Vector4 to convert to right-handed
  84338. */
  84339. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84340. /**
  84341. * Converts a Quaternion to right-handed
  84342. * @param quaternion Source quaternion to convert to right-handed
  84343. */
  84344. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84345. /**
  84346. * Converts a Quaternion to right-handed
  84347. * @param quaternion Source quaternion to convert to right-handed
  84348. */
  84349. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84350. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84351. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84352. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84353. }
  84354. }
  84355. declare module BABYLON.GLTF2.Exporter {
  84356. /**
  84357. * Converts Babylon Scene into glTF 2.0.
  84358. * @hidden
  84359. */
  84360. export class _Exporter {
  84361. /**
  84362. * Stores the glTF to export
  84363. */
  84364. _glTF: IGLTF;
  84365. /**
  84366. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84367. */
  84368. _bufferViews: IBufferView[];
  84369. /**
  84370. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84371. */
  84372. _accessors: IAccessor[];
  84373. /**
  84374. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84375. */
  84376. _nodes: INode[];
  84377. /**
  84378. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84379. */
  84380. private _scenes;
  84381. /**
  84382. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84383. */
  84384. private _meshes;
  84385. /**
  84386. * Stores all the generated material information, which represents the appearance of each primitive
  84387. */
  84388. _materials: IMaterial[];
  84389. _materialMap: {
  84390. [materialID: number]: number;
  84391. };
  84392. /**
  84393. * Stores all the generated texture information, which is referenced by glTF materials
  84394. */
  84395. _textures: ITexture[];
  84396. /**
  84397. * Stores all the generated image information, which is referenced by glTF textures
  84398. */
  84399. _images: IImage[];
  84400. /**
  84401. * Stores all the texture samplers
  84402. */
  84403. _samplers: ISampler[];
  84404. /**
  84405. * Stores all the generated glTF skins
  84406. */
  84407. _skins: ISkin[];
  84408. /**
  84409. * Stores all the generated animation samplers, which is referenced by glTF animations
  84410. */
  84411. /**
  84412. * Stores the animations for glTF models
  84413. */
  84414. private _animations;
  84415. /**
  84416. * Stores the total amount of bytes stored in the glTF buffer
  84417. */
  84418. private _totalByteLength;
  84419. /**
  84420. * Stores a reference to the Babylon scene containing the source geometry and material information
  84421. */
  84422. _babylonScene: Scene;
  84423. /**
  84424. * Stores a map of the image data, where the key is the file name and the value
  84425. * is the image data
  84426. */
  84427. _imageData: {
  84428. [fileName: string]: {
  84429. data: Uint8Array;
  84430. mimeType: ImageMimeType;
  84431. };
  84432. };
  84433. protected _orderedImageData: Array<{
  84434. data: Uint8Array;
  84435. mimeType: ImageMimeType;
  84436. }>;
  84437. /**
  84438. * Stores a map of the unique id of a node to its index in the node array
  84439. */
  84440. _nodeMap: {
  84441. [key: number]: number;
  84442. };
  84443. /**
  84444. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84445. */
  84446. _convertToRightHandedSystem: boolean;
  84447. /**
  84448. * Specifies if a Babylon node should be converted to right-handed on export
  84449. */
  84450. _convertToRightHandedSystemMap: {
  84451. [nodeId: number]: boolean;
  84452. };
  84453. _includeCoordinateSystemConversionNodes: boolean;
  84454. /**
  84455. * Baked animation sample rate
  84456. */
  84457. private _animationSampleRate;
  84458. private _options;
  84459. private _localEngine;
  84460. _glTFMaterialExporter: _GLTFMaterialExporter;
  84461. private _extensions;
  84462. private static _ExtensionNames;
  84463. private static _ExtensionFactories;
  84464. private _applyExtension;
  84465. private _applyExtensions;
  84466. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84467. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84468. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84469. [key: number]: number;
  84470. }): Promise<Nullable<INode>>;
  84471. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84472. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84473. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84474. private _forEachExtensions;
  84475. private _extensionsOnExporting;
  84476. /**
  84477. * Load glTF serializer extensions
  84478. */
  84479. private _loadExtensions;
  84480. /**
  84481. * Creates a glTF Exporter instance, which can accept optional exporter options
  84482. * @param babylonScene Babylon scene object
  84483. * @param options Options to modify the behavior of the exporter
  84484. */
  84485. constructor(babylonScene: Scene, options?: IExportOptions);
  84486. dispose(): void;
  84487. /**
  84488. * Registers a glTF exporter extension
  84489. * @param name Name of the extension to export
  84490. * @param factory The factory function that creates the exporter extension
  84491. */
  84492. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84493. /**
  84494. * Un-registers an exporter extension
  84495. * @param name The name fo the exporter extension
  84496. * @returns A boolean indicating whether the extension has been un-registered
  84497. */
  84498. static UnregisterExtension(name: string): boolean;
  84499. /**
  84500. * Lazy load a local engine
  84501. */
  84502. _getLocalEngine(): Engine;
  84503. private reorderIndicesBasedOnPrimitiveMode;
  84504. /**
  84505. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84506. * clock-wise during export to glTF
  84507. * @param submesh BabylonJS submesh
  84508. * @param primitiveMode Primitive mode of the mesh
  84509. * @param sideOrientation the winding order of the submesh
  84510. * @param vertexBufferKind The type of vertex attribute
  84511. * @param meshAttributeArray The vertex attribute data
  84512. * @param byteOffset The offset to the binary data
  84513. * @param binaryWriter The binary data for the glTF file
  84514. * @param convertToRightHandedSystem Converts the values to right-handed
  84515. */
  84516. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84517. /**
  84518. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84519. * clock-wise during export to glTF
  84520. * @param submesh BabylonJS submesh
  84521. * @param primitiveMode Primitive mode of the mesh
  84522. * @param sideOrientation the winding order of the submesh
  84523. * @param vertexBufferKind The type of vertex attribute
  84524. * @param meshAttributeArray The vertex attribute data
  84525. * @param byteOffset The offset to the binary data
  84526. * @param binaryWriter The binary data for the glTF file
  84527. * @param convertToRightHandedSystem Converts the values to right-handed
  84528. */
  84529. private reorderTriangleFillMode;
  84530. /**
  84531. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84532. * clock-wise during export to glTF
  84533. * @param submesh BabylonJS submesh
  84534. * @param primitiveMode Primitive mode of the mesh
  84535. * @param sideOrientation the winding order of the submesh
  84536. * @param vertexBufferKind The type of vertex attribute
  84537. * @param meshAttributeArray The vertex attribute data
  84538. * @param byteOffset The offset to the binary data
  84539. * @param binaryWriter The binary data for the glTF file
  84540. * @param convertToRightHandedSystem Converts the values to right-handed
  84541. */
  84542. private reorderTriangleStripDrawMode;
  84543. /**
  84544. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84545. * clock-wise during export to glTF
  84546. * @param submesh BabylonJS submesh
  84547. * @param primitiveMode Primitive mode of the mesh
  84548. * @param sideOrientation the winding order of the submesh
  84549. * @param vertexBufferKind The type of vertex attribute
  84550. * @param meshAttributeArray The vertex attribute data
  84551. * @param byteOffset The offset to the binary data
  84552. * @param binaryWriter The binary data for the glTF file
  84553. * @param convertToRightHandedSystem Converts the values to right-handed
  84554. */
  84555. private reorderTriangleFanMode;
  84556. /**
  84557. * Writes the vertex attribute data to binary
  84558. * @param vertices The vertices to write to the binary writer
  84559. * @param byteOffset The offset into the binary writer to overwrite binary data
  84560. * @param vertexAttributeKind The vertex attribute type
  84561. * @param meshAttributeArray The vertex attribute data
  84562. * @param binaryWriter The writer containing the binary data
  84563. * @param convertToRightHandedSystem Converts the values to right-handed
  84564. */
  84565. private writeVertexAttributeData;
  84566. /**
  84567. * Writes mesh attribute data to a data buffer
  84568. * Returns the bytelength of the data
  84569. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84570. * @param meshAttributeArray Array containing the attribute data
  84571. * @param byteStride Specifies the space between data
  84572. * @param binaryWriter The buffer to write the binary data to
  84573. * @param convertToRightHandedSystem Converts the values to right-handed
  84574. */
  84575. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84576. /**
  84577. * Writes mesh attribute data to a data buffer
  84578. * Returns the bytelength of the data
  84579. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84580. * @param meshAttributeArray Array containing the attribute data
  84581. * @param byteStride Specifies the space between data
  84582. * @param binaryWriter The buffer to write the binary data to
  84583. * @param convertToRightHandedSystem Converts the values to right-handed
  84584. */
  84585. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84586. /**
  84587. * Generates glTF json data
  84588. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84589. * @param glTFPrefix Text to use when prefixing a glTF file
  84590. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84591. * @returns json data as string
  84592. */
  84593. private generateJSON;
  84594. /**
  84595. * Generates data for .gltf and .bin files based on the glTF prefix string
  84596. * @param glTFPrefix Text to use when prefixing a glTF file
  84597. * @param dispose Dispose the exporter
  84598. * @returns GLTFData with glTF file data
  84599. */
  84600. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84601. /**
  84602. * Creates a binary buffer for glTF
  84603. * @returns array buffer for binary data
  84604. */
  84605. private _generateBinaryAsync;
  84606. /**
  84607. * Pads the number to a multiple of 4
  84608. * @param num number to pad
  84609. * @returns padded number
  84610. */
  84611. private _getPadding;
  84612. /**
  84613. * @hidden
  84614. */
  84615. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84616. /**
  84617. * Sets the TRS for each node
  84618. * @param node glTF Node for storing the transformation data
  84619. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84620. * @param convertToRightHandedSystem Converts the values to right-handed
  84621. */
  84622. private setNodeTransformation;
  84623. private getVertexBufferFromMesh;
  84624. /**
  84625. * Creates a bufferview based on the vertices type for the Babylon mesh
  84626. * @param kind Indicates the type of vertices data
  84627. * @param componentType Indicates the numerical type used to store the data
  84628. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84629. * @param binaryWriter The buffer to write the bufferview data to
  84630. * @param convertToRightHandedSystem Converts the values to right-handed
  84631. */
  84632. private createBufferViewKind;
  84633. /**
  84634. * Creates a bufferview based on the vertices type for the Babylon mesh
  84635. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84636. * @param babylonMorphTarget the morph target to be exported
  84637. * @param binaryWriter The buffer to write the bufferview data to
  84638. * @param convertToRightHandedSystem Converts the values to right-handed
  84639. */
  84640. private setMorphTargetAttributes;
  84641. /**
  84642. * The primitive mode of the Babylon mesh
  84643. * @param babylonMesh The BabylonJS mesh
  84644. */
  84645. private getMeshPrimitiveMode;
  84646. /**
  84647. * Sets the primitive mode of the glTF mesh primitive
  84648. * @param meshPrimitive glTF mesh primitive
  84649. * @param primitiveMode The primitive mode
  84650. */
  84651. private setPrimitiveMode;
  84652. /**
  84653. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84654. * @param meshPrimitive glTF mesh primitive
  84655. * @param attributeKind vertex attribute
  84656. * @returns boolean specifying if uv coordinates are present
  84657. */
  84658. private setAttributeKind;
  84659. /**
  84660. * Sets data for the primitive attributes of each submesh
  84661. * @param mesh glTF Mesh object to store the primitive attribute information
  84662. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84663. * @param binaryWriter Buffer to write the attribute data to
  84664. * @param convertToRightHandedSystem Converts the values to right-handed
  84665. */
  84666. private setPrimitiveAttributesAsync;
  84667. /**
  84668. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84669. * @param node The node to check
  84670. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84671. */
  84672. private isBabylonCoordinateSystemConvertingNode;
  84673. /**
  84674. * Creates a glTF scene based on the array of meshes
  84675. * Returns the the total byte offset
  84676. * @param babylonScene Babylon scene to get the mesh data from
  84677. * @param binaryWriter Buffer to write binary data to
  84678. */
  84679. private createSceneAsync;
  84680. /**
  84681. * Creates a mapping of Node unique id to node index and handles animations
  84682. * @param babylonScene Babylon Scene
  84683. * @param nodes Babylon transform nodes
  84684. * @param binaryWriter Buffer to write binary data to
  84685. * @returns Node mapping of unique id to index
  84686. */
  84687. private createNodeMapAndAnimationsAsync;
  84688. /**
  84689. * Creates a glTF node from a Babylon mesh
  84690. * @param babylonMesh Source Babylon mesh
  84691. * @param binaryWriter Buffer for storing geometry data
  84692. * @param convertToRightHandedSystem Converts the values to right-handed
  84693. * @param nodeMap Node mapping of unique id to glTF node index
  84694. * @returns glTF node
  84695. */
  84696. private createNodeAsync;
  84697. /**
  84698. * Creates a glTF skin from a Babylon skeleton
  84699. * @param babylonScene Babylon Scene
  84700. * @param nodes Babylon transform nodes
  84701. * @param binaryWriter Buffer to write binary data to
  84702. * @returns Node mapping of unique id to index
  84703. */
  84704. private createSkinsAsync;
  84705. }
  84706. /**
  84707. * @hidden
  84708. *
  84709. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84710. */
  84711. export class _BinaryWriter {
  84712. /**
  84713. * Array buffer which stores all binary data
  84714. */
  84715. private _arrayBuffer;
  84716. /**
  84717. * View of the array buffer
  84718. */
  84719. private _dataView;
  84720. /**
  84721. * byte offset of data in array buffer
  84722. */
  84723. private _byteOffset;
  84724. /**
  84725. * Initialize binary writer with an initial byte length
  84726. * @param byteLength Initial byte length of the array buffer
  84727. */
  84728. constructor(byteLength: number);
  84729. /**
  84730. * Resize the array buffer to the specified byte length
  84731. * @param byteLength
  84732. */
  84733. private resizeBuffer;
  84734. /**
  84735. * Get an array buffer with the length of the byte offset
  84736. * @returns ArrayBuffer resized to the byte offset
  84737. */
  84738. getArrayBuffer(): ArrayBuffer;
  84739. /**
  84740. * Get the byte offset of the array buffer
  84741. * @returns byte offset
  84742. */
  84743. getByteOffset(): number;
  84744. /**
  84745. * Stores an UInt8 in the array buffer
  84746. * @param entry
  84747. * @param byteOffset If defined, specifies where to set the value as an offset.
  84748. */
  84749. setUInt8(entry: number, byteOffset?: number): void;
  84750. /**
  84751. * Stores an UInt16 in the array buffer
  84752. * @param entry
  84753. * @param byteOffset If defined, specifies where to set the value as an offset.
  84754. */
  84755. setUInt16(entry: number, byteOffset?: number): void;
  84756. /**
  84757. * Gets an UInt32 in the array buffer
  84758. * @param entry
  84759. * @param byteOffset If defined, specifies where to set the value as an offset.
  84760. */
  84761. getUInt32(byteOffset: number): number;
  84762. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84763. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84764. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84765. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84766. /**
  84767. * Stores a Float32 in the array buffer
  84768. * @param entry
  84769. */
  84770. setFloat32(entry: number, byteOffset?: number): void;
  84771. /**
  84772. * Stores an UInt32 in the array buffer
  84773. * @param entry
  84774. * @param byteOffset If defined, specifies where to set the value as an offset.
  84775. */
  84776. setUInt32(entry: number, byteOffset?: number): void;
  84777. }
  84778. }
  84779. declare module BABYLON.GLTF2.Exporter {
  84780. /**
  84781. * @hidden
  84782. * Interface to store animation data.
  84783. */
  84784. export interface _IAnimationData {
  84785. /**
  84786. * Keyframe data.
  84787. */
  84788. inputs: number[];
  84789. /**
  84790. * Value data.
  84791. */
  84792. outputs: number[][];
  84793. /**
  84794. * Animation interpolation data.
  84795. */
  84796. samplerInterpolation: AnimationSamplerInterpolation;
  84797. /**
  84798. * Minimum keyframe value.
  84799. */
  84800. inputsMin: number;
  84801. /**
  84802. * Maximum keyframe value.
  84803. */
  84804. inputsMax: number;
  84805. }
  84806. /**
  84807. * @hidden
  84808. */
  84809. export interface _IAnimationInfo {
  84810. /**
  84811. * The target channel for the animation
  84812. */
  84813. animationChannelTargetPath: AnimationChannelTargetPath;
  84814. /**
  84815. * The glTF accessor type for the data.
  84816. */
  84817. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84818. /**
  84819. * Specifies if quaternions should be used.
  84820. */
  84821. useQuaternion: boolean;
  84822. }
  84823. /**
  84824. * @hidden
  84825. * Utility class for generating glTF animation data from BabylonJS.
  84826. */
  84827. export class _GLTFAnimation {
  84828. /**
  84829. * @ignore
  84830. *
  84831. * Creates glTF channel animation from BabylonJS animation.
  84832. * @param babylonTransformNode - BabylonJS mesh.
  84833. * @param animation - animation.
  84834. * @param animationChannelTargetPath - The target animation channel.
  84835. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84836. * @param useQuaternion - Specifies if quaternions are used.
  84837. * @returns nullable IAnimationData
  84838. */
  84839. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84840. private static _DeduceAnimationInfo;
  84841. /**
  84842. * @ignore
  84843. * Create node animations from the transform node animations
  84844. * @param babylonNode
  84845. * @param runtimeGLTFAnimation
  84846. * @param idleGLTFAnimations
  84847. * @param nodeMap
  84848. * @param nodes
  84849. * @param binaryWriter
  84850. * @param bufferViews
  84851. * @param accessors
  84852. * @param convertToRightHandedSystem
  84853. * @param animationSampleRate
  84854. */
  84855. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84856. [key: number]: number;
  84857. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84858. /**
  84859. * @ignore
  84860. * Create individual morph animations from the mesh's morph target animation tracks
  84861. * @param babylonNode
  84862. * @param runtimeGLTFAnimation
  84863. * @param idleGLTFAnimations
  84864. * @param nodeMap
  84865. * @param nodes
  84866. * @param binaryWriter
  84867. * @param bufferViews
  84868. * @param accessors
  84869. * @param convertToRightHandedSystem
  84870. * @param animationSampleRate
  84871. */
  84872. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84873. [key: number]: number;
  84874. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84875. /**
  84876. * @ignore
  84877. * Create node and morph animations from the animation groups
  84878. * @param babylonScene
  84879. * @param glTFAnimations
  84880. * @param nodeMap
  84881. * @param nodes
  84882. * @param binaryWriter
  84883. * @param bufferViews
  84884. * @param accessors
  84885. * @param convertToRightHandedSystemMap
  84886. * @param animationSampleRate
  84887. */
  84888. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84889. [key: number]: number;
  84890. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84891. [nodeId: number]: boolean;
  84892. }, animationSampleRate: number): void;
  84893. private static AddAnimation;
  84894. /**
  84895. * Create a baked animation
  84896. * @param babylonTransformNode BabylonJS mesh
  84897. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84898. * @param animationChannelTargetPath animation target channel
  84899. * @param minFrame minimum animation frame
  84900. * @param maxFrame maximum animation frame
  84901. * @param fps frames per second of the animation
  84902. * @param inputs input key frames of the animation
  84903. * @param outputs output key frame data of the animation
  84904. * @param convertToRightHandedSystem converts the values to right-handed
  84905. * @param useQuaternion specifies if quaternions should be used
  84906. */
  84907. private static _CreateBakedAnimation;
  84908. private static _ConvertFactorToVector3OrQuaternion;
  84909. private static _SetInterpolatedValue;
  84910. /**
  84911. * Creates linear animation from the animation key frames
  84912. * @param babylonTransformNode BabylonJS mesh
  84913. * @param animation BabylonJS animation
  84914. * @param animationChannelTargetPath The target animation channel
  84915. * @param frameDelta The difference between the last and first frame of the animation
  84916. * @param inputs Array to store the key frame times
  84917. * @param outputs Array to store the key frame data
  84918. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84919. * @param useQuaternion Specifies if quaternions are used in the animation
  84920. */
  84921. private static _CreateLinearOrStepAnimation;
  84922. /**
  84923. * Creates cubic spline animation from the animation key frames
  84924. * @param babylonTransformNode BabylonJS mesh
  84925. * @param animation BabylonJS animation
  84926. * @param animationChannelTargetPath The target animation channel
  84927. * @param frameDelta The difference between the last and first frame of the animation
  84928. * @param inputs Array to store the key frame times
  84929. * @param outputs Array to store the key frame data
  84930. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84931. * @param useQuaternion Specifies if quaternions are used in the animation
  84932. */
  84933. private static _CreateCubicSplineAnimation;
  84934. private static _GetBasePositionRotationOrScale;
  84935. /**
  84936. * Adds a key frame value
  84937. * @param keyFrame
  84938. * @param animation
  84939. * @param outputs
  84940. * @param animationChannelTargetPath
  84941. * @param basePositionRotationOrScale
  84942. * @param convertToRightHandedSystem
  84943. * @param useQuaternion
  84944. */
  84945. private static _AddKeyframeValue;
  84946. /**
  84947. * Determine the interpolation based on the key frames
  84948. * @param keyFrames
  84949. * @param animationChannelTargetPath
  84950. * @param useQuaternion
  84951. */
  84952. private static _DeduceInterpolation;
  84953. /**
  84954. * Adds an input tangent or output tangent to the output data
  84955. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84956. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84957. * @param outputs The animation data by keyframe
  84958. * @param animationChannelTargetPath The target animation channel
  84959. * @param interpolation The interpolation type
  84960. * @param keyFrame The key frame with the animation data
  84961. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84962. * @param useQuaternion Specifies if quaternions are used
  84963. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84964. */
  84965. private static AddSplineTangent;
  84966. /**
  84967. * Get the minimum and maximum key frames' frame values
  84968. * @param keyFrames animation key frames
  84969. * @returns the minimum and maximum key frame value
  84970. */
  84971. private static calculateMinMaxKeyFrames;
  84972. }
  84973. }
  84974. declare module BABYLON.GLTF2.Exporter {
  84975. /** @hidden */
  84976. export var textureTransformPixelShader: {
  84977. name: string;
  84978. shader: string;
  84979. };
  84980. }
  84981. declare module BABYLON.GLTF2.Exporter.Extensions {
  84982. /**
  84983. * @hidden
  84984. */
  84985. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84986. private _recordedTextures;
  84987. /** Name of this extension */
  84988. readonly name: string;
  84989. /** Defines whether this extension is enabled */
  84990. enabled: boolean;
  84991. /** Defines whether this extension is required */
  84992. required: boolean;
  84993. /** Reference to the glTF exporter */
  84994. private _wasUsed;
  84995. constructor(exporter: _Exporter);
  84996. dispose(): void;
  84997. /** @hidden */
  84998. get wasUsed(): boolean;
  84999. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85000. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85001. /**
  85002. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85003. * @param babylonTexture
  85004. * @param offset
  85005. * @param rotation
  85006. * @param scale
  85007. * @param scene
  85008. */
  85009. private _textureTransformTextureAsync;
  85010. }
  85011. }
  85012. declare module BABYLON.GLTF2.Exporter.Extensions {
  85013. /**
  85014. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85015. */
  85016. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85017. /** The name of this extension. */
  85018. readonly name: string;
  85019. /** Defines whether this extension is enabled. */
  85020. enabled: boolean;
  85021. /** Defines whether this extension is required */
  85022. required: boolean;
  85023. /** Reference to the glTF exporter */
  85024. private _exporter;
  85025. private _lights;
  85026. /** @hidden */
  85027. constructor(exporter: _Exporter);
  85028. /** @hidden */
  85029. dispose(): void;
  85030. /** @hidden */
  85031. get wasUsed(): boolean;
  85032. /** @hidden */
  85033. onExporting(): void;
  85034. /**
  85035. * Define this method to modify the default behavior when exporting a node
  85036. * @param context The context when exporting the node
  85037. * @param node glTF node
  85038. * @param babylonNode BabylonJS node
  85039. * @param nodeMap Node mapping of unique id to glTF node index
  85040. * @returns nullable INode promise
  85041. */
  85042. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85043. [key: number]: number;
  85044. }): Promise<Nullable<INode>>;
  85045. }
  85046. }
  85047. declare module BABYLON.GLTF2.Exporter.Extensions {
  85048. /**
  85049. * @hidden
  85050. */
  85051. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85052. /** Name of this extension */
  85053. readonly name: string;
  85054. /** Defines whether this extension is enabled */
  85055. enabled: boolean;
  85056. /** Defines whether this extension is required */
  85057. required: boolean;
  85058. /** Reference to the glTF exporter */
  85059. private _textureInfos;
  85060. private _exportedTextures;
  85061. private _wasUsed;
  85062. constructor(exporter: _Exporter);
  85063. dispose(): void;
  85064. /** @hidden */
  85065. get wasUsed(): boolean;
  85066. private _getTextureIndex;
  85067. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85068. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85069. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85070. }
  85071. }
  85072. declare module BABYLON.GLTF2.Exporter.Extensions {
  85073. /**
  85074. * @hidden
  85075. */
  85076. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85077. /** Name of this extension */
  85078. readonly name: string;
  85079. /** Defines whether this extension is enabled */
  85080. enabled: boolean;
  85081. /** Defines whether this extension is required */
  85082. required: boolean;
  85083. private _wasUsed;
  85084. constructor(exporter: _Exporter);
  85085. /** @hidden */
  85086. get wasUsed(): boolean;
  85087. dispose(): void;
  85088. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85089. }
  85090. }
  85091. declare module BABYLON {
  85092. /**
  85093. * Class for generating STL data from a Babylon scene.
  85094. */
  85095. export class STLExport {
  85096. /**
  85097. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85098. * @param meshes list defines the mesh to serialize
  85099. * @param download triggers the automatic download of the file.
  85100. * @param fileName changes the downloads fileName.
  85101. * @param binary changes the STL to a binary type.
  85102. * @param isLittleEndian toggle for binary type exporter.
  85103. * @returns the STL as UTF8 string
  85104. */
  85105. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85106. }
  85107. }
  85108. declare module "babylonjs-gltf2interface" {
  85109. export = BABYLON.GLTF2;
  85110. }
  85111. /**
  85112. * Module for glTF 2.0 Interface
  85113. */
  85114. declare module BABYLON.GLTF2 {
  85115. /**
  85116. * The datatype of the components in the attribute
  85117. */
  85118. const enum AccessorComponentType {
  85119. /**
  85120. * Byte
  85121. */
  85122. BYTE = 5120,
  85123. /**
  85124. * Unsigned Byte
  85125. */
  85126. UNSIGNED_BYTE = 5121,
  85127. /**
  85128. * Short
  85129. */
  85130. SHORT = 5122,
  85131. /**
  85132. * Unsigned Short
  85133. */
  85134. UNSIGNED_SHORT = 5123,
  85135. /**
  85136. * Unsigned Int
  85137. */
  85138. UNSIGNED_INT = 5125,
  85139. /**
  85140. * Float
  85141. */
  85142. FLOAT = 5126,
  85143. }
  85144. /**
  85145. * Specifies if the attirbute is a scalar, vector, or matrix
  85146. */
  85147. const enum AccessorType {
  85148. /**
  85149. * Scalar
  85150. */
  85151. SCALAR = "SCALAR",
  85152. /**
  85153. * Vector2
  85154. */
  85155. VEC2 = "VEC2",
  85156. /**
  85157. * Vector3
  85158. */
  85159. VEC3 = "VEC3",
  85160. /**
  85161. * Vector4
  85162. */
  85163. VEC4 = "VEC4",
  85164. /**
  85165. * Matrix2x2
  85166. */
  85167. MAT2 = "MAT2",
  85168. /**
  85169. * Matrix3x3
  85170. */
  85171. MAT3 = "MAT3",
  85172. /**
  85173. * Matrix4x4
  85174. */
  85175. MAT4 = "MAT4",
  85176. }
  85177. /**
  85178. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85179. */
  85180. const enum AnimationChannelTargetPath {
  85181. /**
  85182. * Translation
  85183. */
  85184. TRANSLATION = "translation",
  85185. /**
  85186. * Rotation
  85187. */
  85188. ROTATION = "rotation",
  85189. /**
  85190. * Scale
  85191. */
  85192. SCALE = "scale",
  85193. /**
  85194. * Weights
  85195. */
  85196. WEIGHTS = "weights",
  85197. }
  85198. /**
  85199. * Interpolation algorithm
  85200. */
  85201. const enum AnimationSamplerInterpolation {
  85202. /**
  85203. * The animated values are linearly interpolated between keyframes
  85204. */
  85205. LINEAR = "LINEAR",
  85206. /**
  85207. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85208. */
  85209. STEP = "STEP",
  85210. /**
  85211. * The animation's interpolation is computed using a cubic spline with specified tangents
  85212. */
  85213. CUBICSPLINE = "CUBICSPLINE",
  85214. }
  85215. /**
  85216. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85217. */
  85218. const enum CameraType {
  85219. /**
  85220. * A perspective camera containing properties to create a perspective projection matrix
  85221. */
  85222. PERSPECTIVE = "perspective",
  85223. /**
  85224. * An orthographic camera containing properties to create an orthographic projection matrix
  85225. */
  85226. ORTHOGRAPHIC = "orthographic",
  85227. }
  85228. /**
  85229. * The mime-type of the image
  85230. */
  85231. const enum ImageMimeType {
  85232. /**
  85233. * JPEG Mime-type
  85234. */
  85235. JPEG = "image/jpeg",
  85236. /**
  85237. * PNG Mime-type
  85238. */
  85239. PNG = "image/png",
  85240. }
  85241. /**
  85242. * The alpha rendering mode of the material
  85243. */
  85244. const enum MaterialAlphaMode {
  85245. /**
  85246. * The alpha value is ignored and the rendered output is fully opaque
  85247. */
  85248. OPAQUE = "OPAQUE",
  85249. /**
  85250. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85251. */
  85252. MASK = "MASK",
  85253. /**
  85254. * 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)
  85255. */
  85256. BLEND = "BLEND",
  85257. }
  85258. /**
  85259. * The type of the primitives to render
  85260. */
  85261. const enum MeshPrimitiveMode {
  85262. /**
  85263. * Points
  85264. */
  85265. POINTS = 0,
  85266. /**
  85267. * Lines
  85268. */
  85269. LINES = 1,
  85270. /**
  85271. * Line Loop
  85272. */
  85273. LINE_LOOP = 2,
  85274. /**
  85275. * Line Strip
  85276. */
  85277. LINE_STRIP = 3,
  85278. /**
  85279. * Triangles
  85280. */
  85281. TRIANGLES = 4,
  85282. /**
  85283. * Triangle Strip
  85284. */
  85285. TRIANGLE_STRIP = 5,
  85286. /**
  85287. * Triangle Fan
  85288. */
  85289. TRIANGLE_FAN = 6,
  85290. }
  85291. /**
  85292. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85293. */
  85294. const enum TextureMagFilter {
  85295. /**
  85296. * Nearest
  85297. */
  85298. NEAREST = 9728,
  85299. /**
  85300. * Linear
  85301. */
  85302. LINEAR = 9729,
  85303. }
  85304. /**
  85305. * Minification filter. All valid values correspond to WebGL enums
  85306. */
  85307. const enum TextureMinFilter {
  85308. /**
  85309. * Nearest
  85310. */
  85311. NEAREST = 9728,
  85312. /**
  85313. * Linear
  85314. */
  85315. LINEAR = 9729,
  85316. /**
  85317. * Nearest Mip-Map Nearest
  85318. */
  85319. NEAREST_MIPMAP_NEAREST = 9984,
  85320. /**
  85321. * Linear Mipmap Nearest
  85322. */
  85323. LINEAR_MIPMAP_NEAREST = 9985,
  85324. /**
  85325. * Nearest Mipmap Linear
  85326. */
  85327. NEAREST_MIPMAP_LINEAR = 9986,
  85328. /**
  85329. * Linear Mipmap Linear
  85330. */
  85331. LINEAR_MIPMAP_LINEAR = 9987,
  85332. }
  85333. /**
  85334. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85335. */
  85336. const enum TextureWrapMode {
  85337. /**
  85338. * Clamp to Edge
  85339. */
  85340. CLAMP_TO_EDGE = 33071,
  85341. /**
  85342. * Mirrored Repeat
  85343. */
  85344. MIRRORED_REPEAT = 33648,
  85345. /**
  85346. * Repeat
  85347. */
  85348. REPEAT = 10497,
  85349. }
  85350. /**
  85351. * glTF Property
  85352. */
  85353. interface IProperty {
  85354. /**
  85355. * Dictionary object with extension-specific objects
  85356. */
  85357. extensions?: {
  85358. [key: string]: any;
  85359. };
  85360. /**
  85361. * Application-Specific data
  85362. */
  85363. extras?: any;
  85364. }
  85365. /**
  85366. * glTF Child of Root Property
  85367. */
  85368. interface IChildRootProperty extends IProperty {
  85369. /**
  85370. * The user-defined name of this object
  85371. */
  85372. name?: string;
  85373. }
  85374. /**
  85375. * Indices of those attributes that deviate from their initialization value
  85376. */
  85377. interface IAccessorSparseIndices extends IProperty {
  85378. /**
  85379. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85380. */
  85381. bufferView: number;
  85382. /**
  85383. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85384. */
  85385. byteOffset?: number;
  85386. /**
  85387. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85388. */
  85389. componentType: AccessorComponentType;
  85390. }
  85391. /**
  85392. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85393. */
  85394. interface IAccessorSparseValues extends IProperty {
  85395. /**
  85396. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85397. */
  85398. bufferView: number;
  85399. /**
  85400. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85401. */
  85402. byteOffset?: number;
  85403. }
  85404. /**
  85405. * Sparse storage of attributes that deviate from their initialization value
  85406. */
  85407. interface IAccessorSparse extends IProperty {
  85408. /**
  85409. * The number of attributes encoded in this sparse accessor
  85410. */
  85411. count: number;
  85412. /**
  85413. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85414. */
  85415. indices: IAccessorSparseIndices;
  85416. /**
  85417. * 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
  85418. */
  85419. values: IAccessorSparseValues;
  85420. }
  85421. /**
  85422. * 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
  85423. */
  85424. interface IAccessor extends IChildRootProperty {
  85425. /**
  85426. * The index of the bufferview
  85427. */
  85428. bufferView?: number;
  85429. /**
  85430. * The offset relative to the start of the bufferView in bytes
  85431. */
  85432. byteOffset?: number;
  85433. /**
  85434. * The datatype of components in the attribute
  85435. */
  85436. componentType: AccessorComponentType;
  85437. /**
  85438. * Specifies whether integer data values should be normalized
  85439. */
  85440. normalized?: boolean;
  85441. /**
  85442. * The number of attributes referenced by this accessor
  85443. */
  85444. count: number;
  85445. /**
  85446. * Specifies if the attribute is a scalar, vector, or matrix
  85447. */
  85448. type: AccessorType;
  85449. /**
  85450. * Maximum value of each component in this attribute
  85451. */
  85452. max?: number[];
  85453. /**
  85454. * Minimum value of each component in this attribute
  85455. */
  85456. min?: number[];
  85457. /**
  85458. * Sparse storage of attributes that deviate from their initialization value
  85459. */
  85460. sparse?: IAccessorSparse;
  85461. }
  85462. /**
  85463. * Targets an animation's sampler at a node's property
  85464. */
  85465. interface IAnimationChannel extends IProperty {
  85466. /**
  85467. * The index of a sampler in this animation used to compute the value for the target
  85468. */
  85469. sampler: number;
  85470. /**
  85471. * The index of the node and TRS property to target
  85472. */
  85473. target: IAnimationChannelTarget;
  85474. }
  85475. /**
  85476. * The index of the node and TRS property that an animation channel targets
  85477. */
  85478. interface IAnimationChannelTarget extends IProperty {
  85479. /**
  85480. * The index of the node to target
  85481. */
  85482. node: number;
  85483. /**
  85484. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85485. */
  85486. path: AnimationChannelTargetPath;
  85487. }
  85488. /**
  85489. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85490. */
  85491. interface IAnimationSampler extends IProperty {
  85492. /**
  85493. * The index of an accessor containing keyframe input values, e.g., time
  85494. */
  85495. input: number;
  85496. /**
  85497. * Interpolation algorithm
  85498. */
  85499. interpolation?: AnimationSamplerInterpolation;
  85500. /**
  85501. * The index of an accessor, containing keyframe output values
  85502. */
  85503. output: number;
  85504. }
  85505. /**
  85506. * A keyframe animation
  85507. */
  85508. interface IAnimation extends IChildRootProperty {
  85509. /**
  85510. * An array of channels, each of which targets an animation's sampler at a node's property
  85511. */
  85512. channels: IAnimationChannel[];
  85513. /**
  85514. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85515. */
  85516. samplers: IAnimationSampler[];
  85517. }
  85518. /**
  85519. * Metadata about the glTF asset
  85520. */
  85521. interface IAsset extends IChildRootProperty {
  85522. /**
  85523. * A copyright message suitable for display to credit the content creator
  85524. */
  85525. copyright?: string;
  85526. /**
  85527. * Tool that generated this glTF model. Useful for debugging
  85528. */
  85529. generator?: string;
  85530. /**
  85531. * The glTF version that this asset targets
  85532. */
  85533. version: string;
  85534. /**
  85535. * The minimum glTF version that this asset targets
  85536. */
  85537. minVersion?: string;
  85538. }
  85539. /**
  85540. * A buffer points to binary geometry, animation, or skins
  85541. */
  85542. interface IBuffer extends IChildRootProperty {
  85543. /**
  85544. * 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
  85545. */
  85546. uri?: string;
  85547. /**
  85548. * The length of the buffer in bytes
  85549. */
  85550. byteLength: number;
  85551. }
  85552. /**
  85553. * A view into a buffer generally representing a subset of the buffer
  85554. */
  85555. interface IBufferView extends IChildRootProperty {
  85556. /**
  85557. * The index of the buffer
  85558. */
  85559. buffer: number;
  85560. /**
  85561. * The offset into the buffer in bytes
  85562. */
  85563. byteOffset?: number;
  85564. /**
  85565. * The lenth of the bufferView in bytes
  85566. */
  85567. byteLength: number;
  85568. /**
  85569. * The stride, in bytes
  85570. */
  85571. byteStride?: number;
  85572. }
  85573. /**
  85574. * An orthographic camera containing properties to create an orthographic projection matrix
  85575. */
  85576. interface ICameraOrthographic extends IProperty {
  85577. /**
  85578. * The floating-point horizontal magnification of the view. Must not be zero
  85579. */
  85580. xmag: number;
  85581. /**
  85582. * The floating-point vertical magnification of the view. Must not be zero
  85583. */
  85584. ymag: number;
  85585. /**
  85586. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85587. */
  85588. zfar: number;
  85589. /**
  85590. * The floating-point distance to the near clipping plane
  85591. */
  85592. znear: number;
  85593. }
  85594. /**
  85595. * A perspective camera containing properties to create a perspective projection matrix
  85596. */
  85597. interface ICameraPerspective extends IProperty {
  85598. /**
  85599. * The floating-point aspect ratio of the field of view
  85600. */
  85601. aspectRatio?: number;
  85602. /**
  85603. * The floating-point vertical field of view in radians
  85604. */
  85605. yfov: number;
  85606. /**
  85607. * The floating-point distance to the far clipping plane
  85608. */
  85609. zfar?: number;
  85610. /**
  85611. * The floating-point distance to the near clipping plane
  85612. */
  85613. znear: number;
  85614. }
  85615. /**
  85616. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85617. */
  85618. interface ICamera extends IChildRootProperty {
  85619. /**
  85620. * An orthographic camera containing properties to create an orthographic projection matrix
  85621. */
  85622. orthographic?: ICameraOrthographic;
  85623. /**
  85624. * A perspective camera containing properties to create a perspective projection matrix
  85625. */
  85626. perspective?: ICameraPerspective;
  85627. /**
  85628. * Specifies if the camera uses a perspective or orthographic projection
  85629. */
  85630. type: CameraType;
  85631. }
  85632. /**
  85633. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85634. */
  85635. interface IImage extends IChildRootProperty {
  85636. /**
  85637. * 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
  85638. */
  85639. uri?: string;
  85640. /**
  85641. * The image's MIME type
  85642. */
  85643. mimeType?: ImageMimeType;
  85644. /**
  85645. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85646. */
  85647. bufferView?: number;
  85648. }
  85649. /**
  85650. * Material Normal Texture Info
  85651. */
  85652. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85653. /**
  85654. * The scalar multiplier applied to each normal vector of the normal texture
  85655. */
  85656. scale?: number;
  85657. }
  85658. /**
  85659. * Material Occlusion Texture Info
  85660. */
  85661. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85662. /**
  85663. * A scalar multiplier controlling the amount of occlusion applied
  85664. */
  85665. strength?: number;
  85666. }
  85667. /**
  85668. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85669. */
  85670. interface IMaterialPbrMetallicRoughness {
  85671. /**
  85672. * The material's base color factor
  85673. */
  85674. baseColorFactor?: number[];
  85675. /**
  85676. * The base color texture
  85677. */
  85678. baseColorTexture?: ITextureInfo;
  85679. /**
  85680. * The metalness of the material
  85681. */
  85682. metallicFactor?: number;
  85683. /**
  85684. * The roughness of the material
  85685. */
  85686. roughnessFactor?: number;
  85687. /**
  85688. * The metallic-roughness texture
  85689. */
  85690. metallicRoughnessTexture?: ITextureInfo;
  85691. }
  85692. /**
  85693. * The material appearance of a primitive
  85694. */
  85695. interface IMaterial extends IChildRootProperty {
  85696. /**
  85697. * 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
  85698. */
  85699. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85700. /**
  85701. * The normal map texture
  85702. */
  85703. normalTexture?: IMaterialNormalTextureInfo;
  85704. /**
  85705. * The occlusion map texture
  85706. */
  85707. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85708. /**
  85709. * The emissive map texture
  85710. */
  85711. emissiveTexture?: ITextureInfo;
  85712. /**
  85713. * 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
  85714. */
  85715. emissiveFactor?: number[];
  85716. /**
  85717. * The alpha rendering mode of the material
  85718. */
  85719. alphaMode?: MaterialAlphaMode;
  85720. /**
  85721. * The alpha cutoff value of the material
  85722. */
  85723. alphaCutoff?: number;
  85724. /**
  85725. * Specifies whether the material is double sided
  85726. */
  85727. doubleSided?: boolean;
  85728. }
  85729. /**
  85730. * Geometry to be rendered with the given material
  85731. */
  85732. interface IMeshPrimitive extends IProperty {
  85733. /**
  85734. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85735. */
  85736. attributes: {
  85737. [name: string]: number;
  85738. };
  85739. /**
  85740. * The index of the accessor that contains the indices
  85741. */
  85742. indices?: number;
  85743. /**
  85744. * The index of the material to apply to this primitive when rendering
  85745. */
  85746. material?: number;
  85747. /**
  85748. * The type of primitives to render. All valid values correspond to WebGL enums
  85749. */
  85750. mode?: MeshPrimitiveMode;
  85751. /**
  85752. * 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
  85753. */
  85754. targets?: {
  85755. [name: string]: number;
  85756. }[];
  85757. }
  85758. /**
  85759. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85760. */
  85761. interface IMesh extends IChildRootProperty {
  85762. /**
  85763. * An array of primitives, each defining geometry to be rendered with a material
  85764. */
  85765. primitives: IMeshPrimitive[];
  85766. /**
  85767. * Array of weights to be applied to the Morph Targets
  85768. */
  85769. weights?: number[];
  85770. }
  85771. /**
  85772. * A node in the node hierarchy
  85773. */
  85774. interface INode extends IChildRootProperty {
  85775. /**
  85776. * The index of the camera referenced by this node
  85777. */
  85778. camera?: number;
  85779. /**
  85780. * The indices of this node's children
  85781. */
  85782. children?: number[];
  85783. /**
  85784. * The index of the skin referenced by this node
  85785. */
  85786. skin?: number;
  85787. /**
  85788. * A floating-point 4x4 transformation matrix stored in column-major order
  85789. */
  85790. matrix?: number[];
  85791. /**
  85792. * The index of the mesh in this node
  85793. */
  85794. mesh?: number;
  85795. /**
  85796. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85797. */
  85798. rotation?: number[];
  85799. /**
  85800. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85801. */
  85802. scale?: number[];
  85803. /**
  85804. * The node's translation along the x, y, and z axes
  85805. */
  85806. translation?: number[];
  85807. /**
  85808. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85809. */
  85810. weights?: number[];
  85811. }
  85812. /**
  85813. * Texture sampler properties for filtering and wrapping modes
  85814. */
  85815. interface ISampler extends IChildRootProperty {
  85816. /**
  85817. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85818. */
  85819. magFilter?: TextureMagFilter;
  85820. /**
  85821. * Minification filter. All valid values correspond to WebGL enums
  85822. */
  85823. minFilter?: TextureMinFilter;
  85824. /**
  85825. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85826. */
  85827. wrapS?: TextureWrapMode;
  85828. /**
  85829. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85830. */
  85831. wrapT?: TextureWrapMode;
  85832. }
  85833. /**
  85834. * The root nodes of a scene
  85835. */
  85836. interface IScene extends IChildRootProperty {
  85837. /**
  85838. * The indices of each root node
  85839. */
  85840. nodes: number[];
  85841. }
  85842. /**
  85843. * Joints and matrices defining a skin
  85844. */
  85845. interface ISkin extends IChildRootProperty {
  85846. /**
  85847. * 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
  85848. */
  85849. inverseBindMatrices?: number;
  85850. /**
  85851. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85852. */
  85853. skeleton?: number;
  85854. /**
  85855. * 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)
  85856. */
  85857. joints: number[];
  85858. }
  85859. /**
  85860. * A texture and its sampler
  85861. */
  85862. interface ITexture extends IChildRootProperty {
  85863. /**
  85864. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85865. */
  85866. sampler?: number;
  85867. /**
  85868. * The index of the image used by this texture
  85869. */
  85870. source: number;
  85871. }
  85872. /**
  85873. * Reference to a texture
  85874. */
  85875. interface ITextureInfo extends IProperty {
  85876. /**
  85877. * The index of the texture
  85878. */
  85879. index: number;
  85880. /**
  85881. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85882. */
  85883. texCoord?: number;
  85884. }
  85885. /**
  85886. * The root object for a glTF asset
  85887. */
  85888. interface IGLTF extends IProperty {
  85889. /**
  85890. * An array of accessors. An accessor is a typed view into a bufferView
  85891. */
  85892. accessors?: IAccessor[];
  85893. /**
  85894. * An array of keyframe animations
  85895. */
  85896. animations?: IAnimation[];
  85897. /**
  85898. * Metadata about the glTF asset
  85899. */
  85900. asset: IAsset;
  85901. /**
  85902. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85903. */
  85904. buffers?: IBuffer[];
  85905. /**
  85906. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85907. */
  85908. bufferViews?: IBufferView[];
  85909. /**
  85910. * An array of cameras
  85911. */
  85912. cameras?: ICamera[];
  85913. /**
  85914. * Names of glTF extensions used somewhere in this asset
  85915. */
  85916. extensionsUsed?: string[];
  85917. /**
  85918. * Names of glTF extensions required to properly load this asset
  85919. */
  85920. extensionsRequired?: string[];
  85921. /**
  85922. * An array of images. An image defines data used to create a texture
  85923. */
  85924. images?: IImage[];
  85925. /**
  85926. * An array of materials. A material defines the appearance of a primitive
  85927. */
  85928. materials?: IMaterial[];
  85929. /**
  85930. * An array of meshes. A mesh is a set of primitives to be rendered
  85931. */
  85932. meshes?: IMesh[];
  85933. /**
  85934. * An array of nodes
  85935. */
  85936. nodes?: INode[];
  85937. /**
  85938. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85939. */
  85940. samplers?: ISampler[];
  85941. /**
  85942. * The index of the default scene
  85943. */
  85944. scene?: number;
  85945. /**
  85946. * An array of scenes
  85947. */
  85948. scenes?: IScene[];
  85949. /**
  85950. * An array of skins. A skin is defined by joints and matrices
  85951. */
  85952. skins?: ISkin[];
  85953. /**
  85954. * An array of textures
  85955. */
  85956. textures?: ITexture[];
  85957. }
  85958. /**
  85959. * The glTF validation results
  85960. * @ignore
  85961. */
  85962. interface IGLTFValidationResults {
  85963. info: {
  85964. generator: string;
  85965. hasAnimations: boolean;
  85966. hasDefaultScene: boolean;
  85967. hasMaterials: boolean;
  85968. hasMorphTargets: boolean;
  85969. hasSkins: boolean;
  85970. hasTextures: boolean;
  85971. maxAttributesUsed: number;
  85972. primitivesCount: number
  85973. };
  85974. issues: {
  85975. messages: Array<string>;
  85976. numErrors: number;
  85977. numHints: number;
  85978. numInfos: number;
  85979. numWarnings: number;
  85980. truncated: boolean
  85981. };
  85982. mimeType: string;
  85983. uri: string;
  85984. validatedAt: string;
  85985. validatorVersion: string;
  85986. }
  85987. /**
  85988. * The glTF validation options
  85989. */
  85990. interface IGLTFValidationOptions {
  85991. /** Uri to use */
  85992. uri?: string;
  85993. /** Function used to load external resources */
  85994. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85995. /** Boolean indicating that we need to validate accessor data */
  85996. validateAccessorData?: boolean;
  85997. /** max number of issues allowed */
  85998. maxIssues?: number;
  85999. /** Ignored issues */
  86000. ignoredIssues?: Array<string>;
  86001. /** Value to override severy settings */
  86002. severityOverrides?: Object;
  86003. }
  86004. /**
  86005. * The glTF validator object
  86006. * @ignore
  86007. */
  86008. interface IGLTFValidator {
  86009. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86010. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86011. }
  86012. /**
  86013. * Interfaces from the EXT_lights_image_based extension
  86014. */
  86015. /** @hidden */
  86016. interface IEXTLightsImageBased_LightReferenceImageBased {
  86017. light: number;
  86018. }
  86019. /** @hidden */
  86020. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86021. intensity: number;
  86022. rotation: number[];
  86023. specularImageSize: number;
  86024. specularImages: number[][];
  86025. irradianceCoefficients: number[][];
  86026. }
  86027. /** @hidden */
  86028. interface IEXTLightsImageBased {
  86029. lights: IEXTLightsImageBased_LightImageBased[];
  86030. }
  86031. /**
  86032. * Interfaces from the EXT_mesh_gpu_instancing extension
  86033. * !!! Experimental Extension Subject to Changes !!!
  86034. */
  86035. /** @hidden */
  86036. interface IEXTMeshGpuInstancing {
  86037. mesh?: number;
  86038. attributes: { [name: string]: number };
  86039. }
  86040. /**
  86041. * Interfaces from the KHR_draco_mesh_compression extension
  86042. */
  86043. /** @hidden */
  86044. interface IKHRDracoMeshCompression {
  86045. bufferView: number;
  86046. attributes: { [name: string]: number };
  86047. }
  86048. /**
  86049. * Interfaces from the KHR_lights_punctual extension
  86050. */
  86051. /** @hidden */
  86052. const enum IKHRLightsPunctual_LightType {
  86053. DIRECTIONAL = "directional",
  86054. POINT = "point",
  86055. SPOT = "spot"
  86056. }
  86057. /** @hidden */
  86058. interface IKHRLightsPunctual_LightReference {
  86059. light: number;
  86060. }
  86061. /** @hidden */
  86062. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86063. type: IKHRLightsPunctual_LightType;
  86064. color?: number[];
  86065. intensity?: number;
  86066. range?: number;
  86067. spot?: {
  86068. innerConeAngle?: number;
  86069. outerConeAngle?: number;
  86070. };
  86071. }
  86072. /** @hidden */
  86073. interface IKHRLightsPunctual {
  86074. lights: IKHRLightsPunctual_Light[];
  86075. }
  86076. /**
  86077. * Interfaces from the KHR_materials_clearcoat extension
  86078. * !!! Experimental Extension Subject to Changes !!!
  86079. */
  86080. /** @hidden */
  86081. interface IKHRMaterialsClearcoat {
  86082. clearcoatFactor: number;
  86083. clearcoatTexture: ITextureInfo;
  86084. clearcoatRoughnessFactor: number;
  86085. clearcoatRoughnessTexture: ITextureInfo;
  86086. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86087. }
  86088. /**
  86089. * Interfaces from the KHR_materials_ior extension
  86090. * !!! Experimental Extension Subject to Changes !!!
  86091. */
  86092. /** @hidden */
  86093. interface IKHRMaterialsIor {
  86094. ior: number;
  86095. }
  86096. /**
  86097. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86098. */
  86099. /** @hidden */
  86100. interface IKHRMaterialsPbrSpecularGlossiness {
  86101. diffuseFactor: number[];
  86102. diffuseTexture: ITextureInfo;
  86103. specularFactor: number[];
  86104. glossinessFactor: number;
  86105. specularGlossinessTexture: ITextureInfo;
  86106. }
  86107. /**
  86108. * Interfaces from the KHR_materials_sheen extension
  86109. * !!! Experimental Extension Subject to Changes !!!
  86110. */
  86111. /** @hidden */
  86112. interface IKHRMaterialsSheen {
  86113. sheenColorFactor?: number[];
  86114. sheenColorTexture?: ITextureInfo;
  86115. sheenRoughnessFactor?: number;
  86116. sheenRoughnessTexture?: ITextureInfo;
  86117. }
  86118. /**
  86119. * Interfaces from the KHR_materials_specular extension
  86120. * !!! Experimental Extension Subject to Changes !!!
  86121. */
  86122. /** @hidden */
  86123. interface IKHRMaterialsSpecular {
  86124. specularFactor: number;
  86125. specularColorFactor: number[];
  86126. specularTexture: ITextureInfo;
  86127. }
  86128. /**
  86129. * Interfaces from the KHR_materials_transmission extension
  86130. * !!! Experimental Extension Subject to Changes !!!
  86131. */
  86132. /** @hidden */
  86133. interface IKHRMaterialsTransmission {
  86134. transmissionFactor?: number;
  86135. transmissionTexture?: ITextureInfo;
  86136. }
  86137. /**
  86138. * Interfaces from the KHR_materials_variants extension
  86139. * !!! Experimental Extension Subject to Changes !!!
  86140. */
  86141. /** @hidden */
  86142. interface IKHRMaterialVariants_Mapping extends IProperty {
  86143. mappings: Array<{
  86144. variants: number[];
  86145. material: number;
  86146. }>;
  86147. }
  86148. /** @hidden */
  86149. interface IKHRMaterialVariants_Variant extends IProperty {
  86150. name: string;
  86151. }
  86152. /** @hidden */
  86153. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86154. variants: Array<IKHRMaterialVariants_Variant>;
  86155. }
  86156. /**
  86157. * Interfaces from the KHR_texture_basisu extension
  86158. * !!! Experimental Extension Subject to Changes !!!
  86159. */
  86160. /** @hidden */
  86161. interface IKHRTextureBasisU {
  86162. source: number;
  86163. }
  86164. /**
  86165. * Interfaces from the EXT_texture_webp extension
  86166. */
  86167. /** @hidden */
  86168. interface IEXTTextureWebP {
  86169. source: number;
  86170. }
  86171. /**
  86172. * Interfaces from the KHR_texture_transform extension
  86173. */
  86174. /** @hidden */
  86175. interface IKHRTextureTransform {
  86176. offset?: number[];
  86177. rotation?: number;
  86178. scale?: number[];
  86179. texCoord?: number;
  86180. }
  86181. /**
  86182. * Interfaces from the KHR_xmp extension
  86183. * !!! Experimental Extension Subject to Changes !!!
  86184. */
  86185. /** @hidden */
  86186. interface IKHRXmp_Data {
  86187. [key: string]: unknown;
  86188. }
  86189. /** @hidden */
  86190. interface IKHRXmp_Gltf {
  86191. packets: IKHRXmp_Data[];
  86192. }
  86193. /** @hidden */
  86194. interface IKHRXmp_Node {
  86195. packet: number;
  86196. }
  86197. /**
  86198. * Interfaces from the MSFT_audio_emitter extension
  86199. */
  86200. /** @hidden */
  86201. interface IMSFTAudioEmitter_ClipReference {
  86202. clip: number;
  86203. weight?: number;
  86204. }
  86205. /** @hidden */
  86206. interface IMSFTAudioEmitter_EmittersReference {
  86207. emitters: number[];
  86208. }
  86209. /** @hidden */
  86210. const enum IMSFTAudioEmitter_DistanceModel {
  86211. linear = "linear",
  86212. inverse = "inverse",
  86213. exponential = "exponential",
  86214. }
  86215. /** @hidden */
  86216. interface IMSFTAudioEmitter_Emitter {
  86217. name?: string;
  86218. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86219. refDistance?: number;
  86220. maxDistance?: number;
  86221. rolloffFactor?: number;
  86222. innerAngle?: number;
  86223. outerAngle?: number;
  86224. loop?: boolean;
  86225. volume?: number;
  86226. clips: IMSFTAudioEmitter_ClipReference[];
  86227. }
  86228. /** @hidden */
  86229. const enum IMSFTAudioEmitter_AudioMimeType {
  86230. WAV = "audio/wav",
  86231. }
  86232. /** @hidden */
  86233. interface IMSFTAudioEmitter_Clip extends IProperty {
  86234. uri?: string;
  86235. bufferView?: number;
  86236. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86237. }
  86238. /** @hidden */
  86239. const enum IMSFTAudioEmitter_AnimationEventAction {
  86240. play = "play",
  86241. pause = "pause",
  86242. stop = "stop",
  86243. }
  86244. /** @hidden */
  86245. interface IMSFTAudioEmitter_AnimationEvent {
  86246. action: IMSFTAudioEmitter_AnimationEventAction;
  86247. emitter: number;
  86248. time: number;
  86249. startOffset?: number;
  86250. }
  86251. /**
  86252. * Interfaces from the MSFT_lod extension
  86253. */
  86254. /** @hidden */
  86255. interface IMSFTLOD {
  86256. ids: number[];
  86257. }
  86258. }
  86259. declare module BABYLON {
  86260. /** @hidden */
  86261. export var cellPixelShader: {
  86262. name: string;
  86263. shader: string;
  86264. };
  86265. }
  86266. declare module BABYLON {
  86267. /** @hidden */
  86268. export var cellVertexShader: {
  86269. name: string;
  86270. shader: string;
  86271. };
  86272. }
  86273. declare module BABYLON {
  86274. export class CellMaterial extends BABYLON.PushMaterial {
  86275. private _diffuseTexture;
  86276. diffuseTexture: BABYLON.BaseTexture;
  86277. diffuseColor: BABYLON.Color3;
  86278. _computeHighLevel: boolean;
  86279. computeHighLevel: boolean;
  86280. private _disableLighting;
  86281. disableLighting: boolean;
  86282. private _maxSimultaneousLights;
  86283. maxSimultaneousLights: number;
  86284. constructor(name: string, scene: BABYLON.Scene);
  86285. needAlphaBlending(): boolean;
  86286. needAlphaTesting(): boolean;
  86287. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86288. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86289. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86290. getAnimatables(): BABYLON.IAnimatable[];
  86291. getActiveTextures(): BABYLON.BaseTexture[];
  86292. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86293. dispose(forceDisposeEffect?: boolean): void;
  86294. getClassName(): string;
  86295. clone(name: string): CellMaterial;
  86296. serialize(): any;
  86297. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86298. }
  86299. }
  86300. declare module BABYLON {
  86301. export class CustomShaderStructure {
  86302. FragmentStore: string;
  86303. VertexStore: string;
  86304. constructor();
  86305. }
  86306. export class ShaderSpecialParts {
  86307. constructor();
  86308. Fragment_Begin: string;
  86309. Fragment_Definitions: string;
  86310. Fragment_MainBegin: string;
  86311. Fragment_Custom_Diffuse: string;
  86312. Fragment_Before_Lights: string;
  86313. Fragment_Before_Fog: string;
  86314. Fragment_Custom_Alpha: string;
  86315. Fragment_Before_FragColor: string;
  86316. Vertex_Begin: string;
  86317. Vertex_Definitions: string;
  86318. Vertex_MainBegin: string;
  86319. Vertex_Before_PositionUpdated: string;
  86320. Vertex_Before_NormalUpdated: string;
  86321. Vertex_After_WorldPosComputed: string;
  86322. Vertex_MainEnd: string;
  86323. }
  86324. export class CustomMaterial extends BABYLON.StandardMaterial {
  86325. static ShaderIndexer: number;
  86326. CustomParts: ShaderSpecialParts;
  86327. _isCreatedShader: boolean;
  86328. _createdShaderName: string;
  86329. _customUniform: string[];
  86330. _newUniforms: string[];
  86331. _newUniformInstances: {
  86332. [name: string]: any;
  86333. };
  86334. _newSamplerInstances: {
  86335. [name: string]: BABYLON.Texture;
  86336. };
  86337. _customAttributes: string[];
  86338. FragmentShader: string;
  86339. VertexShader: string;
  86340. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86341. ReviewUniform(name: string, arr: string[]): string[];
  86342. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86343. constructor(name: string, scene: BABYLON.Scene);
  86344. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86345. AddAttribute(name: string): CustomMaterial;
  86346. Fragment_Begin(shaderPart: string): CustomMaterial;
  86347. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86348. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86349. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86350. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86351. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86352. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86353. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86354. Vertex_Begin(shaderPart: string): CustomMaterial;
  86355. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86356. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86357. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86358. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86359. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86360. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86361. }
  86362. }
  86363. declare module BABYLON {
  86364. export class ShaderAlebdoParts {
  86365. constructor();
  86366. Fragment_Begin: string;
  86367. Fragment_Definitions: string;
  86368. Fragment_MainBegin: string;
  86369. Fragment_Custom_Albedo: string;
  86370. Fragment_Before_Lights: string;
  86371. Fragment_Custom_MetallicRoughness: string;
  86372. Fragment_Custom_MicroSurface: string;
  86373. Fragment_Before_Fog: string;
  86374. Fragment_Custom_Alpha: string;
  86375. Fragment_Before_FragColor: string;
  86376. Vertex_Begin: string;
  86377. Vertex_Definitions: string;
  86378. Vertex_MainBegin: string;
  86379. Vertex_Before_PositionUpdated: string;
  86380. Vertex_Before_NormalUpdated: string;
  86381. Vertex_After_WorldPosComputed: string;
  86382. Vertex_MainEnd: string;
  86383. }
  86384. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86385. static ShaderIndexer: number;
  86386. CustomParts: ShaderAlebdoParts;
  86387. _isCreatedShader: boolean;
  86388. _createdShaderName: string;
  86389. _customUniform: string[];
  86390. _newUniforms: string[];
  86391. _newUniformInstances: {
  86392. [name: string]: any;
  86393. };
  86394. _newSamplerInstances: {
  86395. [name: string]: BABYLON.Texture;
  86396. };
  86397. _customAttributes: string[];
  86398. FragmentShader: string;
  86399. VertexShader: string;
  86400. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86401. ReviewUniform(name: string, arr: string[]): string[];
  86402. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86403. constructor(name: string, scene: BABYLON.Scene);
  86404. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86405. AddAttribute(name: string): PBRCustomMaterial;
  86406. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86407. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86408. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86409. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86410. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86411. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86412. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86413. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86414. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86415. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86416. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86417. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86418. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86419. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86420. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86421. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86422. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86423. }
  86424. }
  86425. declare module BABYLON {
  86426. /** @hidden */
  86427. export var firePixelShader: {
  86428. name: string;
  86429. shader: string;
  86430. };
  86431. }
  86432. declare module BABYLON {
  86433. /** @hidden */
  86434. export var fireVertexShader: {
  86435. name: string;
  86436. shader: string;
  86437. };
  86438. }
  86439. declare module BABYLON {
  86440. export class FireMaterial extends BABYLON.PushMaterial {
  86441. private _diffuseTexture;
  86442. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86443. private _distortionTexture;
  86444. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86445. private _opacityTexture;
  86446. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86447. diffuseColor: BABYLON.Color3;
  86448. speed: number;
  86449. private _scaledDiffuse;
  86450. private _lastTime;
  86451. constructor(name: string, scene: BABYLON.Scene);
  86452. needAlphaBlending(): boolean;
  86453. needAlphaTesting(): boolean;
  86454. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86455. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86456. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86457. getAnimatables(): BABYLON.IAnimatable[];
  86458. getActiveTextures(): BABYLON.BaseTexture[];
  86459. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86460. getClassName(): string;
  86461. dispose(forceDisposeEffect?: boolean): void;
  86462. clone(name: string): FireMaterial;
  86463. serialize(): any;
  86464. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86465. }
  86466. }
  86467. declare module BABYLON {
  86468. /** @hidden */
  86469. export var furPixelShader: {
  86470. name: string;
  86471. shader: string;
  86472. };
  86473. }
  86474. declare module BABYLON {
  86475. /** @hidden */
  86476. export var furVertexShader: {
  86477. name: string;
  86478. shader: string;
  86479. };
  86480. }
  86481. declare module BABYLON {
  86482. export class FurMaterial extends BABYLON.PushMaterial {
  86483. private _diffuseTexture;
  86484. diffuseTexture: BABYLON.BaseTexture;
  86485. private _heightTexture;
  86486. heightTexture: BABYLON.BaseTexture;
  86487. diffuseColor: BABYLON.Color3;
  86488. furLength: number;
  86489. furAngle: number;
  86490. furColor: BABYLON.Color3;
  86491. furOffset: number;
  86492. furSpacing: number;
  86493. furGravity: BABYLON.Vector3;
  86494. furSpeed: number;
  86495. furDensity: number;
  86496. furOcclusion: number;
  86497. furTexture: BABYLON.DynamicTexture;
  86498. private _disableLighting;
  86499. disableLighting: boolean;
  86500. private _maxSimultaneousLights;
  86501. maxSimultaneousLights: number;
  86502. highLevelFur: boolean;
  86503. _meshes: BABYLON.AbstractMesh[];
  86504. private _furTime;
  86505. constructor(name: string, scene: BABYLON.Scene);
  86506. get furTime(): number;
  86507. set furTime(furTime: number);
  86508. needAlphaBlending(): boolean;
  86509. needAlphaTesting(): boolean;
  86510. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86511. updateFur(): void;
  86512. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86513. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86514. getAnimatables(): BABYLON.IAnimatable[];
  86515. getActiveTextures(): BABYLON.BaseTexture[];
  86516. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86517. dispose(forceDisposeEffect?: boolean): void;
  86518. clone(name: string): FurMaterial;
  86519. serialize(): any;
  86520. getClassName(): string;
  86521. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86522. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86523. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86524. }
  86525. }
  86526. declare module BABYLON {
  86527. /** @hidden */
  86528. export var gradientPixelShader: {
  86529. name: string;
  86530. shader: string;
  86531. };
  86532. }
  86533. declare module BABYLON {
  86534. /** @hidden */
  86535. export var gradientVertexShader: {
  86536. name: string;
  86537. shader: string;
  86538. };
  86539. }
  86540. declare module BABYLON {
  86541. export class GradientMaterial extends BABYLON.PushMaterial {
  86542. private _maxSimultaneousLights;
  86543. maxSimultaneousLights: number;
  86544. topColor: BABYLON.Color3;
  86545. topColorAlpha: number;
  86546. bottomColor: BABYLON.Color3;
  86547. bottomColorAlpha: number;
  86548. offset: number;
  86549. scale: number;
  86550. smoothness: number;
  86551. private _disableLighting;
  86552. disableLighting: boolean;
  86553. constructor(name: string, scene: BABYLON.Scene);
  86554. needAlphaBlending(): boolean;
  86555. needAlphaTesting(): boolean;
  86556. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86557. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86558. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86559. getAnimatables(): BABYLON.IAnimatable[];
  86560. dispose(forceDisposeEffect?: boolean): void;
  86561. clone(name: string): GradientMaterial;
  86562. serialize(): any;
  86563. getClassName(): string;
  86564. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86565. }
  86566. }
  86567. declare module BABYLON {
  86568. /** @hidden */
  86569. export var gridPixelShader: {
  86570. name: string;
  86571. shader: string;
  86572. };
  86573. }
  86574. declare module BABYLON {
  86575. /** @hidden */
  86576. export var gridVertexShader: {
  86577. name: string;
  86578. shader: string;
  86579. };
  86580. }
  86581. declare module BABYLON {
  86582. /**
  86583. * The grid materials allows you to wrap any shape with a grid.
  86584. * Colors are customizable.
  86585. */
  86586. export class GridMaterial extends BABYLON.PushMaterial {
  86587. /**
  86588. * Main color of the grid (e.g. between lines)
  86589. */
  86590. mainColor: BABYLON.Color3;
  86591. /**
  86592. * Color of the grid lines.
  86593. */
  86594. lineColor: BABYLON.Color3;
  86595. /**
  86596. * The scale of the grid compared to unit.
  86597. */
  86598. gridRatio: number;
  86599. /**
  86600. * Allows setting an offset for the grid lines.
  86601. */
  86602. gridOffset: BABYLON.Vector3;
  86603. /**
  86604. * The frequency of thicker lines.
  86605. */
  86606. majorUnitFrequency: number;
  86607. /**
  86608. * The visibility of minor units in the grid.
  86609. */
  86610. minorUnitVisibility: number;
  86611. /**
  86612. * The grid opacity outside of the lines.
  86613. */
  86614. opacity: number;
  86615. /**
  86616. * Determine RBG output is premultiplied by alpha value.
  86617. */
  86618. preMultiplyAlpha: boolean;
  86619. private _opacityTexture;
  86620. opacityTexture: BABYLON.BaseTexture;
  86621. private _gridControl;
  86622. /**
  86623. * constructor
  86624. * @param name The name given to the material in order to identify it afterwards.
  86625. * @param scene The scene the material is used in.
  86626. */
  86627. constructor(name: string, scene: BABYLON.Scene);
  86628. /**
  86629. * Returns wehter or not the grid requires alpha blending.
  86630. */
  86631. needAlphaBlending(): boolean;
  86632. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86633. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86634. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86635. /**
  86636. * Dispose the material and its associated resources.
  86637. * @param forceDisposeEffect will also dispose the used effect when true
  86638. */
  86639. dispose(forceDisposeEffect?: boolean): void;
  86640. clone(name: string): GridMaterial;
  86641. serialize(): any;
  86642. getClassName(): string;
  86643. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86644. }
  86645. }
  86646. declare module BABYLON {
  86647. /** @hidden */
  86648. export var lavaPixelShader: {
  86649. name: string;
  86650. shader: string;
  86651. };
  86652. }
  86653. declare module BABYLON {
  86654. /** @hidden */
  86655. export var lavaVertexShader: {
  86656. name: string;
  86657. shader: string;
  86658. };
  86659. }
  86660. declare module BABYLON {
  86661. export class LavaMaterial extends BABYLON.PushMaterial {
  86662. private _diffuseTexture;
  86663. diffuseTexture: BABYLON.BaseTexture;
  86664. noiseTexture: BABYLON.BaseTexture;
  86665. fogColor: BABYLON.Color3;
  86666. speed: number;
  86667. movingSpeed: number;
  86668. lowFrequencySpeed: number;
  86669. fogDensity: number;
  86670. private _lastTime;
  86671. diffuseColor: BABYLON.Color3;
  86672. private _disableLighting;
  86673. disableLighting: boolean;
  86674. private _unlit;
  86675. unlit: boolean;
  86676. private _maxSimultaneousLights;
  86677. maxSimultaneousLights: number;
  86678. private _scaledDiffuse;
  86679. constructor(name: string, scene: BABYLON.Scene);
  86680. needAlphaBlending(): boolean;
  86681. needAlphaTesting(): boolean;
  86682. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86683. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86684. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86685. getAnimatables(): BABYLON.IAnimatable[];
  86686. getActiveTextures(): BABYLON.BaseTexture[];
  86687. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86688. dispose(forceDisposeEffect?: boolean): void;
  86689. clone(name: string): LavaMaterial;
  86690. serialize(): any;
  86691. getClassName(): string;
  86692. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86693. }
  86694. }
  86695. declare module BABYLON {
  86696. /** @hidden */
  86697. export var mixPixelShader: {
  86698. name: string;
  86699. shader: string;
  86700. };
  86701. }
  86702. declare module BABYLON {
  86703. /** @hidden */
  86704. export var mixVertexShader: {
  86705. name: string;
  86706. shader: string;
  86707. };
  86708. }
  86709. declare module BABYLON {
  86710. export class MixMaterial extends BABYLON.PushMaterial {
  86711. /**
  86712. * Mix textures
  86713. */
  86714. private _mixTexture1;
  86715. mixTexture1: BABYLON.BaseTexture;
  86716. private _mixTexture2;
  86717. mixTexture2: BABYLON.BaseTexture;
  86718. /**
  86719. * Diffuse textures
  86720. */
  86721. private _diffuseTexture1;
  86722. diffuseTexture1: BABYLON.Texture;
  86723. private _diffuseTexture2;
  86724. diffuseTexture2: BABYLON.Texture;
  86725. private _diffuseTexture3;
  86726. diffuseTexture3: BABYLON.Texture;
  86727. private _diffuseTexture4;
  86728. diffuseTexture4: BABYLON.Texture;
  86729. private _diffuseTexture5;
  86730. diffuseTexture5: BABYLON.Texture;
  86731. private _diffuseTexture6;
  86732. diffuseTexture6: BABYLON.Texture;
  86733. private _diffuseTexture7;
  86734. diffuseTexture7: BABYLON.Texture;
  86735. private _diffuseTexture8;
  86736. diffuseTexture8: BABYLON.Texture;
  86737. /**
  86738. * Uniforms
  86739. */
  86740. diffuseColor: BABYLON.Color3;
  86741. specularColor: BABYLON.Color3;
  86742. specularPower: number;
  86743. private _disableLighting;
  86744. disableLighting: boolean;
  86745. private _maxSimultaneousLights;
  86746. maxSimultaneousLights: number;
  86747. constructor(name: string, scene: BABYLON.Scene);
  86748. needAlphaBlending(): boolean;
  86749. needAlphaTesting(): boolean;
  86750. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86751. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86752. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86753. getAnimatables(): BABYLON.IAnimatable[];
  86754. getActiveTextures(): BABYLON.BaseTexture[];
  86755. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86756. dispose(forceDisposeEffect?: boolean): void;
  86757. clone(name: string): MixMaterial;
  86758. serialize(): any;
  86759. getClassName(): string;
  86760. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86761. }
  86762. }
  86763. declare module BABYLON {
  86764. /** @hidden */
  86765. export var normalPixelShader: {
  86766. name: string;
  86767. shader: string;
  86768. };
  86769. }
  86770. declare module BABYLON {
  86771. /** @hidden */
  86772. export var normalVertexShader: {
  86773. name: string;
  86774. shader: string;
  86775. };
  86776. }
  86777. declare module BABYLON {
  86778. export class NormalMaterial extends BABYLON.PushMaterial {
  86779. private _diffuseTexture;
  86780. diffuseTexture: BABYLON.BaseTexture;
  86781. diffuseColor: BABYLON.Color3;
  86782. private _disableLighting;
  86783. disableLighting: boolean;
  86784. private _maxSimultaneousLights;
  86785. maxSimultaneousLights: number;
  86786. constructor(name: string, scene: BABYLON.Scene);
  86787. needAlphaBlending(): boolean;
  86788. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86789. needAlphaTesting(): boolean;
  86790. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86791. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86792. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86793. getAnimatables(): BABYLON.IAnimatable[];
  86794. getActiveTextures(): BABYLON.BaseTexture[];
  86795. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86796. dispose(forceDisposeEffect?: boolean): void;
  86797. clone(name: string): NormalMaterial;
  86798. serialize(): any;
  86799. getClassName(): string;
  86800. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86801. }
  86802. }
  86803. declare module BABYLON {
  86804. /** @hidden */
  86805. export var shadowOnlyPixelShader: {
  86806. name: string;
  86807. shader: string;
  86808. };
  86809. }
  86810. declare module BABYLON {
  86811. /** @hidden */
  86812. export var shadowOnlyVertexShader: {
  86813. name: string;
  86814. shader: string;
  86815. };
  86816. }
  86817. declare module BABYLON {
  86818. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86819. private _activeLight;
  86820. private _needAlphaBlending;
  86821. constructor(name: string, scene: BABYLON.Scene);
  86822. shadowColor: BABYLON.Color3;
  86823. needAlphaBlending(): boolean;
  86824. needAlphaTesting(): boolean;
  86825. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86826. get activeLight(): BABYLON.IShadowLight;
  86827. set activeLight(light: BABYLON.IShadowLight);
  86828. private _getFirstShadowLightForMesh;
  86829. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86830. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86831. clone(name: string): ShadowOnlyMaterial;
  86832. serialize(): any;
  86833. getClassName(): string;
  86834. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86835. }
  86836. }
  86837. declare module BABYLON {
  86838. /** @hidden */
  86839. export var simplePixelShader: {
  86840. name: string;
  86841. shader: string;
  86842. };
  86843. }
  86844. declare module BABYLON {
  86845. /** @hidden */
  86846. export var simpleVertexShader: {
  86847. name: string;
  86848. shader: string;
  86849. };
  86850. }
  86851. declare module BABYLON {
  86852. export class SimpleMaterial extends BABYLON.PushMaterial {
  86853. private _diffuseTexture;
  86854. diffuseTexture: BABYLON.BaseTexture;
  86855. diffuseColor: BABYLON.Color3;
  86856. private _disableLighting;
  86857. disableLighting: boolean;
  86858. private _maxSimultaneousLights;
  86859. maxSimultaneousLights: number;
  86860. constructor(name: string, scene: BABYLON.Scene);
  86861. needAlphaBlending(): boolean;
  86862. needAlphaTesting(): boolean;
  86863. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86864. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86865. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86866. getAnimatables(): BABYLON.IAnimatable[];
  86867. getActiveTextures(): BABYLON.BaseTexture[];
  86868. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86869. dispose(forceDisposeEffect?: boolean): void;
  86870. clone(name: string): SimpleMaterial;
  86871. serialize(): any;
  86872. getClassName(): string;
  86873. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86874. }
  86875. }
  86876. declare module BABYLON {
  86877. /** @hidden */
  86878. export var skyPixelShader: {
  86879. name: string;
  86880. shader: string;
  86881. };
  86882. }
  86883. declare module BABYLON {
  86884. /** @hidden */
  86885. export var skyVertexShader: {
  86886. name: string;
  86887. shader: string;
  86888. };
  86889. }
  86890. declare module BABYLON {
  86891. /**
  86892. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86893. * @see https://doc.babylonjs.com/extensions/sky
  86894. */
  86895. export class SkyMaterial extends BABYLON.PushMaterial {
  86896. /**
  86897. * Defines the overall luminance of sky in interval ]0, 1[.
  86898. */
  86899. luminance: number;
  86900. /**
  86901. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86902. */
  86903. turbidity: number;
  86904. /**
  86905. * Defines the sky appearance (light intensity).
  86906. */
  86907. rayleigh: number;
  86908. /**
  86909. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86910. */
  86911. mieCoefficient: number;
  86912. /**
  86913. * Defines the amount of haze particles following the Mie scattering theory.
  86914. */
  86915. mieDirectionalG: number;
  86916. /**
  86917. * Defines the distance of the sun according to the active scene camera.
  86918. */
  86919. distance: number;
  86920. /**
  86921. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86922. * "inclined".
  86923. */
  86924. inclination: number;
  86925. /**
  86926. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86927. * an object direction and a reference direction.
  86928. */
  86929. azimuth: number;
  86930. /**
  86931. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86932. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86933. */
  86934. sunPosition: BABYLON.Vector3;
  86935. /**
  86936. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86937. * .sunPosition property.
  86938. */
  86939. useSunPosition: boolean;
  86940. /**
  86941. * Defines an offset vector used to get a horizon offset.
  86942. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86943. */
  86944. cameraOffset: BABYLON.Vector3;
  86945. private _cameraPosition;
  86946. /**
  86947. * Instantiates a new sky material.
  86948. * This material allows to create dynamic and texture free
  86949. * effects for skyboxes by taking care of the atmosphere state.
  86950. * @see https://doc.babylonjs.com/extensions/sky
  86951. * @param name Define the name of the material in the scene
  86952. * @param scene Define the scene the material belong to
  86953. */
  86954. constructor(name: string, scene: BABYLON.Scene);
  86955. /**
  86956. * Specifies if the material will require alpha blending
  86957. * @returns a boolean specifying if alpha blending is needed
  86958. */
  86959. needAlphaBlending(): boolean;
  86960. /**
  86961. * Specifies if this material should be rendered in alpha test mode
  86962. * @returns false as the sky material doesn't need alpha testing.
  86963. */
  86964. needAlphaTesting(): boolean;
  86965. /**
  86966. * Get the texture used for alpha test purpose.
  86967. * @returns null as the sky material has no texture.
  86968. */
  86969. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86970. /**
  86971. * Get if the submesh is ready to be used and all its information available.
  86972. * Child classes can use it to update shaders
  86973. * @param mesh defines the mesh to check
  86974. * @param subMesh defines which submesh to check
  86975. * @param useInstances specifies that instances should be used
  86976. * @returns a boolean indicating that the submesh is ready or not
  86977. */
  86978. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86979. /**
  86980. * Binds the submesh to this material by preparing the effect and shader to draw
  86981. * @param world defines the world transformation matrix
  86982. * @param mesh defines the mesh containing the submesh
  86983. * @param subMesh defines the submesh to bind the material to
  86984. */
  86985. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86986. /**
  86987. * Get the list of animatables in the material.
  86988. * @returns the list of animatables object used in the material
  86989. */
  86990. getAnimatables(): BABYLON.IAnimatable[];
  86991. /**
  86992. * Disposes the material
  86993. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86994. */
  86995. dispose(forceDisposeEffect?: boolean): void;
  86996. /**
  86997. * Makes a duplicate of the material, and gives it a new name
  86998. * @param name defines the new name for the duplicated material
  86999. * @returns the cloned material
  87000. */
  87001. clone(name: string): SkyMaterial;
  87002. /**
  87003. * Serializes this material in a JSON representation
  87004. * @returns the serialized material object
  87005. */
  87006. serialize(): any;
  87007. /**
  87008. * Gets the current class name of the material e.g. "SkyMaterial"
  87009. * Mainly use in serialization.
  87010. * @returns the class name
  87011. */
  87012. getClassName(): string;
  87013. /**
  87014. * Creates a sky material from parsed material data
  87015. * @param source defines the JSON representation of the material
  87016. * @param scene defines the hosting scene
  87017. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87018. * @returns a new sky material
  87019. */
  87020. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87021. }
  87022. }
  87023. declare module BABYLON {
  87024. /** @hidden */
  87025. export var terrainPixelShader: {
  87026. name: string;
  87027. shader: string;
  87028. };
  87029. }
  87030. declare module BABYLON {
  87031. /** @hidden */
  87032. export var terrainVertexShader: {
  87033. name: string;
  87034. shader: string;
  87035. };
  87036. }
  87037. declare module BABYLON {
  87038. export class TerrainMaterial extends BABYLON.PushMaterial {
  87039. private _mixTexture;
  87040. mixTexture: BABYLON.BaseTexture;
  87041. private _diffuseTexture1;
  87042. diffuseTexture1: BABYLON.Texture;
  87043. private _diffuseTexture2;
  87044. diffuseTexture2: BABYLON.Texture;
  87045. private _diffuseTexture3;
  87046. diffuseTexture3: BABYLON.Texture;
  87047. private _bumpTexture1;
  87048. bumpTexture1: BABYLON.Texture;
  87049. private _bumpTexture2;
  87050. bumpTexture2: BABYLON.Texture;
  87051. private _bumpTexture3;
  87052. bumpTexture3: BABYLON.Texture;
  87053. diffuseColor: BABYLON.Color3;
  87054. specularColor: BABYLON.Color3;
  87055. specularPower: number;
  87056. private _disableLighting;
  87057. disableLighting: boolean;
  87058. private _maxSimultaneousLights;
  87059. maxSimultaneousLights: number;
  87060. constructor(name: string, scene: BABYLON.Scene);
  87061. needAlphaBlending(): boolean;
  87062. needAlphaTesting(): boolean;
  87063. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87064. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87065. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87066. getAnimatables(): BABYLON.IAnimatable[];
  87067. getActiveTextures(): BABYLON.BaseTexture[];
  87068. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87069. dispose(forceDisposeEffect?: boolean): void;
  87070. clone(name: string): TerrainMaterial;
  87071. serialize(): any;
  87072. getClassName(): string;
  87073. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87074. }
  87075. }
  87076. declare module BABYLON {
  87077. /** @hidden */
  87078. export var triplanarPixelShader: {
  87079. name: string;
  87080. shader: string;
  87081. };
  87082. }
  87083. declare module BABYLON {
  87084. /** @hidden */
  87085. export var triplanarVertexShader: {
  87086. name: string;
  87087. shader: string;
  87088. };
  87089. }
  87090. declare module BABYLON {
  87091. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87092. mixTexture: BABYLON.BaseTexture;
  87093. private _diffuseTextureX;
  87094. diffuseTextureX: BABYLON.BaseTexture;
  87095. private _diffuseTextureY;
  87096. diffuseTextureY: BABYLON.BaseTexture;
  87097. private _diffuseTextureZ;
  87098. diffuseTextureZ: BABYLON.BaseTexture;
  87099. private _normalTextureX;
  87100. normalTextureX: BABYLON.BaseTexture;
  87101. private _normalTextureY;
  87102. normalTextureY: BABYLON.BaseTexture;
  87103. private _normalTextureZ;
  87104. normalTextureZ: BABYLON.BaseTexture;
  87105. tileSize: number;
  87106. diffuseColor: BABYLON.Color3;
  87107. specularColor: BABYLON.Color3;
  87108. specularPower: number;
  87109. private _disableLighting;
  87110. disableLighting: boolean;
  87111. private _maxSimultaneousLights;
  87112. maxSimultaneousLights: number;
  87113. constructor(name: string, scene: BABYLON.Scene);
  87114. needAlphaBlending(): boolean;
  87115. needAlphaTesting(): boolean;
  87116. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87117. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87118. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87119. getAnimatables(): BABYLON.IAnimatable[];
  87120. getActiveTextures(): BABYLON.BaseTexture[];
  87121. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87122. dispose(forceDisposeEffect?: boolean): void;
  87123. clone(name: string): TriPlanarMaterial;
  87124. serialize(): any;
  87125. getClassName(): string;
  87126. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87127. }
  87128. }
  87129. declare module BABYLON {
  87130. /** @hidden */
  87131. export var waterPixelShader: {
  87132. name: string;
  87133. shader: string;
  87134. };
  87135. }
  87136. declare module BABYLON {
  87137. /** @hidden */
  87138. export var waterVertexShader: {
  87139. name: string;
  87140. shader: string;
  87141. };
  87142. }
  87143. declare module BABYLON {
  87144. export class WaterMaterial extends BABYLON.PushMaterial {
  87145. renderTargetSize: BABYLON.Vector2;
  87146. private _bumpTexture;
  87147. bumpTexture: BABYLON.BaseTexture;
  87148. diffuseColor: BABYLON.Color3;
  87149. specularColor: BABYLON.Color3;
  87150. specularPower: number;
  87151. private _disableLighting;
  87152. disableLighting: boolean;
  87153. private _maxSimultaneousLights;
  87154. maxSimultaneousLights: number;
  87155. /**
  87156. * Defines the wind force.
  87157. */
  87158. windForce: number;
  87159. /**
  87160. * Defines the direction of the wind in the plane (X, Z).
  87161. */
  87162. windDirection: BABYLON.Vector2;
  87163. /**
  87164. * Defines the height of the waves.
  87165. */
  87166. waveHeight: number;
  87167. /**
  87168. * Defines the bump height related to the bump map.
  87169. */
  87170. bumpHeight: number;
  87171. /**
  87172. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87173. */
  87174. private _bumpSuperimpose;
  87175. bumpSuperimpose: boolean;
  87176. /**
  87177. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87178. */
  87179. private _fresnelSeparate;
  87180. fresnelSeparate: boolean;
  87181. /**
  87182. * Defines wether or not bump Wwves modify the reflection.
  87183. */
  87184. private _bumpAffectsReflection;
  87185. bumpAffectsReflection: boolean;
  87186. /**
  87187. * Defines the water color blended with the refraction (near).
  87188. */
  87189. waterColor: BABYLON.Color3;
  87190. /**
  87191. * Defines the blend factor related to the water color.
  87192. */
  87193. colorBlendFactor: number;
  87194. /**
  87195. * Defines the water color blended with the reflection (far).
  87196. */
  87197. waterColor2: BABYLON.Color3;
  87198. /**
  87199. * Defines the blend factor related to the water color (reflection, far).
  87200. */
  87201. colorBlendFactor2: number;
  87202. /**
  87203. * Defines the maximum length of a wave.
  87204. */
  87205. waveLength: number;
  87206. /**
  87207. * Defines the waves speed.
  87208. */
  87209. waveSpeed: number;
  87210. /**
  87211. * Defines the number of times waves are repeated. This is typically used to adjust waves count according to the ground's size where the material is applied on.
  87212. */
  87213. waveCount: number;
  87214. /**
  87215. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87216. * will avoid calculating useless pixels in the pixel shader of the water material.
  87217. */
  87218. disableClipPlane: boolean;
  87219. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87220. private _mesh;
  87221. private _refractionRTT;
  87222. private _reflectionRTT;
  87223. private _reflectionTransform;
  87224. private _lastTime;
  87225. private _lastDeltaTime;
  87226. private _useLogarithmicDepth;
  87227. private _waitingRenderList;
  87228. private _imageProcessingConfiguration;
  87229. private _imageProcessingObserver;
  87230. /**
  87231. * Gets a boolean indicating that current material needs to register RTT
  87232. */
  87233. get hasRenderTargetTextures(): boolean;
  87234. /**
  87235. * Constructor
  87236. */
  87237. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87238. get useLogarithmicDepth(): boolean;
  87239. set useLogarithmicDepth(value: boolean);
  87240. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87241. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87242. addToRenderList(node: any): void;
  87243. enableRenderTargets(enable: boolean): void;
  87244. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87245. get renderTargetsEnabled(): boolean;
  87246. needAlphaBlending(): boolean;
  87247. needAlphaTesting(): boolean;
  87248. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87249. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87250. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87251. private _createRenderTargets;
  87252. getAnimatables(): BABYLON.IAnimatable[];
  87253. getActiveTextures(): BABYLON.BaseTexture[];
  87254. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87255. dispose(forceDisposeEffect?: boolean): void;
  87256. clone(name: string): WaterMaterial;
  87257. serialize(): any;
  87258. getClassName(): string;
  87259. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87260. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87261. }
  87262. }
  87263. declare module BABYLON {
  87264. /** @hidden */
  87265. export var asciiartPixelShader: {
  87266. name: string;
  87267. shader: string;
  87268. };
  87269. }
  87270. declare module BABYLON {
  87271. /**
  87272. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87273. *
  87274. * It basically takes care rendering the font front the given font size to a texture.
  87275. * This is used later on in the postprocess.
  87276. */
  87277. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87278. private _font;
  87279. private _text;
  87280. private _charSize;
  87281. /**
  87282. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87283. */
  87284. get charSize(): number;
  87285. /**
  87286. * Create a new instance of the Ascii Art FontTexture class
  87287. * @param name the name of the texture
  87288. * @param font the font to use, use the W3C CSS notation
  87289. * @param text the caracter set to use in the rendering.
  87290. * @param scene the scene that owns the texture
  87291. */
  87292. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87293. /**
  87294. * Gets the max char width of a font.
  87295. * @param font the font to use, use the W3C CSS notation
  87296. * @return the max char width
  87297. */
  87298. private getFontWidth;
  87299. /**
  87300. * Gets the max char height of a font.
  87301. * @param font the font to use, use the W3C CSS notation
  87302. * @return the max char height
  87303. */
  87304. private getFontHeight;
  87305. /**
  87306. * Clones the current AsciiArtTexture.
  87307. * @return the clone of the texture.
  87308. */
  87309. clone(): AsciiArtFontTexture;
  87310. /**
  87311. * Parses a json object representing the texture and returns an instance of it.
  87312. * @param source the source JSON representation
  87313. * @param scene the scene to create the texture for
  87314. * @return the parsed texture
  87315. */
  87316. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87317. }
  87318. /**
  87319. * Option available in the Ascii Art Post Process.
  87320. */
  87321. export interface IAsciiArtPostProcessOptions {
  87322. /**
  87323. * The font to use following the w3c font definition.
  87324. */
  87325. font?: string;
  87326. /**
  87327. * The character set to use in the postprocess.
  87328. */
  87329. characterSet?: string;
  87330. /**
  87331. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87332. * This number is defined between 0 and 1;
  87333. */
  87334. mixToTile?: number;
  87335. /**
  87336. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87337. * This number is defined between 0 and 1;
  87338. */
  87339. mixToNormal?: number;
  87340. }
  87341. /**
  87342. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87343. *
  87344. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87345. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87346. */
  87347. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87348. /**
  87349. * The font texture used to render the char in the post process.
  87350. */
  87351. private _asciiArtFontTexture;
  87352. /**
  87353. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87354. * This number is defined between 0 and 1;
  87355. */
  87356. mixToTile: number;
  87357. /**
  87358. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87359. * This number is defined between 0 and 1;
  87360. */
  87361. mixToNormal: number;
  87362. /**
  87363. * Instantiates a new Ascii Art Post Process.
  87364. * @param name the name to give to the postprocess
  87365. * @camera the camera to apply the post process to.
  87366. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87367. */
  87368. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87369. }
  87370. }
  87371. declare module BABYLON {
  87372. /** @hidden */
  87373. export var digitalrainPixelShader: {
  87374. name: string;
  87375. shader: string;
  87376. };
  87377. }
  87378. declare module BABYLON {
  87379. /**
  87380. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87381. *
  87382. * It basically takes care rendering the font front the given font size to a texture.
  87383. * This is used later on in the postprocess.
  87384. */
  87385. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87386. private _font;
  87387. private _text;
  87388. private _charSize;
  87389. /**
  87390. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87391. */
  87392. get charSize(): number;
  87393. /**
  87394. * Create a new instance of the Digital Rain FontTexture class
  87395. * @param name the name of the texture
  87396. * @param font the font to use, use the W3C CSS notation
  87397. * @param text the caracter set to use in the rendering.
  87398. * @param scene the scene that owns the texture
  87399. */
  87400. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87401. /**
  87402. * Gets the max char width of a font.
  87403. * @param font the font to use, use the W3C CSS notation
  87404. * @return the max char width
  87405. */
  87406. private getFontWidth;
  87407. /**
  87408. * Gets the max char height of a font.
  87409. * @param font the font to use, use the W3C CSS notation
  87410. * @return the max char height
  87411. */
  87412. private getFontHeight;
  87413. /**
  87414. * Clones the current DigitalRainFontTexture.
  87415. * @return the clone of the texture.
  87416. */
  87417. clone(): DigitalRainFontTexture;
  87418. /**
  87419. * Parses a json object representing the texture and returns an instance of it.
  87420. * @param source the source JSON representation
  87421. * @param scene the scene to create the texture for
  87422. * @return the parsed texture
  87423. */
  87424. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87425. }
  87426. /**
  87427. * Option available in the Digital Rain Post Process.
  87428. */
  87429. export interface IDigitalRainPostProcessOptions {
  87430. /**
  87431. * The font to use following the w3c font definition.
  87432. */
  87433. font?: string;
  87434. /**
  87435. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87436. * This number is defined between 0 and 1;
  87437. */
  87438. mixToTile?: number;
  87439. /**
  87440. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87441. * This number is defined between 0 and 1;
  87442. */
  87443. mixToNormal?: number;
  87444. }
  87445. /**
  87446. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87447. *
  87448. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87449. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87450. */
  87451. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87452. /**
  87453. * The font texture used to render the char in the post process.
  87454. */
  87455. private _digitalRainFontTexture;
  87456. /**
  87457. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87458. * This number is defined between 0 and 1;
  87459. */
  87460. mixToTile: number;
  87461. /**
  87462. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87463. * This number is defined between 0 and 1;
  87464. */
  87465. mixToNormal: number;
  87466. /**
  87467. * Instantiates a new Digital Rain Post Process.
  87468. * @param name the name to give to the postprocess
  87469. * @camera the camera to apply the post process to.
  87470. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87471. */
  87472. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87473. }
  87474. }
  87475. declare module BABYLON {
  87476. /** @hidden */
  87477. export var brickProceduralTexturePixelShader: {
  87478. name: string;
  87479. shader: string;
  87480. };
  87481. }
  87482. declare module BABYLON {
  87483. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87484. private _numberOfBricksHeight;
  87485. private _numberOfBricksWidth;
  87486. private _jointColor;
  87487. private _brickColor;
  87488. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87489. updateShaderUniforms(): void;
  87490. get numberOfBricksHeight(): number;
  87491. set numberOfBricksHeight(value: number);
  87492. get numberOfBricksWidth(): number;
  87493. set numberOfBricksWidth(value: number);
  87494. get jointColor(): BABYLON.Color3;
  87495. set jointColor(value: BABYLON.Color3);
  87496. get brickColor(): BABYLON.Color3;
  87497. set brickColor(value: BABYLON.Color3);
  87498. /**
  87499. * Serializes this brick procedural texture
  87500. * @returns a serialized brick procedural texture object
  87501. */
  87502. serialize(): any;
  87503. /**
  87504. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87505. * @param parsedTexture defines parsed texture data
  87506. * @param scene defines the current scene
  87507. * @param rootUrl defines the root URL containing brick procedural texture information
  87508. * @returns a parsed Brick Procedural BABYLON.Texture
  87509. */
  87510. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87511. }
  87512. }
  87513. declare module BABYLON {
  87514. /** @hidden */
  87515. export var cloudProceduralTexturePixelShader: {
  87516. name: string;
  87517. shader: string;
  87518. };
  87519. }
  87520. declare module BABYLON {
  87521. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87522. private _skyColor;
  87523. private _cloudColor;
  87524. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87525. updateShaderUniforms(): void;
  87526. get skyColor(): BABYLON.Color4;
  87527. set skyColor(value: BABYLON.Color4);
  87528. get cloudColor(): BABYLON.Color4;
  87529. set cloudColor(value: BABYLON.Color4);
  87530. /**
  87531. * Serializes this cloud procedural texture
  87532. * @returns a serialized cloud procedural texture object
  87533. */
  87534. serialize(): any;
  87535. /**
  87536. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87537. * @param parsedTexture defines parsed texture data
  87538. * @param scene defines the current scene
  87539. * @param rootUrl defines the root URL containing cloud procedural texture information
  87540. * @returns a parsed Cloud Procedural BABYLON.Texture
  87541. */
  87542. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87543. }
  87544. }
  87545. declare module BABYLON {
  87546. /** @hidden */
  87547. export var fireProceduralTexturePixelShader: {
  87548. name: string;
  87549. shader: string;
  87550. };
  87551. }
  87552. declare module BABYLON {
  87553. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87554. private _time;
  87555. private _speed;
  87556. private _autoGenerateTime;
  87557. private _fireColors;
  87558. private _alphaThreshold;
  87559. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87560. updateShaderUniforms(): void;
  87561. render(useCameraPostProcess?: boolean): void;
  87562. static get PurpleFireColors(): BABYLON.Color3[];
  87563. static get GreenFireColors(): BABYLON.Color3[];
  87564. static get RedFireColors(): BABYLON.Color3[];
  87565. static get BlueFireColors(): BABYLON.Color3[];
  87566. get autoGenerateTime(): boolean;
  87567. set autoGenerateTime(value: boolean);
  87568. get fireColors(): BABYLON.Color3[];
  87569. set fireColors(value: BABYLON.Color3[]);
  87570. get time(): number;
  87571. set time(value: number);
  87572. get speed(): BABYLON.Vector2;
  87573. set speed(value: BABYLON.Vector2);
  87574. get alphaThreshold(): number;
  87575. set alphaThreshold(value: number);
  87576. /**
  87577. * Serializes this fire procedural texture
  87578. * @returns a serialized fire procedural texture object
  87579. */
  87580. serialize(): any;
  87581. /**
  87582. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87583. * @param parsedTexture defines parsed texture data
  87584. * @param scene defines the current scene
  87585. * @param rootUrl defines the root URL containing fire procedural texture information
  87586. * @returns a parsed Fire Procedural BABYLON.Texture
  87587. */
  87588. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87589. }
  87590. }
  87591. declare module BABYLON {
  87592. /** @hidden */
  87593. export var grassProceduralTexturePixelShader: {
  87594. name: string;
  87595. shader: string;
  87596. };
  87597. }
  87598. declare module BABYLON {
  87599. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87600. private _grassColors;
  87601. private _groundColor;
  87602. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87603. updateShaderUniforms(): void;
  87604. get grassColors(): BABYLON.Color3[];
  87605. set grassColors(value: BABYLON.Color3[]);
  87606. get groundColor(): BABYLON.Color3;
  87607. set groundColor(value: BABYLON.Color3);
  87608. /**
  87609. * Serializes this grass procedural texture
  87610. * @returns a serialized grass procedural texture object
  87611. */
  87612. serialize(): any;
  87613. /**
  87614. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87615. * @param parsedTexture defines parsed texture data
  87616. * @param scene defines the current scene
  87617. * @param rootUrl defines the root URL containing grass procedural texture information
  87618. * @returns a parsed Grass Procedural BABYLON.Texture
  87619. */
  87620. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87621. }
  87622. }
  87623. declare module BABYLON {
  87624. /** @hidden */
  87625. export var marbleProceduralTexturePixelShader: {
  87626. name: string;
  87627. shader: string;
  87628. };
  87629. }
  87630. declare module BABYLON {
  87631. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87632. private _numberOfTilesHeight;
  87633. private _numberOfTilesWidth;
  87634. private _amplitude;
  87635. private _jointColor;
  87636. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87637. updateShaderUniforms(): void;
  87638. get numberOfTilesHeight(): number;
  87639. set numberOfTilesHeight(value: number);
  87640. get amplitude(): number;
  87641. set amplitude(value: number);
  87642. get numberOfTilesWidth(): number;
  87643. set numberOfTilesWidth(value: number);
  87644. get jointColor(): BABYLON.Color3;
  87645. set jointColor(value: BABYLON.Color3);
  87646. /**
  87647. * Serializes this marble procedural texture
  87648. * @returns a serialized marble procedural texture object
  87649. */
  87650. serialize(): any;
  87651. /**
  87652. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87653. * @param parsedTexture defines parsed texture data
  87654. * @param scene defines the current scene
  87655. * @param rootUrl defines the root URL containing marble procedural texture information
  87656. * @returns a parsed Marble Procedural BABYLON.Texture
  87657. */
  87658. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87659. }
  87660. }
  87661. declare module BABYLON {
  87662. /** @hidden */
  87663. export var normalMapProceduralTexturePixelShader: {
  87664. name: string;
  87665. shader: string;
  87666. };
  87667. }
  87668. declare module BABYLON {
  87669. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87670. private _baseTexture;
  87671. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87672. updateShaderUniforms(): void;
  87673. render(useCameraPostProcess?: boolean): void;
  87674. resize(size: any, generateMipMaps: any): void;
  87675. get baseTexture(): BABYLON.Texture;
  87676. set baseTexture(texture: BABYLON.Texture);
  87677. /**
  87678. * Serializes this normal map procedural texture
  87679. * @returns a serialized normal map procedural texture object
  87680. */
  87681. serialize(): any;
  87682. /**
  87683. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87684. * @param parsedTexture defines parsed texture data
  87685. * @param scene defines the current scene
  87686. * @param rootUrl defines the root URL containing normal map procedural texture information
  87687. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87688. */
  87689. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87690. }
  87691. }
  87692. declare module BABYLON {
  87693. /** @hidden */
  87694. export var perlinNoiseProceduralTexturePixelShader: {
  87695. name: string;
  87696. shader: string;
  87697. };
  87698. }
  87699. declare module BABYLON {
  87700. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87701. time: number;
  87702. timeScale: number;
  87703. translationSpeed: number;
  87704. private _currentTranslation;
  87705. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87706. updateShaderUniforms(): void;
  87707. render(useCameraPostProcess?: boolean): void;
  87708. resize(size: any, generateMipMaps: any): void;
  87709. /**
  87710. * Serializes this perlin noise procedural texture
  87711. * @returns a serialized perlin noise procedural texture object
  87712. */
  87713. serialize(): any;
  87714. /**
  87715. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87716. * @param parsedTexture defines parsed texture data
  87717. * @param scene defines the current scene
  87718. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87719. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87720. */
  87721. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87722. }
  87723. }
  87724. declare module BABYLON {
  87725. /** @hidden */
  87726. export var roadProceduralTexturePixelShader: {
  87727. name: string;
  87728. shader: string;
  87729. };
  87730. }
  87731. declare module BABYLON {
  87732. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87733. private _roadColor;
  87734. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87735. updateShaderUniforms(): void;
  87736. get roadColor(): BABYLON.Color3;
  87737. set roadColor(value: BABYLON.Color3);
  87738. /**
  87739. * Serializes this road procedural texture
  87740. * @returns a serialized road procedural texture object
  87741. */
  87742. serialize(): any;
  87743. /**
  87744. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87745. * @param parsedTexture defines parsed texture data
  87746. * @param scene defines the current scene
  87747. * @param rootUrl defines the root URL containing road procedural texture information
  87748. * @returns a parsed Road Procedural BABYLON.Texture
  87749. */
  87750. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87751. }
  87752. }
  87753. declare module BABYLON {
  87754. /** @hidden */
  87755. export var starfieldProceduralTexturePixelShader: {
  87756. name: string;
  87757. shader: string;
  87758. };
  87759. }
  87760. declare module BABYLON {
  87761. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87762. private _time;
  87763. private _alpha;
  87764. private _beta;
  87765. private _zoom;
  87766. private _formuparam;
  87767. private _stepsize;
  87768. private _tile;
  87769. private _brightness;
  87770. private _darkmatter;
  87771. private _distfading;
  87772. private _saturation;
  87773. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87774. updateShaderUniforms(): void;
  87775. get time(): number;
  87776. set time(value: number);
  87777. get alpha(): number;
  87778. set alpha(value: number);
  87779. get beta(): number;
  87780. set beta(value: number);
  87781. get formuparam(): number;
  87782. set formuparam(value: number);
  87783. get stepsize(): number;
  87784. set stepsize(value: number);
  87785. get zoom(): number;
  87786. set zoom(value: number);
  87787. get tile(): number;
  87788. set tile(value: number);
  87789. get brightness(): number;
  87790. set brightness(value: number);
  87791. get darkmatter(): number;
  87792. set darkmatter(value: number);
  87793. get distfading(): number;
  87794. set distfading(value: number);
  87795. get saturation(): number;
  87796. set saturation(value: number);
  87797. /**
  87798. * Serializes this starfield procedural texture
  87799. * @returns a serialized starfield procedural texture object
  87800. */
  87801. serialize(): any;
  87802. /**
  87803. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87804. * @param parsedTexture defines parsed texture data
  87805. * @param scene defines the current scene
  87806. * @param rootUrl defines the root URL containing startfield procedural texture information
  87807. * @returns a parsed Starfield Procedural BABYLON.Texture
  87808. */
  87809. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87810. }
  87811. }
  87812. declare module BABYLON {
  87813. /** @hidden */
  87814. export var woodProceduralTexturePixelShader: {
  87815. name: string;
  87816. shader: string;
  87817. };
  87818. }
  87819. declare module BABYLON {
  87820. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87821. private _ampScale;
  87822. private _woodColor;
  87823. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87824. updateShaderUniforms(): void;
  87825. get ampScale(): number;
  87826. set ampScale(value: number);
  87827. get woodColor(): BABYLON.Color3;
  87828. set woodColor(value: BABYLON.Color3);
  87829. /**
  87830. * Serializes this wood procedural texture
  87831. * @returns a serialized wood procedural texture object
  87832. */
  87833. serialize(): any;
  87834. /**
  87835. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87836. * @param parsedTexture defines parsed texture data
  87837. * @param scene defines the current scene
  87838. * @param rootUrl defines the root URL containing wood procedural texture information
  87839. * @returns a parsed Wood Procedural BABYLON.Texture
  87840. */
  87841. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87842. }
  87843. }